superstack-wallet-sdk 0.5.10 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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"),a=require("lucide-react"),s=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 l,u,d,f,h,p,m,g,b,y=i(e),w=i(n),v=i(o),x=c(s);function E(e){return"version"in e}"undefined"!=typeof globalThis&&void 0===globalThis.globalThis&&(globalThis.global=globalThis),exports.Network=void 0,(l=exports.Network||(exports.Network={})).Solana="Solana",l.Ethereum="Ethereum",exports.WalletType=void 0,(u=exports.WalletType||(exports.WalletType={})).Phantom="Phantom",u.Embedded="Embedded",exports.SocialType=void 0,(d=exports.SocialType||(exports.SocialType={})).Google="Google",d.Twitter="Twitter",d.Telegram="Telegram",d.Apple="Apple",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.LighterOrderSide=void 0,(h=exports.LighterOrderSide||(exports.LighterOrderSide={})).Buy="buy",h.Sell="sell",exports.LighterOrderType=void 0,(p=exports.LighterOrderType||(exports.LighterOrderType={})).Limit="limit",p.Market="market",p.StopLoss="stop_loss",p.StopLossLimit="stop_loss_limit",p.TakeProfit="take_profit",p.TakeProfitLimit="take_profit_limit",p.Twap="twap",p.TwapSub="twap_sub",exports.LighterTimeInForce=void 0,(m=exports.LighterTimeInForce||(exports.LighterTimeInForce={})).ImmediateOrCancel="immediate_or_cancel",m.GoodTillTime="good_till_time",m.PostOnly="post_only",exports.LighterMarginMode=void 0,(g=exports.LighterMarginMode||(exports.LighterMarginMode={})).Cross="cross",g.Isolated="isolated",exports.LighterGroupingType=void 0,(b=exports.LighterGroupingType||(exports.LighterGroupingType={})).Default="default",b.OneTriggersTheOther="one_triggers_the_other",b.OneCancelsTheOther="one_cancels_the_other",b.OneTriggersAOneCancelsTheOther="one_triggers_a_one_cancels_the_other";const P="embedded_wallet_state",k="superstack_wallet_type",A="superstack_backup_wallet_type",I="embedded_wallet_access_token",N="switched_account_address",S="backup_wallet_info";class T{static saveState(e,t){const n={accessToken:e,socials:t,lastConnected:Date.now()};localStorage.setItem(P,JSON.stringify(n))}static saveAccessToken(e){localStorage.setItem(I,e)}static saveWalletType(e){localStorage.setItem(k,e)}static saveBackupWalletType(e){localStorage.setItem(A,e)}static saveSwitchedAccountAddress(e){localStorage.setItem(N,e)}static saveBackupWalletInfo(e){localStorage.setItem(S,JSON.stringify(e))}static getWalletType(){return localStorage.getItem(k)}static getBackupWalletType(){return localStorage.getItem(A)}static getState(){try{const e=localStorage.getItem(P);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(P);if(!e)return null;return JSON.parse(e).socials}catch(e){return null}}static getAccessToken(){return localStorage.getItem(I)}static getSwitchedAccountAddress(){return localStorage.getItem(N)}static getBackupWalletInfo(){try{const e=localStorage.getItem(S);return e?JSON.parse(e):null}catch(e){return null}}static clear(){localStorage.removeItem(P),localStorage.removeItem(k),localStorage.removeItem(I),localStorage.removeItem(N),localStorage.removeItem(A)}static clearBackup(){localStorage.removeItem(A),localStorage.removeItem(S)}}function B(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var C={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 a(e,t,r,a,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var i=new o(r,a||e,s),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 s(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,a=r.length,s=new Array(a);o<a;o++)s[o]=r[o].fn;return s},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,a,s){var i=n?n+e:e;if(!this._events[i])return!1;var c,l,u=this._events[i],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,a),!0;case 6:return u.fn.call(u.context,t,r,o,a,s),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var f,h=u.length;for(l=0;l<h;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,o);break;default:if(!c)for(f=1,c=new Array(d-1);f<d;f++)c[f-1]=arguments[f];u[l].fn.apply(u[l].context,c)}}return!0},i.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},i.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},i.prototype.removeListener=function(e,t,r,o){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var i=this._events[a];if(i.fn)i.fn!==t||o&&!i.once||r&&i.context!==r||s(this,a);else{for(var c=0,l=[],u=i.length;c<u;c++)(i[c].fn!==t||o&&!i[c].once||r&&i[c].context!==r)&&l.push(i[c]);l.length?this._events[a]=1===l.length?l[0]:l:s(this,a)}return this},i.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(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}(C);var $,O=B(C.exports);class _ extends Error{constructor(e,t){super(e),this.error=t}}class R extends _{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class z extends _{constructor(){super(...arguments),this.name="WalletConnectionError"}}class M extends _{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class L extends _{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class F extends _{constructor(){super(...arguments),this.name="WalletAccountError"}}class U extends _{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class j extends _{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class D extends _{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class G extends _{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class W extends _{constructor(){super(...arguments),this.name="WalletSignMessageError"}}!function(e){e.Installed="Installed",e.NotDetected="NotDetected",e.Loadable="Loadable",e.Unsupported="Unsupported"}($||($={}));class q extends O{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){const r=this.publicKey;if(!r)throw new j;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}}function V(e){return"version"in e}class H extends q{async sendTransaction(e,t,n={}){let r=!0;try{if(V(e)){if(!this.supportedTransactionVersions)throw new D("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new D(`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 G)throw r=!1,e;throw new D(e?.message,e)}}else try{const{signers:r,...o}=n;e=await this.prepareTransaction(e,t,o),r?.length&&e.partialSign(...r);const a=(e=await this.signTransaction(e)).serialize();return await t.sendRawTransaction(a,o)}catch(e){if(e instanceof G)throw r=!1,e;throw new D(e?.message,e)}}catch(e){throw r&&this.emit("error",e),e}}async signAllTransactions(e){for(const t of e)if(V(t)){if(!this.supportedTransactionVersions)throw new G("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(t.version))throw new G(`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 Y extends H{}class K extends Y{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?$.Unsupported:$.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 M),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 U(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!==$.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=$.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=$.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===$.Installed&&await this.connect()}async connect(){var e;try{if(this.connected||this.connecting)return;if(this.readyState===$.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!==$.Installed)throw new R;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 z(null==e?void 0:e.message,e)}if(!n.publicKey)throw new F;let r;try{r=new t.PublicKey(n.publicKey.toBytes())}catch(e){throw new U(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 L(null==e?void 0:e.message,e))}}this.emit("disconnect")}async sendTransaction(e,t,n={}){try{const r=this._wallet;if(!r)throw new j;try{const{signers:o,...a}=n;V(e)?(null==o?void 0:o.length)&&e.sign(o):(e=await this.prepareTransaction(e,t,a),(null==o?void 0:o.length)&&e.partialSign(...o)),a.preflightCommitment=a.preflightCommitment||t.commitment;const{signature:s}=await r.signAndSendTransaction(e,a);return s}catch(e){if(e instanceof _)throw e;throw new D(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 j;try{return await t.signTransaction(e)||e}catch(e){throw new G(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 j;try{return await t.signAllTransactions(e)||e}catch(e){throw new G(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 j;try{const{signature:n}=await t.signMessage(e);return n}catch(e){throw new W(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}}let Z=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 J(e,t){const n=e.exec(t);return n?.groups}const Q=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,X=/^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)?$/,ee=/^\(.+?\).*?$/,te=/^tuple(?<array>(\[(\d*)\])*)$/;function ne(e){let t=e.type;if(te.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=ne(e.components[r]),r<n-1&&(t+=", ")}const r=J(te,e.type);return t+=`)${r?.array??""}`,ne({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function re(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=ne(e[r]),r!==n-1&&(t+=", ")}return t}function oe(e){return"function"===e.type?`function ${e.name}(${re(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${re(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${re(e.inputs)})`:"error"===e.type?`error ${e.name}(${re(e.inputs)})`:"constructor"===e.type?`constructor(${re(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const ae=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const se=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const ie=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const ce=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function le(e){return ce.test(e)}function ue(e){return J(ce,e)}const de=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const fe=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const he=/^receive\(\) external payable$/;const pe=new Set(["memory","indexed","storage","calldata"]),me=new Set(["indexed"]),ge=new Set(["calldata","memory","storage"]);class be extends Z{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 ye extends Z{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 we extends Z{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 ve extends Z{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 xe extends Z{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class Ee extends Z{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 Pe extends Z{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 ke extends Z{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 Ae extends Z{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 Ie extends Z{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Ne extends Z{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Se extends Z{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 Te extends Z{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 Be extends Z{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 Ce=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 $e(e,t={}){if(function(e){return ie.test(e)}(e))return function(e,t={}){const n=function(e){return J(ie,e)}(e);if(!n)throw new Ie({signature:e,type:"function"});const r=Me(n.parameters),o=[],a=r.length;for(let e=0;e<a;e++)o.push(ze(r[e],{modifiers:ge,structs:t,type:"function"}));const s=[];if(n.returns){const e=Me(n.returns),r=e.length;for(let n=0;n<r;n++)s.push(ze(e[n],{modifiers:ge,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:o,outputs:s}}(e,t);if(function(e){return se.test(e)}(e))return function(e,t={}){const n=function(e){return J(se,e)}(e);if(!n)throw new Ie({signature:e,type:"event"});const r=Me(n.parameters),o=[],a=r.length;for(let e=0;e<a;e++)o.push(ze(r[e],{modifiers:me,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:o}}(e,t);if(function(e){return ae.test(e)}(e))return function(e,t={}){const n=function(e){return J(ae,e)}(e);if(!n)throw new Ie({signature:e,type:"error"});const r=Me(n.parameters),o=[],a=r.length;for(let e=0;e<a;e++)o.push(ze(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:o}}(e,t);if(function(e){return de.test(e)}(e))return function(e,t={}){const n=function(e){return J(de,e)}(e);if(!n)throw new Ie({signature:e,type:"constructor"});const r=Me(n.parameters),o=[],a=r.length;for(let e=0;e<a;e++)o.push(ze(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:o}}(e,t);if(function(e){return fe.test(e)}(e))return function(e){const t=function(e){return J(fe,e)}(e);if(!t)throw new Ie({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return he.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new Ne({signature:e})}const Oe=/^(?<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$_]*))?$/,_e=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Re=/^u?int$/;function ze(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(Ce.has(n))return Ce.get(n);const r=ee.test(e),o=J(r?_e:Oe,e);if(!o)throw new xe({param:e});if(o.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||Q.test(e)||X.test(e)||Fe.test(e)}(o.name))throw new Ee({param:e,name:o.name});const a=o.name?{name:o.name}:{},s="indexed"===o.modifier?{indexed:!0}:{},i=t?.structs??{};let c,l={};if(r){c="tuple";const e=Me(o.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(ze(e[r],{structs:i}));l={components:t}}else if(o.type in i)c="tuple",l={components:i[o.type]};else if(Re.test(o.type))c=`${o.type}256`;else if("address payable"===o.type)c="address";else if(c=o.type,"struct"!==t?.type&&!Le(c))throw new we({type:c});if(o.modifier){if(!t?.modifiers?.has?.(o.modifier))throw new Pe({param:e,type:t?.type,modifier:o.modifier});if(ge.has(o.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!o.array))throw new ke({param:e,type:t?.type,modifier:o.modifier})}const u={type:`${c}${o.array??""}`,...a,...s,...l};return Ce.set(n,u),u}function Me(e,t=[],n="",r=0){const o=e.trim().length;for(let a=0;a<o;a++){const o=e[a],s=e.slice(a+1);switch(o){case",":return 0===r?Me(s,[...t,n.trim()]):Me(s,t,`${n}${o}`,r);case"(":return Me(s,t,`${n}${o}`,r+1);case")":return Me(s,t,`${n}${o}`,r-1);default:return Me(s,t,`${n}${o}`,r)}}if(""===n)return t;if(0!==r)throw new Be({current:n,depth:r});return t.push(n.trim()),t}function Le(e){return"address"===e||"bool"===e||"function"===e||"string"===e||Q.test(e)||X.test(e)}const Fe=/^(?: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 Ue(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!le(n))continue;const o=ue(n);if(!o)throw new Ie({signature:n,type:"struct"});const a=o.properties.split(";"),s=[],i=a.length;for(let e=0;e<i;e++){const t=a[e].trim();if(!t)continue;const n=ze(t,{type:"struct"});s.push(n)}if(!s.length)throw new Se({signature:n});t[o.name]=s}const r={},o=Object.entries(t),a=o.length;for(let e=0;e<a;e++){const[n,a]=o[e];r[n]=De(a,t)}return r}const je=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function De(e,t,n=new Set){const r=[],o=e.length;for(let a=0;a<o;a++){const o=e[a];if(ee.test(o.type))r.push(o);else{const e=J(je,o.type);if(!e?.type)throw new Ae({abiParameter:o});const{array:a,type:s}=e;if(s in t){if(n.has(s))throw new Te({type:s});r.push({...o,type:`tuple${a??""}`,components:De(t[s]??[],t,new Set([...n,s]))})}else{if(!Le(s))throw new ye({type:s});r.push(o)}}}return r}function Ge(e){const t=Ue(e),n=[],r=e.length;for(let o=0;o<r;o++){const r=e[o];le(r)||n.push($e(r,t))}return n}function We(e){let t;if("string"==typeof e)t=$e(e);else{const n=Ue(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(!le(r)){t=$e(r,n);break}}}if(!t)throw new be({signature:e});return t}function qe(e){const t=[];if("string"==typeof e){const n=Me(e),r=n.length;for(let e=0;e<r;e++)t.push(ze(n[e],{modifiers:pe}))}else{const n=Ue(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(le(r))continue;const a=Me(r),s=a.length;for(let e=0;e<s;e++)t.push(ze(a[e],{modifiers:pe,structs:n}))}}if(0===t.length)throw new ve({params:e});return t}function Ve(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 He(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new At(e.type);return`${e.name}(${Ye(e.inputs,{includeName:t})})`}function Ye(e,{includeName:t=!1}={}){return e?e.map(e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${Ye(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t})).join(t?", ":","):""}function Ke(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function Ze(e){return Ke(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Je="2.37.8";let Qe=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,Xe=`viem@${Je}`,et=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,a=Qe?.({...n,docsPath:o});super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...r?[`Details: ${r}`]:[],...Xe?[`Version: ${Xe}`]:[]].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=Je}walk(e){return tt(this,e)}};function tt(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?tt(e.cause,t):t?null:e}class nt extends et{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 rt extends et{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 ot extends et{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${Ye(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 at extends et{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class st extends et{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 it extends et{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Ze(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class ct extends et{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 lt extends et{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 ut extends et{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 dt extends et{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 ft extends et{constructor({docsPath:e}){super("Cannot extract event signature from empty topics.",{docsPath:e,name:"AbiEventSignatureEmptyTopicsError"})}}class ht extends et{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 pt extends et{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 mt extends et{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 gt extends et{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 bt extends et{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 yt extends et{constructor(e,t){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${He(e.abiItem)}\`, and`,`\`${t.type}\` in \`${He(t.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let wt=class extends et{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}};class vt extends et{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: (${Ye(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 xt extends et{constructor({abiItem:e,param:t}){super([`Expected a topic for indexed event parameter${t.name?` "${t.name}"`:""} on event "${He(e,{includeName:!0})}".`].join("\n"),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=e}}class Et extends et{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 Pt extends et{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 kt=class extends et{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}};class At extends et{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class It extends et{constructor(e){super(`Filter type "${e}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let Nt=class extends et{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},St=class extends et{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 Tt extends et{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 Bt(e,{dir:t,size:n=32}={}){return"string"==typeof e?Ct(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new St({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let o=0;o<n;o++){const a="right"===t;r[a?o:n-o-1]=e[a?o:e.length-o-1]}return r}(e,{dir:t,size:n})}function Ct(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new St({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}let $t=class extends et{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"})}},Ot=class extends et{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 _t extends et{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let Rt=class extends et{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function zt(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 Mt(e,{size:t}){if(Ze(e)>t)throw new Rt({givenSize:Ze(e),maxSize:t})}function Lt(e,t={}){const{signed:n}=t;t.size&&Mt(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 Ft(e,t={}){return Number(Lt(e,t))}const Ut=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function jt(e,t={}){return"number"==typeof e||"bigint"==typeof e?Wt(e,t):"string"==typeof e?Vt(e,t):"boolean"==typeof e?Dt(e,t):Gt(e,t)}function Dt(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(Mt(n,{size:t.size}),Bt(n,{size:t.size})):n}function Gt(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Ut[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(Mt(r,{size:t.size}),Bt(r,{dir:"right",size:t.size})):r}function Wt(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let a;r?a=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(a=BigInt(Number.MAX_SAFE_INTEGER));const s="bigint"==typeof a&&n?-a-1n:0;if(a&&o>a||o<s){const t="bigint"==typeof e?"n":"";throw new $t({max:a?`${a}${t}`:void 0,min:`${s}${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?Bt(i,{size:r}):i}const qt=new TextEncoder;function Vt(e,t={}){return Gt(qt.encode(e),t)}const Ht=new TextEncoder;function Yt(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=Wt(e,t);return Jt(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return Mt(n,{size:t.size}),Bt(n,{size:t.size});return n}(e,t):Ke(e)?Jt(e,t):Qt(e,t)}const Kt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Zt(e){return e>=Kt.zero&&e<=Kt.nine?e-Kt.zero:e>=Kt.A&&e<=Kt.F?e-(Kt.A-10):e>=Kt.a&&e<=Kt.f?e-(Kt.a-10):void 0}function Jt(e,t={}){let n=e;t.size&&(Mt(n,{size:t.size}),n=Bt(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const o=r.length/2,a=new Uint8Array(o);for(let e=0,t=0;e<o;e++){const n=Zt(r.charCodeAt(t++)),o=Zt(r.charCodeAt(t++));if(void 0===n||void 0===o)throw new et(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);a[e]=16*n+o}return a}function Qt(e,t={}){const n=Ht.encode(e);return"number"==typeof t.size?(Mt(n,{size:t.size}),Bt(n,{dir:"right",size:t.size})):n}const Xt=BigInt(2**32-1),en=BigInt(32);function tn(e,t=!1){return t?{h:Number(e&Xt),l:Number(e>>en&Xt)}:{h:0|Number(e>>en&Xt),l:0|Number(e&Xt)}}const nn="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function rn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function on(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,g,b,y=i(e),w=i(n),v=i(o),x=c(a);function E(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={})).Google="Google",d.Twitter="Twitter",d.Telegram="Telegram",d.Apple="Apple",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.LighterOrderSide=void 0,(h=exports.LighterOrderSide||(exports.LighterOrderSide={})).Buy="buy",h.Sell="sell",exports.LighterOrderType=void 0,(p=exports.LighterOrderType||(exports.LighterOrderType={})).Limit="limit",p.Market="market",p.StopLoss="stop_loss",p.StopLossLimit="stop_loss_limit",p.TakeProfit="take_profit",p.TakeProfitLimit="take_profit_limit",p.Twap="twap",p.TwapSub="twap_sub",exports.LighterTimeInForce=void 0,(m=exports.LighterTimeInForce||(exports.LighterTimeInForce={})).ImmediateOrCancel="immediate_or_cancel",m.GoodTillTime="good_till_time",m.PostOnly="post_only",exports.LighterMarginMode=void 0,(g=exports.LighterMarginMode||(exports.LighterMarginMode={})).Cross="cross",g.Isolated="isolated",exports.LighterGroupingType=void 0,(b=exports.LighterGroupingType||(exports.LighterGroupingType={})).Default="default",b.OneTriggersTheOther="one_triggers_the_other",b.OneCancelsTheOther="one_cancels_the_other",b.OneTriggersAOneCancelsTheOther="one_triggers_a_one_cancels_the_other";const P="embedded_wallet_state",k="superstack_wallet_type",A="superstack_backup_wallet_type",I="embedded_wallet_access_token",S="backup_wallet_info";class N{static saveState(e,t){const n={accessToken:e,socials:t,lastConnected:Date.now()};localStorage.setItem(P,JSON.stringify(n))}static saveAccessToken(e){localStorage.setItem(I,e)}static saveWalletType(e){localStorage.setItem(k,e)}static saveBackupWalletType(e){localStorage.setItem(A,e)}static saveBackupWalletInfo(e){localStorage.setItem(S,JSON.stringify(e))}static getWalletType(){return localStorage.getItem(k)}static getBackupWalletType(){return localStorage.getItem(A)}static getState(){try{const e=localStorage.getItem(P);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(P);if(!e)return null;return JSON.parse(e).socials}catch(e){return null}}static getAccessToken(){return localStorage.getItem(I)}static getBackupWalletInfo(){try{const e=localStorage.getItem(S);return e?JSON.parse(e):null}catch(e){return null}}static clear(){localStorage.removeItem(P),localStorage.removeItem(k),localStorage.removeItem(I),localStorage.removeItem(A)}static clearBackup(){localStorage.removeItem(A),localStorage.removeItem(S)}}function T(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $={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}($);var B,C=T($.exports);class O extends Error{constructor(e,t){super(e),this.error=t}}class _ extends O{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class R extends O{constructor(){super(...arguments),this.name="WalletConnectionError"}}class z extends O{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class M extends O{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class F extends O{constructor(){super(...arguments),this.name="WalletAccountError"}}class L extends O{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class j extends O{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class U extends O{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class D extends O{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class G extends O{constructor(){super(...arguments),this.name="WalletSignMessageError"}}!function(e){e.Installed="Installed",e.NotDetected="NotDetected",e.Loadable="Loadable",e.Unsupported="Unsupported"}(B||(B={}));class q extends C{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){const r=this.publicKey;if(!r)throw new j;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}}function V(e){return"version"in e}class W extends q{async sendTransaction(e,t,n={}){let r=!0;try{if(V(e)){if(!this.supportedTransactionVersions)throw new U("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new U(`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 D)throw r=!1,e;throw new U(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 D)throw r=!1,e;throw new U(e?.message,e)}}catch(e){throw r&&this.emit("error",e),e}}async signAllTransactions(e){for(const t of e)if(V(t)){if(!this.supportedTransactionVersions)throw new D("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(t.version))throw new D(`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 H extends W{}class Y extends H{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?B.Unsupported:B.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 z),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 L(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!==B.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=B.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=B.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===B.Installed&&await this.connect()}async connect(){var e;try{if(this.connected||this.connecting)return;if(this.readyState===B.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!==B.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 R(null==e?void 0:e.message,e)}if(!n.publicKey)throw new F;let r;try{r=new t.PublicKey(n.publicKey.toBytes())}catch(e){throw new L(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 M(null==e?void 0:e.message,e))}}this.emit("disconnect")}async sendTransaction(e,t,n={}){try{const r=this._wallet;if(!r)throw new j;try{const{signers:o,...s}=n;V(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 O)throw e;throw new U(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 j;try{return await t.signTransaction(e)||e}catch(e){throw new D(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 j;try{return await t.signAllTransactions(e)||e}catch(e){throw new D(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 j;try{const{signature:n}=await t.signMessage(e);return n}catch(e){throw new G(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}}let Z=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 K(e,t){const n=e.exec(t);return n?.groups}const J=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Q=/^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)?$/,X=/^\(.+?\).*?$/,ee=/^tuple(?<array>(\[(\d*)\])*)$/;function te(e){let t=e.type;if(ee.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=te(e.components[r]),r<n-1&&(t+=", ")}const r=K(ee,e.type);return t+=`)${r?.array??""}`,te({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function ne(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=te(e[r]),r!==n-1&&(t+=", ")}return t}function re(e){return"function"===e.type?`function ${e.name}(${ne(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${ne(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${ne(e.inputs)})`:"error"===e.type?`error ${e.name}(${ne(e.inputs)})`:"constructor"===e.type?`constructor(${ne(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const oe=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const se=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const ae=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const ie=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function ce(e){return ie.test(e)}function ue(e){return K(ie,e)}const le=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const de=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const fe=/^receive\(\) external payable$/;const he=new Set(["memory","indexed","storage","calldata"]),pe=new Set(["indexed"]),me=new Set(["calldata","memory","storage"]);class ge extends Z{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 be extends Z{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 ye extends Z{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 we extends Z{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 ve extends Z{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class xe extends Z{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 Ee extends Z{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 Pe extends Z{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 ke extends Z{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 Ae extends Z{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Ie extends Z{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Se extends Z{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 Ne extends Z{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 Te extends Z{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 $e=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 Be(e,t={}){if(function(e){return ae.test(e)}(e))return function(e,t={}){const n=function(e){return K(ae,e)}(e);if(!n)throw new Ae({signature:e,type:"function"});const r=ze(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Re(r[e],{modifiers:me,structs:t,type:"function"}));const a=[];if(n.returns){const e=ze(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(Re(e[n],{modifiers:me,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:o,outputs:a}}(e,t);if(function(e){return se.test(e)}(e))return function(e,t={}){const n=function(e){return K(se,e)}(e);if(!n)throw new Ae({signature:e,type:"event"});const r=ze(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Re(r[e],{modifiers:pe,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:o}}(e,t);if(function(e){return oe.test(e)}(e))return function(e,t={}){const n=function(e){return K(oe,e)}(e);if(!n)throw new Ae({signature:e,type:"error"});const r=ze(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Re(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:o}}(e,t);if(function(e){return le.test(e)}(e))return function(e,t={}){const n=function(e){return K(le,e)}(e);if(!n)throw new Ae({signature:e,type:"constructor"});const r=ze(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Re(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:o}}(e,t);if(function(e){return de.test(e)}(e))return function(e){const t=function(e){return K(de,e)}(e);if(!t)throw new Ae({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return fe.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new Ie({signature:e})}const Ce=/^(?<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$_]*))?$/,Oe=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,_e=/^u?int$/;function Re(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($e.has(n))return $e.get(n);const r=X.test(e),o=K(r?Oe:Ce,e);if(!o)throw new ve({param:e});if(o.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||J.test(e)||Q.test(e)||Fe.test(e)}(o.name))throw new xe({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=ze(o.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(Re(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&&!Me(c))throw new ye({type:c});if(o.modifier){if(!t?.modifiers?.has?.(o.modifier))throw new Ee({param:e,type:t?.type,modifier:o.modifier});if(me.has(o.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!o.array))throw new Pe({param:e,type:t?.type,modifier:o.modifier})}const l={type:`${c}${o.array??""}`,...s,...a,...u};return $e.set(n,l),l}function ze(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?ze(a,[...t,n.trim()]):ze(a,t,`${n}${o}`,r);case"(":return ze(a,t,`${n}${o}`,r+1);case")":return ze(a,t,`${n}${o}`,r-1);default:return ze(a,t,`${n}${o}`,r)}}if(""===n)return t;if(0!==r)throw new Te({current:n,depth:r});return t.push(n.trim()),t}function Me(e){return"address"===e||"bool"===e||"function"===e||"string"===e||J.test(e)||Q.test(e)}const Fe=/^(?: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 Le(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!ce(n))continue;const o=ue(n);if(!o)throw new Ae({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=Re(t,{type:"struct"});a.push(n)}if(!a.length)throw new Se({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]=Ue(s,t)}return r}const je=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function Ue(e,t,n=new Set){const r=[],o=e.length;for(let s=0;s<o;s++){const o=e[s];if(X.test(o.type))r.push(o);else{const e=K(je,o.type);if(!e?.type)throw new ke({abiParameter:o});const{array:s,type:a}=e;if(a in t){if(n.has(a))throw new Ne({type:a});r.push({...o,type:`tuple${s??""}`,components:Ue(t[a]??[],t,new Set([...n,a]))})}else{if(!Me(a))throw new be({type:a});r.push(o)}}}return r}function De(e){const t=Le(e),n=[],r=e.length;for(let o=0;o<r;o++){const r=e[o];ce(r)||n.push(Be(r,t))}return n}function Ge(e){let t;if("string"==typeof e)t=Be(e);else{const n=Le(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(!ce(r)){t=Be(r,n);break}}}if(!t)throw new ge({signature:e});return t}function qe(e){const t=[];if("string"==typeof e){const n=ze(e),r=n.length;for(let e=0;e<r;e++)t.push(Re(n[e],{modifiers:he}))}else{const n=Le(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(ce(r))continue;const s=ze(r),a=s.length;for(let e=0;e<a;e++)t.push(Re(s[e],{modifiers:he,structs:n}))}}if(0===t.length)throw new we({params:e});return t}function Ve(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 kt(e.type);return`${e.name}(${He(e.inputs,{includeName:t})})`}function He(e,{includeName:t=!1}={}){return e?e.map(e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${He(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t})).join(t?", ":","):""}function Ye(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function Ze(e){return Ye(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Ke="2.37.8";let Je=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,Qe=`viem@${Ke}`,Xe=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=Je?.({...n,docsPath:o});super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...Qe?[`Version: ${Qe}`]:[]].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=Ke}walk(e){return et(this,e)}};function et(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?et(e.cause,t):t?null:e}class tt extends Xe{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 nt extends Xe{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 rt extends Xe{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${He(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 ot extends Xe{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class st extends Xe{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 at extends Xe{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Ze(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class it extends Xe{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 ct extends Xe{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 ut extends Xe{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 lt extends Xe{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 dt extends Xe{constructor({docsPath:e}){super("Cannot extract event signature from empty topics.",{docsPath:e,name:"AbiEventSignatureEmptyTopicsError"})}}class ft extends Xe{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 ht extends Xe{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 pt extends Xe{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 mt extends Xe{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 gt extends Xe{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 bt extends Xe{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 yt=class extends Xe{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}};class wt extends Xe{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: (${He(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 vt extends Xe{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 xt extends Xe{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 Et extends Xe{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 Pt=class extends Xe{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}};class kt extends Xe{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class At extends Xe{constructor(e){super(`Filter type "${e}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let It=class extends Xe{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},St=class extends Xe{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 Nt extends Xe{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 Tt(e,{dir:t,size:n=32}={}){return"string"==typeof e?$t(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new St({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 $t(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new St({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}let Bt=class extends Xe{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"})}},Ct=class extends Xe{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 Ot extends Xe{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 Xe{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Rt(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 zt(e,{size:t}){if(Ze(e)>t)throw new _t({givenSize:Ze(e),maxSize:t})}function Mt(e,t={}){const{signed:n}=t;t.size&&zt(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 Ft(e,t={}){return Number(Mt(e,t))}const Lt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function jt(e,t={}){return"number"==typeof e||"bigint"==typeof e?Gt(e,t):"string"==typeof e?Vt(e,t):"boolean"==typeof e?Ut(e,t):Dt(e,t)}function Ut(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(zt(n,{size:t.size}),Tt(n,{size:t.size})):n}function Dt(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Lt[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(zt(r,{size:t.size}),Tt(r,{dir:"right",size:t.size})):r}function Gt(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 Bt({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?Tt(i,{size:r}):i}const qt=new TextEncoder;function Vt(e,t={}){return Dt(qt.encode(e),t)}const Wt=new TextEncoder;function Ht(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=Gt(e,t);return Kt(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return zt(n,{size:t.size}),Tt(n,{size:t.size});return n}(e,t):Ye(e)?Kt(e,t):Jt(e,t)}const Yt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Zt(e){return e>=Yt.zero&&e<=Yt.nine?e-Yt.zero:e>=Yt.A&&e<=Yt.F?e-(Yt.A-10):e>=Yt.a&&e<=Yt.f?e-(Yt.a-10):void 0}function Kt(e,t={}){let n=e;t.size&&(zt(n,{size:t.size}),n=Tt(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=Zt(r.charCodeAt(t++)),o=Zt(r.charCodeAt(t++));if(void 0===n||void 0===o)throw new Xe(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);s[e]=16*n+o}return s}function Jt(e,t={}){const n=Wt.encode(e);return"number"==typeof t.size?(zt(n,{size:t.size}),Tt(n,{dir:"right",size:t.size})):n}const Qt=BigInt(2**32-1),Xt=BigInt(32);function en(e,t=!1){return t?{h:Number(e&Qt),l:Number(e>>Xt&Qt)}:{h:0|Number(e>>Xt&Qt),l:0|Number(e&Qt)}}const tn="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function nn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function rn(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 an(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 sn(e,t){on(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function cn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ln(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function un(e,t){return e<<32-t|e>>>t}function dn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const fn=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=dn(e[t]);return e};function hn(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)),on(e),e}class pn{}function mn(e){const t=t=>e().update(hn(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function gn(e=32){if(nn&&"function"==typeof nn.getRandomValues)return nn.getRandomValues(new Uint8Array(e));if(nn&&"function"==typeof nn.randomBytes)return Uint8Array.from(nn.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const bn=BigInt(0),yn=BigInt(1),wn=BigInt(2),vn=BigInt(7),xn=BigInt(256),En=BigInt(113),Pn=[],kn=[],An=[];for(let e=0,t=yn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Pn.push(2*(5*r+n)),kn.push((e+1)*(e+2)/2%64);let o=bn;for(let e=0;e<7;e++)t=(t<<yn^(t>>vn)*En)%xn,t&wn&&(o^=yn<<(yn<<BigInt(e))-yn);An.push(o)}const In=function(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let a=0;a<n;a++){const{h:n,l:s}=tn(e[a],t);[r[a],o[a]]=[n,s]}return[r,o]}(An,!0),Nn=In[0],Sn=In[1],Tn=(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),Bn=(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 Cn extends pn{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,rn(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var a;this.state=new Uint8Array(200),this.state32=(a=this.state,new Uint32Array(a.buffer,a.byteOffset,Math.floor(a.byteLength/4)))}clone(){return this._cloneInto()}keccak(){fn(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,a=n[o],s=n[o+1],i=Tn(a,s,1)^n[r],c=Bn(a,s,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=kn[n],a=Tn(t,o,r),s=Bn(t,o,r),i=Pn[n];t=e[i],o=e[i+1],e[i]=a,e[i+1]=s}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]^=Nn[r],e[1]^=Sn[r]}cn(n)}(this.state32,this.rounds),fn(this.state32),this.posOut=0,this.pos=0}update(e){an(this),on(e=hn(e));const{blockLen:t,state:n}=this,r=e.length;for(let o=0;o<r;){const a=Math.min(t-this.pos,r-o);for(let t=0;t<a;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){an(this,!1),on(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 a=Math.min(n-this.posOut,o-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return rn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(sn(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,cn(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:o,enableXOF:a}=this;return e||(e=new Cn(t,n,r,a,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=a,e.destroyed=this.destroyed,e}}const $n=(()=>{return e=1,t=136,n=32,mn(()=>new Cn(t,e,n));var e,t,n})();function On(e,t){const n=t||"hex",r=$n(Ke(e,{strict:!1})?Yt(e):e);return"bytes"===n?r:jt(r)}function _n(e){return On(Yt(e))}const Rn=e=>function(e){let t=!0,n="",r=0,o="",a=!1;for(let s=0;s<e.length;s++){const i=e[s];if(["(",")",","].includes(i)&&(t=!0),"("===i&&r++,")"===i&&r--,t)if(0!==r)" "!==i?(o+=i,n+=i):","!==e[s-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===i&&["event","function",""].includes(o))o="";else if(o+=i,")"===i){a=!0;break}}if(!a)throw new et("Unable to normalize signature.");return o}("string"==typeof e?e:oe(e));function zn(e){return _n(Rn(e))}const Mn=zn;let Ln=class extends et{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"})}},Fn=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 Un=new Fn(8192);function jn(e,t){if(Un.has(`${e}.${t}`))return Un.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=On(Qt(n),"bytes"),o=n.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&o[e]&&(o[e]=o[e].toUpperCase()),(15&r[e>>1])>=8&&o[e+1]&&(o[e+1]=o[e+1].toUpperCase());const a=`0x${o.join("")}`;return Un.set(`${e}.${t}`,a),a}function Dn(e,t){if(!qn(e,{strict:!1}))throw new Ln({address:e});return jn(e,t)}const Gn=/^0x[a-fA-F0-9]{40}$/,Wn=new Fn(8192);function qn(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Wn.has(r))return Wn.get(r);const o=!(!Gn.test(e)||e.toLowerCase()!==e&&n&&jn(e)!==e);return Wn.set(r,o),o}function Vn(e){return"string"==typeof e[0]?Hn(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 Hn(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function Yn(e,t,n,{strict:r}={}){return Ke(e,{strict:!1})?function(e,t,n,{strict:r}={}){Kn(e,t);const o=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;r&&Zn(o,t,n);return o}(e,t,n,{strict:r}):Jn(e,t,n,{strict:r})}function Kn(e,t){if("number"==typeof t&&t>0&&t>Ze(e)-1)throw new Nt({offset:t,position:"start",size:Ze(e)})}function Zn(e,t,n){if("number"==typeof t&&"number"==typeof n&&Ze(e)!==n-t)throw new Nt({offset:n,position:"end",size:Ze(e)})}function Jn(e,t,n,{strict:r}={}){Kn(e,t);const o=e.slice(t,n);return r&&Zn(o,t,n),o}const Qn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Xn=/^(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 er(e,t){if(e.length!==t.length)throw new ct({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(tr({param:e[r],value:t[r]}));return n}({params:e,values:t}),r=nr(n);return 0===r.length?"0x":r}function tr({param:e,value:t}){const n=rr(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 kt(e);if(!r&&e.length!==t)throw new st({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let o=!1;const a=[];for(let t=0;t<e.length;t++){const r=tr({param:n,value:e[t]});r.dynamic&&(o=!0),a.push(r)}if(r||o){const e=nr(a);if(r){const t=Wt(a.length,{size:32});return{dynamic:!0,encoded:a.length>0?Vn([t,e]):t}}if(o)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Vn(a.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 a=t.components[o],s=tr({param:a,value:e[Array.isArray(e)?o:a.name]});r.push(s),s.dynamic&&(n=!0)}return{dynamic:n,encoded:n?nr(r):Vn(r.map(({encoded:e})=>e))}}(t,{param:e});if("address"===e.type)return function(e){if(!qn(e))throw new Ln({address:e});return{dynamic:!1,encoded:Ct(e.toLowerCase())}}(t);if("bool"===e.type)return function(e){if("boolean"!=typeof e)throw new et(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Ct(Dt(e))}}(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const n=e.type.startsWith("int"),[,,r="256"]=Xn.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 $t({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Wt(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=Ze(e);if(!n){let t=e;return r%32!=0&&(t=Ct(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:Vn([Ct(Wt(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new it({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:Ct(e,{dir:"right"})}}(t,{param:e});if("string"===e.type)return function(e){const t=Vt(e),n=Math.ceil(Ze(t)/32),r=[];for(let e=0;e<n;e++)r.push(Ct(Yn(t,32*e,32*(e+1)),{dir:"right"}));return{dynamic:!0,encoded:Vn([Ct(Wt(Ze(t),{size:32})),...r])}}(t);throw new Et(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function nr(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:Ze(o)}const n=[],r=[];let o=0;for(let a=0;a<e.length;a++){const{dynamic:s,encoded:i}=e[a];s?(n.push(Wt(t+o,{size:32})),r.push(i),o+=Ze(i)):n.push(i)}return Vn([...n,...r])}function rr(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const or=e=>Yn(zn(e),0,4);function ar(e){const{abi:t,args:n=[],name:r}=e,o=Ke(r,{strict:!1}),a=t.filter(e=>o?"function"===e.type?or(e)===r:"event"===e.type&&Mn(e)===r:"name"in e&&e.name===r);if(0===a.length)return;if(1===a.length)return a[0];let s;for(const e of a){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&&sr(t,r)});if(t){if(s&&"inputs"in s&&s.inputs){const t=ir(e.inputs,s.inputs,n);if(t)throw new yt({abiItem:e,type:t[0]},{abiItem:s,type:t[1]})}s=e}}return s||a[0]}function sr(e,t){const n=typeof e,r=t.type;switch(r){case"address":return qn(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)=>sr(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=>sr(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function ir(e,t,n){for(const r in e){const o=e[r],a=t[r];if("tuple"===o.type&&"tuple"===a.type&&"components"in o&&"components"in a)return ir(o.components,a.components,n[r]);const s=[o.type,a.type];if((()=>!(!s.includes("address")||!s.includes("bytes20"))||(s.includes("address")&&s.includes("string")||!(!s.includes("address")||!s.includes("bytes")))&&qn(n[r],{strict:!1}))())return s}}const cr="/docs/contract/encodeEventTopics";function lr(e){const{abi:t,eventName:n,args:r}=e;let o=t[0];if(n){const e=ar({abi:t,name:n});if(!e)throw new pt(n,{docsPath:cr});o=e}if("event"!==o.type)throw new pt(void 0,{docsPath:cr});const a=He(o),s=Mn(a);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)=>ur({param:e,value:t[n][o]})):void 0!==t[n]&&null!==t[n]?ur({param:e,value:t[n]}):null)??[])}return[s,...i]}function ur({param:e,value:t}){if("string"===e.type||"bytes"===e.type)return On(Yt(t));if("tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))throw new It(e.type);return er([e],[t])}function dr(e,{method:t}){const n={};return"fallback"===e.transport.type&&e.transport.onResponse?.(({method:e,response:r,status:o,transport:a})=>{"success"===o&&t===e&&(n[r]=a.request)}),t=>n[t]||e.request}async function fr(e,t){const{address:n,abi:r,args:o,eventName:a,fromBlock:s,strict:i,toBlock:c}=t,l=dr(e,{method:"eth_newFilter"}),u=a?lr({abi:r,args:o,eventName:a}):void 0,d=await e.request({method:"eth_newFilter",params:[{address:n,fromBlock:"bigint"==typeof s?Wt(s):s,toBlock:"bigint"==typeof c?Wt(c):c,topics:u}]});return{abi:r,args:o,eventName:a,id:d,request:l(d),strict:Boolean(i),type:"event"}}function hr(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const pr="/docs/contract/encodeFunctionData";function mr(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=ar({abi:t,args:n,name:r});if(!e)throw new mt(r,{docsPath:pr});o=e}if("function"!==o.type)throw new mt(void 0,{docsPath:pr});return{abi:[o],functionName:or(He(o))}}(e),o=n[0];return Hn([r,("inputs"in o&&o.inputs?er(o.inputs,t??[]):void 0)??"0x"])}const gr={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."},br={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},yr={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};let wr=class extends et{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}},vr=class extends et{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}},xr=class extends et{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}};const Er={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 xr({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new vr({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new wr({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 wr({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 Pr(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(Er);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function kr(e,t={}){void 0!==t.size&&Mt(e,{size:t.size});return Lt(Gt(e,t),t)}function Ar(e,t={}){let n=e;if(void 0!==t.size&&(Mt(n,{size:t.size}),n=zt(n)),n.length>1||n[0]>1)throw new Ot(n);return Boolean(n[0])}function Ir(e,t={}){void 0!==t.size&&Mt(e,{size:t.size});return Ft(Gt(e,t),t)}function Nr(e,t){const n="string"==typeof t?Jt(t):t,r=Pr(n);if(0===Ze(n)&&e.length>0)throw new at;if(Ze(t)&&Ze(t)<32)throw new ot({data:"string"==typeof t?t:Gt(t),params:e,size:Ze(t)});let o=0;const a=[];for(let t=0;t<e.length;++t){const n=e[t];r.setPosition(o);const[s,i]=Sr(r,n,{staticPosition:0});o+=i,a.push(s)}return a}function Sr(e,t,{staticPosition:n}){const r=rr(t.type);if(r){const[o,a]=r;return function(e,t,{length:n,staticPosition:r}){if(!n){const n=r+Ir(e.readBytes(Br)),o=n+Tr;e.setPosition(n);const a=Ir(e.readBytes(Tr)),s=Cr(t);let i=0;const c=[];for(let n=0;n<a;++n){e.setPosition(o+(s?32*n:i));const[r,a]=Sr(e,t,{staticPosition:o});i+=a,c.push(r)}return e.setPosition(r+32),[c,32]}if(Cr(t)){const o=r+Ir(e.readBytes(Br)),a=[];for(let r=0;r<n;++r){e.setPosition(o+32*r);const[n]=Sr(e,t,{staticPosition:o});a.push(n)}return e.setPosition(r+32),[a,32]}let o=0;const a=[];for(let s=0;s<n;++s){const[n,s]=Sr(e,t,{staticPosition:r+o});o+=s,a.push(n)}return[a,o]}(e,{...t,type:a},{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 a=0;if(Cr(t)){const s=n+Ir(e.readBytes(Br));for(let n=0;n<t.components.length;++n){const i=t.components[n];e.setPosition(s+a);const[c,l]=Sr(e,i,{staticPosition:s});a+=l,o[r?n:i?.name]=c}return e.setPosition(n+32),[o,32]}for(let s=0;s<t.components.length;++s){const i=t.components[s],[c,l]=Sr(e,i,{staticPosition:n});o[r?s:i?.name]=c,a+=l}return[o,a]}(e,t,{staticPosition:n});if("address"===t.type)return function(e){const t=e.readBytes(32);return[jn(Gt(Jn(t,-20))),32]}(e);if("bool"===t.type)return function(e){return[Ar(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=Ir(e.readBytes(32));e.setPosition(n+t);const r=Ir(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[Gt(o),32]}const a=Gt(e.readBytes(Number.parseInt(o,10),32));return[a,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?kr(o,{signed:n}):Ir(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=Ir(e.readBytes(32)),r=t+n;e.setPosition(r);const o=Ir(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const a=e.readBytes(o,32),s=function(e,t={}){let n=e;return void 0!==t.size&&(Mt(n,{size:t.size}),n=zt(n,{dir:"right"})),(new TextDecoder).decode(n)}(zt(a));return e.setPosition(t+32),[s,32]}(e,{staticPosition:n});throw new Pt(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Tr=32,Br=32;function Cr(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(Cr);const n=rr(e.type);return!(!n||!Cr({...e,type:n[1]}))}function $r(e){const{abi:t,data:n}=e,r=Yn(n,0,4);if("0x"===r)throw new at;const o=[...t||[],br,yr].find(e=>"error"===e.type&&r===or(He(e)));if(!o)throw new dt(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:o,args:"inputs"in o&&o.inputs&&o.inputs.length>0?Nr(o.inputs,Yn(n,4)):void 0,errorName:o.name}}const Or=(e,t,n)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,n);function _r({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]?Or(t[n]):t[n]}`).join(", ")})`}const Rr={gwei:9,wei:18},zr={ether:-9,wei:9};function Mr(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[o,a]=[n.slice(0,n.length-t),n.slice(n.length-t)];return a=a.replace(/(0+)$/,""),`${r?"-":""}${o||"0"}${a?`.${a}`:""}`}function Lr(e,t="wei"){return Mr(e,Rr[t])}function Fr(e,t="wei"){return Mr(e,zr[t])}class Ur extends et{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class jr extends et{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Dr(e){return e.reduce((e,{slot:t,value:n})=>`${e} ${t}: ${n}\n`,"")}function Gr(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 Wr extends et{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 qr extends et{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Gr(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 Vr extends et{constructor({blockHash:e,blockNumber:t,blockTag:n,hash:r,index:o}){let a="Transaction";n&&void 0!==o&&(a=`Transaction at block time "${n}" at index "${o}"`),e&&void 0!==o&&(a=`Transaction at block hash "${e}" at index "${o}"`),t&&void 0!==o&&(a=`Transaction at block number "${t}" at index "${o}"`),r&&(a=`Transaction with hash "${r}"`),super(`${a} could not be found.`,{name:"TransactionNotFoundError"})}}class Hr extends et{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 Yr extends et{constructor({hash:e}){super(`Timed out while waiting for transaction with hash "${e}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}class Kr extends et{constructor(e,{account:t,docsPath:n,chain:r,data:o,gas:a,gasPrice:s,maxFeePerGas:i,maxPriorityFeePerGas:c,nonce:l,to:u,value:d,stateOverride:f}){const h=t?hr(t):void 0;let p=Gr({from:h?.address,to:u,value:void 0!==d&&`${Lr(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:a,gasPrice:void 0!==s&&`${Fr(s)} gwei`,maxFeePerGas:void 0!==i&&`${Fr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Fr(c)} gwei`,nonce:l});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+=Dr(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=Dr(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 Zr extends et{constructor(e,{abi:t,args:n,contractAddress:r,docsPath:o,functionName:a,sender:s}){const i=ar({abi:t,args:n,name:a}),c=i?_r({abiItem:i,args:n,includeFunctionName:!1,includeName:!1}):void 0,l=Gr({address:r&&r,function:i?He(i,{includeName:!0}):void 0,args:c&&"()"!==c&&`${[...Array(a?.length??0).keys()].map(()=>" ").join("")}${c}`,sender:s});super(e.shortMessage||`An unknown error occurred while executing the contract function "${a}".`,{cause:e,docsPath:o,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],l&&"Contract Call:",l].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=a,this.sender=s}}class Jr extends et{constructor({abi:e,data:t,functionName:n,message:r}){let o,a,s,i,c;if(t&&"0x"!==t)try{a=$r({abi:e,data:t});const{abiItem:n,errorName:r,args:o}=a;if("Error"===r)i=o[0];else if("Panic"===r){const[e]=o;i=gr[e]}else{const e=n?He(n,{includeName:!0}):void 0,t=n&&o?_r({abiItem:n,args:o,includeFunctionName:!1,includeName:!1}):void 0;s=[e?`Error: ${e}`:"",t&&"()"!==t?` ${[...Array(r?.length??0).keys()].map(()=>" ").join("")}${t}`:""]}}catch(e){o=e}else r&&(i=r);o instanceof dt&&(c=o.signature,s=[`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:s,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=a,this.raw=t,this.reason=i,this.signature=c}}class Qr extends et{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 Xr extends et{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 eo extends et{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 to extends et{constructor({body:e,cause:t,details:n,headers:r,status:o,url:a}){super("HTTP request failed.",{cause:t,details:n,metaMessages:[o&&`Status: ${o}`,`URL: ${a}`,e&&`Request body: ${Or(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=a}}class no extends et{constructor({body:e,error:t,url:n}){super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${n}`,`Request body: ${Or(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 ro extends et{constructor({body:e,url:t}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${t}`,`Request body: ${Or(e)}`],name:"TimeoutError"})}}class oo extends et{constructor(e,{code:t,docsPath:n,metaMessages:r,name:o,shortMessage:a}){super(a,{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 no?e.code:t??-1}}class ao extends oo{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class so extends oo{constructor(e){super(e,{code:so.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(so,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class io extends oo{constructor(e){super(e,{code:io.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(io,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class co extends oo{constructor(e,{method:t}={}){super(e,{code:co.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(co,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class lo extends oo{constructor(e){super(e,{code:lo.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(lo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class uo extends oo{constructor(e){super(e,{code:uo.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(uo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class fo extends oo{constructor(e){super(e,{code:fo.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(fo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class ho extends oo{constructor(e){super(e,{code:ho.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(ho,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class po extends oo{constructor(e){super(e,{code:po.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(po,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class mo extends oo{constructor(e){super(e,{code:mo.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(mo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class go extends oo{constructor(e,{method:t}={}){super(e,{code:go.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not supported.`})}}Object.defineProperty(go,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class bo extends oo{constructor(e){super(e,{code:bo.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(bo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class yo extends oo{constructor(e){super(e,{code:yo.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(yo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class wo extends ao{constructor(e){super(e,{code:wo.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(wo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class vo extends ao{constructor(e){super(e,{code:vo.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(vo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class xo extends ao{constructor(e,{method:t}={}){super(e,{code:xo.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(xo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class Eo extends ao{constructor(e){super(e,{code:Eo.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(Eo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Po extends ao{constructor(e){super(e,{code:Po.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(Po,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class ko extends ao{constructor(e){super(e,{code:ko.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(ko,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class Ao extends ao{constructor(e){super(e,{code:Ao.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(Ao,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Io extends ao{constructor(e){super(e,{code:Io.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Io,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class No extends ao{constructor(e){super(e,{code:No.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(No,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class So extends ao{constructor(e){super(e,{code:So.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(So,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class To extends ao{constructor(e){super(e,{code:To.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(To,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Bo extends ao{constructor(e){super(e,{code:Bo.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Bo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Co extends ao{constructor(e){super(e,{code:Co.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Co,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class $o extends oo{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Oo=3;function _o(e,{abi:t,address:n,args:r,docsPath:o,functionName:a,sender:s}){const i=e instanceof eo?e:e instanceof et?e.walk(e=>"data"in e)||e.walk():{},{code:c,data:l,details:u,message:d,shortMessage:f}=i,h=e instanceof at?new Qr({functionName:a}):[Oo,uo.code].includes(c)&&(l||u||d||f)?new Jr({abi:t,data:"object"==typeof l?l.data:l,functionName:a,message:i instanceof no?u:f??d}):e;return new Zr(h,{abi:t,args:r,contractAddress:n,docsPath:o,functionName:a,sender:s})}function Ro(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 zo({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=Ke(e)?e:jt(e),{secp256k1:r}=await Promise.resolve().then(function(){return nd}),o=(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:n,v:o,yParity:a}=t,s=Ro(Number(a??o));return new r.Signature(Lt(e),Lt(n)).addRecoveryBit(s)}const e=Ke(t)?t:jt(t);if(65!==Ze(e))throw new Error("invalid signature length");const n=Ro(Ft(`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}),jn(`0x${On(`0x${n.substring(4)}`).substring(26)}`);var n}function Mo(e,t="hex"){const n=Lo(e),r=Pr(new Uint8Array(n.length));return n.encode(r),"hex"===t?Gt(r.bytes):r.bytes}function Lo(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),n=Fo(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=>Lo(e))):function(e){const t="string"==typeof e?Jt(e):e,n=Fo(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 Fo(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 et("Length is too large.")}function Uo(e){const{chainId:t,nonce:n,to:r}=e,o=e.contractAddress??e.address,a=On(Hn(["0x05",Mo([t?Wt(t):"0x",o,n?Wt(n):"0x"])]));return"bytes"===r?Jt(a):a}async function jo(e){const{authorization:t,signature:n}=e;return zo({hash:Uo(t),signature:n??t})}class Do extends et{constructor(e,{account:t,docsPath:n,chain:r,data:o,gas:a,gasPrice:s,maxFeePerGas:i,maxPriorityFeePerGas:c,nonce:l,to:u,value:d}){const f=Gr({from:t?.address,to:u,value:void 0!==d&&`${Lr(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:a,gasPrice:void 0!==s&&`${Fr(s)} gwei`,maxFeePerGas:void 0!==i&&`${Fr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Fr(c)} gwei`,nonce:l});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 Go extends et{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(Go,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Go,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Wo extends et{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Fr(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Wo,"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 qo extends et{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Fr(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(qo,"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 Vo extends et{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(Vo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Ho extends et{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(Ho,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Yo extends et{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Yo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Ko extends et{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(Ko,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Zo extends et{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(Zo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Jo extends et{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(Jo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Qo extends et{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Qo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Xo extends et{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${Fr(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Fr(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Xo,"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 ea extends et{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function ta(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof et?e.walk(e=>e?.code===Go.code):e;return r instanceof et?new Go({cause:e,message:r.details}):Go.nodeMessage.test(n)?new Go({cause:e,message:e.details}):Wo.nodeMessage.test(n)?new Wo({cause:e,maxFeePerGas:t?.maxFeePerGas}):qo.nodeMessage.test(n)?new qo({cause:e,maxFeePerGas:t?.maxFeePerGas}):Vo.nodeMessage.test(n)?new Vo({cause:e,nonce:t?.nonce}):Ho.nodeMessage.test(n)?new Ho({cause:e,nonce:t?.nonce}):Yo.nodeMessage.test(n)?new Yo({cause:e,nonce:t?.nonce}):Ko.nodeMessage.test(n)?new Ko({cause:e}):Zo.nodeMessage.test(n)?new Zo({cause:e,gas:t?.gas}):Jo.nodeMessage.test(n)?new Jo({cause:e,gas:t?.gas}):Qo.nodeMessage.test(n)?new Qo({cause:e}):Xo.nodeMessage.test(n)?new Xo({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new ea({cause:e})}function na(e,{format:t}){if(!t)return{};const n={};return function t(r){const o=Object.keys(r);for(const a of o)a in e&&(n[a]=e[a]),r[a]&&"object"==typeof r[a]&&!Array.isArray(r[a])&&t(r[a])}(t(e||{})),n}const ra={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function oa(e){const t={};return void 0!==e.authorizationList&&(t.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?Wt(BigInt(e.r)):e.r,s:e.s?Wt(BigInt(e.s)):e.s,chainId:Wt(e.chainId),nonce:Wt(e.nonce),...void 0!==e.yParity?{yParity:Wt(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:Wt(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=>Gt(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=Wt(e.gas)),void 0!==e.gasPrice&&(t.gasPrice=Wt(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(t.maxFeePerBlobGas=Wt(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=Wt(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=Wt(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=Wt(e.nonce)),void 0!==e.to&&(t.to=e.to),void 0!==e.type&&(t.type=ra[e.type]),void 0!==e.value&&(t.value=Wt(e.value)),t}function aa(e){if(e&&0!==e.length)return e.reduce((e,{slot:t,value:n})=>{if(66!==t.length)throw new Tt({size:t.length,targetSize:66,type:"hex"});if(66!==n.length)throw new Tt({size:n.length,targetSize:66,type:"hex"});return e[t]=n,e},{})}function sa(e){const{balance:t,nonce:n,state:r,stateDiff:o,code:a}=e,s={};if(void 0!==a&&(s.code=a),void 0!==t&&(s.balance=Wt(t)),void 0!==n&&(s.nonce=Wt(n)),void 0!==r&&(s.state=aa(r)),void 0!==o){if(s.state)throw new jr;s.stateDiff=aa(o)}return s}function ia(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!qn(n,{strict:!1}))throw new Ln({address:n});if(t[n])throw new Ur({address:n});t[n]=sa(r)}return t}const ca=2n**256n-1n;function la(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:o,to:a}=e,s=t?hr(t):void 0;if(s&&!qn(s.address))throw new Ln({address:s.address});if(a&&!qn(a))throw new Ln({address:a});if(void 0!==n&&(void 0!==r||void 0!==o))throw new Wr;if(r&&r>ca)throw new Wo({maxFeePerGas:r});if(o&&r&&o>r)throw new Xo({maxFeePerGas:r,maxPriorityFeePerGas:o})}class ua extends et{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class da extends et{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class fa extends et{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Fr(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class ha extends et{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 pa={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ma(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Ft(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?Ft(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?pa[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 ga(e){const t=(e.transactions??[]).map(e=>"string"==typeof e?e:ma(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 ba(e,{blockHash:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",includeTransactions:o}={}){const a=o??!1,s=void 0!==n?Wt(n):void 0;let i=null;if(i=t?await e.request({method:"eth_getBlockByHash",params:[t,a]},{dedupe:!0}):await e.request({method:"eth_getBlockByNumber",params:[s||r,a]},{dedupe:Boolean(s)}),!i)throw new ha({blockHash:t,blockNumber:n});return(e.chain?.formatters?.block?.format||ga)(i)}async function ya(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function wa(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 Ve(e,ba,"getBlock")({}),a=await t({block:r,client:e,request:o});if(null===a)throw new Error;return a}if(void 0!==t)return t;return Lt(await e.request({method:"eth_maxPriorityFeePerGas"}))}catch{const[t,r]=await Promise.all([n?Promise.resolve(n):Ve(e,ba,"getBlock")({}),Ve(e,ya,"getGasPrice")({})]);if("bigint"!=typeof t.baseFeePerGas)throw new da;const o=r-t.baseFeePerGas;return o<0n?0n:o}}async function va(e,t){const{block:n,chain:r=e.chain,request:o,type:a="eip1559"}=t||{},s=await(async()=>"function"==typeof r?.fees?.baseFeeMultiplier?r.fees.baseFeeMultiplier({block:n,client:e,request:o}):r?.fees?.baseFeeMultiplier??1.2)();if(s<1)throw new ua;const i=10**(s.toString().split(".")[1]?.length??0),c=e=>e*BigInt(Math.ceil(s*i))/BigInt(i),l=n||await Ve(e,ba,"getBlock")({});if("function"==typeof r?.fees?.estimateFeesPerGas){const t=await r.fees.estimateFeesPerGas({block:n,client:e,multiply:c,request:o,type:a});if(null!==t)return t}if("eip1559"===a){if("bigint"!=typeof l.baseFeePerGas)throw new da;const t="bigint"==typeof o?.maxPriorityFeePerGas?o.maxPriorityFeePerGas:await wa(e,{block:l,chain:r,request:o}),n=c(l.baseFeePerGas);return{maxFeePerGas:o?.maxFeePerGas??n+t,maxPriorityFeePerGas:t}}return{gasPrice:o?.gasPrice??c(await Ve(e,ya,"getGasPrice")({}))}}async function xa(e,{address:t,blockTag:n="latest",blockNumber:r}){return Ft(await e.request({method:"eth_getTransactionCount",params:[t,"bigint"==typeof r?Wt(r):n]},{dedupe:Boolean(r)}))}function Ea(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=>Jt(e)):e.blobs,o=[];for(const e of r)o.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?o:o.map(e=>Gt(e))}function Pa(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=>Jt(e)):e.blobs,o="string"==typeof e.commitments[0]?e.commitments.map(e=>Jt(e)):e.commitments,a=[];for(let e=0;e<r.length;e++){const n=r[e],s=o[e];a.push(Uint8Array.from(t.computeBlobKzgProof(n,s)))}return"bytes"===n?a:a.map(e=>Gt(e))}function ka(e,t,n){return e&t^~e&n}function Aa(e,t,n){return e&t^e&n^t&n}class Ia extends pn{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=ln(this.buffer)}update(e){an(this),on(e=hn(e));const{view:t,buffer:n,blockLen:r}=this,o=e.length;for(let a=0;a<o;){const s=Math.min(r-this.pos,o-a);if(s===r){const t=ln(e);for(;r<=o-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){an(this),sn(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:a}=this;t[a++]=128,cn(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;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),a=BigInt(4294967295),s=Number(n>>o&a),i=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,i,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=ln(e),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=i/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,l[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:a,pos:s}=this;return e.destroyed=a,e.finished=o,e.length=r,e.pos=s,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const Na=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Sa=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]),Ta=new Uint32Array(64);class Ba extends Ia{constructor(e=32){super(64,e,8,!1),this.A=0|Na[0],this.B=0|Na[1],this.C=0|Na[2],this.D=0|Na[3],this.E=0|Na[4],this.F=0|Na[5],this.G=0|Na[6],this.H=0|Na[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:a,G:s,H:i}=this;return[e,t,n,r,o,a,s,i]}set(e,t,n,r,o,a,s,i){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|a,this.G=0|s,this.H=0|i}process(e,t){for(let n=0;n<16;n++,t+=4)Ta[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Ta[e-15],n=Ta[e-2],r=un(t,7)^un(t,18)^t>>>3,o=un(n,17)^un(n,19)^n>>>10;Ta[e]=o+Ta[e-7]+r+Ta[e-16]|0}let{A:n,B:r,C:o,D:a,E:s,F:i,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(un(s,6)^un(s,11)^un(s,25))+ka(s,i,c)+Sa[e]+Ta[e]|0,u=(un(n,2)^un(n,13)^un(n,22))+Aa(n,r,o)|0;l=c,c=i,i=s,s=a+t|0,a=o,o=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,a=a+this.D|0,s=s+this.E|0,i=i+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,o,a,s,i,c,l)}roundClean(){cn(Ta)}destroy(){this.set(0,0,0,0,0,0,0,0),cn(this.buffer)}}const Ca=mn(()=>new Ba),$a=Ca;function Oa(e){const{commitment:t,version:n=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),o=$a(Ke(a=t,{strict:!1})?Yt(a):a);var a;return o.set([n],0),"bytes"===r?o:Gt(o)}const _a=4096,Ra=131072,za=761855;class Ma extends et{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class La extends et{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Fa(e){const{data:t,kzg:n,to:r}=e,o=e.blobs??function(e){const t="string"==typeof e.data?Jt(e.data):e.data,n=Ze(t);if(!n)throw new La;if(n>za)throw new Ma({maxSize:za,size:n});const r=[];let o=!0,a=0;for(;o;){const e=Pr(new Uint8Array(Ra));let n=0;for(;n<_a;){const r=t.slice(a,a+31);if(e.pushByte(0),e.pushBytes(r),r.length<31){e.pushByte(128),o=!1;break}n++,a+=31}r.push(e)}return r.map(e=>Gt(e.bytes))}({data:t}),a=e.commitments??Ea({blobs:o,kzg:n,to:r}),s=e.proofs??Pa({blobs:o,commitments:a,kzg:n,to:r}),i=[];for(let e=0;e<o.length;e++)i.push({blob:o[e],commitment:a[e],proof:s[e]});return i}async function Ua(e){return Ft(await e.request({method:"eth_chainId"},{dedupe:!0}))}const ja=["blobVersionedHashes","chainId","fees","gas","nonce","type"],Da=new Map;async function Ga(e,t){const{account:n=e.account,blobs:r,chain:o,gas:a,kzg:s,nonce:i,nonceManager:c,parameters:l=ja,type:u}=t,d=n?hr(n):n,f={...t,...d?{from:d?.address}:{}};let h,p;async function m(){return h||(h=await Ve(e,ba,"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 Ve(e,Ua,"getChainId")({});return p=n,p}if(l.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 Ve(e,xa,"getTransactionCount")({address:d.address,blockTag:"pending"});if((l.includes("blobVersionedHashes")||l.includes("sidecars"))&&r&&s){const e=Ea({blobs:r,kzg:s});if(l.includes("blobVersionedHashes")){const t=function(e){const{commitments:t,version:n}=e,r=e.to,o=[];for(const e of t)o.push(Oa({commitment:e,to:r,version:n}));return o}({commitments:e,to:"hex"});f.blobVersionedHashes=t}if(l.includes("sidecars")){const t=Fa({blobs:r,commitments:e,proofs:Pa({blobs:r,commitments:e,kzg:s}),to:"hex"});f.sidecars=t}}if(l.includes("chainId")&&(f.chainId=await g()),(l.includes("fees")||l.includes("type"))&&void 0===u)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 qr({transaction:e})}(f)}catch{let t=Da.get(e.uid);if(void 0===t){const n=await m();t="bigint"==typeof n?.baseFeePerGas,Da.set(e.uid,t)}f.type=t?"eip1559":"legacy"}if(l.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:a}=await va(e,{block:n,chain:o,request:f});if(void 0===t.maxPriorityFeePerGas&&t.maxFeePerGas&&t.maxFeePerGas<a)throw new fa({maxPriorityFeePerGas:a});f.maxPriorityFeePerGas=a,f.maxFeePerGas=r}}else{if(void 0!==t.maxFeePerGas||void 0!==t.maxPriorityFeePerGas)throw new da;if(void 0===t.gasPrice){const t=await m(),{gasPrice:n}=await va(e,{block:t,chain:o,request:f,type:"legacy"});f.gasPrice=n}}return l.includes("gas")&&void 0===a&&(f.gas=await Ve(e,Wa,"estimateGas")({...f,account:d?{address:d.address,type:"json-rpc"}:d})),la(f),delete f.parameters,f}async function Wa(e,t){const{account:n=e.account}=t,r=n?hr(n):void 0;try{const{accessList:n,authorizationList:o,blobs:a,blobVersionedHashes:s,blockNumber:i,blockTag:c,data:l,gas:u,gasPrice:d,maxFeePerBlobGas:f,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:m,value:g,stateOverride:b,...y}=await Ga(e,{...t,parameters:"local"===r?.type?void 0:["blobVersionedHashes"]}),w=("bigint"==typeof i?Wt(i):void 0)||c,v=ia(b),x=await(async()=>y.to?y.to:o&&o.length>0?await jo({authorization:o[0]}).catch(()=>{throw new et("`to` is required. Could not infer from `authorizationList`")}):void 0)();la(t);const E=e.chain?.formatters?.transactionRequest?.format,P=(E||oa)({...na(y,{format:E}),from:r?.address,accessList:n,authorizationList:o,blobs:a,blobVersionedHashes:s,data:l,gas:u,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=ta(e,n);return t instanceof ea?e:t})();return new Do(r,{docsPath:t,...n})}(n,{...t,account:r,chain:e.chain})}}function qa(e,t){if(!qn(e,{strict:!1}))throw new Ln({address:e});if(!qn(t,{strict:!1}))throw new Ln({address:t});return e.toLowerCase()===t.toLowerCase()}const Va="/docs/contract/decodeEventLog";function Ha(e){const{abi:t,data:n,strict:r,topics:o}=e,a=r??!0,[s,...i]=o;if(!s)throw new ft({docsPath:Va});const c=t.find(e=>"event"===e.type&&s===Mn(He(e)));if(!c||!("name"in c)||"event"!==c.type)throw new ht(s,{docsPath:Va});const{name:l,inputs:u}=c,d=u?.some(e=>!("name"in e&&e.name)),f=d?[]:{},h=u.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 xt({abiItem:c,param:t});f[d?n:t.name||n]=Ya({param:t,value:r})}const p=u.filter(e=>!("indexed"in e&&e.indexed));if(p.length>0)if(n&&"0x"!==n)try{const e=Nr(p,n);if(e)if(d)for(let t=0;t<u.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(a){if(e instanceof ot||e instanceof vr)throw new vt({abiItem:c,data:n,params:p,size:Ze(n)});throw e}}else if(a)throw new vt({abiItem:c,data:"0x",params:p,size:0});return{eventName:l,args:Object.values(f).length>0?f:void 0}}function Ya({param:e,value:t}){if("string"===e.type||"bytes"===e.type||"tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))return t;return(Nr([e],t)||[])[0]}function Ka(e){const{abi:t,args:n,logs:r,strict:o=!0}=e,a=(()=>{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]===Mn(t));if(!r)return null;const s=Ha({...e,abi:[r],strict:o});return a&&!a.includes(s.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?qa(t,n):"string"===e.type||"bytes"===e.type?On(Yt(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 a=n[r];if(!a)return!1;return(Array.isArray(e)?e:[e]).some(e=>o(a,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 a=n.find(t=>t.name===e);if(!a)return!1;return(Array.isArray(r)?r:[r]).some(n=>o(a,n,t[e]))})}({args:s.args,inputs:r.inputs,matchArgs:n})?{...s,...e}:null}catch(t){let n,r;if(t instanceof ht)return null;if(t instanceof vt||t instanceof xt){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 Za(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 Ja(e,{address:t,blockHash:n,fromBlock:r,toBlock:o,event:a,events:s,args:i,strict:c}={}){const l=c??!1,u=s??(a?[a]:void 0);let d,f=[];if(u){const e=u.flatMap(e=>lr({abi:[e],eventName:e.name,args:s?void 0:i}));f=[e],a&&(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?Wt(r):r,toBlock:"bigint"==typeof o?Wt(o):o}]});const h=d.map(e=>Za(e));return u?Ka({abi:u,args:i,logs:h,strict:l}):h}async function Qa(e,t){const{abi:n,address:r,args:o,blockHash:a,eventName:s,fromBlock:i,toBlock:c,strict:l}=t,u=s?ar({abi:n,name:s}):void 0,d=u?void 0:n.filter(e=>"event"===e.type);return Ve(e,Ja,"getLogs")({address:r,args:o,blockHash:a,event:u,events:d,fromBlock:i,toBlock:c,strict:l})}const Xa="/docs/contract/decodeFunctionResult";function es(e){const{abi:t,args:n,functionName:r,data:o}=e;let a=t[0];if(r){const e=ar({abi:t,args:n,name:r});if(!e)throw new mt(r,{docsPath:Xa});a=e}if("function"!==a.type)throw new mt(void 0,{docsPath:Xa});if(!a.outputs)throw new gt(a.name,{docsPath:Xa});const s=Nr(a.outputs,o);return s&&s.length>1?s:s&&1===s.length?s[0]:void 0}
4
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ts=BigInt(0),ns=BigInt(1);function rs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function os(e){if(!rs(e))throw new Error("Uint8Array expected")}function as(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function ss(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function is(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?ts:BigInt("0x"+e)}const cs="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,ls=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function us(e){if(os(e),cs)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=ls[e[n]];return t}const ds=48,fs=57,hs=65,ps=70,ms=97,gs=102;function bs(e){return e>=ds&&e<=fs?e-ds:e>=hs&&e<=ps?e-(hs-10):e>=ms&&e<=gs?e-(ms-10):void 0}function ys(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(cs)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=bs(e.charCodeAt(o)),a=bs(e.charCodeAt(o+1));if(void 0===n||void 0===a){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+a}return r}function ws(e){return is(us(e))}function vs(e){return os(e),is(us(Uint8Array.from(e).reverse()))}function xs(e,t){return ys(e.toString(16).padStart(2*t,"0"))}function Es(e,t){return xs(e,t).reverse()}function Ps(e,t,n){let r;if("string"==typeof t)try{r=ys(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!rs(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 ks(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];os(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 As=e=>"bigint"==typeof e&&ts<=e;function Is(e,t,n){return As(e)&&As(t)&&As(n)&&t<=e&&e<n}function Ns(e,t,n,r){if(!Is(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const Ss=e=>(ns<<BigInt(e))-ns,Ts=e=>new Uint8Array(e),Bs=e=>Uint8Array.from(e);const Cs={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||rs(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 $s(e,t,n={}){const r=(t,n,r)=>{const o=Cs[n];if("function"!=typeof o)throw new Error("invalid validator function");const a=e[t];if(!(r&&void 0===a||o(a,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+a)};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 Os(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const a=e(n,...r);return t.set(n,a),a}}class _s extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof _s){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 _s&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${r??""}`,a=[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(a,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 Rs(this,e)}}function Rs(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?Rs(e.cause,t):t?null:e}function zs(e,t){if(Xs(e)>t)throw new ii({givenSize:Xs(e),maxSize:t})}const Ms=48,Ls=57,Fs=65,Us=70,js=97,Ds=102;function Gs(e){return e>=Ms&&e<=Ls?e-Ms:e>=Fs&&e<=Us?e-(Fs-10):e>=js&&e<=Ds?e-(js-10):void 0}function Ws(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 qs(e,t){if(wi(e)>t)throw new Ii({givenSize:wi(e),maxSize:t})}function Vs(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 Si({size:Math.ceil(o.length/2),targetSize:r,type:"Hex"});return`0x${o["right"===n?"padEnd":"padStart"](2*r,"0")}`}function Hs(e,t,n){return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString()+"#__bigint":t,n)}const Ys=new TextDecoder,Ks=new TextEncoder;function Zs(e){return e instanceof Uint8Array?e:"string"==typeof e?Js(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}function Js(e,t={}){const{size:n}=t;let r=e;n&&(qs(e,n),r=bi(e,n));let o=r.slice(2);o.length%2&&(o=`0${o}`);const a=o.length/2,s=new Uint8Array(a);for(let e=0,t=0;e<a;e++){const n=Gs(o.charCodeAt(t++)),r=Gs(o.charCodeAt(t++));if(void 0===n||void 0===r)throw new _s(`Invalid byte sequence ("${o[t-2]}${o[t-1]}" in "${o}").`);s[e]=16*n+r}return s}function Qs(e,t={}){const{size:n}=t,r=Ks.encode(e);return"number"==typeof n?(zs(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 ci({size:e.length,targetSize:r,type:"Bytes"});const o=new Uint8Array(r);for(let t=0;t<r;t++){const a="right"===n;o[a?t:r-t-1]=e[a?t:e.length-t-1]}return o}(e,{dir:"right",size:t})}(r,n)):r}function Xs(e){return e.length}function ei(e,t,n,r={}){const{strict:o}=r;return e.slice(t,n)}function ti(e,t={}){const{size:n}=t;void 0!==n&&zs(e,n);return vi(hi(e,t),t)}function ni(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&(zs(r,n),r=ai(r)),r.length>1||r[0]>1)throw new si(r);return Boolean(r[0])}function ri(e,t={}){const{size:n}=t;void 0!==n&&zs(e,n);return xi(hi(e,t),t)}function oi(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&(zs(r,n),r=Ws(r,{dir:"right"})),Ys.decode(r)}function ai(e){return Ws(e,{dir:"left"})}class si extends _s{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 ii=class extends _s{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"})}},ci=class extends _s{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}};const li=new TextEncoder,ui=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function di(...e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function fi(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(qs(n,t.size),gi(n,t.size)):n}function hi(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=ui[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(qs(r,t.size),bi(r,t.size)):r}function pi(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let a;r?a=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(a=BigInt(Number.MAX_SAFE_INTEGER));const s="bigint"==typeof a&&n?-a-1n:0;if(a&&o>a||o<s){const t="bigint"==typeof e?"n":"";throw new Pi({max:a?`${a}${t}`:void 0,min:`${s}${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?gi(i,r):i}function mi(e,t={}){return hi(li.encode(e),t)}function gi(e,t){return Vs(e,{dir:"left",size:t})}function bi(e,t){return Vs(e,{dir:"right",size:t})}function yi(e,t,n,r={}){const{strict:o}=r;!function(e,t){if("number"==typeof t&&t>0&&t>wi(e)-1)throw new Ni({offset:t,position:"start",size:wi(e)})}(e,t);const a=`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&&wi(e)!==n-t)throw new Ni({offset:n,position:"end",size:wi(e)})}(a,t,n),a}function wi(e){return Math.ceil((e.length-2)/2)}function vi(e,t={}){const{signed:n}=t;t.size&&qs(e,t.size);const r=BigInt(e);if(!n)return r;const o=(e.length-2)/2,a=(1n<<8n*BigInt(o))-1n;return r<=a>>1n?r:r-a-1n}function xi(e,t={}){const{signed:n,size:r}=t;return Number(n||r?vi(e,t):e)}function Ei(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new ki(e);if("string"!=typeof e)throw new ki(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new Ai(e);if(!e.startsWith("0x"))throw new Ai(e)}(e,{strict:n}),!0}catch{return!1}}class Pi extends _s{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 ki extends _s{constructor(e){super(`Value \`${"object"==typeof e?Hs(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 Ai extends _s{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 Ii extends _s{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 Ni extends _s{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 Si extends _s{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 Ti(e){return{address:e.address,amount:pi(e.amount),index:pi(e.index),validatorIndex:pi(e.validatorIndex)}}function Bi(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:pi(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:pi(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:pi(e.gasLimit)},..."bigint"==typeof e.number&&{number:pi(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:pi(e.prevRandao)},..."bigint"==typeof e.time&&{time:pi(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(Ti)}}}const Ci=[{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"}],$i=[{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"}]}],Oi=[{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"}],_i=[...Oi,{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"}]}],Ri=[...Oi,{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"}]}],zi=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],Mi=[{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"}]}],Li=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],Fi=[{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"}],Ui="0x82ad56cb",ji="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",Di="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",Gi="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",Wi="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class qi extends et{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 Vi extends et{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}const Hi="/docs/contract/encodeDeployData";function Yi(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 nt({docsPath:Hi});if(!("inputs"in o))throw new rt({docsPath:Hi});if(!o.inputs||0===o.inputs.length)throw new rt({docsPath:Hi});return Hn([r,er(o.inputs,n)])}function Ki({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new qi({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new qi({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function Zi(e,{docsPath:t,...n}){const r=(()=>{const t=ta(e,n);return t instanceof ea?e:t})();return new Kr(r,{docsPath:t,...n})}function Ji(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const Qi=new Map;function Xi({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:o}){const a=async()=>{const t=i();s();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)}})},s=()=>Qi.delete(t),i=()=>Qi.get(t)||[],c=e=>Qi.set(t,[...i(),e]);return{flush:s,async schedule(e){const{promise:t,resolve:o,reject:s}=Ji(),l=n?.([...i().map(({args:e})=>e),e]);l&&a();return i().length>0?(c({args:e,resolve:o,reject:s}),t):(c({args:e,resolve:o,reject:s}),setTimeout(a,r),t)}}}async function ec(e,t){const{account:n=e.account,authorizationList:r,batch:o=Boolean(e.batch?.multicall),blockNumber:a,blockTag:s=e.experimental_blockTag??"latest",accessList:i,blobs:c,blockOverrides:l,code:u,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?hr(n):void 0;if(u&&(f||h))throw new et("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(u&&v)throw new et("Cannot provide both `code` & `to` as parameters.");const A=u&&d,I=f&&h&&v&&d,N=A||I,S=A?tc({code:u,data:d}):I?function(e){const{data:t,factory:n,factoryData:r,to:o}=e;return Yi({abi:Ge(["constructor(address, bytes, address, bytes)"]),bytecode:Di,args:[o,t,n,r]})}({data:d,factory:f,factoryData:h,to:v}):d;try{la(t);const n=("bigint"==typeof a?Wt(a):void 0)||s,u=l?Bi(l):void 0,d=ia(E),f=e.chain?.formatters?.transactionRequest?.format,h=(f||oa)({...na(P,{format:f}),from:k?.address,accessList:i,authorizationList:r,blobs:c,data:S,gas:p,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:b,maxPriorityFeePerGas:y,nonce:w,to:N?void 0:v,value:x});if(o&&function({request:e}){const{data:t,to:n,...r}=e;return!!t&&(!t.startsWith(Ui)&&(!!n&&!(Object.values(r).filter(e=>void 0!==e).length>0)))}({request:h})&&!d&&!u)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:a,blockTag:s=e.experimental_blockTag??"latest",data:i,to:c}=t,l=(()=>{if(r)return null;if(t.multicallAddress)return t.multicallAddress;if(e.chain)return Ki({blockNumber:a,chain:e.chain,contract:"multicall3"});throw new Vi})(),u="bigint"==typeof a?Wt(a):void 0,d=u||s,{schedule:f}=Xi({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=mr({abi:Ci,args:[n],functionName:"aggregate3"}),o=await e.request({method:"eth_call",params:[{...null===l?{data:tc({code:Wi,data:r})}:{to:l,data:r}},d]});return es({abi:Ci,args:[n],functionName:"aggregate3",data:o||"0x"})}}),[{returnData:h,success:p}]=await f({data:i,to:c});if(!p)throw new eo({data:h});return"0x"===h?{data:void 0}:{data:h}}(e,{...h,blockNumber:a,blockTag:s})}catch(e){if(!(e instanceof Vi||e instanceof qi))throw e}const A=(()=>{const e=[h,n];return d&&u?[...e,d,u]:d?[...e,d]:u?[...e,{},u]: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 et))return;const t=e.walk();return"object"==typeof t?.data?t.data?.data:t.data}(n),{offchainLookup:o,offchainLookupSignature:a}=await Promise.resolve().then(function(){return sl});if(!1!==e.ccipRead&&r?.slice(0,10)===a&&v)return{data:await o(e,{data:r,to:v})};if(N&&"0x101bb98d"===r?.slice(0,10))throw new Xr({factory:f});throw Zi(n,{...t,account:k,chain:e.chain})}}function tc(e){const{code:t,data:n}=e;return Yi({abi:Ge(["constructor(bytes, bytes)"]),bytecode:ji,args:[t,n]})}async function nc(e,t){const{abi:n,address:r,args:o,functionName:a,...s}=t,i=mr({abi:n,args:o,functionName:a});try{const{data:t}=await Ve(e,ec,"call")({...s,data:i,to:r});return es({abi:n,args:o,functionName:a,data:t||"0x"})}catch(e){throw _o(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/readContract",functionName:a})}}const rc=new Map,oc=new Map;let ac=0;function sc(e,t,n){const r=++ac,o=()=>rc.get(e)||[],a=()=>{const t=o();if(!t.some(e=>e.id===r))return;const n=oc.get(e);if(1===t.length&&n){const e=n();e instanceof Promise&&e.catch(()=>{})}(()=>{const t=o();rc.set(e,t.filter(e=>e.id!==r))})()},s=o();if(rc.set(e,[...s,{id:r,fns:t}]),s&&s.length>0)return a;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&&oc.set(e,c),a}async function ic(e){return new Promise(t=>setTimeout(t,e))}function cc(e,{emitOnBegin:t,initialWaitTime:n,interval:r}){let o=!0;const a=()=>o=!1;return(async()=>{let s;t&&(s=await e({unpoll:a}));const i=await(n?.(s))??r;await ic(i);const c=async()=>{o&&(await e({unpoll:a}),await ic(r),c())};c()})(),a}const lc=new Map,uc=new Map;async function dc(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,lc),r=t(e,uc);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 a=r.promise.get();a||(a=e(),r.promise.set(a));try{const e=await a;return r.response.set({created:new Date,data:e}),e}finally{r.promise.clear()}}async function fc(e,{cacheTime:t=e.cacheTime}={}){const n=await dc(()=>e.request({method:"eth_blockNumber"}),{cacheKey:(r=e.uid,`blockNumber.${r}`),cacheTime:t});var r;return BigInt(n)}async function hc(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=>Za(e));return"abi"in t&&t.abi?Ka({abi:t.abi,logs:o,strict:n}):o}async function pc(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function mc(e,{delay:t=100,retryCount:n=2,shouldRetry:r=()=>!0}={}){return new Promise((o,a)=>{const s=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 ic(n),s({count:i+1})})({error:e});a(e)}};s()})}const gc={"0x0":"reverted","0x1":"success"};function bc(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=>Za(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Ft(e.transactionIndex):null,status:e.status?gc[e.status]:null,type:e.type?pa[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}let yc,wc=256;function vc(e=11){if(!yc||wc+e>512){yc="",wc=0;for(let e=0;e<256;e++)yc+=(256+256*Math.random()|0).toString(16).substring(1)}return yc.substring(wc,wc+++e)}function xc(e){if(!(e instanceof et))return!1;const t=e.walk(e=>e instanceof Jr);return t instanceof Jr&&("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 Ec="/docs/contract/encodeErrorResult";function Pc(e){const{abi:t,errorName:n,args:r}=e;let o=t[0];if(n){const e=ar({abi:t,args:r,name:n});if(!e)throw new ut(n,{docsPath:Ec});o=e}if("error"!==o.type)throw new ut(void 0,{docsPath:Ec});const a=He(o),s=or(a);let i="0x";if(r&&r.length>0){if(!o.inputs)throw new lt(o.name,{docsPath:Ec});i=er(o.inputs,r)}return Hn([s,i])}const kc="/docs/contract/encodeFunctionResult";const Ac="x-batch-gateway:true";async function Ic(e){const{data:t,ccipRequest:n}=e,{args:[r]}=function(e){const{abi:t,data:n}=e,r=Yn(n,0,4),o=t.find(e=>"function"===e.type&&r===or(He(e)));if(!o)throw new bt(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:o.name,args:"inputs"in o&&o.inputs&&o.inputs.length>0?Nr(o.inputs,Yn(n,4)):void 0}}({abi:$i,data:t}),o=[],a=[];return await Promise.all(r.map(async(e,t)=>{try{a[t]=e.urls.includes(Ac)?await Ic({data:e.data,ccipRequest:n}):await n(e),o[t]=!1}catch(e){o[t]=!0,a[t]="HttpRequestError"===(r=e).name&&r.status?Pc({abi:$i,errorName:"HttpError",args:[r.status,r.shortMessage]}):Pc({abi:[br],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=ar({abi:t,name:n});if(!e)throw new mt(n,{docsPath:kc});o=e}if("function"!==o.type)throw new mt(void 0,{docsPath:kc});if(!o.outputs)throw new gt(o.name,{docsPath:kc});const a=(()=>{if(0===o.outputs.length)return[];if(1===o.outputs.length)return[r];if(Array.isArray(r))return r;throw new kt(r)})();return er(o.outputs,a)}({abi:$i,functionName:"query",result:[o,a]})}function Nc(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 Ke(t)?t:null}function Sc(e){let t=new Uint8Array(32).fill(0);if(!e)return Gt(t);const n=e.split(".");for(let e=n.length-1;e>=0;e-=1){const r=Nc(n[e]),o=r?Yt(r):On(Qt(n[e]),"bytes");t=On(Vn([t,o]),"bytes")}return Gt(t)}function Tc(e){return`[${e.slice(2)}]`}function Bc(e){const t=new Uint8Array(32).fill(0);return e?Nc(e)||On(Qt(e)):Gt(t)}function Cc(e){const t=e.replace(/^\.|\.$/gm,"");if(0===t.length)return new Uint8Array(1);const n=new Uint8Array(Qt(t).byteLength+2);let r=0;const o=t.split(".");for(let e=0;e<o.length;e++){let t=Qt(o[e]);t.byteLength>255&&(t=Qt(Tc(Bc(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 $c extends et{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 Oc extends et{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`,{name:"EnsAvatarInvalidNftUriError"})}}class _c extends et{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 Rc extends et{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const zc=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,Mc=/^(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>\/.*)?$/,Lc=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,Fc=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;function Uc(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function jc({uri:e,gatewayUrls:t}){const n=Lc.test(e);if(n)return{uri:e,isOnChain:!0,isEncoded:n};const r=Uc(t?.ipfs,"https://ipfs.io"),o=Uc(t?.arweave,"https://arweave.net"),a=e.match(zc),{protocol:s,subpath:i,target:c,subtarget:l=""}=a?.groups||{},u="ipns:/"===s||"ipns/"===i,d="ipfs:/"===s||"ipfs/"===i||Mc.test(e);if(e.startsWith("http")&&!u&&!d){let n=e;return t?.arweave&&(n=e.replace(/https:\/\/arweave.net/g,t?.arweave)),{uri:n,isOnChain:!1,isEncoded:!1}}if((u||d)&&c)return{uri:`${r}/${u?"ipns":"ipfs"}/${c}${l}`,isOnChain:!1,isEncoded:!1};if("ar:/"===s&&c)return{uri:`${o}/${c}${l||""}`,isOnChain:!1,isEncoded:!1};let f=e.replace(Fc,"");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 _c({uri:e})}function Dc(e){if("object"!=typeof e||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new $c({data:e});return e.image||e.image_url||e.image_data}async function Gc({gatewayUrls:e,uri:t}){const{uri:n,isOnChain:r}=jc({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 _c({uri:t})}async function Wc(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("/"),[a,s]=n.split(":"),[i,c]=r.split(":");if(!a||"eip155"!==a.toLowerCase())throw new Oc({reason:"Only EIP-155 supported"});if(!s)throw new Oc({reason:"Chain ID not found"});if(!c)throw new Oc({reason:"Contract address not found"});if(!o)throw new Oc({reason:"Token ID not found"});if(!i)throw new Oc({reason:"ERC namespace not found"});return{chainID:Number.parseInt(s,10),namespace:i.toLowerCase(),contractAddress:c,tokenID:o}}(n),o=await async function(e,{nft:t}){if("erc721"===t.namespace)return nc(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 nc(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 Rc({namespace:t.namespace})}(e,{nft:r}),{uri:a,isOnChain:s,isEncoded:i}=jc({uri:o,gatewayUrls:t});if(s&&(a.includes("data:application/json;base64,")||a.startsWith("{"))){const e=i?atob(a.replace("data:application/json;base64,","")):a;return Gc({uri:Dc(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 Gc({gatewayUrls:e,uri:Dc(n)})}catch{throw new _c({uri:t})}}({gatewayUrls:t,uri:a.replace(/(?:0x)?{id}/,c)})}(e,{gatewayUrls:t,record:n}):Gc({uri:n,gatewayUrls:t})}async function qc(e,t){const{blockNumber:n,blockTag:r,key:o,name:a,gatewayUrls:s,strict:i}=t,{chain:c}=e,l=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Ki({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),u=c?.ensTlds;if(u&&!u.some(e=>a.endsWith(e)))return null;try{const t={address:l,abi:_i,args:[jt(Cc(a)),mr({abi:zi,functionName:"text",args:[Sc(a),o]}),s??[Ac]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},i=Ve(e,nc,"readContract"),c=await i(t);if("0x"===c[0])return null;const u=es({abi:zi,functionName:"text",data:c[0]});return""===u?null:u}catch(e){if(i)throw e;if(xc(e))return null;throw e}}async function Vc(e,t){const{account:n=e.account,blockNumber:r,blockTag:o="latest",blobs:a,data:s,gas:i,gasPrice:c,maxFeePerBlobGas:l,maxFeePerGas:u,maxPriorityFeePerGas:d,to:f,value:h,...p}=t,m=n?hr(n):void 0;try{la(t);const n=("bigint"==typeof r?Wt(r):void 0)||o,g=e.chain?.formatters?.transactionRequest?.format,b=(g||oa)({...na(p,{format:g}),from:m?.address,blobs:a,data:s,gas:i,gasPrice:c,maxFeePerBlobGas:l,maxFeePerGas:u,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 Zi(n,{...t,account:m,chain:e.chain})}}async function Hc(e,{address:t,args:n,event:r,events:o,fromBlock:a,strict:s,toBlock:i}={}){const c=o??(r?[r]:void 0),l=dr(e,{method:"eth_newFilter"});let u=[];if(c){const e=c.flatMap(e=>lr({abi:[e],eventName:e.name,args:n}));u=[e],r&&(u=u[0])}const d=await e.request({method:"eth_newFilter",params:[{address:t,fromBlock:"bigint"==typeof a?Wt(a):a,toBlock:"bigint"==typeof i?Wt(i):i,...u.length?{topics:u}:{}}]});return{abi:c,args:n,eventName:r?r.name:void 0,fromBlock:a,id:d,request:l(d),strict:Boolean(s),toBlock:i,type:"event"}}async function Yc(e){const t=dr(e,{method:"eth_newPendingTransactionFilter"}),n=await e.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:t(n),type:"transaction"}}async function Kc(e,{address:t,blockNumber:n,blockTag:r="latest"}){const o=void 0!==n?Wt(n):void 0,a=await e.request({method:"eth_getCode",params:[t,o||r]},{dedupe:Boolean(o)});if("0x"!==a)return a}class Zc extends et{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 Jc=[{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"}];async function Qc(e,{blockCount:t,blockNumber:n,blockTag:r="latest",rewardPercentiles:o}){const a="bigint"==typeof n?Wt(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:[Wt(t),a||r,o]},{dedupe:Boolean(a)}))}const Xc=new Fn(8192);function el(e,t={}){return async(n,r={})=>{const{dedupe:o=!1,methods:a,retryDelay:s=150,retryCount:i=3,uid:c}={...t,...r},{method:l}=n;if(a?.exclude?.includes(l))throw new go(new Error("method not supported"),{method:l});if(a?.include&&!a.include.includes(l))throw new go(new Error("method not supported"),{method:l});return function(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(Xc.get(n))return Xc.get(n);const r=e().finally(()=>Xc.delete(n));return Xc.set(n,r),r}(()=>mc(async()=>{try{return await e(n)}catch(e){const t=e;switch(t.code){case so.code:throw new so(t);case io.code:throw new io(t);case co.code:throw new co(t,{method:n.method});case lo.code:throw new lo(t);case uo.code:throw new uo(t);case fo.code:throw new fo(t);case ho.code:throw new ho(t);case po.code:throw new po(t);case mo.code:throw new mo(t);case go.code:throw new go(t,{method:n.method});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 No.code:throw new No(t);case So.code:throw new So(t);case To.code:throw new To(t);case Bo.code:throw new Bo(t);case Co.code:throw new Co(t);case 5e3:throw new wo(t);default:if(e instanceof et)throw e;throw new $o(t)}}},{delay:({count:e,error:t})=>{if(t&&t instanceof to){const e=t?.headers?.get("Retry-After");if(e?.match(/\d/))return 1e3*Number.parseInt(e,10)}return(1<<e)*s},retryCount:i,shouldRetry:({error:e})=>function(e){if("code"in e&&"number"==typeof e.code)return-1===e.code||(e.code===bo.code||e.code===uo.code);if(e instanceof to&&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?Vt(`${c}.${Or(n)}`):void 0})}}class tl extends et{constructor({callbackSelector:e,cause:t,data:n,extraData:r,sender:o,urls:a}){super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],t.metaMessages?.length?"":[],"Offchain Gateway Call:",a&&[" Gateway URL(s):",...a.map(e=>` ${e}`)],` Sender: ${o}`,` Data: ${n}`,` Callback selector: ${e}`,` Extra data: ${r}`].flat(),name:"OffchainLookupError"})}}class nl extends et{constructor({result:e,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${t}`,`Response: ${Or(e)}`],name:"OffchainLookupResponseMalformedError"})}}class rl extends et{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 ol={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 al({data:e,sender:t,urls:n}){let r=new Error("An unknown error occurred.");for(let o=0;o<n.length;o++){const a=n[o],s=a.includes("{data}")?"GET":"POST",i="POST"===s?{data:e,sender:t}:void 0,c="POST"===s?{"Content-Type":"application/json"}:{};try{const n=await fetch(a.replace("{sender}",t.toLowerCase()).replace("{data}",e),{body:JSON.stringify(i),headers:c,method:s});let o;if(o=n.headers.get("Content-Type")?.startsWith("application/json")?(await n.json()).data:await n.text(),!n.ok){r=new to({body:i,details:o?.error?Or(o.error):n.statusText,headers:n.headers,status:n.status,url:a});continue}if(!Ke(o)){r=new nl({result:o,url:a});continue}return o}catch(e){r=new to({body:i,details:e.message,url:a})}}throw r}var sl=Object.freeze({__proto__:null,ccipRequest:al,offchainLookup:async function(e,{blockNumber:t,blockTag:n,data:r,to:o}){const{args:a}=$r({data:r,abi:[ol]}),[s,i,c,l,u]=a,{ccipRead:d}=e,f=d&&"function"==typeof d?.request?d.request:al;try{if(!qa(o,s))throw new rl({sender:s,to:o});const r=i.includes(Ac)?await Ic({data:c,ccipRequest:f}):await f({data:c,sender:s,urls:i}),{data:a}=await ec(e,{blockNumber:t,blockTag:n,data:Vn([l,er([{type:"bytes"},{type:"bytes"}],[r,u])]),to:o});return a}catch(e){throw new tl({callbackSelector:l,cause:e,data:r,extraData:u,sender:s,urls:i})}},offchainLookupAbiItem:ol,offchainLookupSignature:"0x556f1830"});function il(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const cl=il();function ll(e,t={}){return{async request(n){const{body:r,fetchFn:o=t.fetchFn??fetch,onRequest:a=t.onRequest,onResponse:s=t.onResponse,timeout:i=t.timeout??1e4}=n,c={...t.fetchOptions??{},...n.fetchOptions??{}},{headers:l,method:u,signal:d}=c;try{const t=await function(e,{errorInstance:t=new Error("timed out"),timeout:n,signal:r}){return new Promise((o,a)=>{(async()=>{let s;try{const t=new AbortController;n>0&&(s=setTimeout(()=>{r&&t.abort()},n)),o(await e({signal:t?.signal||null}))}catch(e){"AbortError"===e?.name&&a(t),a(e)}finally{clearTimeout(s)}})()})}(async({signal:t})=>{const n={...c,body:Array.isArray(r)?Or(r.map(e=>({jsonrpc:"2.0",id:e.id??cl.take(),...e}))):Or({jsonrpc:"2.0",id:r.id??cl.take(),...r}),headers:{"Content-Type":"application/json",...l},method:u||"POST",signal:d||(i>0?t:null)},s=new Request(e,n),f=await(a?.(s,n))??{...n,url:e};return await o(f.url??e,f)},{errorInstance:new ro({body:r,url:e}),timeout:i,signal:!0});let n;if(s&&await s(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 to({body:r,details:Or(n.error)||t.statusText,headers:t.headers,status:t.status,url:e});return n}catch(t){if(t instanceof to)throw t;if(t instanceof ro)throw t;throw new to({body:r,cause:t,url:e})}}}}function ul(e,t){return On(function(e){const t="string"==typeof e?Vt(e):"string"==typeof e.raw?e.raw:Gt(e.raw);return Vn([Vt(`Ethereum Signed Message:\n${Ze(t)}`),t])}(e),t)}class dl extends et{constructor({domain:e}){super(`Invalid domain "${Or(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class fl extends et{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 hl extends et{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function pl({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 ml(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new hl({type:e})}function gl(e){const{domain:t={},message:n,primaryType:r}=e,o={EIP712Domain:pl({domain:t}),...e.types};!function(e){const{domain:t,message:n,primaryType:r,types:o}=e,a=(e,t)=>{for(const n of e){const{name:e,type:r}=n,s=t[e],i=r.match(Xn);if(i&&("number"==typeof s||"bigint"==typeof s)){const[e,t,n]=i;Wt(s,{signed:"int"===t,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof s&&!qn(s))throw new Ln({address:s});const c=r.match(Qn);if(c){const[e,t]=c;if(t&&Ze(s)!==Number.parseInt(t,10))throw new wt({expectedSize:Number.parseInt(t,10),givenSize:Ze(s)})}const l=o[r];l&&(ml(r),a(l,s))}};if(o.EIP712Domain&&t){if("object"!=typeof t)throw new dl({domain:t});a(o.EIP712Domain,t)}if("EIP712Domain"!==r){if(!o[r])throw new fl({primaryType:r,types:o});a(o[r],n)}}({domain:t,message:n,primaryType:r,types:o});const a=["0x1901"];return t&&a.push(function({domain:e,types:t}){return bl({data:e,primaryType:"EIP712Domain",types:t})}({domain:t,types:o})),"EIP712Domain"!==r&&a.push(bl({data:n,primaryType:r,types:o})),On(Vn(a))}function bl({data:e,primaryType:t,types:n}){return On(yl({data:e,primaryType:t,types:n}))}function yl({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],o=[wl({primaryType:t,types:n})];for(const a of n[t]){const[t,s]=xl({types:n,name:a.name,type:a.type,value:e[a.name]});r.push(t),o.push(s)}return er(r,o)}function wl({primaryType:e,types:t}){const n=jt(function({primaryType:e,types:t}){let n="";const r=vl({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 On(n)}function vl({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])vl({primaryType:e.type,types:t},n);return n}function xl({types:e,name:t,type:n,value:r}){if(void 0!==e[n])return[{type:"bytes32"},On(yl({data:r,primaryType:n,types:e}))];if("bytes"===n){return[{type:"bytes32"},On(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},On(jt(r))];if(n.lastIndexOf("]")===n.length-1){const o=n.slice(0,n.lastIndexOf("[")),a=r.map(n=>xl({name:t,type:o,types:e,value:n}));return[{type:"bytes32"},On(er(a.map(([e])=>e),a.map(([,e])=>e)))]}return[{type:n},r]}class El 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 Pl={checksum:new El(8192)}.checksum;function kl(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=$n(Zs(e));return"Bytes"===n?r:hi(r)}const Al=/^0x[a-fA-F0-9]{40}$/;function Il(e,t={}){const{strict:n=!0}=t;if(!Al.test(e))throw new Tl({address:e,cause:new Bl});if(n){if(e.toLowerCase()===e)return;if(Nl(e)!==e)throw new Tl({address:e,cause:new Cl})}}function Nl(e){if(Pl.has(e))return Pl.get(e);Il(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=kl(Qs(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 Pl.set(e,o),o}function Sl(e,t={}){const{strict:n=!0}=t??{};try{return Il(e,{strict:n}),!0}catch{return!1}}class Tl extends _s{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 Bl extends _s{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 Cl extends _s{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const $l=/^(.*)\[([0-9]*)\]$/,Ol=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,_l=/^(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)?$/,Rl=2n**256n-1n;function zl(e,t,n){const{checksumAddress:r,staticPosition:o}=n,a=jl(t.type);if(a){const[n,s]=a;return function(e,t,n){const{checksumAddress:r,length:o,staticPosition:a}=n;if(!o){const n=a+ri(e.readBytes(Ll)),o=n+Ml;e.setPosition(n);const s=ri(e.readBytes(Ml)),i=Dl(t);let c=0;const l=[];for(let n=0;n<s;++n){e.setPosition(o+(i?32*n:c));const[a,s]=zl(e,t,{checksumAddress:r,staticPosition:o});c+=s,l.push(a)}return e.setPosition(a+32),[l,32]}if(Dl(t)){const n=a+ri(e.readBytes(Ll)),s=[];for(let a=0;a<o;++a){e.setPosition(n+32*a);const[o]=zl(e,t,{checksumAddress:r,staticPosition:n});s.push(o)}return e.setPosition(a+32),[s,32]}let s=0;const i=[];for(let n=0;n<o;++n){const[n,o]=zl(e,t,{checksumAddress:r,staticPosition:a+s});s+=o,i.push(n)}return[i,s]}(e,{...t,type:s},{checksumAddress:r,length:n,staticPosition:o})}if("tuple"===t.type)return function(e,t,n){const{checksumAddress:r,staticPosition:o}=n,a=0===t.components.length||t.components.some(({name:e})=>!e),s=a?[]:{};let i=0;if(Dl(t)){const n=o+ri(e.readBytes(Ll));for(let o=0;o<t.components.length;++o){const c=t.components[o];e.setPosition(n+i);const[l,u]=zl(e,c,{checksumAddress:r,staticPosition:n});i+=u,s[a?o:c?.name]=l}return e.setPosition(o+32),[s,32]}for(let n=0;n<t.components.length;++n){const c=t.components[n],[l,u]=zl(e,c,{checksumAddress:r,staticPosition:o});s[a?n:c?.name]=l,i+=u}return[s,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?Nl(e):e;return[o(hi(ei(r,-20))),32]}(e,{checksum:r});if("bool"===t.type)return function(e){return[ni(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=ri(e.readBytes(32));e.setPosition(n+t);const r=ri(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[hi(o),32]}const a=hi(e.readBytes(Number.parseInt(o,10),32));return[a,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?ti(o,{signed:n}):ri(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=ri(e.readBytes(32)),r=t+n;e.setPosition(r);const o=ri(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const a=e.readBytes(o,32),s=oi(ai(a));return e.setPosition(t+32),[s,32]}(e,{staticPosition:o});throw new ru(t.type)}const Ml=32,Ll=32;function Fl({checksumAddress:e=!1,parameter:t,value:n}){const r=t,o=jl(r.type);if(o){const[t,a]=o;return function(e,t){const{checksumAddress:n,length:r,parameter:o}=t,a=null===r;if(!Array.isArray(e))throw new nu(e);if(!a&&e.length!==r)throw new Xl({expectedLength:r,givenLength:e.length,type:`${o.type}[${r}]`});let s=!1;const i=[];for(let t=0;t<e.length;t++){const r=Fl({checksumAddress:n,parameter:o,value:e[t]});r.dynamic&&(s=!0),i.push(r)}if(a||s){const e=Ul(i);if(a){const t=pi(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?di(t,e):t}}if(s)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:di(...i.map(({encoded:e})=>e))}}(n,{checksumAddress:e,length:t,parameter:{...r,type:a}})}if("tuple"===r.type)return function(e,t){const{checksumAddress:n,parameter:r}=t;let o=!1;const a=[];for(let t=0;t<r.components.length;t++){const s=r.components[t],i=Fl({checksumAddress:n,parameter:s,value:e[Array.isArray(e)?t:s.name]});a.push(i),i.dynamic&&(o=!0)}return{dynamic:o,encoded:o?Ul(a):di(...a.map(({encoded:e})=>e))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return Il(e,{strict:n}),{dynamic:!1,encoded:gi(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new _s(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:gi(fi(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=_l.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 Pi({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:pi(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=wi(e);if(!n){let t=e;return r%32!=0&&(t=bi(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:di(gi(pi(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new eu({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:bi(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=mi(e),n=Math.ceil(wi(t)/32),r=[];for(let e=0;e<n;e++)r.push(bi(yi(t,32*e,32*(e+1))));return{dynamic:!0,encoded:di(bi(pi(wi(t),{size:32})),...r)}}(n);throw new ru(r.type)}function Ul(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:wi(o)}const n=[],r=[];let o=0;for(let a=0;a<e.length;a++){const{dynamic:s,encoded:i}=e[a];s?(n.push(pi(t+o,{size:32})),r.push(i),o+=wi(i)):n.push(i)}return di(...n,...r)}function jl(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Dl(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(Dl);const n=jl(e.type);return!(!n||!Dl({...e,type:n[1]}))}const Gl={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 Vl({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new ql({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Wl({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 Wl({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 Wl extends _s{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class ql extends _s{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 Vl extends _s{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 Hl(e,t,n={}){const{as:r="Array",checksumAddress:o=!1}=n,a="string"==typeof t?Js(t):t,s=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(Gl);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}(a);if(0===Xs(a)&&e.length>0)throw new Ql;if(Xs(a)&&Xs(a)<32)throw new Jl({data:"string"==typeof t?t:hi(t),parameters:e,size:Xs(a)});let i=0;const c="Array"===r?[]:{};for(let t=0;t<e.length;++t){const n=e[t];s.setPosition(i);const[a,l]=zl(s,n,{checksumAddress:o,staticPosition:0});i+=l,"Array"===r?c.push(a):c[n.name??t]=a}return c}function Yl(e,t,n){const{checksumAddress:r=!1}={};if(e.length!==t.length)throw new tu({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(Fl({checksumAddress:e,parameter:t[o],value:n[o]}));return r}({checksumAddress:r,parameters:e,values:t}),a=Ul(o);return 0===a.length?"0x":a}function Kl(e,t){if(e.length!==t.length)throw new tu({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const o=e[r],a=t[r];n.push(Kl.encode(o,a))}return di(...n)}function Zl(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?qe(e):e}!function(e){e.encode=function e(t,n,r=!1){if("address"===t){const e=n;return Il(e),gi(e.toLowerCase(),r?32:0)}if("string"===t)return mi(n);if("bytes"===t)return n;if("bool"===t)return gi(fi(n),r?32:1);const o=t.match(_l);if(o){const[e,t,a="256"]=o,s=Number.parseInt(a,10)/8;return pi(n,{size:r?32:s,signed:"int"===t})}const a=t.match(Ol);if(a){const[e,t]=a;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new eu({expectedSize:Number.parseInt(t,10),value:n});return bi(n,r?32:0)}const s=t.match($l);if(s&&Array.isArray(n)){const[t,r]=s,o=[];for(let t=0;t<n.length;t++)o.push(e(r,n[t],!0));return 0===o.length?"0x":di(...o)}throw new ru(t)}}(Kl||(Kl={}));class Jl extends _s{constructor({data:e,parameters:t,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${re(t)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Ql extends _s{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Xl extends _s{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 eu extends _s{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${wi(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class tu extends _s{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 nu extends _s{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class ru extends _s{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 ou extends pn{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");rn(e.outputLen),rn(e.blockLen)}(e);const n=hn(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),cn(o)}update(e){return an(this),this.iHash.update(e),this}digestInto(e){an(this),on(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:a,outputLen:s}=this;return e.finished=r,e.destroyed=o,e.blockLen=a,e.outputLen=s,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 au=(e,t,n)=>new ou(e,t).update(n).digest();au.create=(e,t)=>new ou(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 on(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 sn(e,t){rn(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function an(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function cn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function un(e,t){return e<<32-t|e>>>t}function ln(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const dn=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=ln(e[t]);return e};function fn(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)),rn(e),e}class hn{}function pn(e){const t=t=>e().update(fn(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function mn(e=32){if(tn&&"function"==typeof tn.getRandomValues)return tn.getRandomValues(new Uint8Array(e));if(tn&&"function"==typeof tn.randomBytes)return Uint8Array.from(tn.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const gn=BigInt(0),bn=BigInt(1),yn=BigInt(2),wn=BigInt(7),vn=BigInt(256),xn=BigInt(113),En=[],Pn=[],kn=[];for(let e=0,t=bn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],En.push(2*(5*r+n)),Pn.push((e+1)*(e+2)/2%64);let o=gn;for(let e=0;e<7;e++)t=(t<<bn^(t>>wn)*xn)%vn,t&yn&&(o^=bn<<(bn<<BigInt(e))-bn);kn.push(o)}const An=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}=en(e[s],t);[r[s],o[s]]=[n,a]}return[r,o]}(kn,!0),In=An[0],Sn=An[1],Nn=(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),Tn=(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 $n extends hn{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,nn(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(){dn(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=Nn(s,a,1)^n[r],c=Tn(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=Pn[n],s=Nn(t,o,r),a=Tn(t,o,r),i=En[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]^=In[r],e[1]^=Sn[r]}an(n)}(this.state32,this.rounds),dn(this.state32),this.posOut=0,this.pos=0}update(e){on(this),rn(e=fn(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){on(this,!1),rn(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 nn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(sn(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,an(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:o,enableXOF:s}=this;return e||(e=new $n(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 Bn=(()=>{return e=1,t=136,n=32,pn(()=>new $n(t,e,n));var e,t,n})();function Cn(e,t){const n=t||"hex",r=Bn(Ye(e,{strict:!1})?Ht(e):e);return"bytes"===n?r:jt(r)}function On(e){return Cn(Ht(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 Xe("Unable to normalize signature.");return o}("string"==typeof e?e:re(e));function Rn(e){return On(_n(e))}const zn=Rn;let Mn=class extends Xe{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"})}},Fn=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 Ln=new Fn(8192);function jn(e,t){if(Ln.has(`${e}.${t}`))return Ln.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=Cn(Jt(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 Ln.set(`${e}.${t}`,s),s}function Un(e,t){if(!qn(e,{strict:!1}))throw new Mn({address:e});return jn(e,t)}const Dn=/^0x[a-fA-F0-9]{40}$/,Gn=new Fn(8192);function qn(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Gn.has(r))return Gn.get(r);const o=!(!Dn.test(e)||e.toLowerCase()!==e&&n&&jn(e)!==e);return Gn.set(r,o),o}function Vn(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 Hn(e,t,n,{strict:r}={}){return Ye(e,{strict:!1})?function(e,t,n,{strict:r}={}){Yn(e,t);const o=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;r&&Zn(o,t,n);return o}(e,t,n,{strict:r}):Kn(e,t,n,{strict:r})}function Yn(e,t){if("number"==typeof t&&t>0&&t>Ze(e)-1)throw new It({offset:t,position:"start",size:Ze(e)})}function Zn(e,t,n){if("number"==typeof t&&"number"==typeof n&&Ze(e)!==n-t)throw new It({offset:n,position:"end",size:Ze(e)})}function Kn(e,t,n,{strict:r}={}){Yn(e,t);const o=e.slice(t,n);return r&&Zn(o,t,n),o}const Jn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Qn=/^(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 Xn(e,t){if(e.length!==t.length)throw new it({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(er({param:e[r],value:t[r]}));return n}({params:e,values:t}),r=tr(n);return 0===r.length?"0x":r}function er({param:e,value:t}){const n=nr(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 Pt(e);if(!r&&e.length!==t)throw new st({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let o=!1;const s=[];for(let t=0;t<e.length;t++){const r=er({param:n,value:e[t]});r.dynamic&&(o=!0),s.push(r)}if(r||o){const e=tr(s);if(r){const t=Gt(s.length,{size:32});return{dynamic:!0,encoded:s.length>0?Vn([t,e]):t}}if(o)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Vn(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=er({param:s,value:e[Array.isArray(e)?o:s.name]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?tr(r):Vn(r.map(({encoded:e})=>e))}}(t,{param:e});if("address"===e.type)return function(e){if(!qn(e))throw new Mn({address:e});return{dynamic:!1,encoded:$t(e.toLowerCase())}}(t);if("bool"===e.type)return function(e){if("boolean"!=typeof e)throw new Xe(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:$t(Ut(e))}}(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const n=e.type.startsWith("int"),[,,r="256"]=Qn.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 Bt({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Gt(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=Ze(e);if(!n){let t=e;return r%32!=0&&(t=$t(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:Vn([$t(Gt(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new at({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:$t(e,{dir:"right"})}}(t,{param:e});if("string"===e.type)return function(e){const t=Vt(e),n=Math.ceil(Ze(t)/32),r=[];for(let e=0;e<n;e++)r.push($t(Hn(t,32*e,32*(e+1)),{dir:"right"}));return{dynamic:!0,encoded:Vn([$t(Gt(Ze(t),{size:32})),...r])}}(t);throw new xt(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function tr(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:Ze(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(Gt(t+o,{size:32})),r.push(i),o+=Ze(i)):n.push(i)}return Vn([...n,...r])}function nr(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const rr=e=>Hn(Rn(e),0,4);function or(e){const{abi:t,args:n=[],name:r}=e,o=Ye(r,{strict:!1}),s=t.filter(e=>o?"function"===e.type?rr(e)===r:"event"===e.type&&zn(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&&sr(t,r)});if(t){if(a&&"inputs"in a&&a.inputs){const t=ar(e.inputs,a.inputs,n);if(t)throw new bt({abiItem:e,type:t[0]},{abiItem:a,type:t[1]})}a=e}}return a||s[0]}function sr(e,t){const n=typeof e,r=t.type;switch(r){case"address":return qn(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)=>sr(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=>sr(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function ar(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 ar(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")))&&qn(n[r],{strict:!1}))())return a}}const ir="/docs/contract/encodeEventTopics";function cr(e){const{abi:t,eventName:n,args:r}=e;let o=t[0];if(n){const e=or({abi:t,name:n});if(!e)throw new ht(n,{docsPath:ir});o=e}if("event"!==o.type)throw new ht(void 0,{docsPath:ir});const s=We(o),a=zn(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)=>ur({param:e,value:t[n][o]})):void 0!==t[n]&&null!==t[n]?ur({param:e,value:t[n]}):null)??[])}return[a,...i]}function ur({param:e,value:t}){if("string"===e.type||"bytes"===e.type)return Cn(Ht(t));if("tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))throw new At(e.type);return Xn([e],[t])}function lr(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 dr(e,t){const{address:n,abi:r,args:o,eventName:s,fromBlock:a,strict:i,toBlock:c}=t,u=lr(e,{method:"eth_newFilter"}),l=s?cr({abi:r,args:o,eventName:s}):void 0,d=await e.request({method:"eth_newFilter",params:[{address:n,fromBlock:"bigint"==typeof a?Gt(a):a,toBlock:"bigint"==typeof c?Gt(c):c,topics:l}]});return{abi:r,args:o,eventName:s,id:d,request:u(d),strict:Boolean(i),type:"event"}}function fr(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const hr="/docs/contract/encodeFunctionData";function pr(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=or({abi:t,args:n,name:r});if(!e)throw new pt(r,{docsPath:hr});o=e}if("function"!==o.type)throw new pt(void 0,{docsPath:hr});return{abi:[o],functionName:rr(We(o))}}(e),o=n[0];return Wn([r,("inputs"in o&&o.inputs?Xn(o.inputs,t??[]):void 0)??"0x"])}const mr={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."},gr={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},br={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};let yr=class extends Xe{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}},wr=class extends Xe{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}},vr=class extends Xe{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}};const xr={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 vr({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new wr({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new yr({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 yr({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 Er(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(xr);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function Pr(e,t={}){void 0!==t.size&&zt(e,{size:t.size});return Mt(Dt(e,t),t)}function kr(e,t={}){let n=e;if(void 0!==t.size&&(zt(n,{size:t.size}),n=Rt(n)),n.length>1||n[0]>1)throw new Ct(n);return Boolean(n[0])}function Ar(e,t={}){void 0!==t.size&&zt(e,{size:t.size});return Ft(Dt(e,t),t)}function Ir(e,t){const n="string"==typeof t?Kt(t):t,r=Er(n);if(0===Ze(n)&&e.length>0)throw new ot;if(Ze(t)&&Ze(t)<32)throw new rt({data:"string"==typeof t?t:Dt(t),params:e,size:Ze(t)});let o=0;const s=[];for(let t=0;t<e.length;++t){const n=e[t];r.setPosition(o);const[a,i]=Sr(r,n,{staticPosition:0});o+=i,s.push(a)}return s}function Sr(e,t,{staticPosition:n}){const r=nr(t.type);if(r){const[o,s]=r;return function(e,t,{length:n,staticPosition:r}){if(!n){const n=r+Ar(e.readBytes(Tr)),o=n+Nr;e.setPosition(n);const s=Ar(e.readBytes(Nr)),a=$r(t);let i=0;const c=[];for(let n=0;n<s;++n){e.setPosition(o+(a?32*n:i));const[r,s]=Sr(e,t,{staticPosition:o});i+=s,c.push(r)}return e.setPosition(r+32),[c,32]}if($r(t)){const o=r+Ar(e.readBytes(Tr)),s=[];for(let r=0;r<n;++r){e.setPosition(o+32*r);const[n]=Sr(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]=Sr(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($r(t)){const a=n+Ar(e.readBytes(Tr));for(let n=0;n<t.components.length;++n){const i=t.components[n];e.setPosition(a+s);const[c,u]=Sr(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]=Sr(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[jn(Dt(Kn(t,-20))),32]}(e);if("bool"===t.type)return function(e){return[kr(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=Ar(e.readBytes(32));e.setPosition(n+t);const r=Ar(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[Dt(o),32]}const s=Dt(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?Pr(o,{signed:n}):Ar(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=Ar(e.readBytes(32)),r=t+n;e.setPosition(r);const o=Ar(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&&(zt(n,{size:t.size}),n=Rt(n,{dir:"right"})),(new TextDecoder).decode(n)}(Rt(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:n});throw new Et(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Nr=32,Tr=32;function $r(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($r);const n=nr(e.type);return!(!n||!$r({...e,type:n[1]}))}function Br(e){const{abi:t,data:n}=e,r=Hn(n,0,4);if("0x"===r)throw new ot;const o=[...t||[],gr,br].find(e=>"error"===e.type&&r===rr(We(e)));if(!o)throw new lt(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:o,args:"inputs"in o&&o.inputs&&o.inputs.length>0?Ir(o.inputs,Hn(n,4)):void 0,errorName:o.name}}const Cr=(e,t,n)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,n);function Or({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]?Cr(t[n]):t[n]}`).join(", ")})`}const _r={gwei:9,wei:18},Rr={ether:-9,wei:9};function zr(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 Mr(e,t="wei"){return zr(e,_r[t])}function Fr(e,t="wei"){return zr(e,Rr[t])}class Lr extends Xe{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class jr extends Xe{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Ur(e){return e.reduce((e,{slot:t,value:n})=>`${e} ${t}: ${n}\n`,"")}function Dr(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 Gr extends Xe{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 qr extends Xe{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Dr(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 Vr extends Xe{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 Xe{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 Hr extends Xe{constructor({hash:e}){super(`Timed out while waiting for transaction with hash "${e}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}class Yr extends Xe{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?fr(t):void 0;let p=Dr({from:h?.address,to:l,value:void 0!==d&&`${Mr(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${Fr(a)} gwei`,maxFeePerGas:void 0!==i&&`${Fr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Fr(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+=Ur(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=Ur(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 Zr extends Xe{constructor(e,{abi:t,args:n,contractAddress:r,docsPath:o,functionName:s,sender:a}){const i=or({abi:t,args:n,name:s}),c=i?Or({abiItem:i,args:n,includeFunctionName:!1,includeName:!1}):void 0,u=Dr({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 Kr extends Xe{constructor({abi:e,data:t,functionName:n,message:r}){let o,s,a,i,c;if(t&&"0x"!==t)try{s=Br({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=mr[e]}else{const e=n?We(n,{includeName:!0}):void 0,t=n&&o?Or({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 lt&&(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 Jr extends Xe{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 Qr extends Xe{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 Xr extends Xe{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 eo extends Xe{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: ${Cr(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 to extends Xe{constructor({body:e,error:t,url:n}){super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${n}`,`Request body: ${Cr(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 no extends Xe{constructor({body:e,url:t}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${t}`,`Request body: ${Cr(e)}`],name:"TimeoutError"})}}class ro extends Xe{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 to?e.code:t??-1}}class oo extends ro{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class so extends ro{constructor(e){super(e,{code:so.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(so,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class ao extends ro{constructor(e){super(e,{code:ao.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(ao,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class io extends ro{constructor(e,{method:t}={}){super(e,{code:io.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(io,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class co extends ro{constructor(e){super(e,{code:co.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(co,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class uo extends ro{constructor(e){super(e,{code:uo.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(uo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class lo extends ro{constructor(e){super(e,{code:lo.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(lo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class fo extends ro{constructor(e){super(e,{code:fo.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(fo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ho extends ro{constructor(e){super(e,{code:ho.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(ho,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class po extends ro{constructor(e){super(e,{code:po.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(po,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class mo extends ro{constructor(e,{method:t}={}){super(e,{code:mo.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not supported.`})}}Object.defineProperty(mo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class go extends ro{constructor(e){super(e,{code:go.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(go,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class bo extends ro{constructor(e){super(e,{code:bo.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(bo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class yo extends oo{constructor(e){super(e,{code:yo.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(yo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class wo extends oo{constructor(e){super(e,{code:wo.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(wo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class vo extends oo{constructor(e,{method:t}={}){super(e,{code:vo.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(vo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class xo extends oo{constructor(e){super(e,{code:xo.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(xo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Eo extends oo{constructor(e){super(e,{code:Eo.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(Eo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Po extends oo{constructor(e){super(e,{code:Po.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Po,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class ko extends oo{constructor(e){super(e,{code:ko.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(ko,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Ao extends oo{constructor(e){super(e,{code:Ao.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Ao,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class Io extends oo{constructor(e){super(e,{code:Io.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(Io,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class So extends oo{constructor(e){super(e,{code:So.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(So,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class No extends oo{constructor(e){super(e,{code:No.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(No,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class To extends oo{constructor(e){super(e,{code:To.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(To,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class $o extends oo{constructor(e){super(e,{code:$o.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty($o,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Bo extends ro{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Co=3;function Oo(e,{abi:t,address:n,args:r,docsPath:o,functionName:s,sender:a}){const i=e instanceof Xr?e:e instanceof Xe?e.walk(e=>"data"in e)||e.walk():{},{code:c,data:u,details:l,message:d,shortMessage:f}=i,h=e instanceof ot?new Jr({functionName:s}):[Co,uo.code].includes(c)&&(u||l||d||f)?new Kr({abi:t,data:"object"==typeof u?u.data:u,functionName:s,message:i instanceof to?l:f??d}):e;return new Zr(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 Ro({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=Ye(e)?e:jt(e),{secp256k1:r}=await Promise.resolve().then(function(){return td}),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(Mt(e),Mt(n)).addRecoveryBit(a)}const e=Ye(t)?t:jt(t);if(65!==Ze(e))throw new Error("invalid signature length");const n=_o(Ft(`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}),jn(`0x${Cn(`0x${n.substring(4)}`).substring(26)}`);var n}function zo(e,t="hex"){const n=Mo(e),r=Er(new Uint8Array(n.length));return n.encode(r),"hex"===t?Dt(r.bytes):r.bytes}function Mo(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),n=Fo(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=>Mo(e))):function(e){const t="string"==typeof e?Kt(e):e,n=Fo(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 Fo(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 Xe("Length is too large.")}function Lo(e){const{chainId:t,nonce:n,to:r}=e,o=e.contractAddress??e.address,s=Cn(Wn(["0x05",zo([t?Gt(t):"0x",o,n?Gt(n):"0x"])]));return"bytes"===r?Kt(s):s}async function jo(e){const{authorization:t,signature:n}=e;return Ro({hash:Lo(t),signature:n??t})}class Uo extends Xe{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=Dr({from:t?.address,to:l,value:void 0!==d&&`${Mr(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${Fr(a)} gwei`,maxFeePerGas:void 0!==i&&`${Fr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Fr(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 Do extends Xe{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(Do,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Do,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Go extends Xe{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Fr(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Go,"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 qo extends Xe{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Fr(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(qo,"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 Vo extends Xe{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(Vo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Wo extends Xe{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 Ho extends Xe{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Ho,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Yo extends Xe{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(Yo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Zo extends Xe{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(Zo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Ko extends Xe{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(Ko,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Jo extends Xe{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Jo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Qo extends Xe{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${Fr(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Fr(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Qo,"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 Xo extends Xe{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function es(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof Xe?e.walk(e=>e?.code===Do.code):e;return r instanceof Xe?new Do({cause:e,message:r.details}):Do.nodeMessage.test(n)?new Do({cause:e,message:e.details}):Go.nodeMessage.test(n)?new Go({cause:e,maxFeePerGas:t?.maxFeePerGas}):qo.nodeMessage.test(n)?new qo({cause:e,maxFeePerGas:t?.maxFeePerGas}):Vo.nodeMessage.test(n)?new Vo({cause:e,nonce:t?.nonce}):Wo.nodeMessage.test(n)?new Wo({cause:e,nonce:t?.nonce}):Ho.nodeMessage.test(n)?new Ho({cause:e,nonce:t?.nonce}):Yo.nodeMessage.test(n)?new Yo({cause:e}):Zo.nodeMessage.test(n)?new Zo({cause:e,gas:t?.gas}):Ko.nodeMessage.test(n)?new Ko({cause:e,gas:t?.gas}):Jo.nodeMessage.test(n)?new Jo({cause:e}):Qo.nodeMessage.test(n)?new Qo({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new Xo({cause:e})}function ts(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 ns={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function rs(e){const t={};return void 0!==e.authorizationList&&(t.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?Gt(BigInt(e.r)):e.r,s:e.s?Gt(BigInt(e.s)):e.s,chainId:Gt(e.chainId),nonce:Gt(e.nonce),...void 0!==e.yParity?{yParity:Gt(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:Gt(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=>Dt(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=Gt(e.gas)),void 0!==e.gasPrice&&(t.gasPrice=Gt(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(t.maxFeePerBlobGas=Gt(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=Gt(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=Gt(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=Gt(e.nonce)),void 0!==e.to&&(t.to=e.to),void 0!==e.type&&(t.type=ns[e.type]),void 0!==e.value&&(t.value=Gt(e.value)),t}function os(e){if(e&&0!==e.length)return e.reduce((e,{slot:t,value:n})=>{if(66!==t.length)throw new Nt({size:t.length,targetSize:66,type:"hex"});if(66!==n.length)throw new Nt({size:n.length,targetSize:66,type:"hex"});return e[t]=n,e},{})}function ss(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=Gt(t)),void 0!==n&&(a.nonce=Gt(n)),void 0!==r&&(a.state=os(r)),void 0!==o){if(a.state)throw new jr;a.stateDiff=os(o)}return a}function as(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!qn(n,{strict:!1}))throw new Mn({address:n});if(t[n])throw new Lr({address:n});t[n]=ss(r)}return t}const is=2n**256n-1n;function cs(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:o,to:s}=e,a=t?fr(t):void 0;if(a&&!qn(a.address))throw new Mn({address:a.address});if(s&&!qn(s))throw new Mn({address:s});if(void 0!==n&&(void 0!==r||void 0!==o))throw new Gr;if(r&&r>is)throw new Go({maxFeePerGas:r});if(o&&r&&o>r)throw new Qo({maxFeePerGas:r,maxPriorityFeePerGas:o})}class us extends Xe{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class ls extends Xe{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class ds extends Xe{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Fr(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class fs extends Xe{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 hs={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ps(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Ft(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?Ft(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?hs[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 ms(e){const t=(e.transactions??[]).map(e=>"string"==typeof e?e:ps(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 gs(e,{blockHash:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",includeTransactions:o}={}){const s=o??!1,a=void 0!==n?Gt(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 fs({blockHash:t,blockNumber:n});return(e.chain?.formatters?.block?.format||ms)(i)}async function bs(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function ys(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 Ve(e,gs,"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 Mt(await e.request({method:"eth_maxPriorityFeePerGas"}))}catch{const[t,r]=await Promise.all([n?Promise.resolve(n):Ve(e,gs,"getBlock")({}),Ve(e,bs,"getGasPrice")({})]);if("bigint"!=typeof t.baseFeePerGas)throw new ls;const o=r-t.baseFeePerGas;return o<0n?0n:o}}async function ws(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 us;const i=10**(a.toString().split(".")[1]?.length??0),c=e=>e*BigInt(Math.ceil(a*i))/BigInt(i),u=n||await Ve(e,gs,"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 ls;const t="bigint"==typeof o?.maxPriorityFeePerGas?o.maxPriorityFeePerGas:await ys(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 Ve(e,bs,"getGasPrice")({}))}}async function vs(e,{address:t,blockTag:n="latest",blockNumber:r}){return Ft(await e.request({method:"eth_getTransactionCount",params:[t,"bigint"==typeof r?Gt(r):n]},{dedupe:Boolean(r)}))}function xs(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=>Kt(e)):e.blobs,o=[];for(const e of r)o.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?o:o.map(e=>Dt(e))}function Es(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=>Kt(e)):e.blobs,o="string"==typeof e.commitments[0]?e.commitments.map(e=>Kt(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=>Dt(e))}function Ps(e,t,n){return e&t^~e&n}function ks(e,t,n){return e&t^e&n^t&n}class As extends hn{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=cn(this.buffer)}update(e){on(this),rn(e=fn(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=cn(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){on(this),sn(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,an(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=cn(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 Is=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ss=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]),Ns=new Uint32Array(64);class Ts extends As{constructor(e=32){super(64,e,8,!1),this.A=0|Is[0],this.B=0|Is[1],this.C=0|Is[2],this.D=0|Is[3],this.E=0|Is[4],this.F=0|Is[5],this.G=0|Is[6],this.H=0|Is[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)Ns[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Ns[e-15],n=Ns[e-2],r=un(t,7)^un(t,18)^t>>>3,o=un(n,17)^un(n,19)^n>>>10;Ns[e]=o+Ns[e-7]+r+Ns[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+(un(a,6)^un(a,11)^un(a,25))+Ps(a,i,c)+Ss[e]+Ns[e]|0,l=(un(n,2)^un(n,13)^un(n,22))+ks(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(){an(Ns)}destroy(){this.set(0,0,0,0,0,0,0,0),an(this.buffer)}}const $s=pn(()=>new Ts),Bs=$s;function Cs(e){const{commitment:t,version:n=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),o=Bs(Ye(s=t,{strict:!1})?Ht(s):s);var s;return o.set([n],0),"bytes"===r?o:Dt(o)}const Os=4096,_s=131072,Rs=761855;class zs extends Xe{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class Ms extends Xe{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Fs(e){const{data:t,kzg:n,to:r}=e,o=e.blobs??function(e){const t="string"==typeof e.data?Kt(e.data):e.data,n=Ze(t);if(!n)throw new Ms;if(n>Rs)throw new zs({maxSize:Rs,size:n});const r=[];let o=!0,s=0;for(;o;){const e=Er(new Uint8Array(_s));let n=0;for(;n<Os;){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=>Dt(e.bytes))}({data:t}),s=e.commitments??xs({blobs:o,kzg:n,to:r}),a=e.proofs??Es({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 Ls(e){return Ft(await e.request({method:"eth_chainId"},{dedupe:!0}))}const js=["blobVersionedHashes","chainId","fees","gas","nonce","type"],Us=new Map;async function Ds(e,t){const{account:n=e.account,blobs:r,chain:o,gas:s,kzg:a,nonce:i,nonceManager:c,parameters:u=js,type:l}=t,d=n?fr(n):n,f={...t,...d?{from:d?.address}:{}};let h,p;async function m(){return h||(h=await Ve(e,gs,"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 Ve(e,Ls,"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 Ve(e,vs,"getTransactionCount")({address:d.address,blockTag:"pending"});if((u.includes("blobVersionedHashes")||u.includes("sidecars"))&&r&&a){const e=xs({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(Cs({commitment:e,to:r,version:n}));return o}({commitments:e,to:"hex"});f.blobVersionedHashes=t}if(u.includes("sidecars")){const t=Fs({blobs:r,commitments:e,proofs:Es({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 qr({transaction:e})}(f)}catch{let t=Us.get(e.uid);if(void 0===t){const n=await m();t="bigint"==typeof n?.baseFeePerGas,Us.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 ws(e,{block:n,chain:o,request:f});if(void 0===t.maxPriorityFeePerGas&&t.maxFeePerGas&&t.maxFeePerGas<s)throw new ds({maxPriorityFeePerGas:s});f.maxPriorityFeePerGas=s,f.maxFeePerGas=r}}else{if(void 0!==t.maxFeePerGas||void 0!==t.maxPriorityFeePerGas)throw new ls;if(void 0===t.gasPrice){const t=await m(),{gasPrice:n}=await ws(e,{block:t,chain:o,request:f,type:"legacy"});f.gasPrice=n}}return u.includes("gas")&&void 0===s&&(f.gas=await Ve(e,Gs,"estimateGas")({...f,account:d?{address:d.address,type:"json-rpc"}:d})),cs(f),delete f.parameters,f}async function Gs(e,t){const{account:n=e.account}=t,r=n?fr(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 Ds(e,{...t,parameters:"local"===r?.type?void 0:["blobVersionedHashes"]}),w=("bigint"==typeof i?Gt(i):void 0)||c,v=as(b),x=await(async()=>y.to?y.to:o&&o.length>0?await jo({authorization:o[0]}).catch(()=>{throw new Xe("`to` is required. Could not infer from `authorizationList`")}):void 0)();cs(t);const E=e.chain?.formatters?.transactionRequest?.format,P=(E||rs)({...ts(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=es(e,n);return t instanceof Xo?e:t})();return new Uo(r,{docsPath:t,...n})}(n,{...t,account:r,chain:e.chain})}}function qs(e,t){if(!qn(e,{strict:!1}))throw new Mn({address:e});if(!qn(t,{strict:!1}))throw new Mn({address:t});return e.toLowerCase()===t.toLowerCase()}const Vs="/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 dt({docsPath:Vs});const c=t.find(e=>"event"===e.type&&a===zn(We(e)));if(!c||!("name"in c)||"event"!==c.type)throw new ft(a,{docsPath:Vs});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 vt({abiItem:c,param:t});f[d?n:t.name||n]=Hs({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=Ir(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 rt||e instanceof wr)throw new wt({abiItem:c,data:n,params:p,size:Ze(n)});throw e}}else if(s)throw new wt({abiItem:c,data:"0x",params:p,size:0});return{eventName:u,args:Object.values(f).length>0?f:void 0}}function Hs({param:e,value:t}){if("string"===e.type||"bytes"===e.type||"tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))return t;return(Ir([e],t)||[])[0]}function Ys(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]===zn(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?qs(t,n):"string"===e.type||"bytes"===e.type?Cn(Ht(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 ft)return null;if(t instanceof wt||t instanceof vt){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 Zs(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 Ks(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=>cr({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?Gt(r):r,toBlock:"bigint"==typeof o?Gt(o):o}]});const h=d.map(e=>Zs(e));return l?Ys({abi:l,args:i,logs:h,strict:u}):h}async function Js(e,t){const{abi:n,address:r,args:o,blockHash:s,eventName:a,fromBlock:i,toBlock:c,strict:u}=t,l=a?or({abi:n,name:a}):void 0,d=l?void 0:n.filter(e=>"event"===e.type);return Ve(e,Ks,"getLogs")({address:r,args:o,blockHash:s,event:l,events:d,fromBlock:i,toBlock:c,strict:u})}const Qs="/docs/contract/decodeFunctionResult";function Xs(e){const{abi:t,args:n,functionName:r,data:o}=e;let s=t[0];if(r){const e=or({abi:t,args:n,name:r});if(!e)throw new pt(r,{docsPath:Qs});s=e}if("function"!==s.type)throw new pt(void 0,{docsPath:Qs});if(!s.outputs)throw new mt(s.name,{docsPath:Qs});const a=Ir(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 ea=BigInt(0),ta=BigInt(1);function na(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function ra(e){if(!na(e))throw new Error("Uint8Array expected")}function oa(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function sa(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function aa(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?ea:BigInt("0x"+e)}const ia="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,ca=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ua(e){if(ra(e),ia)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=ca[e[n]];return t}const la=48,da=57,fa=65,ha=70,pa=97,ma=102;function ga(e){return e>=la&&e<=da?e-la:e>=fa&&e<=ha?e-(fa-10):e>=pa&&e<=ma?e-(pa-10):void 0}function ba(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(ia)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=ga(e.charCodeAt(o)),s=ga(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 ya(e){return aa(ua(e))}function wa(e){return ra(e),aa(ua(Uint8Array.from(e).reverse()))}function va(e,t){return ba(e.toString(16).padStart(2*t,"0"))}function xa(e,t){return va(e,t).reverse()}function Ea(e,t,n){let r;if("string"==typeof t)try{r=ba(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!na(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 Pa(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];ra(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 ka=e=>"bigint"==typeof e&&ea<=e;function Aa(e,t,n){return ka(e)&&ka(t)&&ka(n)&&t<=e&&e<n}function Ia(e,t,n,r){if(!Aa(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const Sa=e=>(ta<<BigInt(e))-ta,Na=e=>new Uint8Array(e),Ta=e=>Uint8Array.from(e);const $a={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||na(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 Ba(e,t,n={}){const r=(t,n,r)=>{const o=$a[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 Ca(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 Oa extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof Oa){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 Oa&&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 Ra(e,t){if(Qa(e)>t)throw new ai({givenSize:Qa(e),maxSize:t})}const za=48,Ma=57,Fa=65,La=70,ja=97,Ua=102;function Da(e){return e>=za&&e<=Ma?e-za:e>=Fa&&e<=La?e-(Fa-10):e>=ja&&e<=Ua?e-(ja-10):void 0}function Ga(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 qa(e,t){if(yi(e)>t)throw new Ai({givenSize:yi(e),maxSize:t})}function Va(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 Si({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 Ha=new TextDecoder,Ya=new TextEncoder;function Za(e){return e instanceof Uint8Array?e:"string"==typeof e?Ka(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}function Ka(e,t={}){const{size:n}=t;let r=e;n&&(qa(e,n),r=gi(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=Da(o.charCodeAt(t++)),r=Da(o.charCodeAt(t++));if(void 0===n||void 0===r)throw new Oa(`Invalid byte sequence ("${o[t-2]}${o[t-1]}" in "${o}").`);a[e]=16*n+r}return a}function Ja(e,t={}){const{size:n}=t,r=Ya.encode(e);return"number"==typeof n?(Ra(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 ii({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 Qa(e){return e.length}function Xa(e,t,n,r={}){const{strict:o}=r;return e.slice(t,n)}function ei(e,t={}){const{size:n}=t;void 0!==n&&Ra(e,n);return wi(fi(e,t),t)}function ti(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&(Ra(r,n),r=oi(r)),r.length>1||r[0]>1)throw new si(r);return Boolean(r[0])}function ni(e,t={}){const{size:n}=t;void 0!==n&&Ra(e,n);return vi(fi(e,t),t)}function ri(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&(Ra(r,n),r=Ga(r,{dir:"right"})),Ha.decode(r)}function oi(e){return Ga(e,{dir:"left"})}class si extends Oa{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 ai=class extends Oa{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"})}},ii=class extends Oa{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 ci=new TextEncoder,ui=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function li(...e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function di(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(qa(n,t.size),mi(n,t.size)):n}function fi(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=ui[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(qa(r,t.size),gi(r,t.size)):r}function hi(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 Ei({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?mi(i,r):i}function pi(e,t={}){return fi(ci.encode(e),t)}function mi(e,t){return Va(e,{dir:"left",size:t})}function gi(e,t){return Va(e,{dir:"right",size:t})}function bi(e,t,n,r={}){const{strict:o}=r;!function(e,t){if("number"==typeof t&&t>0&&t>yi(e)-1)throw new Ii({offset:t,position:"start",size:yi(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&&yi(e)!==n-t)throw new Ii({offset:n,position:"end",size:yi(e)})}(s,t,n),s}function yi(e){return Math.ceil((e.length-2)/2)}function wi(e,t={}){const{signed:n}=t;t.size&&qa(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 vi(e,t={}){const{signed:n,size:r}=t;return Number(n||r?wi(e,t):e)}function xi(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new Pi(e);if("string"!=typeof e)throw new Pi(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new ki(e);if(!e.startsWith("0x"))throw new ki(e)}(e,{strict:n}),!0}catch{return!1}}class Ei extends Oa{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 Pi extends Oa{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 ki extends Oa{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 Ai extends Oa{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 Ii extends Oa{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 Si extends Oa{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 Ni(e){return{address:e.address,amount:hi(e.amount),index:hi(e.index),validatorIndex:hi(e.validatorIndex)}}function Ti(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:hi(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:hi(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:hi(e.gasLimit)},..."bigint"==typeof e.number&&{number:hi(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:hi(e.prevRandao)},..."bigint"==typeof e.time&&{time:hi(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(Ni)}}}const $i=[{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"}],Bi=[{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"}]}],Ci=[{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"}],Oi=[...Ci,{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=[...Ci,{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"}]}],Ri=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],zi=[{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"}]}],Mi=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],Fi=[{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"}],Li="0x82ad56cb",ji="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",Ui="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",Di="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",Gi="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class qi extends Xe{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 Vi extends Xe{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}const Wi="/docs/contract/encodeDeployData";function Hi(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 tt({docsPath:Wi});if(!("inputs"in o))throw new nt({docsPath:Wi});if(!o.inputs||0===o.inputs.length)throw new nt({docsPath:Wi});return Wn([r,Xn(o.inputs,n)])}function Yi({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new qi({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new qi({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function Zi(e,{docsPath:t,...n}){const r=(()=>{const t=es(e,n);return t instanceof Xo?e:t})();return new Yr(r,{docsPath:t,...n})}function Ki(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const Ji=new Map;function Qi({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=()=>Ji.delete(t),i=()=>Ji.get(t)||[],c=e=>Ji.set(t,[...i(),e]);return{flush:a,async schedule(e){const{promise:t,resolve:o,reject:a}=Ki(),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 Xi(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?fr(n):void 0;if(l&&(f||h))throw new Xe("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(l&&v)throw new Xe("Cannot provide both `code` & `to` as parameters.");const A=l&&d,I=f&&h&&v&&d,S=A||I,N=A?ec({code:l,data:d}):I?function(e){const{data:t,factory:n,factoryData:r,to:o}=e;return Hi({abi:De(["constructor(address, bytes, address, bytes)"]),bytecode:Ui,args:[o,t,n,r]})}({data:d,factory:f,factoryData:h,to:v}):d;try{cs(t);const n=("bigint"==typeof s?Gt(s):void 0)||a,l=u?Ti(u):void 0,d=as(E),f=e.chain?.formatters?.transactionRequest?.format,h=(f||rs)({...ts(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(Li)&&(!!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 Yi({blockNumber:s,chain:e.chain,contract:"multicall3"});throw new Vi})(),l="bigint"==typeof s?Gt(s):void 0,d=l||a,{schedule:f}=Qi({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=pr({abi:$i,args:[n],functionName:"aggregate3"}),o=await e.request({method:"eth_call",params:[{...null===u?{data:ec({code:Gi,data:r})}:{to:u,data:r}},d]});return Xs({abi:$i,args:[n],functionName:"aggregate3",data:o||"0x"})}}),[{returnData:h,success:p}]=await f({data:i,to:c});if(!p)throw new Xr({data:h});return"0x"===h?{data:void 0}:{data:h}}(e,{...h,blockNumber:s,blockTag:a})}catch(e){if(!(e instanceof Vi||e instanceof qi))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 Xe))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 su});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 Qr({factory:f});throw Zi(n,{...t,account:k,chain:e.chain})}}function ec(e){const{code:t,data:n}=e;return Hi({abi:De(["constructor(bytes, bytes)"]),bytecode:ji,args:[t,n]})}async function tc(e,t){const{abi:n,address:r,args:o,functionName:s,...a}=t,i=pr({abi:n,args:o,functionName:s});try{const{data:t}=await Ve(e,Xi,"call")({...a,data:i,to:r});return Xs({abi:n,args:o,functionName:s,data:t||"0x"})}catch(e){throw Oo(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/readContract",functionName:s})}}const nc=new Map,rc=new Map;let oc=0;function sc(e,t,n){const r=++oc,o=()=>nc.get(e)||[],s=()=>{const t=o();if(!t.some(e=>e.id===r))return;const n=rc.get(e);if(1===t.length&&n){const e=n();e instanceof Promise&&e.catch(()=>{})}(()=>{const t=o();nc.set(e,t.filter(e=>e.id!==r))})()},a=o();if(nc.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&&rc.set(e,c),s}async function ac(e){return new Promise(t=>setTimeout(t,e))}function ic(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 ac(i);const c=async()=>{o&&(await e({unpoll:s}),await ac(r),c())};c()})(),s}const cc=new Map,uc=new Map;async function lc(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,cc),r=t(e,uc);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 dc(e,{cacheTime:t=e.cacheTime}={}){const n=await lc(()=>e.request({method:"eth_blockNumber"}),{cacheKey:(r=e.uid,`blockNumber.${r}`),cacheTime:t});var r;return BigInt(n)}async function fc(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=>Zs(e));return"abi"in t&&t.abi?Ys({abi:t.abi,logs:o,strict:n}):o}async function hc(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function pc(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 ac(n),a({count:i+1})})({error:e});s(e)}};a()})}const mc={"0x0":"reverted","0x1":"success"};function gc(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=>Zs(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Ft(e.transactionIndex):null,status:e.status?mc[e.status]:null,type:e.type?hs[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}let bc,yc=256;function wc(e=11){if(!bc||yc+e>512){bc="",yc=0;for(let e=0;e<256;e++)bc+=(256+256*Math.random()|0).toString(16).substring(1)}return bc.substring(yc,yc+++e)}function vc(e){if(!(e instanceof Xe))return!1;const t=e.walk(e=>e instanceof Kr);return t instanceof Kr&&("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 xc="/docs/contract/encodeErrorResult";function Ec(e){const{abi:t,errorName:n,args:r}=e;let o=t[0];if(n){const e=or({abi:t,args:r,name:n});if(!e)throw new ut(n,{docsPath:xc});o=e}if("error"!==o.type)throw new ut(void 0,{docsPath:xc});const s=We(o),a=rr(s);let i="0x";if(r&&r.length>0){if(!o.inputs)throw new ct(o.name,{docsPath:xc});i=Xn(o.inputs,r)}return Wn([a,i])}const Pc="/docs/contract/encodeFunctionResult";const kc="x-batch-gateway:true";async function Ac(e){const{data:t,ccipRequest:n}=e,{args:[r]}=function(e){const{abi:t,data:n}=e,r=Hn(n,0,4),o=t.find(e=>"function"===e.type&&r===rr(We(e)));if(!o)throw new gt(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:o.name,args:"inputs"in o&&o.inputs&&o.inputs.length>0?Ir(o.inputs,Hn(n,4)):void 0}}({abi:Bi,data:t}),o=[],s=[];return await Promise.all(r.map(async(e,t)=>{try{s[t]=e.urls.includes(kc)?await Ac({data:e.data,ccipRequest:n}):await n(e),o[t]=!1}catch(e){o[t]=!0,s[t]="HttpRequestError"===(r=e).name&&r.status?Ec({abi:Bi,errorName:"HttpError",args:[r.status,r.shortMessage]}):Ec({abi:[gr],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=or({abi:t,name:n});if(!e)throw new pt(n,{docsPath:Pc});o=e}if("function"!==o.type)throw new pt(void 0,{docsPath:Pc});if(!o.outputs)throw new mt(o.name,{docsPath:Pc});const s=(()=>{if(0===o.outputs.length)return[];if(1===o.outputs.length)return[r];if(Array.isArray(r))return r;throw new Pt(r)})();return Xn(o.outputs,s)}({abi:Bi,functionName:"query",result:[o,s]})}function Ic(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 Ye(t)?t:null}function Sc(e){let t=new Uint8Array(32).fill(0);if(!e)return Dt(t);const n=e.split(".");for(let e=n.length-1;e>=0;e-=1){const r=Ic(n[e]),o=r?Ht(r):Cn(Jt(n[e]),"bytes");t=Cn(Vn([t,o]),"bytes")}return Dt(t)}function Nc(e){return`[${e.slice(2)}]`}function Tc(e){const t=new Uint8Array(32).fill(0);return e?Ic(e)||Cn(Jt(e)):Dt(t)}function $c(e){const t=e.replace(/^\.|\.$/gm,"");if(0===t.length)return new Uint8Array(1);const n=new Uint8Array(Jt(t).byteLength+2);let r=0;const o=t.split(".");for(let e=0;e<o.length;e++){let t=Jt(o[e]);t.byteLength>255&&(t=Jt(Nc(Tc(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 Bc extends Xe{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 Cc extends Xe{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`,{name:"EnsAvatarInvalidNftUriError"})}}class Oc extends Xe{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 Xe{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const Rc=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,zc=/^(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>\/.*)?$/,Mc=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,Fc=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;function Lc(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function jc({uri:e,gatewayUrls:t}){const n=Mc.test(e);if(n)return{uri:e,isOnChain:!0,isEncoded:n};const r=Lc(t?.ipfs,"https://ipfs.io"),o=Lc(t?.arweave,"https://arweave.net"),s=e.match(Rc),{protocol:a,subpath:i,target:c,subtarget:u=""}=s?.groups||{},l="ipns:/"===a||"ipns/"===i,d="ipfs:/"===a||"ipfs/"===i||zc.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(Fc,"");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 Oc({uri:e})}function Uc(e){if("object"!=typeof e||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new Bc({data:e});return e.image||e.image_url||e.image_data}async function Dc({gatewayUrls:e,uri:t}){const{uri:n,isOnChain:r}=jc({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 Oc({uri:t})}async function Gc(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 Cc({reason:"Only EIP-155 supported"});if(!a)throw new Cc({reason:"Chain ID not found"});if(!c)throw new Cc({reason:"Contract address not found"});if(!o)throw new Cc({reason:"Token ID not found"});if(!i)throw new Cc({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 tc(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 tc(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}=jc({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 Dc({uri:Uc(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 Dc({gatewayUrls:e,uri:Uc(n)})}catch{throw new Oc({uri:t})}}({gatewayUrls:t,uri:s.replace(/(?:0x)?{id}/,c)})}(e,{gatewayUrls:t,record:n}):Dc({uri:n,gatewayUrls:t})}async function qc(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 Yi({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:Oi,args:[jt($c(s)),pr({abi:Ri,functionName:"text",args:[Sc(s),o]}),a??[kc]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},i=Ve(e,tc,"readContract"),c=await i(t);if("0x"===c[0])return null;const l=Xs({abi:Ri,functionName:"text",data:c[0]});return""===l?null:l}catch(e){if(i)throw e;if(vc(e))return null;throw e}}async function Vc(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?fr(n):void 0;try{cs(t);const n=("bigint"==typeof r?Gt(r):void 0)||o,g=e.chain?.formatters?.transactionRequest?.format,b=(g||rs)({...ts(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 Zi(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=lr(e,{method:"eth_newFilter"});let l=[];if(c){const e=c.flatMap(e=>cr({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?Gt(s):s,toBlock:"bigint"==typeof i?Gt(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 Hc(e){const t=lr(e,{method:"eth_newPendingTransactionFilter"}),n=await e.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:t(n),type:"transaction"}}async function Yc(e,{address:t,blockNumber:n,blockTag:r="latest"}){const o=void 0!==n?Gt(n):void 0,s=await e.request({method:"eth_getCode",params:[t,o||r]},{dedupe:Boolean(o)});if("0x"!==s)return s}class Zc extends Xe{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 Kc=[{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 Jc(e,{blockCount:t,blockNumber:n,blockTag:r="latest",rewardPercentiles:o}){const s="bigint"==typeof n?Gt(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:[Gt(t),s||r,o]},{dedupe:Boolean(s)}))}const Qc=new Fn(8192);function Xc(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 mo(new Error("method not supported"),{method:u});if(s?.include&&!s.include.includes(u))throw new mo(new Error("method not supported"),{method:u});return function(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(Qc.get(n))return Qc.get(n);const r=e().finally(()=>Qc.delete(n));return Qc.set(n,r),r}(()=>pc(async()=>{try{return await e(n)}catch(e){const t=e;switch(t.code){case so.code:throw new so(t);case ao.code:throw new ao(t);case io.code:throw new io(t,{method:n.method});case co.code:throw new co(t);case uo.code:throw new uo(t);case lo.code:throw new lo(t);case fo.code:throw new fo(t);case ho.code:throw new ho(t);case po.code:throw new po(t);case mo.code:throw new mo(t,{method:n.method});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 To.code:throw new To(t);case $o.code:throw new $o(t);case 5e3:throw new yo(t);default:if(e instanceof Xe)throw e;throw new Bo(t)}}},{delay:({count:e,error:t})=>{if(t&&t instanceof eo){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===go.code||e.code===uo.code);if(e instanceof eo&&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?Vt(`${c}.${Cr(n)}`):void 0})}}class eu extends Xe{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 tu extends Xe{constructor({result:e,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${t}`,`Response: ${Cr(e)}`],name:"OffchainLookupResponseMalformedError"})}}class nu extends Xe{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 ru={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 ou({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 eo({body:i,details:o?.error?Cr(o.error):n.statusText,headers:n.headers,status:n.status,url:s});continue}if(!Ye(o)){r=new tu({result:o,url:s});continue}return o}catch(e){r=new eo({body:i,details:e.message,url:s})}}throw r}var su=Object.freeze({__proto__:null,ccipRequest:ou,offchainLookup:async function(e,{blockNumber:t,blockTag:n,data:r,to:o}){const{args:s}=Br({data:r,abi:[ru]}),[a,i,c,u,l]=s,{ccipRead:d}=e,f=d&&"function"==typeof d?.request?d.request:ou;try{if(!qs(o,a))throw new nu({sender:a,to:o});const r=i.includes(kc)?await Ac({data:c,ccipRequest:f}):await f({data:c,sender:a,urls:i}),{data:s}=await Xi(e,{blockNumber:t,blockTag:n,data:Vn([u,Xn([{type:"bytes"},{type:"bytes"}],[r,l])]),to:o});return s}catch(e){throw new eu({callbackSelector:u,cause:e,data:r,extraData:l,sender:a,urls:i})}},offchainLookupAbiItem:ru,offchainLookupSignature:"0x556f1830"});function au(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const iu=au();function cu(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)?Cr(r.map(e=>({jsonrpc:"2.0",id:e.id??iu.take(),...e}))):Cr({jsonrpc:"2.0",id:r.id??iu.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 no({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 eo({body:r,details:Cr(n.error)||t.statusText,headers:t.headers,status:t.status,url:e});return n}catch(t){if(t instanceof eo)throw t;if(t instanceof no)throw t;throw new eo({body:r,cause:t,url:e})}}}}function uu(e,t){return Cn(function(e){const t="string"==typeof e?Vt(e):"string"==typeof e.raw?e.raw:Dt(e.raw);return Vn([Vt(`Ethereum Signed Message:\n${Ze(t)}`),t])}(e),t)}class lu extends Xe{constructor({domain:e}){super(`Invalid domain "${Cr(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class du extends Xe{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 fu extends Xe{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function hu({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 pu(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new fu({type:e})}function mu(e){const{domain:t={},message:n,primaryType:r}=e,o={EIP712Domain:hu({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(Qn);if(i&&("number"==typeof a||"bigint"==typeof a)){const[e,t,n]=i;Gt(a,{signed:"int"===t,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof a&&!qn(a))throw new Mn({address:a});const c=r.match(Jn);if(c){const[e,t]=c;if(t&&Ze(a)!==Number.parseInt(t,10))throw new yt({expectedSize:Number.parseInt(t,10),givenSize:Ze(a)})}const u=o[r];u&&(pu(r),s(u,a))}};if(o.EIP712Domain&&t){if("object"!=typeof t)throw new lu({domain:t});s(o.EIP712Domain,t)}if("EIP712Domain"!==r){if(!o[r])throw new du({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 gu({data:e,primaryType:"EIP712Domain",types:t})}({domain:t,types:o})),"EIP712Domain"!==r&&s.push(gu({data:n,primaryType:r,types:o})),Cn(Vn(s))}function gu({data:e,primaryType:t,types:n}){return Cn(bu({data:e,primaryType:t,types:n}))}function bu({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],o=[yu({primaryType:t,types:n})];for(const s of n[t]){const[t,a]=vu({types:n,name:s.name,type:s.type,value:e[s.name]});r.push(t),o.push(a)}return Xn(r,o)}function yu({primaryType:e,types:t}){const n=jt(function({primaryType:e,types:t}){let n="";const r=wu({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 Cn(n)}function wu({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])wu({primaryType:e.type,types:t},n);return n}function vu({types:e,name:t,type:n,value:r}){if(void 0!==e[n])return[{type:"bytes32"},Cn(bu({data:r,primaryType:n,types:e}))];if("bytes"===n){return[{type:"bytes32"},Cn(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},Cn(jt(r))];if(n.lastIndexOf("]")===n.length-1){const o=n.slice(0,n.lastIndexOf("[")),s=r.map(n=>vu({name:t,type:o,types:e,value:n}));return[{type:"bytes32"},Cn(Xn(s.map(([e])=>e),s.map(([,e])=>e)))]}return[{type:n},r]}class xu 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 Eu={checksum:new xu(8192)}.checksum;function Pu(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Bn(Za(e));return"Bytes"===n?r:fi(r)}const ku=/^0x[a-fA-F0-9]{40}$/;function Au(e,t={}){const{strict:n=!0}=t;if(!ku.test(e))throw new Nu({address:e,cause:new Tu});if(n){if(e.toLowerCase()===e)return;if(Iu(e)!==e)throw new Nu({address:e,cause:new $u})}}function Iu(e){if(Eu.has(e))return Eu.get(e);Au(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=Pu(Ja(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 Eu.set(e,o),o}function Su(e,t={}){const{strict:n=!0}=t??{};try{return Au(e,{strict:n}),!0}catch{return!1}}class Nu extends Oa{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 Tu extends Oa{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 $u extends Oa{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const Bu=/^(.*)\[([0-9]*)\]$/,Cu=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Ou=/^(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 Ru(e,t,n){const{checksumAddress:r,staticPosition:o}=n,s=ju(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+ni(e.readBytes(Mu)),o=n+zu;e.setPosition(n);const a=ni(e.readBytes(zu)),i=Uu(t);let c=0;const u=[];for(let n=0;n<a;++n){e.setPosition(o+(i?32*n:c));const[s,a]=Ru(e,t,{checksumAddress:r,staticPosition:o});c+=a,u.push(s)}return e.setPosition(s+32),[u,32]}if(Uu(t)){const n=s+ni(e.readBytes(Mu)),a=[];for(let s=0;s<o;++s){e.setPosition(n+32*s);const[o]=Ru(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]=Ru(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(Uu(t)){const n=o+ni(e.readBytes(Mu));for(let o=0;o<t.components.length;++o){const c=t.components[o];e.setPosition(n+i);const[u,l]=Ru(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]=Ru(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?Iu(e):e;return[o(fi(Xa(r,-20))),32]}(e,{checksum:r});if("bool"===t.type)return function(e){return[ti(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,o]=t.type.split("bytes");if(!o){const t=ni(e.readBytes(32));e.setPosition(n+t);const r=ni(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[fi(o),32]}const s=fi(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?ei(o,{signed:n}):ni(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=ni(e.readBytes(32)),r=t+n;e.setPosition(r);const o=ni(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const s=e.readBytes(o,32),a=ri(oi(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:o});throw new nl(t.type)}const zu=32,Mu=32;function Fu({checksumAddress:e=!1,parameter:t,value:n}){const r=t,o=ju(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 tl(e);if(!s&&e.length!==r)throw new Qu({expectedLength:r,givenLength:e.length,type:`${o.type}[${r}]`});let a=!1;const i=[];for(let t=0;t<e.length;t++){const r=Fu({checksumAddress:n,parameter:o,value:e[t]});r.dynamic&&(a=!0),i.push(r)}if(s||a){const e=Lu(i);if(s){const t=hi(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?li(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:li(...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=Fu({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});s.push(i),i.dynamic&&(o=!0)}return{dynamic:o,encoded:o?Lu(s):li(...s.map(({encoded:e})=>e))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return Au(e,{strict:n}),{dynamic:!1,encoded:mi(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new Oa(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:mi(di(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Ou.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 Ei({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:hi(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=yi(e);if(!n){let t=e;return r%32!=0&&(t=gi(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:li(mi(hi(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new Xu({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:gi(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=pi(e),n=Math.ceil(yi(t)/32),r=[];for(let e=0;e<n;e++)r.push(gi(bi(t,32*e,32*(e+1))));return{dynamic:!0,encoded:li(gi(hi(yi(t),{size:32})),...r)}}(n);throw new nl(r.type)}function Lu(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:yi(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(hi(t+o,{size:32})),r.push(i),o+=yi(i)):n.push(i)}return li(...n,...r)}function ju(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Uu(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(Uu);const n=ju(e.type);return!(!n||!Uu({...e,type:n[1]}))}const Du={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 Vu({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new qu({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Gu({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 Gu({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 Gu extends Oa{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class qu extends Oa{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 Vu extends Oa{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?Ka(t):t,a=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(Du);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===Qa(s)&&e.length>0)throw new Ju;if(Qa(s)&&Qa(s)<32)throw new Ku({data:"string"==typeof t?t:fi(t),parameters:e,size:Qa(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]=Ru(a,n,{checksumAddress:o,staticPosition:0});i+=u,"Array"===r?c.push(s):c[n.name??t]=s}return c}function Hu(e,t,n){const{checksumAddress:r=!1}={};if(e.length!==t.length)throw new el({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(Fu({checksumAddress:e,parameter:t[o],value:n[o]}));return r}({checksumAddress:r,parameters:e,values:t}),s=Lu(o);return 0===s.length?"0x":s}function Yu(e,t){if(e.length!==t.length)throw new el({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(Yu.encode(o,s))}return li(...n)}function Zu(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?qe(e):e}!function(e){e.encode=function e(t,n,r=!1){if("address"===t){const e=n;return Au(e),mi(e.toLowerCase(),r?32:0)}if("string"===t)return pi(n);if("bytes"===t)return n;if("bool"===t)return mi(di(n),r?32:1);const o=t.match(Ou);if(o){const[e,t,s="256"]=o,a=Number.parseInt(s,10)/8;return hi(n,{size:r?32:a,signed:"int"===t})}const s=t.match(Cu);if(s){const[e,t]=s;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new Xu({expectedSize:Number.parseInt(t,10),value:n});return gi(n,r?32:0)}const a=t.match(Bu);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":li(...o)}throw new nl(t)}}(Yu||(Yu={}));class Ku extends Oa{constructor({data:e,parameters:t,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${ne(t)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Ju extends Oa{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Qu extends Oa{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 Xu extends Oa{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${yi(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class el extends Oa{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 tl extends Oa{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class nl extends Oa{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 rl extends hn{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");nn(e.outputLen),nn(e.blockLen)}(e);const n=fn(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),an(o)}update(e){return on(this),this.iHash.update(e),this}digestInto(e){on(this),rn(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 ol=(e,t,n)=>new rl(e,t).update(n).digest();ol.create=(e,t)=>new rl(e,t);
5
5
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6
- const su=BigInt(0),iu=BigInt(1),cu=BigInt(2),lu=BigInt(3),uu=BigInt(4),du=BigInt(5),fu=BigInt(8);function hu(e,t){const n=e%t;return n>=su?n:t+n}function pu(e,t,n){let r=e;for(;t-- >su;)r*=r,r%=n;return r}function mu(e,t){if(e===su)throw new Error("invert: expected non-zero number");if(t<=su)throw new Error("invert: expected positive modulus, got "+t);let n=hu(e,t),r=t,o=su,a=iu;for(;n!==su;){const e=r%n,t=o-a*(r/n);r=n,n=e,o=a,a=t}if(r!==iu)throw new Error("invert: does not exist");return hu(o,t)}function gu(e,t){const n=(e.ORDER+iu)/uu,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function bu(e,t){const n=(e.ORDER-du)/fu,r=e.mul(t,cu),o=e.pow(r,n),a=e.mul(t,o),s=e.mul(e.mul(a,cu),o),i=e.mul(a,e.sub(s,e.ONE));if(!e.eql(e.sqr(i),t))throw new Error("Cannot find square root");return i}function yu(e){return e%uu===lu?gu:e%fu===du?bu:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-iu,n=0;for(;t%cu===su;)t/=cu,n++;let r=cu;const o=Pu(e);for(;1===xu(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return gu;let a=o.pow(r,t);const s=(t+iu)/cu;return function(e,r){if(e.is0(r))return r;if(1!==xu(e,r))throw new Error("Cannot find square root");let o=n,i=e.mul(e.ONE,a),c=e.pow(r,t),l=e.pow(r,s);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=iu<<BigInt(o-t-1),a=e.pow(i,r);o=t,i=e.sqr(a),c=e.mul(c,i),l=e.mul(l,a)}return l}}(e)}const wu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function vu(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),a=e.inv(o);return t.reduceRight((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n)),a),r}function xu(e,t){const n=(e.ORDER-iu)/cu,r=e.pow(t,n),o=e.eql(r,e.ONE),a=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!a&&!s)throw new Error("invalid Legendre symbol result");return o?1:a?0:-1}function Eu(e,t){void 0!==t&&rn(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Pu(e,t,n=!1,r={}){if(e<=su)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:o,nByteLength:a}=Eu(e,t);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s;const i=Object.freeze({ORDER:e,isLE:n,BITS:o,BYTES:a,MASK:Ss(o),ZERO:su,ONE:iu,create:t=>hu(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return su<=t&&t<e},is0:e=>e===su,isOdd:e=>(e&iu)===iu,neg:t=>hu(-t,e),eql:(e,t)=>e===t,sqr:t=>hu(t*t,e),add:(t,n)=>hu(t+n,e),sub:(t,n)=>hu(t-n,e),mul:(t,n)=>hu(t*n,e),pow:(e,t)=>function(e,t,n){if(n<su)throw new Error("invalid exponent, negatives unsupported");if(n===su)return e.ONE;if(n===iu)return t;let r=e.ONE,o=t;for(;n>su;)n&iu&&(r=e.mul(r,o)),o=e.sqr(o),n>>=iu;return r}(i,e,t),div:(t,n)=>hu(t*mu(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>mu(t,e),sqrt:r.sqrt||(t=>(s||(s=yu(e)),s(i,t))),toBytes:e=>n?Es(e,a):xs(e,a),fromBytes:e=>{if(e.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+e.length);return n?vs(e):ws(e)},invertBatch:e=>vu(i,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(i)}function ku(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 Au(e){const t=ku(e);return t+Math.ceil(t/2)}
6
+ const sl=BigInt(0),al=BigInt(1),il=BigInt(2),cl=BigInt(3),ul=BigInt(4),ll=BigInt(5),dl=BigInt(8);function fl(e,t){const n=e%t;return n>=sl?n:t+n}function hl(e,t,n){let r=e;for(;t-- >sl;)r*=r,r%=n;return r}function pl(e,t){if(e===sl)throw new Error("invert: expected non-zero number");if(t<=sl)throw new Error("invert: expected positive modulus, got "+t);let n=fl(e,t),r=t,o=sl,s=al;for(;n!==sl;){const e=r%n,t=o-s*(r/n);r=n,n=e,o=s,s=t}if(r!==al)throw new Error("invert: does not exist");return fl(o,t)}function ml(e,t){const n=(e.ORDER+al)/ul,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function gl(e,t){const n=(e.ORDER-ll)/dl,r=e.mul(t,il),o=e.pow(r,n),s=e.mul(t,o),a=e.mul(e.mul(s,il),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 bl(e){return e%ul===cl?ml:e%dl===ll?gl:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-al,n=0;for(;t%il===sl;)t/=il,n++;let r=il;const o=El(e);for(;1===vl(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return ml;let s=o.pow(r,t);const a=(t+al)/il;return function(e,r){if(e.is0(r))return r;if(1!==vl(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=al<<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 yl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wl(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 vl(e,t){const n=(e.ORDER-al)/il,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 xl(e,t){void 0!==t&&nn(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function El(e,t,n=!1,r={}){if(e<=sl)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:o,nByteLength:s}=xl(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:Sa(o),ZERO:sl,ONE:al,create:t=>fl(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return sl<=t&&t<e},is0:e=>e===sl,isOdd:e=>(e&al)===al,neg:t=>fl(-t,e),eql:(e,t)=>e===t,sqr:t=>fl(t*t,e),add:(t,n)=>fl(t+n,e),sub:(t,n)=>fl(t-n,e),mul:(t,n)=>fl(t*n,e),pow:(e,t)=>function(e,t,n){if(n<sl)throw new Error("invalid exponent, negatives unsupported");if(n===sl)return e.ONE;if(n===al)return t;let r=e.ONE,o=t;for(;n>sl;)n&al&&(r=e.mul(r,o)),o=e.sqr(o),n>>=al;return r}(i,e,t),div:(t,n)=>fl(t*pl(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>pl(t,e),sqrt:r.sqrt||(t=>(a||(a=bl(e)),a(i,t))),toBytes:e=>n?xa(e,s):va(e,s),fromBytes:e=>{if(e.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+e.length);return n?wa(e):ya(e)},invertBatch:e=>wl(i,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(i)}function Pl(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 kl(e){const t=Pl(e);return t+Math.ceil(t/2)}
7
7
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
8
- const Iu=BigInt(0),Nu=BigInt(1);function Su(e,t){const n=t.negate();return e?n:t}function Tu(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Bu(e,t){Tu(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Ss(e),maxNumber:n,shiftBy:BigInt(e)}}function Cu(e,t,n){const{windowSize:r,mask:o,maxNumber:a,shiftBy:s}=n;let i=Number(e&o),c=e>>s;i>r&&(i-=a,c+=Nu);const l=t*r;return{nextN:c,offset:l+Math.abs(i)-1,isZero:0===i,isNeg:i<0,isNegF:t%2!=0,offsetF:l}}const $u=new WeakMap,Ou=new WeakMap;function _u(e){return Ou.get(e)||1}function Ru(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,a=r.length;if(o!==a)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,i=function(e){let t;for(t=0;e>ts;e>>=ns,t+=1);return t}(BigInt(o));let c=1;i>12?c=i-3:i>4?c=i-2:i>0&&(c=2);const l=Ss(c),u=new Array(Number(l)+1).fill(s);let d=s;for(let e=Math.floor((t.BITS-1)/c)*c;e>=0;e-=c){u.fill(s);for(let t=0;t<a;t++){const o=r[t],a=Number(o>>BigInt(e)&l);u[a]=u[a].add(n[t])}let t=s;for(let e=u.length-1,n=s;e>0;e--)n=n.add(u[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 zu(e){return $s(e.Fp,wu.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),$s(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Eu(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
9
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Mu(e){void 0!==e.lowS&&as("lowS",e.lowS),void 0!==e.prehash&&as("prehash",e.prehash)}class Lu extends Error{constructor(e=""){super(e)}}const Fu={Err:Lu,_tlv:{encode:(e,t)=>{const{Err:n}=Fu;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=ss(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const a=r>127?ss(o.length/2|128):"";return ss(e)+a+o+t},decode(e,t){const{Err:n}=Fu;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 a=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 s=t.subarray(r,r+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of s)a=a<<8|e;if(r+=e,a<128)throw new n("tlv.decode(long): not minimal encoding")}else a=o;const s=t.subarray(r,r+a);if(s.length!==a)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(r+a)}}},_int:{encode(e){const{Err:t}=Fu;if(e<ju)throw new t("integer: negative integers are not allowed");let n=ss(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}=Fu;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 ws(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Fu,o=Ps("signature",e),{v:a,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:i,l:c}=r.decode(2,a),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(i),s:n.decode(l)}},hexFromSig(e){const{_tlv:t,_int:n}=Fu,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};function Uu(e,t){return us(xs(e,t))}const ju=BigInt(0),Du=BigInt(1);BigInt(2);const Gu=BigInt(3),Wu=BigInt(4);function qu(e){const t=function(e){const t=zu(e);$s(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=Pu(t.n,t.nBitLength),o=t.toBytes||((e,t,r)=>{const o=t.toAffine();return ks(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),a=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 s(e){const{a:r,b:o}=t,a=n.sqr(e),s=n.mul(a,e);return n.add(n.add(s,n.mul(e,r)),o)}function i(e,t){const r=n.sqr(t),o=s(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,Gu),Wu),l=n.mul(n.sqr(t.b),BigInt(27));if(n.is0(n.add(c,l)))throw new Error("bad curve params: a or b");function u(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:o,n:a}=t;if(n&&"bigint"!=typeof e){if(rs(e)&&(e=us(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*r,"0")}let s;try{s="bigint"==typeof e?e:ws(Ps("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return o&&(s=hu(s,a)),Ns("private key",s,Du,a),s}function d(e){if(!(e instanceof p))throw new Error("ProjectivePoint expected")}const f=Os((e,t)=>{const{px:r,py:o,pz:a}=e;if(n.eql(a,n.ONE))return{x:r,y:o};const s=e.is0();null==t&&(t=s?n.ONE:n.inv(a));const i=n.mul(r,t),c=n.mul(o,t),l=n.mul(a,t);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:i,y:c}}),h=Os(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=vu(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(a(Ps("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return p.BASE.multiply(u(e))}static msm(e,t){return Ru(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:a,py:s,pz:i}=e,c=n.eql(n.mul(t,i),n.mul(a,o)),l=n.eql(n.mul(r,i),n.mul(s,o));return c&&l}negate(){return new p(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,Gu),{px:a,py:s,pz:i}=this;let c=n.ZERO,l=n.ZERO,u=n.ZERO,d=n.mul(a,a),f=n.mul(s,s),h=n.mul(i,i),m=n.mul(a,s);return m=n.add(m,m),u=n.mul(a,i),u=n.add(u,u),c=n.mul(e,u),l=n.mul(o,h),l=n.add(c,l),c=n.sub(f,l),l=n.add(f,l),l=n.mul(c,l),c=n.mul(m,c),u=n.mul(o,u),h=n.mul(e,h),m=n.sub(d,h),m=n.mul(e,m),m=n.add(m,u),u=n.add(d,d),d=n.add(u,d),d=n.add(d,h),d=n.mul(d,m),l=n.add(l,d),h=n.mul(s,i),h=n.add(h,h),d=n.mul(h,m),c=n.sub(c,d),u=n.mul(h,f),u=n.add(u,u),u=n.add(u,u),new p(c,l,u)}add(e){d(e);const{px:r,py:o,pz:a}=this,{px:s,py:i,pz:c}=e;let l=n.ZERO,u=n.ZERO,f=n.ZERO;const h=t.a,m=n.mul(t.b,Gu);let g=n.mul(r,s),b=n.mul(o,i),y=n.mul(a,c),w=n.add(r,o),v=n.add(s,i);w=n.mul(w,v),v=n.add(g,b),w=n.sub(w,v),v=n.add(r,a);let x=n.add(s,c);return v=n.mul(v,x),x=n.add(g,y),v=n.sub(v,x),x=n.add(o,a),l=n.add(i,c),x=n.mul(x,l),l=n.add(b,y),x=n.sub(x,l),f=n.mul(h,v),l=n.mul(m,y),f=n.add(l,f),l=n.sub(b,f),f=n.add(b,f),u=n.mul(l,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),u=n.add(u,g),g=n.mul(x,v),l=n.mul(w,l),l=n.sub(l,g),g=n.mul(w,b),f=n.mul(x,f),f=n.add(f,g),new p(l,u,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;Ns("scalar",e,ju,o);const a=p.ZERO;if(e===ju)return a;if(this.is0()||e===Du)return this;if(!r||b.hasPrecomputes(this))return b.wNAFCachedUnsafe(this,e,p.normalizeZ);let{k1neg:s,k1:i,k2neg:c,k2:l}=r.splitScalar(e),u=a,d=a,f=this;for(;i>ju||l>ju;)i&Du&&(u=u.add(f)),l&Du&&(d=d.add(f)),f=f.double(),i>>=Du,l>>=Du;return s&&(u=u.negate()),c&&(d=d.negate()),d=new p(n.mul(d.px,r.beta),d.py,d.pz),u.add(d)}multiply(e){const{endo:r,n:o}=t;let a,s;if(Ns("scalar",e,Du,o),r){const{k1neg:t,k1:o,k2neg:i,k2:c}=r.splitScalar(e);let{p:l,f:u}=this.wNAF(o),{p:d,f:f}=this.wNAF(c);l=b.constTimeNegate(t,l),d=b.constTimeNegate(i,d),d=new p(n.mul(d.px,r.beta),d.py,d.pz),a=l.add(d),s=u.add(f)}else{const{p:t,f:n}=this.wNAF(e);a=t,s=n}return p.normalizeZ([a,s])[0]}multiplyAndAddUnsafe(e,t,n){const r=p.BASE,o=(e,t)=>t!==ju&&t!==Du&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),a=o(this,t).add(o(e,n));return a.is0()?void 0:a}toAffine(e){return f(this,e)}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===Du)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===Du?this:n?n(p,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return as("isCompressed",e),this.assertValidity(),o(p,this,e)}toHex(e=!0){return as("isCompressed",e),us(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:Su,hasPrecomputes:e=>1!==_u(e),unsafeLadder(e,t,n=y.ZERO){let r=e;for(;t>Iu;)t&Nu&&(n=n.add(r)),r=r.double(),t>>=Nu;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=Bu(t,w),o=[];let a=e,s=a;for(let e=0;e<n;e++){s=a,o.push(s);for(let e=1;e<r;e++)s=s.add(a),o.push(s);a=s.double()}return o},wNAF(e,t,n){let r=y.ZERO,o=y.BASE;const a=Bu(e,w);for(let e=0;e<a.windows;e++){const{nextN:s,offset:i,isZero:c,isNeg:l,isNegF:u,offsetF:d}=Cu(n,e,a);n=s,c?o=o.add(Su(u,t[d])):r=r.add(Su(l,t[i]))}return{p:r,f:o}},wNAFUnsafe(e,t,n,r=y.ZERO){const o=Bu(e,w);for(let e=0;e<o.windows&&n!==Iu;e++){const{nextN:a,offset:s,isZero:i,isNeg:c}=Cu(n,e,o);if(n=a,!i){const e=t[s];r=r.add(c?e.negate():e)}}return r},getPrecomputes(e,t,n){let r=$u.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&$u.set(t,n(r))),r},wNAFCached(e,t,n){const r=_u(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const o=_u(e);return 1===o?this.unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)},setWindowSize(e,t){Tu(t,w),Ou.set(e,t),$u.delete(e)}});var y,w;return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:u,weierstrassEquation:s,isWithinCurveOrder:function(e){return Is(e,Du,t.n)}}}function Vu(e){const t=function(e){const t=zu(e);return $s(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:a}=t,s=n.BYTES+1,i=2*n.BYTES+1;function c(e){return hu(e,r)}function l(e){return mu(e,r)}const{ProjectivePoint:u,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:h}=qu({...t,toBytes(e,t,r){const o=t.toAffine(),a=n.toBytes(o.x),s=ks;return as("isCompressed",r),r?s(Uint8Array.from([t.hasEvenY()?2:3]),a):s(Uint8Array.from([4]),a,n.toBytes(o.y))},fromBytes(e){const t=e.length,r=e[0],o=e.subarray(1);if(t!==s||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 "+s+", or uncompressed "+i+", got "+t)}{const e=ws(o);if(!Is(e,Du,n.ORDER))throw new Error("Point is not on curve");const t=f(e);let a;try{a=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~r)!==((a&Du)===Du)&&(a=n.neg(a)),{x:e,y:a}}}});function p(e){return e>r>>Du}const m=(e,t,n)=>ws(e.slice(t,n));class g{constructor(e,t,n){Ns("r",e,Du,r),Ns("s",t,Du,r),this.r=e,this.s=t,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(e){const t=o;return e=Ps("compactSignature",e,2*t),new g(m(e,0,t),m(e,t,2*t))}static fromDER(e){const{r:t,s:n}=Fu.toSig(Ps("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:a}=this,s=v(Ps("msgHash",e));if(null==a||![0,1,2,3].includes(a))throw new Error("recovery id invalid");const i=2===a||3===a?r+t.n:r;if(i>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&a?"03":"02",f=u.fromHex(d+Uu(i,n.BYTES)),h=l(i),p=c(-s*h),m=c(o*h),g=u.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 ys(this.toDERHex())}toDERHex(){return Fu.hexFromSig(this)}toCompactRawBytes(){return ys(this.toCompactHex())}toCompactHex(){const e=o;return Uu(this.r,e)+Uu(this.s,e)}}const b={isValidPrivateKey(e){try{return d(e),!0}catch(e){return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const e=Au(t.n);return function(e,t,n=!1){const r=e.length,o=ku(t),a=Au(t);if(r<16||r<a||r>1024)throw new Error("expected "+a+"-1024 bytes of input, got "+r);const s=hu(n?vs(e):ws(e),t-iu)+iu;return n?Es(s,o):xs(s,o)}(t.randomBytes(e),t.n)},precompute:(e=8,t=u.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function y(e){if("bigint"==typeof e)return!1;if(e instanceof u)return!0;const r=Ps("key",e).length,a=n.BYTES,s=a+1,i=2*a+1;return t.allowedPrivateKeyLengths||o===s?void 0:r===s||r===i}const w=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=ws(e),n=8*e.length-a;return n>0?t>>BigInt(n):t},v=t.bits2int_modN||function(e){return c(w(e))},x=Ss(a);function E(e){return Ns("num < 2^"+a,e,ju,x),xs(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:a,randomBytes:s}=t;let{lowS:i,prehash:f,extraEntropy:m}=o;null==i&&(i=!0),e=Ps("msgHash",e),Mu(o),f&&(e=Ps("prehashed msgHash",a(e)));const b=v(e),y=d(r),x=[E(y),E(b)];if(null!=m&&!1!==m){const e=!0===m?s(n.BYTES):m;x.push(Ps("extraEntropy",e))}const P=ks(...x),A=b;return{seed:P,k2sig:function(e){const t=w(e);if(!h(t))return;const n=l(t),r=u.BASE.multiply(t).toAffine(),o=c(r.x);if(o===ju)return;const a=c(n*c(A+o*y));if(a===ju)return;let s=(r.x===o?0:2)|Number(r.y&Du),d=a;return i&&p(a)&&(d=function(e){return p(e)?c(-e):e}(a),s^=1),new g(o,d,s)}}}const k={lowS:t.lowS,prehash:!1},A={lowS:t.lowS,prehash:!1};return u.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return u.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 u.fromHex(t).multiply(d(e)).toRawBytes(n)},sign:function(e,n,r=k){const{seed:o,k2sig:a}=P(e,n,r),s=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=Ts(e),o=Ts(e),a=0;const s=()=>{r.fill(1),o.fill(0),a=0},i=(...e)=>n(o,r,...e),c=(e=Ts(0))=>{o=i(Bs([0]),e),r=i(),0!==e.length&&(o=i(Bs([1]),e),r=i())},l=()=>{if(a++>=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 ks(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(l()));)c();return s(),n}}(s.hash.outputLen,s.nByteLength,s.hmac);return i(o,a)},verify:function(e,n,r,o=A){const a=e;n=Ps("msgHash",n),r=Ps("publicKey",r);const{lowS:s,prehash:i,format:d}=o;if(Mu(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 a||rs(a),h=!f&&!d&&"object"==typeof a&&null!==a&&"bigint"==typeof a.r&&"bigint"==typeof a.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(a.r,a.s)),f){try{"compact"!==d&&(p=g.fromDER(a))}catch(e){if(!(e instanceof Fu.Err))throw e}p||"der"===d||(p=g.fromCompact(a))}m=u.fromHex(r)}catch(e){return!1}if(!p)return!1;if(s&&p.hasHighS())return!1;i&&(n=t.hash(n));const{r:b,s:y}=p,w=v(n),x=l(y),E=c(w*x),P=c(b*x),k=u.BASE.multiplyAndAddUnsafe(m,E,P)?.toAffine();return!!k&&c(k.x)===b},ProjectivePoint:u,Signature:g,utils:b}}
10
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Hu(e){return{hash:e,hmac:(t,...n)=>au(e,t,function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];on(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:gn}}
8
+ const Al=BigInt(0),Il=BigInt(1);function Sl(e,t){const n=t.negate();return e?n:t}function Nl(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Tl(e,t){Nl(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Sa(e),maxNumber:n,shiftBy:BigInt(e)}}function $l(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+=Il);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 Bl=new WeakMap,Cl=new WeakMap;function Ol(e){return Cl.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>ea;e>>=ta,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=Sa(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 Rl(e){return Ba(e.Fp,yl.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Ba(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...xl(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
9
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function zl(e){void 0!==e.lowS&&oa("lowS",e.lowS),void 0!==e.prehash&&oa("prehash",e.prehash)}class Ml extends Error{constructor(e=""){super(e)}}const Fl={Err:Ml,_tlv:{encode:(e,t)=>{const{Err:n}=Fl;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=sa(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?sa(o.length/2|128):"";return sa(e)+s+o+t},decode(e,t){const{Err:n}=Fl;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}=Fl;if(e<jl)throw new t("integer: negative integers are not allowed");let n=sa(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}=Fl;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 ya(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Fl,o=Ea("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}=Fl,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};function Ll(e,t){return ua(va(e,t))}const jl=BigInt(0),Ul=BigInt(1);BigInt(2);const Dl=BigInt(3),Gl=BigInt(4);function ql(e){const t=function(e){const t=Rl(e);Ba(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=El(t.n,t.nBitLength),o=t.toBytes||((e,t,r)=>{const o=t.toAffine();return Pa(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,Dl),Gl),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(na(e)&&(e=ua(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:ya(Ea("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return o&&(a=fl(a,s)),Ia("private key",a,Ul,s),a}function d(e){if(!(e instanceof p))throw new Error("ProjectivePoint expected")}const f=Ca((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=Ca(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=wl(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(Ea("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,Dl),{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,Dl);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;Ia("scalar",e,jl,o);const s=p.ZERO;if(e===jl)return s;if(this.is0()||e===Ul)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>jl||u>jl;)i&Ul&&(l=l.add(f)),u&Ul&&(d=d.add(f)),f=f.double(),i>>=Ul,u>>=Ul;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(Ia("scalar",e,Ul,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!==jl&&t!==Ul&&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===Ul)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===Ul?this:n?n(p,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return oa("isCompressed",e),this.assertValidity(),o(p,this,e)}toHex(e=!0){return oa("isCompressed",e),ua(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:Sl,hasPrecomputes:e=>1!==Ol(e),unsafeLadder(e,t,n=y.ZERO){let r=e;for(;t>Al;)t&Il&&(n=n.add(r)),r=r.double(),t>>=Il;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=Tl(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=Tl(e,w);for(let e=0;e<s.windows;e++){const{nextN:a,offset:i,isZero:c,isNeg:u,isNegF:l,offsetF:d}=$l(n,e,s);n=a,c?o=o.add(Sl(l,t[d])):r=r.add(Sl(u,t[i]))}return{p:r,f:o}},wNAFUnsafe(e,t,n,r=y.ZERO){const o=Tl(e,w);for(let e=0;e<o.windows&&n!==Al;e++){const{nextN:s,offset:a,isZero:i,isNeg:c}=$l(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=Bl.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&Bl.set(t,n(r))),r},wNAFCached(e,t,n){const r=Ol(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const o=Ol(e);return 1===o?this.unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)},setWindowSize(e,t){Nl(t,w),Cl.set(e,t),Bl.delete(e)}});var y,w;return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:l,weierstrassEquation:a,isWithinCurveOrder:function(e){return Aa(e,Ul,t.n)}}}function Vl(e){const t=function(e){const t=Rl(e);return Ba(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 fl(e,r)}function u(e){return pl(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:h}=ql({...t,toBytes(e,t,r){const o=t.toAffine(),s=n.toBytes(o.x),a=Pa;return oa("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=ya(o);if(!Aa(e,Ul,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&Ul)===Ul)&&(s=n.neg(s)),{x:e,y:s}}}});function p(e){return e>r>>Ul}const m=(e,t,n)=>ya(e.slice(t,n));class g{constructor(e,t,n){Ia("r",e,Ul,r),Ia("s",t,Ul,r),this.r=e,this.s=t,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(e){const t=o;return e=Ea("compactSignature",e,2*t),new g(m(e,0,t),m(e,t,2*t))}static fromDER(e){const{r:t,s:n}=Fl.toSig(Ea("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(Ea("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+Ll(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 ba(this.toDERHex())}toDERHex(){return Fl.hexFromSig(this)}toCompactRawBytes(){return ba(this.toCompactHex())}toCompactHex(){const e=o;return Ll(this.r,e)+Ll(this.s,e)}}const b={isValidPrivateKey(e){try{return d(e),!0}catch(e){return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const e=kl(t.n);return function(e,t,n=!1){const r=e.length,o=Pl(t),s=kl(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const a=fl(n?wa(e):ya(e),t-al)+al;return n?xa(a,o):va(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=Ea("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=ya(e),n=8*e.length-s;return n>0?t>>BigInt(n):t},v=t.bits2int_modN||function(e){return c(w(e))},x=Sa(s);function E(e){return Ia("num < 2^"+s,e,jl,x),va(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=Ea("msgHash",e),zl(o),f&&(e=Ea("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(Ea("extraEntropy",e))}const P=Pa(...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===jl)return;const s=c(n*c(A+o*y));if(s===jl)return;let a=(r.x===o?0:2)|Number(r.y&Ul),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=Na(e),o=Na(e),s=0;const a=()=>{r.fill(1),o.fill(0),s=0},i=(...e)=>n(o,r,...e),c=(e=Na(0))=>{o=i(Ta([0]),e),r=i(),0!==e.length&&(o=i(Ta([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 Pa(...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=Ea("msgHash",n),r=Ea("publicKey",r);const{lowS:a,prehash:i,format:d}=o;if(zl(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||na(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 Fl.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)=>ol(e,t,function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];rn(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:mn}}
11
11
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
12
- const Yu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ku=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Zu=BigInt(0),Ju=BigInt(1),Qu=BigInt(2),Xu=(e,t)=>(e+t/Qu)/t;const ed=Pu(Yu,void 0,void 0,{sqrt:function(e){const t=Yu,n=BigInt(3),r=BigInt(6),o=BigInt(11),a=BigInt(22),s=BigInt(23),i=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=pu(u,n,t)*u%t,f=pu(d,n,t)*u%t,h=pu(f,Qu,t)*l%t,p=pu(h,o,t)*h%t,m=pu(p,a,t)*p%t,g=pu(m,i,t)*m%t,b=pu(g,c,t)*g%t,y=pu(b,i,t)*m%t,w=pu(y,n,t)*u%t,v=pu(w,s,t)*p%t,x=pu(v,r,t)*l%t,E=pu(x,Qu,t);if(!ed.eql(ed.sqr(E),e))throw new Error("Cannot find square root");return E}}),td=function(e,t){const n=t=>Vu({...e,...Hu(t)});return{...n(t),create:n}}({a:Zu,b:BigInt(7),Fp:ed,n:Ku,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Ku,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Ju*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),a=n,s=BigInt("0x100000000000000000000000000000000"),i=Xu(a*e,t),c=Xu(-r*e,t);let l=hu(e-i*n-c*o,t),u=hu(-i*r-c*a,t);const d=l>s,f=u>s;if(d&&(l=t-l),f&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}}},Ca);var nd=Object.freeze({__proto__:null,secp256k1:td});function rd(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new cd({signature:e});if(void 0===e.s)throw new cd({signature:e});if(n&&void 0===e.yParity)throw new cd({signature:e});if(e.r<0n||e.r>Rl)throw new ld({value:e.r});if(e.s<0n||e.s>Rl)throw new ud({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new dd({value:e.yParity})}function od(e){if(130!==e.length&&132!==e.length)throw new id({signature:e});const t=BigInt(yi(e,0,32)),n=BigInt(yi(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return sd(t)}catch{throw new dd({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function ad(e){if(void 0!==e.r&&void 0!==e.s)return function(e){const t="string"==typeof e?od(e):e instanceof Uint8Array?function(e){return od(hi(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=sd(t)),"number"!=typeof n)throw new dd({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:sd(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return rd(t),t}(e)}function sd(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 fd({value:e})}class id extends _s{constructor({signature:e}){var t;super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${wi((t=e,t instanceof Uint8Array?hi(t):Array.isArray(t)?hi(new Uint8Array(t)):t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class cd extends _s{constructor({signature:e}){super(`Signature \`${Hs(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class ld extends _s{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 ud extends _s{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 dd extends _s{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 fd extends _s{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 hd(e,t={}){return"string"==typeof e.chainId?function(e){const{address:t,chainId:n,nonce:r}=e,o=ad(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...o}}(e):{...e,...t.signature}}const pd=Zl("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function md(e){if("string"==typeof e){if("0x8010801080108010801080108010801080108010801080108010801080108010"!==yi(e,-32))throw new gd(e)}else rd(e.authorization)}let gd=class extends _s{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 bd(e,{address:t,blockNumber:n,blockTag:r,storageKeys:o}){const a=r??"latest",s=void 0!==n?Wt(n):void 0;return function(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?Ft(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,s||a]}))}async function yd(e,{blockHash:t,blockNumber:n,blockTag:r,hash:o,index:a}){const s=r||"latest",i=void 0!==n?Wt(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,Wt(a)]},{dedupe:!0}):await e.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[i||s,Wt(a)]},{dedupe:Boolean(i)}),!c)throw new Vr({blockHash:t,blockNumber:n,blockTag:s,hash:o,index:a});return(e.chain?.formatters?.transaction?.format||ma)(c)}async function wd(e,{hash:t}){const n=await e.request({method:"eth_getTransactionReceipt",params:[t]},{dedupe:!0});if(!n)throw new Hr({hash:t});return(e.chain?.formatters?.transactionReceipt?.format||bc)(n)}async function vd(e,t){const{blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",blocks:o,returnFullTransactions:a,traceTransfers:s,validation:i}=t;try{const t=[];for(const e of o){const n=e.blockOverrides?Bi(e.blockOverrides):void 0,r=e.calls.map(e=>{const t=e,n=t.account?hr(t.account):void 0,r=t.abi?mr(t):t.data,o={...t,data:t.dataSuffix?Vn([r||"0x",t.dataSuffix]):r,from:t.from??n?.address};return la(o),oa(o)}),o=e.stateOverrides?ia(e.stateOverrides):void 0;t.push({blockOverrides:n,calls:r,stateOverrides:o})}const c=("bigint"==typeof n?Wt(n):void 0)||r;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:t,returnFullTransactions:a,traceTransfers:s,validation:i},c]})).map((e,t)=>({...ga(e),calls:e.calls.map((e,n)=>{const{abi:r,args:a,functionName:s,to:i}=o[t].calls[n],c=e.error?.data??e.returnData,l=BigInt(e.gasUsed),u=e.logs?.map(e=>Za(e)),d="0x1"===e.status?"success":"failure",f=r&&"success"===d&&"0x"!==c?es({abi:r,data:c,functionName:s}):null,h=(()=>{if("success"===d)return;let t;return"0x"===e.error?.data?t=new at:e.error&&(t=new eo(e.error)),t?_o(t,{abi:r??[],address:i??"0x",args:a,functionName:s??"<unknown>"}):void 0})();return{data:c,gasUsed:l,logs:u,status:d,..."success"===d?{result:f}:{error:h}}})}))}catch(e){const t=e,n=ta(t,{});if(n instanceof ea)throw t;throw n}}function xd(e){let t=!0,n="",r=0,o="",a=!1;for(let s=0;s<e.length;s++){const i=e[s];if(["(",")",","].includes(i)&&(t=!0),"("===i&&r++,")"===i&&r--,t)if(0!==r)" "!==i?(o+=i,n+=i):","!==e[s-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===i&&["event","function","error",""].includes(o))o="";else if(o+=i,")"===i){a=!0;break}}if(!a)throw new _s("Unable to normalize signature.");return o}function Ed(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Sl(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)=>Ed(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=>Ed(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function Pd(e,t,n){for(const r in e){const o=e[r],a=t[r];if("tuple"===o.type&&"tuple"===a.type&&"components"in o&&"components"in a)return Pd(o.components,a.components,n[r]);const s=[o.type,a.type];if((()=>!(!s.includes("address")||!s.includes("bytes20"))||(s.includes("address")&&s.includes("string")||!(!s.includes("address")||!s.includes("bytes")))&&Sl(n[r],{strict:!1}))())return s}}function kd(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?We(e):e;return{...r,...n?{hash:Nd(r)}:{}}}function Ad(e,t,n){const{args:r=[],prepare:o=!0}=n??{},a=Ei(t,{strict:!1}),s=e.filter(e=>a?"function"===e.type||"error"===e.type?Id(e)===yi(t,0,4):"event"===e.type&&Nd(e)===t:"name"in e&&e.name===t);if(0===s.length)throw new Td({name:t});if(1===s.length)return{...s[0],...o?{hash:Nd(s[0])}:{}};let i;for(const e of s){if(!("inputs"in e))continue;if(!r||0===r.length){if(!e.inputs||0===e.inputs.length)return{...e,...o?{hash:Nd(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&&Ed(t,r)});if(t){if(i&&"inputs"in i&&i.inputs){const t=Pd(e.inputs,i.inputs,r);if(t)throw new Sd({abiItem:e,type:t[0]},{abiItem:i,type:t[1]})}i=e}}const c=(()=>{if(i)return i;const[e,...t]=s;return{...e,overloads:t}})();if(!c)throw new Td({name:t});return{...c,...o?{hash:Nd(c)}:{}}}function Id(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Ad(t,n)}return e[0]})();return yi(Nd(t),0,4)}function Nd(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Ad(t,n)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:kl(mi(function(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Ad(t,n)}return e[0]})();return xd("string"==typeof t?t:oe(t))}(t)))}class Sd extends _s{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${xd(oe(e.abiItem))}\`, and`,`\`${t.type}\` in \`${xd(oe(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 Td extends _s{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 Bd(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new Td({name:"constructor"});return t}function Cd(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[t,n,r]=e;return[Od(t,n,{args:r}),r]}const[t,n]=e;return[t,n]})(),{overloads:r}=t,o=r?Od([t,...r],t.name,{args:n}):t,a=Id(o);const s=n.length>0?Yl(o.inputs,n):void 0;return s?di(a,s):a}function $d(e,t={}){return kd(e,t)}function Od(e,t,n){const r=Ad(e,t,n);if("function"!==r.type)throw new Td({name:t,type:"function"});return r}const _d="0x0000000000000000000000000000000000000000";async function Rd(e,t){const{blockNumber:n,blockTag:r,calls:o,stateOverrides:a,traceAssetChanges:s,traceTransfers:i,validation:c}=t,l=t.account?hr(t.account):void 0;if(s&&!l)throw new et("`account` is required when `traceAssetChanges` is true");const u=l?function(...e){const[t,n]=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return[Bd(t),n]}return e})(),{bytecode:r,args:o}=n;return di(r,t.inputs?.length&&o?.length?Yl(t.inputs,o):"0x")}(kd("constructor(bytes, bytes)"),{bytecode:ji,args:["0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033",Cd($d("function getBalance(address)"),[l.address])]}):void 0;const d=s?await Promise.all(t.calls.map(async t=>{if(!t.data&&!t.abi)return;const{accessList:n}=await Vc(e,{account:l.address,...t,data:t.abi?mr(t):t.data});return n.map(({address:e,storageKeys:t})=>t.length>0?e:null)})).then(e=>e.flat().filter(Boolean)):[],f=await vd(e,{blockNumber:n,blockTag:r,blocks:[...s?[{calls:[{data:u}],stateOverrides:a},{calls:d.map((e,t)=>({abi:[$d("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[l.address],to:e,from:_d,nonce:t})),stateOverrides:[{address:_d,nonce:0}]}]:[],{calls:[...o,{}].map(e=>({...e,from:l?.address})),stateOverrides:a},...s?[{calls:[{data:u}]},{calls:d.map((e,t)=>({abi:[$d("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[l.address],to:e,from:_d,nonce:t})),stateOverrides:[{address:_d,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[$d("function decimals() returns (uint256)")],functionName:"decimals",from:_d,nonce:t})),stateOverrides:[{address:_d,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[$d("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:_d,nonce:t})),stateOverrides:[{address:_d,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[$d("function symbol() returns (string)")],functionName:"symbol",from:_d,nonce:t})),stateOverrides:[{address:_d,nonce:0}]}]:[]],traceTransfers:i,validation:c}),h=s?f[2]:f[0],[p,m,,g,b,y,w,v]=s?f:[],{calls:x,...E}=h,P=x.slice(0,-1)??[],k=[...p?.calls??[],...m?.calls??[]].map(e=>"success"===e.status?Lt(e.data):null),A=[...g?.calls??[],...b?.calls??[]].map(e=>"success"===e.status?Lt(e.data):null),I=(y?.calls??[]).map(e=>"success"===e.status?e.result:null),N=(v?.calls??[]).map(e=>"success"===e.status?e.result:null),S=(w?.calls??[]).map(e=>"success"===e.status?e.result:null),T=[];for(const[e,t]of A.entries()){const n=k[e];if("bigint"!=typeof t)continue;if("bigint"!=typeof n)continue;const r=I[e-1],o=N[e-1],a=S[e-1],s=(()=>0===e?{address:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",decimals:18,symbol:"ETH"}:{address:d[e-1],decimals:a||r?Number(r??1):void 0,symbol:o??void 0})();T.some(e=>e.token.address===s.address)||T.push({token:s,value:{pre:n,post:t,diff:t-n}})}return{assetChanges:T,block:E,results:P}}const zd="0x6492649264926492649264926492649264926492649264926492649264926492";function Md(e){try{return function(e){if(yi(e,-32)!==zd)throw new Ld(e)}(e),!0}catch{return!1}}class Ld extends _s{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 Fd({r:e,s:t,to:n="hex",v:r,yParity:o}){const a=(()=>{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")})(),s=`0x${new td.Signature(Lt(e),Lt(t)).toCompactHex()}${0===a?"1b":"1c"}`;return"hex"===n?s:Jt(s)}async function Ud(e,t){const{address:n,hash:r,erc6492VerifierAddress:o=t.universalSignatureVerifierAddress??e.chain?.contracts?.erc6492Verifier?.address,multicallAddress:a=t.multicallAddress??e.chain?.contracts?.multicall3?.address}=t,s=(()=>{const e=t.signature;return Ke(e)?e:"object"==typeof e&&"r"in e&&"s"in e?Fd(e):Gt(e)})();try{return function(e){try{return md(e),!0}catch{return!1}}(s)?await async function(e,t){const{address:n,blockNumber:r,blockTag:o,hash:a,multicallAddress:s}=t,{authorization:i,data:c,signature:l,to:u}=function(e){md(e);const t=xi(yi(e,-64,-32)),n=yi(e,-t-64,-64),r=yi(e,0,-t-64),[o,a,s]=Hl(pd,n);return{authorization:hd({address:o.delegation,chainId:Number(o.chainId),nonce:o.nonce,yParity:o.yParity,r:o.r,s:o.s}),signature:r,...s&&"0x"!==s?{data:s,to:a}:{}}}(t.signature),d=await Kc(e,{address:n,blockNumber:r,blockTag:o});if(d===Hn(["0xef0100",i.address]))return await async function(e,t){const{address:n,blockNumber:r,blockTag:o,hash:a,signature:s}=t,i=await Ve(e,nc,"readContract")({address:n,abi:Li,args:[a,s],blockNumber:r,blockTag:o,functionName:"isValidSignature"}).catch(e=>{if(e instanceof Zr)throw new jd;throw e});if(i.startsWith("0x1626ba7e"))return!0;throw new jd}(e,{address:n,blockNumber:r,blockTag:o,hash:a,signature:l});const f={address:i.address,chainId:Number(i.chainId),nonce:Number(i.nonce),r:Wt(i.r,{size:32}),s:Wt(i.s,{size:32}),yParity:i.yParity},h=await async function({address:e,authorization:t,signature:n}){return qa(Dn(e),await jo({authorization:t,signature:n}))}({address:n,authorization:f});if(!h)throw new jd;const p=await Ve(e,nc,"readContract")({...s?{address:s}:{code:Wi},authorizationList:[f],abi:Ci,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...c?[{allowFailure:!0,target:u??n,callData:c}]:[],{allowFailure:!0,target:n,callData:mr({abi:Li,functionName:"isValidSignature",args:[a,l]})}]]}),m=p[p.length-1]?.returnData;if(m?.startsWith("0x1626ba7e"))return!0;throw new jd}(e,{...t,multicallAddress:a,signature:s}):await async function(e,t){const{address:n,factory:r,factoryData:o,hash:a,signature:s,verifierAddress:i,...c}=t,l=await(async()=>r||o?Md(s)?s:function(e){const{data:t,signature:n,to:r}=e;return di(Yl(Zl("address, bytes, bytes"),[r,t,n]),zd)}({data:o,signature:s,to:r}):s)(),u=i?{to:i,data:mr({abi:Fi,functionName:"isValidSig",args:[n,a,l]}),...c}:{data:Yi({abi:Fi,args:[n,a,l],bytecode:Gi}),...c},{data:d}=await Ve(e,ec,"call")(u).catch(e=>{if(e instanceof Kr)throw new jd;throw e});if(function(e,t={}){let n=e;if(t.size&&(Mt(n,{size:t.size}),n=zt(n)),"0x00"===zt(n))return!1;if("0x01"===zt(n))return!0;throw new _t(n)}(d??"0x0"))return!0;throw new jd}(e,{...t,verifierAddress:o,signature:s})}catch(e){try{if(qa(Dn(n),await zo({hash:r,signature:s})))return!0}catch{}if(e instanceof jd)return!1;throw e}}class jd extends Error{}function Dd(e,{emitOnBegin:t=!1,emitMissed:n=!1,onBlockNumber:r,onError:o,poll:a,pollingInterval:s=e.pollingInterval}){let i;return(void 0!==a?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))?sc(Or(["watchBlockNumber",e.uid,t,n,s]),{onBlockNumber:r,onError:o},r=>cc(async()=>{try{const t=await Ve(e,fc,"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:s})):sc(Or(["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:a}=await o.subscribe({params:["newHeads"],onData(e){if(!n)return;const r=Lt(e.result?.number);t.onBlockNumber(r,i),i=r},onError(e){t.onError?.(e)}});r=a,n||r()}catch(e){o?.(e)}})(),()=>r()})}const Gd=/^(?:(?<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)?/,Wd=/(?: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 qd(e,t){const{address:n,domain:r,message:o,nonce:a,scheme:s,signature:i,time:c=new Date,...l}=t,u=function(e){const{scheme:t,statement:n,...r}=e.match(Gd)?.groups??{},{chainId:o,expirationTime:a,issuedAt:s,notBefore:i,requestId:c,...l}=e.match(Wd)?.groups??{},u=e.split("Resources:")[1]?.split("\n- ").slice(1);return{...r,...l,...o?{chainId:Number(o)}:{},...a?{expirationTime:new Date(a)}:{},...s?{issuedAt:new Date(s)}:{},...i?{notBefore:new Date(i)}:{},...c?{requestId:c}:{},...u?{resources:u}:{},...t?{scheme:t}:{},...n?{statement:n}:{}}}(o);if(!u.address)return!1;const d=function(e){const{address:t,domain:n,message:r,nonce:o,scheme:a,time:s=new Date}=e;if(n&&r.domain!==n)return!1;if(o&&r.nonce!==o)return!1;if(a&&r.scheme!==a)return!1;if(r.expirationTime&&s>=r.expirationTime)return!1;if(r.notBefore&&s<r.notBefore)return!1;try{if(!r.address)return!1;if(!qn(r.address,{strict:!1}))return!1;if(t&&!qa(r.address,t))return!1}catch{return!1}return!0}({address:n,domain:r,message:u,nonce:a,scheme:s,time:c});if(!d)return!1;const f=ul(o);return Ud(e,{address:u.address,hash:f,signature:i,...l})}function Vd(e){return{call:t=>ec(e,t),createAccessList:t=>Vc(e,t),createBlockFilter:()=>async function(e){const t=dr(e,{method:"eth_newBlockFilter"}),n=await e.request({method:"eth_newBlockFilter"});return{id:n,request:t(n),type:"block"}}(e),createContractEventFilter:t=>fr(e,t),createEventFilter:t=>Hc(e,t),createPendingTransactionFilter:()=>Yc(e),estimateContractGas:t=>async function(e,t){const{abi:n,address:r,args:o,functionName:a,dataSuffix:s,...i}=t,c=mr({abi:n,args:o,functionName:a});try{return await Ve(e,Wa,"estimateGas")({data:`${c}${s?s.replace("0x",""):""}`,to:r,...i})}catch(e){const t=i.account?hr(i.account):void 0;throw _o(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/estimateContractGas",functionName:a,sender:t?.address})}}(e,t),estimateGas:t=>Wa(e,t),getBalance:t=>async function(e,{address:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest"}){const o="bigint"==typeof n?Wt(n):void 0,a=await e.request({method:"eth_getBalance",params:[t,o||r]});return BigInt(a)}(e,t),getBlobBaseFee:()=>async function(e){const t=await e.request({method:"eth_blobBaseFee"});return BigInt(t)}(e),getBlock:t=>ba(e,t),getBlockNumber:t=>fc(e,t),getBlockTransactionCount:t=>async function(e,{blockHash:t,blockNumber:n,blockTag:r="latest"}={}){const o=void 0!==n?Wt(n):void 0;let a;return a=t?await e.request({method:"eth_getBlockTransactionCountByHash",params:[t]},{dedupe:!0}):await e.request({method:"eth_getBlockTransactionCountByNumber",params:[o||r]},{dedupe:Boolean(o)}),Ft(a)}(e,t),getBytecode:t=>Kc(e,t),getChainId:()=>Ua(e),getCode:t=>Kc(e,t),getContractEvents:t=>Qa(e,t),getEip712Domain:t=>async function(e,t){const{address:n,factory:r,factoryData:o}=t;try{const[t,a,s,i,c,l,u]=await Ve(e,nc,"readContract")({abi:Jc,address:n,functionName:"eip712Domain",factory:r,factoryData:o});return{domain:{name:a,version:s,chainId:Number(i),verifyingContract:c,salt:l},extensions:u,fields:t}}catch(e){const t=e;if("ContractFunctionExecutionError"===t.name&&"ContractFunctionZeroDataError"===t.cause.name)throw new Zc({address:n});throw t}}(e,t),getEnsAddress:t=>async function(e,t){const{blockNumber:n,blockTag:r,coinType:o,name:a,gatewayUrls:s,strict:i}=t,{chain:c}=e,l=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Ki({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),u=c?.ensTlds;if(u&&!u.some(e=>a.endsWith(e)))return null;const d=null!=o?[Sc(a),BigInt(o)]:[Sc(a)];try{const t=mr({abi:Mi,functionName:"addr",args:d}),o={address:l,abi:_i,functionName:"resolveWithGateways",args:[jt(Cc(a)),t,s??[Ac]],blockNumber:n,blockTag:r},i=Ve(e,nc,"readContract"),c=await i(o);if("0x"===c[0])return null;const u=es({abi:Mi,args:d,functionName:"addr",data:c[0]});return"0x"===u||"0x00"===zt(u)?null:u}catch(e){if(i)throw e;if(xc(e))return null;throw e}}(e,t),getEnsAvatar:t=>async function(e,{blockNumber:t,blockTag:n,assetGatewayUrls:r,name:o,gatewayUrls:a,strict:s,universalResolverAddress:i}){const c=await Ve(e,qc,"getEnsText")({blockNumber:t,blockTag:n,key:"avatar",name:o,universalResolverAddress:i,gatewayUrls:a,strict:s});if(!c)return null;try{return await Wc(e,{record:c,gatewayUrls:r})}catch{return null}}(e,t),getEnsName:t=>async function(e,t){const{address:n,blockNumber:r,blockTag:o,coinType:a=60n,gatewayUrls:s,strict:i}=t,{chain:c}=e,l=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Ki({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})();try{const t={address:l,abi:Ri,args:[n,a,s??[Ac]],functionName:"reverseWithGateways",blockNumber:r,blockTag:o},i=Ve(e,nc,"readContract"),[c]=await i(t);return c||null}catch(e){if(i)throw e;if(xc(e))return null;throw e}}(e,t),getEnsResolver:t=>async function(e,t){const{blockNumber:n,blockTag:r,name:o}=t,{chain:a}=e,s=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!a)throw new Error("client chain not configured. universalResolverAddress is required.");return Ki({blockNumber:n,chain:a,contract:"ensUniversalResolver"})})(),i=a?.ensTlds;if(i&&!i.some(e=>o.endsWith(e)))throw new Error(`${o} is not a valid ENS TLD (${i?.join(", ")}) for chain "${a.name}" (id: ${a.id}).`);const[c]=await Ve(e,nc,"readContract")({address:s,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[jt(Cc(o))],blockNumber:n,blockTag:r});return c}(e,t),getEnsText:t=>qc(e,t),getFeeHistory:t=>Qc(e,t),estimateFeesPerGas:t=>async function(e,t){return va(e,t)}(e,t),getFilterChanges:e=>hc(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=>Za(e));return t.abi?Ka({abi:t.abi,logs:r,strict:n}):r}(0,e),getGasPrice:()=>ya(e),getLogs:t=>Ja(e,t),getProof:t=>bd(e,t),estimateMaxPriorityFeePerGas:t=>async function(e,t){return wa(e,t)}(e,t),getStorageAt:t=>async function(e,{address:t,blockNumber:n,blockTag:r="latest",slot:o}){const a=void 0!==n?Wt(n):void 0;return await e.request({method:"eth_getStorageAt",params:[t,o,a||r]})}(e,t),getTransaction:t=>yd(e,t),getTransactionConfirmations:t=>async function(e,{hash:t,transactionReceipt:n}){const[r,o]=await Promise.all([Ve(e,fc,"getBlockNumber")({}),t?Ve(e,yd,"getTransaction")({hash:t}):void 0]),a=n?.blockNumber||o?.blockNumber;return a?r-a+1n:0n}(e,t),getTransactionCount:t=>xa(e,t),getTransactionReceipt:t=>wd(e,t),multicall:t=>async function(e,t){const{account:n,authorizationList:r,allowFailure:o=!0,blockNumber:a,blockOverrides:s,blockTag:i,stateOverride:c}=t,l=t.contracts,{batchSize:u=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 Ki({blockNumber:a,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<l.length;e++){const{abi:t,address:r,args:a,functionName:s}=l[e];try{const e=mr({abi:t,args:a,functionName:s});m+=(e.length-2)/2,u>0&&m>u&&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=_o(e,{abi:t,address:r,args:a,docsPath:"/docs/contract/multicall",functionName:s,sender:n});if(!o)throw i;h[p]=[...h[p],{allowFailure:!0,callData:"0x",target:r}]}}const g=await Promise.allSettled(h.map(t=>Ve(e,nc,"readContract")({...null===f?{code:Wi}:{address:f},abi:Ci,account:n,args:[t],authorizationList:r,blockNumber:a,blockOverrides:s,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:a}=n[t],{callData:s}=h[e][t],{abi:i,address:c,functionName:u,args:d}=l[b.length];try{if("0x"===s)throw new at;if(!a)throw new eo({data:r});const e=es({abi:i,args:d,data:r,functionName:u});b.push(o?{result:e,status:"success"}:e)}catch(e){const t=_o(e,{abi:i,address:c,args:d,docsPath:"/docs/contract/multicall",functionName:u});if(!o)throw t;b.push({error:t,result:void 0,status:"failure"})}}}if(b.length!==l.length)throw new et("multicall results mismatch");return b}(e,t),prepareTransactionRequest:t=>Ga(e,t),readContract:t=>nc(e,t),sendRawTransaction:t=>async function(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}(e,t),simulate:t=>vd(e,t),simulateBlocks:t=>vd(e,t),simulateCalls:t=>Rd(e,t),simulateContract:t=>async function(e,t){const{abi:n,address:r,args:o,dataSuffix:a,functionName:s,...i}=t,c=i.account?hr(i.account):e.account,l=mr({abi:n,args:o,functionName:s});try{const{data:u}=await Ve(e,ec,"call")({batch:!1,data:`${l}${a?a.replace("0x",""):""}`,to:r,...i,account:c});return{result:es({abi:n,args:o,functionName:s,data:u||"0x"}),request:{abi:n.filter(e=>"name"in e&&e.name===t.functionName),address:r,args:o,dataSuffix:a,functionName:s,...i,account:c}}}catch(e){throw _o(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/simulateContract",functionName:s,sender:c?.address})}}(e,t),verifyHash:t=>Ud(e,t),verifyMessage:t=>async function(e,{address:t,message:n,factory:r,factoryData:o,signature:a,...s}){return Ud(e,{address:t,factory:r,factoryData:o,hash:ul(n),signature:a,...s})}(e,t),verifySiweMessage:t=>qd(e,t),verifyTypedData:t=>async function(e,t){const{address:n,factory:r,factoryData:o,signature:a,message:s,primaryType:i,types:c,domain:l,...u}=t;return Ud(e,{address:n,factory:r,factoryData:o,hash:gl({message:s,primaryType:i,types:c,domain:l}),signature:a,...u})}(e,t),uninstallFilter:e=>pc(0,e),waitForTransactionReceipt:t=>async function(e,t){const{checkReplacement:n=!0,confirmations:r=1,hash:o,onReplaced:a,retryCount:s=6,retryDelay:i=({count:e})=>200*(1<<e),timeout:c=18e4}=t,l=Or(["waitForTransactionReceipt",e.uid,o]),u=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}=Ji(),v=c?setTimeout(()=>{m?.(),p?.(),w(new Yr({hash:o}))},c):void 0;return p=sc(l,{onReplaced:a,resolve:y,reject:w},async t=>{if(h=await Ve(e,wd,"getTransactionReceipt")({hash:o}).catch(()=>{}),h&&r<=1)return clearTimeout(v),t.resolve(h),void p?.();m=Ve(e,Dd,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:u,async onBlockNumber(a){const c=e=>{clearTimeout(v),m?.(),e(),p?.()};let l=a;if(!g)try{if(h){if(r>1&&(!h.blockNumber||l-h.blockNumber+1n<r))return;return void c(()=>t.resolve(h))}if(n&&!d&&(g=!0,await mc(async()=>{d=await Ve(e,yd,"getTransaction")({hash:o}),d.blockNumber&&(l=d.blockNumber)},{delay:i,retryCount:s}),g=!1),h=await Ve(e,wd,"getTransactionReceipt")({hash:o}),r>1&&(!h.blockNumber||l-h.blockNumber+1n<r))return;c(()=>t.resolve(h))}catch(n){if(n instanceof Vr||n instanceof Hr){if(!d)return void(g=!1);try{f=d,g=!0;const n=await mc(()=>Ve(e,ba,"getBlock")({blockNumber:l,includeTransactions:!0}),{delay:i,retryCount:s,shouldRetry:({error:e})=>e instanceof ha});g=!1;const o=n.transactions.find(({from:e,nonce:t})=>e===f.from&&t===f.nonce);if(!o)return;if(h=await Ve(e,wd,"getTransactionReceipt")({hash:o.hash}),r>1&&(!h.blockNumber||l-h.blockNumber+1n<r))return;let a="replaced";o.to===f.to&&o.value===f.value&&o.input===f.input?a="repriced":o.from===o.to&&0n===o.value&&(a="cancelled"),c(()=>{t.onReplaced?.({reason:a,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:a,includeTransactions:s,poll:i,pollingInterval:c=e.pollingInterval}){const l=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),u=s??!1;let d;return l?sc(Or(["watchBlocks",e.uid,t,n,r,u,c]),{onBlock:o,onError:a},o=>cc(async()=>{try{const r=await Ve(e,ba,"getBlock")({blockTag:t,includeTransactions:u});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 Ve(e,ba,"getBlock")({blockNumber:t,includeTransactions:u});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,s=!0,i=()=>n=!1;return(async()=>{try{r&&Ve(e,ba,"getBlock")({blockTag:t,includeTransactions:u}).then(e=>{n&&s&&(o(e,void 0),s=!1)}).catch(a);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:l}=await c.subscribe({params:["newHeads"],async onData(t){if(!n)return;const r=await Ve(e,ba,"getBlock")({blockNumber:t.result?.number,includeTransactions:u}).catch(()=>{});n&&(o(r,d),s=!1,d=r)},onError(e){a?.(e)}});i=l,n||i()}catch(e){a?.(e)}})(),()=>i()})()}(e,t),watchBlockNumber:t=>Dd(e,t),watchContractEvent:t=>function(e,t){const{abi:n,address:r,args:o,batch:a=!0,eventName:s,fromBlock:i,onError:c,onLogs:l,poll:u,pollingInterval:d=e.pollingInterval,strict:f}=t;return(void 0!==u?u:"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 sc(Or(["watchContractEvent",r,o,a,e.uid,s,d,t,i]),{onLogs:l,onError:c},c=>{let l,u;void 0!==i&&(l=i-1n);let f=!1;const h=cc(async()=>{if(f)try{let i;if(u)i=await Ve(e,hc,"getFilterChanges")({filter:u});else{const a=await Ve(e,fc,"getBlockNumber")({});i=l&&l<a?await Ve(e,Qa,"getContractEvents")({abi:n,address:r,args:o,eventName:s,fromBlock:l+1n,toBlock:a,strict:t}):[],l=a}if(0===i.length)return;if(a)c.onLogs(i);else for(const e of i)c.onLogs([e])}catch(e){u&&e instanceof fo&&(f=!1),c.onError?.(e)}else{try{u=await Ve(e,fr,"createContractEventFilter")({abi:n,address:r,args:o,eventName:s,strict:t,fromBlock:i})}catch{}f=!0}},{emitOnBegin:!0,interval:d});return async()=>{u&&await Ve(e,pc,"uninstallFilter")({filter:u}),h()}})})():(()=>{const t=f??!1,i=Or(["watchContractEvent",r,o,a,e.uid,s,d,t]);let u=!0,h=()=>u=!1;return sc(i,{onLogs:l,onError:c},t=>((async()=>{try{const a=(()=>{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=s?lr({abi:n,eventName:s,args:o}):[],{unsubscribe:c}=await a.subscribe({params:["logs",{address:r,topics:i}],onData(e){if(!u)return;const r=e.result;try{const{eventName:e,args:o}=Ha({abi:n,data:r.data,topics:r.topics,strict:f}),a=Za(r,{args:o,eventName:e});t.onLogs([a])}catch(e){let n,o;if(e instanceof vt||e instanceof xt){if(f)return;n=e.abiItem.name,o=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const a=Za(r,{args:o?[]:{},eventName:n});t.onLogs([a])}},onError(e){t.onError?.(e)}});h=c,u||h()}catch(e){c?.(e)}})(),()=>h()))})()}(e,t),watchEvent:t=>function(e,{address:t,args:n,batch:r=!0,event:o,events:a,fromBlock:s,onError:i,onLogs:c,poll:l,pollingInterval:u=e.pollingInterval,strict:d}){const f=void 0!==l?l:"bigint"==typeof 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),h=d??!1;return f?sc(Or(["watchEvent",t,n,r,e.uid,o,u,s]),{onLogs:c,onError:i},i=>{let c,l;void 0!==s&&(c=s-1n);let d=!1;const f=cc(async()=>{if(d)try{let s;if(l)s=await Ve(e,hc,"getFilterChanges")({filter:l});else{const r=await Ve(e,fc,"getBlockNumber")({});s=c&&c!==r?await Ve(e,Ja,"getLogs")({address:t,args:n,event:o,events:a,fromBlock:c+1n,toBlock:r}):[],c=r}if(0===s.length)return;if(r)i.onLogs(s);else for(const e of s)i.onLogs([e])}catch(e){l&&e instanceof fo&&(d=!1),i.onError?.(e)}else{try{l=await Ve(e,Hc,"createEventFilter")({address:t,args:n,event:o,events:a,strict:h,fromBlock:s})}catch{}d=!0}},{emitOnBegin:!0,interval:u});return async()=>{l&&await Ve(e,pc,"uninstallFilter")({filter:l}),f()}}):(()=>{let r=!0,s=()=>r=!1;return(async()=>{try{const l=(()=>{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})(),u=a??(o?[o]:void 0);let f=[];if(u){const e=u.flatMap(e=>lr({abi:[e],eventName:e.name,args:n}));f=[e],o&&(f=f[0])}const{unsubscribe:p}=await l.subscribe({params:["logs",{address:t,topics:f}],onData(e){if(!r)return;const t=e.result;try{const{eventName:e,args:n}=Ha({abi:u??[],data:t.data,topics:t.topics,strict:h}),r=Za(t,{args:n,eventName:e});c([r])}catch(e){let n,r;if(e instanceof vt||e instanceof xt){if(d)return;n=e.abiItem.name,r=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const o=Za(t,{args:r?[]:{},eventName:n});c([o])}},onError(e){i?.(e)}});s=p,r||s()}catch(e){i?.(e)}})(),()=>s()})()}(e,t),watchPendingTransactions:t=>function(e,{batch:t=!0,onError:n,onTransactions:r,poll:o,pollingInterval:a=e.pollingInterval}){return(void 0!==o?o:"webSocket"!==e.transport.type&&"ipc"!==e.transport.type)?sc(Or(["watchPendingTransactions",e.uid,t,a]),{onTransactions:r,onError:n},n=>{let r;const o=cc(async()=>{try{if(!r)try{return void(r=await Ve(e,Yc,"createPendingTransactionFilter")({}))}catch(e){throw o(),e}const a=await Ve(e,hc,"getFilterChanges")({filter:r});if(0===a.length)return;if(t)n.onTransactions(a);else for(const e of a)n.onTransactions([e])}catch(e){n.onError?.(e)}},{emitOnBegin:!0,interval:a});return async()=>{r&&await Ve(e,pc,"uninstallFilter")({filter:r}),o()}}):(()=>{let t=!0,o=()=>t=!1;return(async()=>{try{const{unsubscribe:a}=await e.transport.subscribe({params:["newPendingTransactions"],onData(e){if(!t)return;const n=e.result;r([n])},onError(e){n?.(e)}});o=a,t||o()}catch(e){n?.(e)}})(),()=>o()})()}(e,t)}}function Hd(e){const{key:t="public",name:n="Public Client"}=e,r=function(e){const{batch:t,chain:n,ccipRead:r,key:o="base",name:a="Base Client",type:s="base"}=e,i=e.experimental_blockTag??("number"==typeof n?.experimental_preconfirmationTime?"pending":void 0),c=n?.blockTime??12e3,l=Math.min(Math.max(Math.floor(c/2),500),4e3),u=e.pollingInterval??l,d=e.cacheTime??u,f=e.account?hr(e.account):void 0,{config:h,request:p,value:m}=e.transport({chain:n,pollingInterval:u}),g={account:f,batch:t,cacheTime:d,ccipRead:r,chain:n,key:o,name:a,pollingInterval:u,request:p,transport:{...h,...m},type:s,uid:vc(),...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(Vd)}class Yd extends et{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 Kd(e,t={}){const{batch:n,fetchFn:r,fetchOptions:o,key:a="http",methods:s,name:i="HTTP JSON-RPC",onFetchRequest:c,onFetchResponse:l,retryDelay:u,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 Yd;const v=ll(w,{fetchFn:r,fetchOptions:o,onRequest:c,onResponse:l,timeout:y});return function({key:e,methods:t,name:n,request:r,retryCount:o=3,retryDelay:a=150,timeout:s,type:i},c){return{config:{key:e,methods:t,name:n,request:r,retryCount:o,retryDelay:a,timeout:s,type:i},request:el(r,{methods:t,retryCount:o,retryDelay:a,uid:vc()}),value:c}}({key:a,methods:s,name:i,async request({method:e,params:t}){const r={method:e,params:t},{schedule:o}=Xi({id:w,wait:g,shouldSplitBatch:e=>e.length>m,fn:e=>v.request({body:e}),sort:(e,t)=>e.id-t.id}),[{error:a,result:s}]=await(async e=>n?o(e):[await v.request({body:e})])(r);if(d)return{error:a,result:s};if(a)throw new no({body:r,error:a,url:w});return s},retryCount:b,retryDelay:u,timeout:y,type:"http"},{fetchOptions:o,url:w})}}function Zd(e,t,n){for(let n in t){let r=t[n];Object.defineProperty(e,n,{enumerable:!0,value:r,writable:!1})}}function Jd(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=>Jd(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 Jd(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=>`${Jd(n,t)}: ${Jd(e[n],t)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Qd(e,t,n,r){if(!e)throw function(e,t,n){let r,o=e;{const r=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${Jd(n)}`);for(const e in n){if("shortMessage"===e)continue;const t=n[e];r.push(e+"="+Jd(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 Zd(r,{code:t}),n&&Object.assign(r,n),null==r.shortMessage&&Zd(r,{shortMessage:o}),r}(t,n,r)}function Xd(e,t,n,r){Qd(e,t,"INVALID_ARGUMENT",{argument:n,value:r})}function ef(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}Xd(!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 tf=BigInt(0),nf=BigInt(1),rf=9007199254740991;function of(e,t){const n=cf(e,"value"),r=BigInt(uf(t,"width"));if(Qd(n>>r===tf,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),n>>r-nf){return-((~n&(nf<<r)-nf)+nf)}return n}function af(e,t){const n=cf(e,"value"),r=BigInt(uf(t,"bits"));return n&(nf<<r)-nf}function sf(e,t){switch(typeof e){case"bigint":return e;case"number":return Xd(Number.isInteger(e),"underflow",t||"value",e),Xd(e>=-rf&&e<=rf,"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){Xd(!1,`invalid BigNumberish string: ${n.message}`,t||"value",e)}}Xd(!1,"invalid BigNumberish value",t||"value",e)}function cf(e,t){const n=sf(e,t);return Qd(n>=tf,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),n}const lf="0123456789abcdef";function uf(e,t){switch(typeof e){case"bigint":return Xd(e>=-rf&&e<=rf,"overflow",t||"value",e),Number(e);case"number":return Xd(Number.isInteger(e),"underflow",t||"value",e),Xd(e>=-rf&&e<=rf,"overflow",t||"value",e),e;case"string":try{if(""===e)throw new Error("empty string");return uf(BigInt(e),t)}catch(n){Xd(!1,`invalid numeric string: ${n.message}`,t||"value",e)}}Xd(!1,"invalid numeric value",t||"value",e)}const df=BigInt(-1),ff=BigInt(0),hf=BigInt(1),pf=BigInt(5),mf={};let gf="0000";for(;gf.length<80;)gf+=gf;function bf(e){let t=gf;for(;t.length<e;)t+=t;return BigInt("1"+t.substring(0,e))}function yf(e,t,n){const r=BigInt(t.width);if(t.signed){const t=hf<<r-hf;Qd(null==n||e>=-t&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=e>ff?of(af(e,r),r):-of(af(-e,r),r)}else{const t=hf<<r;Qd(null==n||e>=0&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=(e%t+t)%t&t-hf}return e}function wf(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]+)$/);Xd(o,"invalid fixed format","format",e),t="u"!==o[1],n=parseInt(o[2]),r=parseInt(o[3])}else if(e){const o=e,a=(e,t,n)=>null==o[e]?n:(Xd(typeof o[e]===t,"invalid fixed format ("+e+" not "+t+")","format."+e,o[e]),o[e]);t=a("signed","boolean",t),n=a("width","number",n),r=a("decimals","number",r)}Xd(n%8==0,"invalid FixedNumber width (not byte aligned)","format.width",n),Xd(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 vf{format;#e;#t;#n;_value;constructor(e,t,n){!function(e,t,n){if(e!==t){let e=n,t="new";e+=".",t+=" "+n,Qd(!1,`private constructor; use ${e}from* methods`,"UNSUPPORTED_OPERATION",{operation:t})}}(e,mf,"FixedNumber"),this.#t=t,this.#e=n;const r=function(e,t){let n="";e<ff&&(n="-",e*=df);let r=e.toString();if(0===t)return n+r;for(;r.length<=t;)r=gf+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);Zd(this,{format:n.name,_value:r}),this.#n=bf(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){Xd(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)}#o(e,t){return e=yf(e,this.#e,t),new vf(mf,e,this.#e)}#a(e,t){return this.#r(e),this.#o(this.#t+e.#t,t)}addUnsafe(e){return this.#a(e)}add(e){return this.#a(e,"add")}#s(e,t){return this.#r(e),this.#o(this.#t-e.#t,t)}subUnsafe(e){return this.#s(e)}sub(e){return this.#s(e,"sub")}#i(e,t){return this.#r(e),this.#o(this.#t*e.#t/this.#n,t)}mulUnsafe(e){return this.#i(e)}mul(e){return this.#i(e,"mul")}mulSignal(e){this.#r(e);const t=this.#t*e.#t;return Qd(t%this.#n===ff,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),this.#o(t/this.#n,"mulSignal")}#c(e,t){return Qd(e.#t!==ff,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),this.#r(e),this.#o(this.#t*this.#n/e.#t,t)}divUnsafe(e){return this.#c(e)}div(e){return this.#c(e,"div")}divSignal(e){Qd(e.#t!==ff,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),this.#r(e);const t=this.#t*this.#n;return Qd(t%e.#t===ff,"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*=bf(r):r<0&&(t*=bf(-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<ff&&(e-=this.#n-hf),e=this.#t/this.#n*this.#n,this.#o(e,"floor")}ceiling(){let e=this.#t;return this.#t>ff&&(e+=this.#n-hf),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=pf*bf(t-1);let r=this.value+n;const o=bf(t);return r=r/o*o,yf(r,this.#e,"round"),new vf(mf,r,this.#e)}isZero(){return this.#t===ff}isNegative(){return this.#t<ff}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return vf.fromString(this.toString(),e)}static fromValue(e,t,n){const r=null==t?0:uf(t),o=wf(n);let a=sf(e,"value");const s=r-o.decimals;if(s>0){const t=bf(s);Qd(a%t===ff,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),a/=t}else s<0&&(a*=bf(-s));return yf(a,o,"fromValue"),new vf(mf,a,o)}static fromString(e,t){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Xd(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const r=wf(t);let o=n[2]||"0",a=n[3]||"";for(;a.length<r.decimals;)a+=gf;Qd(a.substring(r.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),a=a.substring(0,r.decimals);const s=BigInt(n[1]+o+a);return yf(s,r,"fromString"),new vf(mf,s,r)}static fromBytes(e,t){let n=function(e){if(e instanceof Uint8Array){let t="0x0";for(const n of e)t+=lf[n>>4],t+=lf[15&n];return BigInt(t)}return sf(e)}(ef(e,"value"));const r=wf(t);return r.signed&&(n=of(n,r.width)),yf(n,r,"fromBytes"),new vf(mf,n,r)}}function xf(e){return function(e,t){let n=18;return n=uf(t,"unit"),vf.fromValue(e,n,{decimals:n,width:512}).toString()}(e,18)}const Ef="0.38.13";function Pf({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@${Ef}:${t}`):r.searchParams.append("sdkVersion",`onchainkit@${Ef}`),r.searchParams.sort(),r.toString()}var kf=[],Af=[],If="undefined"!=typeof Uint8Array?Uint8Array:Array,Nf=!1;function Sf(){Nf=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)kf[t]=e[t],Af[e.charCodeAt(t)]=t;Af["-".charCodeAt(0)]=62,Af["_".charCodeAt(0)]=63}function Tf(e){return kf[e>>18&63]+kf[e>>12&63]+kf[e>>6&63]+kf[63&e]}function Bf(e,t,n){for(var r,o=[],a=t;a<n;a+=3)r=(e[a]<<16)+(e[a+1]<<8)+e[a+2],o.push(Tf(r));return o.join("")}function Cf(e){var t;Nf||Sf();for(var n=e.length,r=n%3,o="",a=[],s=16383,i=0,c=n-r;i<c;i+=s)a.push(Bf(e,i,i+s>c?c:i+s));return 1===r?(t=e[n-1],o+=kf[t>>2],o+=kf[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=kf[t>>10],o+=kf[t>>4&63],o+=kf[t<<2&63],o+="="),a.push(o),a.join("")}function $f(e,t,n,r,o){var a,s,i=8*o-r-1,c=(1<<i)-1,l=c>>1,u=-7,d=n?o-1:0,f=n?-1:1,h=e[t+d];for(d+=f,a=h&(1<<-u)-1,h>>=-u,u+=i;u>0;a=256*a+e[t+d],d+=f,u-=8);for(s=a&(1<<-u)-1,a>>=-u,u+=r;u>0;s=256*s+e[t+d],d+=f,u-=8);if(0===a)a=1-l;else{if(a===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),a-=l}return(h?-1:1)*s*Math.pow(2,a-r)}function Of(e,t,n,r,o,a){var s,i,c,l=8*a-o-1,u=(1<<l)-1,d=u>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:a-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,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+d>=1?f/c:f*Math.pow(2,1-d))*c>=2&&(s++,c/=2),s+d>=u?(i=0,s=u):s+d>=1?(i=(t*c-1)*Math.pow(2,o),s+=d):(i=t*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;e[n+h]=255&i,h+=p,i/=256,o-=8);for(s=s<<o|i,l+=o;l>0;e[n+h]=255&s,h+=p,s/=256,l-=8);e[n+h-p]|=128*m}var _f={}.toString,Rf=Array.isArray||function(e){return"[object Array]"==_f.call(e)};function zf(){return Lf.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Mf(e,t){if(zf()<t)throw new RangeError("Invalid typed array length");return Lf.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Lf.prototype:(null===e&&(e=new Lf(t)),e.length=t),e}function Lf(e,t,n){if(!(Lf.TYPED_ARRAY_SUPPORT||this instanceof Lf))return new Lf(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 jf(this,e)}return Ff(this,e,t,n)}function Ff(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);Lf.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Lf.prototype:e=Df(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!Lf.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|qf(t,n);e=Mf(e,r);var o=e.write(t,n);o!==r&&(e=e.slice(0,o));return e}(e,t,n):function(e,t){if(Wf(t)){var n=0|Gf(t.length);return 0===(e=Mf(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?Mf(e,0):Df(e,t);if("Buffer"===t.type&&Rf(t.data))return Df(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Uf(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 jf(e,t){if(Uf(t),e=Mf(e,t<0?0:0|Gf(t)),!Lf.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Df(e,t){var n=t.length<0?0:0|Gf(t.length);e=Mf(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Gf(e){if(e>=zf())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+zf().toString(16)+" bytes");return 0|e}function Wf(e){return!(null==e||!e._isBuffer)}function qf(e,t){if(Wf(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 yh(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return wh(e).length;default:if(r)return yh(e).length;t=(""+t).toLowerCase(),r=!0}}function Vf(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 ih(this,t,n);case"utf8":case"utf-8":return rh(this,t,n);case"ascii":return ah(this,t,n);case"latin1":case"binary":return sh(this,t,n);case"base64":return nh(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ch(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Hf(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Yf(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=Lf.from(t,r)),Wf(t))return 0===t.length?-1:Kf(e,t,n,r,o);if("number"==typeof t)return t&=255,Lf.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Kf(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Kf(e,t,n,r,o){var a,s=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;s=2,i/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var u=-1;for(a=n;a<i;a++)if(l(e,a)===l(t,-1===u?0:a-u)){if(-1===u&&(u=a),a-u+1===c)return u*s}else-1!==u&&(a-=a-u),u=-1}else for(n+c>i&&(n=i-c),a=n;a>=0;a--){for(var d=!0,f=0;f<c;f++)if(l(e,a+f)!==l(t,f)){d=!1;break}if(d)return a}return-1}function Zf(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var s=0;s<r;++s){var i=parseInt(t.substr(2*s,2),16);if(isNaN(i))return s;e[n+s]=i}return s}function Jf(e,t,n,r){return vh(yh(t,e.length-n),e,n,r)}function Qf(e,t,n,r){return vh(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Xf(e,t,n,r){return Qf(e,t,n,r)}function eh(e,t,n,r){return vh(wh(t),e,n,r)}function th(e,t,n,r){return vh(function(e,t){for(var n,r,o,a=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,a.push(o),a.push(r);return a}(t,e.length-n),e,n,r)}function nh(e,t,n){return 0===t&&n===e.length?Cf(e):Cf(e.slice(t,n))}function rh(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var a,s,i,c,l=e[o],u=null,d=l>239?4:l>223?3:l>191?2:1;if(o+d<=n)switch(d){case 1:l<128&&(u=l);break;case 2:128==(192&(a=e[o+1]))&&(c=(31&l)<<6|63&a)>127&&(u=c);break;case 3:a=e[o+1],s=e[o+2],128==(192&a)&&128==(192&s)&&(c=(15&l)<<12|(63&a)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:a=e[o+1],s=e[o+2],i=e[o+3],128==(192&a)&&128==(192&s)&&128==(192&i)&&(c=(15&l)<<18|(63&a)<<12|(63&s)<<6|63&i)>65535&&c<1114112&&(u=c)}null===u?(u=65533,d=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=d}return function(e){var t=e.length;if(t<=oh)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=oh));return n}(r)}Lf.TYPED_ARRAY_SUPPORT=void 0===globalThis.TYPED_ARRAY_SUPPORT||globalThis.TYPED_ARRAY_SUPPORT,zf(),Lf.poolSize=8192,Lf._augment=function(e){return e.__proto__=Lf.prototype,e},Lf.from=function(e,t,n){return Ff(null,e,t,n)},Lf.TYPED_ARRAY_SUPPORT&&(Lf.prototype.__proto__=Uint8Array.prototype,Lf.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Lf[Symbol.species]),Lf.alloc=function(e,t,n){return function(e,t,n,r){return Uf(t),t<=0?Mf(e,t):void 0!==n?"string"==typeof r?Mf(e,t).fill(n,r):Mf(e,t).fill(n):Mf(e,t)}(null,e,t,n)},Lf.allocUnsafe=function(e){return jf(null,e)},Lf.allocUnsafeSlow=function(e){return jf(null,e)},Lf.isBuffer=function(e){return null!=e&&(!!e._isBuffer||xh(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&xh(e.slice(0,0))}(e))},Lf.compare=function(e,t){if(!Wf(e)||!Wf(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,a=Math.min(n,r);o<a;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},Lf.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}},Lf.concat=function(e,t){if(!Rf(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Lf.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=Lf.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var a=e[n];if(!Wf(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,o),o+=a.length}return r},Lf.byteLength=qf,Lf.prototype._isBuffer=!0,Lf.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)Hf(this,t,t+1);return this},Lf.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)Hf(this,t,t+3),Hf(this,t+1,t+2);return this},Lf.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)Hf(this,t,t+7),Hf(this,t+1,t+6),Hf(this,t+2,t+5),Hf(this,t+3,t+4);return this},Lf.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?rh(this,0,e):Vf.apply(this,arguments)},Lf.prototype.equals=function(e){if(!Wf(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Lf.compare(this,e)},Lf.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+">"},Lf.prototype.compare=function(e,t,n,r,o){if(!Wf(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 a=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),i=Math.min(a,s),c=this.slice(r,o),l=e.slice(t,n),u=0;u<i;++u)if(c[u]!==l[u]){a=c[u],s=l[u];break}return a<s?-1:s<a?1:0},Lf.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},Lf.prototype.indexOf=function(e,t,n){return Yf(this,e,t,n,!0)},Lf.prototype.lastIndexOf=function(e,t,n){return Yf(this,e,t,n,!1)},Lf.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 a=!1;;)switch(r){case"hex":return Zf(this,e,t,n);case"utf8":case"utf-8":return Jf(this,e,t,n);case"ascii":return Qf(this,e,t,n);case"latin1":case"binary":return Xf(this,e,t,n);case"base64":return eh(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return th(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}},Lf.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var oh=4096;function ah(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 sh(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 ih(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",a=t;a<n;++a)o+=bh(e[a]);return o}function ch(e,t,n){for(var r=e.slice(t,n),o="",a=0;a<r.length;a+=2)o+=String.fromCharCode(r[a]+256*r[a+1]);return o}function lh(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 uh(e,t,n,r,o,a){if(!Wf(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<a)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function dh(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,a=Math.min(e.length-n,2);o<a;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function fh(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,a=Math.min(e.length-n,4);o<a;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function hh(e,t,n,r,o,a){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ph(e,t,n,r,o){return o||hh(e,0,n,4),Of(e,t,n,r,23,4),n+4}function mh(e,t,n,r,o){return o||hh(e,0,n,8),Of(e,t,n,r,52,8),n+8}Lf.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),Lf.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=Lf.prototype;else{var o=t-e;n=new Lf(o,void 0);for(var a=0;a<o;++a)n[a]=this[a+e]}return n},Lf.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||lh(e,t,this.length);for(var r=this[e],o=1,a=0;++a<t&&(o*=256);)r+=this[e+a]*o;return r},Lf.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||lh(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},Lf.prototype.readUInt8=function(e,t){return t||lh(e,1,this.length),this[e]},Lf.prototype.readUInt16LE=function(e,t){return t||lh(e,2,this.length),this[e]|this[e+1]<<8},Lf.prototype.readUInt16BE=function(e,t){return t||lh(e,2,this.length),this[e]<<8|this[e+1]},Lf.prototype.readUInt32LE=function(e,t){return t||lh(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Lf.prototype.readUInt32BE=function(e,t){return t||lh(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Lf.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||lh(e,t,this.length);for(var r=this[e],o=1,a=0;++a<t&&(o*=256);)r+=this[e+a]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},Lf.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||lh(e,t,this.length);for(var r=t,o=1,a=this[e+--r];r>0&&(o*=256);)a+=this[e+--r]*o;return a>=(o*=128)&&(a-=Math.pow(2,8*t)),a},Lf.prototype.readInt8=function(e,t){return t||lh(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Lf.prototype.readInt16LE=function(e,t){t||lh(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Lf.prototype.readInt16BE=function(e,t){t||lh(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Lf.prototype.readInt32LE=function(e,t){return t||lh(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Lf.prototype.readInt32BE=function(e,t){return t||lh(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Lf.prototype.readFloatLE=function(e,t){return t||lh(e,4,this.length),$f(this,e,!0,23,4)},Lf.prototype.readFloatBE=function(e,t){return t||lh(e,4,this.length),$f(this,e,!1,23,4)},Lf.prototype.readDoubleLE=function(e,t){return t||lh(e,8,this.length),$f(this,e,!0,52,8)},Lf.prototype.readDoubleBE=function(e,t){return t||lh(e,8,this.length),$f(this,e,!1,52,8)},Lf.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||uh(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,a=0;for(this[t]=255&e;++a<n&&(o*=256);)this[t+a]=e/o&255;return t+n},Lf.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||uh(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,a=1;for(this[t+o]=255&e;--o>=0&&(a*=256);)this[t+o]=e/a&255;return t+n},Lf.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,1,255,0),Lf.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Lf.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,2,65535,0),Lf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):dh(this,e,t,!0),t+2},Lf.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,2,65535,0),Lf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):dh(this,e,t,!1),t+2},Lf.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,4,4294967295,0),Lf.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):fh(this,e,t,!0),t+4},Lf.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,4,4294967295,0),Lf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):fh(this,e,t,!1),t+4},Lf.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);uh(this,e,t,n,o-1,-o)}var a=0,s=1,i=0;for(this[t]=255&e;++a<n&&(s*=256);)e<0&&0===i&&0!==this[t+a-1]&&(i=1),this[t+a]=(e/s|0)-i&255;return t+n},Lf.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);uh(this,e,t,n,o-1,-o)}var a=n-1,s=1,i=0;for(this[t+a]=255&e;--a>=0&&(s*=256);)e<0&&0===i&&0!==this[t+a+1]&&(i=1),this[t+a]=(e/s|0)-i&255;return t+n},Lf.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,1,127,-128),Lf.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Lf.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,2,32767,-32768),Lf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):dh(this,e,t,!0),t+2},Lf.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,2,32767,-32768),Lf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):dh(this,e,t,!1),t+2},Lf.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,4,2147483647,-2147483648),Lf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):fh(this,e,t,!0),t+4},Lf.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Lf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):fh(this,e,t,!1),t+4},Lf.prototype.writeFloatLE=function(e,t,n){return ph(this,e,t,!0,n)},Lf.prototype.writeFloatBE=function(e,t,n){return ph(this,e,t,!1,n)},Lf.prototype.writeDoubleLE=function(e,t,n){return mh(this,e,t,!0,n)},Lf.prototype.writeDoubleBE=function(e,t,n){return mh(this,e,t,!1,n)},Lf.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,a=r-n;if(this===e&&n<t&&t<r)for(o=a-1;o>=0;--o)e[o+t]=this[o+n];else if(a<1e3||!Lf.TYPED_ARRAY_SUPPORT)for(o=0;o<a;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+a),t);return a},Lf.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&&!Lf.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 a;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(a=t;a<n;++a)this[a]=e;else{var s=Wf(e)?e:yh(new Lf(e,r).toString()),i=s.length;for(a=0;a<n-t;++a)this[a+t]=s[a%i]}return this};var gh=/[^+\/0-9A-Za-z-_]/g;function bh(e){return e<16?"0"+e.toString(16):e.toString(16)}function yh(e,t){var n;t=t||1/0;for(var r=e.length,o=null,a=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&a.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&a.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.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;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function wh(e){return function(e){var t,n,r,o,a,s;Nf||Sf();var i=e.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===e[i-2]?2:"="===e[i-1]?1:0,s=new If(3*i/4-a),r=a>0?i-4:i;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)o=Af[e.charCodeAt(t)]<<18|Af[e.charCodeAt(t+1)]<<12|Af[e.charCodeAt(t+2)]<<6|Af[e.charCodeAt(t+3)],s[c++]=o>>16&255,s[c++]=o>>8&255,s[c++]=255&o;return 2===a?(o=Af[e.charCodeAt(t)]<<2|Af[e.charCodeAt(t+1)]>>4,s[c++]=255&o):1===a&&(o=Af[e.charCodeAt(t)]<<10|Af[e.charCodeAt(t+1)]<<4|Af[e.charCodeAt(t+2)]>>2,s[c++]=o>>8&255,s[c++]=255&o),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(gh,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function vh(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 xh(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Eh(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}class Ph{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=y.default.create({baseURL:e.baseURL,headers:{"Content-Type":"application/json"}}),this.middleAccountApi=y.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=Hd({transport:Kd(e.ethereumNetwork.rpcUrl)})),this.defaultNetwork=e.defaultNetwork||exports.Network.Solana}setWallet(e){this.walletInfo=e}setWalletType(e){this.walletType=e,T.saveWalletType(e)}setBackupWalletType(e){this.backupWalletType=e,T.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===T.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===T.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(T.getWalletType()==="phantom"+(e?"_backup":"")){return await this.connectPhantom()}if(!e){const e=await this.getSession();return this.setWallet(e),e}const t=T.getBackupWalletInfo();return this.setWallet(t),t}catch(e){return null}}async connectPhantom(){try{if(this.phantomAdapter||(this.phantomAdapter=new K),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(),wallets:[{id:e,address:e,network:exports.Network.Solana,wallet_type:exports.WalletType.Phantom,wallet_set:"Main",account_index:0,is_enabled:!0}],social_links:[],social_infos:[],account_info:{name:null,sub_accounts:[]},created_at:Date.now(),is_exported:!1};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,t){if(!this.walletInfo)throw new Error("No wallet info");const n={name:e};void 0!==t&&(n.account_index=t);const r=(await this.api.post("/account/update",n,{withCredentials:!0})).data;return this.setWallet(r),r}async manageMultiAccount(e){if(!this.walletInfo)throw new Error("No wallet info");const t=(await this.api.post("/account/multi",e,{withCredentials:!0})).data;return this.setWallet(t),t}async createSubAccount(e){return this.manageMultiAccount({type:"Create",data:{name:null!=e?e:null}})}async enableSubAccount(e){return this.manageMultiAccount({type:"Enable",data:{index:e}})}async disableSubAccount(e){return this.manageMultiAccount({type:"Disable",data:{index:e}})}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(E(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=await this.signV3({network:exports.Network.Solana,address:r.address,tx:{Solana:w.default.encode(E(e)?e.message.serialize():e.serializeMessage())}});return e.addSignature(new t.PublicKey(r.address),Lf.from(w.default.decode(o))),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");return await this.signV2({network:exports.Network.Ethereum,address:this.ethereumAddress,tx:{EthereumEip712:e}})}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&&T.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?T.clearBackup():T.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 xf(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=await this.signV2({network:exports.Network.Ethereum,address:this.ethereumAddress,tx:{EthereumEip712:e}}),n=w.default.decode(t),r=n[64];return Fd({r:`0x${Lf.from(n.slice(0,32)).toString("hex")}`,s:`0x${Lf.from(n.slice(32,64)).toString("hex")}`,v:BigInt(r+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 Pf(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("/v3/sign/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,t){var n,r;if(!this.walletInfo)throw new Error("No wallet info available");try{const n={...e,wallet_address:t||e.wallet_address||null};return(await this.api.post("/v3/sign/build_transaction",n,{withCredentials:!0})).data}catch(e){if(null===(r=null===(n=e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Failed to build transaction")}}async exportInit(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");const r={user_nonce:Eh(),account_index:e};try{return(await this.api.post("/export/init",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:"Failed to initialize export")}}async exportFinal(e){var t,n,r;if(!this.walletInfo)throw new Error("No wallet info available");const o={user_nonce:e.userNonce,server_nonce:e.serverNonce,account_index:e.accountIndex,is_export:null===(t=e.isExport)||void 0===t||t};try{return(await this.api.post("/export/final",o,{withCredentials:!0})).data}catch(e){if(null===(r=null===(n=e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Failed to finalize export")}}async getExportedWallets(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");const r={account_index:e,is_export:!1};try{return(await this.api.post("/export/final",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:"Failed to retrieve exported wallets")}}async closeInit(){var e,t;if(!this.walletInfo)throw new Error("No wallet info available");const n={user_nonce:Eh()};try{return(await this.api.post("/close/init",n,{withCredentials:!0})).data}catch(n){if(null===(t=null===(e=n.response)||void 0===e?void 0:e.data)||void 0===t?void 0:t.error)throw new Error(n.response.data.error);throw new Error(n instanceof Error?n.message:"Failed to initialize account closure")}}async closeFinal(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");const r={user_nonce:e.userNonce,server_nonce:e.serverNonce};try{const e=await this.api.post("/close/final",r,{withCredentials:!0});return this.setWallet(null),T.clear(),e.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 close account")}}async signV1(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");const r={user_id:this.walletInfo.id,network:e.network,address:e.address,message:e.message};try{return(await this.api.post("/v1/sign",r,{withCredentials:!0})).data.signature}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 sign message")}}async signV2(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");const r={user_id:this.walletInfo.id,network:e.network,address:e.address,tx:e.tx};try{return(await this.api.post("/v2/sign",r,{withCredentials:!0})).data.signature}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 sign transaction")}}async signV3(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");if(e.network!==exports.Network.Solana)throw new Error("v3 sign API only supports Solana transactions");if(!e.tx.Solana)throw new Error("Solana transaction is required for v3 sign API");const r={user_id:this.walletInfo.id,network:e.network,address:e.address,tx:{Solana:e.tx.Solana}};try{return(await this.api.post("/v3/sign",r,{withCredentials:!0})).data.signature}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 sign transaction")}}async lighterBuildTransaction(e,t){var n,r;if(!this.walletInfo)throw new Error("No wallet info available");try{const n={...e,wallet_address:t||e.wallet_address||null};return(await this.api.post("/v3/lighter/build_transaction",n,{withCredentials:!0})).data}catch(e){if(null===(r=null===(n=e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Failed to build Lighter transaction")}}async lighterAuth(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");const r={account_index:e.lighter_account_index,wallet_address:e.wallet_address||null,expires_in_ms:e.expires_in_ms||null};try{return(await this.api.post("/v3/lighter/auth",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:"Failed to generate Lighter auth token")}}async lighterChangeKey(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");if(e.lighter_account_index<0)throw new Error("accountIndex must be non-negative");const r={account_index:e.lighter_account_index,wallet_address:e.wallet_address||null};try{return(await this.api.post("/v3/lighter/change_key",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:"Failed to change Lighter key")}}async exchange(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");try{return(await this.api.post("/v3/sign/exchange",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 exchange transaction")}}}var kh=function(){return kh=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},kh.apply(this,arguments)};function Ah(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;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 Ih(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 Nh=/^((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)-.*))$/,Sh=Ih(function(e){return Nh.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}),Th="-ms-",Bh="-moz-",Ch="-webkit-",$h="comm",Oh="rule",_h="decl",Rh="@keyframes",zh=Math.abs,Mh=String.fromCharCode,Lh=Object.assign;function Fh(e){return e.trim()}function Uh(e,t){return(e=t.exec(e))?e[0]:e}function jh(e,t,n){return e.replace(t,n)}function Dh(e,t,n){return e.indexOf(t,n)}function Gh(e,t){return 0|e.charCodeAt(t)}function Wh(e,t,n){return e.slice(t,n)}function qh(e){return e.length}function Vh(e){return e.length}function Hh(e,t){return t.push(e),e}function Yh(e,t){return e.filter(function(e){return!Uh(e,t)})}var Kh=1,Zh=1,Jh=0,Qh=0,Xh=0,ep="";function tp(e,t,n,r,o,a,s,i){return{value:e,root:t,parent:n,type:r,props:o,children:a,line:Kh,column:Zh,length:s,return:"",siblings:i}}function np(e,t){return Lh(tp("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function rp(e){for(;e.root;)e=np(e.root,{children:[e]});Hh(e,e.siblings)}function op(){return Xh=Qh>0?Gh(ep,--Qh):0,Zh--,10===Xh&&(Zh=1,Kh--),Xh}function ap(){return Xh=Qh<Jh?Gh(ep,Qh++):0,Zh++,10===Xh&&(Zh=1,Kh++),Xh}function sp(){return Gh(ep,Qh)}function ip(){return Qh}function cp(e,t){return Wh(ep,e,t)}function lp(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 up(e){return Fh(cp(Qh-1,hp(91===e?e+2:40===e?e+1:e)))}function dp(e){for(;(Xh=sp())&&Xh<33;)ap();return lp(e)>2||lp(Xh)>3?"":" "}function fp(e,t){for(;--t&&ap()&&!(Xh<48||Xh>102||Xh>57&&Xh<65||Xh>70&&Xh<97););return cp(e,ip()+(t<6&&32==sp()&&32==ap()))}function hp(e){for(;ap();)switch(Xh){case e:return Qh;case 34:case 39:34!==e&&39!==e&&hp(Xh);break;case 40:41===e&&hp(e);break;case 92:ap()}return Qh}function pp(e,t){for(;ap()&&e+Xh!==57&&(e+Xh!==84||47!==sp()););return"/*"+cp(t,Qh-1)+"*"+Mh(47===e?e:ap())}function mp(e){for(;!lp(sp());)ap();return cp(e,Qh)}function gp(e){return function(e){return ep="",e}(bp("",null,null,null,[""],e=function(e){return Kh=Zh=1,Jh=qh(ep=e),Qh=0,[]}(e),0,[0],e))}function bp(e,t,n,r,o,a,s,i,c){for(var l=0,u=0,d=s,f=0,h=0,p=0,m=1,g=1,b=1,y=0,w="",v=o,x=a,E=r,P=w;g;)switch(p=y,y=ap()){case 40:if(108!=p&&58==Gh(P,d-1)){-1!=Dh(P+=jh(up(y),"&","&\f"),"&\f",zh(l?i[l-1]:0))&&(b=-1);break}case 34:case 39:case 91:P+=up(y);break;case 9:case 10:case 13:case 32:P+=dp(p);break;case 92:P+=fp(ip()-1,7);continue;case 47:switch(sp()){case 42:case 47:Hh(wp(pp(ap(),ip()),t,n,c),c);break;default:P+="/"}break;case 123*m:i[l++]=qh(P)*b;case 125*m:case 59:case 0:switch(y){case 0:case 125:g=0;case 59+u:-1==b&&(P=jh(P,/\f/g,"")),h>0&&qh(P)-d&&Hh(h>32?vp(P+";",r,n,d-1,c):vp(jh(P," ","")+";",r,n,d-2,c),c);break;case 59:P+=";";default:if(Hh(E=yp(P,t,n,l,u,o,i,w,v=[],x=[],d,a),a),123===y)if(0===u)bp(P,t,E,E,v,a,d,i,x);else switch(99===f&&110===Gh(P,3)?100:f){case 100:case 108:case 109:case 115:bp(e,E,E,r&&Hh(yp(e,E,E,0,0,o,i,w,o,v=[],d,x),x),o,x,d,i,r?v:x);break;default:bp(P,E,E,E,[""],x,0,i,x)}}l=u=h=0,m=b=1,w=P="",d=s;break;case 58:d=1+qh(P),h=p;default:if(m<1)if(123==y)--m;else if(125==y&&0==m++&&125==op())continue;switch(P+=Mh(y),y*m){case 38:b=u>0?1:(P+="\f",-1);break;case 44:i[l++]=(qh(P)-1)*b,b=1;break;case 64:45===sp()&&(P+=up(ap())),f=sp(),u=d=qh(w=P+=mp(ip())),y++;break;case 45:45===p&&2==qh(P)&&(m=0)}}return a}function yp(e,t,n,r,o,a,s,i,c,l,u,d){for(var f=o-1,h=0===o?a:[""],p=Vh(h),m=0,g=0,b=0;m<r;++m)for(var y=0,w=Wh(e,f+1,f=zh(g=s[m])),v=e;y<p;++y)(v=Fh(g>0?h[y]+" "+w:jh(w,/&\f/g,h[y])))&&(c[b++]=v);return tp(e,t,n,0===o?Oh:i,c,l,u,d)}function wp(e,t,n,r){return tp(e,t,n,$h,Mh(Xh),Wh(e,2,-2),0,r)}function vp(e,t,n,r,o){return tp(e,t,n,_h,Wh(e,0,r),Wh(e,r+1,-1),r,o)}function xp(e,t,n){switch(function(e,t){return 45^Gh(e,0)?(((t<<2^Gh(e,0))<<2^Gh(e,1))<<2^Gh(e,2))<<2^Gh(e,3):0}(e,t)){case 5103:return Ch+"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 Ch+e+e;case 4789:return Bh+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ch+e+Bh+e+Th+e+e;case 5936:switch(Gh(e,t+11)){case 114:return Ch+e+Th+jh(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ch+e+Th+jh(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ch+e+Th+jh(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return Ch+e+Th+e+e;case 6165:return Ch+e+Th+"flex-"+e+e;case 5187:return Ch+e+jh(e,/(\w+).+(:[^]+)/,Ch+"box-$1$2"+Th+"flex-$1$2")+e;case 5443:return Ch+e+Th+"flex-item-"+jh(e,/flex-|-self/g,"")+(Uh(e,/flex-|baseline/)?"":Th+"grid-row-"+jh(e,/flex-|-self/g,""))+e;case 4675:return Ch+e+Th+"flex-line-pack"+jh(e,/align-content|flex-|-self/g,"")+e;case 5548:return Ch+e+Th+jh(e,"shrink","negative")+e;case 5292:return Ch+e+Th+jh(e,"basis","preferred-size")+e;case 6060:return Ch+"box-"+jh(e,"-grow","")+Ch+e+Th+jh(e,"grow","positive")+e;case 4554:return Ch+jh(e,/([^-])(transform)/g,"$1"+Ch+"$2")+e;case 6187:return jh(jh(jh(e,/(zoom-|grab)/,Ch+"$1"),/(image-set)/,Ch+"$1"),e,"")+e;case 5495:case 3959:return jh(e,/(image-set\([^]*)/,Ch+"$1$`$1");case 4968:return jh(jh(e,/(.+:)(flex-)?(.*)/,Ch+"box-pack:$3"+Th+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ch+e+e;case 4200:if(!Uh(e,/flex-|baseline/))return Th+"grid-column-align"+Wh(e,t)+e;break;case 2592:case 3360:return Th+jh(e,"template-","")+e;case 4384:case 3616:return n&&n.some(function(e,n){return t=n,Uh(e.props,/grid-\w+-end/)})?~Dh(e+(n=n[t].value),"span",0)?e:Th+jh(e,"-start","")+e+Th+"grid-row-span:"+(~Dh(n,"span",0)?Uh(n,/\d+/):+Uh(n,/\d+/)-+Uh(e,/\d+/))+";":Th+jh(e,"-start","")+e;case 4896:case 4128:return n&&n.some(function(e){return Uh(e.props,/grid-\w+-start/)})?e:Th+jh(jh(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return jh(e,/(.+)-inline(.+)/,Ch+"$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(qh(e)-1-t>6)switch(Gh(e,t+1)){case 109:if(45!==Gh(e,t+4))break;case 102:return jh(e,/(.+:)(.+)-([^]+)/,"$1"+Ch+"$2-$3$1"+Bh+(108==Gh(e,t+3)?"$3":"$2-$3"))+e;case 115:return~Dh(e,"stretch",0)?xp(jh(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return jh(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(t,n,r,o,a,s,i){return Th+n+":"+r+i+(o?Th+n+"-span:"+(a?s:+s-+r)+i:"")+e});case 4949:if(121===Gh(e,t+6))return jh(e,":",":"+Ch)+e;break;case 6444:switch(Gh(e,45===Gh(e,14)?18:11)){case 120:return jh(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Ch+(45===Gh(e,14)?"inline-":"")+"box$3$1"+Ch+"$2$3$1"+Th+"$2box$3")+e;case 100:return jh(e,":",":"+Th)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return jh(e,"scroll-","scroll-snap-")+e}return e}function Ep(e,t){for(var n="",r=0;r<e.length;r++)n+=t(e[r],r,e,t)||"";return n}function Pp(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case _h:return e.return=e.return||e.value;case $h:return"";case Rh:return e.return=e.value+"{"+Ep(e.children,r)+"}";case Oh:if(!qh(e.value=e.props.join(",")))return""}return qh(n=Ep(e.children,r))?e.return=e.value+"{"+n+"}":""}function kp(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case _h:return void(e.return=xp(e.value,e.length,n));case Rh:return Ep([np(e,{value:jh(e.value,"@","@"+Ch)})],r);case Oh:if(e.length)return function(e,t){return e.map(t).join("")}(n=e.props,function(t){switch(Uh(t,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":rp(np(e,{props:[jh(t,/:(read-\w+)/,":-moz-$1")]})),rp(np(e,{props:[t]})),Lh(e,{props:Yh(n,r)});break;case"::placeholder":rp(np(e,{props:[jh(t,/:(plac\w+)/,":"+Ch+"input-$1")]})),rp(np(e,{props:[jh(t,/:(plac\w+)/,":-moz-$1")]})),rp(np(e,{props:[jh(t,/:(plac\w+)/,Th+"input-$1")]})),rp(np(e,{props:[t]})),Lh(e,{props:Yh(n,r)})}return""})}}var Ap={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},Ip="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Np="active",Sp="data-styled-version",Tp="6.1.19",Bp="/*!sc*/\n",Cp="undefined"!=typeof window&&"undefined"!=typeof document,$p=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),Op=/invalid hook call/i,_p=new Set,Rp=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",a=console.error;try{var s=!0;console.error=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];Op.test(e)?(s=!1,_p.delete(r)):a.apply(void 0,Ah([e],t,!1))},o.useRef(),s&&!_p.has(r)&&(console.warn(r),_p.add(r))}catch(e){Op.test(e.message)&&_p.delete(r)}finally{console.error=a}}},zp=Object.freeze([]),Mp=Object.freeze({});var Lp=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"]),Fp=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Up=/(^-|-$)/g;function jp(e){return e.replace(Fp,"-").replace(Up,"")}var Dp=/(a)(d)/gi,Gp=function(e){return String.fromCharCode(e+(e>25?39:97))};function Wp(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=Gp(t%52)+n;return(Gp(t%52)+n).replace(Dp,"$1-$2")}var qp,Vp=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},Hp=function(e){return Vp(5381,e)};function Yp(e){return Wp(Hp(e)>>>0)}function Kp(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function Zp(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var Jp="function"==typeof Symbol&&Symbol.for,Qp=Jp?Symbol.for("react.memo"):60115,Xp=Jp?Symbol.for("react.forward_ref"):60112,em={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},tm={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},nm={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},rm=((qp={})[Xp]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},qp[Qp]=nm,qp);function om(e){return("type"in(t=e)&&t.type.$$typeof)===Qp?nm:"$$typeof"in e?rm[e.$$typeof]:em;var t}var am=Object.defineProperty,sm=Object.getOwnPropertyNames,im=Object.getOwnPropertySymbols,cm=Object.getOwnPropertyDescriptor,lm=Object.getPrototypeOf,um=Object.prototype;function dm(e,t,n){if("string"!=typeof t){if(um){var r=lm(t);r&&r!==um&&dm(e,r,n)}var o=sm(t);im&&(o=o.concat(im(t)));for(var a=om(e),s=om(t),i=0;i<o.length;++i){var c=o[i];if(!(c in tm||n&&n[c]||s&&c in s||a&&c in a)){var l=cm(t,c);try{am(e,c,l)}catch(e){}}}}return e}function fm(e){return"function"==typeof e}function hm(e){return"object"==typeof e&&"styledComponentId"in e}function pm(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function mm(e,t){if(0===e.length)return"";for(var n=e[0],r=1;r<e.length;r++)n+=e[r];return n}function gm(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function bm(e,t,n){if(void 0===n&&(n=!1),!n&&!gm(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var r=0;r<t.length;r++)e[r]=bm(e[r],t[r]);else if(gm(t))for(var r in t)e[r]=bm(e[r],t[r]);return e}function ym(e,t){Object.defineProperty(e,"toString",{value:t})}var wm="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 vm(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],r=[],o=1,a=e.length;o<a;o+=1)r.push(e[o]);return r.forEach(function(e){n=n.replace(/%[a-z]/,e)}),n}function xm(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(vm.apply(void 0,Ah([wm[e]],t,!1)).trim())}var Em=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 xm(16,"".concat(e));this.groupSizes=new Uint32Array(o),this.groupSizes.set(n),this.length=o;for(var a=r;a<o;a++)this.groupSizes[a]=0}for(var s=this.indexOfGroup(e+1),i=(a=0,t.length);a<i;a++)this.tag.insertRule(s,t[a])&&(this.groupSizes[e]++,s++)},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,a=r;a<o;a++)t+="".concat(this.tag.getRule(a)).concat(Bp);return t},e}(),Pm=1<<30,km=new Map,Am=new Map,Im=1,Nm=function(e){if(km.has(e))return km.get(e);for(;Am.has(Im);)Im++;var t=Im++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>Pm))throw xm(16,"".concat(t));return km.set(e,t),Am.set(t,e),t},Sm=function(e,t){Im=t+1,km.set(e,t),Am.set(t,e)},Tm="style[".concat(Ip,"][").concat(Sp,'="').concat(Tp,'"]'),Bm=new RegExp("^".concat(Ip,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Cm=function(e,t,n){for(var r,o=n.split(","),a=0,s=o.length;a<s;a++)(r=o[a])&&e.registerName(t,r)},$m=function(e,t){for(var n,r=(null!==(n=t.textContent)&&void 0!==n?n:"").split(Bp),o=[],a=0,s=r.length;a<s;a++){var i=r[a].trim();if(i){var c=i.match(Bm);if(c){var l=0|parseInt(c[1],10),u=c[2];0!==l&&(Sm(u,l),Cm(e,u,c[3]),e.getTag().insertRules(l,o)),o.length=0}else o.push(i)}}},Om=function(e){for(var t=document.querySelectorAll(Tm),n=0,r=t.length;n<r;n++){var o=t[n];o&&o.getAttribute(Ip)!==Np&&($m(e,o),o.parentNode&&o.parentNode.removeChild(o))}};var _m=function(e){var t=document.head,n=e||t,r=document.createElement("style"),o=function(e){var t=Array.from(e.querySelectorAll("style[".concat(Ip,"]")));return t[t.length-1]}(n),a=void 0!==o?o.nextSibling:null;r.setAttribute(Ip,Np),r.setAttribute(Sp,Tp);var s="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null;return s&&r.setAttribute("nonce",s),n.insertBefore(r,a),r},Rm=function(){function e(e){this.element=_m(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 xm(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}(),zm=function(){function e(e){this.element=_m(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}(),Mm=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}(),Lm=Cp,Fm={isServer:!Cp,useCSSOMInjection:!$p},Um=function(){function e(e,t,n){void 0===e&&(e=Mp),void 0===t&&(t={});var r=this;this.options=kh(kh({},Fm),e),this.gs=t,this.names=new Map(n),this.server=!!e.isServer,!this.server&&Cp&&Lm&&(Lm=!1,Om(this)),ym(this,function(){return function(e){for(var t=e.getTag(),n=t.length,r="",o=function(n){var o=function(e){return Am.get(e)}(n);if(void 0===o)return"continue";var a=e.names.get(o),s=t.getGroup(n);if(void 0===a||!a.size||0===s.length)return"continue";var i="".concat(Ip,".g").concat(n,'[id="').concat(o,'"]'),c="";void 0!==a&&a.forEach(function(e){e.length>0&&(c+="".concat(e,","))}),r+="".concat(s).concat(i,'{content:"').concat(c,'"}').concat(Bp)},a=0;a<n;a++)o(a);return r}(r)})}return e.registerId=function(e){return Nm(e)},e.prototype.rehydrate=function(){!this.server&&Cp&&Om(this)},e.prototype.reconstructWithOptions=function(t,n){return void 0===n&&(n=!0),new e(kh(kh({},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 Mm(n):t?new Rm(n):new zm(n)}(this.options),new Em(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(Nm(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(Nm(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(Nm(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e}(),jm=/&/g,Dm=/^\s*\/\/.*$/gm;function Gm(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=Gm(e.children,t)),e})}var Wm=new Um,qm=function(){var e,t,n,r=Mp,o=r.options,a=void 0===o?Mp:o,s=r.plugins,i=void 0===s?zp:s,c=function(n,r,o){return o.startsWith(t)&&o.endsWith(t)&&o.replaceAll(t,"").length>0?".".concat(e):n},l=i.slice();l.push(function(e){e.type===Oh&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(jm,t).replace(n,c))}),a.prefix&&l.push(kp),l.push(Pp);var u=function(r,o,s,i){void 0===o&&(o=""),void 0===s&&(s=""),void 0===i&&(i="&"),e=i,t=o,n=new RegExp("\\".concat(t,"\\b"),"g");var c=r.replace(Dm,""),u=gp(s||o?"".concat(s," ").concat(o," { ").concat(c," }"):c);a.namespace&&(u=Gm(u,a.namespace));var d,f=[];return Ep(u,function(e){var t=Vh(e);return function(n,r,o,a){for(var s="",i=0;i<t;i++)s+=e[i](n,r,o,a)||"";return s}}(l.concat((d=function(e){return f.push(e)},function(e){e.root||(e=e.return)&&d(e)})))),f};return u.hash=i.length?i.reduce(function(e,t){return t.name||xm(15),Vp(e,t.name)},5381).toString():"",u}(),Vm=v.default.createContext({shouldForwardProp:void 0,styleSheet:Wm,stylis:qm});function Hm(){return o.useContext(Vm)}Vm.Consumer,v.default.createContext(void 0);var Ym=function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=qm);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,ym(this,function(){throw xm(12,String(n.name))})}return e.prototype.getName=function(e){return void 0===e&&(e=qm),this.name+e.hash},e}(),Km=function(e){return e>="A"&&e<="Z"};function Zm(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(1===n&&"-"===r&&"-"===e[0])return e;Km(r)?t+="-"+r.toLowerCase():t+=r}return t.startsWith("ms-")?"-"+t:t}var Jm=function(e){return null==e||!1===e||""===e},Qm=function(e){var t,n,r=[];for(var o in e){var a=e[o];e.hasOwnProperty(o)&&!Jm(a)&&(Array.isArray(a)&&a.isCss||fm(a)?r.push("".concat(Zm(o),":"),a,";"):gm(a)?r.push.apply(r,Ah(Ah(["".concat(o," {")],Qm(a),!1),["}"],!1)):r.push("".concat(Zm(o),": ").concat((t=o,null==(n=a)||"boolean"==typeof n||""===n?"":"number"!=typeof n||0===n||t in Ap||t.startsWith("--")?String(n).trim():"".concat(n,"px")),";")))}return r};function Xm(e,t,n,r){if(Jm(e))return[];if(hm(e))return[".".concat(e.styledComponentId)];if(fm(e)){if(!fm(a=e)||a.prototype&&a.prototype.isReactComponent||!t)return[e];var o=e(t);return"production"===process.env.NODE_ENV||"object"!=typeof o||Array.isArray(o)||o instanceof Ym||gm(o)||null===o||console.error("".concat(Kp(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.")),Xm(o,t,n,r)}var a;return e instanceof Ym?n?(e.inject(n,r),[e.getName(r)]):[e]:gm(e)?Qm(e):Array.isArray(e)?Array.prototype.concat.apply(zp,e.map(function(e){return Xm(e,t,n,r)})):[e.toString()]}var eg=Hp(Tp),tg=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(fm(n)&&!hm(n))return!1}return!0}(e),this.componentId=t,this.baseHash=Vp(eg,t),this.baseStyle=n,Um.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=pm(r,this.staticRulesId);else{var o=mm(Xm(this.rules,e,t,n)),a=Wp(Vp(this.baseHash,o)>>>0);if(!t.hasNameForId(this.componentId,a)){var s=n(o,".".concat(a),void 0,this.componentId);t.insertRules(this.componentId,a,s)}r=pm(r,a),this.staticRulesId=a}else{for(var i=Vp(this.baseHash,n.hash),c="",l=0;l<this.rules.length;l++){var u=this.rules[l];if("string"==typeof u)c+=u,"production"!==process.env.NODE_ENV&&(i=Vp(i,u));else if(u){var d=mm(Xm(u,e,t,n));i=Vp(i,d+l),c+=d}}if(c){var f=Wp(i>>>0);t.hasNameForId(this.componentId,f)||t.insertRules(this.componentId,f,n(c,".".concat(f),void 0,this.componentId)),r=pm(r,f)}}return r},e}(),ng=v.default.createContext(void 0);ng.Consumer;var rg={},og=new Set;function ag(e,t,n){var r=hm(e),a=e,s=!Zp(e),i=t.attrs,c=void 0===i?zp:i,l=t.componentId,u=void 0===l?function(e,t){var n="string"!=typeof e?"sc":jp(e);rg[n]=(rg[n]||0)+1;var r="".concat(n,"-").concat(Yp(Tp+n+rg[n]));return t?"".concat(t,"-").concat(r):r}(t.displayName,t.parentComponentId):l,d=t.displayName,f=void 0===d?function(e){return Zp(e)?"styled.".concat(e):"Styled(".concat(Kp(e),")")}(e):d,h=t.displayName&&t.componentId?"".concat(jp(t.displayName),"-").concat(t.componentId):t.componentId||u,p=r&&a.attrs?a.attrs.concat(c).filter(Boolean):c,m=t.shouldForwardProp;if(r&&a.shouldForwardProp){var g=a.shouldForwardProp;if(t.shouldForwardProp){var b=t.shouldForwardProp;m=function(e,t){return g(e,t)&&b(e,t)}}else m=g}var y=new tg(n,h,r?a.componentStyle:void 0);function w(e,t){return function(e,t,n){var r=e.attrs,a=e.componentStyle,s=e.defaultProps,i=e.foldedComponentIds,c=e.styledComponentId,l=e.target,u=v.default.useContext(ng),d=Hm(),f=e.shouldForwardProp||d.shouldForwardProp;"production"!==process.env.NODE_ENV&&o.useDebugValue(c);var h=function(e,t,n){return void 0===n&&(n=Mp),e.theme!==n.theme&&e.theme||t||n.theme}(t,u,s)||Mp,p=function(e,t,n){for(var r,o=kh(kh({},t),{className:void 0,theme:n}),a=0;a<e.length;a+=1){var s=fm(r=e[a])?r(o):r;for(var i in s)o[i]="className"===i?pm(o[i],s[i]):"style"===i?kh(kh({},o[i]),s[i]):s[i]}return t.className&&(o.className=pm(o.className,t.className)),o}(r,t,h),m=p.as||l,g={};for(var b in p)void 0===p[b]||"$"===b[0]||"as"===b||"theme"===b&&p.theme===h||("forwardedAs"===b?g.as=p.forwardedAs:f&&!f(b,m)||(g[b]=p[b],f||"development"!==process.env.NODE_ENV||Sh(b)||og.has(b)||!Lp.has(m)||(og.add(b),console.warn('styled-components: it looks like an unknown prop "'.concat(b,'" 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 y=function(e,t){var n=Hm(),r=e.generateAndInjectStyles(t,n.styleSheet,n.stylis);return"production"!==process.env.NODE_ENV&&o.useDebugValue(r),r}(a,p);"production"!==process.env.NODE_ENV&&e.warnTooManyClasses&&e.warnTooManyClasses(y);var w=pm(i,c);return y&&(w+=" "+y),p.className&&(w+=" "+p.className),g[Zp(m)&&!Lp.has(m)?"class":"className"]=w,n&&(g.ref=n),o.createElement(m,g)}(x,e,t)}w.displayName=f;var x=v.default.forwardRef(w);return x.attrs=p,x.componentStyle=y,x.displayName=f,x.shouldForwardProp=m,x.foldedComponentIds=r?pm(a.foldedComponentIds,a.styledComponentId):"",x.styledComponentId=h,x.target=r?a.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++)bm(e,o[r],!0);return e}({},a.defaultProps,e):e}}),"production"!==process.env.NODE_ENV&&(Rp(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 a=t?' with the id of "'.concat(t,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(e).concat(a,".\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)),ym(x,function(){return".".concat(x.styledComponentId)}),s&&dm(x,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),x}function sg(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 ig=function(e){return Object.assign(e,{isCss:!0})};function cg(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(fm(e)||gm(e))return ig(Xm(sg(zp,Ah([e],t,!0))));var r=e;return 0===t.length&&1===r.length&&"string"==typeof r[0]?Xm(r):ig(Xm(sg(r,t)))}function lg(e,t,n){if(void 0===n&&(n=Mp),!t)throw xm(1,t);var r=function(r){for(var o=[],a=1;a<arguments.length;a++)o[a-1]=arguments[a];return e(t,n,cg.apply(void 0,Ah([r],o,!1)))};return r.attrs=function(r){return lg(e,t,kh(kh({},n),{attrs:Array.prototype.concat(n.attrs,r).filter(Boolean)}))},r.withConfig=function(r){return lg(e,t,kh(kh({},n),r))},r}var ug=function(e){return lg(ag,e)},dg=ug;Lp.forEach(function(e){dg[e]=ug(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 fg="__sc-".concat(Ip,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[fg]||(window[fg]=0),1===window[fg]&&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[fg]+=1);const hg={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"}},pg=(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=mm(cg.apply(void 0,Ah([e],t,!1))),o=Yp(r);return new Ym(o,r)})`
12
+ const Hl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Yl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Zl=BigInt(0),Kl=BigInt(1),Jl=BigInt(2),Ql=(e,t)=>(e+t/Jl)/t;const Xl=El(Hl,void 0,void 0,{sqrt:function(e){const t=Hl,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=hl(l,n,t)*l%t,f=hl(d,n,t)*l%t,h=hl(f,Jl,t)*u%t,p=hl(h,o,t)*h%t,m=hl(p,s,t)*p%t,g=hl(m,i,t)*m%t,b=hl(g,c,t)*g%t,y=hl(b,i,t)*m%t,w=hl(y,n,t)*l%t,v=hl(w,a,t)*p%t,x=hl(v,r,t)*u%t,E=hl(x,Jl,t);if(!Xl.eql(Xl.sqr(E),e))throw new Error("Cannot find square root");return E}}),ed=function(e,t){const n=t=>Vl({...e,...Wl(t)});return{...n(t),create:n}}({a:Zl,b:BigInt(7),Fp:Xl,n:Yl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Yl,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Kl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),i=Ql(s*e,t),c=Ql(-r*e,t);let u=fl(e-i*n-c*o,t),l=fl(-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}}}},$s);var td=Object.freeze({__proto__:null,secp256k1:ed});function nd(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new id({signature:e});if(void 0===e.s)throw new id({signature:e});if(n&&void 0===e.yParity)throw new id({signature:e});if(e.r<0n||e.r>_u)throw new cd({value:e.r});if(e.s<0n||e.s>_u)throw new ud({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new ld({value:e.yParity})}function rd(e){if(130!==e.length&&132!==e.length)throw new ad({signature:e});const t=BigInt(bi(e,0,32)),n=BigInt(bi(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return sd(t)}catch{throw new ld({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function od(e){if(void 0!==e.r&&void 0!==e.s)return function(e){const t="string"==typeof e?rd(e):e instanceof Uint8Array?function(e){return rd(fi(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=sd(t)),"number"!=typeof n)throw new ld({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:sd(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return nd(t),t}(e)}function sd(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 dd({value:e})}class ad extends Oa{constructor({signature:e}){var t;super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${yi((t=e,t instanceof Uint8Array?fi(t):Array.isArray(t)?fi(new Uint8Array(t)):t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class id extends Oa{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 cd extends Oa{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 ud extends Oa{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 ld extends Oa{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 dd extends Oa{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 fd(e,t={}){return"string"==typeof e.chainId?function(e){const{address:t,chainId:n,nonce:r}=e,o=od(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...o}}(e):{...e,...t.signature}}const hd=Zu("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function pd(e){if("string"==typeof e){if("0x8010801080108010801080108010801080108010801080108010801080108010"!==bi(e,-32))throw new md(e)}else nd(e.authorization)}let md=class extends Oa{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 gd(e,{address:t,blockNumber:n,blockTag:r,storageKeys:o}){const s=r??"latest",a=void 0!==n?Gt(n):void 0;return function(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?Ft(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 bd(e,{blockHash:t,blockNumber:n,blockTag:r,hash:o,index:s}){const a=r||"latest",i=void 0!==n?Gt(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,Gt(s)]},{dedupe:!0}):await e.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[i||a,Gt(s)]},{dedupe:Boolean(i)}),!c)throw new Vr({blockHash:t,blockNumber:n,blockTag:a,hash:o,index:s});return(e.chain?.formatters?.transaction?.format||ps)(c)}async function yd(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||gc)(n)}async function wd(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?Ti(e.blockOverrides):void 0,r=e.calls.map(e=>{const t=e,n=t.account?fr(t.account):void 0,r=t.abi?pr(t):t.data,o={...t,data:t.dataSuffix?Vn([r||"0x",t.dataSuffix]):r,from:t.from??n?.address};return cs(o),rs(o)}),o=e.stateOverrides?as(e.stateOverrides):void 0;t.push({blockOverrides:n,calls:r,stateOverrides:o})}const c=("bigint"==typeof n?Gt(n):void 0)||r;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:t,returnFullTransactions:s,traceTransfers:a,validation:i},c]})).map((e,t)=>({...ms(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=>Zs(e)),d="0x1"===e.status?"success":"failure",f=r&&"success"===d&&"0x"!==c?Xs({abi:r,data:c,functionName:a}):null,h=(()=>{if("success"===d)return;let t;return"0x"===e.error?.data?t=new ot:e.error&&(t=new Xr(e.error)),t?Oo(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=es(t,{});if(n instanceof Xo)throw t;throw n}}function vd(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 Oa("Unable to normalize signature.");return o}function xd(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Su(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)=>xd(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=>xd(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function Ed(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 Ed(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")))&&Su(n[r],{strict:!1}))())return a}}function Pd(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?Ge(e):e;return{...r,...n?{hash:Id(r)}:{}}}function kd(e,t,n){const{args:r=[],prepare:o=!0}=n??{},s=xi(t,{strict:!1}),a=e.filter(e=>s?"function"===e.type||"error"===e.type?Ad(e)===bi(t,0,4):"event"===e.type&&Id(e)===t:"name"in e&&e.name===t);if(0===a.length)throw new Nd({name:t});if(1===a.length)return{...a[0],...o?{hash:Id(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:Id(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&&xd(t,r)});if(t){if(i&&"inputs"in i&&i.inputs){const t=Ed(e.inputs,i.inputs,r);if(t)throw new Sd({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 Nd({name:t});return{...c,...o?{hash:Id(c)}:{}}}function Ad(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return kd(t,n)}return e[0]})();return bi(Id(t),0,4)}function Id(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return kd(t,n)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:Pu(pi(function(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return kd(t,n)}return e[0]})();return vd("string"==typeof t?t:re(t))}(t)))}class Sd extends Oa{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${vd(re(e.abiItem))}\`, and`,`\`${t.type}\` in \`${vd(re(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 Nd extends Oa{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 Td(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new Nd({name:"constructor"});return t}function $d(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[t,n,r]=e;return[Cd(t,n,{args:r}),r]}const[t,n]=e;return[t,n]})(),{overloads:r}=t,o=r?Cd([t,...r],t.name,{args:n}):t,s=Ad(o);const a=n.length>0?Hu(o.inputs,n):void 0;return a?li(s,a):s}function Bd(e,t={}){return Pd(e,t)}function Cd(e,t,n){const r=kd(e,t,n);if("function"!==r.type)throw new Nd({name:t,type:"function"});return r}const Od="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?fr(t.account):void 0;if(a&&!u)throw new Xe("`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[Td(t),n]}return e})(),{bytecode:r,args:o}=n;return li(r,t.inputs?.length&&o?.length?Hu(t.inputs,o):"0x")}(Pd("constructor(bytes, bytes)"),{bytecode:ji,args:["0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033",$d(Bd("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 Vc(e,{account:u.address,...t,data:t.abi?pr(t):t.data});return n.map(({address:e,storageKeys:t})=>t.length>0?e:null)})).then(e=>e.flat().filter(Boolean)):[],f=await wd(e,{blockNumber:n,blockTag:r,blocks:[...a?[{calls:[{data:l}],stateOverrides:s},{calls:d.map((e,t)=>({abi:[Bd("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Od,nonce:t})),stateOverrides:[{address:Od,nonce:0}]}]:[],{calls:[...o,{}].map(e=>({...e,from:u?.address})),stateOverrides:s},...a?[{calls:[{data:l}]},{calls:d.map((e,t)=>({abi:[Bd("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Od,nonce:t})),stateOverrides:[{address:Od,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Bd("function decimals() returns (uint256)")],functionName:"decimals",from:Od,nonce:t})),stateOverrides:[{address:Od,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Bd("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:Od,nonce:t})),stateOverrides:[{address:Od,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Bd("function symbol() returns (string)")],functionName:"symbol",from:Od,nonce:t})),stateOverrides:[{address:Od,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?Mt(e.data):null),A=[...g?.calls??[],...b?.calls??[]].map(e=>"success"===e.status?Mt(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 Rd="0x6492649264926492649264926492649264926492649264926492649264926492";function zd(e){try{return function(e){if(bi(e,-32)!==Rd)throw new Md(e)}(e),!0}catch{return!1}}class Md extends Oa{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 Fd({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 ed.Signature(Mt(e),Mt(t)).toCompactHex()}${0===s?"1b":"1c"}`;return"hex"===n?a:Kt(a)}async function Ld(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 Ye(e)?e:"object"==typeof e&&"r"in e&&"s"in e?Fd(e):Dt(e)})();try{return function(e){try{return pd(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){pd(e);const t=vi(bi(e,-64,-32)),n=bi(e,-t-64,-64),r=bi(e,0,-t-64),[o,s,a]=Wu(hd,n);return{authorization:fd({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 Yc(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 Ve(e,tc,"readContract")({address:n,abi:Mi,args:[s,a],blockNumber:r,blockTag:o,functionName:"isValidSignature"}).catch(e=>{if(e instanceof Zr)throw new jd;throw e});if(i.startsWith("0x1626ba7e"))return!0;throw new jd}(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:Gt(i.r,{size:32}),s:Gt(i.s,{size:32}),yParity:i.yParity},h=await async function({address:e,authorization:t,signature:n}){return qs(Un(e),await jo({authorization:t,signature:n}))}({address:n,authorization:f});if(!h)throw new jd;const p=await Ve(e,tc,"readContract")({...a?{address:a}:{code:Gi},authorizationList:[f],abi:$i,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...c?[{allowFailure:!0,target:l??n,callData:c}]:[],{allowFailure:!0,target:n,callData:pr({abi:Mi,functionName:"isValidSignature",args:[s,u]})}]]}),m=p[p.length-1]?.returnData;if(m?.startsWith("0x1626ba7e"))return!0;throw new jd}(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?zd(a)?a:function(e){const{data:t,signature:n,to:r}=e;return li(Hu(Zu("address, bytes, bytes"),[r,t,n]),Rd)}({data:o,signature:a,to:r}):a)(),l=i?{to:i,data:pr({abi:Fi,functionName:"isValidSig",args:[n,s,u]}),...c}:{data:Hi({abi:Fi,args:[n,s,u],bytecode:Di}),...c},{data:d}=await Ve(e,Xi,"call")(l).catch(e=>{if(e instanceof Yr)throw new jd;throw e});if(function(e,t={}){let n=e;if(t.size&&(zt(n,{size:t.size}),n=Rt(n)),"0x00"===Rt(n))return!1;if("0x01"===Rt(n))return!0;throw new Ot(n)}(d??"0x0"))return!0;throw new jd}(e,{...t,verifierAddress:o,signature:a})}catch(e){try{if(qs(Un(n),await Ro({hash:r,signature:a})))return!0}catch{}if(e instanceof jd)return!1;throw e}}class jd extends Error{}function Ud(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))?sc(Cr(["watchBlockNumber",e.uid,t,n,a]),{onBlockNumber:r,onError:o},r=>ic(async()=>{try{const t=await Ve(e,dc,"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})):sc(Cr(["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=Mt(e.result?.number);t.onBlockNumber(r,i),i=r},onError(e){t.onError?.(e)}});r=s,n||r()}catch(e){o?.(e)}})(),()=>r()})}const Dd=/^(?:(?<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)?/,Gd=/(?: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 qd(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(Dd)?.groups??{},{chainId:o,expirationTime:s,issuedAt:a,notBefore:i,requestId:c,...u}=e.match(Gd)?.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(!qn(r.address,{strict:!1}))return!1;if(t&&!qs(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=uu(o);return Ld(e,{address:l.address,hash:f,signature:i,...u})}function Vd(e){return{call:t=>Xi(e,t),createAccessList:t=>Vc(e,t),createBlockFilter:()=>async function(e){const t=lr(e,{method:"eth_newBlockFilter"}),n=await e.request({method:"eth_newBlockFilter"});return{id:n,request:t(n),type:"block"}}(e),createContractEventFilter:t=>dr(e,t),createEventFilter:t=>Wc(e,t),createPendingTransactionFilter:()=>Hc(e),estimateContractGas:t=>async function(e,t){const{abi:n,address:r,args:o,functionName:s,dataSuffix:a,...i}=t,c=pr({abi:n,args:o,functionName:s});try{return await Ve(e,Gs,"estimateGas")({data:`${c}${a?a.replace("0x",""):""}`,to:r,...i})}catch(e){const t=i.account?fr(i.account):void 0;throw Oo(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/estimateContractGas",functionName:s,sender:t?.address})}}(e,t),estimateGas:t=>Gs(e,t),getBalance:t=>async function(e,{address:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest"}){const o="bigint"==typeof n?Gt(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=>gs(e,t),getBlockNumber:t=>dc(e,t),getBlockTransactionCount:t=>async function(e,{blockHash:t,blockNumber:n,blockTag:r="latest"}={}){const o=void 0!==n?Gt(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)}),Ft(s)}(e,t),getBytecode:t=>Yc(e,t),getChainId:()=>Ls(e),getCode:t=>Yc(e,t),getContractEvents:t=>Js(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 Ve(e,tc,"readContract")({abi:Kc,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 Zc({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 Yi({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),l=c?.ensTlds;if(l&&!l.some(e=>s.endsWith(e)))return null;const d=null!=o?[Sc(s),BigInt(o)]:[Sc(s)];try{const t=pr({abi:zi,functionName:"addr",args:d}),o={address:u,abi:Oi,functionName:"resolveWithGateways",args:[jt($c(s)),t,a??[kc]],blockNumber:n,blockTag:r},i=Ve(e,tc,"readContract"),c=await i(o);if("0x"===c[0])return null;const l=Xs({abi:zi,args:d,functionName:"addr",data:c[0]});return"0x"===l||"0x00"===Rt(l)?null:l}catch(e){if(i)throw e;if(vc(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 Ve(e,qc,"getEnsText")({blockNumber:t,blockTag:n,key:"avatar",name:o,universalResolverAddress:i,gatewayUrls:s,strict:a});if(!c)return null;try{return await Gc(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 Yi({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})();try{const t={address:u,abi:_i,args:[n,s,a??[kc]],functionName:"reverseWithGateways",blockNumber:r,blockTag:o},i=Ve(e,tc,"readContract"),[c]=await i(t);return c||null}catch(e){if(i)throw e;if(vc(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 Yi({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 Ve(e,tc,"readContract")({address:a,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[jt($c(o))],blockNumber:n,blockTag:r});return c}(e,t),getEnsText:t=>qc(e,t),getFeeHistory:t=>Jc(e,t),estimateFeesPerGas:t=>async function(e,t){return ws(e,t)}(e,t),getFilterChanges:e=>fc(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=>Zs(e));return t.abi?Ys({abi:t.abi,logs:r,strict:n}):r}(0,e),getGasPrice:()=>bs(e),getLogs:t=>Ks(e,t),getProof:t=>gd(e,t),estimateMaxPriorityFeePerGas:t=>async function(e,t){return ys(e,t)}(e,t),getStorageAt:t=>async function(e,{address:t,blockNumber:n,blockTag:r="latest",slot:o}){const s=void 0!==n?Gt(n):void 0;return await e.request({method:"eth_getStorageAt",params:[t,o,s||r]})}(e,t),getTransaction:t=>bd(e,t),getTransactionConfirmations:t=>async function(e,{hash:t,transactionReceipt:n}){const[r,o]=await Promise.all([Ve(e,dc,"getBlockNumber")({}),t?Ve(e,bd,"getTransaction")({hash:t}):void 0]),s=n?.blockNumber||o?.blockNumber;return s?r-s+1n:0n}(e,t),getTransactionCount:t=>vs(e,t),getTransactionReceipt:t=>yd(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 Yi({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=pr({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=Oo(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=>Ve(e,tc,"readContract")({...null===f?{code:Gi}:{address:f},abi:$i,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 ot;if(!s)throw new Xr({data:r});const e=Xs({abi:i,args:d,data:r,functionName:l});b.push(o?{result:e,status:"success"}:e)}catch(e){const t=Oo(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 Xe("multicall results mismatch");return b}(e,t),prepareTransactionRequest:t=>Ds(e,t),readContract:t=>tc(e,t),sendRawTransaction:t=>async function(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}(e,t),simulate:t=>wd(e,t),simulateBlocks:t=>wd(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?fr(i.account):e.account,u=pr({abi:n,args:o,functionName:a});try{const{data:l}=await Ve(e,Xi,"call")({batch:!1,data:`${u}${s?s.replace("0x",""):""}`,to:r,...i,account:c});return{result:Xs({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 Oo(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/simulateContract",functionName:a,sender:c?.address})}}(e,t),verifyHash:t=>Ld(e,t),verifyMessage:t=>async function(e,{address:t,message:n,factory:r,factoryData:o,signature:s,...a}){return Ld(e,{address:t,factory:r,factoryData:o,hash:uu(n),signature:s,...a})}(e,t),verifySiweMessage:t=>qd(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 Ld(e,{address:n,factory:r,factoryData:o,hash:mu({message:a,primaryType:i,types:c,domain:u}),signature:s,...l})}(e,t),uninstallFilter:e=>hc(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=Cr(["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}=Ki(),v=c?setTimeout(()=>{m?.(),p?.(),w(new Hr({hash:o}))},c):void 0;return p=sc(u,{onReplaced:s,resolve:y,reject:w},async t=>{if(h=await Ve(e,yd,"getTransactionReceipt")({hash:o}).catch(()=>{}),h&&r<=1)return clearTimeout(v),t.resolve(h),void p?.();m=Ve(e,Ud,"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 pc(async()=>{d=await Ve(e,bd,"getTransaction")({hash:o}),d.blockNumber&&(u=d.blockNumber)},{delay:i,retryCount:a}),g=!1),h=await Ve(e,yd,"getTransactionReceipt")({hash:o}),r>1&&(!h.blockNumber||u-h.blockNumber+1n<r))return;c(()=>t.resolve(h))}catch(n){if(n instanceof Vr||n instanceof Wr){if(!d)return void(g=!1);try{f=d,g=!0;const n=await pc(()=>Ve(e,gs,"getBlock")({blockNumber:u,includeTransactions:!0}),{delay:i,retryCount:a,shouldRetry:({error:e})=>e instanceof fs});g=!1;const o=n.transactions.find(({from:e,nonce:t})=>e===f.from&&t===f.nonce);if(!o)return;if(h=await Ve(e,yd,"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?sc(Cr(["watchBlocks",e.uid,t,n,r,l,c]),{onBlock:o,onError:s},o=>ic(async()=>{try{const r=await Ve(e,gs,"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 Ve(e,gs,"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&&Ve(e,gs,"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 Ve(e,gs,"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=>Ud(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 sc(Cr(["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=ic(async()=>{if(f)try{let i;if(l)i=await Ve(e,fc,"getFilterChanges")({filter:l});else{const s=await Ve(e,dc,"getBlockNumber")({});i=u&&u<s?await Ve(e,Js,"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 lo&&(f=!1),c.onError?.(e)}else{try{l=await Ve(e,dr,"createContractEventFilter")({abi:n,address:r,args:o,eventName:a,strict:t,fromBlock:i})}catch{}f=!0}},{emitOnBegin:!0,interval:d});return async()=>{l&&await Ve(e,hc,"uninstallFilter")({filter:l}),h()}})})():(()=>{const t=f??!1,i=Cr(["watchContractEvent",r,o,s,e.uid,a,d,t]);let l=!0,h=()=>l=!1;return sc(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?cr({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=Zs(r,{args:o,eventName:e});t.onLogs([s])}catch(e){let n,o;if(e instanceof wt||e instanceof vt){if(f)return;n=e.abiItem.name,o=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const s=Zs(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?sc(Cr(["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=ic(async()=>{if(d)try{let a;if(u)a=await Ve(e,fc,"getFilterChanges")({filter:u});else{const r=await Ve(e,dc,"getBlockNumber")({});a=c&&c!==r?await Ve(e,Ks,"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 lo&&(d=!1),i.onError?.(e)}else{try{u=await Ve(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 Ve(e,hc,"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=>cr({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=Zs(t,{args:n,eventName:e});c([r])}catch(e){let n,r;if(e instanceof wt||e instanceof vt){if(d)return;n=e.abiItem.name,r=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const o=Zs(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)?sc(Cr(["watchPendingTransactions",e.uid,t,s]),{onTransactions:r,onError:n},n=>{let r;const o=ic(async()=>{try{if(!r)try{return void(r=await Ve(e,Hc,"createPendingTransactionFilter")({}))}catch(e){throw o(),e}const s=await Ve(e,fc,"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 Ve(e,hc,"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?fr(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:wc(),...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(Vd)}class Hd extends Xe{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 Yd(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 Hd;const v=cu(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:Xc(r,{methods:t,retryCount:o,retryDelay:s,uid:wc()}),value:c}}({key:s,methods:a,name:i,async request({method:e,params:t}){const r={method:e,params:t},{schedule:o}=Qi({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 to({body:r,error:s,url:w});return a},retryCount:b,retryDelay:l,timeout:y,type:"http"},{fetchOptions:o,url:w})}}function Zd(e,t,n){for(let n in t){let r=t[n];Object.defineProperty(e,n,{enumerable:!0,value:r,writable:!1})}}function Kd(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=>Kd(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 Kd(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=>`${Kd(n,t)}: ${Kd(e[n],t)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Jd(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: ${Kd(n)}`);for(const e in n){if("shortMessage"===e)continue;const t=n[e];r.push(e+"="+Kd(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 Zd(r,{code:t}),n&&Object.assign(r,n),null==r.shortMessage&&Zd(r,{shortMessage:o}),r}(t,n,r)}function Qd(e,t,n,r){Jd(e,t,"INVALID_ARGUMENT",{argument:n,value:r})}function Xd(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}Qd(!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 ef=BigInt(0),tf=BigInt(1),nf=9007199254740991;function rf(e,t){const n=af(e,"value"),r=BigInt(uf(t,"width"));if(Jd(n>>r===ef,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),n>>r-tf){return-((~n&(tf<<r)-tf)+tf)}return n}function of(e,t){const n=af(e,"value"),r=BigInt(uf(t,"bits"));return n&(tf<<r)-tf}function sf(e,t){switch(typeof e){case"bigint":return e;case"number":return Qd(Number.isInteger(e),"underflow",t||"value",e),Qd(e>=-nf&&e<=nf,"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){Qd(!1,`invalid BigNumberish string: ${n.message}`,t||"value",e)}}Qd(!1,"invalid BigNumberish value",t||"value",e)}function af(e,t){const n=sf(e,t);return Jd(n>=ef,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),n}const cf="0123456789abcdef";function uf(e,t){switch(typeof e){case"bigint":return Qd(e>=-nf&&e<=nf,"overflow",t||"value",e),Number(e);case"number":return Qd(Number.isInteger(e),"underflow",t||"value",e),Qd(e>=-nf&&e<=nf,"overflow",t||"value",e),e;case"string":try{if(""===e)throw new Error("empty string");return uf(BigInt(e),t)}catch(n){Qd(!1,`invalid numeric string: ${n.message}`,t||"value",e)}}Qd(!1,"invalid numeric value",t||"value",e)}const lf=BigInt(-1),df=BigInt(0),ff=BigInt(1),hf=BigInt(5),pf={};let mf="0000";for(;mf.length<80;)mf+=mf;function gf(e){let t=mf;for(;t.length<e;)t+=t;return BigInt("1"+t.substring(0,e))}function bf(e,t,n){const r=BigInt(t.width);if(t.signed){const t=ff<<r-ff;Jd(null==n||e>=-t&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=e>df?rf(of(e,r),r):-rf(of(-e,r),r)}else{const t=ff<<r;Jd(null==n||e>=0&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=(e%t+t)%t&t-ff}return e}function yf(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]+)$/);Qd(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:(Qd(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)}Qd(n%8==0,"invalid FixedNumber width (not byte aligned)","format.width",n),Qd(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 wf{format;#e;#t;#n;_value;constructor(e,t,n){!function(e,t,n){if(e!==t){let e=n,t="new";e+=".",t+=" "+n,Jd(!1,`private constructor; use ${e}from* methods`,"UNSUPPORTED_OPERATION",{operation:t})}}(e,pf,"FixedNumber"),this.#t=t,this.#e=n;const r=function(e,t){let n="";e<df&&(n="-",e*=lf);let r=e.toString();if(0===t)return n+r;for(;r.length<=t;)r=mf+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);Zd(this,{format:n.name,_value:r}),this.#n=gf(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){Qd(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)}#o(e,t){return e=bf(e,this.#e,t),new wf(pf,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 Jd(t%this.#n===df,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),this.#o(t/this.#n,"mulSignal")}#c(e,t){return Jd(e.#t!==df,"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){Jd(e.#t!==df,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),this.#r(e);const t=this.#t*this.#n;return Jd(t%e.#t===df,"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*=gf(r):r<0&&(t*=gf(-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<df&&(e-=this.#n-ff),e=this.#t/this.#n*this.#n,this.#o(e,"floor")}ceiling(){let e=this.#t;return this.#t>df&&(e+=this.#n-ff),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=hf*gf(t-1);let r=this.value+n;const o=gf(t);return r=r/o*o,bf(r,this.#e,"round"),new wf(pf,r,this.#e)}isZero(){return this.#t===df}isNegative(){return this.#t<df}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return wf.fromString(this.toString(),e)}static fromValue(e,t,n){const r=null==t?0:uf(t),o=yf(n);let s=sf(e,"value");const a=r-o.decimals;if(a>0){const t=gf(a);Jd(s%t===df,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),s/=t}else a<0&&(s*=gf(-a));return bf(s,o,"fromValue"),new wf(pf,s,o)}static fromString(e,t){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Qd(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const r=yf(t);let o=n[2]||"0",s=n[3]||"";for(;s.length<r.decimals;)s+=mf;Jd(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 bf(a,r,"fromString"),new wf(pf,a,r)}static fromBytes(e,t){let n=function(e){if(e instanceof Uint8Array){let t="0x0";for(const n of e)t+=cf[n>>4],t+=cf[15&n];return BigInt(t)}return sf(e)}(Xd(e,"value"));const r=yf(t);return r.signed&&(n=rf(n,r.width)),bf(n,r,"fromBytes"),new wf(pf,n,r)}}function vf(e){return function(e,t){let n=18;return n=uf(t,"unit"),wf.fromValue(e,n,{decimals:n,width:512}).toString()}(e,18)}const xf="0.38.13";function Ef({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@${xf}:${t}`):r.searchParams.append("sdkVersion",`onchainkit@${xf}`),r.searchParams.sort(),r.toString()}var Pf=[],kf=[],Af="undefined"!=typeof Uint8Array?Uint8Array:Array,If=!1;function Sf(){If=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)Pf[t]=e[t],kf[e.charCodeAt(t)]=t;kf["-".charCodeAt(0)]=62,kf["_".charCodeAt(0)]=63}function Nf(e){return Pf[e>>18&63]+Pf[e>>12&63]+Pf[e>>6&63]+Pf[63&e]}function Tf(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(Nf(r));return o.join("")}function $f(e){var t;If||Sf();for(var n=e.length,r=n%3,o="",s=[],a=16383,i=0,c=n-r;i<c;i+=a)s.push(Tf(e,i,i+a>c?c:i+a));return 1===r?(t=e[n-1],o+=Pf[t>>2],o+=Pf[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=Pf[t>>10],o+=Pf[t>>4&63],o+=Pf[t<<2&63],o+="="),s.push(o),s.join("")}function Bf(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 Cf(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 Of={}.toString,_f=Array.isArray||function(e){return"[object Array]"==Of.call(e)};function Rf(){return Mf.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function zf(e,t){if(Rf()<t)throw new RangeError("Invalid typed array length");return Mf.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Mf.prototype:(null===e&&(e=new Mf(t)),e.length=t),e}function Mf(e,t,n){if(!(Mf.TYPED_ARRAY_SUPPORT||this instanceof Mf))return new Mf(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 jf(this,e)}return Ff(this,e,t,n)}function Ff(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);Mf.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Mf.prototype:e=Uf(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!Mf.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|qf(t,n);e=zf(e,r);var o=e.write(t,n);o!==r&&(e=e.slice(0,o));return e}(e,t,n):function(e,t){if(Gf(t)){var n=0|Df(t.length);return 0===(e=zf(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?zf(e,0):Uf(e,t);if("Buffer"===t.type&&_f(t.data))return Uf(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Lf(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 jf(e,t){if(Lf(t),e=zf(e,t<0?0:0|Df(t)),!Mf.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Uf(e,t){var n=t.length<0?0:0|Df(t.length);e=zf(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Df(e){if(e>=Rf())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Rf().toString(16)+" bytes");return 0|e}function Gf(e){return!(null==e||!e._isBuffer)}function qf(e,t){if(Gf(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 bh(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return yh(e).length;default:if(r)return bh(e).length;t=(""+t).toLowerCase(),r=!0}}function Vf(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 ah(this,t,n);case"utf8":case"utf-8":return nh(this,t,n);case"ascii":return oh(this,t,n);case"latin1":case"binary":return sh(this,t,n);case"base64":return th(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ih(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 Hf(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=Mf.from(t,r)),Gf(t))return 0===t.length?-1:Yf(e,t,n,r,o);if("number"==typeof t)return t&=255,Mf.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Yf(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Yf(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 Zf(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 Kf(e,t,n,r){return wh(bh(t,e.length-n),e,n,r)}function Jf(e,t,n,r){return wh(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Qf(e,t,n,r){return Jf(e,t,n,r)}function Xf(e,t,n,r){return wh(yh(t),e,n,r)}function eh(e,t,n,r){return wh(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 th(e,t,n){return 0===t&&n===e.length?$f(e):$f(e.slice(t,n))}function nh(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<=rh)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=rh));return n}(r)}Mf.TYPED_ARRAY_SUPPORT=void 0===globalThis.TYPED_ARRAY_SUPPORT||globalThis.TYPED_ARRAY_SUPPORT,Rf(),Mf.poolSize=8192,Mf._augment=function(e){return e.__proto__=Mf.prototype,e},Mf.from=function(e,t,n){return Ff(null,e,t,n)},Mf.TYPED_ARRAY_SUPPORT&&(Mf.prototype.__proto__=Uint8Array.prototype,Mf.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Mf[Symbol.species]),Mf.alloc=function(e,t,n){return function(e,t,n,r){return Lf(t),t<=0?zf(e,t):void 0!==n?"string"==typeof r?zf(e,t).fill(n,r):zf(e,t).fill(n):zf(e,t)}(null,e,t,n)},Mf.allocUnsafe=function(e){return jf(null,e)},Mf.allocUnsafeSlow=function(e){return jf(null,e)},Mf.isBuffer=function(e){return null!=e&&(!!e._isBuffer||vh(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&vh(e.slice(0,0))}(e))},Mf.compare=function(e,t){if(!Gf(e)||!Gf(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},Mf.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}},Mf.concat=function(e,t){if(!_f(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Mf.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=Mf.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var s=e[n];if(!Gf(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},Mf.byteLength=qf,Mf.prototype._isBuffer=!0,Mf.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},Mf.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},Mf.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},Mf.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?nh(this,0,e):Vf.apply(this,arguments)},Mf.prototype.equals=function(e){if(!Gf(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Mf.compare(this,e)},Mf.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+">"},Mf.prototype.compare=function(e,t,n,r,o){if(!Gf(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},Mf.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},Mf.prototype.indexOf=function(e,t,n){return Hf(this,e,t,n,!0)},Mf.prototype.lastIndexOf=function(e,t,n){return Hf(this,e,t,n,!1)},Mf.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 Zf(this,e,t,n);case"utf8":case"utf-8":return Kf(this,e,t,n);case"ascii":return Jf(this,e,t,n);case"latin1":case"binary":return Qf(this,e,t,n);case"base64":return Xf(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return eh(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},Mf.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var rh=4096;function oh(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 sh(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 ah(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+=gh(e[s]);return o}function ih(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 ch(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 uh(e,t,n,r,o,s){if(!Gf(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 lh(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 dh(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 fh(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 hh(e,t,n,r,o){return o||fh(e,0,n,4),Cf(e,t,n,r,23,4),n+4}function ph(e,t,n,r,o){return o||fh(e,0,n,8),Cf(e,t,n,r,52,8),n+8}Mf.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),Mf.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=Mf.prototype;else{var o=t-e;n=new Mf(o,void 0);for(var s=0;s<o;++s)n[s]=this[s+e]}return n},Mf.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||ch(e,t,this.length);for(var r=this[e],o=1,s=0;++s<t&&(o*=256);)r+=this[e+s]*o;return r},Mf.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||ch(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},Mf.prototype.readUInt8=function(e,t){return t||ch(e,1,this.length),this[e]},Mf.prototype.readUInt16LE=function(e,t){return t||ch(e,2,this.length),this[e]|this[e+1]<<8},Mf.prototype.readUInt16BE=function(e,t){return t||ch(e,2,this.length),this[e]<<8|this[e+1]},Mf.prototype.readUInt32LE=function(e,t){return t||ch(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Mf.prototype.readUInt32BE=function(e,t){return t||ch(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Mf.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||ch(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},Mf.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||ch(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},Mf.prototype.readInt8=function(e,t){return t||ch(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Mf.prototype.readInt16LE=function(e,t){t||ch(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Mf.prototype.readInt16BE=function(e,t){t||ch(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Mf.prototype.readInt32LE=function(e,t){return t||ch(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Mf.prototype.readInt32BE=function(e,t){return t||ch(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Mf.prototype.readFloatLE=function(e,t){return t||ch(e,4,this.length),Bf(this,e,!0,23,4)},Mf.prototype.readFloatBE=function(e,t){return t||ch(e,4,this.length),Bf(this,e,!1,23,4)},Mf.prototype.readDoubleLE=function(e,t){return t||ch(e,8,this.length),Bf(this,e,!0,52,8)},Mf.prototype.readDoubleBE=function(e,t){return t||ch(e,8,this.length),Bf(this,e,!1,52,8)},Mf.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||uh(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},Mf.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||uh(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},Mf.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,1,255,0),Mf.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Mf.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,2,65535,0),Mf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):lh(this,e,t,!0),t+2},Mf.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,2,65535,0),Mf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):lh(this,e,t,!1),t+2},Mf.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,4,4294967295,0),Mf.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):dh(this,e,t,!0),t+4},Mf.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,4,4294967295,0),Mf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):dh(this,e,t,!1),t+4},Mf.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);uh(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},Mf.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);uh(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},Mf.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,1,127,-128),Mf.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Mf.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,2,32767,-32768),Mf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):lh(this,e,t,!0),t+2},Mf.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,2,32767,-32768),Mf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):lh(this,e,t,!1),t+2},Mf.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,4,2147483647,-2147483648),Mf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):dh(this,e,t,!0),t+4},Mf.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||uh(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Mf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):dh(this,e,t,!1),t+4},Mf.prototype.writeFloatLE=function(e,t,n){return hh(this,e,t,!0,n)},Mf.prototype.writeFloatBE=function(e,t,n){return hh(this,e,t,!1,n)},Mf.prototype.writeDoubleLE=function(e,t,n){return ph(this,e,t,!0,n)},Mf.prototype.writeDoubleBE=function(e,t,n){return ph(this,e,t,!1,n)},Mf.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||!Mf.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},Mf.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&&!Mf.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=Gf(e)?e:bh(new Mf(e,r).toString()),i=a.length;for(s=0;s<n-t;++s)this[s+t]=a[s%i]}return this};var mh=/[^+\/0-9A-Za-z-_]/g;function gh(e){return e<16?"0"+e.toString(16):e.toString(16)}function bh(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 yh(e){return function(e){var t,n,r,o,s,a;If||Sf();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 Af(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=kf[e.charCodeAt(t)]<<18|kf[e.charCodeAt(t+1)]<<12|kf[e.charCodeAt(t+2)]<<6|kf[e.charCodeAt(t+3)],a[c++]=o>>16&255,a[c++]=o>>8&255,a[c++]=255&o;return 2===s?(o=kf[e.charCodeAt(t)]<<2|kf[e.charCodeAt(t+1)]>>4,a[c++]=255&o):1===s&&(o=kf[e.charCodeAt(t)]<<10|kf[e.charCodeAt(t+1)]<<4|kf[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(mh,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function wh(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 vh(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function xh(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}class Eh{constructor(e){this.walletInfo=null,this.userId=null,this.solanaConnection=null,this.ethereumProvider=null,this.phantomAdapter=null,this.walletType="embedded",this.ethereumNetwork=null,this.defaultNetwork=exports.Network.Solana,this.api=y.default.create({baseURL:e.baseURL,headers:{"Content-Type":"application/json"}}),this.middleAccountApi=y.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:Yd(e.ethereumNetwork.rpcUrl)})),this.defaultNetwork=e.defaultNetwork||exports.Network.Solana,this.setWalletInfo=t=>{var n;e.setWalletInfo(t),this.userId=null!==(n=null==t?void 0:t.id)&&void 0!==n?n:null,this.walletInfo=t}}setWalletType(e){this.walletType=e,N.saveWalletType(e)}async reconnect(e){try{if(N.getWalletType()==="phantom"+(e?"_backup":"")){return await this.connectPhantom()}if(!e){const e=await this.getAndRefreshSession();return this.setWalletInfo(e),e}const t=N.getBackupWalletInfo();return this.setWalletInfo(t),t}catch(e){return null}}getPhantomAdapter(){return this.phantomAdapter}async connectPhantom(){try{if(this.phantomAdapter||(this.phantomAdapter=new Y),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(),wallets:[{id:e,address:e,network:exports.Network.Solana,wallet_type:exports.WalletType.Phantom,wallet_set:"Main",account_index:0,is_enabled:!0}],social_links:[],social_infos:[],account_info:{name:null,sub_accounts:[]},created_at:Date.now(),is_exported:!1};return this.setWalletInfo(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,t){const n={name:e,account_index:t},r=(await this.api.post("/account/update",n,{withCredentials:!0})).data;return this.setWalletInfo(r),r}async manageMultiAccount(e){const t=(await this.api.post("/account/multi",e,{withCredentials:!0})).data;return this.setWalletInfo(t),t}async createSubAccount(e){return this.manageMultiAccount({type:"Create",data:{name:null!=e?e:null}})}async enableSubAccount(e){return this.manageMultiAccount({type:"Enable",data:{index:e}})}async disableSubAccount(e){return this.manageMultiAccount({type:"Disable",data:{index:e}})}async signSolanaTransaction(e,n){try{if(!this.solanaConnection)throw new Error("No rpc connection");const{blockhash:r}=await this.solanaConnection.getLatestBlockhash();if(E(e)?e.message.recentBlockhash=r:e.recentBlockhash=r,this.phantomAdapter&&this.phantomAdapter.publicKey)return await this.phantomAdapter.signTransaction(e);const o=await this.signV3({network:exports.Network.Solana,address:n,tx:{Solana:w.default.encode(E(e)?e.message.serialize():e.serializeMessage())}});return e.addSignature(new t.PublicKey(n),Mf.from(w.default.decode(o))),e}catch(e){throw new Error(e instanceof Error?e.message:"Failed to sign transaction")}}async signEthereumEip712(e,t){if(!this.ethereumNetwork)throw new Error("No Ethereum network");if(!this.ethereumProvider)throw new Error("No Ethereum provider");return await this.signV2({network:exports.Network.Ethereum,address:t,tx:{EthereumEip712:e}})}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.setWalletInfo(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.setWalletInfo(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.setWalletInfo(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.setWalletInfo(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.setWalletInfo(r),this.setWalletType("embedded"),r}async loginWithChallenge(e,t){const n={type:e,data:{network:t.network||this.defaultNetwork,...t}},r=(await this.api.post("/login",n,{withCredentials:!0})).data;return this.setWalletInfo(r),this.setWalletType("embedded"),r}async oauthInit(e){return(await this.api.post("/oauth/init",e)).data}async getSignChallenge(e){return(await this.api.get(`/challenge?method=${e.method}&id=${e.id}`)).data}async getAndRefreshSession(){const e=(await this.api.get("/session",{withCredentials:!0})).data,{access_token:t}=e;return t&&N.saveAccessToken(t),this.setWalletInfo(e),e}async logout(e){this.phantomAdapter?(this.phantomAdapter.disconnect(),this.phantomAdapter=null):await this.api.post("/logout",{},{withCredentials:!0}),this.setWalletInfo(null),e?N.clearBackup():N.clear()}async getOAuth2ClientId(e){return(await this.api.get(`/oauth_id/${e}`)).data.client_id}async getSolanaBalance(e){if(!this.solanaConnection)throw new Error("Solana connection not available");return(await this.solanaConnection.getBalance(new t.PublicKey(e))/t.LAMPORTS_PER_SOL).toString()}async getEthereumBalance(e){if(!this.ethereumProvider)throw new Error("Ethereum provider not available");return vf(await this.ethereumProvider.getBalance({address:e}))}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(e){return{signTypedData:async t=>{if(!this.ethereumNetwork)throw new Error("No Ethereum network");if(!this.ethereumProvider)throw new Error("No Ethereum provider");const n=await this.signV2({network:exports.Network.Ethereum,address:e,tx:{EthereumEip712:t}}),r=w.default.decode(n),o=r[64];return Fd({r:`0x${Mf.from(r.slice(0,32)).toString("hex")}`,s:`0x${Mf.from(r.slice(32,64)).toString("hex")}`,v:BigInt(o+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 Ef(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,r;const o={user_id:null!==(t=this.userId)&&void 0!==t?t:"",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("/v3/sign/transfer",o,{withCredentials:!0})).data}catch(e){if(null===(r=null===(n=e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.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("/v3/sign/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 exportInit(e){var t,n;const r={user_nonce:xh(),account_index:e};try{return(await this.api.post("/export/init",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:"Failed to initialize export")}}async exportFinal(e){var t,n,r;const o={user_nonce:e.userNonce,server_nonce:e.serverNonce,account_index:e.accountIndex,is_export:null===(t=e.isExport)||void 0===t||t};try{return(await this.api.post("/export/final",o,{withCredentials:!0})).data}catch(e){if(null===(r=null===(n=e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Failed to finalize export")}}async getExportedWallets(e){var t,n;const r={account_index:e,is_export:!1};try{return(await this.api.post("/export/final",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:"Failed to retrieve exported wallets")}}async closeInit(){var e,t;const n={user_nonce:xh()};try{return(await this.api.post("/close/init",n,{withCredentials:!0})).data}catch(n){if(null===(t=null===(e=n.response)||void 0===e?void 0:e.data)||void 0===t?void 0:t.error)throw new Error(n.response.data.error);throw new Error(n instanceof Error?n.message:"Failed to initialize account closure")}}async closeFinal(e){var t,n;const r={user_nonce:e.userNonce,server_nonce:e.serverNonce};try{const e=await this.api.post("/close/final",r,{withCredentials:!0});return this.setWalletInfo(null),N.clear(),e.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 close account")}}async signV1(e){var t,n,r;const o={user_id:null!==(t=this.userId)&&void 0!==t?t:"",network:e.network,address:e.address,message:e.message};try{return(await this.api.post("/v1/sign",o,{withCredentials:!0})).data.signature}catch(e){if(null===(r=null===(n=e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Failed to sign message")}}async signV2(e){var t,n,r;const o={user_id:null!==(t=this.userId)&&void 0!==t?t:"",network:e.network,address:e.address,tx:e.tx};try{return(await this.api.post("/v2/sign",o,{withCredentials:!0})).data.signature}catch(e){if(null===(r=null===(n=e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Failed to sign transaction")}}async signV3(e){var t,n,r;if(e.network!==exports.Network.Solana)throw new Error("v3 sign API only supports Solana transactions");if(!e.tx.Solana)throw new Error("Solana transaction is required for v3 sign API");const o={user_id:null!==(t=this.userId)&&void 0!==t?t:"",network:e.network,address:e.address,tx:{Solana:e.tx.Solana}};try{return(await this.api.post("/v3/sign",o,{withCredentials:!0})).data.signature}catch(e){if(null===(r=null===(n=e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Failed to sign transaction")}}async lighterBuildTransaction(e,t){var n,r;try{const n={...e,wallet_address:t||e.wallet_address||null};return(await this.api.post("/v3/lighter/build_transaction",n,{withCredentials:!0})).data}catch(e){if(null===(r=null===(n=e.response)||void 0===n?void 0:n.data)||void 0===r?void 0:r.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Failed to build Lighter transaction")}}async lighterAuth(e){var t,n;const r={account_index:e.lighter_account_index,wallet_address:e.wallet_address||null,expires_in_ms:e.expires_in_ms||null};try{return(await this.api.post("/v3/lighter/auth",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:"Failed to generate Lighter auth token")}}async lighterChangeKey(e){var t,n;if(e.lighter_account_index<0)throw new Error("accountIndex must be non-negative");const r={account_index:e.lighter_account_index,wallet_address:e.wallet_address||null};try{return(await this.api.post("/v3/lighter/change_key",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:"Failed to change Lighter key")}}async exchange(e){var t,n;try{return(await this.api.post("/v3/sign/exchange",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 exchange transaction")}}}var Ph=function(){return Ph=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},Ph.apply(this,arguments)};function kh(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 Ah(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 Ih=/^((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)-.*))$/,Sh=Ah(function(e){return Ih.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}),Nh="-ms-",Th="-moz-",$h="-webkit-",Bh="comm",Ch="rule",Oh="decl",_h="@keyframes",Rh=Math.abs,zh=String.fromCharCode,Mh=Object.assign;function Fh(e){return e.trim()}function Lh(e,t){return(e=t.exec(e))?e[0]:e}function jh(e,t,n){return e.replace(t,n)}function Uh(e,t,n){return e.indexOf(t,n)}function Dh(e,t){return 0|e.charCodeAt(t)}function Gh(e,t,n){return e.slice(t,n)}function qh(e){return e.length}function Vh(e){return e.length}function Wh(e,t){return t.push(e),e}function Hh(e,t){return e.filter(function(e){return!Lh(e,t)})}var Yh=1,Zh=1,Kh=0,Jh=0,Qh=0,Xh="";function ep(e,t,n,r,o,s,a,i){return{value:e,root:t,parent:n,type:r,props:o,children:s,line:Yh,column:Zh,length:a,return:"",siblings:i}}function tp(e,t){return Mh(ep("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function np(e){for(;e.root;)e=tp(e.root,{children:[e]});Wh(e,e.siblings)}function rp(){return Qh=Jh>0?Dh(Xh,--Jh):0,Zh--,10===Qh&&(Zh=1,Yh--),Qh}function op(){return Qh=Jh<Kh?Dh(Xh,Jh++):0,Zh++,10===Qh&&(Zh=1,Yh++),Qh}function sp(){return Dh(Xh,Jh)}function ap(){return Jh}function ip(e,t){return Gh(Xh,e,t)}function cp(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 up(e){return Fh(ip(Jh-1,fp(91===e?e+2:40===e?e+1:e)))}function lp(e){for(;(Qh=sp())&&Qh<33;)op();return cp(e)>2||cp(Qh)>3?"":" "}function dp(e,t){for(;--t&&op()&&!(Qh<48||Qh>102||Qh>57&&Qh<65||Qh>70&&Qh<97););return ip(e,ap()+(t<6&&32==sp()&&32==op()))}function fp(e){for(;op();)switch(Qh){case e:return Jh;case 34:case 39:34!==e&&39!==e&&fp(Qh);break;case 40:41===e&&fp(e);break;case 92:op()}return Jh}function hp(e,t){for(;op()&&e+Qh!==57&&(e+Qh!==84||47!==sp()););return"/*"+ip(t,Jh-1)+"*"+zh(47===e?e:op())}function pp(e){for(;!cp(sp());)op();return ip(e,Jh)}function mp(e){return function(e){return Xh="",e}(gp("",null,null,null,[""],e=function(e){return Yh=Zh=1,Kh=qh(Xh=e),Jh=0,[]}(e),0,[0],e))}function gp(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=op()){case 40:if(108!=p&&58==Dh(P,d-1)){-1!=Uh(P+=jh(up(y),"&","&\f"),"&\f",Rh(u?i[u-1]:0))&&(b=-1);break}case 34:case 39:case 91:P+=up(y);break;case 9:case 10:case 13:case 32:P+=lp(p);break;case 92:P+=dp(ap()-1,7);continue;case 47:switch(sp()){case 42:case 47:Wh(yp(hp(op(),ap()),t,n,c),c);break;default:P+="/"}break;case 123*m:i[u++]=qh(P)*b;case 125*m:case 59:case 0:switch(y){case 0:case 125:g=0;case 59+l:-1==b&&(P=jh(P,/\f/g,"")),h>0&&qh(P)-d&&Wh(h>32?wp(P+";",r,n,d-1,c):wp(jh(P," ","")+";",r,n,d-2,c),c);break;case 59:P+=";";default:if(Wh(E=bp(P,t,n,u,l,o,i,w,v=[],x=[],d,s),s),123===y)if(0===l)gp(P,t,E,E,v,s,d,i,x);else switch(99===f&&110===Dh(P,3)?100:f){case 100:case 108:case 109:case 115:gp(e,E,E,r&&Wh(bp(e,E,E,0,0,o,i,w,o,v=[],d,x),x),o,x,d,i,r?v:x);break;default:gp(P,E,E,E,[""],x,0,i,x)}}u=l=h=0,m=b=1,w=P="",d=a;break;case 58:d=1+qh(P),h=p;default:if(m<1)if(123==y)--m;else if(125==y&&0==m++&&125==rp())continue;switch(P+=zh(y),y*m){case 38:b=l>0?1:(P+="\f",-1);break;case 44:i[u++]=(qh(P)-1)*b,b=1;break;case 64:45===sp()&&(P+=up(op())),f=sp(),l=d=qh(w=P+=pp(ap())),y++;break;case 45:45===p&&2==qh(P)&&(m=0)}}return s}function bp(e,t,n,r,o,s,a,i,c,u,l,d){for(var f=o-1,h=0===o?s:[""],p=Vh(h),m=0,g=0,b=0;m<r;++m)for(var y=0,w=Gh(e,f+1,f=Rh(g=a[m])),v=e;y<p;++y)(v=Fh(g>0?h[y]+" "+w:jh(w,/&\f/g,h[y])))&&(c[b++]=v);return ep(e,t,n,0===o?Ch:i,c,u,l,d)}function yp(e,t,n,r){return ep(e,t,n,Bh,zh(Qh),Gh(e,2,-2),0,r)}function wp(e,t,n,r,o){return ep(e,t,n,Oh,Gh(e,0,r),Gh(e,r+1,-1),r,o)}function vp(e,t,n){switch(function(e,t){return 45^Dh(e,0)?(((t<<2^Dh(e,0))<<2^Dh(e,1))<<2^Dh(e,2))<<2^Dh(e,3):0}(e,t)){case 5103:return $h+"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 $h+e+e;case 4789:return Th+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return $h+e+Th+e+Nh+e+e;case 5936:switch(Dh(e,t+11)){case 114:return $h+e+Nh+jh(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return $h+e+Nh+jh(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return $h+e+Nh+jh(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return $h+e+Nh+e+e;case 6165:return $h+e+Nh+"flex-"+e+e;case 5187:return $h+e+jh(e,/(\w+).+(:[^]+)/,$h+"box-$1$2"+Nh+"flex-$1$2")+e;case 5443:return $h+e+Nh+"flex-item-"+jh(e,/flex-|-self/g,"")+(Lh(e,/flex-|baseline/)?"":Nh+"grid-row-"+jh(e,/flex-|-self/g,""))+e;case 4675:return $h+e+Nh+"flex-line-pack"+jh(e,/align-content|flex-|-self/g,"")+e;case 5548:return $h+e+Nh+jh(e,"shrink","negative")+e;case 5292:return $h+e+Nh+jh(e,"basis","preferred-size")+e;case 6060:return $h+"box-"+jh(e,"-grow","")+$h+e+Nh+jh(e,"grow","positive")+e;case 4554:return $h+jh(e,/([^-])(transform)/g,"$1"+$h+"$2")+e;case 6187:return jh(jh(jh(e,/(zoom-|grab)/,$h+"$1"),/(image-set)/,$h+"$1"),e,"")+e;case 5495:case 3959:return jh(e,/(image-set\([^]*)/,$h+"$1$`$1");case 4968:return jh(jh(e,/(.+:)(flex-)?(.*)/,$h+"box-pack:$3"+Nh+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+$h+e+e;case 4200:if(!Lh(e,/flex-|baseline/))return Nh+"grid-column-align"+Gh(e,t)+e;break;case 2592:case 3360:return Nh+jh(e,"template-","")+e;case 4384:case 3616:return n&&n.some(function(e,n){return t=n,Lh(e.props,/grid-\w+-end/)})?~Uh(e+(n=n[t].value),"span",0)?e:Nh+jh(e,"-start","")+e+Nh+"grid-row-span:"+(~Uh(n,"span",0)?Lh(n,/\d+/):+Lh(n,/\d+/)-+Lh(e,/\d+/))+";":Nh+jh(e,"-start","")+e;case 4896:case 4128:return n&&n.some(function(e){return Lh(e.props,/grid-\w+-start/)})?e:Nh+jh(jh(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return jh(e,/(.+)-inline(.+)/,$h+"$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(qh(e)-1-t>6)switch(Dh(e,t+1)){case 109:if(45!==Dh(e,t+4))break;case 102:return jh(e,/(.+:)(.+)-([^]+)/,"$1"+$h+"$2-$3$1"+Th+(108==Dh(e,t+3)?"$3":"$2-$3"))+e;case 115:return~Uh(e,"stretch",0)?vp(jh(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return jh(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(t,n,r,o,s,a,i){return Nh+n+":"+r+i+(o?Nh+n+"-span:"+(s?a:+a-+r)+i:"")+e});case 4949:if(121===Dh(e,t+6))return jh(e,":",":"+$h)+e;break;case 6444:switch(Dh(e,45===Dh(e,14)?18:11)){case 120:return jh(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+$h+(45===Dh(e,14)?"inline-":"")+"box$3$1"+$h+"$2$3$1"+Nh+"$2box$3")+e;case 100:return jh(e,":",":"+Nh)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return jh(e,"scroll-","scroll-snap-")+e}return e}function xp(e,t){for(var n="",r=0;r<e.length;r++)n+=t(e[r],r,e,t)||"";return n}function Ep(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case Oh:return e.return=e.return||e.value;case Bh:return"";case _h:return e.return=e.value+"{"+xp(e.children,r)+"}";case Ch:if(!qh(e.value=e.props.join(",")))return""}return qh(n=xp(e.children,r))?e.return=e.value+"{"+n+"}":""}function Pp(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case Oh:return void(e.return=vp(e.value,e.length,n));case _h:return xp([tp(e,{value:jh(e.value,"@","@"+$h)})],r);case Ch:if(e.length)return function(e,t){return e.map(t).join("")}(n=e.props,function(t){switch(Lh(t,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":np(tp(e,{props:[jh(t,/:(read-\w+)/,":-moz-$1")]})),np(tp(e,{props:[t]})),Mh(e,{props:Hh(n,r)});break;case"::placeholder":np(tp(e,{props:[jh(t,/:(plac\w+)/,":"+$h+"input-$1")]})),np(tp(e,{props:[jh(t,/:(plac\w+)/,":-moz-$1")]})),np(tp(e,{props:[jh(t,/:(plac\w+)/,Nh+"input-$1")]})),np(tp(e,{props:[t]})),Mh(e,{props:Hh(n,r)})}return""})}}var kp={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},Ap="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Ip="active",Sp="data-styled-version",Np="6.1.19",Tp="/*!sc*/\n",$p="undefined"!=typeof window&&"undefined"!=typeof document,Bp=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),Cp=/invalid hook call/i,Op=new Set,_p=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];Cp.test(e)?(a=!1,Op.delete(r)):s.apply(void 0,kh([e],t,!1))},o.useRef(),a&&!Op.has(r)&&(console.warn(r),Op.add(r))}catch(e){Cp.test(e.message)&&Op.delete(r)}finally{console.error=s}}},Rp=Object.freeze([]),zp=Object.freeze({});var Mp=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"]),Fp=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Lp=/(^-|-$)/g;function jp(e){return e.replace(Fp,"-").replace(Lp,"")}var Up=/(a)(d)/gi,Dp=function(e){return String.fromCharCode(e+(e>25?39:97))};function Gp(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=Dp(t%52)+n;return(Dp(t%52)+n).replace(Up,"$1-$2")}var qp,Vp=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},Wp=function(e){return Vp(5381,e)};function Hp(e){return Gp(Wp(e)>>>0)}function Yp(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function Zp(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var Kp="function"==typeof Symbol&&Symbol.for,Jp=Kp?Symbol.for("react.memo"):60115,Qp=Kp?Symbol.for("react.forward_ref"):60112,Xp={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},em={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},tm={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},nm=((qp={})[Qp]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},qp[Jp]=tm,qp);function rm(e){return("type"in(t=e)&&t.type.$$typeof)===Jp?tm:"$$typeof"in e?nm[e.$$typeof]:Xp;var t}var om=Object.defineProperty,sm=Object.getOwnPropertyNames,am=Object.getOwnPropertySymbols,im=Object.getOwnPropertyDescriptor,cm=Object.getPrototypeOf,um=Object.prototype;function lm(e,t,n){if("string"!=typeof t){if(um){var r=cm(t);r&&r!==um&&lm(e,r,n)}var o=sm(t);am&&(o=o.concat(am(t)));for(var s=rm(e),a=rm(t),i=0;i<o.length;++i){var c=o[i];if(!(c in em||n&&n[c]||a&&c in a||s&&c in s)){var u=im(t,c);try{om(e,c,u)}catch(e){}}}}return e}function dm(e){return"function"==typeof e}function fm(e){return"object"==typeof e&&"styledComponentId"in e}function hm(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function pm(e,t){if(0===e.length)return"";for(var n=e[0],r=1;r<e.length;r++)n+=e[r];return n}function mm(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function gm(e,t,n){if(void 0===n&&(n=!1),!n&&!mm(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var r=0;r<t.length;r++)e[r]=gm(e[r],t[r]);else if(mm(t))for(var r in t)e[r]=gm(e[r],t[r]);return e}function bm(e,t){Object.defineProperty(e,"toString",{value:t})}var ym="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 wm(){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 vm(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(wm.apply(void 0,kh([ym[e]],t,!1)).trim())}var xm=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 vm(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(Tp);return t},e}(),Em=1<<30,Pm=new Map,km=new Map,Am=1,Im=function(e){if(Pm.has(e))return Pm.get(e);for(;km.has(Am);)Am++;var t=Am++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>Em))throw vm(16,"".concat(t));return Pm.set(e,t),km.set(t,e),t},Sm=function(e,t){Am=t+1,Pm.set(e,t),km.set(t,e)},Nm="style[".concat(Ap,"][").concat(Sp,'="').concat(Np,'"]'),Tm=new RegExp("^".concat(Ap,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),$m=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)},Bm=function(e,t){for(var n,r=(null!==(n=t.textContent)&&void 0!==n?n:"").split(Tp),o=[],s=0,a=r.length;s<a;s++){var i=r[s].trim();if(i){var c=i.match(Tm);if(c){var u=0|parseInt(c[1],10),l=c[2];0!==u&&(Sm(l,u),$m(e,l,c[3]),e.getTag().insertRules(u,o)),o.length=0}else o.push(i)}}},Cm=function(e){for(var t=document.querySelectorAll(Nm),n=0,r=t.length;n<r;n++){var o=t[n];o&&o.getAttribute(Ap)!==Ip&&(Bm(e,o),o.parentNode&&o.parentNode.removeChild(o))}};var Om=function(e){var t=document.head,n=e||t,r=document.createElement("style"),o=function(e){var t=Array.from(e.querySelectorAll("style[".concat(Ap,"]")));return t[t.length-1]}(n),s=void 0!==o?o.nextSibling:null;r.setAttribute(Ap,Ip),r.setAttribute(Sp,Np);var a="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null;return a&&r.setAttribute("nonce",a),n.insertBefore(r,s),r},_m=function(){function e(e){this.element=Om(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 vm(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}(),Rm=function(){function e(e){this.element=Om(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}(),zm=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}(),Mm=$p,Fm={isServer:!$p,useCSSOMInjection:!Bp},Lm=function(){function e(e,t,n){void 0===e&&(e=zp),void 0===t&&(t={});var r=this;this.options=Ph(Ph({},Fm),e),this.gs=t,this.names=new Map(n),this.server=!!e.isServer,!this.server&&$p&&Mm&&(Mm=!1,Cm(this)),bm(this,function(){return function(e){for(var t=e.getTag(),n=t.length,r="",o=function(n){var o=function(e){return km.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(Ap,".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(Tp)},s=0;s<n;s++)o(s);return r}(r)})}return e.registerId=function(e){return Im(e)},e.prototype.rehydrate=function(){!this.server&&$p&&Cm(this)},e.prototype.reconstructWithOptions=function(t,n){return void 0===n&&(n=!0),new e(Ph(Ph({},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 zm(n):t?new _m(n):new Rm(n)}(this.options),new xm(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(Im(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(Im(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(Im(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e}(),jm=/&/g,Um=/^\s*\/\/.*$/gm;function Dm(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=Dm(e.children,t)),e})}var Gm=new Lm,qm=function(){var e,t,n,r=zp,o=r.options,s=void 0===o?zp:o,a=r.plugins,i=void 0===a?Rp: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===Ch&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(jm,t).replace(n,c))}),s.prefix&&u.push(Pp),u.push(Ep);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(Um,""),l=mp(a||o?"".concat(a," ").concat(o," { ").concat(c," }"):c);s.namespace&&(l=Dm(l,s.namespace));var d,f=[];return xp(l,function(e){var t=Vh(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||vm(15),Vp(e,t.name)},5381).toString():"",l}(),Vm=v.default.createContext({shouldForwardProp:void 0,styleSheet:Gm,stylis:qm});function Wm(){return o.useContext(Vm)}Vm.Consumer,v.default.createContext(void 0);var Hm=function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=qm);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,bm(this,function(){throw vm(12,String(n.name))})}return e.prototype.getName=function(e){return void 0===e&&(e=qm),this.name+e.hash},e}(),Ym=function(e){return e>="A"&&e<="Z"};function Zm(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(1===n&&"-"===r&&"-"===e[0])return e;Ym(r)?t+="-"+r.toLowerCase():t+=r}return t.startsWith("ms-")?"-"+t:t}var Km=function(e){return null==e||!1===e||""===e},Jm=function(e){var t,n,r=[];for(var o in e){var s=e[o];e.hasOwnProperty(o)&&!Km(s)&&(Array.isArray(s)&&s.isCss||dm(s)?r.push("".concat(Zm(o),":"),s,";"):mm(s)?r.push.apply(r,kh(kh(["".concat(o," {")],Jm(s),!1),["}"],!1)):r.push("".concat(Zm(o),": ").concat((t=o,null==(n=s)||"boolean"==typeof n||""===n?"":"number"!=typeof n||0===n||t in kp||t.startsWith("--")?String(n).trim():"".concat(n,"px")),";")))}return r};function Qm(e,t,n,r){if(Km(e))return[];if(fm(e))return[".".concat(e.styledComponentId)];if(dm(e)){if(!dm(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 Hm||mm(o)||null===o||console.error("".concat(Yp(e)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Qm(o,t,n,r)}var s;return e instanceof Hm?n?(e.inject(n,r),[e.getName(r)]):[e]:mm(e)?Jm(e):Array.isArray(e)?Array.prototype.concat.apply(Rp,e.map(function(e){return Qm(e,t,n,r)})):[e.toString()]}var Xm=Wp(Np),eg=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(dm(n)&&!fm(n))return!1}return!0}(e),this.componentId=t,this.baseHash=Vp(Xm,t),this.baseStyle=n,Lm.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=hm(r,this.staticRulesId);else{var o=pm(Qm(this.rules,e,t,n)),s=Gp(Vp(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=hm(r,s),this.staticRulesId=s}else{for(var i=Vp(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=Vp(i,l));else if(l){var d=pm(Qm(l,e,t,n));i=Vp(i,d+u),c+=d}}if(c){var f=Gp(i>>>0);t.hasNameForId(this.componentId,f)||t.insertRules(this.componentId,f,n(c,".".concat(f),void 0,this.componentId)),r=hm(r,f)}}return r},e}(),tg=v.default.createContext(void 0);tg.Consumer;var ng={},rg=new Set;function og(e,t,n){var r=fm(e),s=e,a=!Zp(e),i=t.attrs,c=void 0===i?Rp:i,u=t.componentId,l=void 0===u?function(e,t){var n="string"!=typeof e?"sc":jp(e);ng[n]=(ng[n]||0)+1;var r="".concat(n,"-").concat(Hp(Np+n+ng[n]));return t?"".concat(t,"-").concat(r):r}(t.displayName,t.parentComponentId):u,d=t.displayName,f=void 0===d?function(e){return Zp(e)?"styled.".concat(e):"Styled(".concat(Yp(e),")")}(e):d,h=t.displayName&&t.componentId?"".concat(jp(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 b=t.shouldForwardProp;m=function(e,t){return g(e,t)&&b(e,t)}}else m=g}var y=new eg(n,h,r?s.componentStyle:void 0);function w(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=v.default.useContext(tg),d=Wm(),f=e.shouldForwardProp||d.shouldForwardProp;"production"!==process.env.NODE_ENV&&o.useDebugValue(c);var h=function(e,t,n){return void 0===n&&(n=zp),e.theme!==n.theme&&e.theme||t||n.theme}(t,l,a)||zp,p=function(e,t,n){for(var r,o=Ph(Ph({},t),{className:void 0,theme:n}),s=0;s<e.length;s+=1){var a=dm(r=e[s])?r(o):r;for(var i in a)o[i]="className"===i?hm(o[i],a[i]):"style"===i?Ph(Ph({},o[i]),a[i]):a[i]}return t.className&&(o.className=hm(o.className,t.className)),o}(r,t,h),m=p.as||u,g={};for(var b in p)void 0===p[b]||"$"===b[0]||"as"===b||"theme"===b&&p.theme===h||("forwardedAs"===b?g.as=p.forwardedAs:f&&!f(b,m)||(g[b]=p[b],f||"development"!==process.env.NODE_ENV||Sh(b)||rg.has(b)||!Mp.has(m)||(rg.add(b),console.warn('styled-components: it looks like an unknown prop "'.concat(b,'" 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 y=function(e,t){var n=Wm(),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(y);var w=hm(i,c);return y&&(w+=" "+y),p.className&&(w+=" "+p.className),g[Zp(m)&&!Mp.has(m)?"class":"className"]=w,n&&(g.ref=n),o.createElement(m,g)}(x,e,t)}w.displayName=f;var x=v.default.forwardRef(w);return x.attrs=p,x.componentStyle=y,x.displayName=f,x.shouldForwardProp=m,x.foldedComponentIds=r?hm(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++)gm(e,o[r],!0);return e}({},s.defaultProps,e):e}}),"production"!==process.env.NODE_ENV&&(_p(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)),bm(x,function(){return".".concat(x.styledComponentId)}),a&&lm(x,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),x}function sg(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 ag=function(e){return Object.assign(e,{isCss:!0})};function ig(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(dm(e)||mm(e))return ag(Qm(sg(Rp,kh([e],t,!0))));var r=e;return 0===t.length&&1===r.length&&"string"==typeof r[0]?Qm(r):ag(Qm(sg(r,t)))}function cg(e,t,n){if(void 0===n&&(n=zp),!t)throw vm(1,t);var r=function(r){for(var o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];return e(t,n,ig.apply(void 0,kh([r],o,!1)))};return r.attrs=function(r){return cg(e,t,Ph(Ph({},n),{attrs:Array.prototype.concat(n.attrs,r).filter(Boolean)}))},r.withConfig=function(r){return cg(e,t,Ph(Ph({},n),r))},r}var ug=function(e){return cg(og,e)},lg=ug;Mp.forEach(function(e){lg[e]=ug(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 dg="__sc-".concat(Ap,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[dg]||(window[dg]=0),1===window[dg]&&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[dg]+=1);const fg={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"}},hg=(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=pm(ig.apply(void 0,kh([e],t,!1))),o=Hp(r);return new Hm(o,r)})`
13
13
  from {
14
14
  transform: rotate(0deg);
15
15
  }
16
16
  to {
17
17
  transform: rotate(360deg);
18
18
  }
19
- `,mg=dg.div`
19
+ `,pg=lg.div`
20
20
  position: fixed;
21
21
  inset: 0;
22
- background-color: ${hg.colors.background.overlay};
22
+ background-color: ${fg.colors.background.overlay};
23
23
  display: flex;
24
24
  align-items: center;
25
25
  justify-content: center;
26
26
  z-index: 50;
27
- `,gg=dg.div`
28
- background-color: ${hg.colors.background.main};
29
- border-radius: ${hg.borderRadius.md};
30
- box-shadow: ${hg.shadows.xl};
31
- padding: ${hg.spacing.xl};
27
+ `,mg=lg.div`
28
+ background-color: ${fg.colors.background.main};
29
+ border-radius: ${fg.borderRadius.md};
30
+ box-shadow: ${fg.shadows.xl};
31
+ padding: ${fg.spacing.xl};
32
32
  width: 100%;
33
33
  max-width: 28rem;
34
- `,bg=dg.div`
34
+ `,gg=lg.div`
35
35
  display: flex;
36
36
  justify-content: space-between;
37
37
  align-items: center;
38
- margin-bottom: ${hg.spacing.lg};
39
- `,yg=dg.h2`
40
- font-size: ${hg.typography.fontSizes["2xl"]};
41
- font-weight: ${hg.typography.fontWeights.bold};
42
- color: ${hg.colors.text.primary};
38
+ margin-bottom: ${fg.spacing.lg};
39
+ `,bg=lg.h2`
40
+ font-size: ${fg.typography.fontSizes["2xl"]};
41
+ font-weight: ${fg.typography.fontWeights.bold};
42
+ color: ${fg.colors.text.primary};
43
43
  text-transform: uppercase;
44
44
  letter-spacing: 1px;
45
45
  margin: 0;
46
- `,wg=dg.button`
46
+ `,yg=lg.button`
47
47
  background: none;
48
48
  border: none;
49
- color: ${hg.colors.text.tertiary};
49
+ color: ${fg.colors.text.tertiary};
50
50
  cursor: pointer;
51
51
 
52
52
  &:hover {
53
- color: ${hg.colors.text.primary};
53
+ color: ${fg.colors.text.primary};
54
54
  }
55
- `,vg=dg.svg`
55
+ `,wg=lg.svg`
56
56
  width: 1.5rem;
57
57
  height: 1.5rem;
58
- `,xg=dg.div`
58
+ `,vg=lg.div`
59
59
  display: flex;
60
60
  flex-direction: column;
61
61
  align-items: center;
62
62
  justify-content: center;
63
- gap: ${hg.spacing.lg};
64
- padding: ${hg.spacing.xl} 0;
65
- `,Eg=dg.div`
66
- animation: ${pg} 1s linear infinite;
63
+ gap: ${fg.spacing.lg};
64
+ padding: ${fg.spacing.xl} 0;
65
+ `,xg=lg.div`
66
+ animation: ${hg} 1s linear infinite;
67
67
  display: flex;
68
68
  align-items: center;
69
69
  justify-content: center;
@@ -72,106 +72,106 @@ const Yu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
72
72
  width: 2rem;
73
73
  height: 2rem;
74
74
  }
75
- `,Pg=dg.p`
76
- font-size: ${hg.typography.fontSizes.md};
77
- color: ${hg.colors.text.secondary};
75
+ `,Eg=lg.p`
76
+ font-size: ${fg.typography.fontSizes.md};
77
+ color: ${fg.colors.text.secondary};
78
78
  text-align: center;
79
- `,kg=dg.div`
79
+ `,Pg=lg.div`
80
80
  display: flex;
81
81
  flex-direction: column;
82
- gap: ${hg.spacing.md};
83
- `,Ag=dg.input.attrs({className:"superstack-wallet-input"})`
82
+ gap: ${fg.spacing.md};
83
+ `,kg=lg.input.attrs({className:"superstack-wallet-input"})`
84
84
  width: 100%;
85
- padding: ${hg.spacing.md};
86
- border: 1px solid ${hg.colors.border.light};
87
- border-radius: ${hg.borderRadius.sm};
88
- font-size: ${hg.typography.fontSizes.md};
89
- font-family: ${hg.typography.fontFamily};
90
- transition: border-color ${hg.transitions.normal};
91
- color: ${hg.colors.text.primary};
92
- background-color: ${hg.colors.background.main};
93
- margin-bottom: ${hg.spacing.md};
85
+ padding: ${fg.spacing.md};
86
+ border: 1px solid ${fg.colors.border.light};
87
+ border-radius: ${fg.borderRadius.sm};
88
+ font-size: ${fg.typography.fontSizes.md};
89
+ font-family: ${fg.typography.fontFamily};
90
+ transition: border-color ${fg.transitions.normal};
91
+ color: ${fg.colors.text.primary};
92
+ background-color: ${fg.colors.background.main};
93
+ margin-bottom: ${fg.spacing.md};
94
94
 
95
95
  &:focus {
96
96
  outline: none;
97
- border-color: ${hg.colors.border.dark};
97
+ border-color: ${fg.colors.border.dark};
98
98
  }
99
99
 
100
100
  &:disabled {
101
- background-color: ${hg.colors.background.secondary};
101
+ background-color: ${fg.colors.background.secondary};
102
102
  cursor: not-allowed;
103
103
  }
104
104
 
105
105
  &::placeholder {
106
- color: ${hg.colors.text.tertiary};
106
+ color: ${fg.colors.text.tertiary};
107
107
  opacity: 0.8;
108
108
  }
109
- `,Ig=dg.button`
109
+ `,Ag=lg.button`
110
110
  width: 100%;
111
- padding: ${hg.spacing.md};
112
- background-color: ${hg.colors.button.primary.background};
113
- color: ${hg.colors.button.primary.text};
114
- border-radius: ${hg.borderRadius.sm};
115
- font-weight: ${hg.typography.fontWeights.medium};
111
+ padding: ${fg.spacing.md};
112
+ background-color: ${fg.colors.button.primary.background};
113
+ color: ${fg.colors.button.primary.text};
114
+ border-radius: ${fg.borderRadius.sm};
115
+ font-weight: ${fg.typography.fontWeights.medium};
116
116
  text-transform: uppercase;
117
117
  letter-spacing: 1px;
118
- transition: background-color ${hg.transitions.normal};
119
- font-size: ${hg.typography.fontSizes.md};
118
+ transition: background-color ${fg.transitions.normal};
119
+ font-size: ${fg.typography.fontSizes.md};
120
120
  border: none;
121
121
  cursor: pointer;
122
122
 
123
123
  &:hover {
124
- background-color: ${hg.colors.button.primary.hover};
124
+ background-color: ${fg.colors.button.primary.hover};
125
125
  }
126
126
 
127
127
  &:disabled {
128
- background-color: ${hg.colors.button.primary.disabled};
128
+ background-color: ${fg.colors.button.primary.disabled};
129
129
  cursor: not-allowed;
130
130
  }
131
- `,Ng=dg.div`
131
+ `,Ig=lg.div`
132
132
  display: flex;
133
133
  align-items: center;
134
- margin: ${hg.spacing.lg} 0;
135
- `,Sg=dg.div`
134
+ margin: ${fg.spacing.lg} 0;
135
+ `,Sg=lg.div`
136
136
  flex-grow: 1;
137
137
  height: 1px;
138
- background-color: ${hg.colors.border.light};
139
- `,Tg=dg.span`
140
- padding: 0 ${hg.spacing.md};
141
- font-size: ${hg.typography.fontSizes.sm};
142
- color: ${hg.colors.text.tertiary};
138
+ background-color: ${fg.colors.border.light};
139
+ `,Ng=lg.span`
140
+ padding: 0 ${fg.spacing.md};
141
+ font-size: ${fg.typography.fontSizes.sm};
142
+ color: ${fg.colors.text.tertiary};
143
143
  text-transform: uppercase;
144
144
  letter-spacing: 0.5px;
145
- `;dg.div`
145
+ `;lg.div`
146
146
  height: 1px;
147
- background-color: ${hg.colors.border.light};
147
+ background-color: ${fg.colors.border.light};
148
148
  width: 100%;
149
- margin: ${hg.spacing.lg} 0;
150
- `;const Bg=dg.div`
149
+ margin: ${fg.spacing.lg} 0;
150
+ `;const Tg=lg.div`
151
151
  display: flex;
152
152
  align-items: center;
153
153
  /* grid-template-columns: repeat(2, 1fr); */
154
- gap: ${hg.spacing.md};
155
- `,Cg=dg.button`
154
+ gap: ${fg.spacing.md};
155
+ `,$g=lg.button`
156
156
  display: flex;
157
157
  align-items: center;
158
158
  justify-content: center;
159
- padding: ${hg.spacing.md};
160
- border: 1px solid ${hg.colors.border.light};
161
- border-radius: ${hg.borderRadius.sm};
162
- background-color: ${hg.colors.background.main};
163
- transition: background-color ${hg.transitions.normal};
164
- color: ${hg.colors.text.primary};
165
- font-weight: ${hg.typography.fontWeights.medium};
166
- font-size: ${hg.typography.fontSizes.md};
159
+ padding: ${fg.spacing.md};
160
+ border: 1px solid ${fg.colors.border.light};
161
+ border-radius: ${fg.borderRadius.sm};
162
+ background-color: ${fg.colors.background.main};
163
+ transition: background-color ${fg.transitions.normal};
164
+ color: ${fg.colors.text.primary};
165
+ font-weight: ${fg.typography.fontWeights.medium};
166
+ font-size: ${fg.typography.fontSizes.md};
167
167
  min-width: 120px;
168
168
  flex: 1;
169
169
 
170
170
  &:hover {
171
- background-color: ${hg.colors.background.secondary};
171
+ background-color: ${fg.colors.background.secondary};
172
172
  }
173
- `,$g=dg.div`
174
- margin-right: ${hg.spacing.sm};
173
+ `,Bg=lg.div`
174
+ margin-right: ${fg.spacing.sm};
175
175
  display: flex;
176
176
  align-items: center;
177
177
  justify-content: center;
@@ -181,24 +181,24 @@ const Yu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
181
181
  height: 20px;
182
182
  display: block;
183
183
  }
184
- `,Og=dg.div`
184
+ `,Cg=lg.div`
185
185
  display: flex;
186
186
  flex-direction: column;
187
- gap: ${hg.spacing.lg};
188
- `,_g=dg.h3`
189
- font-size: ${hg.typography.fontSizes.xl};
190
- font-weight: ${hg.typography.fontWeights.semibold};
191
- color: ${hg.colors.text.primary};
192
- margin-bottom: ${hg.spacing.sm};
193
- `,Rg=dg.p`
194
- font-size: ${hg.typography.fontSizes.md};
195
- color: ${hg.colors.text.secondary};
196
- margin-bottom: ${hg.spacing.lg};
197
- `,zg=dg.div`
187
+ gap: ${fg.spacing.lg};
188
+ `,Og=lg.h3`
189
+ font-size: ${fg.typography.fontSizes.xl};
190
+ font-weight: ${fg.typography.fontWeights.semibold};
191
+ color: ${fg.colors.text.primary};
192
+ margin-bottom: ${fg.spacing.sm};
193
+ `,_g=lg.p`
194
+ font-size: ${fg.typography.fontSizes.md};
195
+ color: ${fg.colors.text.secondary};
196
+ margin-bottom: ${fg.spacing.lg};
197
+ `,Rg=lg.div`
198
198
  display: flex;
199
- gap: ${hg.spacing.sm};
199
+ gap: ${fg.spacing.sm};
200
200
  justify-content: center;
201
- margin-bottom: ${hg.spacing.lg};
201
+ margin-bottom: ${fg.spacing.lg};
202
202
  position: relative;
203
203
 
204
204
  &::after {
@@ -208,30 +208,30 @@ const Yu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
208
208
  left: 0;
209
209
  width: 100%;
210
210
  text-align: center;
211
- font-size: ${hg.typography.fontSizes.xs};
212
- color: ${hg.colors.text.tertiary};
211
+ font-size: ${fg.typography.fontSizes.xs};
212
+ color: ${fg.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
- `,Mg=dg.div`
219
+ `,zg=lg.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
- `,Lg=dg.input`
226
+ `,Mg=lg.input`
227
227
  width: 100%;
228
228
  height: 100%;
229
229
  text-align: center;
230
- font-size: ${hg.typography.fontSizes.xl};
231
- border: 1px solid ${hg.colors.border.light};
232
- border-radius: ${hg.borderRadius.sm};
233
- transition: all ${hg.transitions.normal};
234
- font-family: ${hg.typography.fontFamily};
230
+ font-size: ${fg.typography.fontSizes.xl};
231
+ border: 1px solid ${fg.colors.border.light};
232
+ border-radius: ${fg.borderRadius.sm};
233
+ transition: all ${fg.transitions.normal};
234
+ font-family: ${fg.typography.fontFamily};
235
235
  padding: 0;
236
236
  box-sizing: border-box;
237
237
 
@@ -252,46 +252,46 @@ const Yu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
252
252
  /* Remove default box-shadow on iOS */
253
253
  &:focus {
254
254
  outline: none;
255
- border-color: ${hg.colors.border.dark};
256
- box-shadow: 0 0 0 1px ${hg.colors.border.dark};
255
+ border-color: ${fg.colors.border.dark};
256
+ box-shadow: 0 0 0 1px ${fg.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
- `,Fg=dg.button`
263
+ `,Fg=lg.button`
264
264
  background: none;
265
265
  border: none;
266
- color: ${hg.colors.text.secondary};
267
- font-size: ${hg.typography.fontSizes.sm};
266
+ color: ${fg.colors.text.secondary};
267
+ font-size: ${fg.typography.fontSizes.sm};
268
268
  text-align: center;
269
- margin-top: ${hg.spacing.md};
270
- margin-bottom: ${hg.spacing.sm};
271
- padding: ${hg.spacing.sm} ${hg.spacing.md};
269
+ margin-top: ${fg.spacing.md};
270
+ margin-bottom: ${fg.spacing.sm};
271
+ padding: ${fg.spacing.sm} ${fg.spacing.md};
272
272
  text-transform: uppercase;
273
273
  letter-spacing: 0.5px;
274
274
  width: 100%;
275
275
  cursor: pointer;
276
- transition: color ${hg.transitions.normal};
276
+ transition: color ${fg.transitions.normal};
277
277
  display: flex;
278
278
  align-items: center;
279
279
  justify-content: center;
280
280
 
281
281
  &:hover {
282
- color: ${hg.colors.text.primary};
282
+ color: ${fg.colors.text.primary};
283
283
  text-decoration: underline;
284
284
  }
285
285
 
286
286
  &:before {
287
287
  content: "←";
288
- margin-right: ${hg.spacing.sm};
289
- font-size: ${hg.typography.fontSizes.md};
288
+ margin-right: ${fg.spacing.sm};
289
+ font-size: ${fg.typography.fontSizes.md};
290
290
  }
291
- `,Ug=dg.p`
292
- font-size: ${hg.typography.fontSizes.sm};
293
- color: ${hg.colors.text.tertiary};
291
+ `,Lg=lg.p`
292
+ font-size: ${fg.typography.fontSizes.sm};
293
+ color: ${fg.colors.text.tertiary};
294
294
  text-align: center;
295
- margin-top: ${hg.spacing.lg};
296
- `;async function jg(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 Dg(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 Gg=()=>{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: ${hg.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: ${hg.typography.fontWeights.semibold};\n line-height: 1.2;\n margin-bottom: ${hg.spacing.md};\n }\n \n .superstack-wallet-container p {\n font-family: 'Montserrat', sans-serif;\n margin-bottom: ${hg.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: ${hg.colors.background.main};\n border-radius: ${hg.borderRadius.md};\n padding: ${hg.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 Wg=Object.freeze({__proto__:null,injectStyles:Gg,theme:hg});const qg={isAuthenticated:!1,isConnecting:!1,isInitialized:!1,walletInfo:null,wallet:null,session:null,error:null,enableEmail:!0,enablePhone:!1,enableGoogle:!0,enableTwitter:!1,enablePhantom:!0},Vg=o.createContext({});function Hg(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{...qg,isInitialized:!0};default:return e}}function Yg(){const e=o.useContext(Vg);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}function Kg({client:e,isOpen:t,onClose:n,onLogin:a,isLoading:s=!1}){const[i,c]=o.useState(""),[l,u]=o.useState(""),[d,f]=o.useState(!1),[h,p]=o.useState(!1),[m,g]=o.useState(["","","","","",""]),[b,y]=o.useState(!1),[w,v]=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=hg.typography.fontSizes.xl)}})},[m,k]),{email:i,setEmail:c,emailSent:h,setEmailSent:p,sendingCode:b,setVerificationCode:g,verificationCode:m,verifyingCode:w,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 a=n.findIndex(e=>""===e);-1!==a?null===(r=k[a].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 a=o.findIndex(e=>""===e);-1!==a?null===(t=k[a].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");y(!0),await e.sendEmailVerificationCode(t),p(!0)}catch(e){alert("Failed to send verification code"),console.error("Failed to send verification code",e)}finally{y(!1)}},handleCodeSubmit:async(t=m.join(""),r=i)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");v(!0);const o=await e.verifyEmailVerificationCode({email:r,code:t});o&&(null==a||a(o),null==n||n())}catch(e){alert("Failed to verify code"),console.error("Failed to verify code",e)}finally{v(!1)}},handlePhoneCodeSubmit:async(t=m.join(""),r=l)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");v(!0);const o=await e.verifyPhoneVerificationCode({phone:r,code:t});o&&(null==a||a(o),null==n||n())}catch(e){alert("Failed to verify code"),console.error("Failed to verify code",e)}finally{v(!1)}},handleSendPhoneVerificationCode:async(t=l)=>{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{y(!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==a||a(o),null==n||n())}catch(e){alert("Failed to login with challenge"),console.error("Failed to login with challenge",e)}finally{v(!1)}},phone:l,setPhone:u,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:a}=await jg(t),s=new URL(window.location.href);s.searchParams.forEach((e,t)=>{s.searchParams.delete(t)});const i=s.toString(),c=await e.oauthInit({provider:t,redirect_uri:i,state:n,code_challenge:a}),{url:l,client_id:u}=c;if(!l&&!u)throw console.error("OAuth init failed."),new Error("init failed");const d={client_id:u,redirect_uri:l,state:n,code_challenge:a},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?${x.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?${x.stringify(t,{encode:!1})}`}(d);window.location.href=f},handlePhantomLogin:async()=>{try{P(!0);const t=await e.connectPhantom();t&&(null==a||a(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:a,isLoading:s}}const Zg=({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o=!1,enableEmail:s=!0,enablePhone:i=!1,enableGoogle:c=!0,enableTwitter:l=!1,enablePhantom:u=!0})=>{const{email:d,setEmail:f,emailSent:h,sendingCode:p,setEmailSent:m,verifyingCode:g,verificationCode:b,connectingPhantom:y,inputRefs:w,handleCodeChange:x,handleKeyDown:E,handleContainerPaste:P,handleSendVerificationCode:k,handleCodeSubmit:A,onOauthLogin:I,handlePhantomLogin:N}=Kg({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o});return t?v.default.createElement(mg,null,v.default.createElement(gg,null,v.default.createElement(bg,null,v.default.createElement(yg,null,"Connect Wallet"),v.default.createElement(wg,{onClick:n},v.default.createElement(vg,{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},v.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))),o?v.default.createElement(xg,null,v.default.createElement(Eg,null,v.default.createElement(a.Loader2,{size:24})),v.default.createElement(Pg,null,"Loading...")):v.default.createElement(v.default.Fragment,null,h?v.default.createElement(Og,null,v.default.createElement("div",null,v.default.createElement(_g,null,"Enter Verification Code"),v.default.createElement(Rg,null,"We sent a verification code to ",d)),v.default.createElement(zg,{onPaste:P},b.map((e,t)=>v.default.createElement(Mg,{key:t},v.default.createElement(Lg,{ref:w[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))}})))),v.default.createElement(Ig,{onClick:()=>A(),disabled:6!==b.join("").length||g},g?"Verifying...":"Verify Code"),v.default.createElement(Fg,{onClick:()=>m(!1)},"Back to Email")):v.default.createElement(kg,null,s&&v.default.createElement(kg,null,v.default.createElement(Ag,{type:"email",value:d,onChange:e=>f(e.target.value),placeholder:"Enter your email",disabled:p}),v.default.createElement(Ig,{onClick:()=>k(),disabled:!d||p},p?"Sending...":"Send Verification Code")),(c||l||u)&&s&&v.default.createElement(Ng,null,v.default.createElement(Sg,null),v.default.createElement(Tg,null,"Or continue with"),v.default.createElement(Sg,null)),(c||l||u)&&v.default.createElement(v.default.Fragment,null,v.default.createElement(Bg,null,c&&v.default.createElement(Cg,{onClick:()=>I("google")},v.default.createElement($g,null,v.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/google/google-original.svg",alt:"Google",width:20,height:20})),"Google"),l&&v.default.createElement(Cg,{onClick:()=>I("twitter")},v.default.createElement($g,null,v.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/twitter/twitter-original.svg",alt:"Twitter",width:20,height:20})),"X")),u&&v.default.createElement(Cg,{onClick:N,disabled:y},v.default.createElement($g,null,v.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})),y?"Connecting...":"Phantom")),!s&&!i&&!c&&!l&&!u&&v.default.createElement("div",{style:{textAlign:"center",padding:"20px",color:"#666"}},"No login methods are currently enabled."))),v.default.createElement(Ug,null,"By connecting your wallet, you agree to our Terms of Service and Privacy Policy"))):null};class Jg{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:a=!1,enableGoogle:s=!0,enableTwitter:i=!1,enablePhantom:c=!0}){return new Promise((l,u)=>{try{if("undefined"==typeof window)return void l();import("react-dom/client").then(({createRoot:u})=>{if(this.container=this.createContainer(),!this.container)return void l();this.root=u(this.container);const d=()=>{this.hideModal(),null==n||n()},f=e=>{this.hideModal(),null==r||r(e)};this.root&&this.root.render(v.default.createElement(Zg,{client:e,isOpen:!0,onClose:d,isLoading:t,onLogin:f,enableEmail:o,enablePhone:a,enableGoogle:s,enableTwitter:i,enablePhantom:c})),l()}).catch(e=>{console.error("Error importing createRoot:",e),u(e)})}catch(e){console.error("Error showing modal:",e),u(e)}})}hideModal(e){this.root&&(this.root.unmount(),this.container&&this.container.parentNode&&(document.body.removeChild(this.container),this.container=null))}}const Qg={isAuthenticated:!1,isConnecting:!1,isInitialized:!1,walletInfo:null,wallet:null,session:null,error:null,enableEmail:!0,enablePhone:!1,enableGoogle:!0,enableTwitter:!1,enablePhantom:!0},Xg=o.createContext({});function eb(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{...Qg,isInitialized:!0};default:return e}}function tb(){const e=o.useContext(Xg);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}"undefined"!=typeof window&&Promise.resolve().then(function(){return Wg}).then(({injectStyles:e})=>{e()}),exports.ACCESS_TOKEN_KEY=I,exports.BACKUP_WALLET_INFO=S,exports.BACKUP_WALLET_TYPE_KEY=A,exports.STORAGE_STATE_KEY=P,exports.SWITCHED_ACCOUNT_ADDRESS=N,exports.Storage=T,exports.WALLET_TYPE_KEY=k,exports.WalletClient=Ph,exports.WalletProvider=function({children:e,config:t}){var n,r,a,s,i,c;const l=o.useRef(null);l.current||(l.current=new Ph(t));const u=l.current,d=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[f,h]=o.useReducer(eb,{...Qg,enableEmail:null===(r=t.enableEmail)||void 0===r||r,enablePhone:null!==(a=t.enablePhone)&&void 0!==a&&a,enableGoogle:null===(s=t.enableGoogle)||void 0===s||s,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 Jg),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 u.reconnect();e&&(h({type:"SET_WALLET_INFO",payload:e}),h({type:"SET_WALLET",payload:u}))}catch(e){console.error("Auto reconnect failed:",e)}finally{h({type:"SET_INITIALIZED",payload:!0})}}}()},[u]),o.useEffect(()=>{const e=async()=>{try{if(w.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=Dg(t);if(!e)throw new Error("No code verifier found");const{codeVerifier:o,codeChallenge:a}=e;let s;if("twitter"===t)s="TwitterOAuth";else{if("google"!==t)throw new Error("Unsupported provider");s="GoogleOAuth"}g().showLoginModal({client:u,isLoading:!0,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom});const i=await u.oauthLogin(s,{state:n,code:r,code_verifier:o});if(i){h({type:"SET_WALLET_INFO",payload:i}),h({type:"SET_WALLET",payload:u});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 b=o.useCallback(async()=>{try{h({type:"SET_CONNECTING",payload:!0});g().showLoginModal({client:u,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:u})}})}catch(e){h({type:"SET_ERROR",payload:e instanceof Error?e.message:"Failed to connect"}),h({type:"SET_CONNECTING",payload:!1})}},[u]),y=o.useCallback(async()=>{await u.logout(),h({type:"RESET"})},[u]);o.useEffect(()=>{var e;"phantom"===T.getWalletType()&&u.getPhantomAdapter()&&(null===(e=u.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{y()}))},[u]);const w={...f,connect:b,disconnect:y};return v.default.createElement(Xg.Provider,{value:w},e)},exports.WalletProviderBackup=function({children:e,config:t}){var n,r,a,s,i,c;const l=o.useRef(null);l.current||(l.current=new Ph(t));const u=l.current,d=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[f,h]=o.useReducer(Hg,{...qg,enableEmail:null===(r=t.enableEmail)||void 0===r||r,enablePhone:null!==(a=t.enablePhone)&&void 0!==a&&a,enableGoogle:null===(s=t.enableGoogle)||void 0===s||s,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 Jg),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 u.reconnect(!0);e&&(h({type:"SET_WALLET_INFO_BACKUP",payload:e}),h({type:"SET_WALLET_BACKUP",payload:u}))}catch(e){console.error("Auto reconnect failed:",e)}finally{h({type:"SET_INITIALIZED_BACKUP",payload:!0})}}}()},[u]),o.useEffect(()=>{const e=async()=>{try{if(w.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=Dg(t);if(!e)throw new Error("No code verifier found");const{codeVerifier:o,codeChallenge:a}=e;let s;if("twitter"===t)s="TwitterOAuth";else{if("google"!==t)throw new Error("Unsupported provider");s="GoogleOAuth"}g().showLoginModal({isBackup:!0,client:u,isLoading:!0,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom});const i=await u.oauthLogin(s,{state:n,code:r,code_verifier:o});if(i){h({type:"SET_WALLET_INFO_BACKUP",payload:i}),h({type:"SET_WALLET_BACKUP",payload:u});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 b=o.useCallback(async()=>{try{h({type:"SET_CONNECTING_BACKUP",payload:!0});g().showLoginModal({isBackup:!0,client:u,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:u}),T.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})}},[u]),y=o.useCallback(async()=>{await u.logout(!0),h({type:"RESET_BACKUP"})},[u]);o.useEffect(()=>{var e;"phantom_backup"===T.getBackupWalletType()&&u.getPhantomAdapter()&&(null===(e=u.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{y()}))},[u]);const w={...f,connect:b,disconnect:y};return v.default.createElement(Vg.Provider,{value:w},e)},exports.injectStyles=Gg,exports.isVersionedTransaction=E,exports.theme=hg,exports.useActiveWallet=function(){const{wallet:e}=tb();return{wallet:e}},exports.useCoinbaseOnramp=function(){const{wallet:e}=tb(),t=null==e?void 0:e.solanaAddress,n=null==e?void 0:e.ethereumAddress;return{getCoinbaseOnrampUrl:async(r,o="solana",a)=>{if(!e||!t||!n)throw new Error("Wallet not found");const s="solana"===o?t:n;return Pf({sessionToken:await(null==e?void 0:e.fetchCoinbaseToken(s,o)),presetCryptoAmount:Number(r),redirectUrl:a||window.location.href})}}},exports.useConnect=function(){const{connect:e,disconnect:t,isConnecting:n}=tb();return{connect:e,disconnect:t,isConnecting:n}},exports.useLoginModal=Kg,exports.useWallet=tb,exports.useWalletBackup=Yg,exports.useWalletBackupStatus=function(){const{error:e,session:t,isInitialized:n,wallet:r}=Yg();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}=tb();return{isAuthenticated:null!==r,authenticated:null!==r,error:e,session:t,isInitialized:n,ready:n}};
295
+ margin-top: ${fg.spacing.lg};
296
+ `;async function jg(e){const t=e.toLowerCase(),n=r.v4(),o=await async function(e){const t=new TextEncoder,n=t.encode(e),r=await crypto.subtle.digest("SHA-256",n),o=Array.from(new Uint8Array(r));return btoa(String.fromCharCode(...o)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}(n);return sessionStorage.setItem(`${t}_oauthCodeVerifier`,JSON.stringify({code_verifier:n,code_challenge:o,timestamp:Date.now()})),{codeVerifier:n,codeChallenge:o}}const Ug=()=>{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: ${fg.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: ${fg.typography.fontWeights.semibold};\n line-height: 1.2;\n margin-bottom: ${fg.spacing.md};\n }\n \n .superstack-wallet-container p {\n font-family: 'Montserrat', sans-serif;\n margin-bottom: ${fg.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: ${fg.colors.background.main};\n border-radius: ${fg.borderRadius.md};\n padding: ${fg.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 Dg=Object.freeze({__proto__:null,injectStyles:Ug,theme:fg});function Gg({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,y]=o.useState(!1),[w,v]=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=fg.typography.fontSizes.xl)}})},[m,k]),{email:i,setEmail:c,emailSent:h,setEmailSent:p,sendingCode:b,setVerificationCode:g,verificationCode:m,verifyingCode:w,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");y(!0),await e.sendEmailVerificationCode(t),p(!0)}catch(e){alert("Failed to send verification code"),console.error("Failed to send verification code",e)}finally{y(!1)}},handleCodeSubmit:async(t=m.join(""),r=i)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");v(!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{v(!1)}},handlePhoneCodeSubmit:async(t=m.join(""),r=u)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");v(!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{v(!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{y(!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{v(!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 jg(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?${x.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?${x.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 qg=({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:b,connectingPhantom:y,inputRefs:w,handleCodeChange:x,handleKeyDown:E,handleContainerPaste:P,handleSendVerificationCode:k,handleCodeSubmit:A,onOauthLogin:I,handlePhantomLogin:S}=Gg({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o});return t?v.default.createElement(pg,null,v.default.createElement(mg,null,v.default.createElement(gg,null,v.default.createElement(bg,null,"Connect Wallet"),v.default.createElement(yg,{onClick:n},v.default.createElement(wg,{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},v.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))),o?v.default.createElement(vg,null,v.default.createElement(xg,null,v.default.createElement(s.Loader2,{size:24})),v.default.createElement(Eg,null,"Loading...")):v.default.createElement(v.default.Fragment,null,h?v.default.createElement(Cg,null,v.default.createElement("div",null,v.default.createElement(Og,null,"Enter Verification Code"),v.default.createElement(_g,null,"We sent a verification code to ",d)),v.default.createElement(Rg,{onPaste:P},b.map((e,t)=>v.default.createElement(zg,{key:t},v.default.createElement(Mg,{ref:w[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))}})))),v.default.createElement(Ag,{onClick:()=>A(),disabled:6!==b.join("").length||g},g?"Verifying...":"Verify Code"),v.default.createElement(Fg,{onClick:()=>m(!1)},"Back to Email")):v.default.createElement(Pg,null,a&&v.default.createElement(Pg,null,v.default.createElement(kg,{type:"email",value:d,onChange:e=>f(e.target.value),placeholder:"Enter your email",disabled:p}),v.default.createElement(Ag,{onClick:()=>k(),disabled:!d||p},p?"Sending...":"Send Verification Code")),(c||u||l)&&a&&v.default.createElement(Ig,null,v.default.createElement(Sg,null),v.default.createElement(Ng,null,"Or continue with"),v.default.createElement(Sg,null)),(c||u||l)&&v.default.createElement(v.default.Fragment,null,v.default.createElement(Tg,null,c&&v.default.createElement($g,{onClick:()=>I("google")},v.default.createElement(Bg,null,v.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/google/google-original.svg",alt:"Google",width:20,height:20})),"Google"),u&&v.default.createElement($g,{onClick:()=>I("twitter")},v.default.createElement(Bg,null,v.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/twitter/twitter-original.svg",alt:"Twitter",width:20,height:20})),"X")),l&&v.default.createElement($g,{onClick:S,disabled:y},v.default.createElement(Bg,null,v.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})),y?"Connecting...":"Phantom")),!a&&!i&&!c&&!u&&!l&&v.default.createElement("div",{style:{textAlign:"center",padding:"20px",color:"#666"}},"No login methods are currently enabled."))),v.default.createElement(Lg,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(v.default.createElement(qg,{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 Wg={isAuthenticated:!1,isConnecting:!1,isInitialized:!1,walletInfo:null,wallet:null,session:null,error:null,enableEmail:!0,enablePhone:!1,enableGoogle:!0,enableTwitter:!1,enablePhantom:!0},Hg=o.createContext({});function Yg(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{...Wg,isInitialized:!0};default:return e}}function Zg(){const e=o.useContext(Hg);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}"undefined"!=typeof window&&Promise.resolve().then(function(){return Dg}).then(({injectStyles:e})=>{e()}),exports.ACCESS_TOKEN_KEY=I,exports.BACKUP_WALLET_INFO=S,exports.BACKUP_WALLET_TYPE_KEY=A,exports.STORAGE_STATE_KEY=P,exports.Storage=N,exports.WALLET_TYPE_KEY=k,exports.WalletClient=Eh,exports.WalletProvider=function({children:e,config:t}){var n,r,s,a,i,c;const u=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[l,d]=o.useReducer(Yg,{...Wg,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}),f=o.useRef(null);f.current||(f.current=new Eh({...t,setWalletInfo:e=>{d({type:"SET_WALLET_INFO",payload:e})}}));const h=f.current,{walletInfo:p}=l,m=o.useRef(!1),g=o.useCallback(()=>(u.current||"undefined"==typeof window||(u.current=new Vg),u.current),[]);o.useEffect(()=>{t.modalManager&&(u.current=t.modalManager)},[t.modalManager]),o.useEffect(()=>{!async function(){if(!(p||m.current||l.isInitialized)){m.current=!0;try{const e=await h.reconnect();e&&(d({type:"SET_WALLET_INFO",payload:e}),d({type:"SET_WALLET",payload:h}))}catch(e){console.error("Auto reconnect failed:",e)}finally{d({type:"SET_INITIALIZED",payload:!0})}}}()},[h]),o.useEffect(()=>{const e=async()=>{try{if(w.isConnecting)return;d({type:"SET_CONNECTING",payload:!0});const e=new URLSearchParams(window.location.search),t=e.get("wallet_oauth_provider"),n=e.get("wallet_oauth_state"),r=e.get("wallet_oauth_code");if(t&&n&&r){const e=function(e){const t=e.toLowerCase(),n=sessionStorage.getItem(`${t}_oauthCodeVerifier`);if(!n)return null;const r=JSON.parse(n);return sessionStorage.removeItem(`${t}_oauthCodeVerifier`),Date.now()-r.timestamp>6e5?null:{codeVerifier:r.code_verifier,codeChallenge:r.code_challenge}}(t);if(!e)throw new Error("No code verifier found");const{codeVerifier:o,codeChallenge:s}=e;let a;if("twitter"===t)a="TwitterOAuth";else{if("google"!==t)throw new Error("Unsupported provider");a="GoogleOAuth"}g().showLoginModal({client:h,isLoading:!0,enableEmail:l.enableEmail,enablePhone:l.enablePhone,enableGoogle:l.enableGoogle,enableTwitter:l.enableTwitter,enablePhantom:l.enablePhantom});const i=await h.oauthLogin(a,{state:n,code:r,code_verifier:o});if(i){d({type:"SET_WALLET_INFO",payload:i}),d({type:"SET_WALLET",payload:h});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{d({type:"SET_CONNECTING",payload:!1}),await g().hideModal()}};return e(),window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}},[]);const b=o.useCallback(async()=>{try{d({type:"SET_CONNECTING",payload:!0});g().showLoginModal({client:h,enableEmail:l.enableEmail,enablePhone:l.enablePhone,enableGoogle:l.enableGoogle,enableTwitter:l.enableTwitter,enablePhantom:l.enablePhantom,onClose:()=>{d({type:"SET_CONNECTING",payload:!1})},onLogin:e=>{d({type:"SET_CONNECTING",payload:!1}),d({type:"SET_WALLET_INFO",payload:e}),d({type:"SET_WALLET",payload:h})}})}catch(e){d({type:"SET_ERROR",payload:e instanceof Error?e.message:"Failed to connect"}),d({type:"SET_CONNECTING",payload:!1})}},[h]),y=o.useCallback(async()=>{await h.logout(),d({type:"RESET"})},[h]);o.useEffect(()=>{var e;"phantom"===N.getWalletType()&&h.getPhantomAdapter()&&(null===(e=h.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{y()}))},[h]);const w={...l,connect:b,disconnect:y};return v.default.createElement(Hg.Provider,{value:w},e)},exports.injectStyles=Ug,exports.isVersionedTransaction=E,exports.theme=fg,exports.useCoinbaseOnramp=function(e,t){const{wallet:n}=Zg();return{getCoinbaseOnrampUrl:async(r,o="solana",s)=>{if(!n||!e||!t)throw new Error("Wallet not found");const a="solana"===o?e:t;return Ef({sessionToken:await(null==n?void 0:n.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=Gg,exports.useWallet=Zg,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}};
297
297
  //# sourceMappingURL=index.cjs.map