superstack-wallet-sdk 0.5.4 → 0.5.6

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/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,p,m=i(e),g=i(n),b=i(o),y=c(a);function w(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",exports.BorrowedAsset=void 0,(exports.BorrowedAsset||(exports.BorrowedAsset={})).HypercorePerpsUSDC="HypercorePerpsUSDC",exports.CollateralAsset=void 0,(exports.CollateralAsset||(exports.CollateralAsset={})).HypercoreSpotBTC="HypercoreSpotBTC",exports.CrossMarginPositionStatus=void 0,(h=exports.CrossMarginPositionStatus||(exports.CrossMarginPositionStatus={})).Open="Open",h.Closed="Closed",h.PartiallyLiquidated="PartiallyLiquidated",h.AllLiquidated="AllLiquidated",exports.CrossMarginOperationType=void 0,(p=exports.CrossMarginOperationType||(exports.CrossMarginOperationType={})).Borrow="Borrow",p.Repay="Repay",p.AddMargin="AddMargin",p.RemoveMargin="RemoveMargin",p.Liquidation="Liquidation";const v="embedded_wallet_state",x="superstack_wallet_type",E="superstack_backup_wallet_type",P="embedded_wallet_access_token",k="switched_account_address";class A{static saveState(e,t){const n={accessToken:e,socials:t,lastConnected:Date.now()};localStorage.setItem(v,JSON.stringify(n))}static saveAccessToken(e){localStorage.setItem(P,e)}static saveWalletType(e){localStorage.setItem(x,e)}static saveBackupWalletType(e){localStorage.setItem(E,e)}static saveSwitchedAccountAddress(e){localStorage.setItem(k,e)}static getWalletType(){return localStorage.getItem(x)}static getBackupWalletType(){return localStorage.getItem(E)}static getState(){try{const e=localStorage.getItem(v);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(v);if(!e)return null;return JSON.parse(e).socials}catch(e){return null}}static getAccessToken(){return localStorage.getItem(P)}static getSwitchedAccountAddress(){return localStorage.getItem(k)}static clear(){localStorage.removeItem(v),localStorage.removeItem(x),localStorage.removeItem(P),localStorage.removeItem(k)}static clearBackup(){localStorage.removeItem(E)}}function I(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S={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}(S);var N,T=I(S.exports);class B extends Error{constructor(e,t){super(e),this.error=t}}class C extends B{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class $ extends B{constructor(){super(...arguments),this.name="WalletConnectionError"}}class O extends B{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class _ extends B{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class R extends B{constructor(){super(...arguments),this.name="WalletAccountError"}}class z extends B{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class M extends B{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class L extends B{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class F extends B{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class U extends B{constructor(){super(...arguments),this.name="WalletSignMessageError"}}!function(e){e.Installed="Installed",e.NotDetected="NotDetected",e.Loadable="Loadable",e.Unsupported="Unsupported"}(N||(N={}));class j extends T{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){const r=this.publicKey;if(!r)throw new M;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}}function D(e){return"version"in e}class G extends j{async sendTransaction(e,t,n={}){let r=!0;try{if(D(e)){if(!this.supportedTransactionVersions)throw new L("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new L(`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 F)throw r=!1,e;throw new L(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 F)throw r=!1,e;throw new L(e?.message,e)}}catch(e){throw r&&this.emit("error",e),e}}async signAllTransactions(e){for(const t of e)if(D(t)){if(!this.supportedTransactionVersions)throw new F("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(t.version))throw new F(`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 q extends G{}class W extends q{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?N.Unsupported:N.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 O),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 z(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!==N.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=N.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=N.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===N.Installed&&await this.connect()}async connect(){var e;try{if(this.connected||this.connecting)return;if(this.readyState===N.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!==N.Installed)throw new C;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 $(null==e?void 0:e.message,e)}if(!n.publicKey)throw new R;let r;try{r=new t.PublicKey(n.publicKey.toBytes())}catch(e){throw new z(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 M;try{const{signers:o,...s}=n;D(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 B)throw e;throw new L(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 M;try{return await t.signTransaction(e)||e}catch(e){throw new F(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 M;try{return await t.signAllTransactions(e)||e}catch(e){throw new F(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 M;try{const{signature:n}=await t.signMessage(e);return n}catch(e){throw new U(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}}let V=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 H(e,t){const n=e.exec(t);return n?.groups}const Y=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,K=/^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)?$/,Z=/^\(.+?\).*?$/,J=/^tuple(?<array>(\[(\d*)\])*)$/;function Q(e){let t=e.type;if(J.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=Q(e.components[r]),r<n-1&&(t+=", ")}const r=H(J,e.type);return t+=`)${r?.array??""}`,Q({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function X(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=Q(e[r]),r!==n-1&&(t+=", ")}return t}function ee(e){return"function"===e.type?`function ${e.name}(${X(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${X(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${X(e.inputs)})`:"error"===e.type?`error ${e.name}(${X(e.inputs)})`:"constructor"===e.type?`constructor(${X(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const te=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const ne=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const re=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const oe=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function se(e){return oe.test(e)}function ae(e){return H(oe,e)}const ie=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const ce=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const ue=/^receive\(\) external payable$/;const le=new Set(["memory","indexed","storage","calldata"]),de=new Set(["indexed"]),fe=new Set(["calldata","memory","storage"]);class he extends V{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 pe extends V{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 me extends V{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 ge extends V{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 be extends V{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class ye extends V{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 we extends V{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 ve extends V{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 xe extends V{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 Ee extends V{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Pe extends V{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class ke extends V{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 Ae extends V{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 Ie extends V{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 Se=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 Ne(e,t={}){if(function(e){return re.test(e)}(e))return function(e,t={}){const n=function(e){return H(re,e)}(e);if(!n)throw new Ee({signature:e,type:"function"});const r=Oe(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push($e(r[e],{modifiers:fe,structs:t,type:"function"}));const a=[];if(n.returns){const e=Oe(n.returns),r=e.length;for(let n=0;n<r;n++)a.push($e(e[n],{modifiers:fe,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:o,outputs:a}}(e,t);if(function(e){return ne.test(e)}(e))return function(e,t={}){const n=function(e){return H(ne,e)}(e);if(!n)throw new Ee({signature:e,type:"event"});const r=Oe(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push($e(r[e],{modifiers:de,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:o}}(e,t);if(function(e){return te.test(e)}(e))return function(e,t={}){const n=function(e){return H(te,e)}(e);if(!n)throw new Ee({signature:e,type:"error"});const r=Oe(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push($e(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:o}}(e,t);if(function(e){return ie.test(e)}(e))return function(e,t={}){const n=function(e){return H(ie,e)}(e);if(!n)throw new Ee({signature:e,type:"constructor"});const r=Oe(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push($e(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:o}}(e,t);if(function(e){return ce.test(e)}(e))return function(e){const t=function(e){return H(ce,e)}(e);if(!t)throw new Ee({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return ue.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new Pe({signature:e})}const Te=/^(?<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$_]*))?$/,Be=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Ce=/^u?int$/;function $e(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(Se.has(n))return Se.get(n);const r=Z.test(e),o=H(r?Be:Te,e);if(!o)throw new be({param:e});if(o.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||Y.test(e)||K.test(e)||Re.test(e)}(o.name))throw new ye({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=Oe(o.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push($e(e[r],{structs:i}));u={components:t}}else if(o.type in i)c="tuple",u={components:i[o.type]};else if(Ce.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 me({type:c});if(o.modifier){if(!t?.modifiers?.has?.(o.modifier))throw new we({param:e,type:t?.type,modifier:o.modifier});if(fe.has(o.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!o.array))throw new ve({param:e,type:t?.type,modifier:o.modifier})}const l={type:`${c}${o.array??""}`,...s,...a,...u};return Se.set(n,l),l}function Oe(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?Oe(a,[...t,n.trim()]):Oe(a,t,`${n}${o}`,r);case"(":return Oe(a,t,`${n}${o}`,r+1);case")":return Oe(a,t,`${n}${o}`,r-1);default:return Oe(a,t,`${n}${o}`,r)}}if(""===n)return t;if(0!==r)throw new Ie({current:n,depth:r});return t.push(n.trim()),t}function _e(e){return"address"===e||"bool"===e||"function"===e||"string"===e||Y.test(e)||K.test(e)}const Re=/^(?: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 ze(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!se(n))continue;const o=ae(n);if(!o)throw new Ee({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=$e(t,{type:"struct"});a.push(n)}if(!a.length)throw new ke({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]=Le(s,t)}return r}const Me=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function Le(e,t,n=new Set){const r=[],o=e.length;for(let s=0;s<o;s++){const o=e[s];if(Z.test(o.type))r.push(o);else{const e=H(Me,o.type);if(!e?.type)throw new xe({abiParameter:o});const{array:s,type:a}=e;if(a in t){if(n.has(a))throw new Ae({type:a});r.push({...o,type:`tuple${s??""}`,components:Le(t[a]??[],t,new Set([...n,a]))})}else{if(!_e(a))throw new pe({type:a});r.push(o)}}}return r}function Fe(e){const t=ze(e),n=[],r=e.length;for(let o=0;o<r;o++){const r=e[o];se(r)||n.push(Ne(r,t))}return n}function Ue(e){let t;if("string"==typeof e)t=Ne(e);else{const n=ze(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(!se(r)){t=Ne(r,n);break}}}if(!t)throw new he({signature:e});return t}function je(e){const t=[];if("string"==typeof e){const n=Oe(e),r=n.length;for(let e=0;e<r;e++)t.push($e(n[e],{modifiers:le}))}else{const n=ze(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(se(r))continue;const s=Oe(r),a=s.length;for(let e=0;e<a;e++)t.push($e(s[e],{modifiers:le,structs:n}))}}if(0===t.length)throw new ge({params:e});return t}function De(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 Ge(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new xt(e.type);return`${e.name}(${qe(e.inputs,{includeName:t})})`}function qe(e,{includeName:t=!1}={}){return e?e.map(e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${qe(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t})).join(t?", ":","):""}function We(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function Ve(e){return We(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const He="2.37.8";let Ye=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,Ke=`viem@${He}`,Ze=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=Ye?.({...n,docsPath:o});super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...Ke?[`Version: ${Ke}`]:[]].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=He}walk(e){return Je(this,e)}};function Je(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?Je(e.cause,t):t?null:e}class Qe extends Ze{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 Xe extends Ze{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 et extends Ze{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${qe(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 tt extends Ze{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class nt extends Ze{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 rt extends Ze{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Ve(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class ot extends Ze{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 st extends Ze{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 at extends Ze{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 it extends Ze{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 ct extends Ze{constructor({docsPath:e}){super("Cannot extract event signature from empty topics.",{docsPath:e,name:"AbiEventSignatureEmptyTopicsError"})}}class ut extends Ze{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 lt extends Ze{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 dt extends Ze{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 ft extends Ze{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 ht extends Ze{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 pt extends Ze{constructor(e,t){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${Ge(e.abiItem)}\`, and`,`\`${t.type}\` in \`${Ge(t.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let mt=class extends Ze{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}};class gt extends Ze{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: (${qe(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 bt extends Ze{constructor({abiItem:e,param:t}){super([`Expected a topic for indexed event parameter${t.name?` "${t.name}"`:""} on event "${Ge(e,{includeName:!0})}".`].join("\n"),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=e}}class yt extends Ze{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 wt extends Ze{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 vt=class extends Ze{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}};class xt extends Ze{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class Et extends Ze{constructor(e){super(`Filter type "${e}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let Pt=class extends Ze{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},kt=class extends Ze{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 At extends Ze{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 It(e,{dir:t,size:n=32}={}){return"string"==typeof e?St(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new kt({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 St(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new kt({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}let Nt=class extends Ze{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"})}},Tt=class extends Ze{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 Bt extends Ze{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let Ct=class extends Ze{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function $t(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 Ot(e,{size:t}){if(Ve(e)>t)throw new Ct({givenSize:Ve(e),maxSize:t})}function _t(e,t={}){const{signed:n}=t;t.size&&Ot(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 Rt(e,t={}){return Number(_t(e,t))}const zt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Mt(e,t={}){return"number"==typeof e||"bigint"==typeof e?Ut(e,t):"string"==typeof e?Dt(e,t):"boolean"==typeof e?Lt(e,t):Ft(e,t)}function Lt(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(Ot(n,{size:t.size}),It(n,{size:t.size})):n}function Ft(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=zt[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(Ot(r,{size:t.size}),It(r,{dir:"right",size:t.size})):r}function Ut(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 Nt({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?It(i,{size:r}):i}const jt=new TextEncoder;function Dt(e,t={}){return Ft(jt.encode(e),t)}const Gt=new TextEncoder;function qt(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=Ut(e,t);return Ht(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return Ot(n,{size:t.size}),It(n,{size:t.size});return n}(e,t):We(e)?Ht(e,t):Yt(e,t)}const Wt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Vt(e){return e>=Wt.zero&&e<=Wt.nine?e-Wt.zero:e>=Wt.A&&e<=Wt.F?e-(Wt.A-10):e>=Wt.a&&e<=Wt.f?e-(Wt.a-10):void 0}function Ht(e,t={}){let n=e;t.size&&(Ot(n,{size:t.size}),n=It(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=Vt(r.charCodeAt(t++)),o=Vt(r.charCodeAt(t++));if(void 0===n||void 0===o)throw new Ze(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);s[e]=16*n+o}return s}function Yt(e,t={}){const n=Gt.encode(e);return"number"==typeof t.size?(Ot(n,{size:t.size}),It(n,{dir:"right",size:t.size})):n}const Kt=BigInt(2**32-1),Zt=BigInt(32);function Jt(e,t=!1){return t?{h:Number(e&Kt),l:Number(e>>Zt&Kt)}:{h:0|Number(e>>Zt&Kt),l:0|Number(e&Kt)}}const Qt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Xt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function en(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,p,m=i(e),g=i(n),b=i(o),y=c(a);function w(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",exports.BorrowedAsset=void 0,(exports.BorrowedAsset||(exports.BorrowedAsset={})).HypercorePerpsUSDC="HypercorePerpsUSDC",exports.CollateralAsset=void 0,(exports.CollateralAsset||(exports.CollateralAsset={})).HypercoreSpotBTC="HypercoreSpotBTC",exports.CrossMarginPositionStatus=void 0,(h=exports.CrossMarginPositionStatus||(exports.CrossMarginPositionStatus={})).Open="Open",h.Closed="Closed",h.PartiallyLiquidated="PartiallyLiquidated",h.AllLiquidated="AllLiquidated",exports.CrossMarginOperationType=void 0,(p=exports.CrossMarginOperationType||(exports.CrossMarginOperationType={})).Borrow="Borrow",p.Repay="Repay",p.AddMargin="AddMargin",p.RemoveMargin="RemoveMargin",p.Liquidation="Liquidation";const v="embedded_wallet_state",x="superstack_wallet_type",E="superstack_backup_wallet_type",P="embedded_wallet_access_token",k="switched_account_address",A="backup_wallet_info";class I{static saveState(e,t){const n={accessToken:e,socials:t,lastConnected:Date.now()};localStorage.setItem(v,JSON.stringify(n))}static saveAccessToken(e){localStorage.setItem(P,e)}static saveWalletType(e){localStorage.setItem(x,e)}static saveBackupWalletType(e){localStorage.setItem(E,e)}static saveSwitchedAccountAddress(e){localStorage.setItem(k,e)}static saveBackupWalletInfo(e){localStorage.setItem(A,JSON.stringify(e))}static getWalletType(){return localStorage.getItem(x)}static getBackupWalletType(){return localStorage.getItem(E)}static getState(){try{const e=localStorage.getItem(v);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(v);if(!e)return null;return JSON.parse(e).socials}catch(e){return null}}static getAccessToken(){return localStorage.getItem(P)}static getSwitchedAccountAddress(){return localStorage.getItem(k)}static getBackupWalletInfo(){try{const e=localStorage.getItem(A);return e?JSON.parse(e):null}catch(e){return null}}static clear(){localStorage.removeItem(v),localStorage.removeItem(x),localStorage.removeItem(P),localStorage.removeItem(k),localStorage.removeItem(E)}static clearBackup(){localStorage.removeItem(E),localStorage.removeItem(A)}}function S(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var N={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}(N);var T,B=S(N.exports);class C extends Error{constructor(e,t){super(e),this.error=t}}class $ extends C{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class O extends C{constructor(){super(...arguments),this.name="WalletConnectionError"}}class _ extends C{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class R extends C{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class z extends C{constructor(){super(...arguments),this.name="WalletAccountError"}}class M extends C{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class L extends C{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class F extends C{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class U extends C{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class j extends C{constructor(){super(...arguments),this.name="WalletSignMessageError"}}!function(e){e.Installed="Installed",e.NotDetected="NotDetected",e.Loadable="Loadable",e.Unsupported="Unsupported"}(T||(T={}));class D extends B{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){const r=this.publicKey;if(!r)throw new L;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}}function G(e){return"version"in e}class W extends D{async sendTransaction(e,t,n={}){let r=!0;try{if(G(e)){if(!this.supportedTransactionVersions)throw new F("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new F(`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 U)throw r=!1,e;throw new F(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 U)throw r=!1,e;throw new F(e?.message,e)}}catch(e){throw r&&this.emit("error",e),e}}async signAllTransactions(e){for(const t of e)if(G(t)){if(!this.supportedTransactionVersions)throw new U("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(t.version))throw new U(`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 q extends W{}class V extends q{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?T.Unsupported:T.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 M(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!==T.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=T.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=T.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===T.Installed&&await this.connect()}async connect(){var e;try{if(this.connected||this.connecting)return;if(this.readyState===T.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!==T.Installed)throw new $;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 O(null==e?void 0:e.message,e)}if(!n.publicKey)throw new z;let r;try{r=new t.PublicKey(n.publicKey.toBytes())}catch(e){throw new M(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 R(null==e?void 0:e.message,e))}}this.emit("disconnect")}async sendTransaction(e,t,n={}){try{const r=this._wallet;if(!r)throw new L;try{const{signers:o,...s}=n;G(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 C)throw e;throw new F(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 L;try{return await t.signTransaction(e)||e}catch(e){throw new U(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 L;try{return await t.signAllTransactions(e)||e}catch(e){throw new U(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 L;try{const{signature:n}=await t.signMessage(e);return n}catch(e){throw new j(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}}let H=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 Y(e,t){const n=e.exec(t);return n?.groups}const K=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Z=/^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)?$/,J=/^\(.+?\).*?$/,Q=/^tuple(?<array>(\[(\d*)\])*)$/;function X(e){let t=e.type;if(Q.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=X(e.components[r]),r<n-1&&(t+=", ")}const r=Y(Q,e.type);return t+=`)${r?.array??""}`,X({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function ee(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=X(e[r]),r!==n-1&&(t+=", ")}return t}function te(e){return"function"===e.type?`function ${e.name}(${ee(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${ee(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${ee(e.inputs)})`:"error"===e.type?`error ${e.name}(${ee(e.inputs)})`:"constructor"===e.type?`constructor(${ee(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const ne=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const re=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const oe=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const se=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function ae(e){return se.test(e)}function ie(e){return Y(se,e)}const ce=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const ue=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const le=/^receive\(\) external payable$/;const de=new Set(["memory","indexed","storage","calldata"]),fe=new Set(["indexed"]),he=new Set(["calldata","memory","storage"]);class pe extends H{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 me extends H{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 ge extends H{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 be extends H{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 ye extends H{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class we extends H{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 ve extends H{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 xe extends H{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 Ee extends H{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 Pe extends H{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class ke extends H{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Ae extends H{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 Ie extends H{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 Se extends H{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 Ne=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 Te(e,t={}){if(function(e){return oe.test(e)}(e))return function(e,t={}){const n=function(e){return Y(oe,e)}(e);if(!n)throw new Pe({signature:e,type:"function"});const r=_e(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Oe(r[e],{modifiers:he,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(Oe(e[n],{modifiers:he,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:o,outputs:a}}(e,t);if(function(e){return re.test(e)}(e))return function(e,t={}){const n=function(e){return Y(re,e)}(e);if(!n)throw new Pe({signature:e,type:"event"});const r=_e(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Oe(r[e],{modifiers:fe,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:o}}(e,t);if(function(e){return ne.test(e)}(e))return function(e,t={}){const n=function(e){return Y(ne,e)}(e);if(!n)throw new Pe({signature:e,type:"error"});const r=_e(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Oe(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:o}}(e,t);if(function(e){return ce.test(e)}(e))return function(e,t={}){const n=function(e){return Y(ce,e)}(e);if(!n)throw new Pe({signature:e,type:"constructor"});const r=_e(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Oe(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:o}}(e,t);if(function(e){return ue.test(e)}(e))return function(e){const t=function(e){return Y(ue,e)}(e);if(!t)throw new Pe({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return le.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new ke({signature:e})}const Be=/^(?<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$_]*))?$/,Ce=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,$e=/^u?int$/;function Oe(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(Ne.has(n))return Ne.get(n);const r=J.test(e),o=Y(r?Ce:Be,e);if(!o)throw new ye({param:e});if(o.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||K.test(e)||Z.test(e)||ze.test(e)}(o.name))throw new we({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(Oe(e[r],{structs:i}));u={components:t}}else if(o.type in i)c="tuple",u={components:i[o.type]};else if($e.test(o.type))c=`${o.type}256`;else if("address payable"===o.type)c="address";else if(c=o.type,"struct"!==t?.type&&!Re(c))throw new ge({type:c});if(o.modifier){if(!t?.modifiers?.has?.(o.modifier))throw new ve({param:e,type:t?.type,modifier:o.modifier});if(he.has(o.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!o.array))throw new xe({param:e,type:t?.type,modifier:o.modifier})}const l={type:`${c}${o.array??""}`,...s,...a,...u};return Ne.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 Se({current:n,depth:r});return t.push(n.trim()),t}function Re(e){return"address"===e||"bool"===e||"function"===e||"string"===e||K.test(e)||Z.test(e)}const ze=/^(?: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 Me(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!ae(n))continue;const o=ie(n);if(!o)throw new Pe({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=Oe(t,{type:"struct"});a.push(n)}if(!a.length)throw new Ae({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]=Fe(s,t)}return r}const Le=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function Fe(e,t,n=new Set){const r=[],o=e.length;for(let s=0;s<o;s++){const o=e[s];if(J.test(o.type))r.push(o);else{const e=Y(Le,o.type);if(!e?.type)throw new Ee({abiParameter:o});const{array:s,type:a}=e;if(a in t){if(n.has(a))throw new Ie({type:a});r.push({...o,type:`tuple${s??""}`,components:Fe(t[a]??[],t,new Set([...n,a]))})}else{if(!Re(a))throw new me({type:a});r.push(o)}}}return r}function Ue(e){const t=Me(e),n=[],r=e.length;for(let o=0;o<r;o++){const r=e[o];ae(r)||n.push(Te(r,t))}return n}function je(e){let t;if("string"==typeof e)t=Te(e);else{const n=Me(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(!ae(r)){t=Te(r,n);break}}}if(!t)throw new pe({signature:e});return t}function De(e){const t=[];if("string"==typeof e){const n=_e(e),r=n.length;for(let e=0;e<r;e++)t.push(Oe(n[e],{modifiers:de}))}else{const n=Me(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(ae(r))continue;const s=_e(r),a=s.length;for(let e=0;e<a;e++)t.push(Oe(s[e],{modifiers:de,structs:n}))}}if(0===t.length)throw new be({params:e});return t}function Ge(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 We(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new Et(e.type);return`${e.name}(${qe(e.inputs,{includeName:t})})`}function qe(e,{includeName:t=!1}={}){return e?e.map(e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${qe(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t})).join(t?", ":","):""}function Ve(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function He(e){return Ve(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Ye="2.37.8";let Ke=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,Ze=`viem@${Ye}`,Je=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=Ke?.({...n,docsPath:o});super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...Ze?[`Version: ${Ze}`]:[]].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=Ye}walk(e){return Qe(this,e)}};function Qe(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?Qe(e.cause,t):t?null:e}class Xe extends Je{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 et extends Je{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 tt extends Je{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${qe(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 nt extends Je{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class rt extends Je{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 ot extends Je{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${He(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class st extends Je{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 at extends Je{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 it extends Je{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 ct extends Je{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 ut extends Je{constructor({docsPath:e}){super("Cannot extract event signature from empty topics.",{docsPath:e,name:"AbiEventSignatureEmptyTopicsError"})}}class lt extends Je{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 dt extends Je{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 ft extends Je{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 ht extends Je{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 pt extends Je{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 mt extends Je{constructor(e,t){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${We(e.abiItem)}\`, and`,`\`${t.type}\` in \`${We(t.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let gt=class extends Je{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}};class bt extends Je{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: (${qe(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 yt extends Je{constructor({abiItem:e,param:t}){super([`Expected a topic for indexed event parameter${t.name?` "${t.name}"`:""} on event "${We(e,{includeName:!0})}".`].join("\n"),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=e}}class wt extends Je{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 vt extends Je{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 xt=class extends Je{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}};class Et extends Je{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class Pt extends Je{constructor(e){super(`Filter type "${e}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let kt=class extends Je{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},At=class extends Je{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 It extends Je{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 St(e,{dir:t,size:n=32}={}){return"string"==typeof e?Nt(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new At({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 Nt(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new At({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}let Tt=class extends Je{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"})}},Bt=class extends Je{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 Ct extends Je{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let $t=class extends Je{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Ot(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(He(e)>t)throw new $t({givenSize:He(e),maxSize:t})}function Rt(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 zt(e,t={}){return Number(Rt(e,t))}const Mt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Lt(e,t={}){return"number"==typeof e||"bigint"==typeof e?jt(e,t):"string"==typeof e?Gt(e,t):"boolean"==typeof e?Ft(e,t):Ut(e,t)}function Ft(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(_t(n,{size:t.size}),St(n,{size:t.size})):n}function Ut(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Mt[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(_t(r,{size:t.size}),St(r,{dir:"right",size:t.size})):r}function jt(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 Tt({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?St(i,{size:r}):i}const Dt=new TextEncoder;function Gt(e,t={}){return Ut(Dt.encode(e),t)}const Wt=new TextEncoder;function qt(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=jt(e,t);return Yt(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}),St(n,{size:t.size});return n}(e,t):Ve(e)?Yt(e,t):Kt(e,t)}const Vt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ht(e){return e>=Vt.zero&&e<=Vt.nine?e-Vt.zero:e>=Vt.A&&e<=Vt.F?e-(Vt.A-10):e>=Vt.a&&e<=Vt.f?e-(Vt.a-10):void 0}function Yt(e,t={}){let n=e;t.size&&(_t(n,{size:t.size}),n=St(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=Ht(r.charCodeAt(t++)),o=Ht(r.charCodeAt(t++));if(void 0===n||void 0===o)throw new Je(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);s[e]=16*n+o}return s}function Kt(e,t={}){const n=Wt.encode(e);return"number"==typeof t.size?(_t(n,{size:t.size}),St(n,{dir:"right",size:t.size})):n}const Zt=BigInt(2**32-1),Jt=BigInt(32);function Qt(e,t=!1){return t?{h:Number(e&Zt),l:Number(e>>Jt&Zt)}:{h:0|Number(e>>Jt&Zt),l:0|Number(e&Zt)}}const Xt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function en(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function tn(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 tn(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 nn(e,t){en(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function rn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function on(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function sn(e,t){return e<<32-t|e>>>t}function an(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const cn=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=an(e[t]);return e};function un(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)),en(e),e}class ln{}function dn(e){const t=t=>e().update(un(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function fn(e=32){if(Qt&&"function"==typeof Qt.getRandomValues)return Qt.getRandomValues(new Uint8Array(e));if(Qt&&"function"==typeof Qt.randomBytes)return Uint8Array.from(Qt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const hn=BigInt(0),pn=BigInt(1),mn=BigInt(2),gn=BigInt(7),bn=BigInt(256),yn=BigInt(113),wn=[],vn=[],xn=[];for(let e=0,t=pn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],wn.push(2*(5*r+n)),vn.push((e+1)*(e+2)/2%64);let o=hn;for(let e=0;e<7;e++)t=(t<<pn^(t>>gn)*yn)%bn,t&mn&&(o^=pn<<(pn<<BigInt(e))-pn);xn.push(o)}const En=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}=Jt(e[s],t);[r[s],o[s]]=[n,a]}return[r,o]}(xn,!0),Pn=En[0],kn=En[1],An=(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),In=(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 Sn extends ln{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,Xt(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(){cn(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=An(s,a,1)^n[r],c=In(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=vn[n],s=An(t,o,r),a=In(t,o,r),i=wn[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]^=Pn[r],e[1]^=kn[r]}rn(n)}(this.state32,this.rounds),cn(this.state32),this.posOut=0,this.pos=0}update(e){tn(this),en(e=un(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){tn(this,!1),en(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 Xt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(nn(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,rn(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:o,enableXOF:s}=this;return e||(e=new Sn(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 Nn=(()=>{return e=1,t=136,n=32,dn(()=>new Sn(t,e,n));var e,t,n})();function Tn(e,t){const n=t||"hex",r=Nn(We(e,{strict:!1})?qt(e):e);return"bytes"===n?r:Mt(r)}function Bn(e){return Tn(qt(e))}const Cn=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 Ze("Unable to normalize signature.");return o}("string"==typeof e?e:ee(e));function $n(e){return Bn(Cn(e))}const On=$n;let _n=class extends Ze{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"})}},Rn=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 zn=new Rn(8192);function Mn(e,t){if(zn.has(`${e}.${t}`))return zn.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=Tn(Yt(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 zn.set(`${e}.${t}`,s),s}function Ln(e,t){if(!jn(e,{strict:!1}))throw new _n({address:e});return Mn(e,t)}const Fn=/^0x[a-fA-F0-9]{40}$/,Un=new Rn(8192);function jn(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Un.has(r))return Un.get(r);const o=!(!Fn.test(e)||e.toLowerCase()!==e&&n&&Mn(e)!==e);return Un.set(r,o),o}function Dn(e){return"string"==typeof e[0]?Gn(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 Gn(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function qn(e,t,n,{strict:r}={}){return We(e,{strict:!1})?function(e,t,n,{strict:r}={}){Wn(e,t);const o=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;r&&Vn(o,t,n);return o}(e,t,n,{strict:r}):Hn(e,t,n,{strict:r})}function Wn(e,t){if("number"==typeof t&&t>0&&t>Ve(e)-1)throw new Pt({offset:t,position:"start",size:Ve(e)})}function Vn(e,t,n){if("number"==typeof t&&"number"==typeof n&&Ve(e)!==n-t)throw new Pt({offset:n,position:"end",size:Ve(e)})}function Hn(e,t,n,{strict:r}={}){Wn(e,t);const o=e.slice(t,n);return r&&Vn(o,t,n),o}const Yn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Kn=/^(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 Zn(e,t){if(e.length!==t.length)throw new ot({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(Jn({param:e[r],value:t[r]}));return n}({params:e,values:t}),r=Qn(n);return 0===r.length?"0x":r}function Jn({param:e,value:t}){const n=Xn(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 vt(e);if(!r&&e.length!==t)throw new nt({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let o=!1;const s=[];for(let t=0;t<e.length;t++){const r=Jn({param:n,value:e[t]});r.dynamic&&(o=!0),s.push(r)}if(r||o){const e=Qn(s);if(r){const t=Ut(s.length,{size:32});return{dynamic:!0,encoded:s.length>0?Dn([t,e]):t}}if(o)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Dn(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=Jn({param:s,value:e[Array.isArray(e)?o:s.name]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?Qn(r):Dn(r.map(({encoded:e})=>e))}}(t,{param:e});if("address"===e.type)return function(e){if(!jn(e))throw new _n({address:e});return{dynamic:!1,encoded:St(e.toLowerCase())}}(t);if("bool"===e.type)return function(e){if("boolean"!=typeof e)throw new Ze(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:St(Lt(e))}}(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const n=e.type.startsWith("int"),[,,r="256"]=Kn.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 Nt({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Ut(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=Ve(e);if(!n){let t=e;return r%32!=0&&(t=St(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:Dn([St(Ut(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new rt({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:St(e,{dir:"right"})}}(t,{param:e});if("string"===e.type)return function(e){const t=Dt(e),n=Math.ceil(Ve(t)/32),r=[];for(let e=0;e<n;e++)r.push(St(qn(t,32*e,32*(e+1)),{dir:"right"}));return{dynamic:!0,encoded:Dn([St(Ut(Ve(t),{size:32})),...r])}}(t);throw new yt(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function Qn(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:Ve(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(Ut(t+o,{size:32})),r.push(i),o+=Ve(i)):n.push(i)}return Dn([...n,...r])}function Xn(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const er=e=>qn($n(e),0,4);function tr(e){const{abi:t,args:n=[],name:r}=e,o=We(r,{strict:!1}),s=t.filter(e=>o?"function"===e.type?er(e)===r:"event"===e.type&&On(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&&nr(t,r)});if(t){if(a&&"inputs"in a&&a.inputs){const t=rr(e.inputs,a.inputs,n);if(t)throw new pt({abiItem:e,type:t[0]},{abiItem:a,type:t[1]})}a=e}}return a||s[0]}function nr(e,t){const n=typeof e,r=t.type;switch(r){case"address":return jn(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)=>nr(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=>nr(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function rr(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 rr(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")))&&jn(n[r],{strict:!1}))())return a}}const or="/docs/contract/encodeEventTopics";function sr(e){const{abi:t,eventName:n,args:r}=e;let o=t[0];if(n){const e=tr({abi:t,name:n});if(!e)throw new lt(n,{docsPath:or});o=e}if("event"!==o.type)throw new lt(void 0,{docsPath:or});const s=Ge(o),a=On(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)=>ar({param:e,value:t[n][o]})):void 0!==t[n]&&null!==t[n]?ar({param:e,value:t[n]}):null)??[])}return[a,...i]}function ar({param:e,value:t}){if("string"===e.type||"bytes"===e.type)return Tn(qt(t));if("tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))throw new Et(e.type);return Zn([e],[t])}function ir(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 cr(e,t){const{address:n,abi:r,args:o,eventName:s,fromBlock:a,strict:i,toBlock:c}=t,u=ir(e,{method:"eth_newFilter"}),l=s?sr({abi:r,args:o,eventName:s}):void 0,d=await e.request({method:"eth_newFilter",params:[{address:n,fromBlock:"bigint"==typeof a?Ut(a):a,toBlock:"bigint"==typeof c?Ut(c):c,topics:l}]});return{abi:r,args:o,eventName:s,id:d,request:u(d),strict:Boolean(i),type:"event"}}function ur(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const lr="/docs/contract/encodeFunctionData";function dr(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=tr({abi:t,args:n,name:r});if(!e)throw new dt(r,{docsPath:lr});o=e}if("function"!==o.type)throw new dt(void 0,{docsPath:lr});return{abi:[o],functionName:er(Ge(o))}}(e),o=n[0];return Gn([r,("inputs"in o&&o.inputs?Zn(o.inputs,t??[]):void 0)??"0x"])}const fr={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."},hr={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},pr={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};let mr=class extends Ze{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}},gr=class extends Ze{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}},br=class extends Ze{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}};const yr={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 br({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new gr({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new mr({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 mr({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 wr(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(yr);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function vr(e,t={}){void 0!==t.size&&Ot(e,{size:t.size});return _t(Ft(e,t),t)}function xr(e,t={}){let n=e;if(void 0!==t.size&&(Ot(n,{size:t.size}),n=$t(n)),n.length>1||n[0]>1)throw new Tt(n);return Boolean(n[0])}function Er(e,t={}){void 0!==t.size&&Ot(e,{size:t.size});return Rt(Ft(e,t),t)}function Pr(e,t){const n="string"==typeof t?Ht(t):t,r=wr(n);if(0===Ve(n)&&e.length>0)throw new tt;if(Ve(t)&&Ve(t)<32)throw new et({data:"string"==typeof t?t:Ft(t),params:e,size:Ve(t)});let o=0;const s=[];for(let t=0;t<e.length;++t){const n=e[t];r.setPosition(o);const[a,i]=kr(r,n,{staticPosition:0});o+=i,s.push(a)}return s}function kr(e,t,{staticPosition:n}){const r=Xn(t.type);if(r){const[o,s]=r;return function(e,t,{length:n,staticPosition:r}){if(!n){const n=r+Er(e.readBytes(Ir)),o=n+Ar;e.setPosition(n);const s=Er(e.readBytes(Ar)),a=Sr(t);let i=0;const c=[];for(let n=0;n<s;++n){e.setPosition(o+(a?32*n:i));const[r,s]=kr(e,t,{staticPosition:o});i+=s,c.push(r)}return e.setPosition(r+32),[c,32]}if(Sr(t)){const o=r+Er(e.readBytes(Ir)),s=[];for(let r=0;r<n;++r){e.setPosition(o+32*r);const[n]=kr(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]=kr(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(Sr(t)){const a=n+Er(e.readBytes(Ir));for(let n=0;n<t.components.length;++n){const i=t.components[n];e.setPosition(a+s);const[c,u]=kr(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]=kr(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[Mn(Ft(Hn(t,-20))),32]}(e);if("bool"===t.type)return function(e){return[xr(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=Er(e.readBytes(32));e.setPosition(n+t);const r=Er(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[Ft(o),32]}const s=Ft(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?vr(o,{signed:n}):Er(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=Er(e.readBytes(32)),r=t+n;e.setPosition(r);const o=Er(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&&(Ot(n,{size:t.size}),n=$t(n,{dir:"right"})),(new TextDecoder).decode(n)}($t(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:n});throw new wt(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Ar=32,Ir=32;function Sr(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(Sr);const n=Xn(e.type);return!(!n||!Sr({...e,type:n[1]}))}function Nr(e){const{abi:t,data:n}=e,r=qn(n,0,4);if("0x"===r)throw new tt;const o=[...t||[],hr,pr].find(e=>"error"===e.type&&r===er(Ge(e)));if(!o)throw new it(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:o,args:"inputs"in o&&o.inputs&&o.inputs.length>0?Pr(o.inputs,qn(n,4)):void 0,errorName:o.name}}const Tr=(e,t,n)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,n);function Br({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]?Tr(t[n]):t[n]}`).join(", ")})`}const Cr={gwei:9,wei:18},$r={ether:-9,wei:9};function Or(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 Or(e,Cr[t])}function Rr(e,t="wei"){return Or(e,$r[t])}class zr extends Ze{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class Mr extends Ze{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Lr(e){return e.reduce((e,{slot:t,value:n})=>`${e} ${t}: ${n}\n`,"")}function Fr(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 Ur extends Ze{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 jr extends Ze{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Fr(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 Dr extends Ze{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 Gr extends Ze{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 qr extends Ze{constructor({hash:e}){super(`Timed out while waiting for transaction with hash "${e}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}class Wr extends Ze{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?ur(t):void 0;let p=Fr({from:h?.address,to:l,value:void 0!==d&&`${_r(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${Rr(a)} gwei`,maxFeePerGas:void 0!==i&&`${Rr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Rr(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+=Lr(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=Lr(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 Vr extends Ze{constructor(e,{abi:t,args:n,contractAddress:r,docsPath:o,functionName:s,sender:a}){const i=tr({abi:t,args:n,name:s}),c=i?Br({abiItem:i,args:n,includeFunctionName:!1,includeName:!1}):void 0,u=Fr({address:r&&r,function:i?Ge(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 Hr extends Ze{constructor({abi:e,data:t,functionName:n,message:r}){let o,s,a,i,c;if(t&&"0x"!==t)try{s=Nr({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=fr[e]}else{const e=n?Ge(n,{includeName:!0}):void 0,t=n&&o?Br({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 it&&(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 Yr extends Ze{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 Kr extends Ze{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 Zr extends Ze{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 Jr extends Ze{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: ${Tr(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 Qr extends Ze{constructor({body:e,error:t,url:n}){super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${n}`,`Request body: ${Tr(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 Xr extends Ze{constructor({body:e,url:t}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${t}`,`Request body: ${Tr(e)}`],name:"TimeoutError"})}}class eo extends Ze{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 Qr?e.code:t??-1}}class to extends eo{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class no extends eo{constructor(e){super(e,{code:no.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(no,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class ro extends eo{constructor(e){super(e,{code:ro.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(ro,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class oo extends eo{constructor(e,{method:t}={}){super(e,{code:oo.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(oo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class so extends eo{constructor(e){super(e,{code:so.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(so,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class ao extends eo{constructor(e){super(e,{code:ao.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(ao,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class io extends eo{constructor(e){super(e,{code:io.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(io,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class co extends eo{constructor(e){super(e,{code:co.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(co,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class uo extends eo{constructor(e){super(e,{code:uo.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(uo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class lo extends eo{constructor(e){super(e,{code:lo.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(lo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class fo extends eo{constructor(e,{method:t}={}){super(e,{code:fo.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not supported.`})}}Object.defineProperty(fo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class ho extends eo{constructor(e){super(e,{code:ho.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(ho,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class po extends eo{constructor(e){super(e,{code:po.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(po,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class mo extends to{constructor(e){super(e,{code:mo.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(mo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class go extends to{constructor(e){super(e,{code:go.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(go,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class bo extends to{constructor(e,{method:t}={}){super(e,{code:bo.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(bo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class yo extends to{constructor(e){super(e,{code:yo.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(yo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class wo extends to{constructor(e){super(e,{code:wo.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(wo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class vo extends to{constructor(e){super(e,{code:vo.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(vo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class xo extends to{constructor(e){super(e,{code:xo.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(xo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Eo extends to{constructor(e){super(e,{code:Eo.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Eo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class Po extends to{constructor(e){super(e,{code:Po.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(Po,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class ko extends to{constructor(e){super(e,{code:ko.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(ko,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Ao extends to{constructor(e){super(e,{code:Ao.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Ao,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Io extends to{constructor(e){super(e,{code:Io.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Io,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class So extends to{constructor(e){super(e,{code:So.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(So,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class No extends eo{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const To=3;function Bo(e,{abi:t,address:n,args:r,docsPath:o,functionName:s,sender:a}){const i=e instanceof Zr?e:e instanceof Ze?e.walk(e=>"data"in e)||e.walk():{},{code:c,data:u,details:l,message:d,shortMessage:f}=i,h=e instanceof tt?new Yr({functionName:s}):[To,ao.code].includes(c)&&(u||l||d||f)?new Hr({abi:t,data:"object"==typeof u?u.data:u,functionName:s,message:i instanceof Qr?l:f??d}):e;return new Vr(h,{abi:t,args:r,contractAddress:n,docsPath:o,functionName:s,sender:a})}function Co(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 $o({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=We(e)?e:Mt(e),{secp256k1:r}=await Promise.resolve().then(function(){return Ql}),o=(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:n,v:o,yParity:s}=t,a=Co(Number(s??o));return new r.Signature(_t(e),_t(n)).addRecoveryBit(a)}const e=We(t)?t:Mt(t);if(65!==Ve(e))throw new Error("invalid signature length");const n=Co(Rt(`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}),Mn(`0x${Tn(`0x${n.substring(4)}`).substring(26)}`);var n}function Oo(e,t="hex"){const n=_o(e),r=wr(new Uint8Array(n.length));return n.encode(r),"hex"===t?Ft(r.bytes):r.bytes}function _o(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),n=Ro(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?Ht(e):e,n=Ro(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 Ro(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 Ze("Length is too large.")}function zo(e){const{chainId:t,nonce:n,to:r}=e,o=e.contractAddress??e.address,s=Tn(Gn(["0x05",Oo([t?Ut(t):"0x",o,n?Ut(n):"0x"])]));return"bytes"===r?Ht(s):s}async function Mo(e){const{authorization:t,signature:n}=e;return $o({hash:zo(t),signature:n??t})}class Lo extends Ze{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=Fr({from:t?.address,to:l,value:void 0!==d&&`${_r(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${Rr(a)} gwei`,maxFeePerGas:void 0!==i&&`${Rr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Rr(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 Fo extends Ze{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(Fo,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Fo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Uo extends Ze{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Rr(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Uo,"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 jo extends Ze{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Rr(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(jo,"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 Do extends Ze{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(Do,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Go extends Ze{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(Go,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class qo extends Ze{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(qo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Wo extends Ze{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(Wo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Vo extends Ze{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(Vo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Ho extends Ze{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(Ho,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Yo extends Ze{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Yo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Ko extends Ze{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${Rr(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Rr(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Ko,"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 Zo extends Ze{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Jo(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof Ze?e.walk(e=>e?.code===Fo.code):e;return r instanceof Ze?new Fo({cause:e,message:r.details}):Fo.nodeMessage.test(n)?new Fo({cause:e,message:e.details}):Uo.nodeMessage.test(n)?new Uo({cause:e,maxFeePerGas:t?.maxFeePerGas}):jo.nodeMessage.test(n)?new jo({cause:e,maxFeePerGas:t?.maxFeePerGas}):Do.nodeMessage.test(n)?new Do({cause:e,nonce:t?.nonce}):Go.nodeMessage.test(n)?new Go({cause:e,nonce:t?.nonce}):qo.nodeMessage.test(n)?new qo({cause:e,nonce:t?.nonce}):Wo.nodeMessage.test(n)?new Wo({cause:e}):Vo.nodeMessage.test(n)?new Vo({cause:e,gas:t?.gas}):Ho.nodeMessage.test(n)?new Ho({cause:e,gas:t?.gas}):Yo.nodeMessage.test(n)?new Yo({cause:e}):Ko.nodeMessage.test(n)?new Ko({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new Zo({cause:e})}function Qo(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 Xo={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function es(e){const t={};return void 0!==e.authorizationList&&(t.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?Ut(BigInt(e.r)):e.r,s:e.s?Ut(BigInt(e.s)):e.s,chainId:Ut(e.chainId),nonce:Ut(e.nonce),...void 0!==e.yParity?{yParity:Ut(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:Ut(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=>Ft(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=Ut(e.gas)),void 0!==e.gasPrice&&(t.gasPrice=Ut(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(t.maxFeePerBlobGas=Ut(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=Ut(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=Ut(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=Ut(e.nonce)),void 0!==e.to&&(t.to=e.to),void 0!==e.type&&(t.type=Xo[e.type]),void 0!==e.value&&(t.value=Ut(e.value)),t}function ts(e){if(e&&0!==e.length)return e.reduce((e,{slot:t,value:n})=>{if(66!==t.length)throw new At({size:t.length,targetSize:66,type:"hex"});if(66!==n.length)throw new At({size:n.length,targetSize:66,type:"hex"});return e[t]=n,e},{})}function ns(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=Ut(t)),void 0!==n&&(a.nonce=Ut(n)),void 0!==r&&(a.state=ts(r)),void 0!==o){if(a.state)throw new Mr;a.stateDiff=ts(o)}return a}function rs(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!jn(n,{strict:!1}))throw new _n({address:n});if(t[n])throw new zr({address:n});t[n]=ns(r)}return t}const os=2n**256n-1n;function ss(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:o,to:s}=e,a=t?ur(t):void 0;if(a&&!jn(a.address))throw new _n({address:a.address});if(s&&!jn(s))throw new _n({address:s});if(void 0!==n&&(void 0!==r||void 0!==o))throw new Ur;if(r&&r>os)throw new Uo({maxFeePerGas:r});if(o&&r&&o>r)throw new Ko({maxFeePerGas:r,maxPriorityFeePerGas:o})}class as extends Ze{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class is extends Ze{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class cs extends Ze{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Rr(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class us extends Ze{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 ls={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ds(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Rt(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?Rt(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?ls[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 fs(e){const t=(e.transactions??[]).map(e=>"string"==typeof e?e:ds(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 hs(e,{blockHash:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",includeTransactions:o}={}){const s=o??!1,a=void 0!==n?Ut(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 us({blockHash:t,blockNumber:n});return(e.chain?.formatters?.block?.format||fs)(i)}async function ps(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function ms(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 De(e,hs,"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):De(e,hs,"getBlock")({}),De(e,ps,"getGasPrice")({})]);if("bigint"!=typeof t.baseFeePerGas)throw new is;const o=r-t.baseFeePerGas;return o<0n?0n:o}}async function gs(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 as;const i=10**(a.toString().split(".")[1]?.length??0),c=e=>e*BigInt(Math.ceil(a*i))/BigInt(i),u=n||await De(e,hs,"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 is;const t="bigint"==typeof o?.maxPriorityFeePerGas?o.maxPriorityFeePerGas:await ms(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 De(e,ps,"getGasPrice")({}))}}async function bs(e,{address:t,blockTag:n="latest",blockNumber:r}){return Rt(await e.request({method:"eth_getTransactionCount",params:[t,"bigint"==typeof r?Ut(r):n]},{dedupe:Boolean(r)}))}function ys(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=>Ht(e)):e.blobs,o=[];for(const e of r)o.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?o:o.map(e=>Ft(e))}function ws(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=>Ht(e)):e.blobs,o="string"==typeof e.commitments[0]?e.commitments.map(e=>Ht(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=>Ft(e))}function vs(e,t,n){return e&t^~e&n}function xs(e,t,n){return e&t^e&n^t&n}class Es extends ln{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=on(this.buffer)}update(e){tn(this),en(e=un(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=on(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){tn(this),nn(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,rn(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=on(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 Ps=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ks=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]),As=new Uint32Array(64);class Is extends Es{constructor(e=32){super(64,e,8,!1),this.A=0|Ps[0],this.B=0|Ps[1],this.C=0|Ps[2],this.D=0|Ps[3],this.E=0|Ps[4],this.F=0|Ps[5],this.G=0|Ps[6],this.H=0|Ps[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)As[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=As[e-15],n=As[e-2],r=sn(t,7)^sn(t,18)^t>>>3,o=sn(n,17)^sn(n,19)^n>>>10;As[e]=o+As[e-7]+r+As[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+(sn(a,6)^sn(a,11)^sn(a,25))+vs(a,i,c)+ks[e]+As[e]|0,l=(sn(n,2)^sn(n,13)^sn(n,22))+xs(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(){rn(As)}destroy(){this.set(0,0,0,0,0,0,0,0),rn(this.buffer)}}const Ss=dn(()=>new Is),Ns=Ss;function Ts(e){const{commitment:t,version:n=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),o=Ns(We(s=t,{strict:!1})?qt(s):s);var s;return o.set([n],0),"bytes"===r?o:Ft(o)}const Bs=4096,Cs=131072,$s=761855;class Os extends Ze{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class _s extends Ze{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Rs(e){const{data:t,kzg:n,to:r}=e,o=e.blobs??function(e){const t="string"==typeof e.data?Ht(e.data):e.data,n=Ve(t);if(!n)throw new _s;if(n>$s)throw new Os({maxSize:$s,size:n});const r=[];let o=!0,s=0;for(;o;){const e=wr(new Uint8Array(Cs));let n=0;for(;n<Bs;){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=>Ft(e.bytes))}({data:t}),s=e.commitments??ys({blobs:o,kzg:n,to:r}),a=e.proofs??ws({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 zs(e){return Rt(await e.request({method:"eth_chainId"},{dedupe:!0}))}const Ms=["blobVersionedHashes","chainId","fees","gas","nonce","type"],Ls=new Map;async function Fs(e,t){const{account:n=e.account,blobs:r,chain:o,gas:s,kzg:a,nonce:i,nonceManager:c,parameters:u=Ms,type:l}=t,d=n?ur(n):n,f={...t,...d?{from:d?.address}:{}};let h,p;async function m(){return h||(h=await De(e,hs,"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 De(e,zs,"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 De(e,bs,"getTransactionCount")({address:d.address,blockTag:"pending"});if((u.includes("blobVersionedHashes")||u.includes("sidecars"))&&r&&a){const e=ys({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(Ts({commitment:e,to:r,version:n}));return o}({commitments:e,to:"hex"});f.blobVersionedHashes=t}if(u.includes("sidecars")){const t=Rs({blobs:r,commitments:e,proofs:ws({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 jr({transaction:e})}(f)}catch{let t=Ls.get(e.uid);if(void 0===t){const n=await m();t="bigint"==typeof n?.baseFeePerGas,Ls.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 gs(e,{block:n,chain:o,request:f});if(void 0===t.maxPriorityFeePerGas&&t.maxFeePerGas&&t.maxFeePerGas<s)throw new cs({maxPriorityFeePerGas:s});f.maxPriorityFeePerGas=s,f.maxFeePerGas=r}}else{if(void 0!==t.maxFeePerGas||void 0!==t.maxPriorityFeePerGas)throw new is;if(void 0===t.gasPrice){const t=await m(),{gasPrice:n}=await gs(e,{block:t,chain:o,request:f,type:"legacy"});f.gasPrice=n}}return u.includes("gas")&&void 0===s&&(f.gas=await De(e,Us,"estimateGas")({...f,account:d?{address:d.address,type:"json-rpc"}:d})),ss(f),delete f.parameters,f}async function Us(e,t){const{account:n=e.account}=t,r=n?ur(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 Fs(e,{...t,parameters:"local"===r?.type?void 0:["blobVersionedHashes"]}),w=("bigint"==typeof i?Ut(i):void 0)||c,v=rs(b),x=await(async()=>y.to?y.to:o&&o.length>0?await Mo({authorization:o[0]}).catch(()=>{throw new Ze("`to` is required. Could not infer from `authorizationList`")}):void 0)();ss(t);const E=e.chain?.formatters?.transactionRequest?.format,P=(E||es)({...Qo(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=Jo(e,n);return t instanceof Zo?e:t})();return new Lo(r,{docsPath:t,...n})}(n,{...t,account:r,chain:e.chain})}}function js(e,t){if(!jn(e,{strict:!1}))throw new _n({address:e});if(!jn(t,{strict:!1}))throw new _n({address:t});return e.toLowerCase()===t.toLowerCase()}const Ds="/docs/contract/decodeEventLog";function Gs(e){const{abi:t,data:n,strict:r,topics:o}=e,s=r??!0,[a,...i]=o;if(!a)throw new ct({docsPath:Ds});const c=t.find(e=>"event"===e.type&&a===On(Ge(e)));if(!c||!("name"in c)||"event"!==c.type)throw new ut(a,{docsPath:Ds});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 bt({abiItem:c,param:t});f[d?n:t.name||n]=qs({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=Pr(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 et||e instanceof gr)throw new gt({abiItem:c,data:n,params:p,size:Ve(n)});throw e}}else if(s)throw new gt({abiItem:c,data:"0x",params:p,size:0});return{eventName:u,args:Object.values(f).length>0?f:void 0}}function qs({param:e,value:t}){if("string"===e.type||"bytes"===e.type||"tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))return t;return(Pr([e],t)||[])[0]}function Ws(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]===On(t));if(!r)return null;const a=Gs({...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?js(t,n):"string"===e.type||"bytes"===e.type?Tn(qt(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 ut)return null;if(t instanceof gt||t instanceof bt){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 Vs(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 Hs(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=>sr({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?Ut(r):r,toBlock:"bigint"==typeof o?Ut(o):o}]});const h=d.map(e=>Vs(e));return l?Ws({abi:l,args:i,logs:h,strict:u}):h}async function Ys(e,t){const{abi:n,address:r,args:o,blockHash:s,eventName:a,fromBlock:i,toBlock:c,strict:u}=t,l=a?tr({abi:n,name:a}):void 0,d=l?void 0:n.filter(e=>"event"===e.type);return De(e,Hs,"getLogs")({address:r,args:o,blockHash:s,event:l,events:d,fromBlock:i,toBlock:c,strict:u})}const Ks="/docs/contract/decodeFunctionResult";function Zs(e){const{abi:t,args:n,functionName:r,data:o}=e;let s=t[0];if(r){const e=tr({abi:t,args:n,name:r});if(!e)throw new dt(r,{docsPath:Ks});s=e}if("function"!==s.type)throw new dt(void 0,{docsPath:Ks});if(!s.outputs)throw new ft(s.name,{docsPath:Ks});const a=Pr(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 Js=BigInt(0),Qs=BigInt(1);function Xs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function ea(e){if(!Xs(e))throw new Error("Uint8Array expected")}function ta(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function na(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function ra(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Js:BigInt("0x"+e)}const oa="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,sa=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function aa(e){if(ea(e),oa)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=sa[e[n]];return t}const ia=48,ca=57,ua=65,la=70,da=97,fa=102;function ha(e){return e>=ia&&e<=ca?e-ia:e>=ua&&e<=la?e-(ua-10):e>=da&&e<=fa?e-(da-10):void 0}function pa(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(oa)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=ha(e.charCodeAt(o)),s=ha(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 ma(e){return ra(aa(e))}function ga(e){return ea(e),ra(aa(Uint8Array.from(e).reverse()))}function ba(e,t){return pa(e.toString(16).padStart(2*t,"0"))}function ya(e,t){return ba(e,t).reverse()}function wa(e,t,n){let r;if("string"==typeof t)try{r=pa(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Xs(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 va(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];ea(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 xa=e=>"bigint"==typeof e&&Js<=e;function Ea(e,t,n){return xa(e)&&xa(t)&&xa(n)&&t<=e&&e<n}function Pa(e,t,n,r){if(!Ea(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const ka=e=>(Qs<<BigInt(e))-Qs,Aa=e=>new Uint8Array(e),Ia=e=>Uint8Array.from(e);const Sa={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||Xs(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 Na(e,t,n={}){const r=(t,n,r)=>{const o=Sa[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 Ta(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 Ba extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof Ba){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 Ba&&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 Ca(this,e)}}function Ca(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?Ca(e.cause,t):t?null:e}function $a(e,t){if(Ka(e)>t)throw new ri({givenSize:Ka(e),maxSize:t})}const Oa=48,_a=57,Ra=65,za=70,Ma=97,La=102;function Fa(e){return e>=Oa&&e<=_a?e-Oa:e>=Ra&&e<=za?e-(Ra-10):e>=Ma&&e<=La?e-(Ma-10):void 0}function Ua(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 ja(e,t){if(mi(e)>t)throw new Ei({givenSize:mi(e),maxSize:t})}function Da(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 ki({size:Math.ceil(o.length/2),targetSize:r,type:"Hex"});return`0x${o["right"===n?"padEnd":"padStart"](2*r,"0")}`}function Ga(e,t,n){return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString()+"#__bigint":t,n)}const qa=new TextDecoder,Wa=new TextEncoder;function Va(e){return e instanceof Uint8Array?e:"string"==typeof e?Ha(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}function Ha(e,t={}){const{size:n}=t;let r=e;n&&(ja(e,n),r=hi(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=Fa(o.charCodeAt(t++)),r=Fa(o.charCodeAt(t++));if(void 0===n||void 0===r)throw new Ba(`Invalid byte sequence ("${o[t-2]}${o[t-1]}" in "${o}").`);a[e]=16*n+r}return a}function Ya(e,t={}){const{size:n}=t,r=Wa.encode(e);return"number"==typeof n?($a(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 oi({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 Ka(e){return e.length}function Za(e,t,n,r={}){const{strict:o}=r;return e.slice(t,n)}function Ja(e,t={}){const{size:n}=t;void 0!==n&&$a(e,n);return gi(ui(e,t),t)}function Qa(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&($a(r,n),r=ti(r)),r.length>1||r[0]>1)throw new ni(r);return Boolean(r[0])}function Xa(e,t={}){const{size:n}=t;void 0!==n&&$a(e,n);return bi(ui(e,t),t)}function ei(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&($a(r,n),r=Ua(r,{dir:"right"})),qa.decode(r)}function ti(e){return Ua(e,{dir:"left"})}class ni extends Ba{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 ri=class extends Ba{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"})}},oi=class extends Ba{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 si=new TextEncoder,ai=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ii(...e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function ci(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(ja(n,t.size),fi(n,t.size)):n}function ui(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=ai[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(ja(r,t.size),hi(r,t.size)):r}function li(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 wi({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?fi(i,r):i}function di(e,t={}){return ui(si.encode(e),t)}function fi(e,t){return Da(e,{dir:"left",size:t})}function hi(e,t){return Da(e,{dir:"right",size:t})}function pi(e,t,n,r={}){const{strict:o}=r;!function(e,t){if("number"==typeof t&&t>0&&t>mi(e)-1)throw new Pi({offset:t,position:"start",size:mi(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&&mi(e)!==n-t)throw new Pi({offset:n,position:"end",size:mi(e)})}(s,t,n),s}function mi(e){return Math.ceil((e.length-2)/2)}function gi(e,t={}){const{signed:n}=t;t.size&&ja(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 bi(e,t={}){const{signed:n,size:r}=t;return Number(n||r?gi(e,t):e)}function yi(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new vi(e);if("string"!=typeof e)throw new vi(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new xi(e);if(!e.startsWith("0x"))throw new xi(e)}(e,{strict:n}),!0}catch{return!1}}class wi extends Ba{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 vi extends Ba{constructor(e){super(`Value \`${"object"==typeof e?Ga(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 xi extends Ba{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 Ei extends Ba{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 Pi extends Ba{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 ki extends Ba{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 Ai(e){return{address:e.address,amount:li(e.amount),index:li(e.index),validatorIndex:li(e.validatorIndex)}}function Ii(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:li(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:li(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:li(e.gasLimit)},..."bigint"==typeof e.number&&{number:li(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:li(e.prevRandao)},..."bigint"==typeof e.time&&{time:li(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(Ai)}}}const Si=[{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"}],Ni=[{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"}]}],Ti=[{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"}],Bi=[...Ti,{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"}]}],Ci=[...Ti,{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"}]}],$i=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],Oi=[{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"}]}],Ri=[{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"}],zi="0x82ad56cb",Mi="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",Li="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",Fi="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",Ui="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class ji extends Ze{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 Di extends Ze{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}const Gi="/docs/contract/encodeDeployData";function qi(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 Qe({docsPath:Gi});if(!("inputs"in o))throw new Xe({docsPath:Gi});if(!o.inputs||0===o.inputs.length)throw new Xe({docsPath:Gi});return Gn([r,Zn(o.inputs,n)])}function Wi({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new ji({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new ji({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function Vi(e,{docsPath:t,...n}){const r=(()=>{const t=Jo(e,n);return t instanceof Zo?e:t})();return new Wr(r,{docsPath:t,...n})}function Hi(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const Yi=new Map;function Ki({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=()=>Yi.delete(t),i=()=>Yi.get(t)||[],c=e=>Yi.set(t,[...i(),e]);return{flush:a,async schedule(e){const{promise:t,resolve:o,reject:a}=Hi(),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 Zi(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?ur(n):void 0;if(l&&(f||h))throw new Ze("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(l&&v)throw new Ze("Cannot provide both `code` & `to` as parameters.");const A=l&&d,I=f&&h&&v&&d,S=A||I,N=A?Ji({code:l,data:d}):I?function(e){const{data:t,factory:n,factoryData:r,to:o}=e;return qi({abi:Fe(["constructor(address, bytes, address, bytes)"]),bytecode:Li,args:[o,t,n,r]})}({data:d,factory:f,factoryData:h,to:v}):d;try{ss(t);const n=("bigint"==typeof s?Ut(s):void 0)||a,l=u?Ii(u):void 0,d=rs(E),f=e.chain?.formatters?.transactionRequest?.format,h=(f||es)({...Qo(P,{format:f}),from:k?.address,accessList:i,authorizationList:r,blobs:c,data:N,gas:p,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:b,maxPriorityFeePerGas:y,nonce:w,to:S?void 0:v,value:x});if(o&&function({request:e}){const{data:t,to:n,...r}=e;return!!t&&(!t.startsWith(zi)&&(!!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 Wi({blockNumber:s,chain:e.chain,contract:"multicall3"});throw new Di})(),l="bigint"==typeof s?Ut(s):void 0,d=l||a,{schedule:f}=Ki({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=dr({abi:Si,args:[n],functionName:"aggregate3"}),o=await e.request({method:"eth_call",params:[{...null===u?{data:Ji({code:Ui,data:r})}:{to:u,data:r}},d]});return Zs({abi:Si,args:[n],functionName:"aggregate3",data:o||"0x"})}}),[{returnData:h,success:p}]=await f({data:i,to:c});if(!p)throw new Zr({data:h});return"0x"===h?{data:void 0}:{data:h}}(e,{...h,blockNumber:s,blockTag:a})}catch(e){if(!(e instanceof Di||e instanceof ji))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 Ze))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 nu});if(!1!==e.ccipRead&&r?.slice(0,10)===s&&v)return{data:await o(e,{data:r,to:v})};if(S&&"0x101bb98d"===r?.slice(0,10))throw new Kr({factory:f});throw Vi(n,{...t,account:k,chain:e.chain})}}function Ji(e){const{code:t,data:n}=e;return qi({abi:Fe(["constructor(bytes, bytes)"]),bytecode:Mi,args:[t,n]})}async function Qi(e,t){const{abi:n,address:r,args:o,functionName:s,...a}=t,i=dr({abi:n,args:o,functionName:s});try{const{data:t}=await De(e,Zi,"call")({...a,data:i,to:r});return Zs({abi:n,args:o,functionName:s,data:t||"0x"})}catch(e){throw Bo(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/readContract",functionName:s})}}const Xi=new Map,ec=new Map;let tc=0;function nc(e,t,n){const r=++tc,o=()=>Xi.get(e)||[],s=()=>{const t=o();if(!t.some(e=>e.id===r))return;const n=ec.get(e);if(1===t.length&&n){const e=n();e instanceof Promise&&e.catch(()=>{})}(()=>{const t=o();Xi.set(e,t.filter(e=>e.id!==r))})()},a=o();if(Xi.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&&ec.set(e,c),s}async function rc(e){return new Promise(t=>setTimeout(t,e))}function oc(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 rc(i);const c=async()=>{o&&(await e({unpoll:s}),await rc(r),c())};c()})(),s}const sc=new Map,ac=new Map;async function ic(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,sc),r=t(e,ac);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 cc(e,{cacheTime:t=e.cacheTime}={}){const n=await ic(()=>e.request({method:"eth_blockNumber"}),{cacheKey:(r=e.uid,`blockNumber.${r}`),cacheTime:t});var r;return BigInt(n)}async function uc(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=>Vs(e));return"abi"in t&&t.abi?Ws({abi:t.abi,logs:o,strict:n}):o}async function lc(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function dc(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 rc(n),a({count:i+1})})({error:e});s(e)}};a()})}const fc={"0x0":"reverted","0x1":"success"};function hc(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=>Vs(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Rt(e.transactionIndex):null,status:e.status?fc[e.status]:null,type:e.type?ls[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}let pc,mc=256;function gc(e=11){if(!pc||mc+e>512){pc="",mc=0;for(let e=0;e<256;e++)pc+=(256+256*Math.random()|0).toString(16).substring(1)}return pc.substring(mc,mc+++e)}function bc(e){if(!(e instanceof Ze))return!1;const t=e.walk(e=>e instanceof Hr);return t instanceof Hr&&("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 yc="/docs/contract/encodeErrorResult";function wc(e){const{abi:t,errorName:n,args:r}=e;let o=t[0];if(n){const e=tr({abi:t,args:r,name:n});if(!e)throw new at(n,{docsPath:yc});o=e}if("error"!==o.type)throw new at(void 0,{docsPath:yc});const s=Ge(o),a=er(s);let i="0x";if(r&&r.length>0){if(!o.inputs)throw new st(o.name,{docsPath:yc});i=Zn(o.inputs,r)}return Gn([a,i])}const vc="/docs/contract/encodeFunctionResult";const xc="x-batch-gateway:true";async function Ec(e){const{data:t,ccipRequest:n}=e,{args:[r]}=function(e){const{abi:t,data:n}=e,r=qn(n,0,4),o=t.find(e=>"function"===e.type&&r===er(Ge(e)));if(!o)throw new ht(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:o.name,args:"inputs"in o&&o.inputs&&o.inputs.length>0?Pr(o.inputs,qn(n,4)):void 0}}({abi:Ni,data:t}),o=[],s=[];return await Promise.all(r.map(async(e,t)=>{try{s[t]=e.urls.includes(xc)?await Ec({data:e.data,ccipRequest:n}):await n(e),o[t]=!1}catch(e){o[t]=!0,s[t]="HttpRequestError"===(r=e).name&&r.status?wc({abi:Ni,errorName:"HttpError",args:[r.status,r.shortMessage]}):wc({abi:[hr],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=tr({abi:t,name:n});if(!e)throw new dt(n,{docsPath:vc});o=e}if("function"!==o.type)throw new dt(void 0,{docsPath:vc});if(!o.outputs)throw new ft(o.name,{docsPath:vc});const s=(()=>{if(0===o.outputs.length)return[];if(1===o.outputs.length)return[r];if(Array.isArray(r))return r;throw new vt(r)})();return Zn(o.outputs,s)}({abi:Ni,functionName:"query",result:[o,s]})}function Pc(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 We(t)?t:null}function kc(e){let t=new Uint8Array(32).fill(0);if(!e)return Ft(t);const n=e.split(".");for(let e=n.length-1;e>=0;e-=1){const r=Pc(n[e]),o=r?qt(r):Tn(Yt(n[e]),"bytes");t=Tn(Dn([t,o]),"bytes")}return Ft(t)}function Ac(e){return`[${e.slice(2)}]`}function Ic(e){const t=new Uint8Array(32).fill(0);return e?Pc(e)||Tn(Yt(e)):Ft(t)}function Sc(e){const t=e.replace(/^\.|\.$/gm,"");if(0===t.length)return new Uint8Array(1);const n=new Uint8Array(Yt(t).byteLength+2);let r=0;const o=t.split(".");for(let e=0;e<o.length;e++){let t=Yt(o[e]);t.byteLength>255&&(t=Yt(Ac(Ic(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 Nc extends Ze{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 Tc extends Ze{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`,{name:"EnsAvatarInvalidNftUriError"})}}class Bc extends Ze{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 Cc extends Ze{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const $c=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,Oc=/^(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,([^"].*)/,Rc=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;function zc(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function Mc({uri:e,gatewayUrls:t}){const n=_c.test(e);if(n)return{uri:e,isOnChain:!0,isEncoded:n};const r=zc(t?.ipfs,"https://ipfs.io"),o=zc(t?.arweave,"https://arweave.net"),s=e.match($c),{protocol:a,subpath:i,target:c,subtarget:u=""}=s?.groups||{},l="ipns:/"===a||"ipns/"===i,d="ipfs:/"===a||"ipfs/"===i||Oc.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(Rc,"");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 Bc({uri:e})}function Lc(e){if("object"!=typeof e||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new Nc({data:e});return e.image||e.image_url||e.image_data}async function Fc({gatewayUrls:e,uri:t}){const{uri:n,isOnChain:r}=Mc({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 Bc({uri:t})}async function Uc(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 Tc({reason:"Only EIP-155 supported"});if(!a)throw new Tc({reason:"Chain ID not found"});if(!c)throw new Tc({reason:"Contract address not found"});if(!o)throw new Tc({reason:"Token ID not found"});if(!i)throw new Tc({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 Qi(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 Qi(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 Cc({namespace:t.namespace})}(e,{nft:r}),{uri:s,isOnChain:a,isEncoded:i}=Mc({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 Fc({uri:Lc(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 Fc({gatewayUrls:e,uri:Lc(n)})}catch{throw new Bc({uri:t})}}({gatewayUrls:t,uri:s.replace(/(?:0x)?{id}/,c)})}(e,{gatewayUrls:t,record:n}):Fc({uri:n,gatewayUrls:t})}async function jc(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 Wi({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:Bi,args:[Mt(Sc(s)),dr({abi:$i,functionName:"text",args:[kc(s),o]}),a??[xc]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},i=De(e,Qi,"readContract"),c=await i(t);if("0x"===c[0])return null;const l=Zs({abi:$i,functionName:"text",data:c[0]});return""===l?null:l}catch(e){if(i)throw e;if(bc(e))return null;throw e}}async function Dc(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?ur(n):void 0;try{ss(t);const n=("bigint"==typeof r?Ut(r):void 0)||o,g=e.chain?.formatters?.transactionRequest?.format,b=(g||es)({...Qo(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 Vi(n,{...t,account:m,chain:e.chain})}}async function Gc(e,{address:t,args:n,event:r,events:o,fromBlock:s,strict:a,toBlock:i}={}){const c=o??(r?[r]:void 0),u=ir(e,{method:"eth_newFilter"});let l=[];if(c){const e=c.flatMap(e=>sr({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?Ut(s):s,toBlock:"bigint"==typeof i?Ut(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 qc(e){const t=ir(e,{method:"eth_newPendingTransactionFilter"}),n=await e.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:t(n),type:"transaction"}}async function Wc(e,{address:t,blockNumber:n,blockTag:r="latest"}){const o=void 0!==n?Ut(n):void 0,s=await e.request({method:"eth_getCode",params:[t,o||r]},{dedupe:Boolean(o)});if("0x"!==s)return s}class Vc extends Ze{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 Hc=[{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 Yc(e,{blockCount:t,blockNumber:n,blockTag:r="latest",rewardPercentiles:o}){const s="bigint"==typeof n?Ut(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:[Ut(t),s||r,o]},{dedupe:Boolean(s)}))}const Kc=new Rn(8192);function Zc(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 fo(new Error("method not supported"),{method:u});if(s?.include&&!s.include.includes(u))throw new fo(new Error("method not supported"),{method:u});return function(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(Kc.get(n))return Kc.get(n);const r=e().finally(()=>Kc.delete(n));return Kc.set(n,r),r}(()=>dc(async()=>{try{return await e(n)}catch(e){const t=e;switch(t.code){case no.code:throw new no(t);case ro.code:throw new ro(t);case oo.code:throw new oo(t,{method:n.method});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);case uo.code:throw new uo(t);case lo.code:throw new lo(t);case fo.code:throw new fo(t,{method:n.method});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 Ao.code:throw new Ao(t);case Io.code:throw new Io(t);case So.code:throw new So(t);case 5e3:throw new mo(t);default:if(e instanceof Ze)throw e;throw new No(t)}}},{delay:({count:e,error:t})=>{if(t&&t instanceof Jr){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===ho.code||e.code===ao.code);if(e instanceof Jr&&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?Dt(`${c}.${Tr(n)}`):void 0})}}class Jc extends Ze{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 Qc extends Ze{constructor({result:e,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${t}`,`Response: ${Tr(e)}`],name:"OffchainLookupResponseMalformedError"})}}class Xc extends Ze{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 eu={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 tu({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 Jr({body:i,details:o?.error?Tr(o.error):n.statusText,headers:n.headers,status:n.status,url:s});continue}if(!We(o)){r=new Qc({result:o,url:s});continue}return o}catch(e){r=new Jr({body:i,details:e.message,url:s})}}throw r}var nu=Object.freeze({__proto__:null,ccipRequest:tu,offchainLookup:async function(e,{blockNumber:t,blockTag:n,data:r,to:o}){const{args:s}=Nr({data:r,abi:[eu]}),[a,i,c,u,l]=s,{ccipRead:d}=e,f=d&&"function"==typeof d?.request?d.request:tu;try{if(!js(o,a))throw new Xc({sender:a,to:o});const r=i.includes(xc)?await Ec({data:c,ccipRequest:f}):await f({data:c,sender:a,urls:i}),{data:s}=await Zi(e,{blockNumber:t,blockTag:n,data:Dn([u,Zn([{type:"bytes"},{type:"bytes"}],[r,l])]),to:o});return s}catch(e){throw new Jc({callbackSelector:u,cause:e,data:r,extraData:l,sender:a,urls:i})}},offchainLookupAbiItem:eu,offchainLookupSignature:"0x556f1830"});function ru(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const ou=ru();function su(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)?Tr(r.map(e=>({jsonrpc:"2.0",id:e.id??ou.take(),...e}))):Tr({jsonrpc:"2.0",id:r.id??ou.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 Xr({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 Jr({body:r,details:Tr(n.error)||t.statusText,headers:t.headers,status:t.status,url:e});return n}catch(t){if(t instanceof Jr)throw t;if(t instanceof Xr)throw t;throw new Jr({body:r,cause:t,url:e})}}}}function au(e,t){return Tn(function(e){const t="string"==typeof e?Dt(e):"string"==typeof e.raw?e.raw:Ft(e.raw);return Dn([Dt(`Ethereum Signed Message:\n${Ve(t)}`),t])}(e),t)}class iu extends Ze{constructor({domain:e}){super(`Invalid domain "${Tr(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class cu extends Ze{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 uu extends Ze{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function lu({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 du(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new uu({type:e})}function fu(e){const{domain:t={},message:n,primaryType:r}=e,o={EIP712Domain:lu({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(Kn);if(i&&("number"==typeof a||"bigint"==typeof a)){const[e,t,n]=i;Ut(a,{signed:"int"===t,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof a&&!jn(a))throw new _n({address:a});const c=r.match(Yn);if(c){const[e,t]=c;if(t&&Ve(a)!==Number.parseInt(t,10))throw new mt({expectedSize:Number.parseInt(t,10),givenSize:Ve(a)})}const u=o[r];u&&(du(r),s(u,a))}};if(o.EIP712Domain&&t){if("object"!=typeof t)throw new iu({domain:t});s(o.EIP712Domain,t)}if("EIP712Domain"!==r){if(!o[r])throw new cu({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 hu({data:e,primaryType:"EIP712Domain",types:t})}({domain:t,types:o})),"EIP712Domain"!==r&&s.push(hu({data:n,primaryType:r,types:o})),Tn(Dn(s))}function hu({data:e,primaryType:t,types:n}){return Tn(pu({data:e,primaryType:t,types:n}))}function pu({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],o=[mu({primaryType:t,types:n})];for(const s of n[t]){const[t,a]=bu({types:n,name:s.name,type:s.type,value:e[s.name]});r.push(t),o.push(a)}return Zn(r,o)}function mu({primaryType:e,types:t}){const n=Mt(function({primaryType:e,types:t}){let n="";const r=gu({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 Tn(n)}function gu({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])gu({primaryType:e.type,types:t},n);return n}function bu({types:e,name:t,type:n,value:r}){if(void 0!==e[n])return[{type:"bytes32"},Tn(pu({data:r,primaryType:n,types:e}))];if("bytes"===n){return[{type:"bytes32"},Tn(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},Tn(Mt(r))];if(n.lastIndexOf("]")===n.length-1){const o=n.slice(0,n.lastIndexOf("[")),s=r.map(n=>bu({name:t,type:o,types:e,value:n}));return[{type:"bytes32"},Tn(Zn(s.map(([e])=>e),s.map(([,e])=>e)))]}return[{type:n},r]}class yu 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 wu={checksum:new yu(8192)}.checksum;function vu(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Nn(Va(e));return"Bytes"===n?r:ui(r)}const xu=/^0x[a-fA-F0-9]{40}$/;function Eu(e,t={}){const{strict:n=!0}=t;if(!xu.test(e))throw new Au({address:e,cause:new Iu});if(n){if(e.toLowerCase()===e)return;if(Pu(e)!==e)throw new Au({address:e,cause:new Su})}}function Pu(e){if(wu.has(e))return wu.get(e);Eu(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=vu(Ya(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 wu.set(e,o),o}function ku(e,t={}){const{strict:n=!0}=t??{};try{return Eu(e,{strict:n}),!0}catch{return!1}}class Au extends Ba{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 Iu extends Ba{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 Su extends Ba{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const Nu=/^(.*)\[([0-9]*)\]$/,Tu=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Bu=/^(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)?$/,Cu=2n**256n-1n;function $u(e,t,n){const{checksumAddress:r,staticPosition:o}=n,s=Mu(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+Xa(e.readBytes(_u)),o=n+Ou;e.setPosition(n);const a=Xa(e.readBytes(Ou)),i=Lu(t);let c=0;const u=[];for(let n=0;n<a;++n){e.setPosition(o+(i?32*n:c));const[s,a]=$u(e,t,{checksumAddress:r,staticPosition:o});c+=a,u.push(s)}return e.setPosition(s+32),[u,32]}if(Lu(t)){const n=s+Xa(e.readBytes(_u)),a=[];for(let s=0;s<o;++s){e.setPosition(n+32*s);const[o]=$u(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]=$u(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(Lu(t)){const n=o+Xa(e.readBytes(_u));for(let o=0;o<t.components.length;++o){const c=t.components[o];e.setPosition(n+i);const[u,l]=$u(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]=$u(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?Pu(e):e;return[o(ui(Za(r,-20))),32]}(e,{checksum:r});if("bool"===t.type)return function(e){return[Qa(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=Xa(e.readBytes(32));e.setPosition(n+t);const r=Xa(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[ui(o),32]}const s=ui(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?Ja(o,{signed:n}):Xa(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=Xa(e.readBytes(32)),r=t+n;e.setPosition(r);const o=Xa(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const s=e.readBytes(o,32),a=ei(ti(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:o});throw new Xu(t.type)}const Ou=32,_u=32;function Ru({checksumAddress:e=!1,parameter:t,value:n}){const r=t,o=Mu(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 Qu(e);if(!s&&e.length!==r)throw new Ku({expectedLength:r,givenLength:e.length,type:`${o.type}[${r}]`});let a=!1;const i=[];for(let t=0;t<e.length;t++){const r=Ru({checksumAddress:n,parameter:o,value:e[t]});r.dynamic&&(a=!0),i.push(r)}if(s||a){const e=zu(i);if(s){const t=li(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?ii(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:ii(...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=Ru({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});s.push(i),i.dynamic&&(o=!0)}return{dynamic:o,encoded:o?zu(s):ii(...s.map(({encoded:e})=>e))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return Eu(e,{strict:n}),{dynamic:!1,encoded:fi(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new Ba(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:fi(ci(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Bu.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 wi({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:li(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=mi(e);if(!n){let t=e;return r%32!=0&&(t=hi(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:ii(fi(li(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new Zu({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:hi(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=di(e),n=Math.ceil(mi(t)/32),r=[];for(let e=0;e<n;e++)r.push(hi(pi(t,32*e,32*(e+1))));return{dynamic:!0,encoded:ii(hi(li(mi(t),{size:32})),...r)}}(n);throw new Xu(r.type)}function zu(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:mi(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(li(t+o,{size:32})),r.push(i),o+=mi(i)):n.push(i)}return ii(...n,...r)}function Mu(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Lu(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(Lu);const n=Mu(e.type);return!(!n||!Lu({...e,type:n[1]}))}const Fu={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 Du({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new ju({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Uu({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 Uu({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 Uu extends Ba{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class ju extends Ba{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 Du extends Ba{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 Gu(e,t,n={}){const{as:r="Array",checksumAddress:o=!1}=n,s="string"==typeof t?Ha(t):t,a=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(Fu);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===Ka(s)&&e.length>0)throw new Yu;if(Ka(s)&&Ka(s)<32)throw new Hu({data:"string"==typeof t?t:ui(t),parameters:e,size:Ka(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]=$u(a,n,{checksumAddress:o,staticPosition:0});i+=u,"Array"===r?c.push(s):c[n.name??t]=s}return c}function qu(e,t,n){const{checksumAddress:r=!1}={};if(e.length!==t.length)throw new Ju({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(Ru({checksumAddress:e,parameter:t[o],value:n[o]}));return r}({checksumAddress:r,parameters:e,values:t}),s=zu(o);return 0===s.length?"0x":s}function Wu(e,t){if(e.length!==t.length)throw new Ju({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(Wu.encode(o,s))}return ii(...n)}function Vu(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?je(e):e}!function(e){e.encode=function e(t,n,r=!1){if("address"===t){const e=n;return Eu(e),fi(e.toLowerCase(),r?32:0)}if("string"===t)return di(n);if("bytes"===t)return n;if("bool"===t)return fi(ci(n),r?32:1);const o=t.match(Bu);if(o){const[e,t,s="256"]=o,a=Number.parseInt(s,10)/8;return li(n,{size:r?32:a,signed:"int"===t})}const s=t.match(Tu);if(s){const[e,t]=s;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new Zu({expectedSize:Number.parseInt(t,10),value:n});return hi(n,r?32:0)}const a=t.match(Nu);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":ii(...o)}throw new Xu(t)}}(Wu||(Wu={}));class Hu extends Ba{constructor({data:e,parameters:t,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${X(t)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Yu extends Ba{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Ku extends Ba{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 Zu extends Ba{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${mi(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Ju extends Ba{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 Qu extends Ba{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class Xu extends Ba{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 el extends ln{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");Xt(e.outputLen),Xt(e.blockLen)}(e);const n=un(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),rn(o)}update(e){return tn(this),this.iHash.update(e),this}digestInto(e){tn(this),en(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 tl=(e,t,n)=>new el(e,t).update(n).digest();tl.create=(e,t)=>new el(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 nn(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 rn(e,t){tn(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function on(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function sn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function an(e,t){return e<<32-t|e>>>t}function cn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const un=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=cn(e[t]);return e};function ln(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)),tn(e),e}class dn{}function fn(e){const t=t=>e().update(ln(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function hn(e=32){if(Xt&&"function"==typeof Xt.getRandomValues)return Xt.getRandomValues(new Uint8Array(e));if(Xt&&"function"==typeof Xt.randomBytes)return Uint8Array.from(Xt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const pn=BigInt(0),mn=BigInt(1),gn=BigInt(2),bn=BigInt(7),yn=BigInt(256),wn=BigInt(113),vn=[],xn=[],En=[];for(let e=0,t=mn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],vn.push(2*(5*r+n)),xn.push((e+1)*(e+2)/2%64);let o=pn;for(let e=0;e<7;e++)t=(t<<mn^(t>>bn)*wn)%yn,t&gn&&(o^=mn<<(mn<<BigInt(e))-mn);En.push(o)}const Pn=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}=Qt(e[s],t);[r[s],o[s]]=[n,a]}return[r,o]}(En,!0),kn=Pn[0],An=Pn[1],In=(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),Sn=(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 Nn extends dn{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,en(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(){un(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=In(s,a,1)^n[r],c=Sn(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=xn[n],s=In(t,o,r),a=Sn(t,o,r),i=vn[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]^=kn[r],e[1]^=An[r]}on(n)}(this.state32,this.rounds),un(this.state32),this.posOut=0,this.pos=0}update(e){nn(this),tn(e=ln(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){nn(this,!1),tn(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 en(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(rn(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,on(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:o,enableXOF:s}=this;return e||(e=new Nn(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 Tn=(()=>{return e=1,t=136,n=32,fn(()=>new Nn(t,e,n));var e,t,n})();function Bn(e,t){const n=t||"hex",r=Tn(Ve(e,{strict:!1})?qt(e):e);return"bytes"===n?r:Lt(r)}function Cn(e){return Bn(qt(e))}const $n=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 Je("Unable to normalize signature.");return o}("string"==typeof e?e:te(e));function On(e){return Cn($n(e))}const _n=On;let Rn=class extends Je{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"})}},zn=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 Mn=new zn(8192);function Ln(e,t){if(Mn.has(`${e}.${t}`))return Mn.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=Bn(Kt(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 Mn.set(`${e}.${t}`,s),s}function Fn(e,t){if(!Dn(e,{strict:!1}))throw new Rn({address:e});return Ln(e,t)}const Un=/^0x[a-fA-F0-9]{40}$/,jn=new zn(8192);function Dn(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(jn.has(r))return jn.get(r);const o=!(!Un.test(e)||e.toLowerCase()!==e&&n&&Ln(e)!==e);return jn.set(r,o),o}function Gn(e){return"string"==typeof e[0]?Wn(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 Wn(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function qn(e,t,n,{strict:r}={}){return Ve(e,{strict:!1})?function(e,t,n,{strict:r}={}){Vn(e,t);const o=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;r&&Hn(o,t,n);return o}(e,t,n,{strict:r}):Yn(e,t,n,{strict:r})}function Vn(e,t){if("number"==typeof t&&t>0&&t>He(e)-1)throw new kt({offset:t,position:"start",size:He(e)})}function Hn(e,t,n){if("number"==typeof t&&"number"==typeof n&&He(e)!==n-t)throw new kt({offset:n,position:"end",size:He(e)})}function Yn(e,t,n,{strict:r}={}){Vn(e,t);const o=e.slice(t,n);return r&&Hn(o,t,n),o}const Kn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Zn=/^(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 Jn(e,t){if(e.length!==t.length)throw new st({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(Qn({param:e[r],value:t[r]}));return n}({params:e,values:t}),r=Xn(n);return 0===r.length?"0x":r}function Qn({param:e,value:t}){const n=er(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 xt(e);if(!r&&e.length!==t)throw new rt({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let o=!1;const s=[];for(let t=0;t<e.length;t++){const r=Qn({param:n,value:e[t]});r.dynamic&&(o=!0),s.push(r)}if(r||o){const e=Xn(s);if(r){const t=jt(s.length,{size:32});return{dynamic:!0,encoded:s.length>0?Gn([t,e]):t}}if(o)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Gn(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=Qn({param:s,value:e[Array.isArray(e)?o:s.name]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?Xn(r):Gn(r.map(({encoded:e})=>e))}}(t,{param:e});if("address"===e.type)return function(e){if(!Dn(e))throw new Rn({address:e});return{dynamic:!1,encoded:Nt(e.toLowerCase())}}(t);if("bool"===e.type)return function(e){if("boolean"!=typeof e)throw new Je(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Nt(Ft(e))}}(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const n=e.type.startsWith("int"),[,,r="256"]=Zn.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 Tt({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:jt(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=He(e);if(!n){let t=e;return r%32!=0&&(t=Nt(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:Gn([Nt(jt(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new ot({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:Nt(e,{dir:"right"})}}(t,{param:e});if("string"===e.type)return function(e){const t=Gt(e),n=Math.ceil(He(t)/32),r=[];for(let e=0;e<n;e++)r.push(Nt(qn(t,32*e,32*(e+1)),{dir:"right"}));return{dynamic:!0,encoded:Gn([Nt(jt(He(t),{size:32})),...r])}}(t);throw new wt(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function Xn(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:He(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(jt(t+o,{size:32})),r.push(i),o+=He(i)):n.push(i)}return Gn([...n,...r])}function er(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const tr=e=>qn(On(e),0,4);function nr(e){const{abi:t,args:n=[],name:r}=e,o=Ve(r,{strict:!1}),s=t.filter(e=>o?"function"===e.type?tr(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&&rr(t,r)});if(t){if(a&&"inputs"in a&&a.inputs){const t=or(e.inputs,a.inputs,n);if(t)throw new mt({abiItem:e,type:t[0]},{abiItem:a,type:t[1]})}a=e}}return a||s[0]}function rr(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Dn(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)=>rr(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=>rr(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function or(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 or(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")))&&Dn(n[r],{strict:!1}))())return a}}const sr="/docs/contract/encodeEventTopics";function ar(e){const{abi:t,eventName:n,args:r}=e;let o=t[0];if(n){const e=nr({abi:t,name:n});if(!e)throw new dt(n,{docsPath:sr});o=e}if("event"!==o.type)throw new dt(void 0,{docsPath:sr});const s=We(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)=>ir({param:e,value:t[n][o]})):void 0!==t[n]&&null!==t[n]?ir({param:e,value:t[n]}):null)??[])}return[a,...i]}function ir({param:e,value:t}){if("string"===e.type||"bytes"===e.type)return Bn(qt(t));if("tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))throw new Pt(e.type);return Jn([e],[t])}function cr(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 ur(e,t){const{address:n,abi:r,args:o,eventName:s,fromBlock:a,strict:i,toBlock:c}=t,u=cr(e,{method:"eth_newFilter"}),l=s?ar({abi:r,args:o,eventName:s}):void 0,d=await e.request({method:"eth_newFilter",params:[{address:n,fromBlock:"bigint"==typeof a?jt(a):a,toBlock:"bigint"==typeof c?jt(c):c,topics:l}]});return{abi:r,args:o,eventName:s,id:d,request:u(d),strict:Boolean(i),type:"event"}}function lr(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const dr="/docs/contract/encodeFunctionData";function fr(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=nr({abi:t,args:n,name:r});if(!e)throw new ft(r,{docsPath:dr});o=e}if("function"!==o.type)throw new ft(void 0,{docsPath:dr});return{abi:[o],functionName:tr(We(o))}}(e),o=n[0];return Wn([r,("inputs"in o&&o.inputs?Jn(o.inputs,t??[]):void 0)??"0x"])}const hr={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."},pr={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},mr={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};let gr=class extends Je{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}},br=class extends Je{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}},yr=class extends Je{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}};const wr={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 yr({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new br({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new gr({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 gr({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 vr(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(wr);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function xr(e,t={}){void 0!==t.size&&_t(e,{size:t.size});return Rt(Ut(e,t),t)}function Er(e,t={}){let n=e;if(void 0!==t.size&&(_t(n,{size:t.size}),n=Ot(n)),n.length>1||n[0]>1)throw new Bt(n);return Boolean(n[0])}function Pr(e,t={}){void 0!==t.size&&_t(e,{size:t.size});return zt(Ut(e,t),t)}function kr(e,t){const n="string"==typeof t?Yt(t):t,r=vr(n);if(0===He(n)&&e.length>0)throw new nt;if(He(t)&&He(t)<32)throw new tt({data:"string"==typeof t?t:Ut(t),params:e,size:He(t)});let o=0;const s=[];for(let t=0;t<e.length;++t){const n=e[t];r.setPosition(o);const[a,i]=Ar(r,n,{staticPosition:0});o+=i,s.push(a)}return s}function Ar(e,t,{staticPosition:n}){const r=er(t.type);if(r){const[o,s]=r;return function(e,t,{length:n,staticPosition:r}){if(!n){const n=r+Pr(e.readBytes(Sr)),o=n+Ir;e.setPosition(n);const s=Pr(e.readBytes(Ir)),a=Nr(t);let i=0;const c=[];for(let n=0;n<s;++n){e.setPosition(o+(a?32*n:i));const[r,s]=Ar(e,t,{staticPosition:o});i+=s,c.push(r)}return e.setPosition(r+32),[c,32]}if(Nr(t)){const o=r+Pr(e.readBytes(Sr)),s=[];for(let r=0;r<n;++r){e.setPosition(o+32*r);const[n]=Ar(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]=Ar(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(Nr(t)){const a=n+Pr(e.readBytes(Sr));for(let n=0;n<t.components.length;++n){const i=t.components[n];e.setPosition(a+s);const[c,u]=Ar(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]=Ar(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[Ln(Ut(Yn(t,-20))),32]}(e);if("bool"===t.type)return function(e){return[Er(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=Pr(e.readBytes(32));e.setPosition(n+t);const r=Pr(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[Ut(o),32]}const s=Ut(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?xr(o,{signed:n}):Pr(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=Pr(e.readBytes(32)),r=t+n;e.setPosition(r);const o=Pr(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=Ot(n,{dir:"right"})),(new TextDecoder).decode(n)}(Ot(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:n});throw new vt(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Ir=32,Sr=32;function Nr(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(Nr);const n=er(e.type);return!(!n||!Nr({...e,type:n[1]}))}function Tr(e){const{abi:t,data:n}=e,r=qn(n,0,4);if("0x"===r)throw new nt;const o=[...t||[],pr,mr].find(e=>"error"===e.type&&r===tr(We(e)));if(!o)throw new ct(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:o,args:"inputs"in o&&o.inputs&&o.inputs.length>0?kr(o.inputs,qn(n,4)):void 0,errorName:o.name}}const Br=(e,t,n)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,n);function Cr({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]?Br(t[n]):t[n]}`).join(", ")})`}const $r={gwei:9,wei:18},Or={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 Rr(e,t="wei"){return _r(e,$r[t])}function zr(e,t="wei"){return _r(e,Or[t])}class Mr extends Je{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class Lr extends Je{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Fr(e){return e.reduce((e,{slot:t,value:n})=>`${e} ${t}: ${n}\n`,"")}function Ur(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 jr extends Je{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 Dr extends Je{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Ur(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 Gr extends Je{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 Wr extends Je{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 qr extends Je{constructor({hash:e}){super(`Timed out while waiting for transaction with hash "${e}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}class Vr extends Je{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?lr(t):void 0;let p=Ur({from:h?.address,to:l,value:void 0!==d&&`${Rr(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${zr(a)} gwei`,maxFeePerGas:void 0!==i&&`${zr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${zr(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+=Fr(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=Fr(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 Hr extends Je{constructor(e,{abi:t,args:n,contractAddress:r,docsPath:o,functionName:s,sender:a}){const i=nr({abi:t,args:n,name:s}),c=i?Cr({abiItem:i,args:n,includeFunctionName:!1,includeName:!1}):void 0,u=Ur({address:r&&r,function:i?We(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 Yr extends Je{constructor({abi:e,data:t,functionName:n,message:r}){let o,s,a,i,c;if(t&&"0x"!==t)try{s=Tr({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=hr[e]}else{const e=n?We(n,{includeName:!0}):void 0,t=n&&o?Cr({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 ct&&(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 Kr extends Je{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 Zr extends Je{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 Jr extends Je{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 Qr extends Je{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: ${Br(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 Xr extends Je{constructor({body:e,error:t,url:n}){super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${n}`,`Request body: ${Br(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 eo extends Je{constructor({body:e,url:t}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${t}`,`Request body: ${Br(e)}`],name:"TimeoutError"})}}class to extends Je{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 Xr?e.code:t??-1}}class no extends to{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class ro extends to{constructor(e){super(e,{code:ro.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(ro,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class oo extends to{constructor(e){super(e,{code:oo.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(oo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class so extends to{constructor(e,{method:t}={}){super(e,{code:so.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(so,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class ao extends to{constructor(e){super(e,{code:ao.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(ao,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class io extends to{constructor(e){super(e,{code:io.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(io,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class co extends to{constructor(e){super(e,{code:co.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(co,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class uo extends to{constructor(e){super(e,{code:uo.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(uo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class lo extends to{constructor(e){super(e,{code:lo.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(lo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class fo extends to{constructor(e){super(e,{code:fo.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(fo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class ho extends to{constructor(e,{method:t}={}){super(e,{code:ho.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not supported.`})}}Object.defineProperty(ho,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class po extends to{constructor(e){super(e,{code:po.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(po,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class mo extends to{constructor(e){super(e,{code:mo.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(mo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class go extends no{constructor(e){super(e,{code:go.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(go,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class bo extends no{constructor(e){super(e,{code:bo.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(bo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class yo extends no{constructor(e,{method:t}={}){super(e,{code:yo.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(yo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class wo extends no{constructor(e){super(e,{code:wo.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(wo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class vo extends no{constructor(e){super(e,{code:vo.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(vo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class xo extends no{constructor(e){super(e,{code:xo.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(xo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class Eo extends no{constructor(e){super(e,{code:Eo.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(Eo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Po extends no{constructor(e){super(e,{code:Po.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Po,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class ko extends no{constructor(e){super(e,{code:ko.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(ko,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class Ao extends no{constructor(e){super(e,{code:Ao.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(Ao,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Io extends no{constructor(e){super(e,{code:Io.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Io,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class So extends no{constructor(e){super(e,{code:So.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(So,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class No extends no{constructor(e){super(e,{code:No.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(No,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class To extends to{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Bo=3;function Co(e,{abi:t,address:n,args:r,docsPath:o,functionName:s,sender:a}){const i=e instanceof Jr?e:e instanceof Je?e.walk(e=>"data"in e)||e.walk():{},{code:c,data:u,details:l,message:d,shortMessage:f}=i,h=e instanceof nt?new Kr({functionName:s}):[Bo,io.code].includes(c)&&(u||l||d||f)?new Yr({abi:t,data:"object"==typeof u?u.data:u,functionName:s,message:i instanceof Xr?l:f??d}):e;return new Hr(h,{abi:t,args:r,contractAddress:n,docsPath:o,functionName:s,sender:a})}function $o(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 Oo({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=Ve(e)?e:Lt(e),{secp256k1:r}=await Promise.resolve().then(function(){return Xl}),o=(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:n,v:o,yParity:s}=t,a=$o(Number(s??o));return new r.Signature(Rt(e),Rt(n)).addRecoveryBit(a)}const e=Ve(t)?t:Lt(t);if(65!==He(e))throw new Error("invalid signature length");const n=$o(zt(`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}),Ln(`0x${Bn(`0x${n.substring(4)}`).substring(26)}`);var n}function _o(e,t="hex"){const n=Ro(e),r=vr(new Uint8Array(n.length));return n.encode(r),"hex"===t?Ut(r.bytes):r.bytes}function Ro(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),n=zo(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=>Ro(e))):function(e){const t="string"==typeof e?Yt(e):e,n=zo(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 zo(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 Je("Length is too large.")}function Mo(e){const{chainId:t,nonce:n,to:r}=e,o=e.contractAddress??e.address,s=Bn(Wn(["0x05",_o([t?jt(t):"0x",o,n?jt(n):"0x"])]));return"bytes"===r?Yt(s):s}async function Lo(e){const{authorization:t,signature:n}=e;return Oo({hash:Mo(t),signature:n??t})}class Fo extends Je{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=Ur({from:t?.address,to:l,value:void 0!==d&&`${Rr(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${zr(a)} gwei`,maxFeePerGas:void 0!==i&&`${zr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${zr(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 Uo extends Je{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(Uo,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Uo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class jo extends Je{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${zr(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(jo,"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 Do extends Je{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${zr(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(Do,"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 Go extends Je{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(Go,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Wo extends Je{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(Wo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class qo extends Je{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(qo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Vo extends Je{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(Vo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Ho extends Je{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(Ho,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Yo extends Je{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(Yo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Ko extends Je{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Ko,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Zo extends Je{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${zr(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${zr(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Zo,"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 Jo extends Je{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Qo(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof Je?e.walk(e=>e?.code===Uo.code):e;return r instanceof Je?new Uo({cause:e,message:r.details}):Uo.nodeMessage.test(n)?new Uo({cause:e,message:e.details}):jo.nodeMessage.test(n)?new jo({cause:e,maxFeePerGas:t?.maxFeePerGas}):Do.nodeMessage.test(n)?new Do({cause:e,maxFeePerGas:t?.maxFeePerGas}):Go.nodeMessage.test(n)?new Go({cause:e,nonce:t?.nonce}):Wo.nodeMessage.test(n)?new Wo({cause:e,nonce:t?.nonce}):qo.nodeMessage.test(n)?new qo({cause:e,nonce:t?.nonce}):Vo.nodeMessage.test(n)?new Vo({cause:e}):Ho.nodeMessage.test(n)?new Ho({cause:e,gas:t?.gas}):Yo.nodeMessage.test(n)?new Yo({cause:e,gas:t?.gas}):Ko.nodeMessage.test(n)?new Ko({cause:e}):Zo.nodeMessage.test(n)?new Zo({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new Jo({cause:e})}function Xo(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 es={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function ts(e){const t={};return void 0!==e.authorizationList&&(t.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?jt(BigInt(e.r)):e.r,s:e.s?jt(BigInt(e.s)):e.s,chainId:jt(e.chainId),nonce:jt(e.nonce),...void 0!==e.yParity?{yParity:jt(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:jt(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=>Ut(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=jt(e.gas)),void 0!==e.gasPrice&&(t.gasPrice=jt(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(t.maxFeePerBlobGas=jt(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=jt(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=jt(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=jt(e.nonce)),void 0!==e.to&&(t.to=e.to),void 0!==e.type&&(t.type=es[e.type]),void 0!==e.value&&(t.value=jt(e.value)),t}function ns(e){if(e&&0!==e.length)return e.reduce((e,{slot:t,value:n})=>{if(66!==t.length)throw new It({size:t.length,targetSize:66,type:"hex"});if(66!==n.length)throw new It({size:n.length,targetSize:66,type:"hex"});return e[t]=n,e},{})}function rs(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=jt(t)),void 0!==n&&(a.nonce=jt(n)),void 0!==r&&(a.state=ns(r)),void 0!==o){if(a.state)throw new Lr;a.stateDiff=ns(o)}return a}function os(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!Dn(n,{strict:!1}))throw new Rn({address:n});if(t[n])throw new Mr({address:n});t[n]=rs(r)}return t}const ss=2n**256n-1n;function as(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:o,to:s}=e,a=t?lr(t):void 0;if(a&&!Dn(a.address))throw new Rn({address:a.address});if(s&&!Dn(s))throw new Rn({address:s});if(void 0!==n&&(void 0!==r||void 0!==o))throw new jr;if(r&&r>ss)throw new jo({maxFeePerGas:r});if(o&&r&&o>r)throw new Zo({maxFeePerGas:r,maxPriorityFeePerGas:o})}class is extends Je{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class cs extends Je{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class us extends Je{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${zr(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class ls extends Je{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 ds={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function fs(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?zt(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?zt(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?ds[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 hs(e){const t=(e.transactions??[]).map(e=>"string"==typeof e?e:fs(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 ps(e,{blockHash:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",includeTransactions:o}={}){const s=o??!1,a=void 0!==n?jt(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 ls({blockHash:t,blockNumber:n});return(e.chain?.formatters?.block?.format||hs)(i)}async function ms(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function gs(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 Ge(e,ps,"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 Rt(await e.request({method:"eth_maxPriorityFeePerGas"}))}catch{const[t,r]=await Promise.all([n?Promise.resolve(n):Ge(e,ps,"getBlock")({}),Ge(e,ms,"getGasPrice")({})]);if("bigint"!=typeof t.baseFeePerGas)throw new cs;const o=r-t.baseFeePerGas;return o<0n?0n:o}}async function bs(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 is;const i=10**(a.toString().split(".")[1]?.length??0),c=e=>e*BigInt(Math.ceil(a*i))/BigInt(i),u=n||await Ge(e,ps,"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 cs;const t="bigint"==typeof o?.maxPriorityFeePerGas?o.maxPriorityFeePerGas:await gs(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 Ge(e,ms,"getGasPrice")({}))}}async function ys(e,{address:t,blockTag:n="latest",blockNumber:r}){return zt(await e.request({method:"eth_getTransactionCount",params:[t,"bigint"==typeof r?jt(r):n]},{dedupe:Boolean(r)}))}function ws(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=>Yt(e)):e.blobs,o=[];for(const e of r)o.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?o:o.map(e=>Ut(e))}function vs(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=>Yt(e)):e.blobs,o="string"==typeof e.commitments[0]?e.commitments.map(e=>Yt(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=>Ut(e))}function xs(e,t,n){return e&t^~e&n}function Es(e,t,n){return e&t^e&n^t&n}class Ps extends dn{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=sn(this.buffer)}update(e){nn(this),tn(e=ln(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=sn(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){nn(this),rn(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,on(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=sn(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 ks=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),As=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]),Is=new Uint32Array(64);class Ss extends Ps{constructor(e=32){super(64,e,8,!1),this.A=0|ks[0],this.B=0|ks[1],this.C=0|ks[2],this.D=0|ks[3],this.E=0|ks[4],this.F=0|ks[5],this.G=0|ks[6],this.H=0|ks[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)Is[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Is[e-15],n=Is[e-2],r=an(t,7)^an(t,18)^t>>>3,o=an(n,17)^an(n,19)^n>>>10;Is[e]=o+Is[e-7]+r+Is[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+(an(a,6)^an(a,11)^an(a,25))+xs(a,i,c)+As[e]+Is[e]|0,l=(an(n,2)^an(n,13)^an(n,22))+Es(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(){on(Is)}destroy(){this.set(0,0,0,0,0,0,0,0),on(this.buffer)}}const Ns=fn(()=>new Ss),Ts=Ns;function Bs(e){const{commitment:t,version:n=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),o=Ts(Ve(s=t,{strict:!1})?qt(s):s);var s;return o.set([n],0),"bytes"===r?o:Ut(o)}const Cs=4096,$s=131072,Os=761855;class _s extends Je{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class Rs extends Je{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function zs(e){const{data:t,kzg:n,to:r}=e,o=e.blobs??function(e){const t="string"==typeof e.data?Yt(e.data):e.data,n=He(t);if(!n)throw new Rs;if(n>Os)throw new _s({maxSize:Os,size:n});const r=[];let o=!0,s=0;for(;o;){const e=vr(new Uint8Array($s));let n=0;for(;n<Cs;){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=>Ut(e.bytes))}({data:t}),s=e.commitments??ws({blobs:o,kzg:n,to:r}),a=e.proofs??vs({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 Ms(e){return zt(await e.request({method:"eth_chainId"},{dedupe:!0}))}const Ls=["blobVersionedHashes","chainId","fees","gas","nonce","type"],Fs=new Map;async function Us(e,t){const{account:n=e.account,blobs:r,chain:o,gas:s,kzg:a,nonce:i,nonceManager:c,parameters:u=Ls,type:l}=t,d=n?lr(n):n,f={...t,...d?{from:d?.address}:{}};let h,p;async function m(){return h||(h=await Ge(e,ps,"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 Ge(e,Ms,"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 Ge(e,ys,"getTransactionCount")({address:d.address,blockTag:"pending"});if((u.includes("blobVersionedHashes")||u.includes("sidecars"))&&r&&a){const e=ws({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(Bs({commitment:e,to:r,version:n}));return o}({commitments:e,to:"hex"});f.blobVersionedHashes=t}if(u.includes("sidecars")){const t=zs({blobs:r,commitments:e,proofs:vs({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 Dr({transaction:e})}(f)}catch{let t=Fs.get(e.uid);if(void 0===t){const n=await m();t="bigint"==typeof n?.baseFeePerGas,Fs.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 bs(e,{block:n,chain:o,request:f});if(void 0===t.maxPriorityFeePerGas&&t.maxFeePerGas&&t.maxFeePerGas<s)throw new us({maxPriorityFeePerGas:s});f.maxPriorityFeePerGas=s,f.maxFeePerGas=r}}else{if(void 0!==t.maxFeePerGas||void 0!==t.maxPriorityFeePerGas)throw new cs;if(void 0===t.gasPrice){const t=await m(),{gasPrice:n}=await bs(e,{block:t,chain:o,request:f,type:"legacy"});f.gasPrice=n}}return u.includes("gas")&&void 0===s&&(f.gas=await Ge(e,js,"estimateGas")({...f,account:d?{address:d.address,type:"json-rpc"}:d})),as(f),delete f.parameters,f}async function js(e,t){const{account:n=e.account}=t,r=n?lr(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 Us(e,{...t,parameters:"local"===r?.type?void 0:["blobVersionedHashes"]}),w=("bigint"==typeof i?jt(i):void 0)||c,v=os(b),x=await(async()=>y.to?y.to:o&&o.length>0?await Lo({authorization:o[0]}).catch(()=>{throw new Je("`to` is required. Could not infer from `authorizationList`")}):void 0)();as(t);const E=e.chain?.formatters?.transactionRequest?.format,P=(E||ts)({...Xo(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=Qo(e,n);return t instanceof Jo?e:t})();return new Fo(r,{docsPath:t,...n})}(n,{...t,account:r,chain:e.chain})}}function Ds(e,t){if(!Dn(e,{strict:!1}))throw new Rn({address:e});if(!Dn(t,{strict:!1}))throw new Rn({address:t});return e.toLowerCase()===t.toLowerCase()}const Gs="/docs/contract/decodeEventLog";function Ws(e){const{abi:t,data:n,strict:r,topics:o}=e,s=r??!0,[a,...i]=o;if(!a)throw new ut({docsPath:Gs});const c=t.find(e=>"event"===e.type&&a===_n(We(e)));if(!c||!("name"in c)||"event"!==c.type)throw new lt(a,{docsPath:Gs});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 yt({abiItem:c,param:t});f[d?n:t.name||n]=qs({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=kr(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 tt||e instanceof br)throw new bt({abiItem:c,data:n,params:p,size:He(n)});throw e}}else if(s)throw new bt({abiItem:c,data:"0x",params:p,size:0});return{eventName:u,args:Object.values(f).length>0?f:void 0}}function qs({param:e,value:t}){if("string"===e.type||"bytes"===e.type||"tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))return t;return(kr([e],t)||[])[0]}function Vs(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=Ws({...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?Ds(t,n):"string"===e.type||"bytes"===e.type?Bn(qt(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 lt)return null;if(t instanceof bt||t instanceof yt){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 Hs(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 Ys(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=>ar({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?jt(r):r,toBlock:"bigint"==typeof o?jt(o):o}]});const h=d.map(e=>Hs(e));return l?Vs({abi:l,args:i,logs:h,strict:u}):h}async function Ks(e,t){const{abi:n,address:r,args:o,blockHash:s,eventName:a,fromBlock:i,toBlock:c,strict:u}=t,l=a?nr({abi:n,name:a}):void 0,d=l?void 0:n.filter(e=>"event"===e.type);return Ge(e,Ys,"getLogs")({address:r,args:o,blockHash:s,event:l,events:d,fromBlock:i,toBlock:c,strict:u})}const Zs="/docs/contract/decodeFunctionResult";function Js(e){const{abi:t,args:n,functionName:r,data:o}=e;let s=t[0];if(r){const e=nr({abi:t,args:n,name:r});if(!e)throw new ft(r,{docsPath:Zs});s=e}if("function"!==s.type)throw new ft(void 0,{docsPath:Zs});if(!s.outputs)throw new ht(s.name,{docsPath:Zs});const a=kr(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 Qs=BigInt(0),Xs=BigInt(1);function ea(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function ta(e){if(!ea(e))throw new Error("Uint8Array expected")}function na(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function ra(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function oa(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Qs:BigInt("0x"+e)}const sa="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,aa=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ia(e){if(ta(e),sa)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=aa[e[n]];return t}const ca=48,ua=57,la=65,da=70,fa=97,ha=102;function pa(e){return e>=ca&&e<=ua?e-ca:e>=la&&e<=da?e-(la-10):e>=fa&&e<=ha?e-(fa-10):void 0}function ma(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(sa)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=pa(e.charCodeAt(o)),s=pa(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 ga(e){return oa(ia(e))}function ba(e){return ta(e),oa(ia(Uint8Array.from(e).reverse()))}function ya(e,t){return ma(e.toString(16).padStart(2*t,"0"))}function wa(e,t){return ya(e,t).reverse()}function va(e,t,n){let r;if("string"==typeof t)try{r=ma(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!ea(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 xa(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];ta(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 Ea=e=>"bigint"==typeof e&&Qs<=e;function Pa(e,t,n){return Ea(e)&&Ea(t)&&Ea(n)&&t<=e&&e<n}function ka(e,t,n,r){if(!Pa(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const Aa=e=>(Xs<<BigInt(e))-Xs,Ia=e=>new Uint8Array(e),Sa=e=>Uint8Array.from(e);const Na={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||ea(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 Ta(e,t,n={}){const r=(t,n,r)=>{const o=Na[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 Ba(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 Ca extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof Ca){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 Ca&&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 $a(this,e)}}function $a(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?$a(e.cause,t):t?null:e}function Oa(e,t){if(Za(e)>t)throw new oi({givenSize:Za(e),maxSize:t})}const _a=48,Ra=57,za=65,Ma=70,La=97,Fa=102;function Ua(e){return e>=_a&&e<=Ra?e-_a:e>=za&&e<=Ma?e-(za-10):e>=La&&e<=Fa?e-(La-10):void 0}function ja(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 Da(e,t){if(gi(e)>t)throw new Pi({givenSize:gi(e),maxSize:t})}function Ga(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 Ai({size:Math.ceil(o.length/2),targetSize:r,type:"Hex"});return`0x${o["right"===n?"padEnd":"padStart"](2*r,"0")}`}function Wa(e,t,n){return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString()+"#__bigint":t,n)}const qa=new TextDecoder,Va=new TextEncoder;function Ha(e){return e instanceof Uint8Array?e:"string"==typeof e?Ya(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}function Ya(e,t={}){const{size:n}=t;let r=e;n&&(Da(e,n),r=pi(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=Ua(o.charCodeAt(t++)),r=Ua(o.charCodeAt(t++));if(void 0===n||void 0===r)throw new Ca(`Invalid byte sequence ("${o[t-2]}${o[t-1]}" in "${o}").`);a[e]=16*n+r}return a}function Ka(e,t={}){const{size:n}=t,r=Va.encode(e);return"number"==typeof n?(Oa(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 si({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 Za(e){return e.length}function Ja(e,t,n,r={}){const{strict:o}=r;return e.slice(t,n)}function Qa(e,t={}){const{size:n}=t;void 0!==n&&Oa(e,n);return bi(li(e,t),t)}function Xa(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&(Oa(r,n),r=ni(r)),r.length>1||r[0]>1)throw new ri(r);return Boolean(r[0])}function ei(e,t={}){const{size:n}=t;void 0!==n&&Oa(e,n);return yi(li(e,t),t)}function ti(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&(Oa(r,n),r=ja(r,{dir:"right"})),qa.decode(r)}function ni(e){return ja(e,{dir:"left"})}class ri extends Ca{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 oi=class extends Ca{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"})}},si=class extends Ca{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 ai=new TextEncoder,ii=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ci(...e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function ui(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(Da(n,t.size),hi(n,t.size)):n}function li(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=ii[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(Da(r,t.size),pi(r,t.size)):r}function di(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 vi({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?hi(i,r):i}function fi(e,t={}){return li(ai.encode(e),t)}function hi(e,t){return Ga(e,{dir:"left",size:t})}function pi(e,t){return Ga(e,{dir:"right",size:t})}function mi(e,t,n,r={}){const{strict:o}=r;!function(e,t){if("number"==typeof t&&t>0&&t>gi(e)-1)throw new ki({offset:t,position:"start",size:gi(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&&gi(e)!==n-t)throw new ki({offset:n,position:"end",size:gi(e)})}(s,t,n),s}function gi(e){return Math.ceil((e.length-2)/2)}function bi(e,t={}){const{signed:n}=t;t.size&&Da(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 yi(e,t={}){const{signed:n,size:r}=t;return Number(n||r?bi(e,t):e)}function wi(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new xi(e);if("string"!=typeof e)throw new xi(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new Ei(e);if(!e.startsWith("0x"))throw new Ei(e)}(e,{strict:n}),!0}catch{return!1}}class vi extends Ca{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 xi extends Ca{constructor(e){super(`Value \`${"object"==typeof e?Wa(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 Ei extends Ca{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 Pi extends Ca{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 ki extends Ca{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 Ai extends Ca{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 Ii(e){return{address:e.address,amount:di(e.amount),index:di(e.index),validatorIndex:di(e.validatorIndex)}}function Si(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:di(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:di(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:di(e.gasLimit)},..."bigint"==typeof e.number&&{number:di(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:di(e.prevRandao)},..."bigint"==typeof e.time&&{time:di(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(Ii)}}}const Ni=[{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"}],Ti=[{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"}]}],Bi=[{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"}],Ci=[...Bi,{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"}]}],$i=[...Bi,{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"}]}],Oi=[{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"}]}],Ri=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],zi=[{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"}],Mi="0x82ad56cb",Li="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",Fi="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",Ui="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",ji="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class Di extends Je{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 Gi extends Je{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}const Wi="/docs/contract/encodeDeployData";function qi(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 Xe({docsPath:Wi});if(!("inputs"in o))throw new et({docsPath:Wi});if(!o.inputs||0===o.inputs.length)throw new et({docsPath:Wi});return Wn([r,Jn(o.inputs,n)])}function Vi({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new Di({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new Di({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function Hi(e,{docsPath:t,...n}){const r=(()=>{const t=Qo(e,n);return t instanceof Jo?e:t})();return new Vr(r,{docsPath:t,...n})}function Yi(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const Ki=new Map;function Zi({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=()=>Ki.delete(t),i=()=>Ki.get(t)||[],c=e=>Ki.set(t,[...i(),e]);return{flush:a,async schedule(e){const{promise:t,resolve:o,reject:a}=Yi(),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 Ji(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?lr(n):void 0;if(l&&(f||h))throw new Je("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(l&&v)throw new Je("Cannot provide both `code` & `to` as parameters.");const A=l&&d,I=f&&h&&v&&d,S=A||I,N=A?Qi({code:l,data:d}):I?function(e){const{data:t,factory:n,factoryData:r,to:o}=e;return qi({abi:Ue(["constructor(address, bytes, address, bytes)"]),bytecode:Fi,args:[o,t,n,r]})}({data:d,factory:f,factoryData:h,to:v}):d;try{as(t);const n=("bigint"==typeof s?jt(s):void 0)||a,l=u?Si(u):void 0,d=os(E),f=e.chain?.formatters?.transactionRequest?.format,h=(f||ts)({...Xo(P,{format:f}),from:k?.address,accessList:i,authorizationList:r,blobs:c,data:N,gas:p,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:b,maxPriorityFeePerGas:y,nonce:w,to:S?void 0:v,value:x});if(o&&function({request:e}){const{data:t,to:n,...r}=e;return!!t&&(!t.startsWith(Mi)&&(!!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 Vi({blockNumber:s,chain:e.chain,contract:"multicall3"});throw new Gi})(),l="bigint"==typeof s?jt(s):void 0,d=l||a,{schedule:f}=Zi({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=fr({abi:Ni,args:[n],functionName:"aggregate3"}),o=await e.request({method:"eth_call",params:[{...null===u?{data:Qi({code:ji,data:r})}:{to:u,data:r}},d]});return Js({abi:Ni,args:[n],functionName:"aggregate3",data:o||"0x"})}}),[{returnData:h,success:p}]=await f({data:i,to:c});if(!p)throw new Jr({data:h});return"0x"===h?{data:void 0}:{data:h}}(e,{...h,blockNumber:s,blockTag:a})}catch(e){if(!(e instanceof Gi||e instanceof Di))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 Je))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 ru});if(!1!==e.ccipRead&&r?.slice(0,10)===s&&v)return{data:await o(e,{data:r,to:v})};if(S&&"0x101bb98d"===r?.slice(0,10))throw new Zr({factory:f});throw Hi(n,{...t,account:k,chain:e.chain})}}function Qi(e){const{code:t,data:n}=e;return qi({abi:Ue(["constructor(bytes, bytes)"]),bytecode:Li,args:[t,n]})}async function Xi(e,t){const{abi:n,address:r,args:o,functionName:s,...a}=t,i=fr({abi:n,args:o,functionName:s});try{const{data:t}=await Ge(e,Ji,"call")({...a,data:i,to:r});return Js({abi:n,args:o,functionName:s,data:t||"0x"})}catch(e){throw Co(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/readContract",functionName:s})}}const ec=new Map,tc=new Map;let nc=0;function rc(e,t,n){const r=++nc,o=()=>ec.get(e)||[],s=()=>{const t=o();if(!t.some(e=>e.id===r))return;const n=tc.get(e);if(1===t.length&&n){const e=n();e instanceof Promise&&e.catch(()=>{})}(()=>{const t=o();ec.set(e,t.filter(e=>e.id!==r))})()},a=o();if(ec.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&&tc.set(e,c),s}async function oc(e){return new Promise(t=>setTimeout(t,e))}function sc(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 oc(i);const c=async()=>{o&&(await e({unpoll:s}),await oc(r),c())};c()})(),s}const ac=new Map,ic=new Map;async function cc(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,ac),r=t(e,ic);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 uc(e,{cacheTime:t=e.cacheTime}={}){const n=await cc(()=>e.request({method:"eth_blockNumber"}),{cacheKey:(r=e.uid,`blockNumber.${r}`),cacheTime:t});var r;return BigInt(n)}async function lc(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=>Hs(e));return"abi"in t&&t.abi?Vs({abi:t.abi,logs:o,strict:n}):o}async function dc(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function fc(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 oc(n),a({count:i+1})})({error:e});s(e)}};a()})}const hc={"0x0":"reverted","0x1":"success"};function pc(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=>Hs(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?zt(e.transactionIndex):null,status:e.status?hc[e.status]:null,type:e.type?ds[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}let mc,gc=256;function bc(e=11){if(!mc||gc+e>512){mc="",gc=0;for(let e=0;e<256;e++)mc+=(256+256*Math.random()|0).toString(16).substring(1)}return mc.substring(gc,gc+++e)}function yc(e){if(!(e instanceof Je))return!1;const t=e.walk(e=>e instanceof Yr);return t instanceof Yr&&("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 wc="/docs/contract/encodeErrorResult";function vc(e){const{abi:t,errorName:n,args:r}=e;let o=t[0];if(n){const e=nr({abi:t,args:r,name:n});if(!e)throw new it(n,{docsPath:wc});o=e}if("error"!==o.type)throw new it(void 0,{docsPath:wc});const s=We(o),a=tr(s);let i="0x";if(r&&r.length>0){if(!o.inputs)throw new at(o.name,{docsPath:wc});i=Jn(o.inputs,r)}return Wn([a,i])}const xc="/docs/contract/encodeFunctionResult";const Ec="x-batch-gateway:true";async function Pc(e){const{data:t,ccipRequest:n}=e,{args:[r]}=function(e){const{abi:t,data:n}=e,r=qn(n,0,4),o=t.find(e=>"function"===e.type&&r===tr(We(e)));if(!o)throw new pt(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:o.name,args:"inputs"in o&&o.inputs&&o.inputs.length>0?kr(o.inputs,qn(n,4)):void 0}}({abi:Ti,data:t}),o=[],s=[];return await Promise.all(r.map(async(e,t)=>{try{s[t]=e.urls.includes(Ec)?await Pc({data:e.data,ccipRequest:n}):await n(e),o[t]=!1}catch(e){o[t]=!0,s[t]="HttpRequestError"===(r=e).name&&r.status?vc({abi:Ti,errorName:"HttpError",args:[r.status,r.shortMessage]}):vc({abi:[pr],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=nr({abi:t,name:n});if(!e)throw new ft(n,{docsPath:xc});o=e}if("function"!==o.type)throw new ft(void 0,{docsPath:xc});if(!o.outputs)throw new ht(o.name,{docsPath:xc});const s=(()=>{if(0===o.outputs.length)return[];if(1===o.outputs.length)return[r];if(Array.isArray(r))return r;throw new xt(r)})();return Jn(o.outputs,s)}({abi:Ti,functionName:"query",result:[o,s]})}function kc(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 Ve(t)?t:null}function Ac(e){let t=new Uint8Array(32).fill(0);if(!e)return Ut(t);const n=e.split(".");for(let e=n.length-1;e>=0;e-=1){const r=kc(n[e]),o=r?qt(r):Bn(Kt(n[e]),"bytes");t=Bn(Gn([t,o]),"bytes")}return Ut(t)}function Ic(e){return`[${e.slice(2)}]`}function Sc(e){const t=new Uint8Array(32).fill(0);return e?kc(e)||Bn(Kt(e)):Ut(t)}function Nc(e){const t=e.replace(/^\.|\.$/gm,"");if(0===t.length)return new Uint8Array(1);const n=new Uint8Array(Kt(t).byteLength+2);let r=0;const o=t.split(".");for(let e=0;e<o.length;e++){let t=Kt(o[e]);t.byteLength>255&&(t=Kt(Ic(Sc(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 Tc extends Je{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 Bc extends Je{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`,{name:"EnsAvatarInvalidNftUriError"})}}class Cc extends Je{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 $c extends Je{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const Oc=/(?<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>\/.*)?$/,Rc=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,zc=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;function Mc(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function Lc({uri:e,gatewayUrls:t}){const n=Rc.test(e);if(n)return{uri:e,isOnChain:!0,isEncoded:n};const r=Mc(t?.ipfs,"https://ipfs.io"),o=Mc(t?.arweave,"https://arweave.net"),s=e.match(Oc),{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(zc,"");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 Cc({uri:e})}function Fc(e){if("object"!=typeof e||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new Tc({data:e});return e.image||e.image_url||e.image_data}async function Uc({gatewayUrls:e,uri:t}){const{uri:n,isOnChain:r}=Lc({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 Cc({uri:t})}async function jc(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 Bc({reason:"Only EIP-155 supported"});if(!a)throw new Bc({reason:"Chain ID not found"});if(!c)throw new Bc({reason:"Contract address not found"});if(!o)throw new Bc({reason:"Token ID not found"});if(!i)throw new Bc({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 Xi(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 Xi(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 $c({namespace:t.namespace})}(e,{nft:r}),{uri:s,isOnChain:a,isEncoded:i}=Lc({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 Uc({uri:Fc(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 Uc({gatewayUrls:e,uri:Fc(n)})}catch{throw new Cc({uri:t})}}({gatewayUrls:t,uri:s.replace(/(?:0x)?{id}/,c)})}(e,{gatewayUrls:t,record:n}):Uc({uri:n,gatewayUrls:t})}async function Dc(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 Vi({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:Ci,args:[Lt(Nc(s)),fr({abi:Oi,functionName:"text",args:[Ac(s),o]}),a??[Ec]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},i=Ge(e,Xi,"readContract"),c=await i(t);if("0x"===c[0])return null;const l=Js({abi:Oi,functionName:"text",data:c[0]});return""===l?null:l}catch(e){if(i)throw e;if(yc(e))return null;throw e}}async function Gc(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?lr(n):void 0;try{as(t);const n=("bigint"==typeof r?jt(r):void 0)||o,g=e.chain?.formatters?.transactionRequest?.format,b=(g||ts)({...Xo(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 Hi(n,{...t,account:m,chain:e.chain})}}async function Wc(e,{address:t,args:n,event:r,events:o,fromBlock:s,strict:a,toBlock:i}={}){const c=o??(r?[r]:void 0),u=cr(e,{method:"eth_newFilter"});let l=[];if(c){const e=c.flatMap(e=>ar({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?jt(s):s,toBlock:"bigint"==typeof i?jt(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 qc(e){const t=cr(e,{method:"eth_newPendingTransactionFilter"}),n=await e.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:t(n),type:"transaction"}}async function Vc(e,{address:t,blockNumber:n,blockTag:r="latest"}){const o=void 0!==n?jt(n):void 0,s=await e.request({method:"eth_getCode",params:[t,o||r]},{dedupe:Boolean(o)});if("0x"!==s)return s}class Hc extends Je{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 Yc=[{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 Kc(e,{blockCount:t,blockNumber:n,blockTag:r="latest",rewardPercentiles:o}){const s="bigint"==typeof n?jt(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:[jt(t),s||r,o]},{dedupe:Boolean(s)}))}const Zc=new zn(8192);function Jc(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 ho(new Error("method not supported"),{method:u});if(s?.include&&!s.include.includes(u))throw new ho(new Error("method not supported"),{method:u});return function(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(Zc.get(n))return Zc.get(n);const r=e().finally(()=>Zc.delete(n));return Zc.set(n,r),r}(()=>fc(async()=>{try{return await e(n)}catch(e){const t=e;switch(t.code){case ro.code:throw new ro(t);case oo.code:throw new oo(t);case so.code:throw new so(t,{method:n.method});case ao.code:throw new ao(t);case io.code:throw new io(t);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,{method:n.method});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 Ao.code:throw new Ao(t);case Io.code:throw new Io(t);case So.code:throw new So(t);case No.code:throw new No(t);case 5e3:throw new go(t);default:if(e instanceof Je)throw e;throw new To(t)}}},{delay:({count:e,error:t})=>{if(t&&t instanceof Qr){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===po.code||e.code===io.code);if(e instanceof Qr&&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?Gt(`${c}.${Br(n)}`):void 0})}}class Qc extends Je{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 Xc extends Je{constructor({result:e,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${t}`,`Response: ${Br(e)}`],name:"OffchainLookupResponseMalformedError"})}}class eu extends Je{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 tu={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 nu({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 Qr({body:i,details:o?.error?Br(o.error):n.statusText,headers:n.headers,status:n.status,url:s});continue}if(!Ve(o)){r=new Xc({result:o,url:s});continue}return o}catch(e){r=new Qr({body:i,details:e.message,url:s})}}throw r}var ru=Object.freeze({__proto__:null,ccipRequest:nu,offchainLookup:async function(e,{blockNumber:t,blockTag:n,data:r,to:o}){const{args:s}=Tr({data:r,abi:[tu]}),[a,i,c,u,l]=s,{ccipRead:d}=e,f=d&&"function"==typeof d?.request?d.request:nu;try{if(!Ds(o,a))throw new eu({sender:a,to:o});const r=i.includes(Ec)?await Pc({data:c,ccipRequest:f}):await f({data:c,sender:a,urls:i}),{data:s}=await Ji(e,{blockNumber:t,blockTag:n,data:Gn([u,Jn([{type:"bytes"},{type:"bytes"}],[r,l])]),to:o});return s}catch(e){throw new Qc({callbackSelector:u,cause:e,data:r,extraData:l,sender:a,urls:i})}},offchainLookupAbiItem:tu,offchainLookupSignature:"0x556f1830"});function ou(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const su=ou();function au(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)?Br(r.map(e=>({jsonrpc:"2.0",id:e.id??su.take(),...e}))):Br({jsonrpc:"2.0",id:r.id??su.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 eo({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 Qr({body:r,details:Br(n.error)||t.statusText,headers:t.headers,status:t.status,url:e});return n}catch(t){if(t instanceof Qr)throw t;if(t instanceof eo)throw t;throw new Qr({body:r,cause:t,url:e})}}}}function iu(e,t){return Bn(function(e){const t="string"==typeof e?Gt(e):"string"==typeof e.raw?e.raw:Ut(e.raw);return Gn([Gt(`Ethereum Signed Message:\n${He(t)}`),t])}(e),t)}class cu extends Je{constructor({domain:e}){super(`Invalid domain "${Br(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class uu extends Je{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 lu extends Je{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function du({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 fu(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new lu({type:e})}function hu(e){const{domain:t={},message:n,primaryType:r}=e,o={EIP712Domain:du({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(Zn);if(i&&("number"==typeof a||"bigint"==typeof a)){const[e,t,n]=i;jt(a,{signed:"int"===t,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof a&&!Dn(a))throw new Rn({address:a});const c=r.match(Kn);if(c){const[e,t]=c;if(t&&He(a)!==Number.parseInt(t,10))throw new gt({expectedSize:Number.parseInt(t,10),givenSize:He(a)})}const u=o[r];u&&(fu(r),s(u,a))}};if(o.EIP712Domain&&t){if("object"!=typeof t)throw new cu({domain:t});s(o.EIP712Domain,t)}if("EIP712Domain"!==r){if(!o[r])throw new uu({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 pu({data:e,primaryType:"EIP712Domain",types:t})}({domain:t,types:o})),"EIP712Domain"!==r&&s.push(pu({data:n,primaryType:r,types:o})),Bn(Gn(s))}function pu({data:e,primaryType:t,types:n}){return Bn(mu({data:e,primaryType:t,types:n}))}function mu({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],o=[gu({primaryType:t,types:n})];for(const s of n[t]){const[t,a]=yu({types:n,name:s.name,type:s.type,value:e[s.name]});r.push(t),o.push(a)}return Jn(r,o)}function gu({primaryType:e,types:t}){const n=Lt(function({primaryType:e,types:t}){let n="";const r=bu({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 Bn(n)}function bu({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])bu({primaryType:e.type,types:t},n);return n}function yu({types:e,name:t,type:n,value:r}){if(void 0!==e[n])return[{type:"bytes32"},Bn(mu({data:r,primaryType:n,types:e}))];if("bytes"===n){return[{type:"bytes32"},Bn(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},Bn(Lt(r))];if(n.lastIndexOf("]")===n.length-1){const o=n.slice(0,n.lastIndexOf("[")),s=r.map(n=>yu({name:t,type:o,types:e,value:n}));return[{type:"bytes32"},Bn(Jn(s.map(([e])=>e),s.map(([,e])=>e)))]}return[{type:n},r]}class wu 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 vu={checksum:new wu(8192)}.checksum;function xu(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Tn(Ha(e));return"Bytes"===n?r:li(r)}const Eu=/^0x[a-fA-F0-9]{40}$/;function Pu(e,t={}){const{strict:n=!0}=t;if(!Eu.test(e))throw new Iu({address:e,cause:new Su});if(n){if(e.toLowerCase()===e)return;if(ku(e)!==e)throw new Iu({address:e,cause:new Nu})}}function ku(e){if(vu.has(e))return vu.get(e);Pu(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=xu(Ka(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 vu.set(e,o),o}function Au(e,t={}){const{strict:n=!0}=t??{};try{return Pu(e,{strict:n}),!0}catch{return!1}}class Iu extends Ca{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 Su extends Ca{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 Nu extends Ca{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const Tu=/^(.*)\[([0-9]*)\]$/,Bu=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Cu=/^(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)?$/,$u=2n**256n-1n;function Ou(e,t,n){const{checksumAddress:r,staticPosition:o}=n,s=Lu(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+ei(e.readBytes(Ru)),o=n+_u;e.setPosition(n);const a=ei(e.readBytes(_u)),i=Fu(t);let c=0;const u=[];for(let n=0;n<a;++n){e.setPosition(o+(i?32*n:c));const[s,a]=Ou(e,t,{checksumAddress:r,staticPosition:o});c+=a,u.push(s)}return e.setPosition(s+32),[u,32]}if(Fu(t)){const n=s+ei(e.readBytes(Ru)),a=[];for(let s=0;s<o;++s){e.setPosition(n+32*s);const[o]=Ou(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]=Ou(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(Fu(t)){const n=o+ei(e.readBytes(Ru));for(let o=0;o<t.components.length;++o){const c=t.components[o];e.setPosition(n+i);const[u,l]=Ou(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]=Ou(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?ku(e):e;return[o(li(Ja(r,-20))),32]}(e,{checksum:r});if("bool"===t.type)return function(e){return[Xa(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=ei(e.readBytes(32));e.setPosition(n+t);const r=ei(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[li(o),32]}const s=li(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?Qa(o,{signed:n}):ei(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=ei(e.readBytes(32)),r=t+n;e.setPosition(r);const o=ei(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const s=e.readBytes(o,32),a=ti(ni(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:o});throw new el(t.type)}const _u=32,Ru=32;function zu({checksumAddress:e=!1,parameter:t,value:n}){const r=t,o=Lu(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 Xu(e);if(!s&&e.length!==r)throw new Zu({expectedLength:r,givenLength:e.length,type:`${o.type}[${r}]`});let a=!1;const i=[];for(let t=0;t<e.length;t++){const r=zu({checksumAddress:n,parameter:o,value:e[t]});r.dynamic&&(a=!0),i.push(r)}if(s||a){const e=Mu(i);if(s){const t=di(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?ci(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:ci(...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=zu({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});s.push(i),i.dynamic&&(o=!0)}return{dynamic:o,encoded:o?Mu(s):ci(...s.map(({encoded:e})=>e))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return Pu(e,{strict:n}),{dynamic:!1,encoded:hi(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new Ca(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:hi(ui(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Cu.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 vi({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:di(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=gi(e);if(!n){let t=e;return r%32!=0&&(t=pi(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:ci(hi(di(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new Ju({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:pi(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=fi(e),n=Math.ceil(gi(t)/32),r=[];for(let e=0;e<n;e++)r.push(pi(mi(t,32*e,32*(e+1))));return{dynamic:!0,encoded:ci(pi(di(gi(t),{size:32})),...r)}}(n);throw new el(r.type)}function Mu(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:gi(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(di(t+o,{size:32})),r.push(i),o+=gi(i)):n.push(i)}return ci(...n,...r)}function Lu(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Fu(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(Fu);const n=Lu(e.type);return!(!n||!Fu({...e,type:n[1]}))}const Uu={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 Gu({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Du({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new ju({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 ju({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 ju extends Ca{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class Du extends Ca{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 Gu extends Ca{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 Wu(e,t,n={}){const{as:r="Array",checksumAddress:o=!1}=n,s="string"==typeof t?Ya(t):t,a=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(Uu);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===Za(s)&&e.length>0)throw new Ku;if(Za(s)&&Za(s)<32)throw new Yu({data:"string"==typeof t?t:li(t),parameters:e,size:Za(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]=Ou(a,n,{checksumAddress:o,staticPosition:0});i+=u,"Array"===r?c.push(s):c[n.name??t]=s}return c}function qu(e,t,n){const{checksumAddress:r=!1}={};if(e.length!==t.length)throw new Qu({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(zu({checksumAddress:e,parameter:t[o],value:n[o]}));return r}({checksumAddress:r,parameters:e,values:t}),s=Mu(o);return 0===s.length?"0x":s}function Vu(e,t){if(e.length!==t.length)throw new Qu({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(Vu.encode(o,s))}return ci(...n)}function Hu(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?De(e):e}!function(e){e.encode=function e(t,n,r=!1){if("address"===t){const e=n;return Pu(e),hi(e.toLowerCase(),r?32:0)}if("string"===t)return fi(n);if("bytes"===t)return n;if("bool"===t)return hi(ui(n),r?32:1);const o=t.match(Cu);if(o){const[e,t,s="256"]=o,a=Number.parseInt(s,10)/8;return di(n,{size:r?32:a,signed:"int"===t})}const s=t.match(Bu);if(s){const[e,t]=s;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new Ju({expectedSize:Number.parseInt(t,10),value:n});return pi(n,r?32:0)}const a=t.match(Tu);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":ci(...o)}throw new el(t)}}(Vu||(Vu={}));class Yu extends Ca{constructor({data:e,parameters:t,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${ee(t)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Ku extends Ca{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Zu extends Ca{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 Ju extends Ca{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${gi(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Qu extends Ca{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 Xu extends Ca{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class el extends Ca{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 tl extends dn{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");en(e.outputLen),en(e.blockLen)}(e);const n=ln(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),on(o)}update(e){return nn(this),this.iHash.update(e),this}digestInto(e){nn(this),tn(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 nl=(e,t,n)=>new tl(e,t).update(n).digest();nl.create=(e,t)=>new tl(e,t);
5
5
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6
- const nl=BigInt(0),rl=BigInt(1),ol=BigInt(2),sl=BigInt(3),al=BigInt(4),il=BigInt(5),cl=BigInt(8);function ul(e,t){const n=e%t;return n>=nl?n:t+n}function ll(e,t,n){let r=e;for(;t-- >nl;)r*=r,r%=n;return r}function dl(e,t){if(e===nl)throw new Error("invert: expected non-zero number");if(t<=nl)throw new Error("invert: expected positive modulus, got "+t);let n=ul(e,t),r=t,o=nl,s=rl;for(;n!==nl;){const e=r%n,t=o-s*(r/n);r=n,n=e,o=s,s=t}if(r!==rl)throw new Error("invert: does not exist");return ul(o,t)}function fl(e,t){const n=(e.ORDER+rl)/al,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function hl(e,t){const n=(e.ORDER-il)/cl,r=e.mul(t,ol),o=e.pow(r,n),s=e.mul(t,o),a=e.mul(e.mul(s,ol),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 pl(e){return e%al===sl?fl:e%cl===il?hl:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-rl,n=0;for(;t%ol===nl;)t/=ol,n++;let r=ol;const o=wl(e);for(;1===bl(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return fl;let s=o.pow(r,t);const a=(t+rl)/ol;return function(e,r){if(e.is0(r))return r;if(1!==bl(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=rl<<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 ml=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gl(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 bl(e,t){const n=(e.ORDER-rl)/ol,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 yl(e,t){void 0!==t&&Xt(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function wl(e,t,n=!1,r={}){if(e<=nl)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:o,nByteLength:s}=yl(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:ka(o),ZERO:nl,ONE:rl,create:t=>ul(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return nl<=t&&t<e},is0:e=>e===nl,isOdd:e=>(e&rl)===rl,neg:t=>ul(-t,e),eql:(e,t)=>e===t,sqr:t=>ul(t*t,e),add:(t,n)=>ul(t+n,e),sub:(t,n)=>ul(t-n,e),mul:(t,n)=>ul(t*n,e),pow:(e,t)=>function(e,t,n){if(n<nl)throw new Error("invalid exponent, negatives unsupported");if(n===nl)return e.ONE;if(n===rl)return t;let r=e.ONE,o=t;for(;n>nl;)n&rl&&(r=e.mul(r,o)),o=e.sqr(o),n>>=rl;return r}(i,e,t),div:(t,n)=>ul(t*dl(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>dl(t,e),sqrt:r.sqrt||(t=>(a||(a=pl(e)),a(i,t))),toBytes:e=>n?ya(e,s):ba(e,s),fromBytes:e=>{if(e.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+e.length);return n?ga(e):ma(e)},invertBatch:e=>gl(i,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(i)}function vl(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 xl(e){const t=vl(e);return t+Math.ceil(t/2)}
6
+ const rl=BigInt(0),ol=BigInt(1),sl=BigInt(2),al=BigInt(3),il=BigInt(4),cl=BigInt(5),ul=BigInt(8);function ll(e,t){const n=e%t;return n>=rl?n:t+n}function dl(e,t,n){let r=e;for(;t-- >rl;)r*=r,r%=n;return r}function fl(e,t){if(e===rl)throw new Error("invert: expected non-zero number");if(t<=rl)throw new Error("invert: expected positive modulus, got "+t);let n=ll(e,t),r=t,o=rl,s=ol;for(;n!==rl;){const e=r%n,t=o-s*(r/n);r=n,n=e,o=s,s=t}if(r!==ol)throw new Error("invert: does not exist");return ll(o,t)}function hl(e,t){const n=(e.ORDER+ol)/il,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function pl(e,t){const n=(e.ORDER-cl)/ul,r=e.mul(t,sl),o=e.pow(r,n),s=e.mul(t,o),a=e.mul(e.mul(s,sl),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 ml(e){return e%il===al?hl:e%ul===cl?pl:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-ol,n=0;for(;t%sl===rl;)t/=sl,n++;let r=sl;const o=vl(e);for(;1===yl(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return hl;let s=o.pow(r,t);const a=(t+ol)/sl;return function(e,r){if(e.is0(r))return r;if(1!==yl(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=ol<<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 gl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bl(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 yl(e,t){const n=(e.ORDER-ol)/sl,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 wl(e,t){void 0!==t&&en(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function vl(e,t,n=!1,r={}){if(e<=rl)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:o,nByteLength:s}=wl(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:Aa(o),ZERO:rl,ONE:ol,create:t=>ll(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return rl<=t&&t<e},is0:e=>e===rl,isOdd:e=>(e&ol)===ol,neg:t=>ll(-t,e),eql:(e,t)=>e===t,sqr:t=>ll(t*t,e),add:(t,n)=>ll(t+n,e),sub:(t,n)=>ll(t-n,e),mul:(t,n)=>ll(t*n,e),pow:(e,t)=>function(e,t,n){if(n<rl)throw new Error("invalid exponent, negatives unsupported");if(n===rl)return e.ONE;if(n===ol)return t;let r=e.ONE,o=t;for(;n>rl;)n&ol&&(r=e.mul(r,o)),o=e.sqr(o),n>>=ol;return r}(i,e,t),div:(t,n)=>ll(t*fl(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>fl(t,e),sqrt:r.sqrt||(t=>(a||(a=ml(e)),a(i,t))),toBytes:e=>n?wa(e,s):ya(e,s),fromBytes:e=>{if(e.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+e.length);return n?ba(e):ga(e)},invertBatch:e=>bl(i,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(i)}function xl(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 El(e){const t=xl(e);return t+Math.ceil(t/2)}
7
7
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
8
- const El=BigInt(0),Pl=BigInt(1);function kl(e,t){const n=t.negate();return e?n:t}function Al(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Il(e,t){Al(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:ka(e),maxNumber:n,shiftBy:BigInt(e)}}function Sl(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+=Pl);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 Nl=new WeakMap,Tl=new WeakMap;function Bl(e){return Tl.get(e)||1}function Cl(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>Js;e>>=Qs,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=ka(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 $l(e){return Na(e.Fp,ml.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Na(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...yl(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
9
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ol(e){void 0!==e.lowS&&ta("lowS",e.lowS),void 0!==e.prehash&&ta("prehash",e.prehash)}class _l extends Error{constructor(e=""){super(e)}}const Rl={Err:_l,_tlv:{encode:(e,t)=>{const{Err:n}=Rl;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=na(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?na(o.length/2|128):"";return na(e)+s+o+t},decode(e,t){const{Err:n}=Rl;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}=Rl;if(e<Ml)throw new t("integer: negative integers are not allowed");let n=na(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}=Rl;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 ma(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Rl,o=wa("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}=Rl,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};function zl(e,t){return aa(ba(e,t))}const Ml=BigInt(0),Ll=BigInt(1);BigInt(2);const Fl=BigInt(3),Ul=BigInt(4);function jl(e){const t=function(e){const t=$l(e);Na(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=wl(t.n,t.nBitLength),o=t.toBytes||((e,t,r)=>{const o=t.toAffine();return va(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,Fl),Ul),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(Xs(e)&&(e=aa(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:ma(wa("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return o&&(a=ul(a,s)),Pa("private key",a,Ll,s),a}function d(e){if(!(e instanceof p))throw new Error("ProjectivePoint expected")}const f=Ta((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=Ta(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=gl(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(wa("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return p.BASE.multiply(l(e))}static msm(e,t){return Cl(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,Fl),{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,Fl);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;Pa("scalar",e,Ml,o);const s=p.ZERO;if(e===Ml)return s;if(this.is0()||e===Ll)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>Ml||u>Ml;)i&Ll&&(l=l.add(f)),u&Ll&&(d=d.add(f)),f=f.double(),i>>=Ll,u>>=Ll;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(Pa("scalar",e,Ll,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!==Ml&&t!==Ll&&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===Ll)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===Ll?this:n?n(p,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return ta("isCompressed",e),this.assertValidity(),o(p,this,e)}toHex(e=!0){return ta("isCompressed",e),aa(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:kl,hasPrecomputes:e=>1!==Bl(e),unsafeLadder(e,t,n=y.ZERO){let r=e;for(;t>El;)t&Pl&&(n=n.add(r)),r=r.double(),t>>=Pl;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=Il(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=Il(e,w);for(let e=0;e<s.windows;e++){const{nextN:a,offset:i,isZero:c,isNeg:u,isNegF:l,offsetF:d}=Sl(n,e,s);n=a,c?o=o.add(kl(l,t[d])):r=r.add(kl(u,t[i]))}return{p:r,f:o}},wNAFUnsafe(e,t,n,r=y.ZERO){const o=Il(e,w);for(let e=0;e<o.windows&&n!==El;e++){const{nextN:s,offset:a,isZero:i,isNeg:c}=Sl(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=Nl.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&Nl.set(t,n(r))),r},wNAFCached(e,t,n){const r=Bl(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const o=Bl(e);return 1===o?this.unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)},setWindowSize(e,t){Al(t,w),Tl.set(e,t),Nl.delete(e)}});var y,w;return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:l,weierstrassEquation:a,isWithinCurveOrder:function(e){return Ea(e,Ll,t.n)}}}function Dl(e){const t=function(e){const t=$l(e);return Na(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 ul(e,r)}function u(e){return dl(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:h}=jl({...t,toBytes(e,t,r){const o=t.toAffine(),s=n.toBytes(o.x),a=va;return ta("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=ma(o);if(!Ea(e,Ll,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&Ll)===Ll)&&(s=n.neg(s)),{x:e,y:s}}}});function p(e){return e>r>>Ll}const m=(e,t,n)=>ma(e.slice(t,n));class g{constructor(e,t,n){Pa("r",e,Ll,r),Pa("s",t,Ll,r),this.r=e,this.s=t,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(e){const t=o;return e=wa("compactSignature",e,2*t),new g(m(e,0,t),m(e,t,2*t))}static fromDER(e){const{r:t,s:n}=Rl.toSig(wa("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(wa("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+zl(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 pa(this.toDERHex())}toDERHex(){return Rl.hexFromSig(this)}toCompactRawBytes(){return pa(this.toCompactHex())}toCompactHex(){const e=o;return zl(this.r,e)+zl(this.s,e)}}const b={isValidPrivateKey(e){try{return d(e),!0}catch(e){return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const e=xl(t.n);return function(e,t,n=!1){const r=e.length,o=vl(t),s=xl(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const a=ul(n?ga(e):ma(e),t-rl)+rl;return n?ya(a,o):ba(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=wa("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=ma(e),n=8*e.length-s;return n>0?t>>BigInt(n):t},v=t.bits2int_modN||function(e){return c(w(e))},x=ka(s);function E(e){return Pa("num < 2^"+s,e,Ml,x),ba(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=wa("msgHash",e),Ol(o),f&&(e=wa("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(wa("extraEntropy",e))}const P=va(...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===Ml)return;const s=c(n*c(A+o*y));if(s===Ml)return;let a=(r.x===o?0:2)|Number(r.y&Ll),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=Aa(e),o=Aa(e),s=0;const a=()=>{r.fill(1),o.fill(0),s=0},i=(...e)=>n(o,r,...e),c=(e=Aa(0))=>{o=i(Ia([0]),e),r=i(),0!==e.length&&(o=i(Ia([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 va(...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=wa("msgHash",n),r=wa("publicKey",r);const{lowS:a,prehash:i,format:d}=o;if(Ol(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||Xs(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 Rl.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 Gl(e){return{hash:e,hmac:(t,...n)=>tl(e,t,function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];en(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:fn}}
8
+ const Pl=BigInt(0),kl=BigInt(1);function Al(e,t){const n=t.negate();return e?n:t}function Il(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Sl(e,t){Il(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Aa(e),maxNumber:n,shiftBy:BigInt(e)}}function Nl(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+=kl);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 Tl=new WeakMap,Bl=new WeakMap;function Cl(e){return Bl.get(e)||1}function $l(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>Qs;e>>=Xs,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=Aa(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 Ol(e){return Ta(e.Fp,gl.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Ta(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...wl(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&&na("lowS",e.lowS),void 0!==e.prehash&&na("prehash",e.prehash)}class Rl extends Error{constructor(e=""){super(e)}}const zl={Err:Rl,_tlv:{encode:(e,t)=>{const{Err:n}=zl;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=ra(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?ra(o.length/2|128):"";return ra(e)+s+o+t},decode(e,t){const{Err:n}=zl;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}=zl;if(e<Ll)throw new t("integer: negative integers are not allowed");let n=ra(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}=zl;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 ga(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=zl,o=va("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}=zl,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};function Ml(e,t){return ia(ya(e,t))}const Ll=BigInt(0),Fl=BigInt(1);BigInt(2);const Ul=BigInt(3),jl=BigInt(4);function Dl(e){const t=function(e){const t=Ol(e);Ta(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=vl(t.n,t.nBitLength),o=t.toBytes||((e,t,r)=>{const o=t.toAffine();return xa(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,Ul),jl),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(ea(e)&&(e=ia(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:ga(va("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return o&&(a=ll(a,s)),ka("private key",a,Fl,s),a}function d(e){if(!(e instanceof p))throw new Error("ProjectivePoint expected")}const f=Ba((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=Ba(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=bl(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(va("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return p.BASE.multiply(l(e))}static msm(e,t){return $l(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,Ul),{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,Ul);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;ka("scalar",e,Ll,o);const s=p.ZERO;if(e===Ll)return s;if(this.is0()||e===Fl)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>Ll||u>Ll;)i&Fl&&(l=l.add(f)),u&Fl&&(d=d.add(f)),f=f.double(),i>>=Fl,u>>=Fl;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(ka("scalar",e,Fl,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!==Ll&&t!==Fl&&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===Fl)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===Fl?this:n?n(p,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return na("isCompressed",e),this.assertValidity(),o(p,this,e)}toHex(e=!0){return na("isCompressed",e),ia(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:Al,hasPrecomputes:e=>1!==Cl(e),unsafeLadder(e,t,n=y.ZERO){let r=e;for(;t>Pl;)t&kl&&(n=n.add(r)),r=r.double(),t>>=kl;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=Sl(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=Sl(e,w);for(let e=0;e<s.windows;e++){const{nextN:a,offset:i,isZero:c,isNeg:u,isNegF:l,offsetF:d}=Nl(n,e,s);n=a,c?o=o.add(Al(l,t[d])):r=r.add(Al(u,t[i]))}return{p:r,f:o}},wNAFUnsafe(e,t,n,r=y.ZERO){const o=Sl(e,w);for(let e=0;e<o.windows&&n!==Pl;e++){const{nextN:s,offset:a,isZero:i,isNeg:c}=Nl(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=Tl.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&Tl.set(t,n(r))),r},wNAFCached(e,t,n){const r=Cl(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const o=Cl(e);return 1===o?this.unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)},setWindowSize(e,t){Il(t,w),Bl.set(e,t),Tl.delete(e)}});var y,w;return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:l,weierstrassEquation:a,isWithinCurveOrder:function(e){return Pa(e,Fl,t.n)}}}function Gl(e){const t=function(e){const t=Ol(e);return Ta(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 ll(e,r)}function u(e){return fl(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:h}=Dl({...t,toBytes(e,t,r){const o=t.toAffine(),s=n.toBytes(o.x),a=xa;return na("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=ga(o);if(!Pa(e,Fl,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&Fl)===Fl)&&(s=n.neg(s)),{x:e,y:s}}}});function p(e){return e>r>>Fl}const m=(e,t,n)=>ga(e.slice(t,n));class g{constructor(e,t,n){ka("r",e,Fl,r),ka("s",t,Fl,r),this.r=e,this.s=t,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(e){const t=o;return e=va("compactSignature",e,2*t),new g(m(e,0,t),m(e,t,2*t))}static fromDER(e){const{r:t,s:n}=zl.toSig(va("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(va("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+Ml(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 ma(this.toDERHex())}toDERHex(){return zl.hexFromSig(this)}toCompactRawBytes(){return ma(this.toCompactHex())}toCompactHex(){const e=o;return Ml(this.r,e)+Ml(this.s,e)}}const b={isValidPrivateKey(e){try{return d(e),!0}catch(e){return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const e=El(t.n);return function(e,t,n=!1){const r=e.length,o=xl(t),s=El(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const a=ll(n?ba(e):ga(e),t-ol)+ol;return n?wa(a,o):ya(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=va("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=ga(e),n=8*e.length-s;return n>0?t>>BigInt(n):t},v=t.bits2int_modN||function(e){return c(w(e))},x=Aa(s);function E(e){return ka("num < 2^"+s,e,Ll,x),ya(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=va("msgHash",e),_l(o),f&&(e=va("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(va("extraEntropy",e))}const P=xa(...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===Ll)return;const s=c(n*c(A+o*y));if(s===Ll)return;let a=(r.x===o?0:2)|Number(r.y&Fl),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=Ia(e),o=Ia(e),s=0;const a=()=>{r.fill(1),o.fill(0),s=0},i=(...e)=>n(o,r,...e),c=(e=Ia(0))=>{o=i(Sa([0]),e),r=i(),0!==e.length&&(o=i(Sa([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 xa(...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=va("msgHash",n),r=va("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||ea(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 zl.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 Wl(e){return{hash:e,hmac:(t,...n)=>nl(e,t,function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];tn(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:hn}}
11
11
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
12
- const ql=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Wl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Vl=BigInt(0),Hl=BigInt(1),Yl=BigInt(2),Kl=(e,t)=>(e+t/Yl)/t;const Zl=wl(ql,void 0,void 0,{sqrt:function(e){const t=ql,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=ll(l,n,t)*l%t,f=ll(d,n,t)*l%t,h=ll(f,Yl,t)*u%t,p=ll(h,o,t)*h%t,m=ll(p,s,t)*p%t,g=ll(m,i,t)*m%t,b=ll(g,c,t)*g%t,y=ll(b,i,t)*m%t,w=ll(y,n,t)*l%t,v=ll(w,a,t)*p%t,x=ll(v,r,t)*u%t,E=ll(x,Yl,t);if(!Zl.eql(Zl.sqr(E),e))throw new Error("Cannot find square root");return E}}),Jl=function(e,t){const n=t=>Dl({...e,...Gl(t)});return{...n(t),create:n}}({a:Vl,b:BigInt(7),Fp:Zl,n:Wl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Wl,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Hl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),i=Kl(s*e,t),c=Kl(-r*e,t);let u=ul(e-i*n-c*o,t),l=ul(-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}}}},Ss);var Ql=Object.freeze({__proto__:null,secp256k1:Jl});function Xl(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new od({signature:e});if(void 0===e.s)throw new od({signature:e});if(n&&void 0===e.yParity)throw new od({signature:e});if(e.r<0n||e.r>Cu)throw new sd({value:e.r});if(e.s<0n||e.s>Cu)throw new ad({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new id({value:e.yParity})}function ed(e){if(130!==e.length&&132!==e.length)throw new rd({signature:e});const t=BigInt(pi(e,0,32)),n=BigInt(pi(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return nd(t)}catch{throw new id({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function td(e){if(void 0!==e.r&&void 0!==e.s)return function(e){const t="string"==typeof e?ed(e):e instanceof Uint8Array?function(e){return ed(ui(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=nd(t)),"number"!=typeof n)throw new id({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:nd(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return Xl(t),t}(e)}function nd(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 cd({value:e})}class rd extends Ba{constructor({signature:e}){var t;super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${mi((t=e,t instanceof Uint8Array?ui(t):Array.isArray(t)?ui(new Uint8Array(t)):t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class od extends Ba{constructor({signature:e}){super(`Signature \`${Ga(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class sd extends Ba{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 ad extends Ba{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 id extends Ba{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 cd extends Ba{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 ud(e,t={}){return"string"==typeof e.chainId?function(e){const{address:t,chainId:n,nonce:r}=e,o=td(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...o}}(e):{...e,...t.signature}}const ld=Vu("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function dd(e){if("string"==typeof e){if("0x8010801080108010801080108010801080108010801080108010801080108010"!==pi(e,-32))throw new fd(e)}else Xl(e.authorization)}let fd=class extends Ba{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 hd(e,{address:t,blockNumber:n,blockTag:r,storageKeys:o}){const s=r??"latest",a=void 0!==n?Ut(n):void 0;return function(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?Rt(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 pd(e,{blockHash:t,blockNumber:n,blockTag:r,hash:o,index:s}){const a=r||"latest",i=void 0!==n?Ut(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,Ut(s)]},{dedupe:!0}):await e.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[i||a,Ut(s)]},{dedupe:Boolean(i)}),!c)throw new Dr({blockHash:t,blockNumber:n,blockTag:a,hash:o,index:s});return(e.chain?.formatters?.transaction?.format||ds)(c)}async function md(e,{hash:t}){const n=await e.request({method:"eth_getTransactionReceipt",params:[t]},{dedupe:!0});if(!n)throw new Gr({hash:t});return(e.chain?.formatters?.transactionReceipt?.format||hc)(n)}async function gd(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?Ii(e.blockOverrides):void 0,r=e.calls.map(e=>{const t=e,n=t.account?ur(t.account):void 0,r=t.abi?dr(t):t.data,o={...t,data:t.dataSuffix?Dn([r||"0x",t.dataSuffix]):r,from:t.from??n?.address};return ss(o),es(o)}),o=e.stateOverrides?rs(e.stateOverrides):void 0;t.push({blockOverrides:n,calls:r,stateOverrides:o})}const c=("bigint"==typeof n?Ut(n):void 0)||r;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:t,returnFullTransactions:s,traceTransfers:a,validation:i},c]})).map((e,t)=>({...fs(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=>Vs(e)),d="0x1"===e.status?"success":"failure",f=r&&"success"===d&&"0x"!==c?Zs({abi:r,data:c,functionName:a}):null,h=(()=>{if("success"===d)return;let t;return"0x"===e.error?.data?t=new tt:e.error&&(t=new Zr(e.error)),t?Bo(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=Jo(t,{});if(n instanceof Zo)throw t;throw n}}function bd(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 Ba("Unable to normalize signature.");return o}function yd(e,t){const n=typeof e,r=t.type;switch(r){case"address":return ku(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)=>yd(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=>yd(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function wd(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 wd(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")))&&ku(n[r],{strict:!1}))())return a}}function vd(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?Ue(e):e;return{...r,...n?{hash:Pd(r)}:{}}}function xd(e,t,n){const{args:r=[],prepare:o=!0}=n??{},s=yi(t,{strict:!1}),a=e.filter(e=>s?"function"===e.type||"error"===e.type?Ed(e)===pi(t,0,4):"event"===e.type&&Pd(e)===t:"name"in e&&e.name===t);if(0===a.length)throw new Ad({name:t});if(1===a.length)return{...a[0],...o?{hash:Pd(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:Pd(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&&yd(t,r)});if(t){if(i&&"inputs"in i&&i.inputs){const t=wd(e.inputs,i.inputs,r);if(t)throw new kd({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 Ad({name:t});return{...c,...o?{hash:Pd(c)}:{}}}function Ed(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return xd(t,n)}return e[0]})();return pi(Pd(t),0,4)}function Pd(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return xd(t,n)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:vu(di(function(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return xd(t,n)}return e[0]})();return bd("string"==typeof t?t:ee(t))}(t)))}class kd extends Ba{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${bd(ee(e.abiItem))}\`, and`,`\`${t.type}\` in \`${bd(ee(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 Ad extends Ba{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 Id(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new Ad({name:"constructor"});return t}function Sd(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[t,n,r]=e;return[Td(t,n,{args:r}),r]}const[t,n]=e;return[t,n]})(),{overloads:r}=t,o=r?Td([t,...r],t.name,{args:n}):t,s=Ed(o);const a=n.length>0?qu(o.inputs,n):void 0;return a?ii(s,a):s}function Nd(e,t={}){return vd(e,t)}function Td(e,t,n){const r=xd(e,t,n);if("function"!==r.type)throw new Ad({name:t,type:"function"});return r}const Bd="0x0000000000000000000000000000000000000000";async function Cd(e,t){const{blockNumber:n,blockTag:r,calls:o,stateOverrides:s,traceAssetChanges:a,traceTransfers:i,validation:c}=t,u=t.account?ur(t.account):void 0;if(a&&!u)throw new Ze("`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[Id(t),n]}return e})(),{bytecode:r,args:o}=n;return ii(r,t.inputs?.length&&o?.length?qu(t.inputs,o):"0x")}(vd("constructor(bytes, bytes)"),{bytecode:Mi,args:["0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033",Sd(Nd("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 Dc(e,{account:u.address,...t,data:t.abi?dr(t):t.data});return n.map(({address:e,storageKeys:t})=>t.length>0?e:null)})).then(e=>e.flat().filter(Boolean)):[],f=await gd(e,{blockNumber:n,blockTag:r,blocks:[...a?[{calls:[{data:l}],stateOverrides:s},{calls:d.map((e,t)=>({abi:[Nd("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Bd,nonce:t})),stateOverrides:[{address:Bd,nonce:0}]}]:[],{calls:[...o,{}].map(e=>({...e,from:u?.address})),stateOverrides:s},...a?[{calls:[{data:l}]},{calls:d.map((e,t)=>({abi:[Nd("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Bd,nonce:t})),stateOverrides:[{address:Bd,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Nd("function decimals() returns (uint256)")],functionName:"decimals",from:Bd,nonce:t})),stateOverrides:[{address:Bd,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Nd("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:Bd,nonce:t})),stateOverrides:[{address:Bd,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Nd("function symbol() returns (string)")],functionName:"symbol",from:Bd,nonce:t})),stateOverrides:[{address:Bd,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),S=(v?.calls??[]).map(e=>"success"===e.status?e.result:null),N=(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=S[e-1],s=N[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 $d="0x6492649264926492649264926492649264926492649264926492649264926492";function Od(e){try{return function(e){if(pi(e,-32)!==$d)throw new _d(e)}(e),!0}catch{return!1}}class _d extends Ba{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 Rd({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 Jl.Signature(_t(e),_t(t)).toCompactHex()}${0===s?"1b":"1c"}`;return"hex"===n?a:Ht(a)}async function zd(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 We(e)?e:"object"==typeof e&&"r"in e&&"s"in e?Rd(e):Ft(e)})();try{return function(e){try{return dd(e),!0}catch{return!1}}(a)?await async function(e,t){const{address:n,blockNumber:r,blockTag:o,hash:s,multicallAddress:a}=t,{authorization:i,data:c,signature:u,to:l}=function(e){dd(e);const t=bi(pi(e,-64,-32)),n=pi(e,-t-64,-64),r=pi(e,0,-t-64),[o,s,a]=Gu(ld,n);return{authorization:ud({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 Wc(e,{address:n,blockNumber:r,blockTag:o});if(d===Gn(["0xef0100",i.address]))return await async function(e,t){const{address:n,blockNumber:r,blockTag:o,hash:s,signature:a}=t,i=await De(e,Qi,"readContract")({address:n,abi:_i,args:[s,a],blockNumber:r,blockTag:o,functionName:"isValidSignature"}).catch(e=>{if(e instanceof Vr)throw new Md;throw e});if(i.startsWith("0x1626ba7e"))return!0;throw new Md}(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:Ut(i.r,{size:32}),s:Ut(i.s,{size:32}),yParity:i.yParity},h=await async function({address:e,authorization:t,signature:n}){return js(Ln(e),await Mo({authorization:t,signature:n}))}({address:n,authorization:f});if(!h)throw new Md;const p=await De(e,Qi,"readContract")({...a?{address:a}:{code:Ui},authorizationList:[f],abi:Si,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...c?[{allowFailure:!0,target:l??n,callData:c}]:[],{allowFailure:!0,target:n,callData:dr({abi:_i,functionName:"isValidSignature",args:[s,u]})}]]}),m=p[p.length-1]?.returnData;if(m?.startsWith("0x1626ba7e"))return!0;throw new Md}(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?Od(a)?a:function(e){const{data:t,signature:n,to:r}=e;return ii(qu(Vu("address, bytes, bytes"),[r,t,n]),$d)}({data:o,signature:a,to:r}):a)(),l=i?{to:i,data:dr({abi:Ri,functionName:"isValidSig",args:[n,s,u]}),...c}:{data:qi({abi:Ri,args:[n,s,u],bytecode:Fi}),...c},{data:d}=await De(e,Zi,"call")(l).catch(e=>{if(e instanceof Wr)throw new Md;throw e});if(function(e,t={}){let n=e;if(t.size&&(Ot(n,{size:t.size}),n=$t(n)),"0x00"===$t(n))return!1;if("0x01"===$t(n))return!0;throw new Bt(n)}(d??"0x0"))return!0;throw new Md}(e,{...t,verifierAddress:o,signature:a})}catch(e){try{if(js(Ln(n),await $o({hash:r,signature:a})))return!0}catch{}if(e instanceof Md)return!1;throw e}}class Md extends Error{}function Ld(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))?nc(Tr(["watchBlockNumber",e.uid,t,n,a]),{onBlockNumber:r,onError:o},r=>oc(async()=>{try{const t=await De(e,cc,"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})):nc(Tr(["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 Fd=/^(?:(?<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)?/,Ud=/(?: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 jd(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(Fd)?.groups??{},{chainId:o,expirationTime:s,issuedAt:a,notBefore:i,requestId:c,...u}=e.match(Ud)?.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(!jn(r.address,{strict:!1}))return!1;if(t&&!js(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=au(o);return zd(e,{address:l.address,hash:f,signature:i,...u})}function Dd(e){return{call:t=>Zi(e,t),createAccessList:t=>Dc(e,t),createBlockFilter:()=>async function(e){const t=ir(e,{method:"eth_newBlockFilter"}),n=await e.request({method:"eth_newBlockFilter"});return{id:n,request:t(n),type:"block"}}(e),createContractEventFilter:t=>cr(e,t),createEventFilter:t=>Gc(e,t),createPendingTransactionFilter:()=>qc(e),estimateContractGas:t=>async function(e,t){const{abi:n,address:r,args:o,functionName:s,dataSuffix:a,...i}=t,c=dr({abi:n,args:o,functionName:s});try{return await De(e,Us,"estimateGas")({data:`${c}${a?a.replace("0x",""):""}`,to:r,...i})}catch(e){const t=i.account?ur(i.account):void 0;throw Bo(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/estimateContractGas",functionName:s,sender:t?.address})}}(e,t),estimateGas:t=>Us(e,t),getBalance:t=>async function(e,{address:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest"}){const o="bigint"==typeof n?Ut(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=>hs(e,t),getBlockNumber:t=>cc(e,t),getBlockTransactionCount:t=>async function(e,{blockHash:t,blockNumber:n,blockTag:r="latest"}={}){const o=void 0!==n?Ut(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)}),Rt(s)}(e,t),getBytecode:t=>Wc(e,t),getChainId:()=>zs(e),getCode:t=>Wc(e,t),getContractEvents:t=>Ys(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 De(e,Qi,"readContract")({abi:Hc,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 Vc({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 Wi({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),l=c?.ensTlds;if(l&&!l.some(e=>s.endsWith(e)))return null;const d=null!=o?[kc(s),BigInt(o)]:[kc(s)];try{const t=dr({abi:Oi,functionName:"addr",args:d}),o={address:u,abi:Bi,functionName:"resolveWithGateways",args:[Mt(Sc(s)),t,a??[xc]],blockNumber:n,blockTag:r},i=De(e,Qi,"readContract"),c=await i(o);if("0x"===c[0])return null;const l=Zs({abi:Oi,args:d,functionName:"addr",data:c[0]});return"0x"===l||"0x00"===$t(l)?null:l}catch(e){if(i)throw e;if(bc(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 De(e,jc,"getEnsText")({blockNumber:t,blockTag:n,key:"avatar",name:o,universalResolverAddress:i,gatewayUrls:s,strict:a});if(!c)return null;try{return await Uc(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 Wi({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})();try{const t={address:u,abi:Ci,args:[n,s,a??[xc]],functionName:"reverseWithGateways",blockNumber:r,blockTag:o},i=De(e,Qi,"readContract"),[c]=await i(t);return c||null}catch(e){if(i)throw e;if(bc(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 Wi({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 De(e,Qi,"readContract")({address:a,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[Mt(Sc(o))],blockNumber:n,blockTag:r});return c}(e,t),getEnsText:t=>jc(e,t),getFeeHistory:t=>Yc(e,t),estimateFeesPerGas:t=>async function(e,t){return gs(e,t)}(e,t),getFilterChanges:e=>uc(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=>Vs(e));return t.abi?Ws({abi:t.abi,logs:r,strict:n}):r}(0,e),getGasPrice:()=>ps(e),getLogs:t=>Hs(e,t),getProof:t=>hd(e,t),estimateMaxPriorityFeePerGas:t=>async function(e,t){return ms(e,t)}(e,t),getStorageAt:t=>async function(e,{address:t,blockNumber:n,blockTag:r="latest",slot:o}){const s=void 0!==n?Ut(n):void 0;return await e.request({method:"eth_getStorageAt",params:[t,o,s||r]})}(e,t),getTransaction:t=>pd(e,t),getTransactionConfirmations:t=>async function(e,{hash:t,transactionReceipt:n}){const[r,o]=await Promise.all([De(e,cc,"getBlockNumber")({}),t?De(e,pd,"getTransaction")({hash:t}):void 0]),s=n?.blockNumber||o?.blockNumber;return s?r-s+1n:0n}(e,t),getTransactionCount:t=>bs(e,t),getTransactionReceipt:t=>md(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 Wi({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=dr({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=Bo(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=>De(e,Qi,"readContract")({...null===f?{code:Ui}:{address:f},abi:Si,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 tt;if(!s)throw new Zr({data:r});const e=Zs({abi:i,args:d,data:r,functionName:l});b.push(o?{result:e,status:"success"}:e)}catch(e){const t=Bo(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 Ze("multicall results mismatch");return b}(e,t),prepareTransactionRequest:t=>Fs(e,t),readContract:t=>Qi(e,t),sendRawTransaction:t=>async function(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}(e,t),simulate:t=>gd(e,t),simulateBlocks:t=>gd(e,t),simulateCalls:t=>Cd(e,t),simulateContract:t=>async function(e,t){const{abi:n,address:r,args:o,dataSuffix:s,functionName:a,...i}=t,c=i.account?ur(i.account):e.account,u=dr({abi:n,args:o,functionName:a});try{const{data:l}=await De(e,Zi,"call")({batch:!1,data:`${u}${s?s.replace("0x",""):""}`,to:r,...i,account:c});return{result:Zs({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 Bo(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/simulateContract",functionName:a,sender:c?.address})}}(e,t),verifyHash:t=>zd(e,t),verifyMessage:t=>async function(e,{address:t,message:n,factory:r,factoryData:o,signature:s,...a}){return zd(e,{address:t,factory:r,factoryData:o,hash:au(n),signature:s,...a})}(e,t),verifySiweMessage:t=>jd(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 zd(e,{address:n,factory:r,factoryData:o,hash:fu({message:a,primaryType:i,types:c,domain:u}),signature:s,...l})}(e,t),uninstallFilter:e=>lc(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=Tr(["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}=Hi(),v=c?setTimeout(()=>{m?.(),p?.(),w(new qr({hash:o}))},c):void 0;return p=nc(u,{onReplaced:s,resolve:y,reject:w},async t=>{if(h=await De(e,md,"getTransactionReceipt")({hash:o}).catch(()=>{}),h&&r<=1)return clearTimeout(v),t.resolve(h),void p?.();m=De(e,Ld,"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 dc(async()=>{d=await De(e,pd,"getTransaction")({hash:o}),d.blockNumber&&(u=d.blockNumber)},{delay:i,retryCount:a}),g=!1),h=await De(e,md,"getTransactionReceipt")({hash:o}),r>1&&(!h.blockNumber||u-h.blockNumber+1n<r))return;c(()=>t.resolve(h))}catch(n){if(n instanceof Dr||n instanceof Gr){if(!d)return void(g=!1);try{f=d,g=!0;const n=await dc(()=>De(e,hs,"getBlock")({blockNumber:u,includeTransactions:!0}),{delay:i,retryCount:a,shouldRetry:({error:e})=>e instanceof us});g=!1;const o=n.transactions.find(({from:e,nonce:t})=>e===f.from&&t===f.nonce);if(!o)return;if(h=await De(e,md,"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?nc(Tr(["watchBlocks",e.uid,t,n,r,l,c]),{onBlock:o,onError:s},o=>oc(async()=>{try{const r=await De(e,hs,"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 De(e,hs,"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&&De(e,hs,"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 De(e,hs,"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=>Ld(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 nc(Tr(["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=oc(async()=>{if(f)try{let i;if(l)i=await De(e,uc,"getFilterChanges")({filter:l});else{const s=await De(e,cc,"getBlockNumber")({});i=u&&u<s?await De(e,Ys,"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 io&&(f=!1),c.onError?.(e)}else{try{l=await De(e,cr,"createContractEventFilter")({abi:n,address:r,args:o,eventName:a,strict:t,fromBlock:i})}catch{}f=!0}},{emitOnBegin:!0,interval:d});return async()=>{l&&await De(e,lc,"uninstallFilter")({filter:l}),h()}})})():(()=>{const t=f??!1,i=Tr(["watchContractEvent",r,o,s,e.uid,a,d,t]);let l=!0,h=()=>l=!1;return nc(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?sr({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}=Gs({abi:n,data:r.data,topics:r.topics,strict:f}),s=Vs(r,{args:o,eventName:e});t.onLogs([s])}catch(e){let n,o;if(e instanceof gt||e instanceof bt){if(f)return;n=e.abiItem.name,o=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const s=Vs(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?nc(Tr(["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=oc(async()=>{if(d)try{let a;if(u)a=await De(e,uc,"getFilterChanges")({filter:u});else{const r=await De(e,cc,"getBlockNumber")({});a=c&&c!==r?await De(e,Hs,"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 io&&(d=!1),i.onError?.(e)}else{try{u=await De(e,Gc,"createEventFilter")({address:t,args:n,event:o,events:s,strict:h,fromBlock:a})}catch{}d=!0}},{emitOnBegin:!0,interval:l});return async()=>{u&&await De(e,lc,"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=>sr({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}=Gs({abi:l??[],data:t.data,topics:t.topics,strict:h}),r=Vs(t,{args:n,eventName:e});c([r])}catch(e){let n,r;if(e instanceof gt||e instanceof bt){if(d)return;n=e.abiItem.name,r=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const o=Vs(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)?nc(Tr(["watchPendingTransactions",e.uid,t,s]),{onTransactions:r,onError:n},n=>{let r;const o=oc(async()=>{try{if(!r)try{return void(r=await De(e,qc,"createPendingTransactionFilter")({}))}catch(e){throw o(),e}const s=await De(e,uc,"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 De(e,lc,"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 Gd(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?ur(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:gc(),...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(Dd)}class qd extends Ze{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 Wd(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 qd;const v=su(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:Zc(r,{methods:t,retryCount:o,retryDelay:s,uid:gc()}),value:c}}({key:s,methods:a,name:i,async request({method:e,params:t}){const r={method:e,params:t},{schedule:o}=Ki({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 Qr({body:r,error:s,url:w});return a},retryCount:b,retryDelay:l,timeout:y,type:"http"},{fetchOptions:o,url:w})}}function Vd(e,t,n){for(let n in t){let r=t[n];Object.defineProperty(e,n,{enumerable:!0,value:r,writable:!1})}}function Hd(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=>Hd(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 Hd(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=>`${Hd(n,t)}: ${Hd(e[n],t)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Yd(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: ${Hd(n)}`);for(const e in n){if("shortMessage"===e)continue;const t=n[e];r.push(e+"="+Hd(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 Vd(r,{code:t}),n&&Object.assign(r,n),null==r.shortMessage&&Vd(r,{shortMessage:o}),r}(t,n,r)}function Kd(e,t,n,r){Yd(e,t,"INVALID_ARGUMENT",{argument:n,value:r})}function Zd(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}Kd(!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 Jd=BigInt(0),Qd=BigInt(1),Xd=9007199254740991;function ef(e,t){const n=rf(e,"value"),r=BigInt(sf(t,"width"));if(Yd(n>>r===Jd,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),n>>r-Qd){return-((~n&(Qd<<r)-Qd)+Qd)}return n}function tf(e,t){const n=rf(e,"value"),r=BigInt(sf(t,"bits"));return n&(Qd<<r)-Qd}function nf(e,t){switch(typeof e){case"bigint":return e;case"number":return Kd(Number.isInteger(e),"underflow",t||"value",e),Kd(e>=-Xd&&e<=Xd,"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){Kd(!1,`invalid BigNumberish string: ${n.message}`,t||"value",e)}}Kd(!1,"invalid BigNumberish value",t||"value",e)}function rf(e,t){const n=nf(e,t);return Yd(n>=Jd,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),n}const of="0123456789abcdef";function sf(e,t){switch(typeof e){case"bigint":return Kd(e>=-Xd&&e<=Xd,"overflow",t||"value",e),Number(e);case"number":return Kd(Number.isInteger(e),"underflow",t||"value",e),Kd(e>=-Xd&&e<=Xd,"overflow",t||"value",e),e;case"string":try{if(""===e)throw new Error("empty string");return sf(BigInt(e),t)}catch(n){Kd(!1,`invalid numeric string: ${n.message}`,t||"value",e)}}Kd(!1,"invalid numeric value",t||"value",e)}const af=BigInt(-1),cf=BigInt(0),uf=BigInt(1),lf=BigInt(5),df={};let ff="0000";for(;ff.length<80;)ff+=ff;function hf(e){let t=ff;for(;t.length<e;)t+=t;return BigInt("1"+t.substring(0,e))}function pf(e,t,n){const r=BigInt(t.width);if(t.signed){const t=uf<<r-uf;Yd(null==n||e>=-t&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=e>cf?ef(tf(e,r),r):-ef(tf(-e,r),r)}else{const t=uf<<r;Yd(null==n||e>=0&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=(e%t+t)%t&t-uf}return e}function mf(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]+)$/);Kd(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:(Kd(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)}Kd(n%8==0,"invalid FixedNumber width (not byte aligned)","format.width",n),Kd(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 gf{format;#e;#t;#n;_value;constructor(e,t,n){!function(e,t,n){if(e!==t){let e=n,t="new";e+=".",t+=" "+n,Yd(!1,`private constructor; use ${e}from* methods`,"UNSUPPORTED_OPERATION",{operation:t})}}(e,df,"FixedNumber"),this.#t=t,this.#e=n;const r=function(e,t){let n="";e<cf&&(n="-",e*=af);let r=e.toString();if(0===t)return n+r;for(;r.length<=t;)r=ff+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);Vd(this,{format:n.name,_value:r}),this.#n=hf(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){Kd(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)}#o(e,t){return e=pf(e,this.#e,t),new gf(df,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 Yd(t%this.#n===cf,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),this.#o(t/this.#n,"mulSignal")}#c(e,t){return Yd(e.#t!==cf,"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){Yd(e.#t!==cf,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),this.#r(e);const t=this.#t*this.#n;return Yd(t%e.#t===cf,"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*=hf(r):r<0&&(t*=hf(-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<cf&&(e-=this.#n-uf),e=this.#t/this.#n*this.#n,this.#o(e,"floor")}ceiling(){let e=this.#t;return this.#t>cf&&(e+=this.#n-uf),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=lf*hf(t-1);let r=this.value+n;const o=hf(t);return r=r/o*o,pf(r,this.#e,"round"),new gf(df,r,this.#e)}isZero(){return this.#t===cf}isNegative(){return this.#t<cf}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return gf.fromString(this.toString(),e)}static fromValue(e,t,n){const r=null==t?0:sf(t),o=mf(n);let s=nf(e,"value");const a=r-o.decimals;if(a>0){const t=hf(a);Yd(s%t===cf,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),s/=t}else a<0&&(s*=hf(-a));return pf(s,o,"fromValue"),new gf(df,s,o)}static fromString(e,t){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Kd(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const r=mf(t);let o=n[2]||"0",s=n[3]||"";for(;s.length<r.decimals;)s+=ff;Yd(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 pf(a,r,"fromString"),new gf(df,a,r)}static fromBytes(e,t){let n=function(e){if(e instanceof Uint8Array){let t="0x0";for(const n of e)t+=of[n>>4],t+=of[15&n];return BigInt(t)}return nf(e)}(Zd(e,"value"));const r=mf(t);return r.signed&&(n=ef(n,r.width)),pf(n,r,"fromBytes"),new gf(df,n,r)}}function bf(e){return function(e,t){let n=18;return n=sf(t,"unit"),gf.fromValue(e,n,{decimals:n,width:512}).toString()}(e,18)}const yf="0.38.13";function wf({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@${yf}:${t}`):r.searchParams.append("sdkVersion",`onchainkit@${yf}`),r.searchParams.sort(),r.toString()}var vf=[],xf=[],Ef="undefined"!=typeof Uint8Array?Uint8Array:Array,Pf=!1;function kf(){Pf=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)vf[t]=e[t],xf[e.charCodeAt(t)]=t;xf["-".charCodeAt(0)]=62,xf["_".charCodeAt(0)]=63}function Af(e){return vf[e>>18&63]+vf[e>>12&63]+vf[e>>6&63]+vf[63&e]}function If(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(Af(r));return o.join("")}function Sf(e){var t;Pf||kf();for(var n=e.length,r=n%3,o="",s=[],a=16383,i=0,c=n-r;i<c;i+=a)s.push(If(e,i,i+a>c?c:i+a));return 1===r?(t=e[n-1],o+=vf[t>>2],o+=vf[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=vf[t>>10],o+=vf[t>>4&63],o+=vf[t<<2&63],o+="="),s.push(o),s.join("")}function Nf(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 Tf(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 Bf={}.toString,Cf=Array.isArray||function(e){return"[object Array]"==Bf.call(e)};function $f(){return _f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Of(e,t){if($f()<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 Mf(this,e)}return Rf(this,e,t,n)}function Rf(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=Lf(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|jf(t,n);e=Of(e,r);var o=e.write(t,n);o!==r&&(e=e.slice(0,o));return e}(e,t,n):function(e,t){if(Uf(t)){var n=0|Ff(t.length);return 0===(e=Of(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?Of(e,0):Lf(e,t);if("Buffer"===t.type&&Cf(t.data))return Lf(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function zf(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 Mf(e,t){if(zf(t),e=Of(e,t<0?0:0|Ff(t)),!_f.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Lf(e,t){var n=t.length<0?0:0|Ff(t.length);e=Of(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Ff(e){if(e>=$f())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+$f().toString(16)+" bytes");return 0|e}function Uf(e){return!(null==e||!e._isBuffer)}function jf(e,t){if(Uf(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 ph(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return mh(e).length;default:if(r)return ph(e).length;t=(""+t).toLowerCase(),r=!0}}function Df(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 rh(this,t,n);case"utf8":case"utf-8":return Xf(this,t,n);case"ascii":return th(this,t,n);case"latin1":case"binary":return nh(this,t,n);case"base64":return Qf(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return oh(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Gf(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function qf(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)),Uf(t))return 0===t.length?-1:Wf(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):Wf(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Wf(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 Vf(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 Hf(e,t,n,r){return gh(ph(t,e.length-n),e,n,r)}function Yf(e,t,n,r){return gh(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Kf(e,t,n,r){return Yf(e,t,n,r)}function Zf(e,t,n,r){return gh(mh(t),e,n,r)}function Jf(e,t,n,r){return gh(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 Qf(e,t,n){return 0===t&&n===e.length?Sf(e):Sf(e.slice(t,n))}function Xf(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<=eh)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=eh));return n}(r)}_f.TYPED_ARRAY_SUPPORT=void 0===globalThis.TYPED_ARRAY_SUPPORT||globalThis.TYPED_ARRAY_SUPPORT,$f(),_f.poolSize=8192,_f._augment=function(e){return e.__proto__=_f.prototype,e},_f.from=function(e,t,n){return Rf(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 zf(t),t<=0?Of(e,t):void 0!==n?"string"==typeof r?Of(e,t).fill(n,r):Of(e,t).fill(n):Of(e,t)}(null,e,t,n)},_f.allocUnsafe=function(e){return Mf(null,e)},_f.allocUnsafeSlow=function(e){return Mf(null,e)},_f.isBuffer=function(e){return null!=e&&(!!e._isBuffer||bh(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&bh(e.slice(0,0))}(e))},_f.compare=function(e,t){if(!Uf(e)||!Uf(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(!Cf(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(!Uf(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},_f.byteLength=jf,_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)Gf(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)Gf(this,t,t+3),Gf(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)Gf(this,t,t+7),Gf(this,t+1,t+6),Gf(this,t+2,t+5),Gf(this,t+3,t+4);return this},_f.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Xf(this,0,e):Df.apply(this,arguments)},_f.prototype.equals=function(e){if(!Uf(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(!Uf(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 qf(this,e,t,n,!0)},_f.prototype.lastIndexOf=function(e,t,n){return qf(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 Vf(this,e,t,n);case"utf8":case"utf-8":return Hf(this,e,t,n);case"ascii":return Yf(this,e,t,n);case"latin1":case"binary":return Kf(this,e,t,n);case"base64":return Zf(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Jf(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 eh=4096;function th(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 nh(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 rh(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+=hh(e[s]);return o}function oh(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 sh(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 ah(e,t,n,r,o,s){if(!Uf(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 ih(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 ch(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 uh(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 lh(e,t,n,r,o){return o||uh(e,0,n,4),Tf(e,t,n,r,23,4),n+4}function dh(e,t,n,r,o){return o||uh(e,0,n,8),Tf(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||sh(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||sh(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||sh(e,1,this.length),this[e]},_f.prototype.readUInt16LE=function(e,t){return t||sh(e,2,this.length),this[e]|this[e+1]<<8},_f.prototype.readUInt16BE=function(e,t){return t||sh(e,2,this.length),this[e]<<8|this[e+1]},_f.prototype.readUInt32LE=function(e,t){return t||sh(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||sh(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||sh(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||sh(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||sh(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},_f.prototype.readInt16LE=function(e,t){t||sh(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||sh(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||sh(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||sh(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||sh(e,4,this.length),Nf(this,e,!0,23,4)},_f.prototype.readFloatBE=function(e,t){return t||sh(e,4,this.length),Nf(this,e,!1,23,4)},_f.prototype.readDoubleLE=function(e,t){return t||sh(e,8,this.length),Nf(this,e,!0,52,8)},_f.prototype.readDoubleBE=function(e,t){return t||sh(e,8,this.length),Nf(this,e,!1,52,8)},_f.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||ah(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)||ah(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||ah(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||ah(this,e,t,2,65535,0),_f.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ih(this,e,t,!0),t+2},_f.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||ah(this,e,t,2,65535,0),_f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ih(this,e,t,!1),t+2},_f.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||ah(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):ch(this,e,t,!0),t+4},_f.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||ah(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):ch(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);ah(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);ah(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||ah(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||ah(this,e,t,2,32767,-32768),_f.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ih(this,e,t,!0),t+2},_f.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||ah(this,e,t,2,32767,-32768),_f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ih(this,e,t,!1),t+2},_f.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||ah(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):ch(this,e,t,!0),t+4},_f.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||ah(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):ch(this,e,t,!1),t+4},_f.prototype.writeFloatLE=function(e,t,n){return lh(this,e,t,!0,n)},_f.prototype.writeFloatBE=function(e,t,n){return lh(this,e,t,!1,n)},_f.prototype.writeDoubleLE=function(e,t,n){return dh(this,e,t,!0,n)},_f.prototype.writeDoubleBE=function(e,t,n){return dh(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=Uf(e)?e:ph(new _f(e,r).toString()),i=a.length;for(s=0;s<n-t;++s)this[s+t]=a[s%i]}return this};var fh=/[^+\/0-9A-Za-z-_]/g;function hh(e){return e<16?"0"+e.toString(16):e.toString(16)}function ph(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 mh(e){return function(e){var t,n,r,o,s,a;Pf||kf();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 Ef(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=xf[e.charCodeAt(t)]<<18|xf[e.charCodeAt(t+1)]<<12|xf[e.charCodeAt(t+2)]<<6|xf[e.charCodeAt(t+3)],a[c++]=o>>16&255,a[c++]=o>>8&255,a[c++]=255&o;return 2===s?(o=xf[e.charCodeAt(t)]<<2|xf[e.charCodeAt(t+1)]>>4,a[c++]=255&o):1===s&&(o=xf[e.charCodeAt(t)]<<10|xf[e.charCodeAt(t+1)]<<4|xf[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(fh,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function gh(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 bh(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}class yh{constructor(e){this.selectedWalletId=null,this.solanaConnection=null,this.ethereumProvider=null,this.walletInfo=null,this.phantomAdapter=null,this.walletType="embedded",this.backupWalletType="embedded_backup",this.ethereumNetwork=null,this.defaultNetwork=exports.Network.Solana,this.api=m.default.create({baseURL:e.baseURL,headers:{"Content-Type":"application/json"}}),this.middleAccountApi=m.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=Gd({transport:Wd(e.ethereumNetwork.rpcUrl)})),this.defaultNetwork=e.defaultNetwork||exports.Network.Solana}setWallet(e){this.walletInfo=e}setWalletType(e){this.walletType=e,A.saveWalletType(e)}setBackupWalletType(e){this.backupWalletType=e,A.saveBackupWalletType(e),console.log(33)}getWallet(){return this.walletInfo}getPhantomAdapter(){return this.phantomAdapter}getWalletType(){return this.walletType}getBackupWalletType(){return this.backupWalletType}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,t;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.address===A.getSwitchedAccountAddress()))||(null===(t=this.walletInfo)||void 0===t?void 0:t.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,t,n,r;const o=null===(t=null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.address===A.getSwitchedAccountAddress()))||void 0===t?void 0:t.wallet_set;return o?(null===(n=this.walletInfo)||void 0===n?void 0:n.wallets.find(e=>e.network===exports.Network.Solana&&e.wallet_set===o))||null:(null===(r=this.walletInfo)||void 0===r?void 0:r.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(e){try{if(A.getWalletType()==="phantom"+(e?"_backup":""))return await this.connectPhantom();if(!e){const e=await this.getSession();return this.setWallet(e),e}return null}catch(e){return null}}async connectPhantom(){try{if(this.phantomAdapter||(this.phantomAdapter=new W),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(w(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:g.default.encode(w(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(g.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),t.isBackup?this.setBackupWalletType("embedded_backup"):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),console.log(11),t.isBackup?(console.log(22),this.setBackupWalletType("embedded_backup")):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&&A.saveAccessToken(t),e}async logout(e){this.phantomAdapter?(this.phantomAdapter.disconnect(),this.phantomAdapter=null):await this.api.post("/logout",{},{withCredentials:!0}),this.setWallet(null),e?A.clearBackup():A.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 bf(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=g.default.decode(r),s=o[64];return Rd({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 wf(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")}}async getCrossMarginGeneralInfo(){return(await this.api.get("/crossmargin/general_info")).data}async getCrossMarginBorrowQuote(e){return(await this.api.post("/crossmargin/borrow/quote",e,{withCredentials:!0})).data}async borrowCrossMargin(e){return(await this.api.post("/crossmargin/borrow",e,{withCredentials:!0})).data}async getCrossMarginRepayQuote(e){return(await this.api.post("/crossmargin/repay/quote",e,{withCredentials:!0})).data}async repayCrossMargin(e){return(await this.api.post("/crossmargin/repay",e,{withCredentials:!0})).data}async adjustCrossMarginMargin(e){return(await this.api.post("/crossmargin/margin",e,{withCredentials:!0})).data}async getCrossMarginOpenPositions(){return(await this.api.get("/crossmargin/positions",{withCredentials:!0})).data}async getCrossMarginHistory(){return(await this.api.get("/crossmargin/history",{withCredentials:!0})).data}}var wh=function(){return wh=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},wh.apply(this,arguments)};function vh(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 xh(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 Eh=/^((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)-.*))$/,Ph=xh(function(e){return Eh.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}),kh="-ms-",Ah="-moz-",Ih="-webkit-",Sh="comm",Nh="rule",Th="decl",Bh="@keyframes",Ch=Math.abs,$h=String.fromCharCode,Oh=Object.assign;function _h(e){return e.trim()}function Rh(e,t){return(e=t.exec(e))?e[0]:e}function zh(e,t,n){return e.replace(t,n)}function Mh(e,t,n){return e.indexOf(t,n)}function Lh(e,t){return 0|e.charCodeAt(t)}function Fh(e,t,n){return e.slice(t,n)}function Uh(e){return e.length}function jh(e){return e.length}function Dh(e,t){return t.push(e),e}function Gh(e,t){return e.filter(function(e){return!Rh(e,t)})}var qh=1,Wh=1,Vh=0,Hh=0,Yh=0,Kh="";function Zh(e,t,n,r,o,s,a,i){return{value:e,root:t,parent:n,type:r,props:o,children:s,line:qh,column:Wh,length:a,return:"",siblings:i}}function Jh(e,t){return Oh(Zh("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function Qh(e){for(;e.root;)e=Jh(e.root,{children:[e]});Dh(e,e.siblings)}function Xh(){return Yh=Hh>0?Lh(Kh,--Hh):0,Wh--,10===Yh&&(Wh=1,qh--),Yh}function ep(){return Yh=Hh<Vh?Lh(Kh,Hh++):0,Wh++,10===Yh&&(Wh=1,qh++),Yh}function tp(){return Lh(Kh,Hh)}function np(){return Hh}function rp(e,t){return Fh(Kh,e,t)}function op(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 sp(e){return _h(rp(Hh-1,cp(91===e?e+2:40===e?e+1:e)))}function ap(e){for(;(Yh=tp())&&Yh<33;)ep();return op(e)>2||op(Yh)>3?"":" "}function ip(e,t){for(;--t&&ep()&&!(Yh<48||Yh>102||Yh>57&&Yh<65||Yh>70&&Yh<97););return rp(e,np()+(t<6&&32==tp()&&32==ep()))}function cp(e){for(;ep();)switch(Yh){case e:return Hh;case 34:case 39:34!==e&&39!==e&&cp(Yh);break;case 40:41===e&&cp(e);break;case 92:ep()}return Hh}function up(e,t){for(;ep()&&e+Yh!==57&&(e+Yh!==84||47!==tp()););return"/*"+rp(t,Hh-1)+"*"+$h(47===e?e:ep())}function lp(e){for(;!op(tp());)ep();return rp(e,Hh)}function dp(e){return function(e){return Kh="",e}(fp("",null,null,null,[""],e=function(e){return qh=Wh=1,Vh=Uh(Kh=e),Hh=0,[]}(e),0,[0],e))}function fp(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=ep()){case 40:if(108!=p&&58==Lh(P,d-1)){-1!=Mh(P+=zh(sp(y),"&","&\f"),"&\f",Ch(u?i[u-1]:0))&&(b=-1);break}case 34:case 39:case 91:P+=sp(y);break;case 9:case 10:case 13:case 32:P+=ap(p);break;case 92:P+=ip(np()-1,7);continue;case 47:switch(tp()){case 42:case 47:Dh(pp(up(ep(),np()),t,n,c),c);break;default:P+="/"}break;case 123*m:i[u++]=Uh(P)*b;case 125*m:case 59:case 0:switch(y){case 0:case 125:g=0;case 59+l:-1==b&&(P=zh(P,/\f/g,"")),h>0&&Uh(P)-d&&Dh(h>32?mp(P+";",r,n,d-1,c):mp(zh(P," ","")+";",r,n,d-2,c),c);break;case 59:P+=";";default:if(Dh(E=hp(P,t,n,u,l,o,i,w,v=[],x=[],d,s),s),123===y)if(0===l)fp(P,t,E,E,v,s,d,i,x);else switch(99===f&&110===Lh(P,3)?100:f){case 100:case 108:case 109:case 115:fp(e,E,E,r&&Dh(hp(e,E,E,0,0,o,i,w,o,v=[],d,x),x),o,x,d,i,r?v:x);break;default:fp(P,E,E,E,[""],x,0,i,x)}}u=l=h=0,m=b=1,w=P="",d=a;break;case 58:d=1+Uh(P),h=p;default:if(m<1)if(123==y)--m;else if(125==y&&0==m++&&125==Xh())continue;switch(P+=$h(y),y*m){case 38:b=l>0?1:(P+="\f",-1);break;case 44:i[u++]=(Uh(P)-1)*b,b=1;break;case 64:45===tp()&&(P+=sp(ep())),f=tp(),l=d=Uh(w=P+=lp(np())),y++;break;case 45:45===p&&2==Uh(P)&&(m=0)}}return s}function hp(e,t,n,r,o,s,a,i,c,u,l,d){for(var f=o-1,h=0===o?s:[""],p=jh(h),m=0,g=0,b=0;m<r;++m)for(var y=0,w=Fh(e,f+1,f=Ch(g=a[m])),v=e;y<p;++y)(v=_h(g>0?h[y]+" "+w:zh(w,/&\f/g,h[y])))&&(c[b++]=v);return Zh(e,t,n,0===o?Nh:i,c,u,l,d)}function pp(e,t,n,r){return Zh(e,t,n,Sh,$h(Yh),Fh(e,2,-2),0,r)}function mp(e,t,n,r,o){return Zh(e,t,n,Th,Fh(e,0,r),Fh(e,r+1,-1),r,o)}function gp(e,t,n){switch(function(e,t){return 45^Lh(e,0)?(((t<<2^Lh(e,0))<<2^Lh(e,1))<<2^Lh(e,2))<<2^Lh(e,3):0}(e,t)){case 5103:return Ih+"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 Ih+e+e;case 4789:return Ah+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ih+e+Ah+e+kh+e+e;case 5936:switch(Lh(e,t+11)){case 114:return Ih+e+kh+zh(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ih+e+kh+zh(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ih+e+kh+zh(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return Ih+e+kh+e+e;case 6165:return Ih+e+kh+"flex-"+e+e;case 5187:return Ih+e+zh(e,/(\w+).+(:[^]+)/,Ih+"box-$1$2"+kh+"flex-$1$2")+e;case 5443:return Ih+e+kh+"flex-item-"+zh(e,/flex-|-self/g,"")+(Rh(e,/flex-|baseline/)?"":kh+"grid-row-"+zh(e,/flex-|-self/g,""))+e;case 4675:return Ih+e+kh+"flex-line-pack"+zh(e,/align-content|flex-|-self/g,"")+e;case 5548:return Ih+e+kh+zh(e,"shrink","negative")+e;case 5292:return Ih+e+kh+zh(e,"basis","preferred-size")+e;case 6060:return Ih+"box-"+zh(e,"-grow","")+Ih+e+kh+zh(e,"grow","positive")+e;case 4554:return Ih+zh(e,/([^-])(transform)/g,"$1"+Ih+"$2")+e;case 6187:return zh(zh(zh(e,/(zoom-|grab)/,Ih+"$1"),/(image-set)/,Ih+"$1"),e,"")+e;case 5495:case 3959:return zh(e,/(image-set\([^]*)/,Ih+"$1$`$1");case 4968:return zh(zh(e,/(.+:)(flex-)?(.*)/,Ih+"box-pack:$3"+kh+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ih+e+e;case 4200:if(!Rh(e,/flex-|baseline/))return kh+"grid-column-align"+Fh(e,t)+e;break;case 2592:case 3360:return kh+zh(e,"template-","")+e;case 4384:case 3616:return n&&n.some(function(e,n){return t=n,Rh(e.props,/grid-\w+-end/)})?~Mh(e+(n=n[t].value),"span",0)?e:kh+zh(e,"-start","")+e+kh+"grid-row-span:"+(~Mh(n,"span",0)?Rh(n,/\d+/):+Rh(n,/\d+/)-+Rh(e,/\d+/))+";":kh+zh(e,"-start","")+e;case 4896:case 4128:return n&&n.some(function(e){return Rh(e.props,/grid-\w+-start/)})?e:kh+zh(zh(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return zh(e,/(.+)-inline(.+)/,Ih+"$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(Uh(e)-1-t>6)switch(Lh(e,t+1)){case 109:if(45!==Lh(e,t+4))break;case 102:return zh(e,/(.+:)(.+)-([^]+)/,"$1"+Ih+"$2-$3$1"+Ah+(108==Lh(e,t+3)?"$3":"$2-$3"))+e;case 115:return~Mh(e,"stretch",0)?gp(zh(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return zh(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(t,n,r,o,s,a,i){return kh+n+":"+r+i+(o?kh+n+"-span:"+(s?a:+a-+r)+i:"")+e});case 4949:if(121===Lh(e,t+6))return zh(e,":",":"+Ih)+e;break;case 6444:switch(Lh(e,45===Lh(e,14)?18:11)){case 120:return zh(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Ih+(45===Lh(e,14)?"inline-":"")+"box$3$1"+Ih+"$2$3$1"+kh+"$2box$3")+e;case 100:return zh(e,":",":"+kh)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return zh(e,"scroll-","scroll-snap-")+e}return e}function bp(e,t){for(var n="",r=0;r<e.length;r++)n+=t(e[r],r,e,t)||"";return n}function yp(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case Th:return e.return=e.return||e.value;case Sh:return"";case Bh:return e.return=e.value+"{"+bp(e.children,r)+"}";case Nh:if(!Uh(e.value=e.props.join(",")))return""}return Uh(n=bp(e.children,r))?e.return=e.value+"{"+n+"}":""}function wp(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case Th:return void(e.return=gp(e.value,e.length,n));case Bh:return bp([Jh(e,{value:zh(e.value,"@","@"+Ih)})],r);case Nh:if(e.length)return function(e,t){return e.map(t).join("")}(n=e.props,function(t){switch(Rh(t,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Qh(Jh(e,{props:[zh(t,/:(read-\w+)/,":-moz-$1")]})),Qh(Jh(e,{props:[t]})),Oh(e,{props:Gh(n,r)});break;case"::placeholder":Qh(Jh(e,{props:[zh(t,/:(plac\w+)/,":"+Ih+"input-$1")]})),Qh(Jh(e,{props:[zh(t,/:(plac\w+)/,":-moz-$1")]})),Qh(Jh(e,{props:[zh(t,/:(plac\w+)/,kh+"input-$1")]})),Qh(Jh(e,{props:[t]})),Oh(e,{props:Gh(n,r)})}return""})}}var vp={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},xp="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Ep="active",Pp="data-styled-version",kp="6.1.19",Ap="/*!sc*/\n",Ip="undefined"!=typeof window&&"undefined"!=typeof document,Sp=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),Np=/invalid hook call/i,Tp=new Set,Bp=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];Np.test(e)?(a=!1,Tp.delete(r)):s.apply(void 0,vh([e],t,!1))},o.useRef(),a&&!Tp.has(r)&&(console.warn(r),Tp.add(r))}catch(e){Np.test(e.message)&&Tp.delete(r)}finally{console.error=s}}},Cp=Object.freeze([]),$p=Object.freeze({});var Op=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,Rp=/(^-|-$)/g;function zp(e){return e.replace(_p,"-").replace(Rp,"")}var Mp=/(a)(d)/gi,Lp=function(e){return String.fromCharCode(e+(e>25?39:97))};function Fp(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=Lp(t%52)+n;return(Lp(t%52)+n).replace(Mp,"$1-$2")}var Up,jp=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},Dp=function(e){return jp(5381,e)};function Gp(e){return Fp(Dp(e)>>>0)}function qp(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function Wp(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var Vp="function"==typeof Symbol&&Symbol.for,Hp=Vp?Symbol.for("react.memo"):60115,Yp=Vp?Symbol.for("react.forward_ref"):60112,Kp={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Zp={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Jp={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Qp=((Up={})[Yp]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},Up[Hp]=Jp,Up);function Xp(e){return("type"in(t=e)&&t.type.$$typeof)===Hp?Jp:"$$typeof"in e?Qp[e.$$typeof]:Kp;var t}var em=Object.defineProperty,tm=Object.getOwnPropertyNames,nm=Object.getOwnPropertySymbols,rm=Object.getOwnPropertyDescriptor,om=Object.getPrototypeOf,sm=Object.prototype;function am(e,t,n){if("string"!=typeof t){if(sm){var r=om(t);r&&r!==sm&&am(e,r,n)}var o=tm(t);nm&&(o=o.concat(nm(t)));for(var s=Xp(e),a=Xp(t),i=0;i<o.length;++i){var c=o[i];if(!(c in Zp||n&&n[c]||a&&c in a||s&&c in s)){var u=rm(t,c);try{em(e,c,u)}catch(e){}}}}return e}function im(e){return"function"==typeof e}function cm(e){return"object"==typeof e&&"styledComponentId"in e}function um(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function lm(e,t){if(0===e.length)return"";for(var n=e[0],r=1;r<e.length;r++)n+=e[r];return n}function dm(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function fm(e,t,n){if(void 0===n&&(n=!1),!n&&!dm(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var r=0;r<t.length;r++)e[r]=fm(e[r],t[r]);else if(dm(t))for(var r in t)e[r]=fm(e[r],t[r]);return e}function hm(e,t){Object.defineProperty(e,"toString",{value:t})}var pm="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 mm(){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 gm(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(mm.apply(void 0,vh([pm[e]],t,!1)).trim())}var bm=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 gm(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(Ap);return t},e}(),ym=1<<30,wm=new Map,vm=new Map,xm=1,Em=function(e){if(wm.has(e))return wm.get(e);for(;vm.has(xm);)xm++;var t=xm++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>ym))throw gm(16,"".concat(t));return wm.set(e,t),vm.set(t,e),t},Pm=function(e,t){xm=t+1,wm.set(e,t),vm.set(t,e)},km="style[".concat(xp,"][").concat(Pp,'="').concat(kp,'"]'),Am=new RegExp("^".concat(xp,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Im=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)},Sm=function(e,t){for(var n,r=(null!==(n=t.textContent)&&void 0!==n?n:"").split(Ap),o=[],s=0,a=r.length;s<a;s++){var i=r[s].trim();if(i){var c=i.match(Am);if(c){var u=0|parseInt(c[1],10),l=c[2];0!==u&&(Pm(l,u),Im(e,l,c[3]),e.getTag().insertRules(u,o)),o.length=0}else o.push(i)}}},Nm=function(e){for(var t=document.querySelectorAll(km),n=0,r=t.length;n<r;n++){var o=t[n];o&&o.getAttribute(xp)!==Ep&&(Sm(e,o),o.parentNode&&o.parentNode.removeChild(o))}};var Tm=function(e){var t=document.head,n=e||t,r=document.createElement("style"),o=function(e){var t=Array.from(e.querySelectorAll("style[".concat(xp,"]")));return t[t.length-1]}(n),s=void 0!==o?o.nextSibling:null;r.setAttribute(xp,Ep),r.setAttribute(Pp,kp);var a="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null;return a&&r.setAttribute("nonce",a),n.insertBefore(r,s),r},Bm=function(){function e(e){this.element=Tm(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 gm(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}(),Cm=function(){function e(e){this.element=Tm(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}(),$m=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}(),Om=Ip,_m={isServer:!Ip,useCSSOMInjection:!Sp},Rm=function(){function e(e,t,n){void 0===e&&(e=$p),void 0===t&&(t={});var r=this;this.options=wh(wh({},_m),e),this.gs=t,this.names=new Map(n),this.server=!!e.isServer,!this.server&&Ip&&Om&&(Om=!1,Nm(this)),hm(this,function(){return function(e){for(var t=e.getTag(),n=t.length,r="",o=function(n){var o=function(e){return vm.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(xp,".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(Ap)},s=0;s<n;s++)o(s);return r}(r)})}return e.registerId=function(e){return Em(e)},e.prototype.rehydrate=function(){!this.server&&Ip&&Nm(this)},e.prototype.reconstructWithOptions=function(t,n){return void 0===n&&(n=!0),new e(wh(wh({},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 $m(n):t?new Bm(n):new Cm(n)}(this.options),new bm(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(Em(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(Em(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(Em(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e}(),zm=/&/g,Mm=/^\s*\/\/.*$/gm;function Lm(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=Lm(e.children,t)),e})}var Fm=new Rm,Um=function(){var e,t,n,r=$p,o=r.options,s=void 0===o?$p:o,a=r.plugins,i=void 0===a?Cp: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===Nh&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(zm,t).replace(n,c))}),s.prefix&&u.push(wp),u.push(yp);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(Mm,""),l=dp(a||o?"".concat(a," ").concat(o," { ").concat(c," }"):c);s.namespace&&(l=Lm(l,s.namespace));var d,f=[];return bp(l,function(e){var t=jh(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||gm(15),jp(e,t.name)},5381).toString():"",l}(),jm=b.default.createContext({shouldForwardProp:void 0,styleSheet:Fm,stylis:Um});function Dm(){return o.useContext(jm)}jm.Consumer,b.default.createContext(void 0);var Gm=function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=Um);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,hm(this,function(){throw gm(12,String(n.name))})}return e.prototype.getName=function(e){return void 0===e&&(e=Um),this.name+e.hash},e}(),qm=function(e){return e>="A"&&e<="Z"};function Wm(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(1===n&&"-"===r&&"-"===e[0])return e;qm(r)?t+="-"+r.toLowerCase():t+=r}return t.startsWith("ms-")?"-"+t:t}var Vm=function(e){return null==e||!1===e||""===e},Hm=function(e){var t,n,r=[];for(var o in e){var s=e[o];e.hasOwnProperty(o)&&!Vm(s)&&(Array.isArray(s)&&s.isCss||im(s)?r.push("".concat(Wm(o),":"),s,";"):dm(s)?r.push.apply(r,vh(vh(["".concat(o," {")],Hm(s),!1),["}"],!1)):r.push("".concat(Wm(o),": ").concat((t=o,null==(n=s)||"boolean"==typeof n||""===n?"":"number"!=typeof n||0===n||t in vp||t.startsWith("--")?String(n).trim():"".concat(n,"px")),";")))}return r};function Ym(e,t,n,r){if(Vm(e))return[];if(cm(e))return[".".concat(e.styledComponentId)];if(im(e)){if(!im(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 Gm||dm(o)||null===o||console.error("".concat(qp(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.")),Ym(o,t,n,r)}var s;return e instanceof Gm?n?(e.inject(n,r),[e.getName(r)]):[e]:dm(e)?Hm(e):Array.isArray(e)?Array.prototype.concat.apply(Cp,e.map(function(e){return Ym(e,t,n,r)})):[e.toString()]}var Km=Dp(kp),Zm=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(im(n)&&!cm(n))return!1}return!0}(e),this.componentId=t,this.baseHash=jp(Km,t),this.baseStyle=n,Rm.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=um(r,this.staticRulesId);else{var o=lm(Ym(this.rules,e,t,n)),s=Fp(jp(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=um(r,s),this.staticRulesId=s}else{for(var i=jp(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=jp(i,l));else if(l){var d=lm(Ym(l,e,t,n));i=jp(i,d+u),c+=d}}if(c){var f=Fp(i>>>0);t.hasNameForId(this.componentId,f)||t.insertRules(this.componentId,f,n(c,".".concat(f),void 0,this.componentId)),r=um(r,f)}}return r},e}(),Jm=b.default.createContext(void 0);Jm.Consumer;var Qm={},Xm=new Set;function eg(e,t,n){var r=cm(e),s=e,a=!Wp(e),i=t.attrs,c=void 0===i?Cp:i,u=t.componentId,l=void 0===u?function(e,t){var n="string"!=typeof e?"sc":zp(e);Qm[n]=(Qm[n]||0)+1;var r="".concat(n,"-").concat(Gp(kp+n+Qm[n]));return t?"".concat(t,"-").concat(r):r}(t.displayName,t.parentComponentId):u,d=t.displayName,f=void 0===d?function(e){return Wp(e)?"styled.".concat(e):"Styled(".concat(qp(e),")")}(e):d,h=t.displayName&&t.componentId?"".concat(zp(t.displayName),"-").concat(t.componentId):t.componentId||l,p=r&&s.attrs?s.attrs.concat(c).filter(Boolean):c,m=t.shouldForwardProp;if(r&&s.shouldForwardProp){var g=s.shouldForwardProp;if(t.shouldForwardProp){var y=t.shouldForwardProp;m=function(e,t){return g(e,t)&&y(e,t)}}else m=g}var w=new Zm(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=b.default.useContext(Jm),d=Dm(),f=e.shouldForwardProp||d.shouldForwardProp;"production"!==process.env.NODE_ENV&&o.useDebugValue(c);var h=function(e,t,n){return void 0===n&&(n=$p),e.theme!==n.theme&&e.theme||t||n.theme}(t,l,a)||$p,p=function(e,t,n){for(var r,o=wh(wh({},t),{className:void 0,theme:n}),s=0;s<e.length;s+=1){var a=im(r=e[s])?r(o):r;for(var i in a)o[i]="className"===i?um(o[i],a[i]):"style"===i?wh(wh({},o[i]),a[i]):a[i]}return t.className&&(o.className=um(o.className,t.className)),o}(r,t,h),m=p.as||u,g={};for(var y in p)void 0===p[y]||"$"===y[0]||"as"===y||"theme"===y&&p.theme===h||("forwardedAs"===y?g.as=p.forwardedAs:f&&!f(y,m)||(g[y]=p[y],f||"development"!==process.env.NODE_ENV||Ph(y)||Xm.has(y)||!Op.has(m)||(Xm.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=Dm(),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=um(i,c);return w&&(v+=" "+w),p.className&&(v+=" "+p.className),g[Wp(m)&&!Op.has(m)?"class":"className"]=v,n&&(g.ref=n),o.createElement(m,g)}(x,e,t)}v.displayName=f;var x=b.default.forwardRef(v);return x.attrs=p,x.componentStyle=w,x.displayName=f,x.shouldForwardProp=m,x.foldedComponentIds=r?um(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++)fm(e,o[r],!0);return e}({},s.defaultProps,e):e}}),"production"!==process.env.NODE_ENV&&(Bp(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)),hm(x,function(){return".".concat(x.styledComponentId)}),a&&am(x,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),x}function tg(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 ng=function(e){return Object.assign(e,{isCss:!0})};function rg(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(im(e)||dm(e))return ng(Ym(tg(Cp,vh([e],t,!0))));var r=e;return 0===t.length&&1===r.length&&"string"==typeof r[0]?Ym(r):ng(Ym(tg(r,t)))}function og(e,t,n){if(void 0===n&&(n=$p),!t)throw gm(1,t);var r=function(r){for(var o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];return e(t,n,rg.apply(void 0,vh([r],o,!1)))};return r.attrs=function(r){return og(e,t,wh(wh({},n),{attrs:Array.prototype.concat(n.attrs,r).filter(Boolean)}))},r.withConfig=function(r){return og(e,t,wh(wh({},n),r))},r}var sg=function(e){return og(eg,e)},ag=sg;Op.forEach(function(e){ag[e]=sg(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 ig="__sc-".concat(xp,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[ig]||(window[ig]=0),1===window[ig]&&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[ig]+=1);const cg={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"}},ug=(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=lm(rg.apply(void 0,vh([e],t,!1))),o=Gp(r);return new Gm(o,r)})`
12
+ const ql=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Vl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Hl=BigInt(0),Yl=BigInt(1),Kl=BigInt(2),Zl=(e,t)=>(e+t/Kl)/t;const Jl=vl(ql,void 0,void 0,{sqrt:function(e){const t=ql,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=dl(l,n,t)*l%t,f=dl(d,n,t)*l%t,h=dl(f,Kl,t)*u%t,p=dl(h,o,t)*h%t,m=dl(p,s,t)*p%t,g=dl(m,i,t)*m%t,b=dl(g,c,t)*g%t,y=dl(b,i,t)*m%t,w=dl(y,n,t)*l%t,v=dl(w,a,t)*p%t,x=dl(v,r,t)*u%t,E=dl(x,Kl,t);if(!Jl.eql(Jl.sqr(E),e))throw new Error("Cannot find square root");return E}}),Ql=function(e,t){const n=t=>Gl({...e,...Wl(t)});return{...n(t),create:n}}({a:Hl,b:BigInt(7),Fp:Jl,n:Vl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Vl,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Yl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),i=Zl(s*e,t),c=Zl(-r*e,t);let u=ll(e-i*n-c*o,t),l=ll(-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}}}},Ns);var Xl=Object.freeze({__proto__:null,secp256k1:Ql});function ed(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new sd({signature:e});if(void 0===e.s)throw new sd({signature:e});if(n&&void 0===e.yParity)throw new sd({signature:e});if(e.r<0n||e.r>$u)throw new ad({value:e.r});if(e.s<0n||e.s>$u)throw new id({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new cd({value:e.yParity})}function td(e){if(130!==e.length&&132!==e.length)throw new od({signature:e});const t=BigInt(mi(e,0,32)),n=BigInt(mi(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return rd(t)}catch{throw new cd({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function nd(e){if(void 0!==e.r&&void 0!==e.s)return function(e){const t="string"==typeof e?td(e):e instanceof Uint8Array?function(e){return td(li(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=rd(t)),"number"!=typeof n)throw new cd({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:rd(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return ed(t),t}(e)}function rd(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 ud({value:e})}class od extends Ca{constructor({signature:e}){var t;super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${gi((t=e,t instanceof Uint8Array?li(t):Array.isArray(t)?li(new Uint8Array(t)):t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class sd extends Ca{constructor({signature:e}){super(`Signature \`${Wa(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class ad extends Ca{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 id extends Ca{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 cd extends Ca{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 ud extends Ca{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 ld(e,t={}){return"string"==typeof e.chainId?function(e){const{address:t,chainId:n,nonce:r}=e,o=nd(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...o}}(e):{...e,...t.signature}}const dd=Hu("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function fd(e){if("string"==typeof e){if("0x8010801080108010801080108010801080108010801080108010801080108010"!==mi(e,-32))throw new hd(e)}else ed(e.authorization)}let hd=class extends Ca{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 pd(e,{address:t,blockNumber:n,blockTag:r,storageKeys:o}){const s=r??"latest",a=void 0!==n?jt(n):void 0;return function(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?zt(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 md(e,{blockHash:t,blockNumber:n,blockTag:r,hash:o,index:s}){const a=r||"latest",i=void 0!==n?jt(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,jt(s)]},{dedupe:!0}):await e.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[i||a,jt(s)]},{dedupe:Boolean(i)}),!c)throw new Gr({blockHash:t,blockNumber:n,blockTag:a,hash:o,index:s});return(e.chain?.formatters?.transaction?.format||fs)(c)}async function gd(e,{hash:t}){const n=await e.request({method:"eth_getTransactionReceipt",params:[t]},{dedupe:!0});if(!n)throw new Wr({hash:t});return(e.chain?.formatters?.transactionReceipt?.format||pc)(n)}async function bd(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?Si(e.blockOverrides):void 0,r=e.calls.map(e=>{const t=e,n=t.account?lr(t.account):void 0,r=t.abi?fr(t):t.data,o={...t,data:t.dataSuffix?Gn([r||"0x",t.dataSuffix]):r,from:t.from??n?.address};return as(o),ts(o)}),o=e.stateOverrides?os(e.stateOverrides):void 0;t.push({blockOverrides:n,calls:r,stateOverrides:o})}const c=("bigint"==typeof n?jt(n):void 0)||r;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:t,returnFullTransactions:s,traceTransfers:a,validation:i},c]})).map((e,t)=>({...hs(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=>Hs(e)),d="0x1"===e.status?"success":"failure",f=r&&"success"===d&&"0x"!==c?Js({abi:r,data:c,functionName:a}):null,h=(()=>{if("success"===d)return;let t;return"0x"===e.error?.data?t=new nt:e.error&&(t=new Jr(e.error)),t?Co(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=Qo(t,{});if(n instanceof Jo)throw t;throw n}}function yd(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 Ca("Unable to normalize signature.");return o}function wd(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Au(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)=>wd(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=>wd(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function vd(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 vd(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")))&&Au(n[r],{strict:!1}))())return a}}function xd(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?je(e):e;return{...r,...n?{hash:kd(r)}:{}}}function Ed(e,t,n){const{args:r=[],prepare:o=!0}=n??{},s=wi(t,{strict:!1}),a=e.filter(e=>s?"function"===e.type||"error"===e.type?Pd(e)===mi(t,0,4):"event"===e.type&&kd(e)===t:"name"in e&&e.name===t);if(0===a.length)throw new Id({name:t});if(1===a.length)return{...a[0],...o?{hash:kd(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:kd(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&&wd(t,r)});if(t){if(i&&"inputs"in i&&i.inputs){const t=vd(e.inputs,i.inputs,r);if(t)throw new Ad({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 Id({name:t});return{...c,...o?{hash:kd(c)}:{}}}function Pd(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Ed(t,n)}return e[0]})();return mi(kd(t),0,4)}function kd(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Ed(t,n)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:xu(fi(function(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Ed(t,n)}return e[0]})();return yd("string"==typeof t?t:te(t))}(t)))}class Ad extends Ca{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${yd(te(e.abiItem))}\`, and`,`\`${t.type}\` in \`${yd(te(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 Id extends Ca{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 Sd(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new Id({name:"constructor"});return t}function Nd(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[t,n,r]=e;return[Bd(t,n,{args:r}),r]}const[t,n]=e;return[t,n]})(),{overloads:r}=t,o=r?Bd([t,...r],t.name,{args:n}):t,s=Pd(o);const a=n.length>0?qu(o.inputs,n):void 0;return a?ci(s,a):s}function Td(e,t={}){return xd(e,t)}function Bd(e,t,n){const r=Ed(e,t,n);if("function"!==r.type)throw new Id({name:t,type:"function"});return r}const Cd="0x0000000000000000000000000000000000000000";async function $d(e,t){const{blockNumber:n,blockTag:r,calls:o,stateOverrides:s,traceAssetChanges:a,traceTransfers:i,validation:c}=t,u=t.account?lr(t.account):void 0;if(a&&!u)throw new Je("`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[Sd(t),n]}return e})(),{bytecode:r,args:o}=n;return ci(r,t.inputs?.length&&o?.length?qu(t.inputs,o):"0x")}(xd("constructor(bytes, bytes)"),{bytecode:Li,args:["0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033",Nd(Td("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 Gc(e,{account:u.address,...t,data:t.abi?fr(t):t.data});return n.map(({address:e,storageKeys:t})=>t.length>0?e:null)})).then(e=>e.flat().filter(Boolean)):[],f=await bd(e,{blockNumber:n,blockTag:r,blocks:[...a?[{calls:[{data:l}],stateOverrides:s},{calls:d.map((e,t)=>({abi:[Td("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Cd,nonce:t})),stateOverrides:[{address:Cd,nonce:0}]}]:[],{calls:[...o,{}].map(e=>({...e,from:u?.address})),stateOverrides:s},...a?[{calls:[{data:l}]},{calls:d.map((e,t)=>({abi:[Td("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Cd,nonce:t})),stateOverrides:[{address:Cd,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Td("function decimals() returns (uint256)")],functionName:"decimals",from:Cd,nonce:t})),stateOverrides:[{address:Cd,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Td("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:Cd,nonce:t})),stateOverrides:[{address:Cd,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Td("function symbol() returns (string)")],functionName:"symbol",from:Cd,nonce:t})),stateOverrides:[{address:Cd,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?Rt(e.data):null),A=[...g?.calls??[],...b?.calls??[]].map(e=>"success"===e.status?Rt(e.data):null),I=(y?.calls??[]).map(e=>"success"===e.status?e.result:null),S=(v?.calls??[]).map(e=>"success"===e.status?e.result:null),N=(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=S[e-1],s=N[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 Od="0x6492649264926492649264926492649264926492649264926492649264926492";function _d(e){try{return function(e){if(mi(e,-32)!==Od)throw new Rd(e)}(e),!0}catch{return!1}}class Rd extends Ca{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 zd({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 Ql.Signature(Rt(e),Rt(t)).toCompactHex()}${0===s?"1b":"1c"}`;return"hex"===n?a:Yt(a)}async function Md(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 Ve(e)?e:"object"==typeof e&&"r"in e&&"s"in e?zd(e):Ut(e)})();try{return function(e){try{return fd(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){fd(e);const t=yi(mi(e,-64,-32)),n=mi(e,-t-64,-64),r=mi(e,0,-t-64),[o,s,a]=Wu(dd,n);return{authorization:ld({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 Vc(e,{address:n,blockNumber:r,blockTag:o});if(d===Wn(["0xef0100",i.address]))return await async function(e,t){const{address:n,blockNumber:r,blockTag:o,hash:s,signature:a}=t,i=await Ge(e,Xi,"readContract")({address:n,abi:Ri,args:[s,a],blockNumber:r,blockTag:o,functionName:"isValidSignature"}).catch(e=>{if(e instanceof Hr)throw new Ld;throw e});if(i.startsWith("0x1626ba7e"))return!0;throw new Ld}(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:jt(i.r,{size:32}),s:jt(i.s,{size:32}),yParity:i.yParity},h=await async function({address:e,authorization:t,signature:n}){return Ds(Fn(e),await Lo({authorization:t,signature:n}))}({address:n,authorization:f});if(!h)throw new Ld;const p=await Ge(e,Xi,"readContract")({...a?{address:a}:{code:ji},authorizationList:[f],abi:Ni,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...c?[{allowFailure:!0,target:l??n,callData:c}]:[],{allowFailure:!0,target:n,callData:fr({abi:Ri,functionName:"isValidSignature",args:[s,u]})}]]}),m=p[p.length-1]?.returnData;if(m?.startsWith("0x1626ba7e"))return!0;throw new Ld}(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 ci(qu(Hu("address, bytes, bytes"),[r,t,n]),Od)}({data:o,signature:a,to:r}):a)(),l=i?{to:i,data:fr({abi:zi,functionName:"isValidSig",args:[n,s,u]}),...c}:{data:qi({abi:zi,args:[n,s,u],bytecode:Ui}),...c},{data:d}=await Ge(e,Ji,"call")(l).catch(e=>{if(e instanceof Vr)throw new Ld;throw e});if(function(e,t={}){let n=e;if(t.size&&(_t(n,{size:t.size}),n=Ot(n)),"0x00"===Ot(n))return!1;if("0x01"===Ot(n))return!0;throw new Ct(n)}(d??"0x0"))return!0;throw new Ld}(e,{...t,verifierAddress:o,signature:a})}catch(e){try{if(Ds(Fn(n),await Oo({hash:r,signature:a})))return!0}catch{}if(e instanceof Ld)return!1;throw e}}class Ld extends Error{}function Fd(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))?rc(Br(["watchBlockNumber",e.uid,t,n,a]),{onBlockNumber:r,onError:o},r=>sc(async()=>{try{const t=await Ge(e,uc,"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})):rc(Br(["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=Rt(e.result?.number);t.onBlockNumber(r,i),i=r},onError(e){t.onError?.(e)}});r=s,n||r()}catch(e){o?.(e)}})(),()=>r()})}const Ud=/^(?:(?<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)?/,jd=/(?: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 Dd(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(Ud)?.groups??{},{chainId:o,expirationTime:s,issuedAt:a,notBefore:i,requestId:c,...u}=e.match(jd)?.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(!Dn(r.address,{strict:!1}))return!1;if(t&&!Ds(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=iu(o);return Md(e,{address:l.address,hash:f,signature:i,...u})}function Gd(e){return{call:t=>Ji(e,t),createAccessList:t=>Gc(e,t),createBlockFilter:()=>async function(e){const t=cr(e,{method:"eth_newBlockFilter"}),n=await e.request({method:"eth_newBlockFilter"});return{id:n,request:t(n),type:"block"}}(e),createContractEventFilter:t=>ur(e,t),createEventFilter:t=>Wc(e,t),createPendingTransactionFilter:()=>qc(e),estimateContractGas:t=>async function(e,t){const{abi:n,address:r,args:o,functionName:s,dataSuffix:a,...i}=t,c=fr({abi:n,args:o,functionName:s});try{return await Ge(e,js,"estimateGas")({data:`${c}${a?a.replace("0x",""):""}`,to:r,...i})}catch(e){const t=i.account?lr(i.account):void 0;throw Co(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/estimateContractGas",functionName:s,sender:t?.address})}}(e,t),estimateGas:t=>js(e,t),getBalance:t=>async function(e,{address:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest"}){const o="bigint"==typeof n?jt(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=>ps(e,t),getBlockNumber:t=>uc(e,t),getBlockTransactionCount:t=>async function(e,{blockHash:t,blockNumber:n,blockTag:r="latest"}={}){const o=void 0!==n?jt(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)}),zt(s)}(e,t),getBytecode:t=>Vc(e,t),getChainId:()=>Ms(e),getCode:t=>Vc(e,t),getContractEvents:t=>Ks(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 Ge(e,Xi,"readContract")({abi:Yc,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 Hc({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 Vi({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),l=c?.ensTlds;if(l&&!l.some(e=>s.endsWith(e)))return null;const d=null!=o?[Ac(s),BigInt(o)]:[Ac(s)];try{const t=fr({abi:_i,functionName:"addr",args:d}),o={address:u,abi:Ci,functionName:"resolveWithGateways",args:[Lt(Nc(s)),t,a??[Ec]],blockNumber:n,blockTag:r},i=Ge(e,Xi,"readContract"),c=await i(o);if("0x"===c[0])return null;const l=Js({abi:_i,args:d,functionName:"addr",data:c[0]});return"0x"===l||"0x00"===Ot(l)?null:l}catch(e){if(i)throw e;if(yc(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 Ge(e,Dc,"getEnsText")({blockNumber:t,blockTag:n,key:"avatar",name:o,universalResolverAddress:i,gatewayUrls:s,strict:a});if(!c)return null;try{return await jc(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 Vi({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})();try{const t={address:u,abi:$i,args:[n,s,a??[Ec]],functionName:"reverseWithGateways",blockNumber:r,blockTag:o},i=Ge(e,Xi,"readContract"),[c]=await i(t);return c||null}catch(e){if(i)throw e;if(yc(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 Vi({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 Ge(e,Xi,"readContract")({address:a,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[Lt(Nc(o))],blockNumber:n,blockTag:r});return c}(e,t),getEnsText:t=>Dc(e,t),getFeeHistory:t=>Kc(e,t),estimateFeesPerGas:t=>async function(e,t){return bs(e,t)}(e,t),getFilterChanges:e=>lc(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=>Hs(e));return t.abi?Vs({abi:t.abi,logs:r,strict:n}):r}(0,e),getGasPrice:()=>ms(e),getLogs:t=>Ys(e,t),getProof:t=>pd(e,t),estimateMaxPriorityFeePerGas:t=>async function(e,t){return gs(e,t)}(e,t),getStorageAt:t=>async function(e,{address:t,blockNumber:n,blockTag:r="latest",slot:o}){const s=void 0!==n?jt(n):void 0;return await e.request({method:"eth_getStorageAt",params:[t,o,s||r]})}(e,t),getTransaction:t=>md(e,t),getTransactionConfirmations:t=>async function(e,{hash:t,transactionReceipt:n}){const[r,o]=await Promise.all([Ge(e,uc,"getBlockNumber")({}),t?Ge(e,md,"getTransaction")({hash:t}):void 0]),s=n?.blockNumber||o?.blockNumber;return s?r-s+1n:0n}(e,t),getTransactionCount:t=>ys(e,t),getTransactionReceipt:t=>gd(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 Vi({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=fr({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=Co(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=>Ge(e,Xi,"readContract")({...null===f?{code:ji}:{address:f},abi:Ni,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 nt;if(!s)throw new Jr({data:r});const e=Js({abi:i,args:d,data:r,functionName:l});b.push(o?{result:e,status:"success"}:e)}catch(e){const t=Co(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 Je("multicall results mismatch");return b}(e,t),prepareTransactionRequest:t=>Us(e,t),readContract:t=>Xi(e,t),sendRawTransaction:t=>async function(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}(e,t),simulate:t=>bd(e,t),simulateBlocks:t=>bd(e,t),simulateCalls:t=>$d(e,t),simulateContract:t=>async function(e,t){const{abi:n,address:r,args:o,dataSuffix:s,functionName:a,...i}=t,c=i.account?lr(i.account):e.account,u=fr({abi:n,args:o,functionName:a});try{const{data:l}=await Ge(e,Ji,"call")({batch:!1,data:`${u}${s?s.replace("0x",""):""}`,to:r,...i,account:c});return{result:Js({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 Co(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/simulateContract",functionName:a,sender:c?.address})}}(e,t),verifyHash:t=>Md(e,t),verifyMessage:t=>async function(e,{address:t,message:n,factory:r,factoryData:o,signature:s,...a}){return Md(e,{address:t,factory:r,factoryData:o,hash:iu(n),signature:s,...a})}(e,t),verifySiweMessage:t=>Dd(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 Md(e,{address:n,factory:r,factoryData:o,hash:hu({message:a,primaryType:i,types:c,domain:u}),signature:s,...l})}(e,t),uninstallFilter:e=>dc(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=Br(["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}=Yi(),v=c?setTimeout(()=>{m?.(),p?.(),w(new qr({hash:o}))},c):void 0;return p=rc(u,{onReplaced:s,resolve:y,reject:w},async t=>{if(h=await Ge(e,gd,"getTransactionReceipt")({hash:o}).catch(()=>{}),h&&r<=1)return clearTimeout(v),t.resolve(h),void p?.();m=Ge(e,Fd,"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 fc(async()=>{d=await Ge(e,md,"getTransaction")({hash:o}),d.blockNumber&&(u=d.blockNumber)},{delay:i,retryCount:a}),g=!1),h=await Ge(e,gd,"getTransactionReceipt")({hash:o}),r>1&&(!h.blockNumber||u-h.blockNumber+1n<r))return;c(()=>t.resolve(h))}catch(n){if(n instanceof Gr||n instanceof Wr){if(!d)return void(g=!1);try{f=d,g=!0;const n=await fc(()=>Ge(e,ps,"getBlock")({blockNumber:u,includeTransactions:!0}),{delay:i,retryCount:a,shouldRetry:({error:e})=>e instanceof ls});g=!1;const o=n.transactions.find(({from:e,nonce:t})=>e===f.from&&t===f.nonce);if(!o)return;if(h=await Ge(e,gd,"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?rc(Br(["watchBlocks",e.uid,t,n,r,l,c]),{onBlock:o,onError:s},o=>sc(async()=>{try{const r=await Ge(e,ps,"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 Ge(e,ps,"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&&Ge(e,ps,"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 Ge(e,ps,"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=>Fd(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 rc(Br(["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=sc(async()=>{if(f)try{let i;if(l)i=await Ge(e,lc,"getFilterChanges")({filter:l});else{const s=await Ge(e,uc,"getBlockNumber")({});i=u&&u<s?await Ge(e,Ks,"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 co&&(f=!1),c.onError?.(e)}else{try{l=await Ge(e,ur,"createContractEventFilter")({abi:n,address:r,args:o,eventName:a,strict:t,fromBlock:i})}catch{}f=!0}},{emitOnBegin:!0,interval:d});return async()=>{l&&await Ge(e,dc,"uninstallFilter")({filter:l}),h()}})})():(()=>{const t=f??!1,i=Br(["watchContractEvent",r,o,s,e.uid,a,d,t]);let l=!0,h=()=>l=!1;return rc(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?ar({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}=Ws({abi:n,data:r.data,topics:r.topics,strict:f}),s=Hs(r,{args:o,eventName:e});t.onLogs([s])}catch(e){let n,o;if(e instanceof bt||e instanceof yt){if(f)return;n=e.abiItem.name,o=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const s=Hs(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?rc(Br(["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=sc(async()=>{if(d)try{let a;if(u)a=await Ge(e,lc,"getFilterChanges")({filter:u});else{const r=await Ge(e,uc,"getBlockNumber")({});a=c&&c!==r?await Ge(e,Ys,"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 co&&(d=!1),i.onError?.(e)}else{try{u=await Ge(e,Wc,"createEventFilter")({address:t,args:n,event:o,events:s,strict:h,fromBlock:a})}catch{}d=!0}},{emitOnBegin:!0,interval:l});return async()=>{u&&await Ge(e,dc,"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=>ar({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}=Ws({abi:l??[],data:t.data,topics:t.topics,strict:h}),r=Hs(t,{args:n,eventName:e});c([r])}catch(e){let n,r;if(e instanceof bt||e instanceof yt){if(d)return;n=e.abiItem.name,r=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const o=Hs(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)?rc(Br(["watchPendingTransactions",e.uid,t,s]),{onTransactions:r,onError:n},n=>{let r;const o=sc(async()=>{try{if(!r)try{return void(r=await Ge(e,qc,"createPendingTransactionFilter")({}))}catch(e){throw o(),e}const s=await Ge(e,lc,"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 Ge(e,dc,"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 Wd(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?lr(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:bc(),...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(Gd)}class qd extends Je{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 Vd(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 qd;const v=au(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:Jc(r,{methods:t,retryCount:o,retryDelay:s,uid:bc()}),value:c}}({key:s,methods:a,name:i,async request({method:e,params:t}){const r={method:e,params:t},{schedule:o}=Zi({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 Xr({body:r,error:s,url:w});return a},retryCount:b,retryDelay:l,timeout:y,type:"http"},{fetchOptions:o,url:w})}}function Hd(e,t,n){for(let n in t){let r=t[n];Object.defineProperty(e,n,{enumerable:!0,value:r,writable:!1})}}function Yd(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=>Yd(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 Yd(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=>`${Yd(n,t)}: ${Yd(e[n],t)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Kd(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: ${Yd(n)}`);for(const e in n){if("shortMessage"===e)continue;const t=n[e];r.push(e+"="+Yd(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 Hd(r,{code:t}),n&&Object.assign(r,n),null==r.shortMessage&&Hd(r,{shortMessage:o}),r}(t,n,r)}function Zd(e,t,n,r){Kd(e,t,"INVALID_ARGUMENT",{argument:n,value:r})}function Jd(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}Zd(!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 Qd=BigInt(0),Xd=BigInt(1),ef=9007199254740991;function tf(e,t){const n=of(e,"value"),r=BigInt(af(t,"width"));if(Kd(n>>r===Qd,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),n>>r-Xd){return-((~n&(Xd<<r)-Xd)+Xd)}return n}function nf(e,t){const n=of(e,"value"),r=BigInt(af(t,"bits"));return n&(Xd<<r)-Xd}function rf(e,t){switch(typeof e){case"bigint":return e;case"number":return Zd(Number.isInteger(e),"underflow",t||"value",e),Zd(e>=-ef&&e<=ef,"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){Zd(!1,`invalid BigNumberish string: ${n.message}`,t||"value",e)}}Zd(!1,"invalid BigNumberish value",t||"value",e)}function of(e,t){const n=rf(e,t);return Kd(n>=Qd,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),n}const sf="0123456789abcdef";function af(e,t){switch(typeof e){case"bigint":return Zd(e>=-ef&&e<=ef,"overflow",t||"value",e),Number(e);case"number":return Zd(Number.isInteger(e),"underflow",t||"value",e),Zd(e>=-ef&&e<=ef,"overflow",t||"value",e),e;case"string":try{if(""===e)throw new Error("empty string");return af(BigInt(e),t)}catch(n){Zd(!1,`invalid numeric string: ${n.message}`,t||"value",e)}}Zd(!1,"invalid numeric value",t||"value",e)}const cf=BigInt(-1),uf=BigInt(0),lf=BigInt(1),df=BigInt(5),ff={};let hf="0000";for(;hf.length<80;)hf+=hf;function pf(e){let t=hf;for(;t.length<e;)t+=t;return BigInt("1"+t.substring(0,e))}function mf(e,t,n){const r=BigInt(t.width);if(t.signed){const t=lf<<r-lf;Kd(null==n||e>=-t&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=e>uf?tf(nf(e,r),r):-tf(nf(-e,r),r)}else{const t=lf<<r;Kd(null==n||e>=0&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=(e%t+t)%t&t-lf}return e}function gf(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]+)$/);Zd(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:(Zd(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)}Zd(n%8==0,"invalid FixedNumber width (not byte aligned)","format.width",n),Zd(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 bf{format;#e;#t;#n;_value;constructor(e,t,n){!function(e,t,n){if(e!==t){let e=n,t="new";e+=".",t+=" "+n,Kd(!1,`private constructor; use ${e}from* methods`,"UNSUPPORTED_OPERATION",{operation:t})}}(e,ff,"FixedNumber"),this.#t=t,this.#e=n;const r=function(e,t){let n="";e<uf&&(n="-",e*=cf);let r=e.toString();if(0===t)return n+r;for(;r.length<=t;)r=hf+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);Hd(this,{format:n.name,_value:r}),this.#n=pf(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){Zd(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)}#o(e,t){return e=mf(e,this.#e,t),new bf(ff,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 Kd(t%this.#n===uf,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),this.#o(t/this.#n,"mulSignal")}#c(e,t){return Kd(e.#t!==uf,"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){Kd(e.#t!==uf,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),this.#r(e);const t=this.#t*this.#n;return Kd(t%e.#t===uf,"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*=pf(r):r<0&&(t*=pf(-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<uf&&(e-=this.#n-lf),e=this.#t/this.#n*this.#n,this.#o(e,"floor")}ceiling(){let e=this.#t;return this.#t>uf&&(e+=this.#n-lf),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=df*pf(t-1);let r=this.value+n;const o=pf(t);return r=r/o*o,mf(r,this.#e,"round"),new bf(ff,r,this.#e)}isZero(){return this.#t===uf}isNegative(){return this.#t<uf}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return bf.fromString(this.toString(),e)}static fromValue(e,t,n){const r=null==t?0:af(t),o=gf(n);let s=rf(e,"value");const a=r-o.decimals;if(a>0){const t=pf(a);Kd(s%t===uf,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),s/=t}else a<0&&(s*=pf(-a));return mf(s,o,"fromValue"),new bf(ff,s,o)}static fromString(e,t){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Zd(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const r=gf(t);let o=n[2]||"0",s=n[3]||"";for(;s.length<r.decimals;)s+=hf;Kd(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 mf(a,r,"fromString"),new bf(ff,a,r)}static fromBytes(e,t){let n=function(e){if(e instanceof Uint8Array){let t="0x0";for(const n of e)t+=sf[n>>4],t+=sf[15&n];return BigInt(t)}return rf(e)}(Jd(e,"value"));const r=gf(t);return r.signed&&(n=tf(n,r.width)),mf(n,r,"fromBytes"),new bf(ff,n,r)}}function yf(e){return function(e,t){let n=18;return n=af(t,"unit"),bf.fromValue(e,n,{decimals:n,width:512}).toString()}(e,18)}const wf="0.38.13";function vf({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@${wf}:${t}`):r.searchParams.append("sdkVersion",`onchainkit@${wf}`),r.searchParams.sort(),r.toString()}var xf=[],Ef=[],Pf="undefined"!=typeof Uint8Array?Uint8Array:Array,kf=!1;function Af(){kf=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)xf[t]=e[t],Ef[e.charCodeAt(t)]=t;Ef["-".charCodeAt(0)]=62,Ef["_".charCodeAt(0)]=63}function If(e){return xf[e>>18&63]+xf[e>>12&63]+xf[e>>6&63]+xf[63&e]}function Sf(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(If(r));return o.join("")}function Nf(e){var t;kf||Af();for(var n=e.length,r=n%3,o="",s=[],a=16383,i=0,c=n-r;i<c;i+=a)s.push(Sf(e,i,i+a>c?c:i+a));return 1===r?(t=e[n-1],o+=xf[t>>2],o+=xf[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=xf[t>>10],o+=xf[t>>4&63],o+=xf[t<<2&63],o+="="),s.push(o),s.join("")}function Tf(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 Bf(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 Cf={}.toString,$f=Array.isArray||function(e){return"[object Array]"==Cf.call(e)};function Of(){return Rf.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function _f(e,t){if(Of()<t)throw new RangeError("Invalid typed array length");return Rf.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Rf.prototype:(null===e&&(e=new Rf(t)),e.length=t),e}function Rf(e,t,n){if(!(Rf.TYPED_ARRAY_SUPPORT||this instanceof Rf))return new Rf(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 Lf(this,e)}return zf(this,e,t,n)}function zf(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);Rf.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Rf.prototype:e=Ff(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!Rf.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Df(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(jf(t)){var n=0|Uf(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):Ff(e,t);if("Buffer"===t.type&&$f(t.data))return Ff(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Mf(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 Lf(e,t){if(Mf(t),e=_f(e,t<0?0:0|Uf(t)),!Rf.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Ff(e,t){var n=t.length<0?0:0|Uf(t.length);e=_f(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Uf(e){if(e>=Of())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Of().toString(16)+" bytes");return 0|e}function jf(e){return!(null==e||!e._isBuffer)}function Df(e,t){if(jf(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 mh(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return gh(e).length;default:if(r)return mh(e).length;t=(""+t).toLowerCase(),r=!0}}function Gf(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 oh(this,t,n);case"utf8":case"utf-8":return eh(this,t,n);case"ascii":return nh(this,t,n);case"latin1":case"binary":return rh(this,t,n);case"base64":return Xf(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sh(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Wf(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function qf(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=Rf.from(t,r)),jf(t))return 0===t.length?-1:Vf(e,t,n,r,o);if("number"==typeof t)return t&=255,Rf.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Vf(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Vf(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 Hf(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 Yf(e,t,n,r){return bh(mh(t,e.length-n),e,n,r)}function Kf(e,t,n,r){return bh(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Zf(e,t,n,r){return Kf(e,t,n,r)}function Jf(e,t,n,r){return bh(gh(t),e,n,r)}function Qf(e,t,n,r){return bh(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 Xf(e,t,n){return 0===t&&n===e.length?Nf(e):Nf(e.slice(t,n))}function eh(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<=th)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=th));return n}(r)}Rf.TYPED_ARRAY_SUPPORT=void 0===globalThis.TYPED_ARRAY_SUPPORT||globalThis.TYPED_ARRAY_SUPPORT,Of(),Rf.poolSize=8192,Rf._augment=function(e){return e.__proto__=Rf.prototype,e},Rf.from=function(e,t,n){return zf(null,e,t,n)},Rf.TYPED_ARRAY_SUPPORT&&(Rf.prototype.__proto__=Uint8Array.prototype,Rf.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Rf[Symbol.species]),Rf.alloc=function(e,t,n){return function(e,t,n,r){return Mf(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)},Rf.allocUnsafe=function(e){return Lf(null,e)},Rf.allocUnsafeSlow=function(e){return Lf(null,e)},Rf.isBuffer=function(e){return null!=e&&(!!e._isBuffer||yh(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&yh(e.slice(0,0))}(e))},Rf.compare=function(e,t){if(!jf(e)||!jf(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},Rf.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}},Rf.concat=function(e,t){if(!$f(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Rf.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=Rf.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var s=e[n];if(!jf(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},Rf.byteLength=Df,Rf.prototype._isBuffer=!0,Rf.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)Wf(this,t,t+1);return this},Rf.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)Wf(this,t,t+3),Wf(this,t+1,t+2);return this},Rf.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)Wf(this,t,t+7),Wf(this,t+1,t+6),Wf(this,t+2,t+5),Wf(this,t+3,t+4);return this},Rf.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?eh(this,0,e):Gf.apply(this,arguments)},Rf.prototype.equals=function(e){if(!jf(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Rf.compare(this,e)},Rf.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+">"},Rf.prototype.compare=function(e,t,n,r,o){if(!jf(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},Rf.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},Rf.prototype.indexOf=function(e,t,n){return qf(this,e,t,n,!0)},Rf.prototype.lastIndexOf=function(e,t,n){return qf(this,e,t,n,!1)},Rf.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 Hf(this,e,t,n);case"utf8":case"utf-8":return Yf(this,e,t,n);case"ascii":return Kf(this,e,t,n);case"latin1":case"binary":return Zf(this,e,t,n);case"base64":return Jf(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qf(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},Rf.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var th=4096;function nh(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 rh(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 oh(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+=ph(e[s]);return o}function sh(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 ah(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 ih(e,t,n,r,o,s){if(!jf(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 ch(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 uh(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 lh(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 dh(e,t,n,r,o){return o||lh(e,0,n,4),Bf(e,t,n,r,23,4),n+4}function fh(e,t,n,r,o){return o||lh(e,0,n,8),Bf(e,t,n,r,52,8),n+8}Rf.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),Rf.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=Rf.prototype;else{var o=t-e;n=new Rf(o,void 0);for(var s=0;s<o;++s)n[s]=this[s+e]}return n},Rf.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||ah(e,t,this.length);for(var r=this[e],o=1,s=0;++s<t&&(o*=256);)r+=this[e+s]*o;return r},Rf.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||ah(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},Rf.prototype.readUInt8=function(e,t){return t||ah(e,1,this.length),this[e]},Rf.prototype.readUInt16LE=function(e,t){return t||ah(e,2,this.length),this[e]|this[e+1]<<8},Rf.prototype.readUInt16BE=function(e,t){return t||ah(e,2,this.length),this[e]<<8|this[e+1]},Rf.prototype.readUInt32LE=function(e,t){return t||ah(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Rf.prototype.readUInt32BE=function(e,t){return t||ah(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Rf.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||ah(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},Rf.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||ah(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},Rf.prototype.readInt8=function(e,t){return t||ah(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Rf.prototype.readInt16LE=function(e,t){t||ah(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Rf.prototype.readInt16BE=function(e,t){t||ah(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Rf.prototype.readInt32LE=function(e,t){return t||ah(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Rf.prototype.readInt32BE=function(e,t){return t||ah(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Rf.prototype.readFloatLE=function(e,t){return t||ah(e,4,this.length),Tf(this,e,!0,23,4)},Rf.prototype.readFloatBE=function(e,t){return t||ah(e,4,this.length),Tf(this,e,!1,23,4)},Rf.prototype.readDoubleLE=function(e,t){return t||ah(e,8,this.length),Tf(this,e,!0,52,8)},Rf.prototype.readDoubleBE=function(e,t){return t||ah(e,8,this.length),Tf(this,e,!1,52,8)},Rf.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||ih(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},Rf.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||ih(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},Rf.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||ih(this,e,t,1,255,0),Rf.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Rf.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||ih(this,e,t,2,65535,0),Rf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ch(this,e,t,!0),t+2},Rf.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||ih(this,e,t,2,65535,0),Rf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ch(this,e,t,!1),t+2},Rf.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||ih(this,e,t,4,4294967295,0),Rf.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):uh(this,e,t,!0),t+4},Rf.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||ih(this,e,t,4,4294967295,0),Rf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):uh(this,e,t,!1),t+4},Rf.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);ih(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},Rf.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);ih(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},Rf.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||ih(this,e,t,1,127,-128),Rf.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Rf.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||ih(this,e,t,2,32767,-32768),Rf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ch(this,e,t,!0),t+2},Rf.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||ih(this,e,t,2,32767,-32768),Rf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ch(this,e,t,!1),t+2},Rf.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||ih(this,e,t,4,2147483647,-2147483648),Rf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):uh(this,e,t,!0),t+4},Rf.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||ih(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Rf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):uh(this,e,t,!1),t+4},Rf.prototype.writeFloatLE=function(e,t,n){return dh(this,e,t,!0,n)},Rf.prototype.writeFloatBE=function(e,t,n){return dh(this,e,t,!1,n)},Rf.prototype.writeDoubleLE=function(e,t,n){return fh(this,e,t,!0,n)},Rf.prototype.writeDoubleBE=function(e,t,n){return fh(this,e,t,!1,n)},Rf.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||!Rf.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},Rf.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&&!Rf.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=jf(e)?e:mh(new Rf(e,r).toString()),i=a.length;for(s=0;s<n-t;++s)this[s+t]=a[s%i]}return this};var hh=/[^+\/0-9A-Za-z-_]/g;function ph(e){return e<16?"0"+e.toString(16):e.toString(16)}function mh(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 gh(e){return function(e){var t,n,r,o,s,a;kf||Af();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 Pf(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=Ef[e.charCodeAt(t)]<<18|Ef[e.charCodeAt(t+1)]<<12|Ef[e.charCodeAt(t+2)]<<6|Ef[e.charCodeAt(t+3)],a[c++]=o>>16&255,a[c++]=o>>8&255,a[c++]=255&o;return 2===s?(o=Ef[e.charCodeAt(t)]<<2|Ef[e.charCodeAt(t+1)]>>4,a[c++]=255&o):1===s&&(o=Ef[e.charCodeAt(t)]<<10|Ef[e.charCodeAt(t+1)]<<4|Ef[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(hh,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function bh(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 yh(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}class wh{constructor(e){this.selectedWalletId=null,this.solanaConnection=null,this.ethereumProvider=null,this.walletInfo=null,this.phantomAdapter=null,this.walletType="embedded",this.backupWalletType="embedded_backup",this.ethereumNetwork=null,this.defaultNetwork=exports.Network.Solana,this.api=m.default.create({baseURL:e.baseURL,headers:{"Content-Type":"application/json"}}),this.middleAccountApi=m.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=Wd({transport:Vd(e.ethereumNetwork.rpcUrl)})),this.defaultNetwork=e.defaultNetwork||exports.Network.Solana}setWallet(e){this.walletInfo=e}setWalletType(e){this.walletType=e,I.saveWalletType(e)}setBackupWalletType(e){this.backupWalletType=e,I.saveBackupWalletType(e),console.log(33)}getWallet(){return this.walletInfo}getPhantomAdapter(){return this.phantomAdapter}getWalletType(){return this.walletType}getBackupWalletType(){return this.backupWalletType}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,t;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.address===I.getSwitchedAccountAddress()))||(null===(t=this.walletInfo)||void 0===t?void 0:t.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,t,n,r;const o=null===(t=null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.address===I.getSwitchedAccountAddress()))||void 0===t?void 0:t.wallet_set;return o?(null===(n=this.walletInfo)||void 0===n?void 0:n.wallets.find(e=>e.network===exports.Network.Solana&&e.wallet_set===o))||null:(null===(r=this.walletInfo)||void 0===r?void 0:r.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(e){try{if(I.getWalletType()==="phantom"+(e?"_backup":"")){return await this.connectPhantom()}if(!e){const e=await this.getSession();return this.setWallet(e),e}const t=I.getBackupWalletInfo();return this.setWallet(t),t}catch(e){return null}}async connectPhantom(){try{if(this.phantomAdapter||(this.phantomAdapter=new V),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(w(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:g.default.encode(w(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),Rf.from(g.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),t.isBackup?this.setBackupWalletType("embedded_backup"):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),console.log(11),t.isBackup?(console.log(22),this.setBackupWalletType("embedded_backup")):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&&I.saveAccessToken(t),e}async logout(e){this.phantomAdapter?(this.phantomAdapter.disconnect(),this.phantomAdapter=null):await this.api.post("/logout",{},{withCredentials:!0}),this.setWallet(null),e?I.clearBackup():I.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 yf(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=g.default.decode(r),s=o[64];return zd({r:`0x${Rf.from(o.slice(0,32)).toString("hex")}`,s:`0x${Rf.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 vf(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")}}async getCrossMarginGeneralInfo(){return(await this.api.get("/crossmargin/general_info")).data}async getCrossMarginBorrowQuote(e){return(await this.api.post("/crossmargin/borrow/quote",e,{withCredentials:!0})).data}async borrowCrossMargin(e){return(await this.api.post("/crossmargin/borrow",e,{withCredentials:!0})).data}async getCrossMarginRepayQuote(e){return(await this.api.post("/crossmargin/repay/quote",e,{withCredentials:!0})).data}async repayCrossMargin(e){return(await this.api.post("/crossmargin/repay",e,{withCredentials:!0})).data}async adjustCrossMarginMargin(e){return(await this.api.post("/crossmargin/margin",e,{withCredentials:!0})).data}async getCrossMarginOpenPositions(){return(await this.api.get("/crossmargin/positions",{withCredentials:!0})).data}async getCrossMarginHistory(){return(await this.api.get("/crossmargin/history",{withCredentials:!0})).data}}var vh=function(){return vh=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},vh.apply(this,arguments)};function xh(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 Eh(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 Ph=/^((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)-.*))$/,kh=Eh(function(e){return Ph.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}),Ah="-ms-",Ih="-moz-",Sh="-webkit-",Nh="comm",Th="rule",Bh="decl",Ch="@keyframes",$h=Math.abs,Oh=String.fromCharCode,_h=Object.assign;function Rh(e){return e.trim()}function zh(e,t){return(e=t.exec(e))?e[0]:e}function Mh(e,t,n){return e.replace(t,n)}function Lh(e,t,n){return e.indexOf(t,n)}function Fh(e,t){return 0|e.charCodeAt(t)}function Uh(e,t,n){return e.slice(t,n)}function jh(e){return e.length}function Dh(e){return e.length}function Gh(e,t){return t.push(e),e}function Wh(e,t){return e.filter(function(e){return!zh(e,t)})}var qh=1,Vh=1,Hh=0,Yh=0,Kh=0,Zh="";function Jh(e,t,n,r,o,s,a,i){return{value:e,root:t,parent:n,type:r,props:o,children:s,line:qh,column:Vh,length:a,return:"",siblings:i}}function Qh(e,t){return _h(Jh("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function Xh(e){for(;e.root;)e=Qh(e.root,{children:[e]});Gh(e,e.siblings)}function ep(){return Kh=Yh>0?Fh(Zh,--Yh):0,Vh--,10===Kh&&(Vh=1,qh--),Kh}function tp(){return Kh=Yh<Hh?Fh(Zh,Yh++):0,Vh++,10===Kh&&(Vh=1,qh++),Kh}function np(){return Fh(Zh,Yh)}function rp(){return Yh}function op(e,t){return Uh(Zh,e,t)}function sp(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 ap(e){return Rh(op(Yh-1,up(91===e?e+2:40===e?e+1:e)))}function ip(e){for(;(Kh=np())&&Kh<33;)tp();return sp(e)>2||sp(Kh)>3?"":" "}function cp(e,t){for(;--t&&tp()&&!(Kh<48||Kh>102||Kh>57&&Kh<65||Kh>70&&Kh<97););return op(e,rp()+(t<6&&32==np()&&32==tp()))}function up(e){for(;tp();)switch(Kh){case e:return Yh;case 34:case 39:34!==e&&39!==e&&up(Kh);break;case 40:41===e&&up(e);break;case 92:tp()}return Yh}function lp(e,t){for(;tp()&&e+Kh!==57&&(e+Kh!==84||47!==np()););return"/*"+op(t,Yh-1)+"*"+Oh(47===e?e:tp())}function dp(e){for(;!sp(np());)tp();return op(e,Yh)}function fp(e){return function(e){return Zh="",e}(hp("",null,null,null,[""],e=function(e){return qh=Vh=1,Hh=jh(Zh=e),Yh=0,[]}(e),0,[0],e))}function hp(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=tp()){case 40:if(108!=p&&58==Fh(P,d-1)){-1!=Lh(P+=Mh(ap(y),"&","&\f"),"&\f",$h(u?i[u-1]:0))&&(b=-1);break}case 34:case 39:case 91:P+=ap(y);break;case 9:case 10:case 13:case 32:P+=ip(p);break;case 92:P+=cp(rp()-1,7);continue;case 47:switch(np()){case 42:case 47:Gh(mp(lp(tp(),rp()),t,n,c),c);break;default:P+="/"}break;case 123*m:i[u++]=jh(P)*b;case 125*m:case 59:case 0:switch(y){case 0:case 125:g=0;case 59+l:-1==b&&(P=Mh(P,/\f/g,"")),h>0&&jh(P)-d&&Gh(h>32?gp(P+";",r,n,d-1,c):gp(Mh(P," ","")+";",r,n,d-2,c),c);break;case 59:P+=";";default:if(Gh(E=pp(P,t,n,u,l,o,i,w,v=[],x=[],d,s),s),123===y)if(0===l)hp(P,t,E,E,v,s,d,i,x);else switch(99===f&&110===Fh(P,3)?100:f){case 100:case 108:case 109:case 115:hp(e,E,E,r&&Gh(pp(e,E,E,0,0,o,i,w,o,v=[],d,x),x),o,x,d,i,r?v:x);break;default:hp(P,E,E,E,[""],x,0,i,x)}}u=l=h=0,m=b=1,w=P="",d=a;break;case 58:d=1+jh(P),h=p;default:if(m<1)if(123==y)--m;else if(125==y&&0==m++&&125==ep())continue;switch(P+=Oh(y),y*m){case 38:b=l>0?1:(P+="\f",-1);break;case 44:i[u++]=(jh(P)-1)*b,b=1;break;case 64:45===np()&&(P+=ap(tp())),f=np(),l=d=jh(w=P+=dp(rp())),y++;break;case 45:45===p&&2==jh(P)&&(m=0)}}return s}function pp(e,t,n,r,o,s,a,i,c,u,l,d){for(var f=o-1,h=0===o?s:[""],p=Dh(h),m=0,g=0,b=0;m<r;++m)for(var y=0,w=Uh(e,f+1,f=$h(g=a[m])),v=e;y<p;++y)(v=Rh(g>0?h[y]+" "+w:Mh(w,/&\f/g,h[y])))&&(c[b++]=v);return Jh(e,t,n,0===o?Th:i,c,u,l,d)}function mp(e,t,n,r){return Jh(e,t,n,Nh,Oh(Kh),Uh(e,2,-2),0,r)}function gp(e,t,n,r,o){return Jh(e,t,n,Bh,Uh(e,0,r),Uh(e,r+1,-1),r,o)}function bp(e,t,n){switch(function(e,t){return 45^Fh(e,0)?(((t<<2^Fh(e,0))<<2^Fh(e,1))<<2^Fh(e,2))<<2^Fh(e,3):0}(e,t)){case 5103:return Sh+"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 Sh+e+e;case 4789:return Ih+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Sh+e+Ih+e+Ah+e+e;case 5936:switch(Fh(e,t+11)){case 114:return Sh+e+Ah+Mh(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Sh+e+Ah+Mh(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Sh+e+Ah+Mh(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return Sh+e+Ah+e+e;case 6165:return Sh+e+Ah+"flex-"+e+e;case 5187:return Sh+e+Mh(e,/(\w+).+(:[^]+)/,Sh+"box-$1$2"+Ah+"flex-$1$2")+e;case 5443:return Sh+e+Ah+"flex-item-"+Mh(e,/flex-|-self/g,"")+(zh(e,/flex-|baseline/)?"":Ah+"grid-row-"+Mh(e,/flex-|-self/g,""))+e;case 4675:return Sh+e+Ah+"flex-line-pack"+Mh(e,/align-content|flex-|-self/g,"")+e;case 5548:return Sh+e+Ah+Mh(e,"shrink","negative")+e;case 5292:return Sh+e+Ah+Mh(e,"basis","preferred-size")+e;case 6060:return Sh+"box-"+Mh(e,"-grow","")+Sh+e+Ah+Mh(e,"grow","positive")+e;case 4554:return Sh+Mh(e,/([^-])(transform)/g,"$1"+Sh+"$2")+e;case 6187:return Mh(Mh(Mh(e,/(zoom-|grab)/,Sh+"$1"),/(image-set)/,Sh+"$1"),e,"")+e;case 5495:case 3959:return Mh(e,/(image-set\([^]*)/,Sh+"$1$`$1");case 4968:return Mh(Mh(e,/(.+:)(flex-)?(.*)/,Sh+"box-pack:$3"+Ah+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Sh+e+e;case 4200:if(!zh(e,/flex-|baseline/))return Ah+"grid-column-align"+Uh(e,t)+e;break;case 2592:case 3360:return Ah+Mh(e,"template-","")+e;case 4384:case 3616:return n&&n.some(function(e,n){return t=n,zh(e.props,/grid-\w+-end/)})?~Lh(e+(n=n[t].value),"span",0)?e:Ah+Mh(e,"-start","")+e+Ah+"grid-row-span:"+(~Lh(n,"span",0)?zh(n,/\d+/):+zh(n,/\d+/)-+zh(e,/\d+/))+";":Ah+Mh(e,"-start","")+e;case 4896:case 4128:return n&&n.some(function(e){return zh(e.props,/grid-\w+-start/)})?e:Ah+Mh(Mh(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return Mh(e,/(.+)-inline(.+)/,Sh+"$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(jh(e)-1-t>6)switch(Fh(e,t+1)){case 109:if(45!==Fh(e,t+4))break;case 102:return Mh(e,/(.+:)(.+)-([^]+)/,"$1"+Sh+"$2-$3$1"+Ih+(108==Fh(e,t+3)?"$3":"$2-$3"))+e;case 115:return~Lh(e,"stretch",0)?bp(Mh(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return Mh(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(t,n,r,o,s,a,i){return Ah+n+":"+r+i+(o?Ah+n+"-span:"+(s?a:+a-+r)+i:"")+e});case 4949:if(121===Fh(e,t+6))return Mh(e,":",":"+Sh)+e;break;case 6444:switch(Fh(e,45===Fh(e,14)?18:11)){case 120:return Mh(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Sh+(45===Fh(e,14)?"inline-":"")+"box$3$1"+Sh+"$2$3$1"+Ah+"$2box$3")+e;case 100:return Mh(e,":",":"+Ah)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Mh(e,"scroll-","scroll-snap-")+e}return e}function yp(e,t){for(var n="",r=0;r<e.length;r++)n+=t(e[r],r,e,t)||"";return n}function wp(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case Bh:return e.return=e.return||e.value;case Nh:return"";case Ch:return e.return=e.value+"{"+yp(e.children,r)+"}";case Th:if(!jh(e.value=e.props.join(",")))return""}return jh(n=yp(e.children,r))?e.return=e.value+"{"+n+"}":""}function vp(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case Bh:return void(e.return=bp(e.value,e.length,n));case Ch:return yp([Qh(e,{value:Mh(e.value,"@","@"+Sh)})],r);case Th:if(e.length)return function(e,t){return e.map(t).join("")}(n=e.props,function(t){switch(zh(t,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Xh(Qh(e,{props:[Mh(t,/:(read-\w+)/,":-moz-$1")]})),Xh(Qh(e,{props:[t]})),_h(e,{props:Wh(n,r)});break;case"::placeholder":Xh(Qh(e,{props:[Mh(t,/:(plac\w+)/,":"+Sh+"input-$1")]})),Xh(Qh(e,{props:[Mh(t,/:(plac\w+)/,":-moz-$1")]})),Xh(Qh(e,{props:[Mh(t,/:(plac\w+)/,Ah+"input-$1")]})),Xh(Qh(e,{props:[t]})),_h(e,{props:Wh(n,r)})}return""})}}var xp={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},Ep="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Pp="active",kp="data-styled-version",Ap="6.1.19",Ip="/*!sc*/\n",Sp="undefined"!=typeof window&&"undefined"!=typeof document,Np=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),Tp=/invalid hook call/i,Bp=new Set,Cp=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];Tp.test(e)?(a=!1,Bp.delete(r)):s.apply(void 0,xh([e],t,!1))},o.useRef(),a&&!Bp.has(r)&&(console.warn(r),Bp.add(r))}catch(e){Tp.test(e.message)&&Bp.delete(r)}finally{console.error=s}}},$p=Object.freeze([]),Op=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"]),Rp=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,zp=/(^-|-$)/g;function Mp(e){return e.replace(Rp,"-").replace(zp,"")}var Lp=/(a)(d)/gi,Fp=function(e){return String.fromCharCode(e+(e>25?39:97))};function Up(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=Fp(t%52)+n;return(Fp(t%52)+n).replace(Lp,"$1-$2")}var jp,Dp=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},Gp=function(e){return Dp(5381,e)};function Wp(e){return Up(Gp(e)>>>0)}function qp(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function Vp(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var Hp="function"==typeof Symbol&&Symbol.for,Yp=Hp?Symbol.for("react.memo"):60115,Kp=Hp?Symbol.for("react.forward_ref"):60112,Zp={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Jp={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Qp={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Xp=((jp={})[Kp]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},jp[Yp]=Qp,jp);function em(e){return("type"in(t=e)&&t.type.$$typeof)===Yp?Qp:"$$typeof"in e?Xp[e.$$typeof]:Zp;var t}var tm=Object.defineProperty,nm=Object.getOwnPropertyNames,rm=Object.getOwnPropertySymbols,om=Object.getOwnPropertyDescriptor,sm=Object.getPrototypeOf,am=Object.prototype;function im(e,t,n){if("string"!=typeof t){if(am){var r=sm(t);r&&r!==am&&im(e,r,n)}var o=nm(t);rm&&(o=o.concat(rm(t)));for(var s=em(e),a=em(t),i=0;i<o.length;++i){var c=o[i];if(!(c in Jp||n&&n[c]||a&&c in a||s&&c in s)){var u=om(t,c);try{tm(e,c,u)}catch(e){}}}}return e}function cm(e){return"function"==typeof e}function um(e){return"object"==typeof e&&"styledComponentId"in e}function lm(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function dm(e,t){if(0===e.length)return"";for(var n=e[0],r=1;r<e.length;r++)n+=e[r];return n}function fm(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function hm(e,t,n){if(void 0===n&&(n=!1),!n&&!fm(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var r=0;r<t.length;r++)e[r]=hm(e[r],t[r]);else if(fm(t))for(var r in t)e[r]=hm(e[r],t[r]);return e}function pm(e,t){Object.defineProperty(e,"toString",{value:t})}var mm="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 gm(){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 bm(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(gm.apply(void 0,xh([mm[e]],t,!1)).trim())}var ym=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 bm(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(Ip);return t},e}(),wm=1<<30,vm=new Map,xm=new Map,Em=1,Pm=function(e){if(vm.has(e))return vm.get(e);for(;xm.has(Em);)Em++;var t=Em++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>wm))throw bm(16,"".concat(t));return vm.set(e,t),xm.set(t,e),t},km=function(e,t){Em=t+1,vm.set(e,t),xm.set(t,e)},Am="style[".concat(Ep,"][").concat(kp,'="').concat(Ap,'"]'),Im=new RegExp("^".concat(Ep,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Sm=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)},Nm=function(e,t){for(var n,r=(null!==(n=t.textContent)&&void 0!==n?n:"").split(Ip),o=[],s=0,a=r.length;s<a;s++){var i=r[s].trim();if(i){var c=i.match(Im);if(c){var u=0|parseInt(c[1],10),l=c[2];0!==u&&(km(l,u),Sm(e,l,c[3]),e.getTag().insertRules(u,o)),o.length=0}else o.push(i)}}},Tm=function(e){for(var t=document.querySelectorAll(Am),n=0,r=t.length;n<r;n++){var o=t[n];o&&o.getAttribute(Ep)!==Pp&&(Nm(e,o),o.parentNode&&o.parentNode.removeChild(o))}};var Bm=function(e){var t=document.head,n=e||t,r=document.createElement("style"),o=function(e){var t=Array.from(e.querySelectorAll("style[".concat(Ep,"]")));return t[t.length-1]}(n),s=void 0!==o?o.nextSibling:null;r.setAttribute(Ep,Pp),r.setAttribute(kp,Ap);var a="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null;return a&&r.setAttribute("nonce",a),n.insertBefore(r,s),r},Cm=function(){function e(e){this.element=Bm(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 bm(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}(),$m=function(){function e(e){this.element=Bm(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}(),Om=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=Sp,Rm={isServer:!Sp,useCSSOMInjection:!Np},zm=function(){function e(e,t,n){void 0===e&&(e=Op),void 0===t&&(t={});var r=this;this.options=vh(vh({},Rm),e),this.gs=t,this.names=new Map(n),this.server=!!e.isServer,!this.server&&Sp&&_m&&(_m=!1,Tm(this)),pm(this,function(){return function(e){for(var t=e.getTag(),n=t.length,r="",o=function(n){var o=function(e){return xm.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(Ep,".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(Ip)},s=0;s<n;s++)o(s);return r}(r)})}return e.registerId=function(e){return Pm(e)},e.prototype.rehydrate=function(){!this.server&&Sp&&Tm(this)},e.prototype.reconstructWithOptions=function(t,n){return void 0===n&&(n=!0),new e(vh(vh({},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 Om(n):t?new Cm(n):new $m(n)}(this.options),new ym(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(Pm(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(Pm(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(Pm(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e}(),Mm=/&/g,Lm=/^\s*\/\/.*$/gm;function Fm(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=Fm(e.children,t)),e})}var Um=new zm,jm=function(){var e,t,n,r=Op,o=r.options,s=void 0===o?Op:o,a=r.plugins,i=void 0===a?$p: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===Th&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(Mm,t).replace(n,c))}),s.prefix&&u.push(vp),u.push(wp);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(Lm,""),l=fp(a||o?"".concat(a," ").concat(o," { ").concat(c," }"):c);s.namespace&&(l=Fm(l,s.namespace));var d,f=[];return yp(l,function(e){var t=Dh(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||bm(15),Dp(e,t.name)},5381).toString():"",l}(),Dm=b.default.createContext({shouldForwardProp:void 0,styleSheet:Um,stylis:jm});function Gm(){return o.useContext(Dm)}Dm.Consumer,b.default.createContext(void 0);var Wm=function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=jm);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,pm(this,function(){throw bm(12,String(n.name))})}return e.prototype.getName=function(e){return void 0===e&&(e=jm),this.name+e.hash},e}(),qm=function(e){return e>="A"&&e<="Z"};function Vm(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(1===n&&"-"===r&&"-"===e[0])return e;qm(r)?t+="-"+r.toLowerCase():t+=r}return t.startsWith("ms-")?"-"+t:t}var Hm=function(e){return null==e||!1===e||""===e},Ym=function(e){var t,n,r=[];for(var o in e){var s=e[o];e.hasOwnProperty(o)&&!Hm(s)&&(Array.isArray(s)&&s.isCss||cm(s)?r.push("".concat(Vm(o),":"),s,";"):fm(s)?r.push.apply(r,xh(xh(["".concat(o," {")],Ym(s),!1),["}"],!1)):r.push("".concat(Vm(o),": ").concat((t=o,null==(n=s)||"boolean"==typeof n||""===n?"":"number"!=typeof n||0===n||t in xp||t.startsWith("--")?String(n).trim():"".concat(n,"px")),";")))}return r};function Km(e,t,n,r){if(Hm(e))return[];if(um(e))return[".".concat(e.styledComponentId)];if(cm(e)){if(!cm(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 Wm||fm(o)||null===o||console.error("".concat(qp(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.")),Km(o,t,n,r)}var s;return e instanceof Wm?n?(e.inject(n,r),[e.getName(r)]):[e]:fm(e)?Ym(e):Array.isArray(e)?Array.prototype.concat.apply($p,e.map(function(e){return Km(e,t,n,r)})):[e.toString()]}var Zm=Gp(Ap),Jm=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(cm(n)&&!um(n))return!1}return!0}(e),this.componentId=t,this.baseHash=Dp(Zm,t),this.baseStyle=n,zm.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=lm(r,this.staticRulesId);else{var o=dm(Km(this.rules,e,t,n)),s=Up(Dp(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=lm(r,s),this.staticRulesId=s}else{for(var i=Dp(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=Dp(i,l));else if(l){var d=dm(Km(l,e,t,n));i=Dp(i,d+u),c+=d}}if(c){var f=Up(i>>>0);t.hasNameForId(this.componentId,f)||t.insertRules(this.componentId,f,n(c,".".concat(f),void 0,this.componentId)),r=lm(r,f)}}return r},e}(),Qm=b.default.createContext(void 0);Qm.Consumer;var Xm={},eg=new Set;function tg(e,t,n){var r=um(e),s=e,a=!Vp(e),i=t.attrs,c=void 0===i?$p:i,u=t.componentId,l=void 0===u?function(e,t){var n="string"!=typeof e?"sc":Mp(e);Xm[n]=(Xm[n]||0)+1;var r="".concat(n,"-").concat(Wp(Ap+n+Xm[n]));return t?"".concat(t,"-").concat(r):r}(t.displayName,t.parentComponentId):u,d=t.displayName,f=void 0===d?function(e){return Vp(e)?"styled.".concat(e):"Styled(".concat(qp(e),")")}(e):d,h=t.displayName&&t.componentId?"".concat(Mp(t.displayName),"-").concat(t.componentId):t.componentId||l,p=r&&s.attrs?s.attrs.concat(c).filter(Boolean):c,m=t.shouldForwardProp;if(r&&s.shouldForwardProp){var g=s.shouldForwardProp;if(t.shouldForwardProp){var y=t.shouldForwardProp;m=function(e,t){return g(e,t)&&y(e,t)}}else m=g}var w=new Jm(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=b.default.useContext(Qm),d=Gm(),f=e.shouldForwardProp||d.shouldForwardProp;"production"!==process.env.NODE_ENV&&o.useDebugValue(c);var h=function(e,t,n){return void 0===n&&(n=Op),e.theme!==n.theme&&e.theme||t||n.theme}(t,l,a)||Op,p=function(e,t,n){for(var r,o=vh(vh({},t),{className:void 0,theme:n}),s=0;s<e.length;s+=1){var a=cm(r=e[s])?r(o):r;for(var i in a)o[i]="className"===i?lm(o[i],a[i]):"style"===i?vh(vh({},o[i]),a[i]):a[i]}return t.className&&(o.className=lm(o.className,t.className)),o}(r,t,h),m=p.as||u,g={};for(var y in p)void 0===p[y]||"$"===y[0]||"as"===y||"theme"===y&&p.theme===h||("forwardedAs"===y?g.as=p.forwardedAs:f&&!f(y,m)||(g[y]=p[y],f||"development"!==process.env.NODE_ENV||kh(y)||eg.has(y)||!_p.has(m)||(eg.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=Gm(),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=lm(i,c);return w&&(v+=" "+w),p.className&&(v+=" "+p.className),g[Vp(m)&&!_p.has(m)?"class":"className"]=v,n&&(g.ref=n),o.createElement(m,g)}(x,e,t)}v.displayName=f;var x=b.default.forwardRef(v);return x.attrs=p,x.componentStyle=w,x.displayName=f,x.shouldForwardProp=m,x.foldedComponentIds=r?lm(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++)hm(e,o[r],!0);return e}({},s.defaultProps,e):e}}),"production"!==process.env.NODE_ENV&&(Cp(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)),pm(x,function(){return".".concat(x.styledComponentId)}),a&&im(x,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),x}function ng(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 rg=function(e){return Object.assign(e,{isCss:!0})};function og(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(cm(e)||fm(e))return rg(Km(ng($p,xh([e],t,!0))));var r=e;return 0===t.length&&1===r.length&&"string"==typeof r[0]?Km(r):rg(Km(ng(r,t)))}function sg(e,t,n){if(void 0===n&&(n=Op),!t)throw bm(1,t);var r=function(r){for(var o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];return e(t,n,og.apply(void 0,xh([r],o,!1)))};return r.attrs=function(r){return sg(e,t,vh(vh({},n),{attrs:Array.prototype.concat(n.attrs,r).filter(Boolean)}))},r.withConfig=function(r){return sg(e,t,vh(vh({},n),r))},r}var ag=function(e){return sg(tg,e)},ig=ag;_p.forEach(function(e){ig[e]=ag(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 cg="__sc-".concat(Ep,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[cg]||(window[cg]=0),1===window[cg]&&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[cg]+=1);const ug={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"}},lg=(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=dm(og.apply(void 0,xh([e],t,!1))),o=Wp(r);return new Wm(o,r)})`
13
13
  from {
14
14
  transform: rotate(0deg);
15
15
  }
16
16
  to {
17
17
  transform: rotate(360deg);
18
18
  }
19
- `,lg=ag.div`
19
+ `,dg=ig.div`
20
20
  position: fixed;
21
21
  inset: 0;
22
- background-color: ${cg.colors.background.overlay};
22
+ background-color: ${ug.colors.background.overlay};
23
23
  display: flex;
24
24
  align-items: center;
25
25
  justify-content: center;
26
26
  z-index: 50;
27
- `,dg=ag.div`
28
- background-color: ${cg.colors.background.main};
29
- border-radius: ${cg.borderRadius.md};
30
- box-shadow: ${cg.shadows.xl};
31
- padding: ${cg.spacing.xl};
27
+ `,fg=ig.div`
28
+ background-color: ${ug.colors.background.main};
29
+ border-radius: ${ug.borderRadius.md};
30
+ box-shadow: ${ug.shadows.xl};
31
+ padding: ${ug.spacing.xl};
32
32
  width: 100%;
33
33
  max-width: 28rem;
34
- `,fg=ag.div`
34
+ `,hg=ig.div`
35
35
  display: flex;
36
36
  justify-content: space-between;
37
37
  align-items: center;
38
- margin-bottom: ${cg.spacing.lg};
39
- `,hg=ag.h2`
40
- font-size: ${cg.typography.fontSizes["2xl"]};
41
- font-weight: ${cg.typography.fontWeights.bold};
42
- color: ${cg.colors.text.primary};
38
+ margin-bottom: ${ug.spacing.lg};
39
+ `,pg=ig.h2`
40
+ font-size: ${ug.typography.fontSizes["2xl"]};
41
+ font-weight: ${ug.typography.fontWeights.bold};
42
+ color: ${ug.colors.text.primary};
43
43
  text-transform: uppercase;
44
44
  letter-spacing: 1px;
45
45
  margin: 0;
46
- `,pg=ag.button`
46
+ `,mg=ig.button`
47
47
  background: none;
48
48
  border: none;
49
- color: ${cg.colors.text.tertiary};
49
+ color: ${ug.colors.text.tertiary};
50
50
  cursor: pointer;
51
51
 
52
52
  &:hover {
53
- color: ${cg.colors.text.primary};
53
+ color: ${ug.colors.text.primary};
54
54
  }
55
- `,mg=ag.svg`
55
+ `,gg=ig.svg`
56
56
  width: 1.5rem;
57
57
  height: 1.5rem;
58
- `,gg=ag.div`
58
+ `,bg=ig.div`
59
59
  display: flex;
60
60
  flex-direction: column;
61
61
  align-items: center;
62
62
  justify-content: center;
63
- gap: ${cg.spacing.lg};
64
- padding: ${cg.spacing.xl} 0;
65
- `,bg=ag.div`
66
- animation: ${ug} 1s linear infinite;
63
+ gap: ${ug.spacing.lg};
64
+ padding: ${ug.spacing.xl} 0;
65
+ `,yg=ig.div`
66
+ animation: ${lg} 1s linear infinite;
67
67
  display: flex;
68
68
  align-items: center;
69
69
  justify-content: center;
@@ -72,106 +72,106 @@ const ql=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
72
72
  width: 2rem;
73
73
  height: 2rem;
74
74
  }
75
- `,yg=ag.p`
76
- font-size: ${cg.typography.fontSizes.md};
77
- color: ${cg.colors.text.secondary};
75
+ `,wg=ig.p`
76
+ font-size: ${ug.typography.fontSizes.md};
77
+ color: ${ug.colors.text.secondary};
78
78
  text-align: center;
79
- `,wg=ag.div`
79
+ `,vg=ig.div`
80
80
  display: flex;
81
81
  flex-direction: column;
82
- gap: ${cg.spacing.md};
83
- `,vg=ag.input.attrs({className:"superstack-wallet-input"})`
82
+ gap: ${ug.spacing.md};
83
+ `,xg=ig.input.attrs({className:"superstack-wallet-input"})`
84
84
  width: 100%;
85
- padding: ${cg.spacing.md};
86
- border: 1px solid ${cg.colors.border.light};
87
- border-radius: ${cg.borderRadius.sm};
88
- font-size: ${cg.typography.fontSizes.md};
89
- font-family: ${cg.typography.fontFamily};
90
- transition: border-color ${cg.transitions.normal};
91
- color: ${cg.colors.text.primary};
92
- background-color: ${cg.colors.background.main};
93
- margin-bottom: ${cg.spacing.md};
85
+ padding: ${ug.spacing.md};
86
+ border: 1px solid ${ug.colors.border.light};
87
+ border-radius: ${ug.borderRadius.sm};
88
+ font-size: ${ug.typography.fontSizes.md};
89
+ font-family: ${ug.typography.fontFamily};
90
+ transition: border-color ${ug.transitions.normal};
91
+ color: ${ug.colors.text.primary};
92
+ background-color: ${ug.colors.background.main};
93
+ margin-bottom: ${ug.spacing.md};
94
94
 
95
95
  &:focus {
96
96
  outline: none;
97
- border-color: ${cg.colors.border.dark};
97
+ border-color: ${ug.colors.border.dark};
98
98
  }
99
99
 
100
100
  &:disabled {
101
- background-color: ${cg.colors.background.secondary};
101
+ background-color: ${ug.colors.background.secondary};
102
102
  cursor: not-allowed;
103
103
  }
104
104
 
105
105
  &::placeholder {
106
- color: ${cg.colors.text.tertiary};
106
+ color: ${ug.colors.text.tertiary};
107
107
  opacity: 0.8;
108
108
  }
109
- `,xg=ag.button`
109
+ `,Eg=ig.button`
110
110
  width: 100%;
111
- padding: ${cg.spacing.md};
112
- background-color: ${cg.colors.button.primary.background};
113
- color: ${cg.colors.button.primary.text};
114
- border-radius: ${cg.borderRadius.sm};
115
- font-weight: ${cg.typography.fontWeights.medium};
111
+ padding: ${ug.spacing.md};
112
+ background-color: ${ug.colors.button.primary.background};
113
+ color: ${ug.colors.button.primary.text};
114
+ border-radius: ${ug.borderRadius.sm};
115
+ font-weight: ${ug.typography.fontWeights.medium};
116
116
  text-transform: uppercase;
117
117
  letter-spacing: 1px;
118
- transition: background-color ${cg.transitions.normal};
119
- font-size: ${cg.typography.fontSizes.md};
118
+ transition: background-color ${ug.transitions.normal};
119
+ font-size: ${ug.typography.fontSizes.md};
120
120
  border: none;
121
121
  cursor: pointer;
122
122
 
123
123
  &:hover {
124
- background-color: ${cg.colors.button.primary.hover};
124
+ background-color: ${ug.colors.button.primary.hover};
125
125
  }
126
126
 
127
127
  &:disabled {
128
- background-color: ${cg.colors.button.primary.disabled};
128
+ background-color: ${ug.colors.button.primary.disabled};
129
129
  cursor: not-allowed;
130
130
  }
131
- `,Eg=ag.div`
131
+ `,Pg=ig.div`
132
132
  display: flex;
133
133
  align-items: center;
134
- margin: ${cg.spacing.lg} 0;
135
- `,Pg=ag.div`
134
+ margin: ${ug.spacing.lg} 0;
135
+ `,kg=ig.div`
136
136
  flex-grow: 1;
137
137
  height: 1px;
138
- background-color: ${cg.colors.border.light};
139
- `,kg=ag.span`
140
- padding: 0 ${cg.spacing.md};
141
- font-size: ${cg.typography.fontSizes.sm};
142
- color: ${cg.colors.text.tertiary};
138
+ background-color: ${ug.colors.border.light};
139
+ `,Ag=ig.span`
140
+ padding: 0 ${ug.spacing.md};
141
+ font-size: ${ug.typography.fontSizes.sm};
142
+ color: ${ug.colors.text.tertiary};
143
143
  text-transform: uppercase;
144
144
  letter-spacing: 0.5px;
145
- `;ag.div`
145
+ `;ig.div`
146
146
  height: 1px;
147
- background-color: ${cg.colors.border.light};
147
+ background-color: ${ug.colors.border.light};
148
148
  width: 100%;
149
- margin: ${cg.spacing.lg} 0;
150
- `;const Ag=ag.div`
149
+ margin: ${ug.spacing.lg} 0;
150
+ `;const Ig=ig.div`
151
151
  display: flex;
152
152
  align-items: center;
153
153
  /* grid-template-columns: repeat(2, 1fr); */
154
- gap: ${cg.spacing.md};
155
- `,Ig=ag.button`
154
+ gap: ${ug.spacing.md};
155
+ `,Sg=ig.button`
156
156
  display: flex;
157
157
  align-items: center;
158
158
  justify-content: center;
159
- padding: ${cg.spacing.md};
160
- border: 1px solid ${cg.colors.border.light};
161
- border-radius: ${cg.borderRadius.sm};
162
- background-color: ${cg.colors.background.main};
163
- transition: background-color ${cg.transitions.normal};
164
- color: ${cg.colors.text.primary};
165
- font-weight: ${cg.typography.fontWeights.medium};
166
- font-size: ${cg.typography.fontSizes.md};
159
+ padding: ${ug.spacing.md};
160
+ border: 1px solid ${ug.colors.border.light};
161
+ border-radius: ${ug.borderRadius.sm};
162
+ background-color: ${ug.colors.background.main};
163
+ transition: background-color ${ug.transitions.normal};
164
+ color: ${ug.colors.text.primary};
165
+ font-weight: ${ug.typography.fontWeights.medium};
166
+ font-size: ${ug.typography.fontSizes.md};
167
167
  min-width: 120px;
168
168
  flex: 1;
169
169
 
170
170
  &:hover {
171
- background-color: ${cg.colors.background.secondary};
171
+ background-color: ${ug.colors.background.secondary};
172
172
  }
173
- `,Sg=ag.div`
174
- margin-right: ${cg.spacing.sm};
173
+ `,Ng=ig.div`
174
+ margin-right: ${ug.spacing.sm};
175
175
  display: flex;
176
176
  align-items: center;
177
177
  justify-content: center;
@@ -181,24 +181,24 @@ const ql=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
181
181
  height: 20px;
182
182
  display: block;
183
183
  }
184
- `,Ng=ag.div`
184
+ `,Tg=ig.div`
185
185
  display: flex;
186
186
  flex-direction: column;
187
- gap: ${cg.spacing.lg};
188
- `,Tg=ag.h3`
189
- font-size: ${cg.typography.fontSizes.xl};
190
- font-weight: ${cg.typography.fontWeights.semibold};
191
- color: ${cg.colors.text.primary};
192
- margin-bottom: ${cg.spacing.sm};
193
- `,Bg=ag.p`
194
- font-size: ${cg.typography.fontSizes.md};
195
- color: ${cg.colors.text.secondary};
196
- margin-bottom: ${cg.spacing.lg};
197
- `,Cg=ag.div`
187
+ gap: ${ug.spacing.lg};
188
+ `,Bg=ig.h3`
189
+ font-size: ${ug.typography.fontSizes.xl};
190
+ font-weight: ${ug.typography.fontWeights.semibold};
191
+ color: ${ug.colors.text.primary};
192
+ margin-bottom: ${ug.spacing.sm};
193
+ `,Cg=ig.p`
194
+ font-size: ${ug.typography.fontSizes.md};
195
+ color: ${ug.colors.text.secondary};
196
+ margin-bottom: ${ug.spacing.lg};
197
+ `,$g=ig.div`
198
198
  display: flex;
199
- gap: ${cg.spacing.sm};
199
+ gap: ${ug.spacing.sm};
200
200
  justify-content: center;
201
- margin-bottom: ${cg.spacing.lg};
201
+ margin-bottom: ${ug.spacing.lg};
202
202
  position: relative;
203
203
 
204
204
  &::after {
@@ -208,30 +208,30 @@ const ql=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
208
208
  left: 0;
209
209
  width: 100%;
210
210
  text-align: center;
211
- font-size: ${cg.typography.fontSizes.xs};
212
- color: ${cg.colors.text.tertiary};
211
+ font-size: ${ug.typography.fontSizes.xs};
212
+ color: ${ug.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
- `,$g=ag.div`
219
+ `,Og=ig.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
- `,Og=ag.input`
226
+ `,_g=ig.input`
227
227
  width: 100%;
228
228
  height: 100%;
229
229
  text-align: center;
230
- font-size: ${cg.typography.fontSizes.xl};
231
- border: 1px solid ${cg.colors.border.light};
232
- border-radius: ${cg.borderRadius.sm};
233
- transition: all ${cg.transitions.normal};
234
- font-family: ${cg.typography.fontFamily};
230
+ font-size: ${ug.typography.fontSizes.xl};
231
+ border: 1px solid ${ug.colors.border.light};
232
+ border-radius: ${ug.borderRadius.sm};
233
+ transition: all ${ug.transitions.normal};
234
+ font-family: ${ug.typography.fontFamily};
235
235
  padding: 0;
236
236
  box-sizing: border-box;
237
237
 
@@ -252,46 +252,46 @@ const ql=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
252
252
  /* Remove default box-shadow on iOS */
253
253
  &:focus {
254
254
  outline: none;
255
- border-color: ${cg.colors.border.dark};
256
- box-shadow: 0 0 0 1px ${cg.colors.border.dark};
255
+ border-color: ${ug.colors.border.dark};
256
+ box-shadow: 0 0 0 1px ${ug.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
- `,_g=ag.button`
263
+ `,Rg=ig.button`
264
264
  background: none;
265
265
  border: none;
266
- color: ${cg.colors.text.secondary};
267
- font-size: ${cg.typography.fontSizes.sm};
266
+ color: ${ug.colors.text.secondary};
267
+ font-size: ${ug.typography.fontSizes.sm};
268
268
  text-align: center;
269
- margin-top: ${cg.spacing.md};
270
- margin-bottom: ${cg.spacing.sm};
271
- padding: ${cg.spacing.sm} ${cg.spacing.md};
269
+ margin-top: ${ug.spacing.md};
270
+ margin-bottom: ${ug.spacing.sm};
271
+ padding: ${ug.spacing.sm} ${ug.spacing.md};
272
272
  text-transform: uppercase;
273
273
  letter-spacing: 0.5px;
274
274
  width: 100%;
275
275
  cursor: pointer;
276
- transition: color ${cg.transitions.normal};
276
+ transition: color ${ug.transitions.normal};
277
277
  display: flex;
278
278
  align-items: center;
279
279
  justify-content: center;
280
280
 
281
281
  &:hover {
282
- color: ${cg.colors.text.primary};
282
+ color: ${ug.colors.text.primary};
283
283
  text-decoration: underline;
284
284
  }
285
285
 
286
286
  &:before {
287
287
  content: "←";
288
- margin-right: ${cg.spacing.sm};
289
- font-size: ${cg.typography.fontSizes.md};
288
+ margin-right: ${ug.spacing.sm};
289
+ font-size: ${ug.typography.fontSizes.md};
290
290
  }
291
- `,Rg=ag.p`
292
- font-size: ${cg.typography.fontSizes.sm};
293
- color: ${cg.colors.text.tertiary};
291
+ `,zg=ig.p`
292
+ font-size: ${ug.typography.fontSizes.sm};
293
+ color: ${ug.colors.text.tertiary};
294
294
  text-align: center;
295
- margin-top: ${cg.spacing.lg};
296
- `;async function zg(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}}function Mg(e){const t=e.toLowerCase(),n=sessionStorage.getItem(`${t}_oauthCodeVerifier`);if(!n)return null;const r=JSON.parse(n);sessionStorage.removeItem(`${t}_oauthCodeVerifier`);return Date.now()-r.timestamp>6e5?null:{codeVerifier:r.code_verifier,codeChallenge:r.code_challenge}}const Lg=()=>{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: ${cg.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: ${cg.typography.fontWeights.semibold};\n line-height: 1.2;\n margin-bottom: ${cg.spacing.md};\n }\n \n .superstack-wallet-container p {\n font-family: 'Montserrat', sans-serif;\n margin-bottom: ${cg.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: ${cg.colors.background.main};\n border-radius: ${cg.borderRadius.md};\n padding: ${cg.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 Fg=Object.freeze({__proto__:null,injectStyles:Lg,theme:cg});const Ug={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 Dg(e,t){switch(t.type){case"SET_CONNECTING_BACKUP":return{...e,isConnecting:t.payload};case"SET_INITIALIZED_BACKUP":return{...e,isInitialized:t.payload};case"SET_SESSION_BACKUP":return{...e,isAuthenticated:!0,session:t.payload,error:null};case"SET_WALLET_INFO_BACKUP":return{...e,walletInfo:t.payload};case"SET_WALLET_BACKUP":return{...e,wallet:t.payload};case"SET_ERROR_BACKUP":return{...e,error:t.payload};case"RESET_BACKUP":return{...Ug,isInitialized:!0};default:return e}}function Gg(){const e=o.useContext(jg);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}function qg({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,g]=o.useState(["","","","","",""]),[b,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=cg.typography.fontSizes.xl)}})},[m,k]),{email:i,setEmail:c,emailSent:h,setEmailSent:p,sendingCode:b,setVerificationCode:g,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,g(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)}),g(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)}),g(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 zg(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?${y.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?${y.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 Wg=({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:m,verifyingCode:g,verificationCode:y,connectingPhantom:w,inputRefs:v,handleCodeChange:x,handleKeyDown:E,handleContainerPaste:P,handleSendVerificationCode:k,handleCodeSubmit:A,onOauthLogin:I,handlePhantomLogin:S}=qg({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o});return t?b.default.createElement(lg,null,b.default.createElement(dg,null,b.default.createElement(fg,null,b.default.createElement(hg,null,"Connect Wallet"),b.default.createElement(pg,{onClick:n},b.default.createElement(mg,{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},b.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))),o?b.default.createElement(gg,null,b.default.createElement(bg,null,b.default.createElement(s.Loader2,{size:24})),b.default.createElement(yg,null,"Loading...")):b.default.createElement(b.default.Fragment,null,h?b.default.createElement(Ng,null,b.default.createElement("div",null,b.default.createElement(Tg,null,"Enter Verification Code"),b.default.createElement(Bg,null,"We sent a verification code to ",d)),b.default.createElement(Cg,{onPaste:P},y.map((e,t)=>b.default.createElement($g,{key:t},b.default.createElement(Og,{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))}})))),b.default.createElement(xg,{onClick:()=>A(),disabled:6!==y.join("").length||g},g?"Verifying...":"Verify Code"),b.default.createElement(_g,{onClick:()=>m(!1)},"Back to Email")):b.default.createElement(wg,null,a&&b.default.createElement(wg,null,b.default.createElement(vg,{type:"email",value:d,onChange:e=>f(e.target.value),placeholder:"Enter your email",disabled:p}),b.default.createElement(xg,{onClick:()=>k(),disabled:!d||p},p?"Sending...":"Send Verification Code")),(c||u||l)&&a&&b.default.createElement(Eg,null,b.default.createElement(Pg,null),b.default.createElement(kg,null,"Or continue with"),b.default.createElement(Pg,null)),(c||u||l)&&b.default.createElement(b.default.Fragment,null,b.default.createElement(Ag,null,c&&b.default.createElement(Ig,{onClick:()=>I("google")},b.default.createElement(Sg,null,b.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/google/google-original.svg",alt:"Google",width:20,height:20})),"Google"),u&&b.default.createElement(Ig,{onClick:()=>I("twitter")},b.default.createElement(Sg,null,b.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/twitter/twitter-original.svg",alt:"Twitter",width:20,height:20})),"X")),l&&b.default.createElement(Ig,{onClick:S,disabled:w},b.default.createElement(Sg,null,b.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&&b.default.createElement("div",{style:{textAlign:"center",padding:"20px",color:"#666"}},"No login methods are currently enabled."))),b.default.createElement(Rg,null,"By connecting your wallet, you agree to our Terms of Service and Privacy Policy"))):null};class Vg{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(b.default.createElement(Wg,{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(e){this.root&&(this.root.unmount(),this.container&&this.container.parentNode&&(document.body.removeChild(this.container),this.container=null))}}const Hg={isAuthenticated:!1,isConnecting:!1,isInitialized:!1,walletInfo:null,wallet:null,session:null,error:null,enableEmail:!0,enablePhone:!1,enableGoogle:!0,enableTwitter:!1,enablePhantom:!0},Yg=o.createContext({});function Kg(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{...Hg,isInitialized:!0};default:return e}}function Zg(){const e=o.useContext(Yg);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}"undefined"!=typeof window&&Promise.resolve().then(function(){return Fg}).then(({injectStyles:e})=>{e()}),exports.ACCESS_TOKEN_KEY=P,exports.BACKUP_WALLET_TYPE_KEY=E,exports.STORAGE_STATE_KEY=v,exports.SWITCHED_ACCOUNT_ADDRESS=k,exports.Storage=A,exports.WALLET_TYPE_KEY=x,exports.WalletClient=yh,exports.WalletProvider=function({children:e,config:t}){var n,r,s,a,i,c;const u=o.useRef(null);u.current||(u.current=new yh(t));const l=u.current,d=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[f,h]=o.useReducer(Kg,{...Hg,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,m=o.useRef(!1),g=o.useCallback(()=>(d.current||"undefined"==typeof window||(d.current=new Vg),d.current),[]);o.useEffect(()=>{t.modalManager&&(d.current=t.modalManager)},[t.modalManager]),o.useEffect(()=>{!async function(){if(!(p||m.current||f.isInitialized)){m.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=Mg(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"}g().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 g().hideModal()}};return e(),window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}},[]);const y=o.useCallback(async()=>{try{h({type:"SET_CONNECTING",payload:!0});g().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"===A.getWalletType()&&l.getPhantomAdapter()&&(null===(e=l.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{w()}))},[l]);const v={...f,connect:y,disconnect:w};return b.default.createElement(Yg.Provider,{value:v},e)},exports.WalletProviderBackup=function({children:e,config:t}){var n,r,s,a,i,c;const u=o.useRef(null);u.current||(u.current=new yh(t));const l=u.current,d=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[f,h]=o.useReducer(Dg,{...Ug,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,m=o.useRef(!1),g=o.useCallback(()=>(d.current||"undefined"==typeof window||(d.current=new Vg),d.current),[]);o.useEffect(()=>{t.modalManager&&(d.current=t.modalManager)},[t.modalManager]),o.useEffect(()=>{!async function(){if(!(p||m.current||f.isInitialized)){m.current=!0;try{const e=await l.reconnect(!0);e&&(h({type:"SET_WALLET_INFO_BACKUP",payload:e}),h({type:"SET_WALLET_BACKUP",payload:l}))}catch(e){console.error("Auto reconnect failed:",e)}finally{h({type:"SET_INITIALIZED_BACKUP",payload:!0})}}}()},[l]),o.useEffect(()=>{const e=async()=>{try{if(v.isConnecting)return;h({type:"SET_CONNECTING_BACKUP",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=Mg(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"}g().showLoginModal({isBackup:!0,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_BACKUP",payload:i}),h({type:"SET_WALLET_BACKUP",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_BACKUP",payload:!1}),await g().hideModal(!0)}};return e(),window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}},[]);const y=o.useCallback(async()=>{try{h({type:"SET_CONNECTING_BACKUP",payload:!0});g().showLoginModal({isBackup:!0,client:l,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom,onClose:()=>{h({type:"SET_CONNECTING_BACKUP",payload:!1})},onLogin:e=>{h({type:"SET_CONNECTING_BACKUP",payload:!1}),h({type:"SET_WALLET_INFO_BACKUP",payload:e}),h({type:"SET_WALLET_BACKUP",payload:l})}})}catch(e){h({type:"SET_ERROR_BACKUP",payload:e instanceof Error?e.message:"Failed to connect"}),h({type:"SET_CONNECTING_BACKUP",payload:!1})}},[l]),w=o.useCallback(async()=>{await l.logout(!0),h({type:"RESET_BACKUP"})},[l]);o.useEffect(()=>{var e;"phantom_backup"===A.getBackupWalletType()&&l.getPhantomAdapter()&&(null===(e=l.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{w()}))},[l]);const v={...f,connect:y,disconnect:w};return b.default.createElement(jg.Provider,{value:v},e)},exports.injectStyles=Lg,exports.isVersionedTransaction=w,exports.theme=cg,exports.useActiveWallet=function(){const{wallet:e}=Zg();return{wallet:e}},exports.useCoinbaseOnramp=function(){const{wallet:e}=Zg(),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 wf({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}=Zg();return{connect:e,disconnect:t,isConnecting:n}},exports.useLoginModal=qg,exports.useWallet=Zg,exports.useWalletBackup=Gg,exports.useWalletBackupStatus=function(){const{error:e,session:t,isInitialized:n,wallet:r}=Gg();return{isAuthenticated:null!==r,authenticated:null!==r,error:e,session:t,isInitialized:n,ready:n}},exports.useWalletStatus=function(){const{error:e,session:t,isInitialized:n,wallet:r}=Zg();return{isAuthenticated:null!==r,authenticated:null!==r,error:e,session:t,isInitialized:n,ready:n}};
295
+ margin-top: ${ug.spacing.lg};
296
+ `;async function Mg(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}}function Lg(e){const t=e.toLowerCase(),n=sessionStorage.getItem(`${t}_oauthCodeVerifier`);if(!n)return null;const r=JSON.parse(n);sessionStorage.removeItem(`${t}_oauthCodeVerifier`);return Date.now()-r.timestamp>6e5?null:{codeVerifier:r.code_verifier,codeChallenge:r.code_challenge}}const Fg=()=>{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: ${ug.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: ${ug.typography.fontWeights.semibold};\n line-height: 1.2;\n margin-bottom: ${ug.spacing.md};\n }\n \n .superstack-wallet-container p {\n font-family: 'Montserrat', sans-serif;\n margin-bottom: ${ug.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: ${ug.colors.background.main};\n border-radius: ${ug.borderRadius.md};\n padding: ${ug.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 Ug=Object.freeze({__proto__:null,injectStyles:Fg,theme:ug});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},Dg=o.createContext({});function Gg(e,t){switch(t.type){case"SET_CONNECTING_BACKUP":return{...e,isConnecting:t.payload};case"SET_INITIALIZED_BACKUP":return{...e,isInitialized:t.payload};case"SET_SESSION_BACKUP":return{...e,isAuthenticated:!0,session:t.payload,error:null};case"SET_WALLET_INFO_BACKUP":return{...e,walletInfo:t.payload};case"SET_WALLET_BACKUP":return{...e,wallet:t.payload};case"SET_ERROR_BACKUP":return{...e,error:t.payload};case"RESET_BACKUP":return{...jg,isInitialized:!0};default:return e}}function Wg(){const e=o.useContext(Dg);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}function qg({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,g]=o.useState(["","","","","",""]),[b,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=ug.typography.fontSizes.xl)}})},[m,k]),{email:i,setEmail:c,emailSent:h,setEmailSent:p,sendingCode:b,setVerificationCode:g,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,g(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)}),g(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)}),g(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 Mg(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?${y.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?${y.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 Vg=({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:m,verifyingCode:g,verificationCode:y,connectingPhantom:w,inputRefs:v,handleCodeChange:x,handleKeyDown:E,handleContainerPaste:P,handleSendVerificationCode:k,handleCodeSubmit:A,onOauthLogin:I,handlePhantomLogin:S}=qg({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o});return t?b.default.createElement(dg,null,b.default.createElement(fg,null,b.default.createElement(hg,null,b.default.createElement(pg,null,"Connect Wallet"),b.default.createElement(mg,{onClick:n},b.default.createElement(gg,{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},b.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))),o?b.default.createElement(bg,null,b.default.createElement(yg,null,b.default.createElement(s.Loader2,{size:24})),b.default.createElement(wg,null,"Loading...")):b.default.createElement(b.default.Fragment,null,h?b.default.createElement(Tg,null,b.default.createElement("div",null,b.default.createElement(Bg,null,"Enter Verification Code"),b.default.createElement(Cg,null,"We sent a verification code to ",d)),b.default.createElement($g,{onPaste:P},y.map((e,t)=>b.default.createElement(Og,{key:t},b.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))}})))),b.default.createElement(Eg,{onClick:()=>A(),disabled:6!==y.join("").length||g},g?"Verifying...":"Verify Code"),b.default.createElement(Rg,{onClick:()=>m(!1)},"Back to Email")):b.default.createElement(vg,null,a&&b.default.createElement(vg,null,b.default.createElement(xg,{type:"email",value:d,onChange:e=>f(e.target.value),placeholder:"Enter your email",disabled:p}),b.default.createElement(Eg,{onClick:()=>k(),disabled:!d||p},p?"Sending...":"Send Verification Code")),(c||u||l)&&a&&b.default.createElement(Pg,null,b.default.createElement(kg,null),b.default.createElement(Ag,null,"Or continue with"),b.default.createElement(kg,null)),(c||u||l)&&b.default.createElement(b.default.Fragment,null,b.default.createElement(Ig,null,c&&b.default.createElement(Sg,{onClick:()=>I("google")},b.default.createElement(Ng,null,b.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/google/google-original.svg",alt:"Google",width:20,height:20})),"Google"),u&&b.default.createElement(Sg,{onClick:()=>I("twitter")},b.default.createElement(Ng,null,b.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/twitter/twitter-original.svg",alt:"Twitter",width:20,height:20})),"X")),l&&b.default.createElement(Sg,{onClick:S,disabled:w},b.default.createElement(Ng,null,b.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&&b.default.createElement("div",{style:{textAlign:"center",padding:"20px",color:"#666"}},"No login methods are currently enabled."))),b.default.createElement(zg,null,"By connecting your wallet, you agree to our Terms of Service and Privacy Policy"))):null};class Hg{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(b.default.createElement(Vg,{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(e){this.root&&(this.root.unmount(),this.container&&this.container.parentNode&&(document.body.removeChild(this.container),this.container=null))}}const Yg={isAuthenticated:!1,isConnecting:!1,isInitialized:!1,walletInfo:null,wallet:null,session:null,error:null,enableEmail:!0,enablePhone:!1,enableGoogle:!0,enableTwitter:!1,enablePhantom:!0},Kg=o.createContext({});function Zg(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{...Yg,isInitialized:!0};default:return e}}function Jg(){const e=o.useContext(Kg);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}"undefined"!=typeof window&&Promise.resolve().then(function(){return Ug}).then(({injectStyles:e})=>{e()}),exports.ACCESS_TOKEN_KEY=P,exports.BACKUP_WALLET_INFO=A,exports.BACKUP_WALLET_TYPE_KEY=E,exports.STORAGE_STATE_KEY=v,exports.SWITCHED_ACCOUNT_ADDRESS=k,exports.Storage=I,exports.WALLET_TYPE_KEY=x,exports.WalletClient=wh,exports.WalletProvider=function({children:e,config:t}){var n,r,s,a,i,c;const u=o.useRef(null);u.current||(u.current=new wh(t));const l=u.current,d=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[f,h]=o.useReducer(Zg,{...Yg,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,m=o.useRef(!1),g=o.useCallback(()=>(d.current||"undefined"==typeof window||(d.current=new Hg),d.current),[]);o.useEffect(()=>{t.modalManager&&(d.current=t.modalManager)},[t.modalManager]),o.useEffect(()=>{!async function(){if(!(p||m.current||f.isInitialized)){m.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=Lg(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"}g().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 g().hideModal()}};return e(),window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}},[]);const y=o.useCallback(async()=>{try{h({type:"SET_CONNECTING",payload:!0});g().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"===I.getWalletType()&&l.getPhantomAdapter()&&(null===(e=l.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{w()}))},[l]);const v={...f,connect:y,disconnect:w};return b.default.createElement(Kg.Provider,{value:v},e)},exports.WalletProviderBackup=function({children:e,config:t}){var n,r,s,a,i,c;const u=o.useRef(null);u.current||(u.current=new wh(t));const l=u.current,d=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[f,h]=o.useReducer(Gg,{...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,m=o.useRef(!1),g=o.useCallback(()=>(d.current||"undefined"==typeof window||(d.current=new Hg),d.current),[]);o.useEffect(()=>{t.modalManager&&(d.current=t.modalManager)},[t.modalManager]),o.useEffect(()=>{!async function(){if(!(p||m.current||f.isInitialized)){m.current=!0;try{const e=await l.reconnect(!0);e&&(h({type:"SET_WALLET_INFO_BACKUP",payload:e}),h({type:"SET_WALLET_BACKUP",payload:l}))}catch(e){console.error("Auto reconnect failed:",e)}finally{h({type:"SET_INITIALIZED_BACKUP",payload:!0})}}}()},[l]),o.useEffect(()=>{const e=async()=>{try{if(v.isConnecting)return;h({type:"SET_CONNECTING_BACKUP",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=Lg(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"}g().showLoginModal({isBackup:!0,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_BACKUP",payload:i}),h({type:"SET_WALLET_BACKUP",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_BACKUP",payload:!1}),await g().hideModal(!0)}};return e(),window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}},[]);const y=o.useCallback(async()=>{try{h({type:"SET_CONNECTING_BACKUP",payload:!0});g().showLoginModal({isBackup:!0,client:l,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom,onClose:()=>{h({type:"SET_CONNECTING_BACKUP",payload:!1})},onLogin:e=>{h({type:"SET_CONNECTING_BACKUP",payload:!1}),h({type:"SET_WALLET_INFO_BACKUP",payload:e}),h({type:"SET_WALLET_BACKUP",payload:l}),I.saveBackupWalletInfo(e)}})}catch(e){h({type:"SET_ERROR_BACKUP",payload:e instanceof Error?e.message:"Failed to connect"}),h({type:"SET_CONNECTING_BACKUP",payload:!1})}},[l]),w=o.useCallback(async()=>{await l.logout(!0),h({type:"RESET_BACKUP"})},[l]);o.useEffect(()=>{var e;"phantom_backup"===I.getBackupWalletType()&&l.getPhantomAdapter()&&(null===(e=l.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{w()}))},[l]);const v={...f,connect:y,disconnect:w};return b.default.createElement(Dg.Provider,{value:v},e)},exports.injectStyles=Fg,exports.isVersionedTransaction=w,exports.theme=ug,exports.useActiveWallet=function(){const{wallet:e}=Jg();return{wallet:e}},exports.useCoinbaseOnramp=function(){const{wallet:e}=Jg(),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 vf({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}=Jg();return{connect:e,disconnect:t,isConnecting:n}},exports.useLoginModal=qg,exports.useWallet=Jg,exports.useWalletBackup=Wg,exports.useWalletBackupStatus=function(){const{error:e,session:t,isInitialized:n,wallet:r}=Wg();return{isAuthenticated:null!==r,authenticated:null!==r,error:e,session:t,isInitialized:n,ready:n}},exports.useWalletStatus=function(){const{error:e,session:t,isInitialized:n,wallet:r}=Jg();return{isAuthenticated:null!==r,authenticated:null!==r,error:e,session:t,isInitialized:n,ready:n}};
297
297
  //# sourceMappingURL=index.cjs.map