1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ccip-CC2QKXgd.js","assets/clsx.m-DHulAg21.js","assets/index-Chd_Wa1n.js","assets/index-BUUZxY2d.css","assets/index-nibyPLVP.js","assets/sha3-Bk1ffKuE.js"])))=>i.map(i=>d[i]); 2import{c as Kn}from"./clsx.m-DHulAg21.js";import{dz as Q,dx as fh,_ as vd,dB as ph,en as hh,eo as mh}from"./index-Chd_Wa1n.js";import{c as yh,s as gh,d as bh,g as wh}from"./index-nibyPLVP.js";import{r as vh}from"./sha3-Bk1ffKuE.js";function xd(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const a=c=>c===null?null:JSON.parse(c,void 0),o=(i=n.getItem(s))!=null?i:null;return o instanceof Promise?o.then(a):a(o)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const qi=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return qi(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return qi(r)(n)}}}},xh=(e,t)=>(n,r,s)=>{let i={storage:xd(()=>localStorage),partialize:h=>h,version:0,merge:(h,m)=>({...m,...h}),...t},a=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e((...h)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...h)},r,s);const l=()=>{const h=i.partialize({...r()});return u.setItem(i.name,{state:h,version:i.version})},d=s.setState;s.setState=(h,m)=>{d(h,m),l()};const f=e((...h)=>{n(...h),l()},r,s);s.getInitialState=()=>f;let p;const y=()=>{var h,m;if(!u)return;a=!1,o.forEach(b=>{var w;return b((w=r())!=null?w:f)});const g=((m=i.onRehydrateStorage)==null?void 0:m.call(i,(h=r())!=null?h:f))||void 0;return qi(u.getItem.bind(u))(i.name).then(b=>{if(b)if(typeof b.version=="number"&&b.version!==i.version){if(i.migrate){const w=i.migrate(b.state,b.version);return w instanceof Promise?w.then(x=>[!0,x]):[!0,w]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,b.state];return[!1,void 0]}).then(b=>{var w;const[x,S]=b;if(p=i.merge(S,(w=r())!=null?w:f),n(p,!0),x)return l()}).then(()=>{g?.(p,void 0),p=r(),a=!0,c.forEach(b=>b(p))}).catch(b=>{g?.(void 0,b)})};return s.persist={setOptions:h=>{i={...i,...h},h.storage&&(u=h.storage)},clearStorage:()=>{u?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>y(),hasHydrated:()=>a,onHydrate:h=>(o.add(h),()=>{o.delete(h)}),onFinishHydration:h=>(c.add(h),()=>{c.delete(h)})},i.skipHydration||y(),p||f},Eh=xh,_c=e=>{let t;const n=new Set,r=(u,l)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const f=t;t=l??(typeof d!="object"||d===null)?d:Object.assign({}
2,t,d),n.forEach(p=>p(t,f))}},s=()=>t,o={setState:r,getState:s,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(r,s,o);return o},lo=e=>e?_c(e):_c,_h="1.0.8";let Me=class Vi extends Error{constructor(t,n={}){const r=n.cause instanceof Vi?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Vi&&n.cause.docsPath||n.docsPath,i=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...r?[`Details: ${r}`]:[],`Version: abitype@${_h}`].join(` 3`);super(i),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.shortMessage=t}};function St(e,t){return e.exec(t)?.groups}const Ed=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,_d=/^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)?$/,Sd=/^\(.+?\).*?$/,Sc=/^tuple(?<array>(\[(\d*)\])*)$/;function Wi(e){let t=e.type;if(Sc.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let s=0;s<n;s++){const i=e.components[s];t+=Wi(i),s<n-1&&(t+=", ")}const r=St(Sc,e.type);return t+=`)${r?.array??""}`,Wi({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Fn(e){let t="";const n=e.length;for(let r=0;r<n;r++){const s=e[r];t+=Wi(s),r!==n-1&&(t+=", ")}return t}function fs(e){return e.type==="function"?`function ${e.name}(${Fn(e.inputs)})${e.stateMutability&&e.stateMutability!=="nonpayable"?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${Fn(e.outputs)})`:""}`:e.type==="event"?`event ${e.name}(${Fn(e.inputs)})`:e.type==="error"?`error ${e.name}(${Fn(e.inputs)})`:e.type==="constructor"?`constructor(${Fn(e.inputs)})${e.stateMutability==="payable"?" payable":""}`:e.type==="fallback"?`fallback() external${e.stateMutability==="payable"?" payable":""}`:"receive() external payable"}const Ad=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function Sh(e){return Ad.test(e)}function Ah(e){return St(Ad,e)}const kd=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function kh(e){return kd.test(e)}function Ih(e){return St(kd,e)}const Id=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;function Ph(e){return Id.test(e)}function Th(e){return St(Id,e)}const Pd=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function fo(e){return Pd.test(e)}function Oh(e){return St(Pd,e)}const Td=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function Ch(e){return Td.test(e)}function Bh(e){return St(Td,e)}const Od=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function $h(e){return Od.test(e)}function Nh(e){return St(Od,e)}const Mh=/^receive\(\) external payable$/;function Rh(e){return Mh.test(e)}const jh=new Set(["indexed"]),Ki=new Set(["calldata","memory","storage"]);class Lh extends Me{constructor({signature:t}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(t,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class Uh extends Me{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" 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 Dh extends Me{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class zh extends Me{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class Fh extends Me{constructor({param:t,name:n}
3){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${n}" 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 Hh extends Me{constructor({param:t,type:n,modifier:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${r}" not allowed${n?` in "${n}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class Gh extends Me{constructor({param:t,type:n,modifier:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${r}" not allowed${n?` in "${n}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${r}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class qh extends Me{constructor({abiParameter:t}){super("Invalid ABI parameter.",{details:JSON.stringify(t,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class jn extends Me{constructor({signature:t,type:n}){super(`Invalid ${n} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Vh extends Me{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Wh extends Me{constructor({signature:t}){super("Invalid struct signature.",{details:t,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class Kh extends Me{constructor({type:t}){super("Circular reference detected.",{metaMessages:[`Struct "${t}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class Zh extends Me{constructor({current:t,depth:n}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${n>0?"opening":"closing"} parentheses.`],details:`Depth "${n}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function Yh(e,t,n){let r="";if(n)for(const s of Object.entries(n)){if(!s)continue;let i="";for(const a of s[1])i+=`[${a.type}${a.name?`:${a.name}`:""}]`;r+=`(${s[0]}{${i}})`}return t?`${t}:${e}${r}`:e}const pi=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 Zi(e,t={}){if(Ph(e))return Jh(e,t);if(kh(e))return Qh(e,t);if(Sh(e))return Xh(e,t);if(Ch(e))return e0(e,t);if($h(e))return t0(e);if(Rh(e))return{type:"receive",stateMutability:"payable"};throw new Vh({signature:e})}function Jh(e,t={}){const n=Th(e);if(!n)throw new jn({signature:e,type:"function"});const r=Ze(n.parameters),s=[],i=r.length;for(let o=0;o<i;o++)s.push(Jt(r[o],{modifiers:Ki,structs:t,type:"function"}));const a=[];if(n.returns){const o=Ze(n.returns),c=o.length;for(let u=0;u<c;u++)a.push(Jt(o[u],{modifiers:Ki,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:s,outputs:a}}function Qh(e,t={}){const n=Ih(e);if(!n)throw new jn({signature:e,type:"event"});const r=Ze(n.parameters),s=[],i=r.length;for(let a=0;a<i;a++)s.push(Jt(r[a],{modifiers:jh,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:s}}function Xh(e,t={}){const n=Ah(e);if(!n)throw new jn({signature:e,type:"error"});const r=Ze(n.parameters),s=[],i=r.length;for(let a=0;a<i;a++)s.push(Jt(r[a],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:s}}function e0(e,t={}){const n=Bh(e);if(!n)throw new jn({signature:e,type:"constructor"});const r=Ze(n.parameters),s=[],i=r.length;for(let a=0;a<i;a++)s.push(Jt(r[a],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:s}}function t0(e){const t=Nh(e);if(!t)throw new jn({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}const n0=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,r0=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,s0=/^u?int$/;function Jt(e,t){const n=Yh(e,t?.type,t?.structs);if(pi.has(n))return pi.get(n);const r=Sd.test(e),s=St(r?r0:n0,e);if(!s)throw new zh({param:e});if(s.name&&a0(s.name))throw new Fh({param:e,name:s.name});const i=s.name?{name:s.name}:{},a=s.modifier==="indexed"?{indexed:!0}:{},o=t?.structs??{};let c,u={};if(r){c="tuple";const d=Ze(s.type),f=[],p=d.length;for(let y=0;y<p;y++)f.push(Jt(d[y],{structs:o}));u={components:f}}else if(s.type in o)c="tuple",u={components:o[s.type]};else if(s0.test(s.type))c=`${s.type}256`;else if(c=s.type,t?.type!=="struct"&&!Cd(c))throw new Dh({type:c});if(s.modifier){if(!t?.modifiers?.has?.(s.modifier))throw new Hh({param:e,type:t?.type,modifier:s.modifier});if(Ki.has(s.modifier)&&!o0(c,!!s.array))throw new Gh({param:e,type:t?.type,modifier:s.modifier})}const l={type:`${c}${s.array??""}`,...i,...a,...u};return pi.set(n,l),l}function Ze(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const a=e[i],o=e.slice(i+1);switch(a){case",":return r===0?Ze(o,[...t,n.trim()]):Ze(o,t,`${n}${a}`,r);case"(":return Ze(o,t,`${n}${a}`,r+1);case")":return Ze(o,t,`${n}${a}`,r-1);default:return Ze(o,t,`${n}${a}`,r)}}if(n==="")return t;if(r!==0)throw new Zh({current:n,depth:r});return t.push(n.trim()),t}function Cd(e){return e==="address"||e==="bool"||e==="function"||e==="string"||Ed.test(e)||_d.test(e)}const i0=/^(?: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 a0(e){return e==="address"||e==="bool"||e==="function"||e==="string"||e==="tuple"||Ed.test(e)||_d.test(e)||i0.test(e)}function o0(e,t){return t||e==="bytes"||e==="string"||e==="tuple"}function Bd(e){const t={},n=e.length;for(let a=0;a<n;a++){const o=e[a];if(!fo(o))continue;const c=Oh(o);if(!c)throw new jn({signature:o,type:"struct"});const u=c.properties.split(";"),l=[],d=u.length;for(let f=0;f<d;f++){const y=u[f].trim();if(!y)continue;const h=Jt(y,{type:"struct"});l.push(h)}if(!l.length)throw new Wh({signature:o});t[c.name]=l}const r={},s=Object.entries(t),i=s.length;for(let a=0;a<i;a++){const[o,c]=s[a];r[o]=$d(c,t)}return r}const c0=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function $d(e,t,n=new Set){const r=[],s=e.length;for(let i=0;i<s;i++){const a=e[i];if(Sd.test(a.type))r.push(a);else{const c=St(c0,a.type);if(!c?.type)throw new qh({abiParameter:a});const{array:u,type:l}=c;if(l in t){if(n.has(l))throw new Kh({type:l});
3r.push({...a,type:`tuple${u??""}`,components:$d(t[l]??[],t,new Set([...n,l]))})}else if(Cd(l))r.push(a);else throw new Uh({type:l})}}return r}function po(e){const t=Bd(e),n=[],r=e.length;for(let s=0;s<r;s++){const i=e[s];fo(i)||n.push(Zi(i,t))}return n}function Ac(e){let t;if(typeof e=="string")t=Zi(e);else{const n=Bd(e),r=e.length;for(let s=0;s<r;s++){const i=e[s];if(!fo(i)){t=Zi(i,n);break}}}if(!t)throw new Lh({signature:e});return t}var js,ee,Nd,Dt,kc,Md,Yi,ho,Ji,Qi,nr={},Rd=[],u0=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,mo=Array.isArray;function $t(e,t){for(var n in t)e[n]=t[n];return e}function jd(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function J(e,t,n){var r,s,i,a={};for(i in t)i=="key"?r=t[i]:i=="ref"?s=t[i]:a[i]=t[i];if(arguments.length>2&&(a.children=arguments.length>3?js.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(i in e.defaultProps)a[i]===void 0&&(a[i]=e.defaultProps[i]);return is(e,a,r,s,null)}function is(e,t,n,r,s){var i={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:s??++Nd,__i:-1,__u:0};return s==null&&ee.vnode!=null&&ee.vnode(i),i}function Ls(e){return e.children}function as(e,t){this.props=e,this.context=t}function Sn(e,t){if(t==null)return e.__?Sn(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Sn(e):null}function Ld(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return Ld(e)}}function Ic(e){(!e.__d&&(e.__d=!0)&&Dt.push(e)&&!ps.__r++||kc!==ee.debounceRendering)&&((kc=ee.debounceRendering)||Md)(ps)}function ps(){var e,t,n,r,s,i,a,o;for(Dt.sort(Yi);e=Dt.shift();)e.__d&&(t=Dt.length,r=void 0,i=(s=(n=e).__v).__e,a=[],o=[],n.__P&&((r=$t({},s)).__v=s.__v+1,ee.vnode&&ee.vnode(r),yo(n.__P,r,s,n.__n,n.__P.namespaceURI,32&s.__u?[i]:null,a,i??Sn(s),!!(32&s.__u),o),r.__v=s.__v,r.__.__k[r.__i]=r,zd(a,r,o),r.__e!=i&&Ld(r)),Dt.length>t&&Dt.sort(Yi));ps.__r=0}function Ud(e,t,n,r,s,i,a,o,c,u,l){var d,f,p,y,h,m=r&&r.__k||Rd,g=t.length;for(n.__d=c,d0(n,t,m),c=n.__d,d=0;d<g;d++)(p=n.__k[d])!=null&&(f=p.__i===-1?nr:m[p.__i]||nr,p.__i=d,yo(e,p,f,s,i,a,o,c,u,l),y=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&go(f.ref,null,p),l.push(p.ref,p.__c||y,p)),h==null&&y!=null&&(h=y),65536&p.__u||f.__k===p.__k?c=Dd(p,c,e):typeof p.type=="function"&&p.__d!==void 0?c=p.__d:y&&(c=y.nextSibling),p.__d=void 0,p.__u&=-196609);n.__d=c,n.__e=h}function d0(e,t,n){var r,s,i,a,o,c=t.length,u=n.length,l=u,d=0;for(e.__k=[],r=0;r<c;r++)(s=t[r])!=null&&typeof s!="boolean"&&typeof s!="function"?(a=r+d,(s=e.__k[r]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?is(null,s,null,null,null):mo(s)?is(Ls,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?is(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=e,s.__b=e.__b+1,i=null,(o=s.__i=l0(s,n,a,l))!==-1&&(l--,(i=n[o])&&(i.__u|=131072)),i==null||i.__v===null?(o==-1&&d--,typeof s.type!="function"&&(s.__u|=65536)):o!==a&&(o==a-1?d--:o==a+1?d++:(o>a?d--:d++,s.__u|=65536))):s=e.__k[r]=null;if(l)for(r=0;r<u;r++)(i=n[r])!=null&&(131072&i.__u)==0&&(i.__e==e.__d&&(e.__d=Sn(i)),Fd(i,i))}function Dd(e,t,n){var r,s;if(typeof e.type=="function"){for(r=e.__k,s=0;r&&s<r.length;s++)r[s]&&(r[s].__=e,t=Dd(r[s],t,n));return t}e.__e!=t&&(t&&e.type&&!n.contains(t)&&(t=Sn(e)),n.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType===8);return t}function l0(e,t,n,r){var s=e.key,i=e.type,a=n-1,o=n+1,c=t[n];if(c===null||c&&s==c.key&&i===c.type&&(131072&c.__u)==0)return n;if(r>(c!=null&&(131072&c.__u)==0?1:0))for(;a>=0||o<t.length;){if(a>=0){if((c=t[a])&&(131072&c.__u)==0&&s==c.key&&i===c.type)return a;a--}
3if(o<t.length){if((c=t[o])&&(131072&c.__u)==0&&s==c.key&&i===c.type)return o;o++}}return-1}function Pc(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||u0.test(t)?n:n+"px"}function zr(e,t,n,r,s){var i;e:if(t==="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Pc(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||Pc(e.style,t,n[t])}else if(t[0]==="o"&&t[1]==="n")i=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e||t==="onFocusOut"||t==="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?r?n.u=r.u:(n.u=ho,e.addEventListener(t,i?Qi:Ji,i)):e.removeEventListener(t,i?Qi:Ji,i);else{if(s=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function Tc(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=ho++;else if(t.t<n.u)return;return n(ee.event?ee.event(t):t)}}}function yo(e,t,n,r,s,i,a,o,c,u){var l,d,f,p,y,h,m,g,b,w,x,S,A,k,$,v,C=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),i=[o=t.__e=n.__e]),(l=ee.__b)&&l(t);e:if(typeof C=="function")try{if(g=t.props,b="prototype"in C&&C.prototype.render,w=(l=C.contextType)&&r[l.__c],x=l?w?w.props.value:l.__:r,n.__c?m=(d=t.__c=n.__c).__=d.__E:(b?t.__c=d=new C(g,x):(t.__c=d=new as(g,x),d.constructor=C,d.render=p0),w&&w.sub(d),d.props=g,d.state||(d.state={}),d.context=x,d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),b&&d.__s==null&&(d.__s=d.state),b&&C.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=$t({},d.__s)),$t(d.__s,C.getDerivedStateFromProps(g,d.__s))),p=d.props,y=d.state,d.__v=t,f)b&&C.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),b&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(b&&C.getDerivedStateFromProps==null&&g!==p&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(g,x),!d.__e&&(d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(g,d.__s,x)===!1||t.__v===n.__v)){for(t.__v!==n.__v&&(d.props=g,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(E){E&&(E.__=t)}),S=0;S<d._sb.length;S++)d.__h.push(d._sb[S]);d._sb=[],d.__h.length&&a.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(g,d.__s,x),b&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(p,y,h)})}if(d.context=x,d.props=g,d.__P=e,d.__e=!1,A=ee.__r,k=0,b){for(d.state=d.__s,d.__d=!1,A&&A(t),l=d.render(d.props,d.state,d.context),$=0;$<d._sb.length;$++)d.__h.push(d._sb[$]);d._sb=[]}else do d.__d=!1,A&&A(t),l=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++k<25);d.state=d.__s,d.getChildContext!=null&&(r=$t($t({},r),d.getChildContext())),b&&!f&&d.getSnapshotBeforeUpdate!=null&&(h=d.getSnapshotBeforeUpdate(p,y)),Ud(e,mo(v=l!=null&&l.type===Ls&&l.key==null?l.props.children:l)?v:[v],t,n,r,s,i,a,o,c,u),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),m&&(d.__E=d.__=null)}catch(E){if(t.__v=null,c||i!=null){for(t.__u|=c?160:32;o&&o.nodeType===8&&o.nextSibling;)o=o.nextSibling;i[i.indexOf(o)]=null,t.__e=o}else t.__e=n.__e,t.__k=n.__k;ee.__e(E,t,n)}else i==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=f0(n.__e,t,n,r,s,i,a,c,u);(l=ee.diffed)&&l(t)}function zd(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)go(n[r],n[++r],n[++r]);ee.__c&&ee.__c(t,e),e.some(function(s){try{e=s.__h,s.__h=[],e.some(function(i){i.call(s)})}catch(i){ee.__e(i,s.__v)}})}function f0(e,t,n,r,s,i,a,o,c){var u,l,d,f,p,y,h,m=n.props,g=t.props,b=t.type;if(b==="svg"?s="http://www.w3.org/2000/svg":b==="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),i!=null){for(u=0;u<i.length;u++)if((p=i[u])&&"setAttribute"in p==!!b&&(b?p.localName===b:p.nodeType===3)){e=p,i[u]=null;break}}if(e==null){if(b===null)return document.createTextNode(g);e=document.createElementNS(s,b,g.is&&g),o&&(ee.__m&&ee.__m(t,i),o=!1),i=null}if(b===null)m===g||o&&e.data===g||(e.data=g);else{if(i=i&&js.call(e.childNodes),m=n.props||nr,!o&&i!=null)for(m={},u=0;u<e.attributes.length;u++)m[(p=e.attributes[u]).name]=p.value;for(u in m)if(p=m[u],u!="children"){if(u=="dangerouslySetInnerHTML")d=p;else if(!(u in g)){if(u=="value"&&"defaultValue"in g||u=="checked"&&"defaultChecked"in g)continue;zr(e,u,null,p,s)}}for(u in g)p=g[u],u=="children"?f=p:u=="dangerouslySetInnerHTML"?l=p:u=="value"?y=p:u=="checked"?h=p:o&&typeof p!="function"||m[u]===p||zr(e,u,p,m[u],s);if(l)o||d&&(l.__html===d.__html||l.__html===e.innerHTML)||(e.innerHTML=l.__html),t.__k=[];else if(d&&(e.innerHTML=""),Ud(e,mo(f)?f:[f],t,n,r,b==="foreignObject"?"http://www.w3.org/1999/xhtml":s,i,a,i?i[0]:n.__k&&Sn(n,0),o,c),i!=null)for(u=i.length;u--;)jd(i[u]);o||(u="value",b==="progress"&&y==null?e.removeAttribute("value"):y!==void 0&&(y!==e[u]||b==="progress"&&!y||b==="option"&&y!==m[u])&&zr(e,u,y,m[u],s),u="checked",h!==void 0&&h!==e[u]&&zr(e,u,h,m[u],s))}return e}function go(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(s){ee.__e(s,n)}}
3function Fd(e,t,n){var r,s;if(ee.unmount&&ee.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||go(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(i){ee.__e(i,t)}r.base=r.__P=null}if(r=e.__k)for(s=0;s<r.length;s++)r[s]&&Fd(r[s],t,n||typeof e.type!="function");n||jd(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function p0(e,t,n){return this.constructor(e,n)}function Xi(e,t,n){var r,s,i,a;ee.__&&ee.__(e,t),s=(r=!1)?null:t.__k,i=[],a=[],yo(t,e=t.__k=J(Ls,null,[e]),s||nr,nr,t.namespaceURI,s?null:t.firstChild?js.call(t.childNodes):null,i,s?s.__e:t.firstChild,r,a),zd(i,e,a)}js=Rd.slice,ee={__e:function(e,t,n,r){for(var s,i,a;t=t.__;)if((s=t.__c)&&!s.__)try{if((i=s.constructor)&&i.getDerivedStateFromError!=null&&(s.setState(i.getDerivedStateFromError(e)),a=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(e,r||{}),a=s.__d),a)return s.__E=s}catch(o){e=o}throw e}},Nd=0,as.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=$t({},this.state),typeof e=="function"&&(e=e($t({},n),this.props)),e&&$t(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Ic(this))},as.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Ic(this))},as.prototype.render=Ls,Dt=[],Md=typeof Promise=="function"?Promise.prototype.then.bind(Prom
3ise.resolve()):setTimeout,Yi=function(e,t){return e.__v.__b-t.__v.__b},ps.__r=0,ho=0,Ji=Tc(!1),Qi=Tc(!0);var hs,ie,hi,Oc,ea=0,Hd=[],ue=ee,Cc=ue.__b,Bc=ue.__r,$c=ue.diffed,Nc=ue.__c,Mc=ue.unmount,Rc=ue.__;function Gd(e,t){ue.__h&&ue.__h(ie,e,ea||t),ea=0;var n=ie.__H||(ie.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function jc(e){return ea=1,h0(qd,e)}function h0(e,t,n){var r=Gd(hs++,2);if(r.t=e,!r.__c&&(r.__=[qd(void 0,t),function(o){var c=r.__N?r.__N[0]:r.__[0],u=r.t(c,o);c!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=ie,!ie.u)){var s=function(o,c,u){if(!r.__c.__H)return!0;var l=r.__c.__H.__.filter(function(f){return!!f.__c});if(l.every(function(f){return!f.__N}))return!i||i.call(this,o,c,u);var d=!1;return l.forEach(function(f){if(f.__N){var p=f.__[0];f.__=f.__N,f.__N=void 0,p!==f.__[0]&&(d=!0)}}),!(!d&&r.__c.props===o)&&(!i||i.call(this,o,c,u))};ie.u=!0;var i=ie.shouldComponentUpdate,a=ie.componentWillUpdate;ie.componentWillUpdate=function(o,c,u){if(this.__e){var l=i;i=void 0,s(o,c,u),i=l}a&&a.call(this,o,c,u)},ie.shouldComponentUpdate=s}return r.__N||r.__}function m0(e,t){var n=Gd(hs++,3);!ue.__s&&b0(n.__H,t)&&(n.__=e,n.i=t,ie.__H.__h.push(n))}function y0(){for(var e;e=Hd.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(os),e.__H.__h.forEach(ta),e.__H.__h=[]}catch(t){e.__H.__h=[],ue.__e(t,e.__v)}}ue.__b=function(e){ie=null,Cc&&Cc(e)},ue.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Rc&&Rc(e,t)},ue.__r=function(e){Bc&&Bc(e),hs=0;var t=(ie=e.__c).__H;t&&(hi===ie?(t.__h=[],ie.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.i=n.__N=void 0})):(t.__h.forEach(os),t.__h.forEach(ta),t.__h=[],hs=0)),hi=ie},ue.diffed=function(e){$c&&$c(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Hd.push(t)!==1&&Oc===ue.requestAnimationFrame||((Oc=ue.requestAnimationFrame)||g0)(y0)),t.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.i=void 0})),hi=ie=null},ue.__c=function(e,t){t.some(function(n){try{n.__h.forEach(os),n.__h=n.__h.filter(function(r){return!r.__||ta(r)})}catch(r){t.some(function(s){s.__h&&(s.__h=[])}),t=[],ue.__e(r,n.__v)}}),Nc&&Nc(e,t)},ue.unmount=function(e){Mc&&Mc(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{os(r)}catch(s){t=s}}),n.__H=void 0,t&&ue.__e(t,n.__v))};var Lc=typeof requestAnimationFrame=="function";function g0(e){var t,n=function(){clearTimeout(r),Lc&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);Lc&&(t=requestAnimationFrame(n))}function os(e){var t=ie,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ie=t}function ta(e){var t=ie;e.__c=e.__(),ie=t}function b0(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function qd(e,t){return typeof t=="function"?t(e):t}const Ln="4.3.6",Vd="@coinbase/wallet-sdk",w0=()=>({chains:[]}),v0=()=>({keys:{}}),x0=()=>({account:{}}),E0=()=>({subAccount:void 0}),_0=()=>({subAccountConfig:{}}),S0=()=>({spendPermissions:[]}),A0=()=>({config:{version:Ln}}),oe=lo(Eh((...e)=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},w0(...e)),v0(...e)),x0(...e)),E0(...e)),S0(...e)),A0(...e)),_0(...e)),{name:"cbwsdk.store",storage:xd(()=>localStorage),partialize:e=>({chains:e.chains,keys:e.keys,account:e.account,subAccount:e.subAccount,spendPermissions:e.spendPermissions,config:e.config})})),k0={get:()=>oe.getState().subAccountConfig,set:e=>{oe.setState(t=>({subAccountConfig:Object.assign(Object.assign({},t.subAccountConfig),e)}))},clear:()=>{oe.setState({subAccountConfig:{}})}},I0={get:()=>oe.getState().subAccount,set:e=>{oe.setState(t=>({subAccount:t.subAccount?Object.assign(Object.assign({},t.subAccount),e):Object.assign({address:e.address},e)}))},clear:()=>{oe.setState({subAccount:void 0})}},P0={get:()=>oe.getState().spendPermissions,set:e=>{oe.setState({spendPermissions:e})},clear:()=>{oe.setState({spendPermissions:[]})}},T0={get:()=>oe.getState().account,set:e=>{oe.setState(t=>({account:Object.assign(Object.assign({},t.account),e)}))},clear:()=>{oe.setState({account:{}})}},O0={get:()=>oe.getState().chains,set:e=>{oe.setState({chains:e})},clear:()=>{oe.setState({chains:[]})}},C0={get:e=>oe.getState().keys[e],set:(e,t)=>{oe.setState(n=>
3({keys:Object.assign(Object.assign({},n.keys),{[e]:t})}))},clear:()=>{oe.setState({keys:{}})}},Wd={get:()=>oe.getState().config,set:e=>{oe.setState(t=>({config:Object.assign(Object.assign({},t.config),e)}))}},B0={subAccounts:I0,subAccountsConfig:k0,spendPermissions:P0,account:T0,chains:O0,keys:C0,config:Wd},L=Object.assign(Object.assign({},oe),B0),$0
vendor: 83,976 bytes, line 3
3='!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ClientAnalytics=t():e.ClientAnalytics=t()}(this,(function(){return(()=>{var e={792:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=t},562:e=>{var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],r=0;r<e.length;r+=3)for(var i=e[r]<<16|e[r+1]<<8|e[r+2],a=0;a<4;a++)8*r+6*a<=8*e.length?n.push(t.charAt(i>>>6*(3-a)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\\/]/gi,"");for(var n=[],r=0,i=0;r<e.length;i=++r%4)0!=i&&n.push((t.indexOf(e.charAt(r-1))&Math.pow(2,-2*i+8)-1)<<2*i|t.indexOf(e.charAt(r))>>>6-2*i);return n}},e.exports=n},335:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},762:(e,t,n)=>{var r,i,a,o,s;r=n(562),i=n(792).utf8,a=n(335),o=n(792).bin,(s=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?o.stringToBytes(e):i.stringToBytes(e):a(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),c=8*e.length,u=1732584193,l=-271733879,d=-1732584194,p=271733878,m=0;m<n.length;m++)n[m]=16711935&(n[m]<<8|n[m]>>>24)|4278255360&(n[m]<<24|n[m]>>>8);n[c>>>5]|=128<<c%32,n[14+(c+64>>>9<<4)]=c;var f=s._ff,v=s._gg,g=s._hh,b=s._ii;for(m=0;m<n.length;m+=16){var h=u,w=l,y=d,T=p;u=f(u,l,d,p,n[m+0],7,-680876936),p=f(p,u,l,d,n[m+1],12,-389564586),d=f(d,p,u,l,n[m+2],17,606105819),l=f(l,d,p,u,n[m+3],22,-1044525330),u=f(u,l,d,p,n[m+4],7,-176418897),p=f(p,u,l,d,n[m+5],12,1200080426),d=f(d,p,u,l,n[m+6],17,-1473231341),l=f(l,d,p,u,n[m+7],22,-45705983),u=f(u,l,d,p,n[m+8],7,1770035416),p=f(p,u,l,d,n[m+9],12,-1958414417),d=f(d,p,u,l,n[m+10],17,-42063),l=f(l,d,p,u,n[m+11],22,-1990404162),u=f(u,l,d,p,n[m+12],7,1804603682),p=f(p,u,l,d,n[m+13],12,-40341101),d=f(d,p,u,l,n[m+14],17,-1502002290),u=v(u,l=f(l,d,p,u,n[m+15],22,1236535329),d,p,n[m+1],5,-165796510),p=v(p,u,l,d,n[m+6],9,-1069501632),d=v(d,p,u,l,n[m+11],14,643717713),l=v(l,d,p,u,n[m+0],20,-373897302),u=v(u,l,d,p,n[m+5],5,-701558691),p=v(p,u,l,d,n[m+10],9,38016083),d=v(d,p,u,l,n[m+15],14,-660478335),l=v(l,d,p,u,n[m+4],20,-405537848),u=v(u,l,d,p,n[m+9],5,568446438),p=v(p,u,l,d,n[m+14],9,-1019803690),d=v(d,p,u,l,n[m+3],14,-187363961),l=v(l,d,p,u,n[m+8],20,1163531501),u=v(u,l,d,p,n[m+13],5,-1444681467),p=v(p,u,l,d,n[m+2],9,-51403784),d=v(d,p,u,l,n[m+7],14,1735328473),u=g(u,l=v(l,d,p,u,n[m+12],20,-1926607734),d,p,n[m+5],4,-378558),p=g(p,u,l,d,n[m+8],11,-2022574463),d=g(d,p,u,l,n[m+11],16,1839030562),l=g(l,d,p,u,n[m+14],23,-35309556),u=g(u,l,d,p,n[m+1],4,-1530992060),p=g(p,u,l,d,n[m+4],11,1272893353),d=g(d,p,u,l,n[m+7],16,-155497632),l=g(l,d,p,u,n[m+10],23,-1094730640),u=g(u,l,d,p,n[m+13],4,681279174),p=g(p,u,l,d,n[m+0],11,-358537222),d=g(d,p,u,l,n[m+3],16,-722521979),l=g(l,d,p,u,n[m+6],23,76029189),u=g(u,l,d,p,n[m+9],4,-640364487),p=g(p,u,l,d,n[m+12],11,-421815835),d=g(d,p,u,l,n[m+15],16,530742520),u=b(u,l=g(l,d,p,u,n[m+2],23,-995338651),d,p,n[m+0],6,-198630844),p=b(p,u,l,d,n[m+7],10,1126891415),d=b(d,p,u,l,n[m+14],15,-1416354905),l=b(l,d,p,u,n[m+5],21,-57434055),u=b(u,l,d,p,n[m+12],6,1700485571),p=b(p,u,l,d,n[m+3],10,-1894986606),d=b(d,p,u,l,n[m+10],15,-1051523),l=b(l,d,p,u,n[m+1],21,-2054922799),u=b(u,l,d,p,n[m+8],6,1873313359),p=b(p,u,l,d,n[m+15],10,-30611744),d=b(d,p,u,l,n[m+6],15,-1560198380),l=b(l,d,p,u,n[m+13],21,1309151649),u=b(u,l,d,p,n[m+4],6,-145523070),p=b(p,u,l,d,n[m+11],10,-1120210379),d=b(d,p,u,l,n[m+2],15,718787259),l=b(l,d,p,u,n[m+9],21,-343485551),u=u+h>>>0,l=l+w>>>0,d=d+y>>>0,p=p+T>>>0}return r.endian([u,l,d,p])})._ff=function(e,t,n,r,i,a,o){var s=e+(t&n|~t&r)+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._gg=function(e,t,n,r,i,a,o){var s=e+(t&r|n&~r)+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._hh=function(e,t,n,r,i,a,o){var s=e+(t^n^r)+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._ii=function(e,t,n,r,i,a,o){var s=e+(n^(t|~r))+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._blocksize=16,s._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var n=r.wordsToBytes(s(e,t));return t&&t.asBytes?n:t&&t.asString?o.bytesToString(n):r.bytesToHex(n)}},2:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Perfume:()=>ze,incrementUjNavigation:()=>Le,markStep:()=>Re,markStepOnce:()=>qe});var r,i,a={isResourceTiming:!1,isElementTiming:!1,maxTime:3e4,reportOptions:{},enableNavigationTracking:!0},o=window,s=o.console,c=o.navigator,u=o.performance,l=function(){return c.deviceMemory},d=function(){return c.hardwareConcurrency},p="mark.",m=function(){return u&&!!u.getEntriesByType&&!!u.now&&!!u.mark},f="4g",v=!1,g={},b={value:0},h={value:{beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0}},w={value:0},y={value:0},T={},k={isHidden:!1,didChange:!1},_=function(){k.isHidden=!1,document.hidden&&(k.isHidden=document.hidden,k.didChange=!0)},S=function(e,t){try{var n=new PerformanceObserver((function(e){t(e.getEntries())}));return n.observe({type:e,buffered:!0}),n}catch(e){s.warn("Perfume.js:",e)}return null},E=function(){return!!(d()&&d()<=4)||!!(l()&&l()<=4)},x=function(e,t){switch(e){case"slow-2g":case"2g":case"3g":return!0;default:return E()||t}},O=function(e){return parseFloat(e.toFixed(4))},j=function(e){return"number"!=typeof e?null:O(e/Math.pow(1024,2))},N=function(e,t,n,r,i){var s,u=function(){a.analyticsTracker&&(k.isHidden&&!["CLS","INP"].includes(e)||a.analyticsTracker({attribution:r,metricName:e,data:t,navigatorInformation:c?{deviceMemory:l()||0,hardwareConcurrency:d()||0,serviceWorkerStatus:"serviceWorker"in c?c.serviceWorker.controller?"controlled":"supported":"unsupported",isLowEndDevice:E(),isLowEndExperience:x(f,v)}:{},rating:n,navigationType:i}))};["CLS","INP"].includes(e)?u():(s=u,"requestIdleCallback"in o?o.requestIdleCallback(s,{timeout:3e3}):s())},I=function(e){e.forEach((function(e){if(!("self"!==e.name||e.startTime<b.value)){var t=e.duration-50;t>0&&(w.value+=t,y.value+=t)}}))};!function(e){e.instant="instant",e.quick="quick",e.moderate="moderate",e.slow="slow",e.unavoidable="unavoidable"}(r||(r={}));var P,M,B,C,D,A=((i={})[r.instant]={vitalsThresholds:[100,200],maxOutlierThreshold:1e4},i[r.quick]={vitalsThresholds:[200,500],maxOutlierThreshold:1e4},i[r.moderate]={vitalsThresholds:[500,1e3],maxOutlierThreshold:1e4},i[r.slow]={vitalsThresholds:[1e3,2e3],maxOutlierThreshold:1e4},i[r.unavoidable]={vitalsThresholds:[2e3,5e3],maxOutlierThreshold:2e4},i),L={RT:[100,200],TBT:[200,600],NTBT:[200,600]},U=function(e,t){return L[e]?t<=L[e][0]?"good":t<=L[e][1]?"needsImprovement":"poor":null},R=function(e,t,n){Object.keys(t).forEach((function(e){"number"==typeof t[e]&&(t[e]=O(t[e]))})),N(e,t,null,n||{})},q=function(e){var t=e.attribution,n=e.name,r=e.rating,i=e.value,o=e.navigationType;"FCP"===n&&(b.value=i),["FCP","LCP"].includes(n)&&!T[0]&&(T[0]=S("longtask",I)),"FID"===n&&setTimeout((function(){k.didChange||(q({attribution:t,name:"TBT",rating:U("TBT",w.value),value:w.value,navigationType:o}),R("dataConsumption",h.value))}),1e4);var s=O(i);s<=a.maxTime&&s>=0&&N(n,s,r,t,o)},F=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},z=function(e){if("loading"===document.readyState)return"loading";var t=F();if(t){if(e<t.domInteractive)return"loading";if(0===t.domContentLoadedEventStart||e<t.domContentLoadedEventStart)return"dom-interactive";if(0===t.domComplete||e<t.domComplete)return"dom-content-loaded"}return"complete"},K=function(e){var t=e.nodeName;return 1===e.nodeType?t.toLowerCase():t.toUpperCase().replace(/^#/,"")},$=function(e,t){var n="";try{for(;e&&9!==e.nodeType;){var r=e,i=r.id?"#"+r.id:K(r)+(r.className&&r.className.length?"."+r.className.replace(/\\s+/g,"."):"");if(n.length+i.length>(t||100)-1)return n||i;if(n=n?i+">"+n:i,r.id)break;e=r.parentNode}}catch(e){}return n},Q=-1,W=function(){return Q},H=function(e){addEventListener("pageshow",(function(t){t.persisted&&(Q=t.timeStamp,e(t))}),!0)},V=function(){var e=F();return e&&e.activationStart||0},J=function(e,t){var n=F(),r="navigate";return W()>=0?r="back-forward-cache":n&&(r=document.prerendering||V()>0?"prerender":document.wasDiscarded?"restore":n.type.replace(/_/g,"-")),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},X=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver((function(e){Promise.resolve().then((function(){t(e.getEntries())}))}));return r.observe(Object.assign({type:e,buffered:!0},n||{})),r}}catch(e){}},G=function(e,t){var n=function n(r){"pagehide"!==r.type&&"hidden"!==document.visibilityState||(e(r),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},Z=function(e,t,n,r){var i,a;return function(o){t.value>=0&&(o||r)&&((a=t.value-(i||0))||void 0===i)&&(i=t.value,t.delta=a,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},Y=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},ee=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()},te=-1,ne=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},re=function(e){"hidden"===document.visibilityState&&te>-1&&(te="visibilitychange"===e.type?e.timeStamp:0,ae())},ie=function(){addEventListener("visibilitychange",re,!0),addEventListener("prerenderingchange",re,!0)},ae=function(){removeEventListener("visibilitychange",re,!0),removeEventListener("prerenderingchange",re,!0)},oe=function(){return te<0&&(te=ne(),ie(),H((function(){setTimeout((function(){te=ne(),ie()}),0)}))),{get firstHiddenTime(){return te}}},se=function(e,t){t=t||{},ee((function(){var n,r=[1800,3e3],i=oe(),a=J("FCP"),o=X("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(o.disconnect(),e.startTime<i.firstHiddenTime&&(a.value=Math.max(e.startTime-V(),0),a.entries.push(e),n(!0)))}))}));o&&(n=Z(e,a,r,t.reportAllChanges),H((function(i){a=J("FCP"),n=Z(e,a,r,t.reportAllChanges),Y((function(){a.value=performance.now()-i.timeStamp,n(!0)}))})))}))},ce={passive:!0,capture:!0},ue=new Date,le=function(e,t){P||(P=t,M=e,B=new Date,me(removeEventListener),de())},de=function(){if(M>=0&&M<B-ue){var e={entryType:"first-input",name:P.type,target:P.target,cancelable:P.cancelable,startTime:P.timeStamp,processingStart:P.timeStamp+M};C.forEach((function(t){t(e)})),C=[]}},pe=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){le(e,t),i()},r=function(){i()},i=function(){removeEventListener("pointerup",n,ce),removeEventListener("pointercancel",r,ce)};addEventListener("pointerup",n,ce),addEventListener("pointercancel",r,ce)}(t,e):le(t,e)}},me=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,pe,ce)}))},fe=0,ve=1/0,ge=0,be=function(e){e.forEach((function(e){e.interactionId&&(ve=Math.min(ve,e.interactionId),ge=Math.max(ge,e.interactionId),fe=ge?(ge-ve)/7+1:0)}))},he=function(){return D?fe:performance.interactionCount||0},we=0,ye=function(){return he()-we},Te=[],ke={},_e=function(e){var t=Te[Te.length-1],n=ke[e.interactionId];if(n||Te.length<10||e.duration>t.latency){if(n)n.entries.push(e),n.latency=Math.max(n.latency,e.duration);else{var r={id:e.interactionId,latency:e.duration,entries:[e]};ke[r.id]=r,Te.push(r)}Te.sort((function(e,t){return t.latency-e.latency})),Te.splice(10).forEach((function(e){delete ke[e.id]}))}},Se={},Ee=function e(t){document.prerendering?ee((function(){return e(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(t)}),!0):setTimeout(t,0)},xe=function(e,t){t=t||{};var n=[800,1800],r=J("TTFB"),i=Z(e,r,n,t.reportAllChanges);Ee((function(){var a=F();if(a){var o=a.responseStart;if(o<=0||o>performance.now())return;r.value=Math.max(o-V(),0),r.entries=[a],i(!0),H((function(){r=J("TTFB",0),(i=Z(e,r,n,t.reportAllChanges))(!0)}))}}))},Oe=function(e){e.forEach((function(e){e.identifier&&q({attribution:{identifier:e.identifier},name:"ET",rating:null,value:e.startTime})}))},je=function(e){e.forEach((function(e){if(a.isResourceTiming&&R("resourceTiming",e),e.decodedBodySize&&e.initiatorType){var t=e.decodedBodySize/1e3;h.value[e.initiatorType]+=t,h.value.total+=t}}))},Ne=function(){!function(e,t){xe((function(e){!function(e){if(e.entries.length){var t=e.entries[0],n=t.activationStart||0,r=Math.max(t.domainLookupStart-n,0),i=Math.max(t.connectStart-n,0),a=Math.max(t.requestStart-n,0);e.attribution={waitingTime:r,dnsTime:i-r,connectionTime:a-i,requestTime:e.value-a,navigationEntry:t}}else e.attribution={waitingTime:0,dnsTime:0,connectionTime:0,requestTime:0}}(e),function(e){e.value>0&&q(e)}(e)}),t)}(0,a.reportOptions.ttfb),function(e,t){!function(e,t){t=t||{},ee((function(){var e,n=[.1,.25],r=J("CLS"),i=-1,a=0,o=[],s=function(e){i>-1&&function(e){!function(e){if(e.entries.length){var t=e.entries.reduce((function(e,t){return e&&e.value>t.value?e:t}));if(t&&t.sources&&t.sources.length){var n=(r=t.sources).find((function(e){return e.node&&1===e.node.nodeType}))||r[0];if(n)return void(e.attribution={largestShiftTarget:$(n.node),largestShiftTime:t.startTime,largestShiftValue:t.value,largestShiftSource:n,largestShiftEntry:t,loadState:z(t.startTime)})}}var r;e.attribution={}}(e),function(e){q(e)}(e)}(e)},c=function(t){t.forEach((function(t){if(!t.hadRecentInput){var n=o[0],i=o[o.length-1];a&&t.startTime-i.startTime<1e3&&t.startTime-n.startTime<5e3?(a+=t.value,o.push(t)):(a=t.value,o=[t]),a>r.value&&(r.value=a,r.entries=o,e())}}))},u=X("layout-shift",c);u&&(e=Z(s,r,n,t.reportAllChanges),se((function(t){i=t.value,r.value<0&&(r.value=0,e())})),G((function(){c(u.takeRecords()),e(!0)})),H((function(){a=0,i=-1,r=J("CLS",0),e=Z(s,r,n,t.reportAllChanges),Y((function(){return e()}))})))}))}(0,t)}(0,a.reportOptions.cls),function(e,t){se((function(e){!function(e){if(e.entries.length){var t=F(),n=e.entries[e.entries.length-1];if(t){var r=t.activationStart||0,i=Math.max(0,t.responseStart-r);return void(e.attribution={timeToFirstByte:i,firstByteToFCP:e.value-i,loadState:z(e.entries[0].startTime),navigationEntry:t,fcpEntry:n})}}e.attribution={timeToFirstByte:0,firstByteToFCP:e.value,loadState:z(W())}}(e),function(e){q(e)}(e)}),t)}(0,a.reportOptions.fcp),function(e,t){!function(e,t){t=t||{},ee((function(){var n,r=[100,300],i=oe(),a=J("FID"),o=function(e){e.startTime<i.firstHiddenTime&&(a.value=e.processingStart-e.startTime,a.entries.push(e),n(!0))},s=function(e){e.forEach(o)},c=X("first-input",s);n=Z(e,a,r,t.reportAllChanges),c&&G((function(){s(c.takeRecords()),c.disconnect()}),!0),c&&H((function(){var i;a=J("FID"),n=Z(e,a,r,t.reportAllChanges),C=[],M=-1,P=null,me(addEventListener),i=o,C.push(i),de()}))}))}((function(e){!function(e){var t=e.entries[0];e.attribution={eventTarget:$(t.target),eventType:t.name,eventTime:t.startTime,eventEntry:t,loadState:z(t.startTime)}}(e),function(e){q(e)}(e)}),t)}(0,a.reportOptions.fid),function(e,t){!function(e,t){t=t||{},ee((function(){var n,r=[2500,4e3],i=oe(),a=J("LCP"),o=function(e){var t=e[e.length-1];if(t){var r=Math.max(t.startTime-V(),0);r<i.firstHiddenTime&&(a.value=r,a.entries=[t],n())}},s=X("largest-contentful-paint",o);if(s){n=Z(e,a,r,t.reportAllChanges);var c=function(){Se[a.id]||(o(s.takeRecords()),s.disconnect(),Se[a.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,c,{once:!0,capture:!0})})),G(c,!0),H((function(i){a=J("LCP"),n=Z(e,a,r,t.reportAllChanges),Y((function(){a.value=performance.now()-i.timeStamp,Se[a.id]=!0,n(!0)}))}))}}))}((function(e){!function(e){if(e.entries.length){var t=F();if(t){var n=t.activationStart||0,r=e.entries[e.entries.length-1],i=r.url&&performance.getEntriesByType("resource").filter((function(e){return e.name===r.url}))[0],a=Math.max(0,t.responseStart-n),o=Math.max(a,i?(i.requestStart||i.startTime)-n:0),s=Math.max(o,i?i.responseEnd-n:0),c=Math.max(s,r?r.startTime-n:0),u={element:$(r.element),timeToFirstByte:a,resourceLoadDelay:o-a,resourceLoadTime:s-o,elementRenderDelay:c-s,navigationEntry:t,lcpEntry:r};return r.url&&(u.url=r.url),i&&(u.lcpResourceEntry=i),void(e.attribution=u)}}e.attribution={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadTime:0,elementRenderDelay:e.value}}(e),function(e){q(e)}(e)}),t)}(0,a.reportOptions.lcp),function(e,t){!function(e,t){t=t||{},ee((function(){var n=[200,500];"interactionCount"in performance||D||(D=X("event",be,{type:"event",buffered:!0,durationThreshold:0}));var r,i=J("INP"),a=function(e){e.forEach((function(e){e.interactionId&&_e(e),"first-input"===e.entryType&&!Te.some((function(t){return t.entries.some((function(t){return e.duration===t.duration&&e.startTime===t.startTime}))}))&&_e(e)}));var t,n=(t=Math.min(Te.length-1,Math.floor(ye()/50)),Te[t]);n&&n.latency!==i.value&&(i.value=n.latency,i.entries=n.entries,r())},o=X("event",a,{durationThreshold:t.durationThreshold||40});r=Z(e,i,n,t.reportAllChanges),o&&(o.observe({type:"first-input",buffered:!0}),G((function(){a(o.takeRecords()),i.value<0&&ye()>0&&(i.value=0,i.entries=[]),r(!0)})),H((function(){Te=[],we=he(),i=J("INP"),r=Z(e,i,n,t.reportAllChanges)})))}))}((function(t){!function(e){if(e.entries.length){var t=e.entries.sort((function(e,t){return t.duration-e.duration||t.processingEnd-t.processingStart-(e.processingEnd-e.processingStart)}))[0];e.attribution={eventTarget:$(t.target),eventType:t.name,eventTime:t.startTime,eventEntry:t,loadState:z(t.startTime)}}else e.attribution={}}(t),e(t)}),t)}((function(e){return q(e)}),a.reportOptions.inp),a.isResourceTiming&&S("resource",je),a.isElementTiming&&S("element",Oe)},Ie=function(e){var t="usageDetails"in e?e.usageDetails:{};R("storageEstimate",{quota:j(e.quota),usage:j(e.usage),caches:j(t.caches),indexedDB:j(t.indexedDB),serviceWorker:j(t.serviceWorkerRegistrations)})},Pe={finalMarkToStepsMap:{},startMarkToStepsMap:{},active:{},navigationSteps:{}},Me=function(e){delete Pe.active[e]},Be=function(){return Pe.navigationSteps},Ce=function(e){var t;return null!==(t=Be()[e])&&void 0!==t?t:{}},De=function(e,t,n){var r="step."+e,i=u.getEntriesByName(p+t).length>0;if(u.getEntriesByName(p+n).length>0&&a.steps){var o=A[a.steps[e].threshold],s=o.maxOutlierThreshold,c=o.vitalsThresholds;if(i){var l=u.measure(r,p+t,p+n),d=l.duration;if(d<=s){var m=function(e,t){return e<=t[0]?"good":e<=t[1]?"needsImprovement":"poor"}(d,c);d>=0&&(N("userJourneyStep",d,m,{stepName:e},void 0),u.measure("step.".concat(e,"_vitals_").concat(m),{start:l.startTime+l.duration,end:l.startTime+l.duration,detail:{type:"stepVital",duration:d}}))}}}},Ae=function(){var e=Be(),t=Pe.startMarkToStepsMap,n=Object.keys(e).length;if(0===n)return{};var r={},i=n-1,a=Ce(i);if(Object.keys(a).forEach((function(e){var n,i=null!==(n=t[e])&&void 0!==n?n:[];Object.keys(i).forEach((function(e){r[e]=!0}))})),n>1){var o=Ce(i-1);Object.keys(o).forEach((function(e){var n,i=null!==(n=t[e])&&void 0!==n?n:[];Object.keys(i).forEach((function(e){r[e]=!0}))}))}return r},Le=function(){var e,t=Object.keys(Pe.navigationSteps).length;Pe.navigationSteps[t]={};var n=Ae();null===(e=a.onMarkStep)||void 0===e||e.call(a,"",Object.keys(n))},Ue=function(e){var t,n,r,i,o,s,c;if(Pe.finalMarkToStepsMap[e]){!function(e){var t=Pe.navigationSteps,n=Pe.finalMarkToStepsMap,r=Object.keys(t).length;if(0!==r){var i=r-1,a=Ce(i);if(a&&n[e]){var o=n[e];o&&Object.keys(o).forEach((function(e){if(a[e]){var n=Ce(i)||{};n[e]=!1,t[i]=n}if(r>1){var o=i-1,s=Ce(o);s[e]&&(s[e]=!1,t[o]=s)}}))}}}(e);var u=Pe.finalMarkToStepsMap[e];Object.keys(u).forEach((function(t){var n=u[t];n.forEach(Me),Promise.all(n.map((function(n){return function(e,t,n,r){return new(n||(n=Promise))((function(e,t){function i(e){try{o(r.next(e))}catch(e){t(e)}}function a(e){try{o(r.throw(e))}catch(e){t(e)}}function o(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(i,a)}o((r=r.apply(undefined,[])).next())}))}(0,0,void 0,(function(){return function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}(this,(function(r){switch(r.label){case 0:return[4,De(n,t,e)];case 1:return r.sent(),[2]}}))}))}))).catch((function(){}))}))}else r=e,i=Pe.navigationSteps,o=Object.keys(i).length,(c=Ce(s=(o>0?o:1)-1)||[])[r]=!0,i[s]=c,function(e){var t,n=null!==(t=Pe.startMarkToStepsMap[e])&&void 0!==t?t:[];Object.keys(n).forEach((function(e){Pe.active[e]||(Pe.active[e]=!0)}))}(e);if(a.enableNavigationTracking){var l=Ae();null===(t=a.onMarkStep)||void 0===t||t.call(a,e,Object.keys(l))}else null===(n=a.onMarkStep)||void 0===n||n.call(a,e,Object.keys(Pe.active))},Re=function(e){u.mark(p+e),Ue(e)},qe=function(e){0===u.getEntriesByName(p+e).length&&(u.mark(p+e),Ue(e))},Fe=0,ze=function(){function e(e){if(void 0===e&&(e={}),this.v="9.0.0-rc.3",a.analyticsTracker=e.analyticsTracker,a.isResourceTiming=!!e.resourceTiming,a.isElementTiming=!!e.elementTiming,a.maxTime=e.maxMeasureTime||a.maxTime,a.reportOptions=e.reportOptions||a.reportOptions,a.steps=e.steps,a.onMarkStep=e.onMarkStep,a.enableNavigationTracking=e.enableNavigationTracking,m()){"PerformanceObserver"in o&&Ne(),void 0!==document.hidden&&document.addEventListener("visibilitychange",_);var t=function(){if(!m())return{};var e=u.getEntriesByType("navigation")[0];if(!e)return{};var t=e.responseStart,n=e.responseEnd;return{fetchTime:n-e.fetchStart,workerTime:e.workerStart>0?n-e.workerStart:0,totalTime:n-e.requestStart,downloadTime:n-t,timeToFirstByte:t-e.requestStart,headerSize:e.transferSize-e.encodedBodySize||0,dnsLookupTime:e.domainLookupEnd-e.domainLookupStart,redirectTime:e.redirectEnd-e.redirectStart}}();R("navigationTiming",t),t.redirectTime&&q({attribution:{},name:"RT",rating:U("RT",t.redirectTime),value:t.redirectTime}),R("networkInformation",function(){if("connection"in c){var e=c.connection;return"object"!=typeof e?{}:(f=e.effectiveType,v=!!e.saveData,{downlink:e.downlink,effectiveType:e.effectiveType,rtt:e.rtt,saveData:!!e.saveData})}return{}}()),c&&c.storage&&"function"==typeof c.storage.estimate&&c.storage.estimate().then(Ie),a.steps&&a.steps&&(Pe.startMarkToStepsMap={},Pe.finalMarkToStepsMap={},Pe.active={},Pe.navigationSteps={},Object.entries(a.steps).forEach((function(e){var t,n,r=e[0],i=e[1].marks,a=i[0],o=i[1],s=null!==(n=Pe.startMarkToStepsMap[a])&&void 0!==n?n:{};if(s[r]=!0,Pe.startMarkToStepsMap[a]=s,Pe.finalMarkToStepsMap[o]){var c=Pe.finalMarkToStepsMap[o][a]||[];c.push(r),Pe.finalMarkToStepsMap[o][a]=c}else Pe.finalMarkToStepsMap[o]=((t={})[a]=[r],t)})))}}return e.prototype.start=function(e){m()&&!g[e]&&(g[e]=!0,u.mark("mark_".concat(e,"_start")))},e.prototype.end=function(e,t,n){if(void 0===t&&(t={}),void 0===n&&(n=!0),m()&&g[e]){u.mark("mark_".concat(e,"_end")),delete g[e];var r=function(e){u.measure(e,"mark_".concat(e,"_start"),"mark_".concat(e,"_end"));var t=u.getEntriesByName(e).pop();return t&&"measure"===t.entryType?t.duration:-1}(e);n&&R(e,O(r),t)}},e.prototype.endPaint=function(e,t){var n=this;setTimeout((function(){n.end(e,t)}))},e.prototype.clear=function(e){delete g[e],u.clearMarks&&(u.clearMarks("mark_".concat(e,"_start")),u.clearMarks("mark_".concat(e,"_end")))},e.prototype.markNTBT=function(){var e=this;this.start("ntbt"),y.value=0,clearTimeout(Fe),Fe=setTimeout((function(){e.end("ntbt",{},!1),q({attribution:{},name:"NTBT",rating:U("NTBT",y.value),value:y.value}),y.value=0}),2e3)},e}()},426:(e,t)=>{"use strict";Symbol.for("react.element"),Symbol.for("react.portal"),Symbol.for("react.fragment"),Symbol.for("react.strict_mode"),Symbol.for("react.profiler"),Symbol.for("react.provider"),Symbol.for("react.context"),Symbol.for("react.forward_ref"),Symbol.for("react.suspense"),Symbol.for("react.memo"),Symbol.for("react.lazy"),Symbol.iterator;var n={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},r=Object.assign,i={};function a(e,t,r){this.props=e,this.context=t,this.refs=i,this.updater=r||n}function o(){}function s(e,t,r){this.props=e,this.context=t,this.refs=i,this.updater=r||n}a.prototype.isReactComponent={},a.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},a.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},o.prototype=a.prototype;var c=s.prototype=new o;c.constructor=s,r(c,a.prototype),c.isPureReactComponent=!0;Array.isArray,Object.prototype.hasOwnProperty;var u={current:null};t.useCallback=function(e,t){return u.current.useCallback(e,t)},t.useEffect=function(e,t){return u.current.useEffect(e,t)},t.useRef=function(e){return u.current.useRef(e)}},784:(e,t,n)=>{"use strict";e.exports=n(426)},353:function(e,t,n){var r;!function(i,a){"use strict";var o="function",s="undefined",c="object",u="string",l="major",d="model",p="name",m="type",f="vendor",v="version",g="architecture",b="console",h="mobile",w="tablet",y="smarttv",T="wearable",k="embedded",_="Amazon",S="Apple",E="ASUS",x="BlackBerry",O="Browser",j="Chrome",N="Firefox",I="Google",P="Huawei",M="LG",B="Microsoft",C="Motorola",D="Opera",A="Samsung",L="Sharp",U="Sony",R="Xiaomi",q="Zebra",F="Facebook",z="Chromium OS",K="Mac OS",$=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},Q=function(e,t){return typeof e===u&&-1!==W(t).indexOf(W(e))},W=function(e){return e.toLowerCase()},H=function(e,t){if(typeof e===u)return e=e.replace(/^\\s\\s*/,""),typeof t===s?e:e.substring(0,350)},V=function(e,t){for(var n,r,i,s,u,l,d=0;d<t.length&&!u;){var p=t[d],m=t[d+1];for(n=r=0;n<p.length&&!u&&p[n];)if(u=p[n++].exec(e))for(i=0;i<m.length;i++)l=u[++r],typeof(s=m[i])===c&&s.length>0?2===s.length?typeof s[1]==o?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:3===s.length?typeof s[1]!==o||s[1].exec&&s[1].test?this[s[0]]=l?l.replace(s[1],s[2]):a:this[s[0]]=l?s[1].call(this,l,s[2]):a:4===s.length&&(this[s[0]]=l?s[3].call(this,l.replace(s[1],s[2])):a):this[s]=l||a;d+=2}},J=function(e,t){for(var n in t)if(typeof t[n]===c&&t[n].length>0){for(var r=0;r<t[n].length;r++)if(Q(t[n][r],e))return"?"===n?a:n}else if(Q(t[n],e))return"?"===n?a:n;return e},X={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},G={browser:[[/\\b(?:crmo|crios)\\/([\\w\\.]+)/i],[v,[p,"Chrome"]],[/edg(?:e|ios|a)?\\/([\\w\\.]+)/i],[v,[p,"Edge"]],[/(opera mini)\\/([-\\w\\.]+)/i,/(opera [mobiletab]{3,6})\\b.+version\\/([-\\w\\.]+)/i,/(opera)(?:.+version\\/|[\\/ ]+)([\\w\\.]+)/i],[p,v],[/opios[\\/ ]+([\\w\\.]+)/i],[v,[p,D+" Mini"]],[/\\bopr\\/([\\w\\.]+)/i],[v,[p,D]],[/(kindle)\\/([\\w\\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\\/ ]?([\\w\\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\\/ ]?([\\w\\.]*)/i,/(ba?idubrowser)[\\/ ]?([\\w\\.]+)/i,/(?:ms|\\()(ie) ([\\w\\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\\/([-\\w\\.]+)/i,/(heytap|ovi)browser\\/([\\d\\.]+)/i,/(weibo)__([\\d\\.]+)/i],[p,v],[/(?:\\buc? ?browser|(?:juc.+)ucweb)[\\/ ]?([\\w\\.]+)/i],[v,[p,"UC"+O]],[/microm.+\\bqbcore\\/([\\w\\.]+)/i,/\\bqbcore\\/([\\w\\.]+).+microm/i],[v,[p,"WeChat(Win) Desktop"]],[/micromessenger\\/([\\w\\.]+)/i],[v,[p,"WeChat"]],[/konqueror\\/([\\w\\.]+)/i],[v,[p,"Konqueror"]],[/trident.+rv[: ]([\\w\\.]{1,9})\\b.+like gecko/i],[v,[p,"IE"]],[/ya(?:search)?browser\\/([\\w\\.]+)/i],[v,[p,"Yandex"]],[/(avast|avg)\\/([\\w\\.]+)/i],[[p,/(.+)/,"$1 Secure "+O],v],[/\\bfocus\\/([\\w\\.]+)/i],[v,[p,N+" Focus"]],[/\\bopt\\/([\\w\\.]+)/i],[v,[p,D+" Touch"]],[/coc_coc\\w+\\/([\\w\\.]+)/i],[v,[p,"Coc Coc"]],[/dolfin\\/([\\w\\.]+)/i],[v,[p,"Dolphin"]],[/coast\\/([\\w\\.]+)/i],[v,[p,D+" Coast"]],[/miuibrowser\\/([\\w\\.]+)/i],[v,[p,"MIUI "+O]],[/fxios\\/([-\\w\\.]+)/i],[v,[p,N]],[/\\bqihu|(qi?ho?o?|360)browser/i],[[p,"360 "+O]],[/(oculus|samsung|sailfish|huawei)browser\\/([\\w\\.]+)/i],[[p,/(.+)/,"$1 "+O],v],[/(comodo_dragon)\\/([\\w\\.]+)/i],[[p,/_/g," "],v],[/(electron)\\/([\\w\\.]+) safari/i,/(tesla)(?: qtcarbrowser|\\/(20\\d\\d\\.[-\\w\\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\\/ ]?([\\w\\.]+)/i],[p,v],[/(metasr)[\\/ ]?([\\w\\.]+)/i,/(lbbrowser)/i,/\\[(linkedin)app\\]/i],[p],[/((?:fban\\/fbios|fb_iab\\/fb4a)(?!.+fbav)|;fbav\\/([\\w\\.]+);)/i],[[p,F],v],[/(kakao(?:talk|story))[\\/ ]([\\w\\.]+)/i,/(naver)\\(.*?(\\d+\\.[\\w\\.]+).*\\)/i,/safari (line)\\/([\\w\\.]+)/i,/\\b(line)\\/([\\w\\.]+)\\/iab/i,/(chromium|instagram)[\\/ ]([-\\w\\.]+)/i],[p,v],[/\\bgsa\\/([\\w\\.]+) .*safari\\//i],[v,[p,"GSA"]],[/musical_ly(?:.+app_?version\\/|_)([\\w\\.]+)/i],[v,[p,"TikTok"]],[/headlesschrome(?:\\/([\\w\\.]+)| )/i],[v,[p,j+" Headless"]],[/ wv\\).+(chrome)\\/([\\w\\.]+)/i],[[p,j+" WebView"],v],[/droid.+ version\\/([\\w\\.]+)\\b.+(?:mobile safari|safari)/i],[v,[p,"Android "+O]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\\/v?([\\w\\.]+)/i],[p,v],[/version\\/([\\w\\.\\,]+) .*mobile\\/\\w+ (safari)/i],[v,[p,"Mobile Safari"]],[/version\\/([\\w(\\.|\\,)]+) .*(mobile ?safari|safari)/i],[v,p],[/webkit.+?(mobile ?safari|safari)(\\/[\\w\\.]+)/i],[p,[v,J,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\\/([\\w\\.]+)/i],[p,v],[/(navigator|netscape\\d?)\\/([-\\w\\.]+)/i],[[p,"Netscape"],v],[/mobile vr; rv:([\\w\\.]+)\\).+firefox/i],[v,[p,N+" Reality"]],[/ekiohf.+(flow)\\/([\\w\\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\\/ ]?([\\w\\.\\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\\/([-\\w\\.]+)$/i,/(firefox)\\/([\\w\\.]+)/i,/(mozilla)\\/([\\w\\.]+) .+rv\\:.+gecko\\/\\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\\. ]?browser)[-\\/ ]?v?([\\w\\.]+)/i,/(links) \\(([\\w\\.]+)/i,/panasonic;(viera)/i],[p,v],[/(cobalt)\\/([\\w\\.]+)/i],[p,[v,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\\)]/i],[[g,"amd64"]],[/(ia32(?=;))/i],[[g,W]],[/((?:i[346]|x)86)[;\\)]/i],[[g,"ia32"]],[/\\b(aarch64|arm(v?8e?l?|_?64))\\b/i],[[g,"arm64"]],[/\\b(arm(?:v[67])?ht?n?[fl]p?)\\b/i],[[g,"armhf"]],[/windows (ce|mobile); ppc;/i],[[g,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\\))/i],[[g,/ower/,"",W]],[/(sun4\\w)[;\\)]/i],[[g,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\\))|\\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\\b|pa-risc)/i],[[g,W]]],device:[[/\\b(sch-i[89]0\\d|shw-m380s|sm-[ptx]\\w{2,4}|gt-[pn]\\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[f,A],[m,w]],[/\\b((?:s[cgp]h|gt|sm)-\\w+|sc[g-]?[\\d]+a?|galaxy nexus)/i,/samsung[- ]([-\\w]+)/i,/sec-(sgh\\w+)/i],[d,[f,A],[m,h]],[/(?:\\/|\\()(ip(?:hone|od)[\\w, ]*)(?:\\/|;)/i],[d,[f,S],[m,h]],[/\\((ipad);[-\\w\\),; ]+apple/i,/applecoremedia\\/[\\w\\.]+ \\((ipad)/i,/\\b(ipad)\\d\\d?,\\d\\d?[;\\]].+ios/i],[d,[f,S],[m,w]],[/(macintosh);/i],[d,[f,S]],[/\\b(sh-?[altvz]?\\d\\d[a-ekm]?)/i],[d,[f,L],[m,h]],[/\\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\\d{2})\\b(?!.+d\\/s)/i],[d,[f,P],[m,w]],[/(?:huawei|honor)([-\\w ]+)[;\\)]/i,/\\b(nexus 6p|\\w{2,4}e?-[atu]?[ln][\\dx][012359c][adn]?)\\b(?!.+d\\/s)/i],[d,[f,P],[m,h]],[/\\b(poco[\\w ]+)(?: bui|\\))/i,/\\b; (\\w+) build\\/hm\\1/i,/\\b(hm[-_ ]?note?[_ ]?(?:\\d\\w)?) bui/i,/\\b(redmi[\\-_ ]?(?:note|k)?[\\w_ ]+)(?: bui|\\))/i,/\\b(mi[-_ ]?(?:a\\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\\d?\\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\\))/i],[[d,/_/g," "],[f,R],[m,h]],[/\\b(mi[-_ ]?(?:pad)(?:[\\w_ ]+))(?: bui|\\))/i],[[d,/_/g," "],[f,R],[m,w]],[/; (\\w+) bui.+ oppo/i,/\\b(cph[12]\\d{3}|p(?:af|c[al]|d\\w|e[ar])[mt]\\d0|x9007|a101op)\\b/i],[d,[f,"OPPO"],[m,h]],[/vivo (\\w+)(?: bui|\\))/i,/\\b(v[12]\\d{3}\\w?[at])(?: bui|;)/i],[d,[f,"Vivo"],[m,h]],[/\\b(rmx[12]\\d{3})(?: bui|;|\\))/i],[d,[f,"Realme"],[m,h]],[/\\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\\b[\\w ]+build\\//i,/\\bmot(?:orola)?[- ](\\w*)/i,/((?:moto[\\w\\(\\) ]+|xt\\d{3,4}|nexus 6)(?= bui|\\)))/i],[d,[f,C],[m,h]],[/\\b(mz60\\d|xoom[2 ]{0,2}) build\\//i],[d,[f,C],[m,w]],[/((?=lg)?[vl]k\\-?\\d{3}) bui| 3\\.[-\\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[f,M],[m,w]],[/(lm(?:-?f100[nv]?|-[\\w\\.]+)(?= bui|\\))|nexus [45])/i,/\\blg[-e;\\/ ]+((?!browser|netcast|android tv)\\w+)/i,/\\blg-?([\\d\\w]+) bui/i],[d,[f,M],[m,h]],[/(ideatab[-\\w ]+)/i,/lenovo ?(s[56]000[-\\w]+|tab(?:[\\w ]+)|yt[-\\d\\w]{6}|tb[-\\d\\w]{6})/i],[d,[f,"Lenovo"],[m,w]],[/(?:maemo|nokia).*(n900|lumia \\d+)/i,/nokia[-_ ]?([-\\w\\.]*)/i],[[d,/_/g," "],[f,"Nokia"],[m,h]],[/(pixel c)\\b/i],[d,[f,I],[m,w]],[/droid.+; (pixel[\\daxl ]{0,6})(?: bui|\\))/i],[d,[f,I],[m,h]],[/droid.+ (a?\\d[0-2]{2}so|[c-g]\\d{4}|so[-gl]\\w+|xq-a\\w[4-7][12])(?= bui|\\).+chrome\\/(?![1-6]{0,1}\\d\\.))/i],[d,[f,U],[m,h]],[/sony tablet [ps]/i,/\\b(?:sony)?sgp\\w+(?: bui|\\))/i],[[d,"Xperia Tablet"],[f,U],[m,w]],[/ (kb2005|in20[12]5|be20[12][59])\\b/i,/(?:one)?(?:plus)? (a\\d0\\d\\d)(?: b|\\))/i],[d,[f,"OnePlus"],[m,h]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\\))/i,/(kf[a-z]+)( bui|\\)).+silk\\//i],[d,[f,_],[m,w]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\\)).+silk\\//i],[[d,/(.+)/g,"Fire Phone $1"],[f,_],[m,h]],[/(playbook);[-\\w\\),; ]+(rim)/i],[d,f,[m,w]],[/\\b((?:bb[a-f]|st[hv])100-\\d)/i,/\\(bb10; (\\w+)/i],[d,[f,x],[m,h]],[/(?:\\b|asus_)(transfo[prime ]{4,10} \\w+|eeepc|slider \\w+|nexus 7|padfone|p00[cj])/i],[d,[f,E],[m,w]],[/ (z[bes]6[027][012][km][ls]|zenfone \\d\\w?)\\b/i],[d,[f,E],[m,h]],[/(nexus 9)/i],[d,[f,"HTC"],[m,w]],[/(htc)[-;_ ]{1,2}([\\w ]+(?=\\)| bui)|\\w+)/i,/(zte)[- ]([\\w ]+?)(?: bui|\\/|\\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\\.))|sony(?!-bra))[-_ ]?([-\\w]*)/i],[f,[d,/_/g," "],[m,h]],[/droid.+; ([ab][1-7]-?[0178a]\\d\\d?)/i],[d,[f,"Acer"],[m,w]],[/droid.+; (m[1-5] note) bui/i,/\\bmz-([-\\w]{2,})/i],[d,[f,"Meizu"],[m,h]],[/(blackberry|benq|palm(?=\\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\\w]*)/i,/(hp) ([\\w ]+\\w)/i,/(asus)-?(\\w+)/i,/(microsoft); (lumia[\\w ]+)/i,/(lenovo)[-_ ]?([-\\w]+)/i,/(jolla)/i,/(oppo) ?([\\w ]+) bui/i],[f,d,[m,h]],[/(kobo)\\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\\/([\\w\\.]+)/i,/(nook)[\\w ]+build\\/(\\w+)/i,/(dell) (strea[kpr\\d ]*[\\dko])/i,/(le[- ]+pan)[- ]+(\\w{1,9}) bui/i,/(trinity)[- ]*(t\\d{3}) bui/i,/(gigaset)[- ]+(q\\w{1,9}) bui/i,/(vodafone) ([\\w ]+)(?:\\)| bui)/i],[f,d,[m,w]],[/(surface duo)/i],[d,[f,B],[m,w]],[/droid [\\d\\.]+; (fp\\du?)(?: b|\\))/i],[d,[f,"Fairphone"],[m,h]],[/(u304aa)/i],[d,[f,"AT&T"],[m,h]],[/\\bsie-(\\w*)/i],[d,[f,"Siemens"],[m,h]],[/\\b(rct\\w+) b/i],[d,[f,"RCA"],[m,w]],[/\\b(venue[\\d ]{2,7}) b/i],[d,[f,"Dell"],[m,w]],[/\\b(q(?:mv|ta)\\w+) b/i],[d,[f,"Verizon"],[m,w]],[/\\b(?:barnes[& ]+noble |bn[rt])([\\w\\+ ]*) b/i],[d,[f,"Barnes & Noble"],[m,w]],[/\\b(tm\\d{3}\\w+) b/i],[d,[f,"NuVision"],[m,w]],[/\\b(k88) b/i],[d,[f,"ZTE"],[m,w]],[/\\b(nx\\d{3}j) b/i],[d,[f,"ZTE"],[m,h]],[/\\b(gen\\d{3}) b.+49h/i],[d,[f,"Swiss"],[m,h]],[/\\b(zur\\d{3}) b/i],[d,[f,"Swiss"],[m,w]],[/\\b((zeki)?tb.*\\b) b/i],[d,[f,"Zeki"],[m,w]],[/\\b([yr]\\d{2}) b/i,/\\b(dragon[- ]+touch |dt)(\\w{5}) b/i],[[f,"Dragon Touch"],d,[m,w]],[/\\b(ns-?\\w{0,9}) b/i],[d,[f,"Insignia"],[m,w]],[/\\b((nxa|next)-?\\w{0,9}) b/i],[d,[f,"NextBook"],[m,w]],[/\\b(xtreme\\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[f,"Voice"],d,[m,h]],[/\\b(lvtel\\-)?(v1[12]) b/i],[[f,"LvTel"],d,[m,h]],[/\\b(ph-1) /i],[d,[f,"Essential"],[m,h]],[/\\b(v(100md|700na|7011|917g).*\\b) b/i],[d,[f,"Envizen"],[m,w]],[/\\b(trio[-\\w\\. ]+) b/i],[d,[f,"MachSpeed"],[m,w]],[/\\btu_(1491) b/i],[d,[f,"Rotor"],[m,w]],[/(shield[\\w ]+) b/i],[d,[f,"Nvidia"],[m,w]],[/(sprint) (\\w+)/i],[f,d,[m,h]],[/(kin\\.[onetw]{3})/i],[[d,/\\./g," "],[f,B],[m,h]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\\)/i],[d,[f,q],[m,w]],[/droid.+; (ec30|ps20|tc[2-8]\\d[kx])\\)/i],[d,[f,q],[m,h]],[/smart-tv.+(samsung)/i],[f,[m,y]],[/hbbtv.+maple;(\\d+)/i],[[d,/^/,"SmartTV"],[f,A],[m,y]],[/(nux; netcast.+smarttv|lg (netcast\\.tv-201\\d|android tv))/i],[[f,M],[m,y]],[/(apple) ?tv/i],[f,[d,S+" TV"],[m,y]],[/crkey/i],[[d,j+"cast"],[f,I],[m,y]],[/droid.+aft(\\w)( bui|\\))/i],[d,[f,_],[m,y]],[/\\(dtv[\\);].+(aquos)/i,/(aquos-tv[\\w ]+)\\)/i],[d,[f,L],[m,y]],[/(bravia[\\w ]+)( bui|\\))/i],[d,[f,U],[m,y]],[/(mitv-\\w{5}) bui/i],[d,[f,R],[m,y]],[/Hbbtv.*(technisat) (.*);/i],[f,d,[m,y]],[/\\b(roku)[\\dx]*[\\)\\/]((?:dvp-)?[\\d\\.]*)/i,/hbbtv\\/\\d+\\.\\d+\\.\\d+ +\\([\\w\\+ ]*; *([\\w\\d][^;]*);([^;]*)/i],[[f,H],[d,H],[m,y]],[/\\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\\b/i],[[m,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[f,d,[m,b]],[/droid.+; (shield) bui/i],[d,[f,"Nvidia"],[m,b]],[/(playstation [345portablevi]+)/i],[d,[f,U],[m,b]],[/\\b(xbox(?: one)?(?!; xbox))[\\); ]/i],[d,[f,B],[m,b]],[/((pebble))app/i],[f,d,[m,T]],[/(watch)(?: ?os[,\\/]|\\d,\\d\\/)[\\d\\.]+/i],[d,[f,S],[m,T]],[/droid.+; (glass) \\d/i],[d,[f,I],[m,T]],[/droid.+; (wt63?0{2,3})\\)/i],[d,[f,q],[m,T]],[/(quest( 2| pro)?)/i],[d,[f,F],[m,T]],[/(tesla)(?: qtcarbrowser|\\/[-\\w\\.]+)/i],[f,[m,k]],[/(aeobc)\\b/i],[d,[f,_],[m,k]],[/droid .+?; ([^;]+?)(?: bui|\\) applew).+? mobile safari/i],[d,[m,h]],[/droid .+?; ([^;]+?)(?: bui|\\) applew).+?(?! mobile) safari/i],[d,[m,w]],[/\\b((tablet|tab)[;\\/]|focus\\/\\d(?!.+mobile))/i],[[m,w]],[/(phone|mobile(?:[;\\/]| [ \\w\\/\\.]*safari)|pda(?=.+windows ce))/i],[[m,h]],[/(android[-\\w\\. ]{0,9});.+buil/i],[d,[f,"Generic"]]],engine:[[/windows.+ edge\\/([\\w\\.]+)/i],[v,[p,"EdgeHTML"]],[/webkit\\/537\\.36.+chrome\\/(?!27)([\\w\\.]+)/i],[v,[p,"Blink"]],[/(presto)\\/([\\w\\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\\/([\\w\\.]+)/i,/ekioh(flow)\\/([\\w\\.]+)/i,/(khtml|tasman|links)[\\/ ]\\(?([\\w\\.]+)/i,/(icab)[\\/ ]([23]\\.[\\d\\.]+)/i,/\\b(libweb)/i],[p,v],[/rv\\:([\\w\\.]{1,9})\\b.+(gecko)/i],[v,p]],os:[[/microsoft (windows) (vista|xp)/i],[p,v],[/(windows) nt 6\\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\\/ ]?([\\d\\.\\w ]*)/i,/(windows)[\\/ ]?([ntce\\d\\. ]+\\w)(?!.+xbox)/i],[p,[v,J,X]],[/(win(?=3|9|n)|win 9x )([nt\\d\\.]+)/i],[[p,"Windows"],[v,J,X]],[/ip[honead]{2,4}\\b(?:.*os ([\\w]+) like mac|; opera)/i,/ios;fbsv\\/([\\d\\.]+)/i,/cfnetwork\\/.+darwin/i],[[v,/_/g,"."],[p,"iOS"]],[/(mac os x) ?([\\w\\. ]*)/i,/(macintosh|mac_powerpc\\b)(?!.+haiku)/i],[[p,K],[v,/_/g,"."]],[/droid ([\\w\\.]+)\\b.+(android[- ]x86|harmonyos)/i],[v,p],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\\/ ]?([\\w\\.]*)/i,/(blackberry)\\w*\\/([\\w\\.]*)/i,/(tizen|kaios)[\\/ ]([\\w\\.]+)/i,/\\((series40);/i],[p,v],[/\\(bb(10);/i],[v,[p,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\\/ ]?([\\w\\.]*)/i],[v,[p,"Symbian"]],[/mozilla\\/[\\d\\.]+ \\((?:mobile|tablet|tv|mobile; [\\w ]+); rv:.+ gecko\\/([\\w\\.]+)/i],[v,[p,N+" OS"]],[/web0s;.+rt(tv)/i,/\\b(?:hp)?wos(?:browser)?\\/([\\w\\.]+)/i],[v,[p,"webOS"]],[/watch(?: ?os[,\\/]|\\d,\\d\\/)([\\d\\.]+)/i],[v,[p,"watchOS"]],[/crkey\\/([\\d\\.]+)/i],[v,[p,j+"cast"]],[/(cros) [\\w]+(?:\\)| ([\\w\\.]+)\\b)/i],[[p,z],v],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\\/(\\d+\\.[\\w\\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\\);]+)/i,/\\b(joli|palm)\\b ?(?:os)?\\/?([\\w\\.]*)/i,/(mint)[\\/\\(\\) ]?(\\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\\/ ]?(?!chrom|package)([-\\w\\.]*)/i,/(hurd|linux) ?([\\w\\.]*)/i,/(gnu) ?([\\w\\.]*)/i,/\\b([-frentopcghs]{0,5}bsd|dragonfly)[\\/ ]?(?!amd|[ix346]{1,2}86)([\\w\\.]*)/i,/(haiku) (\\w+)/i],[p,v],[/(sunos) ?([\\w\\.\\d]*)/i],[[p,"Solaris"],v],[/((?:open)?solaris)[-\\/ ]?([\\w\\.]*)/i,/(aix) ((\\d)(?=\\.|\\)| )[\\w\\.])*/i,/\\b(beos|os\\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\\w\\.]*)/i],[p,v]]},Z=function(e,t){if(typeof e===c&&(t=e,e=a),!(this instanceof Z))return new Z(e,t).getResult();var n=typeof i!==s&&i.navigator?i.navigator:a,r=e||(n&&n.userAgent?n.userAgent:""),b=n&&n.userAgentData?n.userAgentData:a,y=t?function(e,t){var n={};for(var r in e)t[r]&&t[r].length%2==0?n[r]=t[r].concat(e[r]):n[r]=e[r];return n}(G,t):G,T=n&&n.userAgent==r;return this.getBrowser=function(){var e,t={};return t[p]=a,t[v]=a,V.call(t,r,y.browser),t[l]=typeof(e=t[v])===u?e.replace(/[^\\d\\.]/g,"").split(".")[0]:a,T&&n&&n.brave&&typeof n.brave.isBrave==o&&(t[p]="Brave"),t},this.getCPU=function(){var e={};return e[g]=a,V.call(e,r,y.cpu),e},this.getDevice=function(){var e={};return e[f]=a,e[d]=a,e[m]=a,V.call(e,r,y.device),T&&!e[m]&&b&&b.mobile&&(e[m]=h),T&&"Macintosh"==e[d]&&n&&typeof n.standalone!==s&&n.maxTouchPoints&&n.maxTouchPoints>2&&(e[d]="iPad",e[m]=w),e},this.getEngine=function(){var e={};return e[p]=a,e[v]=a,V.call(e,r,y.engine),e},this.getOS=function(){var e={};return e[p]=a,e[v]=a,V.call(e,r,y.os),T&&!e[p]&&b&&"Unknown"!=b.platform&&(e[p]=b.platform.replace(/chrome os/i,z).replace(/macos/i,K)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return r},this.setUA=function(e){return r=typeof e===u&&e.length>350?H(e,350):e,this},this.setUA(r),this};Z.VERSION="1.0.35",Z.BROWSER=$([p,v,l]),Z.CPU=$([g]),Z.DEVICE=$([d,f,m,b,h,y,w,T,k]),Z.ENGINE=Z.OS=$([p,v]),typeof t!==s?(e.exports&&(t=e.exports=Z),t.UAParser=Z):n.amdO?(r=function(){return Z}.call(t,n,t,e))===a||(e.exports=r):typeof i!==s&&(i.UAParser=Z);var Y=typeof i!==s&&(i.jQuery||i.Zepto);if(Y&&!Y.ua){var ee=new Z;Y.ua=ee.getResult(),Y.ua.get=function(){return ee.getUA()},Y.ua.set=function(e){ee.setUA(e);var t=ee.getResult();for(var n in t)Y.ua[n]=t[n]}}}("object"==typeof window?window:this)}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{ActionType:()=>f,AmplitudePlatformName:()=>g,AnalyticsEventImportance:()=>l,AnalyticsQueries:()=>e,AuthStatus:()=>b,ComponentType:()=>m,IThresholdTier:()=>Jt,MetricType:()=>d,PlatformName:()=>v,SessionActions:()=>h,SessionAutomatedEvents:()=>w,SessionRank:()=>y,SubjectType:()=>p,UserTypeCommerce:()=>c,UserTypeInsto:()=>i,UserTypeRetail:()=>t,UserTypeRetailBusinessBanking:()=>s,UserTypeRetailEmployeeInternal:()=>a,UserTypeRetailEmployeePersonal:()=>o,UserTypeWallet:()=>u,automatedEvents:()=>xn,automatedMappingConfig:()=>In,clearMarkEntry:()=>Vn,clearPerformanceMarkEntries:()=>Xn,config:()=>A,createEventConfig:()=>On,createNewSpan:()=>Ln,createNewTrace:()=>Un,device:()=>W,endPerfMark:()=>Jn,exposeExperiment:()=>wn,flushQueue:()=>or,generateUUID:()=>V,getAnalyticsHeaders:()=>sr,getReferrerData:()=>le,getTracingHeaders:()=>An,getTracingId:()=>Dn,getUrlHostname:()=>pe,getUrlParams:()=>me,getUrlPathname:()=>fe,getUserContext:()=>ar,identify:()=>Tn,identifyFlow:()=>xe,identity:()=>H,identityFlow:()=>Se,incrementUjNavigation:()=>an,init:()=>yn,initNextJsTrackPageview:()=>_n,initTrackPageview:()=>kn,isEventKeyFormatValid:()=>we,isSessionEnded:()=>pt,location:()=>re,logEvent:()=>$t,logMetric:()=>Ht,logPageView:()=>on,logTrace:()=>Rn,markNTBT:()=>tn,markStep:()=>nn,markStepOnce:()=>rn,onVisibilityChange:()=>ln,optIn:()=>En,optOut:()=>Sn,perfMark:()=>Wn,persistentData:()=>oe,postMessage:()=>K,recordSessionDuration:()=>pn,removeFromIdentifyFlow:()=>Ee,savePersistentData:()=>st,sendScheduledEvents:()=>Bt,setBreadcrumbs:()=>ie,setConfig:()=>U,setLocation:()=>ae,setPagePath:()=>ve,setPageview:()=>Kt,setPersistentData:()=>se,setSessionStart:()=>dt,setTime:()=>Ue,startPerfMark:()=>Hn,timeStone:()=>Le,useEventLogger:()=>Yn,useLogEventOnMount:()=>tr,usePerformanceMarks:()=>rr});let e=function(e){return e.fbclid="fbclid",e.gclid="gclid",e.msclkid="msclkid",e.ptclid="ptclid",e.ttclid="ttclid",e.utm_source="utm_source",e.utm_medium="utm_medium",e.utm_campaign="utm_campaign",e.utm_term="utm_term",e.utm_content="utm_content",e}({});const t=0,i=1,a=2,o=3,s=4,c=5,u=6;let l=function(e){return e.low="low",e.high="high",e}({}),d=function(e){return e.count="count",e.rate="rate",e.gauge="gauge",e.distribution="distribution",e.histogram="histogram",e}({}),p=function(e){return e.commerce_merchant="commerce_merchant",e.device="device",e.edp_fingerprint_id="edp_fingerprint_id",e.nft_user="nft_user",e.user="user",e.wallet_user="wallet_user",e.uuid="user_uuid",e}({}),m=function(e){return e.unknown="unknown",e.banner="banner",e.button="button",e.card="card",e.chart="chart",e.content_script="content_script",e.dropdown="dropdown",e.link="link",e.page="page",e.modal="modal",e.table="table",e.search_bar="search_bar",e.service_worker="service_worker",e.text="text",e.text_input="text_input",e.tray="tray",e.checkbox="checkbox",e.icon="icon",e}({}),f=function(e){return e.unknown="unknown",e.blur="blur",e.click="click",e.change="change",e.dismiss="dismiss",e.focus="focus",e.hover="hover",e.select="select",e.measurement="measurement",e.move="move",e.process="process",e.render="render",e.scroll="scroll",e.view="view",e.search="search",e.keyPress="keyPress",e}({}),v=function(e){return e.unknown="unknown",e.web="web",e.android="android",e.ios="ios",e.mobile_web="mobile_web",e.tablet_web="tablet_web",e.server="server",e.windows="windows",e.macos="macos",e.extension="extension",e}({}),g=function(e){return e.web="Web",e.ios="iOS",e.android="Android",e}({}),b=function(e){return e[e.notLoggedIn=0]="notLoggedIn",e[e.loggedIn=1]="loggedIn",e}({}),h=function(e){return e.ac="ac",e.af="af",e.ah="ah",e.al="al",e.am="am",e.ar="ar",e.as="as",e}({}),w=function(e){return e.pv="pv",e}({}),y=function(e){return e.xs="xs",e.s="s",e.m="m",e.l="l",e.xl="xl",e.xxl="xxl",e}({});const T="https://analytics-service-dev.cbhq.net",k=3e5,_=5e3,S="analytics-db",E="experiment-exposure-db",x="Analytics SDK:",O=Object.values(e),j="pageview",N="session_duration",I={navigationTiming:{eventName:"perf_navigation_timing"},redirectTime:{eventName:"perf_redirect_time"},RT:{eventName:"perf_redirect_time"},TTFB:{eventName:"perf_time_to_first_byte"},networkInformation:{eventName:"perf_network_information"},storageEstimate:{eventName:"perf_storage_estimate"},FCP:{eventName:"perf_first_contentful_paint"},FID:{eventName:"perf_first_input_delay"},LCP:{eventName:"perf_largest_contentful_paint"},CLS:{eventName:"perf_cumulative_layout_shift"},TBT:{eventName:"perf_total_blocking_time"},NTBT:{eventName:"perf_navigation_total_blocking_time"},INP:{eventName:"perf_interact_to_next_paint"},ET:{eventName:"perf_element_timing"},userJourneyStep:{eventName:"perf_user_journey_step"}},P="1",M="web";function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(this,arguments)}const C=/^(https?:\\/\\/)/;function D(e){return{eventsEndpoint:e+"/amp",metricsEndPoint:e+"/metrics",exposureEndpoint:e+"/track-exposures",tracesEndpoint:e+"/traces"}}const A=B({authCookie:"logged_in",amplitudeApiKey:"",batchEventsPeriod:_,batchEventsThreshold:30,batchMetricsPeriod:_,batchMetricsThreshold:30,batchTracesPeriod:_,batchTracesThreshold:30,headers:{},interactionManager:null,isAlwaysAuthed:!1,isProd:!1,isInternalApplication:!1,onError:(e,t)=>{console.error(x,e,t)},platform:v.unknown,projectName:"",ricTimeoutScheduleEvent:1e3,ricTimeoutSetDevice:500,showDebugLogging:!1,trackUserId:!1,version:null,apiEndpoint:T},D(T),{steps:{}}),L=[].reduce(((e,t)=>n=>e(t(n))),(e=>{if(!e.isProd)return e.isInternalApplication?(e.apiEndpoint="https://analytics-service-internal-dev.cbhq.net",B({},e,D(e.apiEndpoint))):e;const t=(e=>e.apiEndpoint?C.test(e.apiEndpoint)?e.apiEndpoint:`https://${e.apiEndpoint}`:e.isInternalApplication?"https://analytics-service-internal.cbhq.net":"https://as.coinbase.com")(e);return B({},e,{apiEndpoint:t},D(t))})),U=e=>{const{batchEventsThreshold:t,batchMetricsThreshold:n,batchTracesThreshold:r}=e,i=[t,n,r];for(const e of i)if((e||0)>30){console.warn("You are setting the threshhold for the batch limit to be greater than 30. This may cause request overload.");break}Object.assign(A,L(e))},R=[v.web,v.mobile_web,v.tablet_web];function q(){return"android"===A.platform}function F(){return"ios"===A.platform}function z(){return R.includes(A.platform)}function K(e){if(z()&&navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.controller)try{navigator.serviceWorker.controller.postMessage(e)}catch(e){e instanceof Error&&A.onError(e)}}var $=n(353),Q=n.n($);const W={amplitudeOSName:null,amplitudeOSVersion:null,amplitudeDeviceModel:null,amplitudePlatform:null,browserName:null,browserMajor:null,osName:null,userAgent:null,width:null,height:null},H={countryCode:null,deviceId:null,device_os:null,isOptOut:!1,languageCode:null,locale:null,jwt:null,session_lcc_id:null,userAgent:null,userId:null},V=e=>e?(e^16*Math.random()>>e/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,V),J=()=>A.isAlwaysAuthed||!!H.userId,X=()=>{const e={};return H.countryCode&&(e.country_code=H.countryCode),e},G=()=>{const{platform:e}=A;if(e===v.web)switch(!0){case window.matchMedia("(max-width: 560px)").matches:return v.mobile_web;case window.matchMedia("(max-width: 1024px, min-width: 561px)").matches:return v.tablet_web}return e},Z=()=>{var e,t,n,r,i;z()?("requestIdleCallback"in window?window.requestIdleCallback(ne,{timeout:A.ricTimeoutSetDevice}):ne(),W.amplitudePlatform=g.web,W.userAgent=(null==(e=window)||null==(e=e.navigator)?void 0:e.userAgent)||null,ee({height:null!=(t=null==(n=window)?void 0:n.innerHeight)?t:null,width:null!=(r=null==(i=window)?void 0:i.innerWidth)?r:null})):F()?(W.amplitudePlatform=g.ios,W.userAgent=H.userAgent,W.userAgent&&ne()):q()&&(W.userAgent=H.userAgent,W.amplitudePlatform=g.android,W.userAgent&&ne())},Y=e=>{Object.assign(H,e),z()&&K({identity:{isAuthed:!!H.userId,locale:H.locale||null}})},ee=e=>{W.height=e.height,W.width=e.width},te=()=>{U({platform:G()}),z()&&K({config:{platform:A.platform}})},ne=()=>{var e;performance.mark&&performance.mark("ua_parser_start");const t=new(Q())(null!=(e=W.userAgent)?e:"").getResult();W.browserName=t.browser.name||null,W.browserMajor=t.browser.major||null,W.osName=t.os.name||null,W.amplitudeOSName=W.browserName,W.amplitudeOSVersion=W.browserMajor,W.amplitudeDeviceModel=W.osName,K({device:{browserName:W.browserName,osName:W.osName}}),performance.mark&&(performance.mark("ua_parser_end"),performance.measure("ua_parser","ua_parser_start","ua_parser_end"))},re={breadcrumbs:[],initialUAAData:{},pageKey:"",pageKeyRegex:{},pagePath:"",prevPageKey:"",prevPagePath:""};function ie(e){Object.assign(re,{breadcrumbs:e})}function ae(e){Object.assign(re,e)}const oe={eventId:0,sequenceNumber:0,sessionId:0,lastEventTime:0,sessionStart:0,sessionUUID:null,userId:null,ac:0,af:0,ah:0,al:0,am:0,ar:0,as:0,pv:0};function se(e){Object.assign(oe,e)}function ce(){var e,t;return null!=(e=null==(t=document)?void 0:t.referrer)?e:""}function ue(){return ue=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ue.apply(this,arguments)}const le=()=>{const e=ce();if(!e)return{};const t=new URL(e);return t.hostname===pe()?{}:{referrer:e,referring_domain:t.hostname}},de=()=>{const e=new URLSearchParams(me()),t={};return O.forEach((n=>{e.has(n)&&(t[n]=(e.get(n)||"").toLowerCase())})),t},pe=()=>{var e;return(null==(e=window)||null==(e=e.location)?void 0:e.hostname)||""},me=()=>{var e;return(null==(e=window)||null==(e=e.location)?void 0:e.search)||""},fe=()=>{var e;return(null==(e=window)||null==(e=e.location)?void 0:e.pathname)||""},ve=()=>{const e=A.overrideWindowLocation?re.pagePath:fe()+me();e&&e!==re.pagePath&&(e!==re.pagePath&&ge(),re.pagePath=e,re.pageKeyRegex&&Object.keys(re.pageKeyRegex).some((e=>{if(re.pageKeyRegex[e].test(re.pagePath))return re.pageKey=e,!0})))},ge=()=>{if(z()){const e=ce();if(!re.prevPagePath&&e){const t=new URL(e);if(t.hostname===pe())return void(re.prevPagePath=t.pathname)}}re.prevPagePath=re.pagePath,re.prevPageKey=re.pageKey},be=e=>{z()&&Object.assign(e,z()?(Object.keys(re.initialUAAData).length>0||(new URLSearchParams(me()),re.initialUAAData=ue({},(()=>{const e={};return O.forEach((t=>{oe[t]&&(e[t]=oe[t])})),e})(),de(),le())),re.initialUAAData):re.initialUAAData)},he=/^[a-zd]+(_[a-zd]+)*$/;function we(e){return he.test(e)}function ye(){return ye=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ye.apply(this,arguments)}const Te=["action","component_type","component_name","context","logging_id"],ke=["num_non_hardware_accounts","ujs"],_e="ujs_",Se={};function Ee(e){e.forEach((e=>{ke.includes(e)&&delete Se[e]}))}function xe(e){var t;const n=Object.entries(e).reduce(((e,t)=>{const[n,r]=t;return!Te.includes(n)&&ke.includes(n)?we(n)?ye({},e,{[n]:r}):(A.onError(new Error("IdentityFlow property names must have snake case format"),{[n]:r}),e):e}),{});null!=(t=n.ujs)&&t.length&&(n.ujs=n.ujs.map((e=>`${_e}${e}`))),Object.assign(Se,n)}function Oe(){return A.platform!==v.unknown||(A.onError(new Error("SDK platform not initialized")),!1)}const je={eventsQueue:[],eventsScheduled:!1,metricsQueue:[],metricsScheduled:!1,tracesQueue:[],tracesScheduled:!1};function Ne(e){Object.assign(je,e)}const Ie={ac:0,af:0,ah:0,al:0,am:0,ar:0,as:0,pv:0,sqs:0},Pe={ac:20,af:5,ah:1,al:1,am:0,ar:10,as:20},Me={pv:25},Be={xs:0,s:1,m:1,l:2,xl:2,xxl:2},Ce=e=>e<15?y.xs:e<60?y.s:e<240?y.m:e<960?y.l:e<3840?y.xl:y.xxl,De=e=>{Object.assign(Ie,e)};function Ae(){return(new Date).getTime()}const Le={timeStart:Ae(),timeOnPagePath:0,timeOnPageKey:0,prevTimeOnPagePath:0,prevTimeOnPageKey:0,sessionDuration:0,sessionEnd:0,sessionStart:0,prevSessionDuration:0};function Ue(e){Object.assign(Le,e)}const Re=(e,t)=>t.some((t=>e instanceof t));let qe,Fe;const ze=new WeakMap,Ke=new WeakMap,$e=new WeakMap,Qe=new WeakMap,We=new WeakMap;let He={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return Ke.get(e);if("objectStoreNames"===t)return e.objectStoreNames||$e.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Je(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function Ve(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(Fe||(Fe=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(Xe(this),e),Je(ze.get(this))}:function(...e){return Je(t.apply(Xe(this),e))}:function(e,...n){const r=t.call(Xe(this),e,...n);return $e.set(r,e.sort?e.sort():[e]),Je(r)}:(e instanceof IDBTransaction&&function(e){if(Ke.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",a),e.removeEventListener("abort",a)},i=()=>{t(),r()},a=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",a),e.addEventListener("abort",a)}));Ke.set(e,t)}(e),Re(e,qe||(qe=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,He):e);var t}function Je(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",a)},i=()=>{t(Je(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",a)}));return t.then((t=>{t instanceof IDBCursor&&ze.set(t,e)})).catch((()=>{})),We.set(t,e),t}(e);if(Qe.has(e))return Qe.get(e);const t=Ve(e);return t!==e&&(Qe.set(e,t),We.set(t,e)),t}const Xe=e=>We.get(e),Ge=["get","getKey","getAll","getAllKeys","count"],Ze=["put","add","delete","clear"],Ye=new Map;function et(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(Ye.get(t))return Ye.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=Ze.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!Ge.includes(n))return;const a=async function(e,...t){const a=this.transaction(e,i?"readwrite":"readonly");let o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]};return Ye.set(t,a),a}var tt;tt=He,He={...tt,get:(e,t,n)=>et(e,t)||tt.get(e,t,n),has:(e,t)=>!!et(e,t)||tt.has(e,t)};const nt={isReady:!1,idbKeyval:null};function rt(e){Object.assign(nt,e)}const it={},at=async e=>{if(!nt.idbKeyval)return Promise.resolve(null);try{return await nt.idbKeyval.get(e)}catch(e){return A.onError(new Error("IndexedDB:Get:InternalError")),Promise.resolve(null)}},ot=async(e,t)=>{if(nt.idbKeyval)try{await nt.idbKeyval.set(e,t)}catch(e){A.onError(new Error("IndexedDB:Set:InternalError"))}},st=()=>{"server"!==A.platform&&(se({sessionStart:Le.sessionStart,ac:Ie.ac,af:Ie.af,ah:Ie.ah,al:Ie.al,am:Ie.am,ar:Ie.ar,as:Ie.as,pv:Ie.pv}),H.userId&&se({userId:H.userId}),ot(S,oe))},ct="rgb(5,177,105)",ut=e=>{const{metricName:t,data:n}=e,r=e.importance||l.low;if(!A.showDebugLogging||!console)return;const i=`%c ${x}`,a=`color:${ct};font-size:11px;`,o=`Importance: ${r}`;console.group(i,a,t,o),n.forEach((e=>{e.event_type?console.log(e.event_type,e):console.log(e)})),console.groupEnd()},lt=e=>{const{metricName:t,data:n}=e,r=e.importance||l.low;if(!A.showDebugLogging||!console)return;const i=`color:${ct};font-size:11px;`,a=`%c ${x}`,o=`Importance: ${r}`;console.log(a,i,t,n,o)},dt=()=>{const e=Ae();oe.sessionId&&oe.lastEventTime&&oe.sessionUUID&&!pt(e)||(oe.sessionId=e,oe.sessionUUID=V(),Ue({sessionStart:e}),lt({metricName:"Started new session:",data:{persistentData:oe,timeStone:Le}})),oe.lastEventTime=e},pt=e=>e-oe.lastEventTime>18e5;function mt(){return mt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mt.apply(this,arguments)}const ft=e=>{var t;(e=>{switch(e.action){case f.click:Ie.ac+=1;break;case f.focus:Ie.af+=1;break;case f.hover:Ie.ah+=1;break;case f.move:Ie.am+=1;break;case f.scroll:Ie.al+=1;break;case f.search:Ie.ar+=1;break;case f.select:Ie.as+=1}})(t=e),t.event_type!==j?t.event_type===N&&((e=>{if(!e.session_rank)return;const t=e.session_rank;Object.values(h).forEach((e=>{Ie.sqs+=Ie[e]*Pe[e]})),Object.values(w).forEach((e=>{Ie.sqs+=Ie[e]*Me[e]})),Ie.sqs*=Be[t]})(t),Object.assign(t,Ie),De({ac:0,af:0,ah:0,al:0,am:0,ar:0,as:0,pv:0,sqs:0})):Ie.pv+=1;const n=e.event_type;delete e.event_type;const r=e.deviceId?e.deviceId:null,i=e.timestamp;return delete e.timestamp,se({eventId:oe.eventId+1}),se({sequenceNumber:oe.sequenceNumber+1}),dt(),st(),{device_id:H.deviceId||r||null,user_id:H.userId,timestamp:i,event_id:oe.eventId,session_id:oe.sessionId||-1,event_type:n,version_name:A.version||null,platform:W.amplitudePlatform,os_name:W.amplitudeOSName,os_version:W.amplitudeOSVersion,device_model:W.amplitudeDeviceModel,language:H.languageCode,event_properties:mt({},e,{session_uuid:oe.sessionUUID,height:W.height,width:W.width}),user_properties:X(),uuid:V(),library:{name:"@cbhq/client-analytics",version:"10.6.0"},sequence_number:oe.sequenceNumber,user_agent:W.userAgent||H.userAgent}},vt=e=>e.map((e=>ft(e)));function gt(){return gt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gt.apply(this,arguments)}const bt=e=>e.map((e=>(e=>{const t=e.tags||{},n=gt({authed:J()?"true":"false",platform:A.platform},t,{project_name:A.projectName,version_name:A.version||null});return{metric_name:e.metricName,page_path:e.pagePath||null,value:e.value,tags:n,type:e.metricType}})(e))),ht=e=>0!==je.metricsQueue.length&&(je.metricsQueue.length>=A.batchMetricsThreshold||(je.metricsScheduled||(je.metricsScheduled=!0,setTimeout((()=>{je.metricsScheduled=!1,e(bt(je.metricsQueue)),je.metricsQueue=[]}),A.batchMetricsPeriod)),!1)),wt=e=>0!==je.tracesQueue.length&&(je.tracesQueue.length>=A.batchTracesThreshold||(je.tracesScheduled||(je.tracesScheduled=!0,setTimeout((()=>{je.tracesScheduled=!1,e(je.tracesQueue),je.tracesQueue=[]}),A.batchTracesPeriod)),!1)),yt=e=>{var t;z()&&null!=(t=window)&&t.requestIdleCallback?window.requestIdleCallback(e,{timeout:A.ricTimeoutScheduleEvent}):(q()||F())&&A.interactionManager?A.interactionManager.runAfterInteractions(e):e()};function Tt(){return Tt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Tt.apply(this,arguments)}const kt="application/x-www-form-urlencoded; charset=UTF-8",_t=e=>{const{data:t,importance:n,isJSON:r,onError:i,url:a}=e,o=r?"application/json":kt,s=n||l.low,c=r?JSON.stringify(t):new URLSearchParams(t).toString();function u(){const e=new XMLHttpRequest;e.open("POST",a,!0),Object.keys(A.headers||{}).forEach((t=>{e.setRequestHeader(t,A.headers[t])})),e.setRequestHeader("Content-Type",kt),H.jwt&&e.setRequestHeader("authorization",`Bearer ${H.jwt}`),e.send(c)}if(!z()||r||!("sendBeacon"in navigator)||s!==l.low||A.headers&&0!==Object.keys(A.headers).length)if(z()&&!r)u();else{const e=Tt({},A.headers,{"Content-Type":o});H.jwt&&(e.Authorization=`Bearer ${H.jwt}`),fetch(a,{method:"POST",mode:"no-cors",headers:e,body:c}).catch((e=>{i(e,{context:"AnalyticsSDKApiError"})}))}else{const e=new Blob([c],{type:kt});try{navigator.sendBeacon.bind(navigator)(a,e)||u()}catch(e){console.error(e),u()}}};var St=n(762),Et=n.n(St);const xt=(e,t,n)=>{const r=e||"";return Et()("2"+r+t+n)};function Ot(){return Ot=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ot.apply(this,arguments)}class jt extends Error{constructor(e){super(e),this.name="CircularJsonReference",this.message=e,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack}}class Nt extends jt{constructor(...e){super(...e),this.name="DomReferenceInAnalyticsEvent"}}function It(){return It=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},It.apply(this,arguments)}const Pt=(e,t=l.low)=>{var n;e&&je.eventsQueue.push(e),nt.isReady&&(!A.trackUserId||H.userId?(t===l.high||(n=Mt,0!==je.eventsQueue.length&&(je.eventsQueue.length>=A.batchEventsThreshold||(je.eventsScheduled||(je.eventsScheduled=!0,setTimeout((()=>{je.eventsScheduled=!1,n(vt(je.eventsQueue)),je.eventsQueue=[]}),A.batchEventsPeriod)),0))))&&Bt():je.eventsQueue.length>10&&(A.trackUserId=!1,A.onError(new Error("userId not set in Logged-in"))))},Mt=(e,t=l.low)=>{if(H.isOptOut||0===e.length)return;let n;try{n=JSON.stringify(e)}catch(t){const r=e.map((e=>e.event_type)).join(", "),[i,a]=(e=>{try{const n=[];for(const r of e){const e=Ot({},r);r.event_properties&&(e.event_properties=Ot({},e.event_properties,{currentTarget:null,target:null,relatedTarget:null,_dispatchInstances:null,_targetInst:null,view:(t=r.event_properties.view,["string","number","boolean"].includes(typeof t)?r.event_properties.view:null)})),n.push(e)}return[!0,JSON.stringify(n)]}catch(e){return[!1,""]}var t})(e);if(!i)return void A.onError(new jt(t instanceof Error?t.message:"unknown"),{listEventType:r});n=a,A.onError(new Nt("Found DOM element reference"),{listEventType:r,stringifiedEventData:n})}const r=Ae().toString(),i=It({},{e:n,v:"2",upload_time:r},{client:A.amplitudeApiKey,checksum:xt(A.amplitudeApiKey,n,r)});_t({url:A.eventsEndpoint,data:i,importance:t,onError:A.onError}),ut({metricName:"Batch Events",data:e,importance:t})},Bt=()=>{Mt(vt(je.eventsQueue)),Ne({eventsQueue:[]})};function Ct(){return Ct=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ct.apply(this,arguments)}const Dt=Object.values(f),At=Object.values(m),Lt=e=>Dt.includes(e)?e:f.unknown,Ut=e=>At.includes(e)?e:m.unknown,Rt=(e,t,n)=>{const r={auth:J()?b.loggedIn:b.notLoggedIn,action:Lt(e),component_type:Ut(t),logging_id:n,platform:A.platform,project_name:A.projectName};return"number"==typeof H.userTypeEnum&&(r.user_type_enum=H.userTypeEnum),r},qt=e=>{const t=Ae();if(!e)return A.onError(new Error("missing logData")),Ct({},Rt(f.unknown,m.unknown),{locale:H.locale,session_lcc_id:H.session_lcc_id,timestamp:t,time_start:Le.timeStart});const n=Ct({},e,Rt(e.action,e.componentType,e.loggingId),{locale:H.locale,session_lcc_id:H.session_lcc_id,timestamp:t,time_start:Le.timeStart});return delete n.componentType,delete n.loggingId,n},Ft={blacklistRegex:[],isEnabled:!1};function zt(){return{page_key:re.pageKey,page_path:re.pagePath,prev_page_key:re.prevPageKey,prev_page_path:re.prevPagePath}}function Kt(e){Object.assign(Ft,e)}function $t(e,t,n=l.low){if(H.isOptOut)return;if(!Oe())return;const r=qt(t);!function(e){Ft.isEnabled&&(ve(),Object.assign(e,zt()))}(r),be(r),function(e){Object.keys(Se).length>0&&Object.assign(e,Se)}(r),r.has_double_fired=!1,r.event_type=e,n===l.high?Pt(r,n):yt((()=>{Pt(r)}))}function Qt(e,t=!1){t?_t({url:A.metricsEndPoint,data:{metrics:e},isJSON:!0,onError:A.onError}):yt((()=>{_t({url:A.metricsEndPoint,data:{metrics:e},isJSON:!0,onError:A.onError})})),ut({metricName:"Batch Metrics",data:e})}function Wt(){return Wt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Wt.apply(this,arguments)}function Ht(e){if(!Oe())return;v.server!==A.platform&&!e.pagePath&&re.pagePath&&(e.pagePath=re.pagePath);const t=Object.keys(Se).length?Wt({},e.tags,Se):e.tags;t&&Object.assign(e,{tags:t}),je.metricsQueue.push(e),ht(Qt)&&(Qt(bt(je.metricsQueue)),je.metricsQueue=[])}function Vt(){return Vt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Vt.apply(this,arguments)}let Jt=function(e){return e.instant="instant",e.quick="quick",e.moderate="moderate",e.slow="slow",e.unavoidable="unavoidable",e}({});function Xt(e){return e.toLowerCase()}let Gt={};const Zt=(e,t)=>{null!=A&&A.onMarkStep&&A.onMarkStep(e,t),xe({ujs:t})};let Yt;const en={Perfume:()=>{},markStep:e=>{},markStepOnce:e=>{},incrementUjNavigation:()=>{}},tn=()=>{z()&&Yt&&Yt.markNTBT&&Yt.markNTBT()},nn=e=>{z()&&Yt&&en.markStep&&en.markStep(e)},rn=e=>{z()&&Yt&&en.markStepOnce&&en.markStepOnce(e)},an=()=>{z()&&Yt&&en.incrementUjNavigation&&en.incrementUjNavigation()};function on(e={callMarkNTBT:!0}){"unknown"!==A.platform&&(Ft.blacklistRegex.some((e=>e.test(fe())))||($t(j,{action:f.render,componentType:m.page}),e.callMarkNTBT&&tn()))}let sn=!1,cn=!1;const un=e=>{sn=!e.persisted},ln=(e,t="hidden",n=!1)=>{cn||(addEventListener("pagehide",un),addEventListener("beforeunload",(()=>{})),cn=!0),addEventListener("visibilitychange",(({timeStamp:n})=>{document.visibilityState===t&&e({timeStamp:n,isUnloading:sn})}),{capture:!0,once:n})},dn=36e3;function pn(){const e=pt(Ae());if(e&&(O.forEach((e=>{oe[e]&&delete oe[e]})),st()),!oe.lastEventTime||!Le.sessionStart||!e)return;const t=Math.round((oe.lastEventTime-Le.sessionStart)/1e3);if(t<1||t>dn)return;const n=Ce(t);$t(N,{action:f.measurement,componentType:m.page,session_duration:t,session_end:oe.lastEventTime,session_start:Le.sessionStart,session_rank:n})}function mn(){return mn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mn.apply(this,arguments)}const fn=[],vn=[],gn=()=>{const e=fn.shift();e&&e()},bn=()=>{const e=vn.shift();e&&e()};let hn={};function wn(e){const t=function(e){return{test_name:e.testName,group_name:e.group,subject_id:e.subjectId,exposed_at:Ae(),subject_type:e.subjectType,platform:A.platform}}(e);hn[e.testName]=hn[e.testName]||0,hn[e.testName]+k>Ae()?lt({metricName:`Event: exposeExperiment ${e.testName} not sent`,data:t}):(hn[e.testName]=Ae(),ot(E,hn),lt({metricName:`Event: exposeExperiment ${e.testName} sent`,data:t}),_t({url:A.exposureEndpoint,data:[t],onError:(t,n)=>{hn[e.testName]=0,ot(E,hn),A.onError(t,n)},isJSON:!0,importance:l.high}))}const yn=e=>{var t,r,i;U(e),z()&&(H.languageCode=(null==(t=navigator)?void 0:t.languages[0])||(null==(r=navigator)?void 0:r.language)||""),te(),(()=>{var e;if(z()&&null!=(e=window)&&e.indexedDB){const e=function(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){const o=indexedDB.open(e,t),s=Je(o);return r&&o.addEventListener("upgradeneeded",(e=>{r(Je(o.result),e.oldVersion,e.newVersion,Je(o.transaction),e)})),n&&o.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),s.then((e=>{a&&e.addEventListener("close",(()=>a())),i&&e.addEventListener("versionchange",(e=>i(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),s}("keyval-store",1,{upgrade(e){e.createObjectStore("keyval")}});rt({idbKeyval:{get:async t=>(await e).get("keyval",t),set:async(t,n)=>(await e).put("keyval",n,t),delete:async t=>(await e).delete("keyval",t),keys:async()=>(await e).getAllKeys("keyval")}})}else rt({idbKeyval:{get:async e=>new Promise((t=>{t(it[e])})),set:async(e,t)=>new Promise((n=>{it[e]=t,n(e)})),delete:async e=>new Promise((()=>{delete it[e]})),keys:async()=>new Promise((e=>{e(Object.keys(it))}))}})})(),lt({metricName:"Initialized Analytics:",data:{deviceId:H.deviceId}}),fn.push((()=>{Pt()})),(async()=>{const e=await at(S);rt({isReady:!0}),gn(),e&&(bn(),se({eventId:e.eventId||oe.eventId,sequenceNumber:e.sequenceNumber||oe.sequenceNumber,sessionId:e.sessionId||oe.sessionId,lastEventTime:e.lastEventTime||oe.lastEventTime,sessionUUID:e.sessionUUID||oe.sessionUUID}),function(e){se(mn({},function(e){const t={};return O.forEach((n=>{e[n]&&(t[n]=e[n])})),t}(e),de()))}(e),Ue({sessionStart:e.sessionStart||oe.sessionStart}),De({ac:e.ac||Ie.ac,af:e.af||Ie.af,ah:e.ah||Ie.ah,al:e.al||Ie.al,am:e.am||Ie.am,ar:e.ar||Ie.ar,as:e.as||Ie.as,pv:e.pv||Ie.pv}),A.trackUserId&&Y({userId:e.userId||H.userId}),pn(),lt({metricName:"Initialized Analytics IndexedDB:",data:e}))})(),async function(){at(E).then((e=>{hn=null!=e?e:{}})).catch((e=>{e instanceof Error&&A.onError(e)}))}(),Z(),z()&&(ln((()=>{se({lastEventTime:Ae()}),st(),Bt()}),"hidden"),ln((()=>{pn()}),"visible")),z()&&(i=()=>{var e,t,n,r;te(),ee({width:null!=(e=null==(t=window)?void 0:t.innerWidth)?e:null,height:null!=(n=null==(r=window)?void 0:r.innerHeight)?n:null})},addEventListener("resize",(()=>{requestAnimationFrame((()=>{i()}))}))),(()=>{if(z())try{const e=n(2);en.markStep=e.markStep,en.markStepOnce=e.markStepOnce,en.incrementUjNavigation=e.incrementUjNavigation,Yt=new e.Perfume({analyticsTracker:e=>{const{data:t,attribution:n,metricName:r,navigatorInformation:i,rating:a}=e,o=I[r],s=(null==n?void 0:n.category)||null;if(!o&&!s)return;const c=(null==i?void 0:i.deviceMemory)||0,u=(null==i?void 0:i.hardwareConcurrency)||0,l=(null==i?void 0:i.isLowEndDevice)||!1,p=(null==i?void 0:i.isLowEndExperience)||!1,v=(null==i?void 0:i.serviceWorkerStatus)||"unsupported",g=Vt({deviceMemory:c,hardwareConcurrency:u,isLowEndDevice:l,isLowEndExperience:p,serviceWorkerStatus:v},Gt),b={is_low_end_device:l,is_low_end_experience:p,page_key:re.pageKey||"",save_data:t.saveData||!1,service_worker:v,is_perf_metric:!0};if("navigationTiming"===r)t&&"number"==typeof t.redirectTime&&Ht({metricName:I.redirectTime.eventName,metricType:d.histogram,tags:b,value:t.redirectTime||0});else if("TTFB"===r)$t(o.eventName,Vt({action:f.measurement,componentType:m.page,duration:t||null,vitalsScore:a||null},g)),Ht({metricName:I.TTFB.eventName,metricType:d.histogram,tags:Vt({},b),value:t}),a&&Ht({metricName:`perf_web_vitals_ttfb_${a}`,metricType:d.count,tags:b,value:1});else if("networkInformation"===r)null!=t&&t.effectiveType&&(Gt=t,$t(o.eventName,{action:f.measurement,componentType:m.page,networkInformationDownlink:t.downlink,networkInformationEffectiveType:t.effectiveType,networkInformationRtt:t.rtt,networkInformationSaveData:t.saveData,navigatorDeviceMemory:c,navigatorHardwareConcurrency:u}));else if("storageEstimate"===r)$t(o.eventName,Vt({action:f.measurement,componentType:m.page},t,g)),Ht({metricName:"perf_storage_estimate_caches",metricType:d.histogram,tags:b,value:t.caches}),Ht({metricName:"perf_storage_estimate_indexed_db",metricType:d.histogram,tags:b,value:t.indexedDB});else if("CLS"===r)$t(o.eventName,Vt({action:f.measurement,componentType:m.page,score:100*t||null,vitalsScore:a||null},g)),a&&Ht({metricName:`perf_web_vitals_cls_${a}`,metricType:d.count,tags:b,value:1});else if("FID"===r){const e=(null==n?void 0:n.performanceEntry)||null,r=parseInt((null==e?void 0:e.processingStart)||"");$t(o.eventName,Vt({action:f.measurement,componentType:m.page,duration:t||null,processingStart:null!=e&&e.processingStart?r:null,startTime:null!=e&&e.startTime?parseInt(e.startTime):null,vitalsScore:a||null},g)),a&&Ht({metricName:`perf_web_vitals_fidVitals_${a}`,metricType:d.count,tags:b,value:1})}else"userJourneyStep"===r?($t("perf_user_journey_step",Vt({action:f.measurement,componentType:m.page,duration:t||null,rating:null!=a?a:null,step_name:(null==n?void 0:n.stepName)||""},g)),Ht({metricName:`user_journey_step.${A.projectName}.${A.platform}.${(null==n?void 0:n.stepName)||""}_vitals_${a}`,metricType:d.count,tags:b,value:1}),Ht({metricName:`user_journey_step.${A.projectName}.${A.platform}.${(null==n?void 0:n.stepName)||""}`,metricType:d.distribution,tags:b,value:t||null})):I[r]&&t&&($t(o.eventName,Vt({action:f.measurement,componentType:m.page,duration:t||null,vitalsScore:a||null},g)),a&&(Ht({metricName:`perf_web_vitals_${Xt(r)}_${a}`,metricType:d.count,tags:b,value:1}),"LCP"===r&&Ht({metricName:`perf_web_vitals_${Xt(r)}`,metricType:d.distribution,tags:b,value:t})))},maxMeasureTime:3e4,steps:A.steps,onMarkStep:Zt})}catch(e){e instanceof Error&&A.onError(e)}})()},Tn=e=>{Y(e),e.userAgent&&Z(),lt({metricName:"Identify:",data:{countryCode:H.countryCode,deviceId:H.deviceId,userId:H.userId}})},kn=({blacklistRegex:e,pageKeyRegex:t,browserHistory:n})=>{Kt({blacklistRegex:e||[],isEnabled:!0}),ae({pageKeyRegex:t}),on({callMarkNTBT:!1}),n.listen((()=>{on()}))},_n=({blacklistRegex:e,pageKeyRegex:t,nextJsRouter:n})=>{Kt({blacklistRegex:e||[],isEnabled:!0}),ae({pageKeyRegex:t}),on({callMarkNTBT:!1}),n.events.on("routeChangeComplete",(()=>{on()}))},Sn=()=>{Y({isOptOut:!0}),ot(S,{})},En=()=>{Y({isOptOut:!1})},xn={Button:{label:"cb_button",uuid:"e921a074-40e6-4371-8700-134d5cd633e6",componentType:m.button}};function On(e,t,n){return{componentName:e,actions:t,data:n}}function jn(){return jn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},jn.apply(this,arguments)}function Nn(e,t,n){const{componentName:r,data:i}=n;$t(e.label,jn({componentType:e.componentType,action:t,loggingId:e.uuid,component_name:r},i))}const In={actionMapping:{onPress:f.click,onHover:f.hover},handlers:{Button:{[f.click]:e=>Nn(xn.Button,f.click,e),[f.hover]:e=>Nn(xn.Button,f.hover,e)}}};function Pn(e,t=!1){t?_t({url:A.tracesEndpoint,data:{traces:e},isJSON:!0,onError:A.onError}):yt((()=>{_t({url:A.tracesEndpoint,data:{traces:e},isJSON:!0,onError:A.onError})})),ut({metricName:"Batch Traces",data:e})}function Mn(){return Mn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Mn.apply(this,arguments)}const Bn=1e6;function Cn(e){return e*Bn}function Dn(e=function(){var e;return null==(e=window)?void 0:e.crypto}()){const t=new Uint32Array(2);return null==e||e.getRandomValues(t),((BigInt(t[0])<<BigInt(32))+BigInt(t[1])).toString()}function An(e,t){return{"x-datadog-origin":"rum","x-datadog-parent-id":t,"x-datadog-sampling-priority":"1","x-datadog-trace-id":e}}function Ln(e){var t;const{name:n,traceId:r,spanId:i,start:a,duration:o,resource:s,meta:c}=e;return{duration:o?Cn(o):0,name:n,resource:s,service:A.projectName,span_id:null!=i?i:Dn(),start:a?Cn(a):0,trace_id:null!=r?r:Dn(),parent_id:P,type:M,meta:Mn({platform:A.platform},re.pageKey?{page_key:re.pageKey}:{},null!=(t=Se.ujs)&&t.length?{last_ujs:Se.ujs[Se.ujs.length-1]}:{},null!=c?c:{})}}function Un(e){return[Ln(e)]}function Rn(e,t){Oe()&&function(e){return e.length>0}(e)&&(t&&function(e,t){e.forEach((e=>function(e,t){const n=Mn({},e.meta,t.meta),r={start:t.start?Cn(t.start):e.start,duration:t.duration?Cn(t.duration):e.duration};Object.assign(e,t,Mn({meta:n},r))}(e,t)))}(e,t),je.tracesQueue.push(e),wt(Pn)&&(Pn(je.tracesQueue),je.tracesQueue=[]))}function qn(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Fn.apply(this,arguments)}function zn(){return void 0!==typeof window&&"performance"in window&&"mark"in performance&&"getEntriesByName"in performance}function Kn(e,t){return`perf_${e}${null!=t&&t.label?`_${t.label}`:""}`}function $n(e,t,n){return`${Kn(e,n)}__${t}`}let Qn={};function Wn(e,t,n){if(!zn())return;const r=$n(e,t,n);if(performance.mark(r),"end"===t){const t=Kn(e,n);!function(e,t,n){try{performance.measure(e,t,n)}catch(e){A.onError(e)}}(t,$n(e,"start",n),r);const i=performance.getEntriesByName(t).pop();i&&Ht(Fn({metricName:e,metricType:d.distribution,value:i.duration},null!=n&&n.tags?{tags:n.tags}:{}))}}function Hn(e,t){if(!zn())return;const n=$n(e,"start",t);Qn[n]||(Wn(e,"start",t),Qn[n]=!0)}function Vn(e,t){const n=$n(e,"start",t),r=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(Qn,[n].map(qn));Qn=r}function Jn(e,t){if(!zn())return;const n=$n(e,"start",t);Qn[n]&&(Wn(e,"end",t),Vn(e,t))}function Xn(){zn()&&(performance.clearMarks(),Qn={})}var Gn=n(784);function Zn(){return Zn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Zn.apply(this,arguments)}function Yn(e,t,n=l.low){const r=(0,Gn.useRef)(t);return(0,Gn.useEffect)((()=>{r.current=t}),[t]),(0,Gn.useCallback)((t=>{$t(e,Zn({},r.current,t),n)}),[e,n])}function er(){return er=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},er.apply(this,arguments)}function tr(e,t,n=l.low){(0,Gn.useEffect)((()=>{const r=er({},t,{action:f.render});$t(e,r,n)}),[])}function nr(){return nr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nr.apply(this,arguments)}const rr=function(e,t){return{markStartPerf:(0,Gn.useCallback)((()=>Hn(e,t)),[e,t]),markEndPerf:(0,Gn.useCallback)((n=>Jn(e,nr({},t,n))),[e,t])}};function ir(){return ir=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ir.apply(this,arguments)}function ar(){return Object.entries(ir({},Se,zt(),{sessionUUID:oe.sessionUUID,userId:oe.userId})).reduce(((e,t)=>{return null!=(n=t[1])&&""!==n?ir({},e,{[t[0]]:t[1]}):e;var n}),{})}async function or(){return new Promise((e=>{Mt(vt(je.eventsQueue)),Qt(bt(je.metricsQueue),!0),Pn(je.tracesQueue,!0),Ne({eventsQueue:[],metricsQueue:[],tracesQueue:[]}),e()}))}function sr(){return{"X-CB-Device-ID":H.deviceId||"unknown","X-CB-Is-Logged-In":H.userId?"true":"false","X-CB-Pagekey":re.pageKey||"unknown","X-CB-UJS":(e=Se.ujs,void 0===e||0===e.length?"":e.join(",")),"X-CB-Platform":A.platform||"unknown","X-CB-Project-Name":A.projectName||"unknown","X-CB-Session-UUID":oe.sessionUUID||"unknown","X-CB-Version-Name":A.version?String(A.version):"unknown"};var e}})(),r})()}));',
3N0=()=>new Promise((e,t)=>{if(window.ClientAnalytics)return e();try{const n=document.createElement("script");n.textContent=$0,n.type="text/javascript",document.head.appendChild(n),M0(),document.head.removeChild(n),e()}catch{console.error("Failed to execute inlined telemetry script"),t()}}),M0=()=>{var e,t,n;if(typeof window<"u"){const r=(n=(e=L.config.get().deviceId)!==null&&e!==void 0?e:(t=window.crypto)===null||t===void 0?void 0:t.randomUUID())!==null&&n!==void 0?n:"";if(window.ClientAnalytics){const{init:s,identify:i,PlatformName:a}=window.ClientAnalytics;s({isProd:!0,amplitudeApiKey:"c66737ad47ec354ced777935b0af822e",platform:a.web,projectName:"base_account_sdk",showDebugLogging:!1,version:"1.0.0",apiEndpoint:"https://cca-lite.coinbase.com"}),i({deviceId:r}),L.config.set({deviceId:r})}}},se={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}},na={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},Kd="Unspecified error message.",R0="Unspecified server error.";function bo(e,t=Kd){if(e&&Number.isInteger(e)){const n=e.toString();if(ra(na,n))return na[n].message;if(Zd(e))return R0}return t}function j0(e){if(!Number.isInteger(e))return!1;const t=e.toString();return!!(na[t]||Zd(e))}function L0(e,{shouldIncludeStack:t=!1}={}){const n={};if(e&&typeof e=="object"&&!Array.isArray(e)&&ra(e,"code")&&j0(e.code)){const r=e;n.code=r.code,r.message&&typeof r.message=="string"?(n.message=r.message,ra(r,"data")&&(n.data=r.data)):(n.message=bo(n.code),n.data={originalError:Uc(e)})}else n.code=se.rpc.internal,n.message=Dc(e,"message")?e.message:Kd,n.data={originalError:Uc(e)};return t&&(n.stack=Dc(e,"stack")?e.stack:void 0),n}function Zd(e){return e>=-32099&&e<=-32e3}function Uc(e){return e&&typeof e=="object"&&!Array.isArray(e)?Object.assign({},e):e}function ra(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Dc(e,t){return typeof e=="object"&&e!==null&&t in e&&typeof e[t]=="string"}const j={rpc:{parse:e=>Le(se.rpc.parse,e),invalidRequest:e=>Le(se.rpc.invalidRequest,e),invalidParams:e=>Le(se.rpc.invalidParams,e),methodNotFound:e=>Le(se.rpc.methodNotFound,e),internal:e=>Le(se.rpc.internal,e),server:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code
3<= -32005');return Le(t,e)},invalidInput:e=>Le(se.rpc.invalidInput,e),resourceNotFound:e=>Le(se.rpc.resourceNotFound,e),resourceUnavailable:e=>Le(se.rpc.resourceUnavailable,e),transactionRejected:e=>Le(se.rpc.transactionRejected,e),methodNotSupported:e=>Le(se.rpc.methodNotSupported,e),limitExceeded:e=>Le(se.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>fn(se.provider.userRejectedRequest,e),unauthorized:e=>fn(se.provider.unauthorized,e),unsupportedMethod:e=>fn(se.provider.unsupportedMethod,e),disconnected:e=>fn(se.provider.disconnected,e),chainDisconnected:e=>fn(se.provider.chainDisconnected,e),unsupportedChain:e=>fn(se.provider.unsupportedChain,e),custom:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:n,data:r}=e;if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string');return new Jd(t,n,r)}}};function Le(e,t){const[n,r]=Yd(t);return new wo(e,n||bo(e),r)}function fn(e,t){const[n,r]=Yd(t);return new Jd(e,n||bo(e),r)}function Yd(e){if(e){if(typeof e=="string")return[e];if(typeof e=="object"&&!Array.isArray(e)){const{message:t,data:n}=e;
3if(t&&typeof t!="string")throw new Error("Must specify string message.");return[t||void 0,n]}}return[]}class wo extends Error{constructor(t,n,r){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string.');super(n),this.code=t,r!==void 0&&(this.data=r)}}class Jd extends wo{constructor(t,n,r){if(!U0(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,n,r)}}function U0(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}function zc(e){return typeof e=="object"&&e!==null&&"code"in e&&"data"in e&&e.code===-32090&&typeof e.data=="object"&&e.data!==null&&"type"in e.data&&e.data.type==="INSUFFICIENT_FUNDS"}function Qd(e){return typeof e=="object"&&e!==null&&"details"in e}function D0(e){try{const t=JSON.parse(e.details);return new wo(t.code,t.message,t.data)}catch{return null}}function Xd(){return e=>e}const rr=Xd(),z0=Xd();function mt(e){return Math.floor(e)}const el=/^[0-9]*$/,tl=/^[a-f0-9]*$/;function zt(e){return vo(crypto.getRandomValues(new Uint8Array(e)))}function vo(e){return[...e].map(t=>t.toString(16).padStart(2,"0")).join("")}function cs(e){return new Uint8Array(e.match(/.{1,2}/g).map(t=>Number.parseInt(t,16)))}function Zn(e,t=!1){const n=e.toString("hex");return rr(t?`0x${n}`:n)}function mi(e){return Zn(ia(e),!0)}function Xe(e){return z0(e.toString(10))}function yn(e){return rr(`0x${BigInt(e).toString(16)}`)}function nl(e){return e.startsWith("0x")||e.startsWith("0X")}function xo(e){return nl(e)?e.slice(2):e}function rl(e){return nl(e)?`0x${e.slice(2)}`:`0x${e}`}function Us(e){if(typeof e!="string")return!1;const t=xo(e).toLowerCase();return tl.test(t)}function sa(e,t=!1){if(typeof e=="string"){const n=xo(e).toLowerCase();if(tl.test(n))return rr(t?`0x${n}`:n)}throw j.rpc.invalidParams(`"${String(e)}" is not a hexadecimal string`)}function Eo(e,t=!1){let n=sa(e,!1);return n.length%2===1&&(n=rr(`0${n}`)),t?rr(`0x${n}`):n}function At(e){if(typeof e=="string"){const t=xo(e).toLowerCase();if(Us(t)&&t.length===40)return rl(t)}throw j.rpc.invalidParams(`Invalid Ethereum address: ${String(e)}`)}function ia(e){if(Q.isBuffer(e))return e;if(typeof e=="string"){if(Us(e)){const t=Eo(e,!1);return Q.from(t,"hex")}return Q.from(e,"utf8")}throw j.rpc.invalidParams(`Not binary data: ${String(e)}`)}function Yn(e){if(typeof e=="number"&&Number.isInteger(e))return mt(e);if(typeof e=="string"){if(el.test(e))return mt(Number(e));if(Us(e))return mt(Number(BigInt(Eo(e,!0))))}throw j.rpc.invalidParams(`Not an integer: ${String(e)}`)}function Hn(e){if(e!==null&&(typeof e=="bigint"||H0(e)))return BigInt(e.toString(10));if(typeof e=="number")return BigInt(Yn(e));if(typeof e=="string"){if(el.test(e))return BigInt(e);if(Us(e))return BigInt(Eo(e,!0))}throw j.rpc.invalidParams(`Not an integer: ${String(e)}`)}function F0(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw j.rpc.invalidParams(`Not a JSON string or an object: ${String(e)}`)}function H0(e){if(e==null||typeof e.constructor!="function")return!1;const{constructor:t}=e;return typeof t.config=="function"&&typeof t.EUCLID=="number"}const G0=`Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app. 4 5Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`,q0=()=>{let e;return{getCrossOriginOpenerPolicy:()=>e===void 0?"undefined":e,checkCrossOriginOpenerPolicy:async()=>{if(typeof window>"u"){e="non-browser-env";return}try{const t=`${window.location.origin}${window.location.pathname}`,n=await fetch(t,{method:"HEAD"});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=n.headers.get("Cross-Origin-Opener-Policy");e=r??"null",e==="same-origin"&&console.error(G0)}catch(t){console.error("Error checking Cross-Origin-Opener-Policy:",t.message),e="error"}}}},{checkCrossOriginOpenerPolicy:V0,getCrossOriginOpenerPolicy:W0}=q0();async function Jn(e,t){const n=Object.assign(Object.assign({},e),{jsonrpc:"2.0",id:crypto.randomUUID()}
5),r=await window.fetch(t,{method:"POST",body:JSON.stringify(n),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":Ln,"X-Cbw-Sdk-Platform":Vd}}),{result:s,error:i}=await r.json();if(i)throw i;return s}function K0(){return globalThis.coinbaseWalletExtension}function Z0(){var e,t;try{const n=globalThis;return(e=n.ethereum)!==null&&e!==void 0?e:(t=n.top)===null||t===void 0?void 0:t.ethereum}catch{return}}function Y0({metadata:e,preference:t}){var n,r;const{appName:s,appLogoUrl:i,appChainIds:a}=e;if(t.options!=="smartWalletOnly"){const c=K0();if(c)return(n=c.setAppInfo)===null||n===void 0||n.call(c,s,i,a,t),c}const o=Z0();if(o?.isCoinbaseBrowser)return(r=o.setAppInfo)===null||r===void 0||r.call(o,s,i,a,t),o}function J0(e){if(!e||typeof e!="object"||Array.isArray(e))throw j.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:e});const{method:t,params:n}=e;if(typeof t!="string"||t.length===0)throw j.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:e});if(n!==void 0&&!Array.isArray(n)&&(typeof n!="object"||n===null))throw j.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:e});switch(t){case"eth_sign":case"eth_signTypedData_v2":case"eth_subscribe":case"eth_unsubscribe":throw j.provider.unsupportedMethod()}}function Q0(e){if(e){if(!["all","smartWalletOnly","eoaOnly"].includes(e.options))throw new Error(`Invalid options: ${e.options}`);if(e.attribution&&e.attribution.auto!==void 0&&e.attribution.dataSuffix!==void 0)throw new Error("Attribution cannot contain both auto and dataSuffix properties");if(e.telemetry&&typeof e.telemetry!="boolean")throw new Error("Telemetry must be a boolean")}}function Fc(e){if(typeof e!="function")throw new Error("toAccount is not a function")}const X0="https://keys.coinbase.com/connect",sl="https://rpc.wallet.coinbase.com",Hc="https://www.walletlink.org",em="https://go.cb-w.com/walletlink";var G;(function(e){e.unknown="unknown",e.banner="banner",e.button="button",e.card="card",e.chart="chart",e.content_script="content_script",e.dropdown="dropdown",e.link="link",e.page="page",e.modal="modal",e.table="table",e.search_bar="search_bar",e.service_worker="service_worker",e.text="text",e.text_input="text_input",e.tray="tray",e.checkbox="checkbox",e.icon="icon"})(G||(G={}));var q;(function(e){e.unknown="unknown",e.blur="blur",e.click="click",e.change="change",e.dismiss="dismiss",e.focus="focus",e.hover="hover",e.select="select",e.measurement="measurement",e.move="move",e.process="process",e.render="render",e.scroll="scroll",e.view="view",e.search="search",e.keyPress="keyPress",e.error="error"})(q||(q={}));var V;(function(e){e.low="low",e.high="high"})(V||(V={}));function W(e,t,n){var r,s,i,a;window.ClientAnalytics&&((r=window.ClientAnalytics)===null||r===void 0||r.logEvent(e,Object.assign(Object.assign({},t),{sdkVersion:Ln,appName:(i=(s=L.config.get().metadata)===null||s===void 0?void 0:s.appName)!==null&&i!==void 0?i:"",appOrigin:window.location.origin,appPreferredSigner:(a=L.config.get().preference)===null||a===void 0?void 0:a.options}),n))}const tm=()=>{W("communicator.popup_setup.started",{action:q.unknown,componentType:G.unknown},V.high)},nm=()=>{W("communicator.popup_setup.completed",{action:q.unknown,componentType:G.unknown},V.high)},rm=()=>{W("communicator.popup_unload.received",{action:q.unknown,componentType:G.unknown},V.high)},_o=({snackbarContext:e})=>{W(`snackbar.${e}.shown`,{action:q.render,componentType:G.modal,snackbarContext:e},V.high)},vn=({snackbarContext:e,snackbarAction:t})=>{W(`snackbar.${e}.action_clicked`,{action:q.click,componentType:G.button,snackbarContext:e,snackbarAction:t},V.high)},sm='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';function il(){const e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode(sm)),document.documentElement.appendChild(e)}function im(){try{return window.frameElement!==null}catch{return!1}}function am(){try{return im()&&window.top?window.top.location:window.location}catch{return window.location}}function om(){var e;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((e=window?.navigator)===null||e===void 0?void 0:e.userAgent)}function al(){var e,t;return(t=(e=window?.matchMedia)===null||e===void 0?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)!==null&&t!==void 0?t:!1}const cm=".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;
5cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}",um="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",dm="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class ol{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=al()}attach(t){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",t.appendChild(this.root),this.render()}presentItem(t){const n=this.nextItemKey++;return this.items.set(n,t),this.render(),()=>{this.items.delete(n),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&Xi(J("div",null,J(cl,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([t,n])=>J(lm,Object.assign({},n,{key:t}
5))))),this.root)}}const cl=e=>J("div",{class:Kn("-cbwsdk-snackbar-container")},J("style",null,cm),J("div",{class:"-cbwsdk-snackbar"},e.children)),lm=({autoExpand:e,message:t,menuItems:n})=>{const[r,s]=jc(!0),[i,a]=jc(e??!1);m0(()=>{const c=[window.setTimeout(()=>{s(!1)},1),window.setTimeout(()=>{a(!0)},1e4)];return()=>{c.forEach(window.clearTimeout)}});const o=()=>{a(!i)};return J("div",{class:Kn("-cbwsdk-snackbar-instance",r&&"-cbwsdk-snackbar-instance-hidden",i&&"-cbwsdk-snackbar-instance-expanded")},J("div",{class:"-cbwsdk-snackbar-instance-header",onClick:o},J("img",{src:um,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",J("div",{class:"-cbwsdk-snackbar-instance-header-message"},t),J("div",{class:"-gear-container"},!i&&J("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),J("img",{src:dm,class:"-gear-icon",title:"Expand"}))),n&&n.length>0&&J("div",{class:"-cbwsdk-snackbar-instance-menu"},n.map((c,u)=>J("div",{class:Kn("-cbwsdk-snackbar-instance-menu-item",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:c.onClick,key:u},J("svg",{width:c.svgWidth,height:c.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J("path",{"fill-rule":c.defaultFillRule,"clip-rule":c.defaultClipRule,d:c.path,fill:"#AAAAAA"})),J("span",{class:Kn("-cbwsdk-snackbar-instance-menu-item-info",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},c.info)))))},ul="M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z";class fm{constructor(){this.attached=!1,this.snackbar=new ol}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const t=document.documentElement,n=document.createElement("div");n.className="-cbwsdk-css-reset",t.appendChild(n),this.snackbar.attach(n),this.attached=!0,il()}showConnecting(t){let n;return t.isUnlinkedErrorState?n={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:t.onResetConnection}]}:n={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:t.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:ul,defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:t.onResetConnection}]},this.snackbar.presentItem(n)}}const Gc=420,qc=700,pm={isRed:!1,info:"Retry",svgWidth:"10",svgHeight:"11",path:ul,defaultFillRule:"evenodd",defaultClipRule:"evenodd"},hm="Popup was blocked. Try again.";let Fr=null;function mm(e){const t=(window.innerWidth-Gc)/2+window.screenX,n=(window.innerHeight-qc)/2+window.screenY;gm(e);function r(){const i=`wallet_${crypto.randomUUID()}`,a=window.open(e,i,`width=${Gc}, height=${qc}, left=${t}, top=${n}`);return a?.focus(),a||null}let s=r();if(!s){const i=So();return new Promise((a,o)=>{_o({snackbarContext:"popup_blocked"}),i.presentItem({autoExpand:!0,message:hm,menuItems:[Object.assign(Object.assign({},pm),{onClick:()=>{vn({snackbarContext:"popup_blocked",snackbarAction:"confirm"}),s=r(),s?a(s):o(j.rpc.internal("Popup window was blocked")),i.clear()}})]})})}return Promise.resolve(s)}function ym(e){e&&!e.closed&&e.close()}function gm(e){const t={sdkName:Vd,sdkVersion:Ln,origin:window.location.origin,coop:W0()};for(const[n,r]of Object.entries(t))e.searchParams.has(n)||e.searchParams.append(n,r.toString())}
5function So(){if(!Fr){const e=document.createElement("div");e.className="-cbwsdk-css-reset",document.body.appendChild(e),Fr=new ol,Fr.attach(e)}return Fr}class bm{constructor({url:t=X0,metadata:n,preference:r}){this.popup=null,this.listeners=new Map,this.postMessage=async s=>{(await this.waitForPopupLoaded()).postMessage(s,this.url.origin)},this.postRequestAndWaitForResponse=async s=>{const i=this.onMessage(({requestId:a})=>a===s.id);return this.postMessage(s),await i},this.onMessage=async s=>new Promise((i,a)=>{const o=c=>{if(c.origin!==this.url.origin)return;const u=c.data;s(u)&&(i(u),window.removeEventListener("message",o),this.listeners.delete(o))};window.addEventListener("message",o),this.listeners.set(o,{reject:a})}),this.disconnect=()=>{ym(this.popup),this.popup=null,this.listeners.forEach(({reject:s},i)=>{s(j.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",i)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(tm(),this.popup=await mm(this.url),this.onMessage(({event:s})=>s==="PopupUnload").then(()=>{this.disconnect(),rm()}).catch(()=>{}),this.onMessage(({event:s})=>s==="PopupLoaded").then(s=>{this.postMessage({requestId:s.id,data:{version:Ln,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw j.rpc.internal();return nm(),this.popup})),this.url=new URL(t),this.metadata=n,this.preference=r}}function ye(e){return e.errorMessage!==void 0}function wm(e){const t=L0(vm(e),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return n.searchParams.set("version",Ln),n.searchParams.set("code",t.code.toString()),n.searchParams.set("message",t.message),Object.assign(Object.assign({},t),{docUrl:n.href})}function vm(e){var t;if(typeof e=="string")return{message:e,code:se.rpc.internal};if(ye(e)){const n=e.errorMessage,r=(t=e.errorCode)!==null&&t!==void 0?t:n.match(/(denied|rejected)/i)?se.provider.userRejectedRequest:void 0;return Object.assign(Object.assign({},e),{message:n,code:r,data:{method:e.method}})}return e}class xm extends fh{}class Qt{constructor(t,n){this.scope=t,this.module=n}storeObject(t,n){this.setItem(t,JSON.stringify(n))}loadObject(t){const n=this.getItem(t);return n?JSON.parse(n):void 0}setItem(t,n){localStorage.setItem(this.scopedKey(t),n)}getItem(t){return localStorage.getItem(this.scopedKey(t))}removeItem(t){localStorage.removeItem(this.scopedKey(t))}clear(){const t=this.scopedKey(""),n=[];for(let r=0;r<localStorage.length;r++){const s=localStorage.key(r);typeof s=="string"&&s.startsWith(t)&&n.push(s)}n.forEach(r=>localStorage.removeItem(r))}scopedKey(t){return`-${this.scope}${this.module?`:${this.module}`:""}:${t}`}static clearAll(){new Qt("CBWSDK").clear(),new Qt("walletlink").clear()}}const Em=({signerType:e})=>{W("provider.signer.loaded_from_storage",{action:q.measurement,componentType:G.unknown,signerType:e},V.low)},_m=({method:e,correlationId:t})=>{W("provider.request.started",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t},V.high)},Sm=({method:e,correlationId:t,signerType:n,errorMessage:r})=>{W("provider.request.error",{action:q.error,componentType:G.unknown,method:e,signerType:n,correlationId:t,errorMessage:r},V.high)},Am=({method:e,signerType:t,correlationId:n})=>{W("provider.request.responded",{action:q.unknown,componentType:G.unknown,method:e,signerType:t,correlationId:n},V.high)},km=()=>{W("provider.enable_function.called",{action:q.measurement,componentType:G.unknown},V.high)},Im=()=>{W("signer.selection.requested",{action:q.unknown,componentType:G.unknown},V.high)},Pm=e=>{W("signer.selection.responded",{action:q.unknown,componentType:G.unknown,signerType:e},V.high)},Hr=lo(()=>({correlationIds:new Map})),Ke={get:e=>Hr.getState().correlationIds.get(e),set:(e,t)=>{Hr.setState(n=>{const r=new Map(n.correlationIds);return r.set(e,t),{correlationIds:r}})},delete:e=>{Hr.setState(t=>{const n=new Map(t.correlationIds);return n.delete(e),{correlationIds:n}})},clear:()=>{Hr.setState({correlationIds:new Map})}};function z(e,t,n){const r=e[t.name];if(typeof r=="function")return r;const s=e[n];return typeof s=="function"?s:i=>t(e,i)}function Qe(e,{includeName:t=!1}={}){if(e.type!=="function"&&e.type!=="event"&&e.type!=="error")throw new Um(e.type);return`${e.name}(${Ds(e.inputs,{includeName:t})})`}function Ds(e,{includeName:t=!1}={}){return e?e.map(n=>Tm(n,{includeName:t})).join(t?", ":","):""}function Tm(e,{includeName:t}){return e.type.startsWith("tuple")?`(${Ds(e.components,{includeName:t})})${e.type.slice(5)}`:e.type+(t&&e.name?` ${e.name}`:"")}function we(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function re(e){return we(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const dl="2.33.1";let yi={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${dl}`}
5,_=class aa extends Error{constructor(t,n={}){const r=n.cause instanceof aa?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof aa&&n.cause.docsPath||n.docsPath,i=yi.getDocsUrl?.({...n,docsPath:s}),a=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...yi.version?[`Version: ${yi.version}`]:[]].join(` 6`);super(a,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=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=dl}walk(t){return ll(this,t)}};function ll(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?ll(e.cause,t):t?null:e}class Om extends _{constructor({docsPath:t}){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(` 7`),{docsPath:t,name:"AbiConstructorNotFoundError"})}}class Vc extends _{constructor({docsPath:t}){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(` 8`),{docsPath:t,name:"AbiConstructorParamsNotFoundError"})}}class fl extends _{constructor({data:t,params:n,size:r}){super([`Data size of ${r} bytes is too small for given parameters.`].join(` 9`),{metaMessages:[`Params: (${Ds(n,{includeName:!0})})`,`Data: ${t} (${r} 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=t,this.params=n,this.size=r}}class Or extends _{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class Cm extends _{constructor({expectedLength:t,givenLength:n,type:r}){super([`ABI encoding array length mismatch for type ${r}.`,`Expected length: ${t}`,`Given length: ${n}`].join(` 10`),{name:"AbiEncodingArrayLengthMismatchError"})}}class Bm extends _{constructor({expectedSize:t,value:n}){super(`Size of bytes "${n}" (bytes${re(n)}) does not match expected size (bytes${t}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class pl extends _{constructor({expectedLength:t,givenLength:n}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${t}`,`Given length (values): ${n}`].join(` 11`),{name:"AbiEncodingLengthMismatchError"})}}class $m extends _{constructor(t,{docsPath:n}){super([`Arguments (\`args\`) were provided to "${t}", but "${t}" 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(` 12`),{docsPath:n,name:"AbiErrorInputsNotFoundError"})}}class Wc extends _{constructor(t,{docsPath:n}={}){super([`Error ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join(` 13`),{docsPath:n,name:"AbiErrorNotFoundError"})}}class hl extends _{constructor(t,{docsPath:n}){super([`Encoded error signature "${t}" 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=${t}.`].join(` 14`),{docsPath:n,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=t}}class Nm extends _{constructor({docsPath:t}){super("Cannot extract event signature from empty topics.",{docsPath:t,name:"AbiEventSignatureEmptyTopicsError"})}}class ml extends _{constructor(t,{docsPath:n}){super([`Encoded event signature "${t}" 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=${t}.`].join(` 15`),{docsPath:n,name:"AbiEventSignatureNotFoundError"})}}class Kc extends _{constructor(t,{docsPath:n}={}){super([`Event ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it."].join(` 16`),{docsPath:n,name:"AbiEventNotFoundError"})}}class An extends _{constructor(t,{docsPath:n}={}){super([`Function ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(` 17`),{docsPath:n,name:"AbiFunctionNotFoundError"})}}class yl extends _{constructor(t,{docsPath:n}){super([`Function "${t}" 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(` 18`),{docsPath:n,name:"AbiFunctionOutputsNotFoundError"})}}class Mm extends _{constructor(t,{docsPath:n}){super([`Encoded function signature "${t}" 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=${t}.`].join(` 19`),{docsPath:n,name:"AbiFunctionSignatureNotFoundError"})}}class Rm extends _{constructor(t,n){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${t.type}\` in \`${Qe(t.abiItem)}\`, and`,`\`${n.type}\` in \`${Qe(n.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let gl=class extends _{constructor({expectedSize:t,givenSize:n}){super(`Expected bytes${t}, got bytes${n}.`,{name:"BytesSizeMismatchError"})}};class sr extends _{constructor({abiItem:t,data:n,params:r,size:s}){super([`Data size of ${s} bytes is too small for non-indexed event parameters.`].join(` 20`),{metaMessages:[`Params: (${Ds(r,{includeName:!0})})`,`Data: ${n} (${s} 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=t,this.data=n,this.params=r,this.size=s}}class zs extends _{constructor({abiItem:t,param:n}){super([`Expected a topic for indexed event parameter${n.name?` "${n.name}"`:""} on event "${Qe(t,{includeName:!0})}".`].join(` 21`),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=t}}class jm extends _{constructor(t,{docsPath:n}){super([`Type "${t}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(` 22`),{docsPath:n,name:"InvalidAbiEncodingType"})}}class Lm extends _{constructor(t,{docsPath:n}){super([`Type "${t}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(` 23`),{docsPath:n,name:"InvalidAbiDecodingType"})}}let bl=class extends _{constructor(t){super([`Value "${t}" is not a valid array.`].join(` 24`),{name:"InvalidArrayError"})}};class Um extends _{constructor(t){super([`"${t}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(` 25`),{name:"InvalidDefinitionTypeError"})}}class Dm extends _{constructor(t){super(`Type "${t}" is not supported for packed encoding.`,{name:"UnsupportedPackedAbiType"})}}class zm extends _{constructor(t){super(`Filter type "${t}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let wl=class extends _{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}},vl=class extends _{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}};class Zc extends _{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} is expected to be ${n} ${r} long, but is ${t} ${r} long.`,{name:"InvalidBytesLengthError"})}}function le(e,{dir:t,size:n=32}={}){return typeof e=="string"?Nt(e,{dir:t,size:n}):Fm(e,{dir:t,size:n})}function Nt(e,{dir:t,size:n=32}={}){if(n===null)return e;const r=e.replace("0x","");if(r.length>n*2)throw new vl({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function Fm(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new vl({size:e.length,targetSize:n,type:"bytes"});
25const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=t==="right";r[i?s:n-s-1]=e[i?s:e.length-s-1]}return r}let xl=class extends _{constructor({max:t,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}};class Hm extends _{constructor(t){super(`Bytes value "${t}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class Gm extends _{constructor(t){super(`Hex value "${t}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let qm=class extends _{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}};function Je(e,{dir:t="left"}={}){let n=typeof e=="string"?e.replace("0x",""):e,r=0;for(let s=0;s<n.length-1&&n[t==="left"?s:n.length-s-1].toString()==="0";s++)r++;return n=t==="left"?n.slice(r):n.slice(0,n.length-r),typeof e=="string"?(n.length===1&&t==="right"&&(n=`${n}0`),`0x${n.length%2===1?`0${n}`:n}`):n}function Ve(e,{size:t}){if(re(e)>t)throw new qm({givenSize:re(e),maxSize:t})}function de(e,t={}){const{signed:n}=t;t.size&&Ve(e,{size:t.size});const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,i=(1n<<BigInt(s)*8n-1n)-1n;return r<=i?r:r-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function Vm(e,t={}){let n=e;if(t.size&&(Ve(n,{size:t.size}),n=Je(n)),Je(n)==="0x00")return!1;if(Je(n)==="0x01")return!0;throw new Gm(n)}function Te(e,t={}){return Number(de(e,t))}function Yc(e,t={}){let n=Ae(e);return t.size&&(Ve(n,{size:t.size}),n=Je(n,{dir:"right"})),new TextDecoder().decode(n)}const Wm=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function _e(e,t={}){return typeof e=="number"||typeof e=="bigint"?R(e,t):typeof e=="string"?Xt(e,t):typeof e=="boolean"?Ao(e,t):pe(e,t)}function Ao(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(Ve(n,{size:t.size}),le(n,{size:t.size})):n}function pe(e,t={}){let n="";for(let s=0;s<e.length;s++)n+=Wm[e[s]];const r=`0x${n}`;return typeof t.size=="number"?(Ve(r,{size:t.size}),le(r,{dir:"right",size:t.size})):r}function R(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<a){const c=typeof e=="bigint"?"n":"";throw new xl({max:i?`${i}${c}`:void 0,min:`${a}${c}`,signed:n,size:r,value:`${e}${c}`})}const o=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?le(o,{size:r}):o}const Km=new TextEncoder;function Xt(e,t={}){const n=Km.encode(e);return pe(n,t)}const Zm=new TextEncoder;function Un(e,t={}){return typeof e=="number"||typeof e=="bigint"?Jm(e,t):typeof e=="boolean"?Ym(e,t):we(e)?Ae(e,t):vt(e,t)}function Ym(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(Ve(n,{size:t.size}),le(n,{size:t.size})):n}const dt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Jc(e){if(e>=dt.zero&&e<=dt.nine)return e-dt.zero;if(e>=dt.A&&e<=dt.F)return e-(dt.A-10);if(e>=dt.a&&e<=dt.f)return e-(dt.a-10)}function Ae(e,t={}){let n=e;t.size&&(Ve(n,{size:t.size}),n=le(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let a=0,o=0;a<s;a++){const c=Jc(r.charCodeAt(o++)),u=Jc(r.charCodeAt(o++));if(c===void 0||u===void 0)throw new _(`Invalid byte sequence ("${r[o-2]}${r[o-1]}" in "${r}").`);i[a]=c*16+u}return i}function Jm(e,t){const n=R(e,t);return Ae(n)}function vt(e,t={}){const n=Zm.encode(e);return typeof t.size=="number"?(Ve(n,{size:t.size}),le(n,{dir:"right",size:t.size})):n}const Gr=BigInt(2**32-1),Qc=BigInt(32);function Qm(e,t=!1){return t?{h:Number(e&Gr),l:Number(e>>Qc&Gr)}:{h:Number(e>>Qc&Gr)|0,l:Number(e&Gr)|0}}function Xm(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:a,l:o}=Qm(e[i],t);[r[i],s[i]]=[a,o]}return[r,s]}const ey=(e,t,n)=>e<<n|t>>>32-n,ty=(e,t,n)=>t<<n|e>>>32-n,ny=(e,t,n)=>t<<n-32|e>>>64-n,ry=(e,t,n)=>e<<n-32|t>>>64-n;function sy(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Xc(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ir(e,...t){if(!sy(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ms(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 El(e,t){ir(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function iy(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function gi(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function et(e,t){return e<<32-t|e>>>t}const ay=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function oy(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function cy(e){for(let t=0;t<e.length;t++)e[t]=oy(e[t]);return e}const eu=ay?e=>e:cy;function uy(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ko(e){return typeof e=="string"&&(e=uy(e)),ir(e),e}let _l=class{};function Sl(e){const t=r=>e().update(ko(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const dy=BigInt(0),Gn=BigInt(1),ly=BigInt(2),fy=BigInt(7),py=BigInt(256),hy=BigInt(113),Al=[],kl=[],Il=[];for(let e=0,t=Gn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Al.push(2*(5*r+n)),kl.push((e+1)*(e+2)/2%64);let s=dy;for(let i=0;i<7;i++)t=(t<<Gn^(t>>fy)*hy)%py,t&ly&&(s^=Gn<<(Gn<<BigInt(i))-Gn);Il.push(s)}
25const Pl=Xm(Il,!0),my=Pl[0],yy=Pl[1],tu=(e,t,n)=>n>32?ny(e,t,n):ey(e,t,n),nu=(e,t,n)=>n>32?ry(e,t,n):ty(e,t,n);function gy(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let a=0;a<10;a++)n[a]=e[a]^e[a+10]^e[a+20]^e[a+30]^e[a+40];for(let a=0;a<10;a+=2){const o=(a+8)%10,c=(a+2)%10,u=n[c],l=n[c+1],d=tu(u,l,1)^n[o],f=nu(u,l,1)^n[o+1];for(let p=0;p<50;p+=10)e[a+p]^=d,e[a+p+1]^=f}let s=e[2],i=e[3];for(let a=0;a<24;a++){const o=kl[a],c=tu(s,i,o),u=nu(s,i,o),l=Al[a];s=e[l],i=e[l+1],e[l]=c,e[l+1]=u}for(let a=0;a<50;a+=10){for(let o=0;o<10;o++)n[o]=e[a+o];for(let o=0;o<10;o++)e[a+o]^=~n[(o+2)%10]&n[(o+4)%10]}e[0]^=my[r],e[1]^=yy[r]}ar(n)}class Io extends _l{constructor(t,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,Xc(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=iy(this.state)}clone(){return this._cloneInto()}keccak(){eu(this.state32),gy(this.state32,this.rounds),eu(this.state32),this.posOut=0,this.pos=0}update(t){ms(this),t=ko(t),ir(t);const{blockLen:n,state:r}=this,s=t.length;for(let i=0;i<s;){const a=Math.min(n-this.pos,s-i);for(let o=0;o<a;o++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){ms(this,!1),ir(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=t.length;s<i;){this.posOut>=r&&this.keccak();const a=Math.min(r-this.posOut,i-s);t.set(n.subarray(this.posOut,this.posOut+a),s),this.posOut+=a,s+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Xc(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(El(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ar(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:a}=this;return t||(t=new Io(n,r,s,a,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=s,t.enableXOF=a,t.destroyed=this.destroyed,t}}const by=(e,t,n)=>Sl(()=>new Io(t,e,n)),Tl=by(1,136,256/8);function X(e,t){const n=t||"hex",r=Tl(we(e,{strict:!1})?Un(e):e);return n==="bytes"?r:_e(r)}const wy=e=>X(Un(e));function vy(e){return wy(e)}function xy(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),o==="("&&r++,o===")"&&r--,!!t){if(r===0){if(o===" "&&["event","function",""].includes(s))s="";else if(s+=o,o===")"){i=!0;break}continue}if(o===" "){e[a-1]!==","&&n!==","&&n!==",("&&(n="",t=!1);continue}s+=o,n+=o}}if(!i)throw new _("Unable to normalize signature.");return s}const Ey=e=>{const t=typeof e=="string"?e:fs(e);return xy(t)};function Ol(e){return vy(Ey(e))}const Fs=Ol;let Et=class extends _{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}},Hs=class extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}};const bi=new Hs(8192);function Gs(e,t){if(bi.has(`${e}.${t}`))return bi.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=X(vt(n),"bytes"),s=n.split("");for(let a=0;a<40;a+=2)r[a>>
251]>>4>=8&&s[a]&&(s[a]=s[a].toUpperCase()),(r[a>>1]&15)>=8&&s[a+1]&&(s[a+1]=s[a+1].toUpperCase());const i=`0x${s.join("")}`;return bi.set(`${e}.${t}`,i),i}function oa(e,t){if(!be(e,{strict:!1}))throw new Et({address:e});return Gs(e,t)}const _y=/^0x[a-fA-F0-9]{40}$/,wi=new Hs(8192);function be(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(wi.has(r))return wi.get(r);const s=_y.test(e)?e.toLowerCase()===e?!0:n?Gs(e)===e:!0:!1;return wi.set(r,s),s}function ve(e){return typeof e[0]=="string"?jt(e):Sy(e)}function Sy(e){let t=0;for(const s of e)t+=s.length;const n=new Uint8Array(t);let r=0;for(const s of e)n.set(s,r),r+=s.length;return n}function jt(e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function en(e,t,n,{strict:r}={}){return we(e,{strict:!1})?ys(e,t,n,{strict:r}):$l(e,t,n,{strict:r})}function Cl(e,t){if(typeof t=="number"&&t>0&&t>re(e)-1)throw new wl({offset:t,position:"start",size:re(e)})}function Bl(e,t,n){if(typeof t=="number"&&typeof n=="number"&&re(e)!==n-t)throw new wl({offset:n,position:"end",size:re(e)})}function $l(e,t,n,{strict:r}={}){Cl(e,t);const s=e.slice(t,n);return r&&Bl(s,t,n),s}function ys(e,t,n,{strict:r}={}){Cl(e,t);const s=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return r&&Bl(s,t,n),s}const Ay=/^(.*)\[([0-9]*)\]$/,Nl=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Po=/^(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 $e(e,t){if(e.length!==t.length)throw new pl({expectedLength:e.length,givenLength:t.length});const n=ky({params:e,values:t}),r=Oo(n);return r.length===0?"0x":r}function ky({params:e,values:t}){const n=[];for(let r=0;r<e.length;r++)n.push(To({param:e[r],value:t[r]}));return n}function To({param:e,value:t}){const n=Co(e.type);if(n){const[r,s]=n;return Py(t,{length:r,param:{...e,type:s}})}if(e.type==="tuple")return $y(t,{param:e});if(e.type==="address")return Iy(t);if(e.type==="bool")return Oy(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const r=e.type.startsWith("int"),[,,s="256"]=Po.exec(e.type)??[];return Cy(t,{signed:r,size:Number(s)})}if(e.type.startsWith("bytes"))return Ty(t,{param:e});if(e.type==="string")return By(t);throw new jm(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function Oo(e){let t=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?t+=32:t+=re(o)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(R(t+s,{size:32})),r.push(o),s+=re(o)):n.push(o)}return ve([...n,...r])}function Iy(e){if(!be(e))throw new Et({address:e});return{dynamic:!1,encoded:Nt(e.toLowerCase())}}function Py(e,{length:t,param:n}){const r=t===null;if(!Array.isArray(e))throw new bl(e);if(!r&&e.length!==t)throw new Cm({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let s=!1;const i=[];for(let a=0;a<e.length;a++){const o=To({param:n,value:e[a]});o.dynamic&&(s=!0),i.push(o)}if(r||s){const a=Oo(i);if(r){const o=R(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?ve([o,a]):o}}if(s)return{dynamic:!0,encoded:a}}return{dynamic:!1,encoded:ve(i.map(({encoded:a})=>a))}}function Ty(e,{param:t}){const[,n]=t.type.split("bytes"),r=re(e);if(!n){let s=e;return r%32!==0&&(s=Nt(s,{dir:"right",size:Math.ceil((e.length-2)/2/32)*32})),{dynamic:!0,encoded:ve([Nt(R(r,{size:32})),s])}}if(r!==Number.parseInt(n))throw new Bm({expectedSize:Number.parseInt(n),value:e});return{dynamic:!1,encoded:Nt(e,{dir:"right"})}}function Oy(e){if(typeof e!="boolean")throw new _(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Nt(Ao(e))}}function Cy(e,{signed:t,size:n=256}){if(typeof n=="number"){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new xl({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:R(e,{size:32,signed:t})}}function By(e){const t=Xt(e),n=Math.ceil(re(t)/32),r=[];for(let s=0;s<n;s++)r.push(Nt(en(t,s*32,(s+1)*32),{dir:"right"}));return{dynamic:!0,encoded:ve([Nt(R(re(t),{size:32})),...r])}}function $y(e,{param:t}){let n=!1;const r=[];for(let s=0;s<t.components.length;
25s++){const i=t.components[s],a=Array.isArray(e)?s:i.name,o=To({param:i,value:e[a]});r.push(o),o.dynamic&&(n=!0)}return{dynamic:n,encoded:n?Oo(r):ve(r.map(({encoded:s})=>s))}}function Co(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const Cr=e=>en(Ol(e),0,4);function on(e){const{abi:t,args:n=[],name:r}=e,s=we(r,{strict:!1}),i=t.filter(o=>s?o.type==="function"?Cr(o)===r:o.type==="event"?Fs(o)===r:!1:"name"in o&&o.name===r);if(i.length===0)return;if(i.length===1)return i[0];let a;for(const o of i){if(!("inputs"in o))continue;if(!n||n.length===0){if(!o.inputs||o.inputs.length===0)return o;continue}if(!o.inputs||o.inputs.length===0||o.inputs.length!==n.length)continue;if(n.every((u,l)=>{const d="inputs"in o&&o.inputs[l];return d?ca(u,d):!1})){if(a&&"inputs"in a&&a.inputs){const u=Ml(o.inputs,a.inputs,n);if(u)throw new Rm({abiItem:o,type:u[0]},{abiItem:a,type:u[1]})}a=o}}return a||i[0]}function ca(e,t){const n=typeof e,r=t.type;switch(r){case"address":return be(e,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in t?Object.values(t.components).every((s,i)=>ca(Object.values(e)[i],s)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||e instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(e)&&e.every(s=>ca(s,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Ml(e,t,n){for(const r in e){const s=e[r],i=t[r];if(s.type==="tuple"&&i.type==="tuple"&&"components"in s&&"components"in i)return Ml(s.components,i.components,n[r]);const a=[s.type,i.type];if(a.includes("address")&&a.includes("bytes20")?!0:a.includes("address")&&a.includes("string")?be(n[r],{strict:!1}):a.includes("address")&&a.includes("bytes")?be(n[r],{strict:!1}):!1)return a}}const ru="/docs/contract/encodeEventTopics";function Br(e){const{abi:t,eventName:n,args:r}=e;let s=t[0];if(n){const c=on({abi:t,name:n});if(!c)throw new Kc(n,{docsPath:ru});s=c}if(s.type!=="event")throw new Kc(void 0,{docsPath:ru});const i=Qe(s),a=Fs(i);let o=[];if(r&&"inputs"in s){const c=s.inputs?.filter(l=>"indexed"in l&&l.indexed),u=Array.isArray(r)?r:Object.values(r).length>0?c?.map(l=>r[l.name])??[]:[];u.length>0&&(o=c?.map((l,d)=>Array.isArray(u[d])?u[d].map((f,p)=>su({param:l,value:u[d][p]})):typeof u[d]<"u"&&u[d]!==null?su({param:l,value:u[d]}):null)??[])}return[a,...o]}function su({param:e,value:t}){if(e.type==="string"||e.type==="bytes")return X(Un(t));if(e.type==="tuple"||e.type.match(/^(.*)\[(\d+)?\]$/))throw new zm(e.type);return $e([e],[t])}function qs(e,{method:t}){const n={};return e.transport.type==="fallback"&&e.transport.onResponse?.(({method:r,response:s,status:i,transport:a})=>{i==="success"&&t===r&&(n[s]=a.request)}),(r=>n[r]||e.request)}async function Rl(e,t){const{address:n,abi:r,args:s,eventName:i,fromBlock:a,strict:o,toBlock:c}=t,u=qs(e,{method:"eth_newFilter"}),l=i?Br({abi:r,args:s,eventName:i}):void 0,d=await e.request({method:"eth_newFilter",params:[{address:n,fromBlock:typeof a=="bigint"?R(a):a,toBlock:typeof c=="bigint"?R(c):c,topics:l}]});return{abi:r,args:s,eventName:i,id:d,request:u(d),strict:!!o,type:"event"}}function xe(e){return typeof e=="string"?{address:e,type:"json-rpc"}:e}const iu="/docs/contract/encodeFunctionData";function Ny(e){const{abi:t,args:n,functionName:r}=e;let s=t[0];if(r){const i=on({abi:t,args:n,name:r});if(!i)throw new An(r,{docsPath:iu});s=i}if(s.type!=="function")throw new An(void 0,{docsPath:iu});return{abi:[s],functionName:Cr(Qe(s))}}function he(e){const{args:t}=e,{abi:n,functionName:r}=e.abi.length===1&&e.functionName?.startsWith("0x")?e:Ny(e),s=n[0],i=r,a="inputs"in s&&s.inputs?$e(s.inputs,t??[]):void 0;return jt([i,a??"0x"])}const jl={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 invali
25d 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."},Ll={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},My={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};class au extends _{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class Ul extends _{constructor({length:t,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}}class Ry extends _{constructor({count:t,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}const jy={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 Ry({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Ul({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new au({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 au({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,e&255),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 Bo(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(jy);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function Ly(e,t={}){typeof t.size<"u"&&Ve(e,{size:t.size});const n=pe(e,t);return de(n,t)}function Uy(e,t={}){let n=e;if(typeof t.size<"u"&&(Ve(n,{size:t.size}),n=Je(n)),n.length>1||n[0]>1)throw new Hm(n);return!!n[0]}function xt(e,t={}){typeof t.size<"u"&&Ve(e,{size:t.size});const n=pe(e,t);return Te(n,t)}function Dy(e,t={}){let n=e;return typeof t.size<"u"&&(Ve(n,{size:t.size}),n=Je(n,{dir:"right"})),new TextDecoder().decode(n)}function cn(e,t){const n=typeof t=="string"?Ae(t):t,r=Bo(n);if(re(n)===0&&e.length>0)throw new Or;if(re(t)&&re(t)<32)throw new fl({data:typeof t=="string"?t:pe(t),params:e,size:re(t)});let s=0;const i=[];for(let a=0;a<e.length;++a){const o=e[a];r.setPosition(s);const[c,u]=xn(r,o,{staticPosition:0});s+=u,i.push(c)}return i}function xn(e,t,{staticPosition:n}){const r=Co(t.type);if(r){const[s,i]=r;return Fy(e,{...t,type:i},{length:s,staticPosition:n})}if(t.type==="tuple")return Vy(e,t,{staticPosition:n});if(t.type==="address")return zy(e);if(t.type==="bool")return Hy(e);if(t.type.startsWith("bytes"))return Gy(e,t,{staticPosition:n});if(t.type.startsWith("uint")||t.type.startsWith("int"))return qy(e,t);if(t.type==="string")return Wy(e,{staticPosition:n});throw new Lm(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const ou=32,ua=32;function zy(e){const t=e.readBytes(32);return[Gs(pe($l(t,-20))),32]}function Fy(e,t,{length:n,staticPosition:r}){if(!n){const a=xt(e.readBytes(ua)),o=r+a,c=o+ou;e.setPosition(o);const u=xt(e.readBytes(ou)),l=or(t);let d=0;const f=[];for(let p=0;p<u;++p){e.setPosition(c+(l?p*32:d));const[y,h]=xn(e,t,{staticPosition:c});
25d+=h,f.push(y)}return e.setPosition(r+32),[f,32]}if(or(t)){const a=xt(e.readBytes(ua)),o=r+a,c=[];for(let u=0;u<n;++u){e.setPosition(o+u*32);const[l]=xn(e,t,{staticPosition:o});c.push(l)}return e.setPosition(r+32),[c,32]}let s=0;const i=[];for(let a=0;a<n;++a){const[o,c]=xn(e,t,{staticPosition:r+s});s+=c,i.push(o)}return[i,s]}function Hy(e){return[Uy(e.readBytes(32),{size:32}),32]}function Gy(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const a=xt(e.readBytes(32));e.setPosition(n+a);const o=xt(e.readBytes(32));if(o===0)return e.setPosition(n+32),["0x",32];const c=e.readBytes(o);return e.setPosition(n+32),[pe(c),32]}return[pe(e.readBytes(Number.parseInt(s),32)),32]}function qy(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256"),s=e.readBytes(32);return[r>48?Ly(s,{signed:n}):xt(s,{signed:n}),32]}function Vy(e,t,{staticPosition:n}){const r=t.components.length===0||t.components.some(({name:a})=>!a),s=r?[]:{};let i=0;if(or(t)){const a=xt(e.readBytes(ua)),o=n+a;for(let c=0;c<t.components.length;++c){const u=t.components[c];e.setPosition(o+i);const[l,d]=xn(e,u,{staticPosition:o});i+=d,s[r?c:u?.name]=l}return e.setPosition(n+32),[s,32]}for(let a=0;a<t.components.length;++a){const o=t.components[a],[c,u]=xn(e,o,{staticPosition:n});s[r?a:o?.name]=c,i+=u}return[s,i]}function Wy(e,{staticPosition:t}){const n=xt(e.readBytes(32)),r=t+n;e.setPosition(r);const s=xt(e.readBytes(32));if(s===0)return e.setPosition(t+32),["",32];const i=e.readBytes(s,32),a=Dy(Je(i));return e.setPosition(t+32),[a,32]}function or(e){const{type:t}=e;if(t==="string"||t==="bytes"||t.endsWith("[]"))return!0;if(t==="tuple")return e.components?.some(or);const n=Co(e.type);return!!(n&&or({...e,type:n[1]}))}function Dl(e){const{abi:t,data:n}=e,r=en(n,0,4);if(r==="0x")throw new Or;const i=[...t||[],Ll,My].find(a=>a.type==="error"&&r===Cr(Qe(a)));if(!i)throw new hl(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:i,args:"inputs"in i&&i.inputs&&i.inputs.length>0?cn(i.inputs,en(n,4)):void 0,errorName:i.name}}const fe=(e,t,n)=>JSON.stringify(e,(r,s)=>typeof s=="bigint"?s.toString():s,n);function zl({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((s,i)=>`${r&&s.name?`${s.name}: `:""}${typeof t[i]=="object"?fe(t[i]):t[i]}`).join(", ")})`}const Ky={gwei:9,wei:18},Zy={ether:-9,wei:9};function Fl(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[s,i]=[n.slice(0,n.length-t),n.slice(n.length-t)];return i=i.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${i?`.${i}`:""}`}function Hl(e,t="wei"){return Fl(e,Ky[t])}function Ne(e,t="wei"){return Fl(e,Zy[t])}class Yy extends _{constructor({address:t}){super(`State for account "${t}" is set multiple times.`,{name:"AccountStateConflictError"})}}class Jy extends _{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function cu(e){return e.reduce((t,{slot:n,value:r})=>`${t} ${n}: ${r} 26`,"")}function Qy(e){return e.reduce((t,{address:n,...r})=>{let s=`${t} ${n}: 27`;return r.nonce&&(s+=` nonce: ${r.nonce} 28`),r.balance&&(s+=` balance: ${r.balance} 29`),r.code&&(s+=` code: ${r.code} 30`),r.state&&(s+=` state: 31`,s+=cu(r.state)),r.stateDiff&&(s+=` stateDiff: 32`,s+=cu(r.stateDiff)),s},` State Override: 33`).slice(0,-1)}function $r(e){const t=Object.entries(e).map(([r,s])=>s===void 0||s===!1?null:[r,s]).filter(Boolean),n=t.reduce((r,[s])=>Math.max(r,s.length),0);return t.map(([r,s])=>` ${`${r}:`.padEnd(n+1)} ${s}`).join(` 34`)}class Xy extends _{constructor(){super(["Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.","Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."].join(` 35`),{name:"FeeConflictError"})}}class eg extends _{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",$r(t),"}","","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 Gl extends _{constructor({blockHash:t,blockNumber:n,blockTag:r,hash:s,index:i}){let a="Transaction";r&&i!==void 0&&(a=`Transaction at block time "${r}" at index "${i}"`),t&&i!==void 0&&(a=`Transaction at block hash "${t}" at index "${i}"`),n&&i!==void 0&&(a=`Transaction at block number "${n}" at index "${i}"`),s&&(a=`Transaction with hash "${s}"`),super(`${a} could not be found.`,{name:"TransactionNotFoundError"})}}class ql extends _{constructor({hash:t}){super(`Transaction receipt with hash "${t}" could not be found. The Transaction may not be processed on a block yet.`,{name:"TransactionReceiptNotFoundError"})}}class tg extends _{constructor({hash:t}){super(`Timed out while waiting for transaction with hash "${t}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}const ng=e=>e,$o=e=>e;class Vl extends _{constructor(t,{account:n,docsPath:r,chain:s,data:i,gas:a,gasPrice:o,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:l,to:d,value:f,stateOverride:p}){const y=n?xe(n):void 0;let h=$r({from:y?.address,to:d,value:typeof f<"u"&&`${Hl(f)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:a,gasPrice:typeof o<"u"&&`${Ne(o)} gwei`,maxFeePerGas:typeof c<"u"&&`${Ne(c)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${Ne(u)} gwei`,nonce:l});p&&(h+=` 36${Qy(p)}`),super(t.shortMessage,{cause:t,docsPath:r,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Raw Call Arguments:",h].filter(
36Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class Wl extends _{constructor(t,{abi:n,args:r,contractAddress:s,docsPath:i,functionName:a,sender:o}){const c=on({abi:n,args:r,name:a}),u=c?zl({abiItem:c,args:r,includeFunctionName:!1,includeName:!1}):void 0,l=c?Qe(c,{includeName:!0}):void 0,d=$r({address:s&&ng(s),function:l,args:u&&u!=="()"&&`${[...Array(a?.length??0).keys()].map(()=>" ").join("")}${u}`,sender:o});super(t.shortMessage||`An unknown error occurred while executing the contract function "${a}".`,{cause:t,docsPath:i,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],d&&"Contract Call:",d].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=n,this.args=r,this.cause=t,this.contractAddress=s,this.functionName=a,this.sender=o}}class gs extends _{constructor({abi:t,data:n,functionName:r,message:s}){let i,a,o,c;if(n&&n!=="0x")try{a=Dl({abi:t,data:n});const{abiItem:l,errorName:d,args:f}=a;if(d==="Error")c=f[0];else if(d==="Panic"){const[p]=f;c=jl[p]}else{const p=l?Qe(l,{includeName:!0}):void 0,y=l&&f?zl({abiItem:l,args:f,includeFunctionName:!1,includeName:!1}):void 0;o=[p?`Error: ${p}`:"",y&&y!=="()"?` ${[...Array(d?.length??0).keys()].map(()=>" ").join("")}${y}`:""]}}catch(l){i=l}else s&&(c=s);let u;i instanceof hl&&(u=i.signature,o=[`Unable to decode signature "${u}" 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=${u}.`]),super(c&&c!=="execution reverted"||u?[`The contract function "${r}" reverted with the following ${u?"signature":"reason"}:`,c||u].join(` 37`):`The contract function "${r}" reverted.`,{cause:i,metaMessages:o,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=n,this.reason=c,this.signature=u}}class Kl extends _{constructor({functionName:t}){super(`The contract function "${t}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${t}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class rg extends _{constructor({factory:t}){super(`Deployment for counterfactual contract call failed${t?` for factory "${t}".`:""}`,{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 Vs extends _{constructor({data:t,message:n}){super(n||"",{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=t}}class Qn extends _{constructor({body:t,cause:n,details:r,headers:s,status:i,url:a}){super("HTTP request failed.",{cause:n,details:r,metaMessages:[i&&`Status: ${i}`,`URL: ${$o(a)}`,t&&`Request body: ${fe(t)}
37`].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=t,this.headers=s,this.status=i,this.url=a}}class No extends _{constructor({body:t,error:n,url:r}){super("RPC Request failed.",{cause:n,details:n.message,metaMessages:[`URL: ${$o(r)}`,`Request body: ${fe(t)}`],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=n.code,this.data=n.data}}class uu extends _{constructor({body:t,url:n}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${$o(n)}`,`Request body: ${fe(t)}`],name:"TimeoutError"})}}const sg=-1;class Oe extends _{constructor(t,{code:n,docsPath:r,metaMessages:s,name:i,shortMessage:a}){super(a,{cause:t,docsPath:r,metaMessages:s||t?.metaMessages,name:i||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=i||t.name,this.code=t instanceof No?t.code:n??sg}}class Re extends Oe{constructor(t,n){super(t,n),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n.data}}class cr extends Oe{constructor(t){super(t,{code:cr.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(cr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class ur extends Oe{constructor(t){super(t,{code:ur.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(ur,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class dr extends Oe{constructor(t,{method:n}={}){super(t,{code:dr.code,name:"MethodNotFoundRpcError",shortMessage:`The method${n?` "${n}"`:""} does not exist / is not available.`})}}Object.defineProperty(dr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class lr extends Oe{constructor(t){super(t,{code:lr.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(` 38`)})}}Object.defineProperty(lr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class tn extends Oe{constructor(t){super(t,{code:tn.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(tn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class nn extends Oe{constructor(t){super(t,{code:nn.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(` 39`)})}}Object.defineProperty(nn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class fr extends Oe{constructor(t){super(t,{code:fr.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(fr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class pr extends Oe{constructor(t){super(t,{code:pr.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(pr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class hr extends Oe{constructor(t){super(t,{code:hr.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(hr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Gt extends Oe{constructor(t,{method:n}={}){super(t,{code:Gt.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${n?` "${n}"`:""} is not supported.`})}}Object.defineProperty(Gt,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});
39class kn extends Oe{constructor(t){super(t,{code:kn.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(kn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class mr extends Oe{constructor(t){super(t,{code:mr.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(mr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class En extends Re{constructor(t){super(t,{code:En.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(En,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class yr extends Re{constructor(t){super(t,{code:yr.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(yr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class gr extends Re{constructor(t,{method:n}={}){super(t,{code:gr.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${n?` " ${n}"`:""}.`})}}Object.defineProperty(gr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class br extends Re{constructor(t){super(t,{code:br.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(br,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class wr extends Re{constructor(t){super(t,{code:wr.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(wr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class vr extends Re{constructor(t){super(t,{code:vr.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(vr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class xr extends Re{constructor(t){super(t,{code:xr.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(xr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Er extends Re{constructor(t){super(t,{code:Er.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Er,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class _r extends Re{constructor(t){super(t,{code:_r.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(_r,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class Sr extends Re{constructor(t){super(t,{code:Sr.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(Sr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Ar extends Re{constructor(t){super(t,{code:Ar.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Ar,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class kr extends Re{constructor(t){super(t,{code:kr.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(kr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Ir extends Re{constructor(t){super(t,{code:Ir.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class ig extends Oe{constructor(t){super(t,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const ag=3;function In(e,{abi:t,address:n,args:r,docsPath:s,functionName:i,sender:a}){const o=e instanceof Vs?e:e instanceof _?e.walk(y=>"data"in y)||e.walk():{},{code:c,data:u,details:l,message:d,shortMessage:f}=o,p=e instanceof Or?new Kl({functionName:i}):[ag,tn.code].includes(c)&&(u||l||d||f)?new gs({abi:t,data:typeof u=="object"?u.data:u,functionName:i,message:o instanceof No?l:f??d}):e;return new Wl(p,{abi:t,args:r,contractAddress:n,docsPath:s,functionName:i,sender:a})}function og(e){const t=X(`0x${e.substring(4)}`).substring(26);return Gs(`0x${t}`)}async function cg({hash:e,signature:t}){const n=we(e)?e:_e(e),{secp256k1:r}=await vd(async()=>{const{secp256k1:a}=await Promise.resolve().then(()=>u1);return{secp256k1:a}},void 0);return`0x${(()=>{if(typeof t=="object"&&"r"in t&&"s"in t){const{r:u,s:l,v:d,yParity:f}=t,p=Number(f??d),y=du(p);return new r.Signature(de(u),de(l)).addRecoveryBit(y)}const a=we(t)?t:_e(t);if(re(a)!==65)throw new Error("invalid signature length");const o=Te(`0x${a.slice(130)}`),c=du(o);return r.Signature.fromCompact(a.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function du(e){if(e===0||e===1)return e;if(e===27)return 0;if(e===28)return 1;throw new Error("Invalid yParityOrV value")}async function Zl({hash:e,signature:t}){return og(await cg({hash:e,signature:t}))}function ug(e,t="hex"){const n=Yl(e),r=Bo(new Uint8Array(n.length));return n.encode(r),t==="hex"?pe(r.bytes):r.bytes}function Yl(e){return Array.isArray(e)?dg(e.map(t=>Yl(t))):lg(e)}function dg(e){const t=e.reduce((s,i)=>s+i.length,0),n=Jl(t);return{length:t<=55?1+t:1+n+t,encode(s){t<=55?s.pushByte(192+t):(s.pushByte(247+n),n===1?s.pushUint8(t):n===2?s.pushUint16(t):n===3?s.pushUint24(t):s.pushUint32(t));for(const{encode:i}of e)i(s)}}}function lg(e){const t=typeof e=="string"?Ae(e):e,n=Jl(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length,encode(s){t.length===1&&t[0]<128?s.pushBytes(t):t.length<=55?(s.pushByte(128+t.length),s.pushBytes(t)):(s.pushByte(183+n),n===1?s.pushUint8(t.length):n===2?s.pushUint16(t.length):n===3?s.pushUint24(t.length):s.pushUint32(t.length),s.pushBytes(t))}}}function Jl(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new _("Length is too large.")}function fg(e){const{chainId:t,nonce:n,to:r}=e,s=e.contractAddress??e.address,i=X(jt(["0x05",ug([t?R(t):"0x",s,n?R(n):"0x"])]));return r==="bytes"?Ae(i):i}async function pg(e){const{authorization:t,signature:n}=e;return Zl({hash:fg(t),signature:n??t})}class hg extends _{constructor(t,{account:n,docsPath:r,chain:s,data:i,gas:a,gasPrice:o,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:l,to:d,value:f}){const p=$r({from:n?.address,to:d,value:typeof f<"u"&&`${Hl(f)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:a,gasPrice:typeof o<"u"&&`${Ne(o)} gwei`,maxFeePerGas:typeof c<"u"&&`${Ne(c)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${Ne(u)} gwei`,nonce:l});super(t.shortMessage,{cause:t,docsPath:r,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Estimate Gas Arguments:",p].filter(
39Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}let gn=class extends _{constructor({cause:t,message:n}={}){const r=n?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${r?`with reason: ${r}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}};Object.defineProperty(gn,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(gn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class bs extends _{constructor({cause:t,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${Ne(n)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(bs,"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 da extends _{constructor({cause:t,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${Ne(n)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}}Object.defineProperty(da,"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 la extends _{constructor({cause:t,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}}Object.defineProperty(la,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class fa extends _{constructor({cause:t,nonce:n}={}){super([`Nonce provided for the transaction ${n?`(${n}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(` 40`),{cause:t,name:"NonceTooLowError"})}}Object.defineProperty(fa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class pa extends _{constructor({cause:t,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}}Object.defineProperty(pa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class ha extends _{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(` 41`),{cause:t,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(ha,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class ma extends _{constructor({cause:t,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(ma,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class ya extends _{constructor({cause:t,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(ya,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class ga extends _{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(ga,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class ws extends _{constructor({cause:t,maxPriorityFeePerGas:n,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${n?` = ${Ne(n)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${Ne(r)} gwei`:""}).`].join(` 42`),{cause:t,name:"TipAboveFeeCapError"})}}Object.defineProperty(ws,"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 Ws extends _{constructor({cause:t}){super(`An error occurred while executing: ${t?.shortMessage}`,{cause:t,name:"UnknownNodeError"})}}function Mo(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof _?e.walk(s=>s?.code===gn.code):e;return r instanceof _?new gn({cause:e,message:r.details}):gn.nodeMessage.test(n)?new gn({cause:e,message:e.details}):bs.nodeMessage.test(n)?new bs({cause:e,maxFeePerGas:t?.maxFeePerGas}):da.nodeMessage.test(n)?new da({cause:e,maxFeePerGas:t?.maxFeePerGas}):la.nodeMessage.test(n)?new la({cause:e,nonce:t?.nonce}):fa.nodeMessage.test(n)?new fa({cause:e,nonce:t?.nonce}):pa.nodeMessage.test(n)?new pa({cause:e,nonce:t?.nonce}):ha.nodeMessage.test(n)?new ha({cause:e}):ma.nodeMessage.test(n)?new ma({cause:e,gas:t?.gas}):ya.nodeMessage.test(n)?new ya({cause:e,gas:t?.gas}):ga.nodeMessage.test(n)?new ga({cause:e}):ws.nodeMessage.test(n)?new ws({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new Ws({cause:e})}function mg(e,{docsPath:t,...n}){const r=(()=>{const s=Mo(e,n);return s instanceof Ws?e:s})();return new hg(r,{docsPath:t,...n})}function Ro(e,{format:t}){if(!t)return{};const n={};function r(i){const a=Object.keys(i);for(const o of a)o in e&&(n[o]=e[o]),i[o]&&typeof i[o]=="object"&&!Array.isArray(i[o])&&r(i[o]
42)}const s=t(e||{});return r(s),n}const yg={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Ks(e){const t={};return typeof e.authorizationList<"u"&&(t.authorizationList=gg(e.authorizationList)),typeof e.accessList<"u"&&(t.accessList=e.accessList),typeof e.blobVersionedHashes<"u"&&(t.blobVersionedHashes=e.blobVersionedHashes),typeof e.blobs<"u"&&(typeof e.blobs[0]!="string"?t.blobs=e.blobs.map(n=>pe(n)):t.blobs=e.blobs),typeof e.data<"u"&&(t.data=e.data),typeof e.from<"u"&&(t.from=e.from),typeof e.gas<"u"&&(t.gas=R(e.gas)),typeof e.gasPrice<"u"&&(t.gasPrice=R(e.gasPrice)),typeof e.maxFeePerBlobGas<"u"&&(t.maxFeePerBlobGas=R(e.maxFeePerBlobGas)),typeof e.maxFeePerGas<"u"&&(t.maxFeePerGas=R(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(t.maxPriorityFeePerGas=R(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(t.nonce=R(e.nonce)),typeof e.to<"u"&&(t.to=e.to),typeof e.type<"u"&&(t.type=yg[e.type]),typeof e.value<"u"&&(t.value=R(e.value)),t}function gg(e){return e.map(t=>({address:t.address,r:t.r?R(BigInt(t.r)):t.r,s:t.s?R(BigInt(t.s)):t.s,chainId:R(t.chainId),nonce:R(t.nonce),...typeof t.yParity<"u"?{yParity:R(t.yParity)}:{},...typeof t.v<"u"&&typeof t.yParity>"u"?{v:R(t.v)}:{}}))}function lu(e){if(!(!e||e.length===0))return e.reduce((t,{slot:n,value:r})=>{if(n.length!==66)throw new Zc({size:n.length,targetSize:66,type:"hex"});if(r.length!==66)throw new Zc({size:r.length,targetSize:66,type:"hex"});return t[n]=r,t},{})}function bg(e){const{balance:t,nonce:n,state:r,stateDiff:s,code:i}=e,a={};if(i!==void 0&&(a.code=i),t!==void 0&&(a.balance=R(t)),n!==void 0&&(a.nonce=R(n)),r!==void 0&&(a.state=lu(r)),s!==void 0){if(a.state)throw new Jy;a.stateDiff=lu(s)}return a}function Zs(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!be(n,{strict:!1}))throw new Et({address:n});if(t[n])throw new Yy({address:n});t[n]=bg(r)}return t}const wg=2n**256n-1n;function Nr(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:s,to:i}=e,a=t?xe(t):void 0;if(a&&!be(a.address))throw new Et({address:a.address});if(i&&!be(i))throw new Et({address:i});if(typeof n<"u"&&(typeof r<"u"||typeof s<"u"))throw new Xy;if(r&&r>wg)throw new bs({maxFeePerGas:r});if(s&&r&&s>r)throw new ws({maxFeePerGas:r,maxPriorityFeePerGas:s})}class vg extends _{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class jo extends _{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class xg extends _{constructor({maxPriorityFeePerGas:t}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Ne(t)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class Ql extends _{constructor({blockHash:t,blockNumber:n}){let r="Block";t&&(r=`Block at hash "${t}"`),n&&(r=`Block at number "${n}"`),super(`${r} could not be found.`,{name:"BlockNotFoundError"})}}const Xl={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ef(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Te(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?Te(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Xl[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=Eg(e.authorizationList)),t.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof t.v=="bigint"){if(t.v===0n||t.v===27n)return 0;if(t.v===1n||t.v===28n)return 1;if(t.v>=35n)return t.v%2n===0n?1:0}})(),t.type==="legacy"&&(delete t.accessList,delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,delete t.yParity),t.type==="eip2930"&&(delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas),t.type==="eip1559"&&delete t.maxFeePerBlobGas,t}function Eg(e){return e.map(t=>
42({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function tf(e){const t=(e.transactions??[]).map(n=>typeof n=="string"?n:ef(n));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 st(e,{blockHash:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",includeTransactions:s}={}){const i=s??!1,a=n!==void 0?R(n):void 0;let o=null;if(t?o=await e.request({method:"eth_getBlockByHash",params:[t,i]},{dedupe:!0}):o=await e.request({method:"eth_getBlockByNumber",params:[a||r,i]},{dedupe:!!a}),!o)throw new Ql({blockHash:t,blockNumber:n});return(e.chain?.formatters?.block?.format||tf)(o)}async function Lo(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function _g(e,t){return nf(e,t)}async function nf(e,t){const{block:n,chain:r=e.chain,request:s}=t||{};try{const i=r?.fees?.maxPriorityFeePerGas??r?.fees?.defaultPriorityFee;if(typeof i=="function"){const o=n||await z(e,st,"getBlock")({}),c=await i({block:o,client:e,request:s});if(c===null)throw new Error;return c}if(typeof i<"u")return i;const a=await e.request({method:"eth_maxPriorityFeePerGas"});return de(a)}catch{const[i,a]=await Promise.all([n?Promise.resolve(n):z(e,st,"getBlock")({}),z(e,Lo,"getGasPrice")({})]);if(typeof i.baseFeePerGas!="bigint")throw new jo;const o=a-i.baseFeePerGas;return o<0n?0n:o}}async function rf(e,t){return ba(e,t)}async function ba(e,t){const{block:n,chain:r=e.chain,request:s,type:i="eip1559"}=t||{},a=await(async()=>typeof r?.fees?.baseFeeMultiplier=="function"?r.fees.baseFeeMultiplier({block:n,client:e,request:s}):r?.fees?.baseFeeMultiplier??1.2)();if(a<1)throw new vg;const c=10**(a.toString().split(".")[1]?.length??0),u=f=>f*BigInt(Math.ceil(a*c))/BigInt(c),l=n||await z(e,st,"getBlock")({});if(typeof r?.fees?.estimateFeesPerGas=="function"){const f=await r.fees.estimateFeesPerGas({block:n,client:e,multiply:u,request:s,type:i});if(f!==null)return f}if(i==="eip1559"){if(typeof l.baseFeePerGas!="bigint")throw new jo;const f=typeof s?.maxPriorityFeePerGas=="bigint"?s.maxPriorityFeePerGas:await nf(e,{block:l,chain:r,request:s}),p=u(l.baseFeePerGas);return{maxFeePerGas:s?.maxFeePerGas??p+f,maxPriorityFeePerGas:f}}return{gasPrice:s?.gasPrice??u(await z(e,Lo,"getGasPrice")({}))}}async function Uo(e,{address:t,blockTag:n="latest",blockNumber:r}){const s=await e.request({method:"eth_getTransactionCount",params:[t,typeof r=="bigint"?R(r):n]},{dedupe:!!r});return Te(s)}function sf(e){const{kzg:t}=e,n=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),r=typeof e.blobs[0]=="string"?e.blobs.map(i=>Ae(i)):e.blobs,s=[];for(const i of r)s.push(Uint8Array.from(t.blobToKzgCommitment(i)));return n==="bytes"?s:s.map(i=>pe(i))}function af(e){const{kzg:t}=e,n=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),r=typeof e.blobs[0]=="string"?e.blobs.map(a=>Ae(a)):e.blobs,s=typeof e.commitments[0]=="string"?e.commitments.map(a=>Ae(a)):e.commitments,i=[];for(let a=0;a<r.length;a++){const o=r[a],c=s[a];i.push(Uint8Array.from(t.computeBlobKzgProof(o,c)))}return n==="bytes"?i:i.map(a=>pe(a))}function Sg(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),a=Number(n>>s&i),o=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,o,r)}function Ag(e,t,n){return e&t^~e&n}function kg(e,t,n){return e&t^e&n^t&n}let Ig=class extends _l{constructor(t,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(t),this.view=gi(this.buffer)}update(t){ms(this),t=ko(t),ir(t);const{view:n,buffer:r,blockLen:s}=this,i=t.length;for(let a=0;a<i;){const o=Math.min(s-this.pos,i-a);if(o===s){const c=gi(t);for(;s<=i-a;a+=s)this.process(c,a);continue}r.set(t.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ms(this),El(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:i}=this;let{pos:a}=this;n[a++]=128,ar(this.buffer.subarray(a)),this.padOffset>s-a&&(this.process(r,0),a=0);for(let d=a;d<s;d++)n[d]=0;Sg(r,s-8,BigInt(this.length*8),i),this.process(r,0);
42const o=gi(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)o.setUint32(4*d,l[d],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:i,destroyed:a,pos:o}=this;return t.destroyed=a,t.finished=i,t.length=s,t.pos=o,s%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}};const kt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pg=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]),It=new Uint32Array(64);let Tg=class extends Ig{constructor(t=32){super(64,t,8,!1),this.A=kt[0]|0,this.B=kt[1]|0,this.C=kt[2]|0,this.D=kt[3]|0,this.E=kt[4]|0,this.F=kt[5]|0,this.G=kt[6]|0,this.H=kt[7]|0}get(){const{A:t,B:n,C:r,D:s,E:i,F:a,G:o,H:c}=this;return[t,n,r,s,i,a,o,c]}set(t,n,r,s,i,a,o,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=c|0}process(t,n){for(let d=0;d<16;d++,n+=4)It[d]=t.getUint32(n,!1);for(let d=16;d<64;d++){const f=It[d-15],p=It[d-2],y=et(f,7)^et(f,18)^f>>>3,h=et(p,17)^et(p,19)^p>>>10;It[d]=h+It[d-7]+y+It[d-16]|0}let{A:r,B:s,C:i,D:a,E:o,F:c,G:u,H:l}=this;for(let d=0;d<64;d++){const f=et(o,6)^et(o,11)^et(o,25),p=l+f+Ag(o,c,u)+Pg[d]+It[d]|0,h=(et(r,2)^et(r,13)^et(r,22))+kg(r,s,i)|0;l=u,u=c,c=o,o=a+p|0,a=i,i=s,s=r,r=p+h|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,i,a,o,c,u,l)}roundClean(){ar(It)}destroy(){this.set(0,0,0,0,0,0,0,0),ar(this.buffer)}};const Og=Sl(()=>new Tg),Cg=Og;function Bg(e,t){return Cg(we(e,{strict:!1})?Un(e):e)}function $g(e){const{commitment:t,version:n=1}=e,r=e.to??(typeof t=="string"?"hex":"bytes"),s=Bg(t);return s.set([n],0),r==="bytes"?s:pe(s)}function Ng(e){const{commitments:t,version:n}=e,r=e.to,s=[];for(const i of t)s.push($g({commitment:i,to:r,version:n}));return s}const fu=6,of=32,Do=4096,cf=of*Do,pu=cf*fu-1-1*Do*fu;class Mg extends _{constructor({maxSize:t,size:n}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${n} bytes`],name:"BlobSizeTooLargeError"})}}class Rg extends _{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function jg(e){const t=typeof e.data=="string"?Ae(e.data):e.data,n=re(t);if(!n)throw new Rg;if(n>pu)throw new Mg({maxSize:pu,size:n});const r=[];let s=!0,i=0;for(;s;){const a=Bo(new Uint8Array(cf));let o=0;for(;o<Do;){const c=t.slice(i,i+(of-1));if(a.pushByte(0),a.pushBytes(c),c.length<31){a.pushByte(128),s=!1;break}o++,i+=31}r.push(a)}return r.map(a=>pe(a.bytes))}function Lg(e){const{data:t,kzg:n,to:r}=e,s=e.blobs??jg({data:t}),i=e.commitments??sf({blobs:s,kzg:n,to:r}),a=e.proofs??af({blobs:s,commitments:i,kzg:n,to:r}),o=[];for(let c=0;c<s.length;c++)o.push({blob:s[c],commitment:i[c],proof:a[c]});return o}function Ug(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new eg({transaction:e})}async function Mr(e){const t=await e.request({method:"eth_chainId"},{dedupe:!0});return Te(t)}const Dg=["blobVersionedHashes","chainId","fees","gas","nonce","type"],hu=new Map;async function uf(e,t){const{account:n=e.account,blobs:r,chain:s,gas:i,kzg:a,nonce:o,nonceManager:c,parameters:u=Dg,type:l}=t,d=n&&xe(n),f={...t,...d?{from:d?.address}:{}};let p;async function y(){return p||(p=await z(e,st,"getBlock")({blockTag:"latest"}),p)}let h;async function m(){return h||(s?s.id:typeof t.chainId<"u"?t.chainId:(h=await z(e,Mr,"getChainId")({}),h))}if(u.includes("nonce")&&typeof o>"u"&&d)if(c){const g=await m();f.nonce=await c.consume({address:d.address,chainId:g,client:e})}else f.nonce=await z(e,Uo,"getTransactionCount")({address:d.address,blockTag:"pending"});if((u.includes("blobVersionedHashes")||u.includes("sidecars"))&&r&&a){const g=sf({blobs:r,kzg:
42a});if(u.includes("blobVersionedHashes")){const b=Ng({commitments:g,to:"hex"});f.blobVersionedHashes=b}if(u.includes("sidecars")){const b=af({blobs:r,commitments:g,kzg:a}),w=Lg({blobs:r,commitments:g,proofs:b,to:"hex"});f.sidecars=w}}if(u.includes("chainId")&&(f.chainId=await m()),(u.includes("fees")||u.includes("type"))&&typeof l>"u")try{f.type=Ug(f)}catch{let g=hu.get(e.uid);typeof g>"u"&&(g=typeof(await y())?.baseFeePerGas=="bigint",hu.set(e.uid,g)),f.type=g?"eip1559":"legacy"}if(u.includes("fees"))if(f.type!=="legacy"&&f.type!=="eip2930"){if(typeof f.maxFeePerGas>"u"||typeof f.maxPriorityFeePerGas>"u"){const g=await y(),{maxFeePerGas:b,maxPriorityFeePerGas:w}=await ba(e,{block:g,chain:s,request:f});if(typeof t.maxPriorityFeePerGas>"u"&&t.maxFeePerGas&&t.maxFeePerGas<w)throw new xg({maxPriorityFeePerGas:w});f.maxPriorityFeePerGas=w,f.maxFeePerGas=b}}else{if(typeof t.maxFeePerGas<"u"||typeof t.maxPriorityFeePerGas<"u")throw new jo;if(typeof t.gasPrice>"u"){const g=await y(),{gasPrice:b}=await ba(e,{block:g,chain:s,request:f,type:"legacy"});f.gasPrice=b}}return u.includes("gas")&&typeof i>"u"&&(f.gas=await z(e,zo,"estimateGas")({...f,account:d&&{address:d.address,type:"json-rpc"}})),Nr(f),delete f.parameters,f}async function df(e,{address:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest"}){const s=typeof n=="bigint"?R(n):void 0,i=await e.request({method:"eth_getBalance",params:[t,s||r]});return BigInt(i)}async function zo(e,t){const{account:n=e.account}=t,r=n?xe(n):void 0;try{let E=function(M){const{block:I,request:T,rpcStateOverride:O}=M;return e.request({method:"eth_estimateGas",params:O?[T,I??e.experimental_blockTag??"latest",O]:I?[T,I]:[T]})};const{accessList:s,authorizationList:i,blobs:a,blobVersionedHashes:o,blockNumber:c,blockTag:u,data:l,gas:d,gasPrice:f,maxFeePerBlobGas:p,maxFeePerGas:y,maxPriorityFeePerGas:h,nonce:m,value:g,stateOverride:b,...w}=await uf(e,{...t,parameters:r?.type==="local"?void 0:["blobVersionedHashes"]}),S=(typeof c=="bigint"?R(c):void 0)||u,A=Zs(b),k=await(async()=>{if(w.to)return w.to;if(i&&i.length>0)return await pg({authorization:i[0]}).catch(()=>{throw new _("`to` is required. Could not infer from `authorizationList`")})})();Nr(t);const $=e.chain?.formatters?.transactionRequest?.format,C=($||Ks)({...Ro(w,{format:$}),from:r?.address,accessList:s,authorizationList:i,blobs:a,blobVersionedHashes:o,data:l,gas:d,gasPrice:f,maxFeePerBlobGas:p,maxFeePerGas:y,maxPriorityFeePerGas:h,nonce:m,to:k,value:g});let P=BigInt(await E({block:S,request:C,rpcStateOverride:A}));if(i){const M=await df(e,{address:C.from}),I=await Promise.all(i.map(async T=>{const{address:O}=T,N=await E({block:S,request:{authorizationList:void 0,data:l,from:r?.address,to:O,value:R(M)},rpcStateOverride:A}).catch(()=>100000n);return 2n*BigInt(N)}));P+=I.reduce((T,O)=>T+O,0n)}return P}catch(s){throw mg(s,{...t,account:r,chain:e.chain})}}async function zg(e,t){const{abi:n,address:r,args:s,functionName:i,dataSuffix:a,...o}=t,c=he({abi:n,args:s,functionName:i});try{return await z(e,zo,"estimateGas")({data:`${c}${a?a.replace("0x",""):""}`,to:r,...o})}catch(u){const l=o.account?xe(o.account):void 0;throw In(u,{abi:n,address:r,args:s,docsPath:"/docs/contract/estimateContractGas",functionName:i,sender:l?.address})}}function Rr(e,t){if(!be(e,{strict:!1}))throw new Et({address:e});if(!be(t,{strict:!1}))throw new Et({address:t});return e.toLowerCase()===t.toLowerCase()}const mu="/docs/contract/decodeEventLog";function Fo(e){const{abi:t,data:n,strict:r,topics:s}=e,i=r??!0,[a,...o]=s;if(!a)throw new Nm({docsPath:mu});const c=t.find(h=>h.type==="event"&&a===Fs(Qe(h)));if(!(c&&"name"in c)||c.type!=="event")throw new ml(a,{docsPath:mu});const{name:u,inputs:l}=c,d=l?.some(h=>!("name"in h&&h.name)),f=d?[]:{},p=l.map((h,m)=>[h,m]).filter(([h])=>"indexed"in h&&h.indexed);for(let h=0;h<p.length;h++){const[m,g]=p[h],b=o[h];if(!b)throw new zs({abiItem:c,param:m});f[d?g:m.name||g]=Fg({param:m,value:b})}const y=l.filter(h=>!("indexed"in h&&h.indexed));if(y.length>0){if(n&&n!=="0x")try{const h=cn(y,n);if(h)if(d)for(let m=0;m<l.length;m++)f[m]=f[m]??h.shift();else for(let m=0;m<y.length;m++)f[y[m].name]=h[m]}catch(h){if(i)throw h instanceof fl||h instanceof Ul?new sr({abiItem:c,data:n,params:y,size:re(n)}):h}else if(i)throw new sr({abiItem:c,data:"0x",params:y,size:0})}return{eventName:u,args:Object.values(f).length>0?f:void 0}}function Fg({param:e,value:t}){return e.type==="string"||e.type==="bytes"||e.type==="tuple"||e.type.match(/^(.*)\[(\d+)?\]$/)?t:(cn([e],t)||[])[0]}function Ho(e){const{abi:t,args:n,logs:r,strict:s=!0}=e,i=(()=>
42{if(e.eventName)return Array.isArray(e.eventName)?e.eventName:[e.eventName]})();return r.map(a=>{try{const o=t.find(u=>u.type==="event"&&a.topics[0]===Fs(u));if(!o)return null;const c=Fo({...a,abi:[o],strict:s});return i&&!i.includes(c.eventName)||!Hg({args:c.args,inputs:o.inputs,matchArgs:n})?null:{...c,...a}}catch(o){let c,u;if(o instanceof ml)return null;if(o instanceof sr||o instanceof zs){if(s)return null;c=o.abiItem.name,u=o.abiItem.inputs?.some(l=>!("name"in l&&l.name))}return{...a,args:u?[]:{},eventName:c}}}).filter(Boolean)}function Hg(e){const{args:t,inputs:n,matchArgs:r}=e;if(!r)return!0;if(!t)return!1;function s(i,a,o){try{return i.type==="address"?Rr(a,o):i.type==="string"||i.type==="bytes"?X(Un(a))===o:a===o}catch{return!1}}return Array.isArray(t)&&Array.isArray(r)?r.every((i,a)=>{if(i==null)return!0;const o=n[a];return o?(Array.isArray(i)?i:[i]).some(u=>s(o,u,t[a])):!1}):typeof t=="object"&&!Array.isArray(t)&&typeof r=="object"&&!Array.isArray(r)?Object.entries(r).every(([i,a])=>{if(a==null)return!0;const o=n.find(u=>u.name===i);return o?(Array.isArray(a)?a:[a]).some(u=>s(o,u,t[i])):!1}):!1}function at(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 Go(e,{address:t,blockHash:n,fromBlock:r,toBlock:s,event:i,events:a,args:o,strict:c}={}){const u=c??!1,l=a??(i?[i]:void 0);let d=[];l&&(d=[l.flatMap(h=>Br({abi:[h],eventName:h.name,args:a?void 0:o}))],i&&(d=d[0]));let f;n?f=await e.request({method:"eth_getLogs",params:[{address:t,topics:d,blockHash:n}]}):f=await e.request({method:"eth_getLogs",params:[{address:t,topics:d,fromBlock:typeof r=="bigint"?R(r):r,toBlock:typeof s=="bigint"?R(s):s}]});const p=f.map(y=>at(y));return l?Ho({abi:l,args:o,logs:p,strict:u}):p}async function lf(e,t){const{abi:n,address:r,args:s,blockHash:i,eventName:a,fromBlock:o,toBlock:c,strict:u}=t,l=a?on({abi:n,name:a}):void 0,d=l?void 0:n.filter(f=>f.type==="event");return z(e,Go,"getLogs")({address:r,args:s,blockHash:i,event:l,events:d,fromBlock:o,toBlock:c,strict:u})}const vi="/docs/contract/decodeFunctionResult";function un(e){const{abi:t,args:n,functionName:r,data:s}=e;let i=t[0];if(r){const o=on({abi:t,args:n,name:r});if(!o)throw new An(r,{docsPath:vi});i=o}if(i.type!=="function")throw new An(void 0,{docsPath:vi});if(!i.outputs)throw new yl(i.name,{docsPath:vi});const a=cn(i.outputs,s);if(a&&a.length>1)return a;if(a&&a.length===1)return a[0]}const Gg="0.1.1";function qg(){return Gg}let ce=class wa extends Error{constructor(t,n={}){const r=(()=>{if(n.cause instanceof wa){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:n.cause?.message?n.cause.message:n.details})(),s=n.cause instanceof wa&&n.cause.docsPath||n.docsPath,a=`https://oxlib.sh${s??""}`,o=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||s?["",r?`Details: ${r}`:void 0,s?`See: ${a}`:void 0]:[]].filter(c=>typeof c=="string").join(` 43`);super(o,n.cause?{cause:n.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@${qg()}`}),this.cause=n.cause,this.details=r,this.docs=a,this.docsPath=s,this.shortMessage=t}walk(t){return ff(this,t)}};function ff(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?ff(e.cause,t):t?null:e}const Vg="#__bigint";function Wg(e,t,n){return JSON.stringify(e,(r,s)=>typeof s=="bigint"?s.toString()+Vg:s,n)}function Kg(e,t){if(gu(e)>t)throw new sb({givenSize:gu(e),maxSize:t})}const lt={zero:48,nine:57,A:65,F:70,a:97,f:102};function yu(e){if(e>=lt.zero&&e<=lt.nine)return e-lt.zero;if(e>=lt.A&&e<=lt.F)return e-(lt.A-10);if(e>=lt.a&&e<=lt.f)return e-(lt.a-10)}function Zg(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new ib({size:e.length,targetSize:r,type:"Bytes"});const s=new Uint8Array(r);for(let i=0;i<r;i++){const a=n==="right";s[a?i:r-i-1]=e[a?i:e.length-i-1]}return s}function qo(e,t){if(Ge(e)>t)throw new db({givenSize:Ge(e),maxSize:t})}function Yg(e,t){if(typeof t=="number"&&t>0&&t>Ge(e)-1)throw new gf({offset:t,position:"start",size:Ge(e)})}function Jg(e,t,n){if(typeof t=="number"&&typeof n=="number"&&Ge(e)!==n-t)throw new gf({offset:n,position:"end",size:Ge(e)})}function pf(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const s=e.replace("0x","");if(s.length>r*2)throw new lb({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s[n==="right"?"padEnd":"padStart"](r*2,"0")}`}const Qg=new TextEncoder;function Xg(e){return e instanceof Uint8Array?e:typeof e=="string"?tb(e):eb(e)}function eb(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function tb(e,t={}){const{size:n}=t;let r=e;n&&(qo(e,n),r=sn(e,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,a=new Uint8Array(i);for(let o=0,c=0;o<i;o++){const u=yu(s.charCodeAt(c++)),l=yu(s.charCodeAt(c++));if(u===void 0||l===void 0)throw new ce(`Invalid byte sequence ("${s[c-2]}${s[c-1]}" in "${s}").`);a[o]=u*16+l}return a}
43function nb(e,t={}){const{size:n}=t,r=Qg.encode(e);return typeof n=="number"?(Kg(r,n),rb(r,n)):r}function rb(e,t){return Zg(e,{dir:"right",size:t})}function gu(e){return e.length}let sb=class extends ce{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}},ib=class extends ce{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}};const ab=new TextEncoder,ob=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function cb(e,t={}){const{strict:n=!1}=t;if(!e)throw new bu(e);if(typeof e!="string")throw new bu(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new wu(e);if(!e.startsWith("0x"))throw new wu(e)}function ot(...e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function hf(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(qo(n,t.size),rn(n,t.size)):n}function mf(e,t={}){let n="";for(let s=0;s<e.length;s++)n+=ob[e[s]];const r=`0x${n}`;return typeof t.size=="number"?(qo(r,t.size),sn(r,t.size)):r}function Ee(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<a){const u=typeof e=="bigint"?"n":"";throw new yf({max:i?`${i}${u}`:void 0,min:`${a}${u}`,signed:n,size:r,value:`${e}${u}`})}const c=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?rn(c,r):c}function Vo(e,t={}){return mf(ab.encode(e),t)}function rn(e,t){return pf(e,{dir:"left",size:t})}function sn(e,t){return pf(e,{dir:"right",size:t})}function Wo(e,t,n,r={}){const{strict:s}=r;Yg(e,t);const i=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return s&&Jg(i,t,n),i}function Ge(e){return Math.ceil((e.length-2)/2)}function ub(e,t={}){const{strict:n=!1}=t;try{return cb(e,{strict:n}),!0}catch{return!1}}let yf=class extends ce{constructor({max:t,min:n,signed:r,size:s,value:i}){super(`Number \`${i}\` is not in safe${s?` ${s*8}-bit`:""}${r?" signed":" unsigned"} integer range ${t?`(\`${n}\` to \`${t}\`)`:`(above \`${n}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}},bu=class extends ce{constructor(t){super(`Value \`${typeof t=="object"?Wg(t):t}\` of type \`${typeof t}\` 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"})}},wu=class extends ce{constructor(t){super(`Value \`${t}\` 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"})}},db=class extends ce{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}},gf=class extends ce{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}},lb=class extends ce{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}};function fb(e){return{address:e.address,amount:Ee(e.amount),index:Ee(e.index),validatorIndex:Ee(e.validatorIndex)}}function bf(e){return{...typeof e.baseFeePerGas=="bigint"&&{baseFeePerGas:Ee(e.baseFeePerGas)},...typeof e.blobBaseFee=="bigint"&&{blobBaseFee:Ee(e.blobBaseFee)},...typeof e.feeRecipient=="string"&&{feeRecipient:e.feeRecipient}
43,...typeof e.gasLimit=="bigint"&&{gasLimit:Ee(e.gasLimit)},...typeof e.number=="bigint"&&{number:Ee(e.number)},...typeof e.prevRandao=="bigint"&&{prevRandao:Ee(e.prevRandao)},...typeof e.time=="bigint"&&{time:Ee(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(fb)}}}const va=[{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"}],xa=[{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"}]}],wf=[{inputs:[],name:"ResolverNotFound",type:"error"},{inputs:[],name:"ResolverWildcardNotSupported",type:"error"},{inputs:[],name:"ResolverNotContract",type:"error"},{inputs:[{name:"returnData",type:"bytes"}],name:"ResolverError",type:"error"},{inputs:[{components:[{name:"status",type:"uint16"},{name:"message",type:"string"}],name:"errors",type:"tuple[]"}],name:"HttpError",type:"error"}],vf=[...wf,{name:"resolve",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]},{name:"resolve",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"}]}],pb=[...wf,{name:"reverse",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolvedAddress"},{type:"address",name:"reverseResolver"},{type:"address",name:"resolver"}]},{name:"reverse",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"},{type:"string[]",name:"gateways"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolvedAddress"},{type:"address",name:"reverseResolver"},{type:"address",name:"resolver"}]}],vu=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],xu=[{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"}]}],Eu=[{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"}],hb=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],mb="0x82ad56cb",xf="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b
43602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",yb="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",gb="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848
43603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572";class Ea extends _{constructor({blockNumber:t,chain:n,contract:r}){super(`Chain "${n.name}" does not support contract "${r.name}".`,{metaMessages:["This could be due to any of the following:",...t&&r.blockCreated&&r.blockCreated>t?[`- The contract "${r.name}" was not deployed until block ${r.blockCreated} (current block ${t}).`]:[`- The chain does not have the contract "${r.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class Ef extends _{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}const xi="/docs/contract/encodeDeployData";function Ko(e){const{abi:t,args:n,bytecode:r}=e;if(!n||n.length===0)return r;const s=t.find(a=>"type"in a&&a.type==="constructor");if(!s)throw new Om({docsPath:xi});if(!("inputs"in s))throw new Vc({docsPath:xi});if(!s.inputs||s.inputs.length===0)throw new Vc({docsPath:xi});const i=$e(s.inputs,n);return jt([r,i])}function Dn({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new Ea({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new Ea({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function _f(e,{docsPath:t,...n}){const r=(()=>{const s=Mo(e,n);return s instanceof Ws?e:s})();return new Vl(r,{docsPath:t,...n})}function Zo(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}const Ei=new Map;function Sf({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:s}){const i=async()=>{const l=c();a();const d=l.map(({args:f})=>f);d.length!==0&&e(d).then(f=>{s&&Array.isArray(f)&&f.sort(s);for(let p=0;p<l.length;p++){const{resolve:y}=l[p];y?.([f[p],f])}}).catch(f=>{for(let p=0;p<l.length;p++){const{reject:y}=l[p];y?.(f)}})},a=()=>Ei.delete(t),o=()=>c().map(({args:l})=>l),c=()=>Ei.get(t)||[],u=l=>Ei.set(t,[...c(),l]);return{flush:a,async schedule(l){const{promise:d,resolve:f,reject:p}=Zo();return n?.([...o(),l])&&i(),c().length>0?(u({args:l,resolve:f,reject:p}),d):(u({args:l,resolve:f,reject:p}),setTimeout(i,r),d)}}}async function Ys(e,t){const{account:n=e.account,authorizationList:r,batch:s=!!e.batch?.multicall,blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",accessList:o,blobs:c,blockOverrides:u,code:l,data:d,factory:f,factoryData:p,gas:y,gasPrice:h,maxFeePerBlobGas:m,maxFeePerGas:g,maxPriorityFeePerGas:b,nonce:w,to:x,value:S,stateOverride:A,...k}=t,$=n?xe(n):void 0;if(l&&(f||p))throw new _("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(l&&x)throw new _("Cannot provide both `code` & `to` as parameters.");const v=l&&d,C=f&&p&&x&&d,E=v||C,P=v?vb({code:l,data:d}):C?xb({data:d,factory:f,factoryData:p,to:x}):d;try{Nr(t);const I=(typeof i=="bigint"?R(i):void 0)||a,T=u?bf(u):void 0,O=Zs(A),N=e.chain?.formatters?.transactionRequest?.format,D=(N||Ks)({...Ro(k,{format:N}),from:$?.address,accessList:o,authorizationList:r,blobs:c,data:P,gas:y,gasPrice:h,maxFeePerBlobGas:m,maxFeePerGas:g,maxPriorityFeePerGas:b,nonce:w,to:E?void 0:x,value:S});if(s&&bb({request:D})&&!O&&!T)try{return await wb(e,{...D,blockNumber:i,blockTag:a})}catch(H){if(!(H instanceof Ef)&&!(H instanceof Ea))throw H}const F=(()=>{const H=[D,I];return O&&T?[...H,O,T]:O?[...H,O]:T?[...H,{},T]:H})(),U=await e.request({method:"eth_call",params:F});return U==="0x"?{data:void 0}:{data:U}}catch(M){const I=Eb(M),{offchainLookup:T,offchainLookupSignature:O}=await vd(async()=>{const{offchainLookup:N,offchainLookupSignature:B}=await import("./ccip-CC2QKXgd.js");return{offchainLookup:N,offchainLookupSignature:B}},__vite__mapDeps([0,1,2,3,4,5]));if(e.ccipRead!==!1&&I?.slice(0,10)===O&&x)return{data:await T(e,{data:I,to:x})};throw E&&I?.slice(0,10)==="0x101bb98d"?new rg({factory:f}):_f(M,{...t,account:$,chain:e.chain})}}function bb({request:e}){const{data:t,to:n,...r}=e;return!(!t||t.startsWith(mb)||!n||Object.values(r).filter(s=>typeof s<"u").length>0)}async function wb(e,t){const{batchSize:n=1024,wait:r=0}=typeof e.batch?.multicall=="object"?e.batch.multicall:{},{blockNumber:s,blockTag:i=e.experimental_blockTag??"latest",data:a,multicallAddress:o,to:c}=t;let u=o;if(!u){if(!e.chain)throw new Ef;u=Dn({blockNumber:s,chain:e.chain,contract:"multicall3"})}const d=(typeof s=="bigint"?R(s):void 0)||i,{schedule:f}=Sf({id:`${e.uid}.${d}`,wait:r,shouldSplitBatch(h){return h.reduce((g,{data:b})=>g+(b.length-2),0)>n*2},fn:async h=>{const m=h.map(w=>
43({allowFailure:!0,callData:w.data,target:w.to})),g=he({abi:va,args:[m],functionName:"aggregate3"}),b=await e.request({method:"eth_call",params:[{data:g,to:u},d]});return un({abi:va,args:[m],functionName:"aggregate3",data:b||"0x"})}}),[{returnData:p,success:y}]=await f({data:a,to:c});if(!y)throw new Vs({data:p});return p==="0x"?{data:void 0}:{data:p}}function vb(e){const{code:t,data:n}=e;return Ko({abi:po(["constructor(bytes, bytes)"]),bytecode:xf,args:[t,n]})}function xb(e){const{data:t,factory:n,factoryData:r,to:s}=e;return Ko({abi:po(["constructor(address, bytes, address, bytes)"]),bytecode:yb,args:[s,t,n,r]})}function Eb(e){if(!(e instanceof _))return;const t=e.walk();return typeof t?.data=="object"?t.data?.data:t.data}async function qe(e,t){const{abi:n,address:r,args:s,functionName:i,...a}=t,o=he({abi:n,args:s,functionName:i});try{const{data:c}=await z(e,Ys,"call")({...a,data:o,to:r});return un({abi:n,args:s,functionName:i,data:c||"0x"})}catch(c){throw In(c,{abi:n,address:r,args:s,docsPath:"/docs/contract/readContract",functionName:i})}}async function _b(e,t){const{abi:n,address:r,args:s,dataSuffix:i,functionName:a,...o}=t,c=o.account?xe(o.account):e.account,u=he({abi:n,args:s,functionName:a});try{const{data:l}=await z(e,Ys,"call")({batch:!1,data:`${u}${i?i.replace("0x",""):""}`,to:r,...o,account:c}),d=un({abi:n,args:s,functionName:a,data:l||"0x"}),f=n.filter(p=>"name"in p&&p.name===t.functionName);return{result:d,request:{abi:f,address:r,args:s,dataSuffix:i,functionName:a,...o,account:c}}}catch(l){throw In(l,{abi:n,address:r,args:s,docsPath:"/docs/contract/simulateContract",functionName:a,sender:c?.address})}}const _i=new Map,_u=new Map;let Sb=0;function ct(e,t,n){const r=++Sb,s=()=>_i.get(e)||[],i=()=>{const l=s();_i.set(e,l.filter(d=>d.id!==r))},a=()=>{const l=s();if(!l.some(f=>f.id===r))return;const d=_u.get(e);if(l.length===1&&d){const f=d();f instanceof Promise&&f.catch(()=>{})}i()},o=s();if(_i.set(e,[...o,{id:r,fns:t}]),o&&o.length>0)return a;const c={};for(const l in t)c[l]=((...d)=>{const f=s();if(f.length!==0)for(const p of f)p.fns[l]?.(...d)});const u=n(c);return typeof u=="function"&&_u.set(e,u),a}async function _a(e){return new Promise(t=>setTimeout(t,e))}function dn(e,{emitOnBegin:t,initialWaitTime:n,interval:r}){let s=!0;const i=()=>s=!1;return(async()=>{let o;t&&(o=await e({unpoll:i}));const c=await n?.(o)??r;await _a(c);const u=async()=>{s&&(await e({unpoll:i}),await _a(r),u())};u()})(),i}const Ab=new Map,kb=new Map;function Ib(e){const t=(s,i)=>({clear:()=>i.delete(s),get:()=>i.get(s),set:a=>i.set(s,a)}),n=t(e,Ab),r=t(e,kb);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}async function Pb(e,{cacheKey:t,cacheTime:n=Number.POSITIVE_INFINITY}){const r=Ib(t),s=r.response.get();if(s&&n>0&&new Date().getTime()-s.created.getTime()<n)return s.data;let i=r.promise.get();i||(i=e(),r.promise.set(i));try{const a=await i;return r.response.set({created:new Date,data:a}),a}finally{r.promise.clear()}}const Tb=e=>`blockNumber.${e}`;async function jr(e,{cacheTime:t=e.cacheTime}={}){const n=await Pb(()=>e.request({method:"eth_blockNumber"}),{cacheKey:Tb(e.uid),cacheTime:t});return BigInt(n)}async function Js(e,{filter:t}){const n="strict"in t&&t.strict,r=await t.request({method:"eth_getFilterChanges",params:[t.id]});if(typeof r[0]=="string")return r;const s=r.map(i=>at(i));return!("abi"in t)||!t.abi?s:Ho({abi:t.abi,logs:s,strict:n})}async function Qs(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function Ob(e,t){const{abi:n,address:r,args:s,batch:i=!0,eventName:a,fromBlock:o,onError:c,onLogs:u,poll:l,pollingInterval:d=e.pollingInterval,strict:f}=t;return(typeof l<"u"?l:typeof o=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].c
43onfig.type==="webSocket"||e.transport.transports[0].config.type==="ipc")))?(()=>{const m=f??!1,g=fe(["watchContractEvent",r,s,i,e.uid,a,d,m,o]);return ct(g,{onLogs:u,onError:c},b=>{let w;o!==void 0&&(w=o-1n);let x,S=!1;const A=dn(async()=>{if(!S){try{x=await z(e,Rl,"createContractEventFilter")({abi:n,address:r,args:s,eventName:a,strict:m,fromBlock:o})}catch{}S=!0;return}try{let k;if(x)k=await z(e,Js,"getFilterChanges")({filter:x});else{const $=await z(e,jr,"getBlockNumber")({});w&&w<$?k=await z(e,lf,"getContractEvents")({abi:n,address:r,args:s,eventName:a,fromBlock:w+1n,toBlock:$,strict:m}):k=[],w=$}if(k.length===0)return;if(i)b.onLogs(k);else for(const $ of k)b.onLogs([$])}catch(k){x&&k instanceof nn&&(S=!1),b.onError?.(k)}},{emitOnBegin:!0,interval:d});return async()=>{x&&await z(e,Qs,"uninstallFilter")({filter:x}),A()}})})():(()=>{const m=f??!1,g=fe(["watchContractEvent",r,s,i,e.uid,a,d,m]);let b=!0,w=()=>b=!1;return ct(g,{onLogs:u,onError:c},x=>((async()=>{try{const S=(()=>{if(e.transport.type==="fallback"){const $=e.transport.transports.find(v=>v.config.type==="webSocket"||v.config.type==="ipc");return $?$.value:e.transport}return e.transport})(),A=a?Br({abi:n,eventName:a,args:s}):[],{unsubscribe:k}=await S.subscribe({params:["logs",{address:r,topics:A}],onData($){if(!b)return;const v=$.result;try{const{eventName:C,args:E}=Fo({abi:n,data:v.data,topics:v.topics,strict:f}),P=at(v,{args:E,eventName:C});x.onLogs([P])}catch(C){let E,P;if(C instanceof sr||C instanceof zs){if(f)return;E=C.abiItem.name,P=C.abiItem.inputs?.some(I=>!("name"in I&&I.name))}const M=at(v,{args:P?[]:{},eventName:E});x.onLogs([M])}},onError($){x.onError?.($)}});w=k,b||w()}catch(S){c?.(S)}})(),()=>w()))})()}class Xs extends _{constructor({docsPath:t}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(` 44`),{docsPath:t,docsSlug:"account",name:"AccountNotFoundError"})}}async function Cb(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}const Af={"0x0":"reverted","0x1":"success"};function kf(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(n=>at(n)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Te(e.transactionIndex):null,status:e.status?Af[e.status]:null,type:e.type?Xl[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}const Bb="0x5792579257925792579257925792579257925792579257925792579257925792",$b=R(0,{size:32});async function Nb(e,t){async function n(l){if(l.endsWith(Bb.slice(2))){const f=Je(ys(l,-64,-32)),p=ys(l,0,-64).slice(2).match(/.{1,64}/g),y=await Promise.all(p.map(m=>$b.slice(2)!==m?e.request({method:"eth_getTransactionReceipt",params:[`0x${m}`]},{dedupe:!0}):void 0)),h=y.some(m=>m===null)?100:y.every(m=>m?.status==="0x1")?200:y.every(m=>m?.status==="0x0")?500:600;return{atomic:!1,chainId:Te(f),receipts:y.filter(Boolean),status:h,version:"2.0.0"}}return e.request({method:"wallet_getCallsStatus",params:[l]})}const{atomic:r=!1,chainId:s,receipts:i,version:a="2.0.0",...o}=await n(t.id),[c,u]=(()=>{const l=o.status;return l>=100&&l<200?["pending",l]:l>=200&&l<300?["success",l]:l>=300&&l<700?["failure",l]:l==="CONFIRMED"?["success",200]:l==="PENDING"?["pending",100]:[void 0,l]})();return{...o,atomic:r,chainId:s?Te(s):void 0,receipts:i?.map(l=>({...l,blockNumber:de(l.blockNumber),gasUsed:de(l.gasUsed),status:Af[l.status]}))??[],statusCode:u,status:c,version:a}}async function If(e,t){const{id:n,pollingInterval:r=e.pollingInterval,status:s=({statusCode:f})=>f>=200,timeout:i=6e4}=t,a=fe(["waitForCallsStatus",e.uid,n]),{promise:o,resolve:c,reject:u}=Zo();let l;const d=ct(a,{resolve:c,reject:u},f=>{const p=dn(async()=>{const y=h=>{clearTimeout(l),p(),h(),d()};try{const h=await Nb(e,{id:n});if(!s(h))return;y(()=>f.resolve(h))}catch(h){y(()=>f.reject(h))}},{interval:r,emitOnBegin:!0});return p});return l=i?setTimeout(()=>{d(),clearTimeout(l),u(new Mb({id:n}))},i):void 0,await o}class Mb extends _{constructor({id:t}){super(`Timed out while waiting for call bundle with id "${t}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}const Sa=256;let qr=Sa,Vr;function Pf(e=11){if(!Vr||qr+e>Sa*2){Vr="",qr=0;for(let t=0;t<Sa;t++)Vr+=(256+Math.random()*256|0).toString(16).substring(1)}return Vr.substring(qr,qr+++e)}
44function Tf(e){const{batch:t,chain:n,ccipRead:r,key:s="base",name:i="Base Client",type:a="base"}=e,o=e.experimental_blockTag??(typeof n?.experimental_preconfirmationTime=="number"?"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?xe(e.account):void 0,{config:p,request:y,value:h}=e.transport({chain:n,pollingInterval:l}),m={...p,...h},g={account:f,batch:t,cacheTime:d,ccipRead:r,chain:n,key:s,name:i,pollingInterval:l,request:y,transport:m,type:a,uid:Pf(),...o?{experimental_blockTag:o}:{}};function b(w){return x=>{const S=x(w);for(const k in g)delete S[k];const A={...w,...S};return Object.assign(A,{extend:b(A)})}}return Object.assign(g,{extend:b(g)})}const Wr=new Hs(8192);function Rb(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(Wr.get(n))return Wr.get(n);const r=e().finally(()=>Wr.delete(n));return Wr.set(n,r),r}function Aa(e,{delay:t=100,retryCount:n=2,shouldRetry:r=()=>!0}={}){return new Promise((s,i)=>{const a=async({count:o=0}={})=>{const c=async({error:u})=>{const l=typeof t=="function"?t({count:o,error:u}):t;l&&await _a(l),a({count:o+1})};try{const u=await e();s(u)}catch(u){if(o<n&&await r({count:o,error:u}))return c({error:u});i(u)}};a()})}function jb(e,t={}){return async(n,r={})=>{const{dedupe:s=!1,methods:i,retryDelay:a=150,retryCount:o=3,uid:c}={...t,...r},{method:u}=n;if(i?.exclude?.includes(u))throw new Gt(new Error("method not supported"),{method:u});if(i?.include&&!i.include.includes(u))throw new Gt(new Error("method not supported"),{method:u});const l=s?Xt(`${c}.${fe(n)}`):void 0;return Rb(()=>Aa(async()=>{try{return await e(n)}catch(d){const f=d;switch(f.code){case cr.code:throw new cr(f);case ur.code:throw new ur(f);case dr.code:throw new dr(f,{method:n.method});case lr.code:throw new lr(f);case tn.code:throw new tn(f);case nn.code:throw new nn(f);case fr.code:throw new fr(f);case pr.code:throw new pr(f);case hr.code:throw new hr(f);case Gt.code:throw new Gt(f,{method:n.method});case kn.code:throw new kn(f);case mr.code:throw new mr(f);case En.code:throw new En(f);case yr.code:throw new yr(f);case gr.code:throw new gr(f);case br.code:throw new br(f);case wr.code:throw new wr(f);case vr.code:throw new vr(f);case xr.code:throw new xr(f);case Er.code:throw new Er(f);case _r.code:throw new _r(f);case Sr.code:throw new Sr(f);case Ar.code:throw new Ar(f);case kr.code:throw new kr(f);case Ir.code:throw new Ir(f);case 5e3:throw new En(f);default:throw d instanceof _?d:new ig(f)}}},{delay:({count:d,error:f})=>{if(f&&f instanceof Qn){const p=f?.headers?.get("Retry-After");if(p?.match(/\d/))return Number.parseInt(p)*1e3}return~~(1<<d)*a},retryCount:o,shouldRetry:({error:d})=>Lb(d)}),{enabled:s,id:l})}}function Lb(e){return"code"in e&&typeof e.code=="number"?e.code===-1||e.code===kn.code||e.code===tn.code:e instanceof Qn&&e.status?e.status===403||e.status===408||e.status===4
4413||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504:!0}function Ub({key:e,methods:t,name:n,request:r,retryCount:s=3,retryDelay:i=150,timeout:a,type:o},c){const u=Pf();return{config:{key:e,methods:t,name:n,request:r,retryCount:s,retryDelay:i,timeout:a,type:o},request:jb(r,{methods:t,retryCount:s,retryDelay:i,uid:u}),value:c}}class Db extends _{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 zb(e,{errorInstance:t=new Error("timed out"),timeout:n,signal:r}){return new Promise((s,i)=>{(async()=>{let a;try{const o=new AbortController;n>0&&(a=setTimeout(()=>{r&&o.abort()},n)),s(await e({signal:o?.signal||null}))}catch(o){o?.name==="AbortError"&&i(t),i(o)}finally{clearTimeout(a)}})()})}function Fb(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const Su=Fb();function Hb(e,t={}){return{async request(n){const{body:r,onRequest:s=t.onRequest,onResponse:i=t.onResponse,timeout:a=t.timeout??1e4}=n,o={...t.fetchOptions??{},...n.fetchOptions??{}},{headers:c,method:u,signal:l}=o;try{const d=await zb(async({signal:p})=>{const y={...o,body:Array.isArray(r)?fe(r.map(b=>({jsonrpc:"2.0",id:b.id??Su.take(),...b}))):fe({jsonrpc:"2.0",id:r.id??Su.take(),...r}),headers:{"Content-Type":"application/json",...c},method:u||"POST",signal:l||(a>0?p:null)},h=new Request(e,y),m=await s?.(h,y)??{...y,url:e};return await fetch(m.url??e,m)},{errorInstance:new uu({body:r,url:e}),timeout:a,signal:!0});i&&await i(d);let f;if(d.headers.get("Content-Type")?.startsWith("application/json"))f=await d.json();else{f=await d.text();try{f=JSON.parse(f||"{}")}catch(p){if(d.ok)throw p;f={error:f}}}if(!d.ok)throw new Qn({body:r,details:fe(f.error)||d.statusText,headers:d.headers,status:d.status,url:e});return f}catch(d){throw d instanceof Qn||d instanceof uu?d:new Qn({body:r,cause:d,url:e})}}}}function Au(e,t={}){const{batch:n,fetchOptions:r,key:s="http",methods:i,name:a="HTTP JSON-RPC",onFetchRequest:o,onFetchResponse:c,retryDelay:u,raw:l}=t;return({chain:d,retryCount:f,timeout:p})=>{const{batchSize:y=1e3,wait:h=0}=typeof n=="object"?n:{},m=t.retryCount??f,g=p??t.timeout??1e4,b=e||d?.rpcUrls.default.http[0];if(!b)throw new Db;const w=Hb(b,{fetchOptions:r,onRequest:o,onResponse:c,timeout:g});return Ub({key:s,methods:i,name:a,async request({method:x,params:S}){const A={method:x,params:S},{schedule:k}=Sf({id:b,wait:h,shouldSplitBatch(E){return E.length>y},fn:E=>w.request({body:E}),sort:(E,P)=>E.id-P.id}),$=async E=>n?k(E):[await w.request({body:E})],[{error:v,result:C}]=await $(A);if(l)return{error:v,result:C};if(v)throw new No({body:A,error:v,url:b});return C},retryCount:m,retryDelay:u,timeout:g,type:"http"},{fetchOptions:r,url:b})}}function Yo(e,t){if(!(e instanceof _))return!1;const n=e.walk(r=>r instanceof gs);return n instanceof gs?!!(n.data?.errorName==="ResolverNotFound"||n.data?.errorName==="ResolverWildcardNotSupported"||n.data?.errorName==="ResolverNotContract"||n.data?.errorName==="ResolverError"||n.data?.errorName==="HttpError"||n.reason?.includes("Wildcard on non-extended resolvers is not supported")||t==="reverse"&&n.reason===jl[50]):!1}function Jo(e){const{abi:t,data:n}=e,r=en(n,0,4),s=t.find(i=>i.type==="function"&&r===Cr(Qe(i)));if(!s)throw new Mm(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:s.name,args:"inputs"in s&&s.inputs&&s.inputs.length>0?cn(s.inputs,en(n,4)):void 0}}const Si="/docs/contract/encodeErrorResult";function ku(e){const{abi:t,errorName:n,args:r}=e;let s=t[0];if(n){const c=on({abi:t,args:r,name:n});if(!c)throw new Wc(n,{docsPath:Si});s=c}if(s.type!=="error")throw new Wc(void 0,{docsPath:Si});const i=Qe(s),a=Cr(i);let o="0x";if(r&&r.length>0){if(!s.inputs)throw new $m(s.name,{docsPath:Si});o=$e(s.inputs,r)}return jt([a,o])}const Ai="/docs/contract/encodeFunctionResult";function Gb(e){const{abi:t,functionName:n,result:r}=e;let s=t[0];if(n){const a=on({abi:t,name:n});if(!a)throw new An(n,{docsPath:Ai});s=a}if(s.type!=="function")throw new An(void 0,{docsPath:Ai});if(!s.outputs)throw new yl(s.name,{docsPath:Ai});const i=(()=>
44{if(s.outputs.length===0)return[];if(s.outputs.length===1)return[r];if(Array.isArray(r))return r;throw new bl(r)})();return $e(s.outputs,i)}const Qo="x-batch-gateway:true";async function qb(e){const{data:t,ccipRequest:n}=e,{args:[r]}=Jo({abi:xa,data:t}),s=[],i=[];return await Promise.all(r.map(async(a,o)=>{try{i[o]=a.urls.includes(Qo)?await qb({data:a.data,ccipRequest:n}):await n(a),s[o]=!1}catch(c){s[o]=!0,i[o]=Vb(c)}})),Gb({abi:xa,functionName:"query",result:[s,i]})}function Vb(e){return e.name==="HttpRequestError"&&e.status?ku({abi:xa,errorName:"HttpError",args:[e.status,e.shortMessage]}):ku({abi:[Ll],errorName:"Error",args:["shortMessage"in e?e.shortMessage:e.message]})}function Of(e){if(e.length!==66||e.indexOf("[")!==0||e.indexOf("]")!==65)return null;const t=`0x${e.slice(1,65)}`;return we(t)?t:null}function us(e){let t=new Uint8Array(32).fill(0);if(!e)return pe(t);const n=e.split(".");for(let r=n.length-1;r>=0;r-=1){const s=Of(n[r]),i=s?Un(s):X(vt(n[r]),"bytes");t=X(ve([t,i]),"bytes")}return pe(t)}function Wb(e){return`[${e.slice(2)}]`}function Kb(e){const t=new Uint8Array(32).fill(0);return e?Of(e)||X(vt(e)):pe(t)}function ei(e){const t=e.replace(/^\.|\.$/gm,"");if(t.length===0)return new Uint8Array(1);const n=new Uint8Array(vt(t).byteLength+2);let r=0;const s=t.split(".");for(let i=0;i<s.length;i++){let a=vt(s[i]);a.byteLength>255&&(a=vt(Wb(Kb(s[i])))),n[r]=a.length,n.set(a,r+1),r+=a.length+1}return n.byteLength!==r+1?n.slice(0,r+1):n}async function Zb(e,t){const{blockNumber:n,blockTag:r,coinType:s,name:i,gatewayUrls:a,strict:o}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Dn({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),l=c?.ensTlds;if(l&&!l.some(d=>i.endsWith(d)))return null;try{const d=he({abi:xu,functionName:"addr",...s!=null?{args:[us(i),BigInt(s)]}:{args:[us(i)]}}),f={address:u,abi:vf,functionName:"resolve",args:[_e(ei(i)),d,a??[Qo]],blockNumber:n,blockTag:r},y=await z(e,qe,"readContract")(f);if(y[0]==="0x")return null;const h=un({abi:xu,args:s!=null?[us(i),BigInt(s)]:void 0,functionName:"addr",data:y[0]});return h==="0x"||Je(h)==="0x00"?null:h}catch(d){if(o)throw d;if(Yo(d,"resolve"))return null;throw d}}class Yb extends _{constructor({data:t}){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(t)}`],name:"EnsAvatarInvalidMetadataError"})}}class qn extends _{constructor({reason:t}){super(`ENS NFT avatar URI is invalid. ${t}`,{name:"EnsAvatarInvalidNftUriError"})}}class Xo extends _{constructor({uri:t}){super(`Unable to resolve ENS avatar URI "${t}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class Jb extends _{constructor({namespace:t}){super(`ENS NFT avatar namespace "${t}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const Qb=/(?<protocol>https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,Xb=/^(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>\/.*)?$/,ew=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,tw=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function nw(e){try{const t=await fetch(e,{method:"HEAD"});return t.status===200?t.headers.get("content-type")?.startsWith("image/"):!1}catch(t){return typeof t=="object"&&typeof t.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(n=>{const r=new Image;r.onload=()=>{n(!0)},r.onerror=()=>{n(!1)},r.src=e})}}function Iu(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function Cf({uri:e,gatewayUrls:t}){const n=ew.test(e);if(n)return{uri:e,isOnChain:!0,isEncoded:n};const r=Iu(t?.ipfs,"https://ipfs.io"),s=Iu(t?.arweave,"https://arweave.net"),i=e.match(Qb),{protocol:a,subpath:o,target:c,subtarget:u=""}=i?.groups||{},l=a==="ipns:/"||o==="ipns/",d=a==="ipfs:/"||o==="ipfs/"||Xb.test(e);
44if(e.startsWith("http")&&!l&&!d){let p=e;return t?.arweave&&(p=e.replace(/https:\/\/arweave.net/g,t?.arweave)),{uri:p,isOnChain:!1,isEncoded:!1}}if((l||d)&&c)return{uri:`${r}/${l?"ipns":"ipfs"}/${c}${u}`,isOnChain:!1,isEncoded:!1};if(a==="ar:/"&&c)return{uri:`${s}/${c}${u||""}`,isOnChain:!1,isEncoded:!1};let f=e.replace(tw,"");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 Xo({uri:e})}function Bf(e){if(typeof e!="object"||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new Yb({data:e});return e.image||e.image_url||e.image_data}async function rw({gatewayUrls:e,uri:t}){try{const n=await fetch(t).then(s=>s.json());return await ec({gatewayUrls:e,uri:Bf(n)})}catch{throw new Xo({uri:t})}}async function ec({gatewayUrls:e,uri:t}){const{uri:n,isOnChain:r}=Cf({uri:t,gatewayUrls:e});if(r||await nw(n))return n;throw new Xo({uri:t})}function sw(e){let t=e;t.startsWith("did:nft:")&&(t=t.replace("did:nft:","").replace(/_/g,"/"));const[n,r,s]=t.split("/"),[i,a]=n.split(":"),[o,c]=r.split(":");if(!i||i.toLowerCase()!=="eip155")throw new qn({reason:"Only EIP-155 supported"});if(!a)throw new qn({reason:"Chain ID not found"});if(!c)throw new qn({reason:"Contract address not found"});if(!s)throw new qn({reason:"Token ID not found"});if(!o)throw new qn({reason:"ERC namespace not found"});return{chainID:Number.parseInt(a),namespace:o.toLowerCase(),contractAddress:c,tokenID:s}}async function iw(e,{nft:t}){if(t.namespace==="erc721")return qe(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(t.namespace==="erc1155")return qe(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 Jb({namespace:t.namespace})}async function aw(e,{gatewayUrls:t,record:n}){return/eip155:/i.test(n)?ow(e,{gatewayUrls:t,record:n}):ec({uri:n,gatewayUrls:t})}async function ow(e,{gatewayUrls:t,record:n}){const r=sw(n),s=await iw(e,{nft:r}),{uri:i,isOnChain:a,isEncoded:o}=Cf({uri:s,gatewayUrls:t});if(a&&(i.includes("data:application/json;base64,")||i.startsWith("{"))){const u=o?atob(i.replace("data:application/json;base64,","")):i,l=JSON.parse(u);return ec({uri:Bf(l),gatewayUrls:t})}let c=r.tokenID;return r.namespace==="erc1155"&&(c=c.replace("0x","").padStart(64,"0")),rw({gatewayUrls:t,uri:i.replace(/(?:0x)?{id}/,c)})}async function $f(e,t){const{blockNumber:n,blockTag:r,key:s,name:i,gatewayUrls:a,strict:o}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Dn({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),l=c?.ensTlds;if(l&&!l.some(d=>i.endsWith(d)))return null;try{const d={address:u,abi:vf,functionName:"resolve",args:[_e(ei(i)),he({abi:vu,functionName:"text",args:[us(i),s]}),a??[Qo]],blockNumber:n,blockTag:r},p=await z(e,qe,"readContract")(d);if(p[0]==="0x")return null;const y=un({abi:vu,functionName:"text",data:p[0]});return y===""?null:y}catch(d){if(o)throw d;if(Yo(d,"resolve"))return null;throw d}}async function cw(e,{blockNumber:t,blockTag:n,assetGatewayUrls:r,name:s,gatewayUrls:i,strict:a,universalResolverAddress:o}){const c=await z(e,$f,"getEnsText")({blockNumber:t,blockTag:n,key:"avatar",name:s,universalResolverAddress:o,gatewayUrls:i,strict:a});if(!c)return null;try{return await aw(e,{record:c,gatewayUrls:r})}catch{return null}}async function uw(e,{address:t,blockNumber:n,blockTag:r,gatewayUrls:s,strict:i,universalResolverAddress:a}){let o=a;if(!o){if(!e.chain)throw new Error("client chain not configured. universalResolverAddress is required.");o=Dn({blockNumber:n,chain:e.chain,contract:"ensUniversalResolver"})}const c=`${t.toLowerCase().substring(2)}.addr.reverse`;try{const u={address:o,abi:pb,functionName:"reverse",args:[_e(ei(c))],blockNumber:n,blockTag:r},l=z(e,qe,"readContract"),[d,f]=s?await l({...u,args:[...u.args,s]}):await l(u);return t.toLowerCase()!==f.toLowerCase()?null:d}catch(u){if(i)throw u;if(Yo(u,"reverse"))return null;throw u}}async function dw(e,t){const{blockNumber:n,blockTag:r,name:s}=t,{chain:i}=e,a=(()=>
44{if(t.universalResolverAddress)return t.universalResolverAddress;if(!i)throw new Error("client chain not configured. universalResolverAddress is required.");return Dn({blockNumber:n,chain:i,contract:"ensUniversalResolver"})})(),o=i?.ensTlds;if(o&&!o.some(u=>s.endsWith(u)))throw new Error(`${s} is not a valid ENS TLD (${o?.join(", ")}) for chain "${i.name}" (id: ${i.id}).`);const[c]=await z(e,qe,"readContract")({address:a,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[_e(ei(s))],blockNumber:n,blockTag:r});return c}async function Nf(e,t){const{account:n=e.account,blockNumber:r,blockTag:s="latest",blobs:i,data:a,gas:o,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:d,to:f,value:p,...y}=t,h=n?xe(n):void 0;try{Nr(t);const g=(typeof r=="bigint"?R(r):void 0)||s,b=e.chain?.formatters?.transactionRequest?.format,x=(b||Ks)({...Ro(y,{format:b}),from:h?.address,blobs:i,data:a,gas:o,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:d,to:f,value:p}),S=await e.request({method:"eth_createAccessList",params:[x,g]});return{accessList:S.accessList,gasUsed:BigInt(S.gasUsed)}}catch(m){throw _f(m,{...t,account:h,chain:e.chain})}}async function lw(e){const t=qs(e,{method:"eth_newBlockFilter"}),n=await e.request({method:"eth_newBlockFilter"});return{id:n,request:t(n),type:"block"}}async function Mf(e,{address:t,args:n,event:r,events:s,fromBlock:i,strict:a,toBlock:o}={}){const c=s??(r?[r]:void 0),u=qs(e,{method:"eth_newFilter"});let l=[];c&&(l=[c.flatMap(p=>Br({abi:[p],eventName:p.name,args:n}))],r&&(l=l[0]));const d=await e.request({method:"eth_newFilter",params:[{address:t,fromBlock:typeof i=="bigint"?R(i):i,toBlock:typeof o=="bigint"?R(o):o,...l.length?{topics:l}:{}}]});return{abi:c,args:n,eventName:r?r.name:void 0,fromBlock:i,id:d,request:u(d),strict:!!a,toBlock:o,type:"event"}}async function Rf(e){const t=qs(e,{method:"eth_newPendingTransactionFilter"}),n=await e.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:t(n),type:"transaction"}}async function fw(e){const t=await e.request({method:"eth_blobBaseFee"});return BigInt(t)}async function pw(e,{blockHash:t,blockNumber:n,blockTag:r="latest"}={}){const s=n!==void 0?R(n):void 0;let i;return t?i=await e.request({method:"eth_getBlockTransactionCountByHash",params:[t]},{dedupe:!0}):i=await e.request({method:"eth_getBlockTransactionCountByNumber",params:[s||r]},{dedupe:!!s}),Te(i)}async function vs(e,{address:t,blockNumber:n,blockTag:r="latest"}){const s=n!==void 0?R(n):void 0,i=await e.request({method:"eth_getCode",params:[t,s||r]},{dedupe:!!s});if(i!=="0x")return i}class hw extends _{constructor({address:t}){super(`No EIP-712 domain found on contract "${t}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${t}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}async function mw(e,t){const{address:n,factory:r,factoryData:s}=t;try{const[i,a,o,c,u,l,d]=await z(e,qe,"readContract")({abi:yw,address:n,functionName:"eip712Domain",factory:r,factoryData:s});return{domain:{name:a,version:o,chainId:Number(c),verifyingContract:u,salt:l},extensions:d,fields:i}}catch(i){const a=i;throw a.name==="ContractFunctionExecutionError"&&a.cause.name==="ContractFunctionZeroDataError"?new hw({address:n}):a}}const yw=[{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"}];function gw(e){return{baseFeePerGas:e.baseFeePerGas.map(t=>BigInt(t)),gasUsedRatio:e.gasUsedRatio,oldestBlock:BigInt(e.oldestBlock),reward:e.reward?.map(t=>t.map(n=>BigInt(n)))}}async function bw(e,{blockCount:t,blockNumber:n,blockTag:r="latest",rewardPercentiles:s}){const i=typeof n=="bigint"?R(n):void 0,a=await e.request({method:"eth_feeHistory",params:[R(t),i||r,s]},{dedupe:!!i});return gw(a)}async function ww(e,{filter:t}){const n=t.strict??!1,s=(await t.request({method:"eth_getFilterLogs",params:[t.id]})).map(i=>at(i));return t.abi?Ho({abi:t.abi,logs:s,strict:n}):s}function vw(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}class xw extends _{constructor({domain:t}){super(`Invalid domain "${fe(t)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class Ew extends _{constructor({primaryType:t,types:n}){super(`Invalid primary type \`${t}\` must be one of \`${JSON.stringify(Object.keys(n))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class _w extends _{constructor({type:t}){super(`Struct type "${t}
44" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function Lr(e){const{domain:t={},message:n,primaryType:r}=e,s={EIP712Domain:Pw({domain:t}),...e.types};Iw({domain:t,message:n,primaryType:r,types:s});const i=["0x1901"];return t&&i.push(Sw({domain:t,types:s})),r!=="EIP712Domain"&&i.push(jf({data:n,primaryType:r,types:s})),X(ve(i))}function Sw({domain:e,types:t}){return jf({data:e,primaryType:"EIP712Domain",types:t})}function jf({data:e,primaryType:t,types:n}){const r=Lf({data:e,primaryType:t,types:n});return X(r)}function Lf({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],s=[Aw({primaryType:t,types:n})];for(const i of n[t]){const[a,o]=Df({types:n,name:i.name,type:i.type,value:e[i.name]});r.push(a),s.push(o)}return $e(r,s)}function Aw({primaryType:e,types:t}){const n=_e(kw({primaryType:e,types:t}));return X(n)}function kw({primaryType:e,types:t}){let n="";const r=Uf({primaryType:e,types:t});r.delete(e);const s=[e,...Array.from(r).sort()];for(const i of s)n+=`${i}(${t[i].map(({name:a,type:o})=>`${o} ${a}`).join(",")})`;return n}function Uf({primaryType:e,types:t},n=new Set){const s=e.match(/^\w*/u)?.[0];if(n.has(s)||t[s]===void 0)return n;n.add(s);for(const i of t[s])Uf({primaryType:i.type,types:t},n);return n}function Df({types:e,name:t,type:n,value:r}){if(e[n]!==void 0)return[{type:"bytes32"},X(Lf({data:r,primaryType:n,types:e}))];if(n==="bytes")return r=`0x${(r.length%2?"0":"")+r.slice(2)}`,[{type:"bytes32"},X(r)];if(n==="string")return[{type:"bytes32"},X(_e(r))];if(n.lastIndexOf("]")===n.length-1){const s=n.slice(0,n.lastIndexOf("[")),i=r.map(a=>Df({name:t,type:s,types:e,value:a}));return[{type:"bytes32"},X($e(i.map(([a])=>a),i.map(([,a])=>a)))]}return[{type:n},r]}function Iw(e){const{domain:t,message:n,primaryType:r,types:s}=e,i=(a,o)=>{for(const c of a){const{name:u,type:l}=c,d=o[u],f=l.match(Po);if(f&&(typeof d=="number"||typeof d=="bigint")){const[h,m,g]=f;R(d,{signed:m==="int",size:Number.parseInt(g)/8})}if(l==="address"&&typeof d=="string"&&!be(d))throw new Et({address:d});const p=l.match(Nl);if(p){const[h,m]=p;if(m&&re(d)!==Number.parseInt(m))throw new gl({expectedSize:Number.parseInt(m),givenSize:re(d)})}const y=s[l];y&&(Tw(l),i(y,d))}};if(s.EIP712Domain&&t){if(typeof t!="object")throw new xw({domain:t});i(s.EIP712Domain,t)}if(r!=="EIP712Domain")if(s[r])i(s[r],n);else throw new Ew({primaryType:r,types:s})}function Pw({domain:e}){return[typeof e?.name=="string"&&{name:"name",type:"string"},e?.version&&{name:"version",type:"string"},(typeof e?.chainId=="number"||typeof e?.chainId=="bigint")&&{name:"chainId",type:"uint256"},e?.verifyingContract&&{name:"verifyingContract",type:"address"},e?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function Tw(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new _w({type:e})}function Ow(e,t){if(e.length!==t.length)throw new pl({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r];n.push(zf(s,i))}return jt(n)}function zf(e,t,n=!1){if(e==="address"){const a=t;if(!be(a))throw new Et({address:a});return le(a.toLowerCase(),{size:n?32:null})}if(e==="string")return Xt(t);if(e==="bytes")return t;if(e==="bool")return le(Ao(t),{size:n?32:1});const r=e.match(Po);if(r){const[a,o,c="256"]=r,u=Number.parseInt(c)/8;return R(t,{size:n?32:u,signed:o==="int"})}const s=e.match(Nl);if(s){const[a,o]=s;if(Number.parseInt(o)!==(t.length-2)/2)throw new gl({expectedSize:Number.parseInt(o),givenSize:(t.length-2)/2});return le(t,{dir:"right",size:n?32:null})}const i=e.match(Ay);if(i&&Array.isArray(t)){const[a,o]=i,c=[];for(let u=0;u<t.length;u++)c.push(zf(o,t[u],!0));return c.length===0?"0x":jt(c)}throw new Dm(e)}const Cw=`�Ethereum Signed Message: 45`;function Bw(e){const t=typeof e=="string"?Xt(e):typeof e.raw=="string"?e.raw:pe(e.raw),n=Xt(`${Cw}${re(t)}`);return ve([n,t])}function ti(e,t){return X(Bw(e),t)}const Ff="0x6492649264926492649264926492649264926492649264926492649264926492";function $w(e){return ys(e,-32)===Ff}function ds(e){const{address:t,data:n,signature:r,to:s="hex"}=e,i=jt([$e([{type:"address"},{type:"bytes"},{type:"bytes"}],[t,n,r]),Ff]);return s==="hex"?i:Ae(i)}function Nw(e){const{source:t}=e,n=new Map,r=new Hs(8192),s=new Map,i=({address:a,chainId:o})=>`${a}.${o}`;return{async consume({address:a,chainId:o,client:c}){const u=i({address:a,chainId:o}),l=this.get({address:a,chainId:o,client:c});this.increment({address:a,chainId:o});const d=await l;return await t.set({address:a,chainId:o},d),r.set(u,d),d},async increment({address:a,chainId:o}){const c=i({address:a,chainId:o}),u=n.get(c)??0;n.set(c,u+1)},async get({address:a,chainId:o,client:c}){const u=i({address:a,chainId:o});let l=s.get(u);return l||(l=(async()=>{try{const f=await t.get({address:a,chainId:o,client:c}),p=r.get(u)??0;return p>0&&f<=p?p+1:(r.delete(u),f)}finally{this.reset({address:a,chainId:o})}})(),s.set(u,l)),(n.get(u)??0)+await l},reset({address:a,chainId:o}){const c=i({address:a,chainId:o});n.delete(c),s.delete(c)}}}function Mw(e){return e.map(t=>({...t,value:BigInt(t.value)}))}function Rw(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?Te(e.nonce):void 0,storageProof:e.storageProof?Mw(e.storageProof):void 0}}async function jw(e,{address:t,blockNumber:n,blockTag:r,storageKeys:s}){const i=r??"latest",a=n!==void 0?R(n):void 0,o=await e.request({method:"eth_getProof",params:[t,s,a||i]});return Rw(o)}async function Lw(e,{address:t,blockNumber:n,blockTag:r="latest",slot:s}){const i=n!==void 0?R(n):void 0;return await e.request({method:"eth_getStorageAt",params:[t,s,i||r]})}async function tc(e,{blockHash:t,blockNumber:n,blockTag:r,hash:s,index:i}){const a=r||"latest",o=n!==void 0?R(n):void 0;let c=null;if(s?c=await e.request({method:"eth_getTransactionByHash",params:[s]},{dedupe:!0}):t?c=await e.request({method:"eth_getTransactionByBlockHashAndIndex",params:[t,R(i)]},{dedupe:!0}):c=await e.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[o||a,R(i)]},{dedupe:!!o}),!c)throw new Gl({blockHash:t,blockNumber:n,blockTag:a,hash:s,index:i});return(e.chain?.formatters?.transaction?.format||ef)(c)}async function Uw(e,{hash:t,transactionReceipt:n}){const[r,s]=await Promise.all([z(e,jr,"getBlockNumber")({}),t?z(e,tc,"getTransaction")({hash:t}):void 0]),i=n?.blockNumber||s?.blockNumber;return i?r-i+1n:0n}async function ls(e,{hash:t}){const n=await e.request({method:"eth_getTransactionReceipt",params:[t]},{dedupe:!0});if(!n)throw new ql({hash:t});return(e.chain?.formatters?.transactionReceipt?.format||kf)(n)}
45async function Dw(e,t){const{account:n,allowFailure:r=!0,batchSize:s,blockNumber:i,blockTag:a,multicallAddress:o,stateOverride:c}=t,u=t.contracts,l=s??(typeof e.batch?.multicall=="object"&&e.batch.multicall.batchSize||1024);let d=o;if(!d){if(!e.chain)throw new Error("client chain not configured. multicallAddress is required.");d=Dn({blockNumber:i,chain:e.chain,contract:"multicall3"})}const f=[[]];let p=0,y=0;for(let g=0;g<u.length;g++){const{abi:b,address:w,args:x,functionName:S}=u[g];try{const A=he({abi:b,args:x,functionName:S});y+=(A.length-2)/2,l>0&&y>l&&f[p].length>0&&(p++,y=(A.length-2)/2,f[p]=[]),f[p]=[...f[p],{allowFailure:!0,callData:A,target:w}]}catch(A){const k=In(A,{abi:b,address:w,args:x,docsPath:"/docs/contract/multicall",functionName:S,sender:n});if(!r)throw k;f[p]=[...f[p],{allowFailure:!0,callData:"0x",target:w}]}}const h=await Promise.allSettled(f.map(g=>z(e,qe,"readContract")({abi:va,account:n,address:d,args:[g],blockNumber:i,blockTag:a,functionName:"aggregate3",stateOverride:c}))),m=[];for(let g=0;g<h.length;g++){const b=h[g];if(b.status==="rejected"){if(!r)throw b.reason;for(let x=0;x<f[g].length;x++)m.push({status:"failure",error:b.reason,result:void 0});continue}const w=b.value;for(let x=0;x<w.length;x++){const{returnData:S,success:A}=w[x],{callData:k}=f[g][x],{abi:$,address:v,functionName:C,args:E}=u[m.length];try{if(k==="0x")throw new Or;if(!A)throw new Vs({data:S});const P=un({abi:$,args:E,data:S,functionName:C});m.push(r?{result:P,status:"success"}:P)}catch(P){const M=In(P,{abi:$,address:v,args:E,docsPath:"/docs/contract/multicall",functionName:C});if(!r)throw M;m.push({error:M,result:void 0,status:"failure"})}}}if(m.length!==u.length)throw new _("multicall results mismatch");return m}async function ka(e,t){const{blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",blocks:s,returnFullTransactions:i,traceTransfers:a,validation:o}=t;try{const c=[];for(const f of s){const p=f.blockOverrides?bf(f.blockOverrides):void 0,y=f.calls.map(m=>{const g=m,b=g.account?xe(g.account):void 0,w=g.abi?he(g):g.data,x={...g,data:g.dataSuffix?ve([w||"0x",g.dataSuffix]):w,from:g.from??b?.address};return Nr(x),Ks(x)}),h=f.stateOverrides?Zs(f.stateOverrides):void 0;c.push({blockOverrides:p,calls:y,stateOverrides:h})}const l=(typeof n=="bigint"?R(n):void 0)||r;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:c,returnFullTransactions:i,traceTransfers:a,validation:o},l]})).map((f,p)=>({...tf(f),calls:f.calls.map((y,h)=>{const{abi:m,args:g,functionName:b,to:w}=s[p].calls[h],x=y.error?.data??y.returnData,S=BigInt(y.gasUsed),A=y.logs?.map(C=>at(C)),k=y.status==="0x1"?"success":"failure",$=m&&k==="success"&&x!=="0x"?un({abi:m,data:x,functionName:b}):null,v=(()=>{if(k==="success")return;let C;if(y.error?.data==="0x"?C=new Or:y.error&&(C=new Vs(y.error)),!!C)return In(C,{abi:m??[],address:w??"0x",args:g,functionName:b??"<unknown>"})})();return{data:x,gasUsed:S,logs:A,status:k,...k==="success"?{result:$}:{error:v}}})}))}catch(c){const u=c,l=Mo(u,{});throw l instanceof Ws?u:l}}function Hf(e,t={}){const{as:n=typeof e=="string"?"Hex":"Bytes"}=t,r=Tl(Xg(e));return n==="Bytes"?r:mf(r)}class zw extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const Fw={checksum:new zw(8192)},ki=Fw.checksum,Hw=/^0x[a-fA-F0-9]{40}$/;function ni(e,t={}){const{strict:n=!0}=t;if(!Hw.test(e))throw new Pu({address:e,cause:new qw});if(n){if(e.toLowerCase()===e)return;if(Gw(e)!==e)throw new Pu({address:e,cause:new Vw})}}function Gw(e){if(ki.has(e))return ki.get(e);ni(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=Hf(nb(t),{as:"Bytes"}),r=t.split("");for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&r[i]&&(r[i]=r[i].toUpperCase()),(n[i>>1]&15)>=8&&r[i+1]&&(r[i+1]=r[i+1].toUpperCase());const s=`0x${r.join("")}`;return ki.set(e,s),s}function Ia(e,t={}){const{strict:n=!0}=t??{};try{return ni(e,{strict:n}),!0}catch{return!1}}class Pu extends ce{constructor({address:t,cause:n}){super(`Address "${t}
45" is invalid.`,{cause:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class qw extends ce{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 Vw extends ce{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}function Pa(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),o==="("&&r++,o===")"&&r--,!!t){if(r===0){if(o===" "&&["event","function","error",""].includes(s))s="";else if(s+=o,o===")"){i=!0;break}continue}if(o===" "){e[a-1]!==","&&n!==","&&n!==",("&&(n="",t=!1);continue}s+=o,n+=o}}if(!i)throw new ce("Unable to normalize signature.");return s}function Ta(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Ia(e,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in t?Object.values(t.components).every((s,i)=>Ta(Object.values(e)[i],s)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||e instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(e)&&e.every(s=>Ta(s,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Gf(e,t,n){for(const r in e){const s=e[r],i=t[r];if(s.type==="tuple"&&i.type==="tuple"&&"components"in s&&"components"in i)return Gf(s.components,i.components,n[r]);const a=[s.type,i.type];if(a.includes("address")&&a.includes("bytes20")?!0:a.includes("address")&&a.includes("string")?Ia(n[r],{strict:!1}):a.includes("address")&&a.includes("bytes")?Ia(n[r],{strict:!1}):!1)return a}}function qf(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||typeof e=="string"?Ac(e):e;return{...r,...n?{hash:bn(r)}:{}}}function Ww(e,t,n){const{args:r=[],prepare:s=!0}=n??{},i=ub(t,{strict:!1}),a=e.filter(u=>i?u.type==="function"||u.type==="error"?Vf(u)===Wo(t,0,4):u.type==="event"?bn(u)===t:!1:"name"in u&&u.name===t);if(a.length===0)throw new Oa({name:t});if(a.length===1)return{...a[0],...s?{hash:bn(a[0])}:{}};let o;for(const u of a){if(!("inputs"in u))continue;if(!r||r.length===0){if(!u.inputs||u.inputs.length===0)return{...u,...s?{hash:bn(u)}:{}};continue}if(!u.inputs||u.inputs.length===0||u.inputs.length!==r.length)continue;if(r.every((d,f)=>{const p="inputs"in u&&u.inputs[f];return p?Ta(d,p):!1})){if(o&&"inputs"in o&&o.inputs){const d=Gf(u.inputs,o.inputs,r);if(d)throw new Zw({abiItem:u,type:d[0]},{abiItem:o,type:d[1]})}o=u}}const c=(()=>{if(o)return o;const[u,...l]=a;return{...u,overloads:l}})();if(!c)throw new Oa({name:t});return{...c,...s?{hash:bn(c)}:{}}}function Vf(e){return Wo(bn(e),0,4)}function Kw(e){const t=typeof e=="string"?e:fs(e);return Pa(t)}function bn(e){return typeof e!="string"&&"hash"in e&&e.hash?e.hash:Hf(Vo(Kw(e)))}class Zw extends ce{constructor(t,n){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${t.type}\` in \`${Pa(fs(t.abiItem))}\`, and`,`\`${n.type}\` in \`${Pa(fs(n.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 Oa extends ce{constructor({name:t,data:n,type:r="item"}){const s=t?` with name "${t}"`:n?` with data "${n}"`:"";super(`ABI ${r}${s} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}const Yw=/^(.*)\[([0-9]*)\]$/,Jw=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Wf=/^(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 Qw({checksumAddress:e,parameters:t,values:n}){const r=[];for(let s=0;s<t.length;s++)r.push(nc({checksumAddress:e,parameter:t[s],value:n[s]}));return r}function nc({checksumAddress:e=!1,parameter:t,value:n}){const r=t,s=av(r.type);if(s){const[i,a]=s;return ev(n,{checksumAddress:e,length:i,parameter:{...r,type:a}})}if(r.type==="tuple")return iv(n,{checksumAddress:e,parameter:r});if(r.type==="address")return Xw(n,{checksum:e});if(r.type==="bool")return nv(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const i=r.type.startsWith("int"),[,,a="256"]=Wf.exec(r.type)??[];return rv(n,{signed:i,size:Number(a)})}if(r.type.startsWith("bytes"))return tv(n,{type:r.type});if(r.type==="string")return sv(n);throw new Jf(r.type)}function rc(e){let t=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];
45a?t+=32:t+=Ge(o)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(Ee(t+s,{size:32})),r.push(o),s+=Ge(o)):n.push(o)}return ot(...n,...r)}function Xw(e,t){const{checksum:n=!1}=t;return ni(e,{strict:n}),{dynamic:!1,encoded:rn(e.toLowerCase())}}function ev(e,t){const{checksumAddress:n,length:r,parameter:s}=t,i=r===null;if(!Array.isArray(e))throw new cv(e);if(!i&&e.length!==r)throw new ov({expectedLength:r,givenLength:e.length,type:`${s.type}[${r}]`});let a=!1;const o=[];for(let c=0;c<e.length;c++){const u=nc({checksumAddress:n,parameter:s,value:e[c]});u.dynamic&&(a=!0),o.push(u)}if(i||a){const c=rc(o);if(i){const u=Ee(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?ot(u,c):u}}if(a)return{dynamic:!0,encoded:c}}return{dynamic:!1,encoded:ot(...o.map(({encoded:c})=>c))}}function tv(e,{type:t}){const[,n]=t.split("bytes"),r=Ge(e);if(!n){let s=e;return r%32!==0&&(s=sn(s,Math.ceil((e.length-2)/2/32)*32)),{dynamic:!0,encoded:ot(rn(Ee(r,{size:32})),s)}}if(r!==Number.parseInt(n))throw new Zf({expectedSize:Number.parseInt(n),value:e});return{dynamic:!1,encoded:sn(e)}}function nv(e){if(typeof e!="boolean")throw new ce(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:rn(hf(e))}}function rv(e,{signed:t,size:n}){if(typeof n=="number"){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new yf({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Ee(e,{size:32,signed:t})}}function sv(e){const t=Vo(e),n=Math.ceil(Ge(t)/32),r=[];for(let s=0;s<n;s++)r.push(sn(Wo(t,s*32,(s+1)*32)));return{dynamic:!0,encoded:ot(sn(Ee(Ge(t),{size:32})),...r)}}function iv(e,t){const{checksumAddress:n,parameter:r}=t;let s=!1;const i=[];for(let a=0;a<r.components.length;a++){const o=r.components[a],c=Array.isArray(e)?a:o.name,u=nc({checksumAddress:n,parameter:o,value:e[c]});i.push(u),u.dynamic&&(s=!0)}return{dynamic:s,encoded:s?rc(i):ot(...i.map(({encoded:a})=>a))}}function av(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Kf(e,t,n){const{checksumAddress:r=!1}={};if(e.length!==t.length)throw new Yf({expectedLength:e.length,givenLength:t.length});const s=Qw({checksumAddress:r,parameters:e,values:t}),i=rc(s);return i.length===0?"0x":i}function Ca(e,t){if(e.length!==t.length)throw new Yf({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r];n.push(Ca.encode(s,i))}return ot(...n)}(function(e){function t(n,r,s=!1){if(n==="address"){const c=r;return ni(c),rn(c.toLowerCase(),s?32:0)}if(n==="string")return Vo(r);if(n==="bytes")return r;if(n==="bool")return rn(hf(r),s?32:1);const i=n.match(Wf);if(i){const[c,u,l="256"]=i,d=Number.parseInt(l)/8;return Ee(r,{size:s?32:d,signed:u==="int"})}const a=n.match(Jw);if(a){const[c,u]=a;if(Number.parseInt(u)!==(r.length-2)/2)throw new Zf({expectedSize:Number.parseInt(u),value:r});return sn(r,s?32:0)}const o=n.match(Yw);if(o&&Array.isArray(r)){const[c,u]=o,l=[];for(let d=0;d<r.length;d++)l.push(t(u,r[d],!0));return l.length===0?"0x":ot(...l)}throw new Jf(n)}e.encode=t})(Ca||(Ca={}));class ov extends ce{constructor({expectedLength:t,givenLength:n,type:r}){super(`Array length mismatch for type \`${r}\`. Expected: \`${t}\`. Given: \`${n}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class Zf extends ce{constructor({expectedSize:t,value:n}){super(`Size of bytes "${n}" (bytes${Ge(n)}) does not match expected size (bytes${t}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Yf extends ce{constructor({expectedLength:t,givenLength:n}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${t}`,`Given length (values): ${n}`].join(` 46`)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class cv extends ce{constructor(t){super(`Value \`${t}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class Jf extends ce{constructor(t){super(`Type \`${t}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}function uv(e,t){const{bytecode:n,args:r}=t;
46return ot(n,e.inputs?.length&&r?.length?Kf(e.inputs,r):"0x")}function dv(e){return qf(e)}function lv(e,...t){const{overloads:n}=e,r=n?fv([e,...n],e.name,{args:t[0]}):e,s=pv(r),i=t.length>0?Kf(r.inputs,t[0]):void 0;return i?ot(s,i):s}function pn(e,t={}){return qf(e,t)}function fv(e,t,n){const r=Ww(e,t,n);if(r.type!=="function")throw new Oa({name:t,type:"function"});return r}function pv(e){return Vf(e)}const hv="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",tt="0x0000000000000000000000000000000000000000",mv="0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033";async function yv(e,t){const{blockNumber:n,blockTag:r,calls:s,stateOverrides:i,traceAssetChanges:a,traceTransfers:o,validation:c}=t,u=t.account?xe(t.account):void 0;if(a&&!u)throw new _("`account` is required when `traceAssetChanges` is true");const l=u?uv(dv("constructor(bytes, bytes)"),{bytecode:xf,args:[mv,lv(pn("function getBalance(address)"),[u.address])]}):void 0,d=a?await Promise.all(t.calls.map(async B=>{if(!B.data&&!B.abi)return;const{accessList:D}=await Nf(e,{account:u.address,...B,data:B.abi?he(B):B.data});return D.map(({address:F,storageKeys:U})=>U.length>0?F:null)})).then(B=>B.flat().filter(Boolean)):[],f=await ka(e,{blockNumber:n,blockTag:r,blocks:[...a?[{calls:[{data:l}],stateOverrides:i},{calls:d.map((B,D)=>({abi:[pn("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:B,from:tt,nonce:D})),stateOverrides:[{address:tt,nonce:0}]}]:[],{calls:[...s,{}].map(B=>({...B,from:u?.address})),stateOverrides:i},...a?[{calls:[{data:l}]},{calls:d.map((B,D)=>({abi:[pn("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:B,from:tt,nonce:D})),stateOverrides:[{address:tt,nonce:0}]},{calls:d.map((B,D)=>({to:B,abi:[pn("function decimals() returns (uint256)")],functionName:"decimals",from:tt,nonce:D})),stateOverrides:[{address:tt,nonce:0}]},{calls:d.map((B,D)=>({to:B,abi:[pn("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:tt,nonce:D})),stateOverrides:[{address:tt,nonce:0}]},{calls:d.map((B,D)=>({to:B,abi:[pn("function symbol() returns (string)")],functionName:"symbol",from:tt,nonce:D})),stateOverrides:[{address:tt,nonce:0}]}]:[]],traceTransfers:o,validation:c}),p=a?f[2]:f[0],[y,h,,m,g,b,w,x]=a?f:[],{calls:S,...A}=p,k=S.slice(0,-1)??[],$=y?.calls??[],v=h?.calls??[],C=[...$,...v].map(B=>B.status==="success"?de(B.data):null),E=m?.calls??[],P=g?.calls??[],M=[...E,...P].map(B=>B.status==="success"?de(B.data):null),I=(b?.calls??[]).map(B=>B.status==="success"?B.result:null),T=(x?.calls??[]).map(B=>B.status==="success"?B.result:null),O=(w?.calls??[]).map(B=>B.status==="success"?B.result:null),N=[];for(const[B,D]of M.entries()){const F=C[B];if(typeof D!="bigint"||typeof F!="bigint")continue;const U=I[B-1],H=T[B-1],Y=O[B-1],K=B===0?{address:hv,decimals:18,symbol:"ETH"}:{address:d[B-1],decimals:Y||U?Number(U??1):void 0,symbol:H??void 0};N.some(Z=>Z.token.address===K.address)||N.push({token:K,value:{pre:F,post:D,diff:D-F}})}return{assetChanges:N,block:A,results:k}}const hn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function sc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ba(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function _t(e,...t){if(!sc(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}
46function gv(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Ba(e.outputLen),Ba(e.blockLen)}function xs(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 bv(e,t){_t(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Es(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ii(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function nt(e,t){return e<<32-t|e>>>t}const Qf=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",wv=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Pr(e){if(_t(e),Qf)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=wv[e[n]];return t}const ft={_0:48,_9:57,A:65,F:70,a:97,f:102};function Tu(e){if(e>=ft._0&&e<=ft._9)return e-ft._0;if(e>=ft.A&&e<=ft.F)return e-(ft.A-10);if(e>=ft.a&&e<=ft.f)return e-(ft.a-10)}function ic(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Qf)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 s=0,i=0;s<n;s++,i+=2){const a=Tu(e.charCodeAt(i)),o=Tu(e.charCodeAt(i+1));if(a===void 0||o===void 0){const c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}r[s]=a*16+o}return r}function vv(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ac(e){return typeof e=="string"&&(e=vv(e)),_t(e),e}function qt(...e){let t=0;for(let r=0;r<e.length;r++){const s=e[r];_t(s),t+=s.length}const n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const i=e[r];n.set(i,s),s+=i.length}return n}let Xf=class{};function xv(e){const t=r=>e().update(ac(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ev(e=32){if(hn&&typeof hn.getRandomValues=="function")return hn.getRandomValues(new Uint8Array(e));if(hn&&typeof hn.randomBytes=="function")return Uint8Array.from(hn.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function _v(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),a=Number(n>>s&i),o=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,o,r)}function Sv(e,t,n){return e&t^~e&n}function Av(e,t,n){return e&t^e&n^t&n}let kv=class extends Xf{constructor(t,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(t),this.view=Ii(this.buffer)}update(t){xs(this),t=ac(t),_t(t);const{view:n,buffer:r,blockLen:s}=this,i=t.length;for(let a=0;a<i;){const o=Math.min(s-this.pos,i-a);if(o===s){const c=Ii(t);for(;s<=i-a;a+=s)this.process(c,a);continue}r.set(t.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){xs(this),bv(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:i}=this;let{pos:a}=this;n[a++]=128,Es(this.buffer.subarray(a)),this.padOffset>s-a&&(this.process(r,0),a=0);for(let d=a;d<s;d++)n[d]=0;_v(r,s-8,BigInt(this.length*8),i),this.process(r,0);const o=Ii(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)o.setUint32(4*d,l[d],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:i,destroyed:a,pos:o}=this;return t.destroyed=a,t.finished=i,t.length=s,t.pos=o,s%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}};const Pt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Iv=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,2756
46734187,3204031479,3329325298]),Tt=new Uint32Array(64);let Pv=class extends kv{constructor(t=32){super(64,t,8,!1),this.A=Pt[0]|0,this.B=Pt[1]|0,this.C=Pt[2]|0,this.D=Pt[3]|0,this.E=Pt[4]|0,this.F=Pt[5]|0,this.G=Pt[6]|0,this.H=Pt[7]|0}get(){const{A:t,B:n,C:r,D:s,E:i,F:a,G:o,H:c}=this;return[t,n,r,s,i,a,o,c]}set(t,n,r,s,i,a,o,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=c|0}process(t,n){for(let d=0;d<16;d++,n+=4)Tt[d]=t.getUint32(n,!1);for(let d=16;d<64;d++){const f=Tt[d-15],p=Tt[d-2],y=nt(f,7)^nt(f,18)^f>>>3,h=nt(p,17)^nt(p,19)^p>>>10;Tt[d]=h+Tt[d-7]+y+Tt[d-16]|0}let{A:r,B:s,C:i,D:a,E:o,F:c,G:u,H:l}=this;for(let d=0;d<64;d++){const f=nt(o,6)^nt(o,11)^nt(o,25),p=l+f+Sv(o,c,u)+Iv[d]+Tt[d]|0,h=(nt(r,2)^nt(r,13)^nt(r,22))+Av(r,s,i)|0;l=u,u=c,c=o,o=a+p|0,a=i,i=s,s=r,r=p+h|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,i,a,o,c,u,l)}roundClean(){Es(Tt)}destroy(){this.set(0,0,0,0,0,0,0,0),Es(this.buffer)}};const Tv=xv(()=>new Pv);let ep=class extends Xf{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,gv(t);const r=ac(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?t.create().update(r).digest():r);for(let a=0;a<i.length;a++)i[a]^=54;this.iHash.update(i),this.oHash=t.create();for(let a=0;a<i.length;a++)i[a]^=106;this.oHash.update(i),Es(i)}update(t){return xs(this),this.iHash.update(t),this}digestInto(t){xs(this),_t(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:s,destroyed:i,blockLen:a,outputLen:o}=this;return t=t,t.finished=s,t.destroyed=i,t.blockLen=a,t.outputLen=o,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const tp=(e,t,n)=>new ep(e,t).update(n).digest();tp.create=(e,t)=>new ep(e,t);const oc=BigInt(0),$a=BigInt(1);function _s(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Kr(e){const t=e.toString(16);return t.length&1?"0"+t:t}function np(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?oc:BigInt("0x"+e)}function ri(e){return np(Pr(e))}function rp(e){return _t(e),np(Pr(Uint8Array.from(e).reverse()))}function cc(e,t){return ic(e.toString(16).padStart(t*2,"0"))}function sp(e,t){return cc(e,t).reverse()}function De(e,t,n){let r;if(typeof t=="string")try{r=ic(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(sc(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return r}const Pi=e=>typeof e=="bigint"&&oc<=e;function Ov(e,t,n){return Pi(e)&&Pi(t)&&Pi(n)&&t<=e&&e<n}function Cv(e,t,n,r){if(!Ov(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Bv(e){let t;for(t=0;e>oc;e>>=$a,t+=1);return t}const si=e=>($a<<BigInt(e))-$a;function $v(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=p=>new Uint8Array(p),s=p=>Uint8Array.of(p);let i=r(e),a=r(e),o=0;const c=()=>{i.fill(1),a.fill(0),o=0},u=(...p)=>n(a,i,...p),l=(p=r(0))=>{a=u(s(0),p),i=u(),p.length!==0&&(a=u(s(1),p),i=u())},d=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let p=0;const y=[];for(;p<t;){i=u();const h=i.slice();y.push(h),p+=i.length}return qt(...y)};return(p,y)=>{c(),l(p);let h;for(;!(h=y(d()));)l();return c(),h}}function uc(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(s,i,a){const o=e[s];if(a&&o===void 0)return;const c=typeof o;if(c!==i||o===null)throw new Error(`param "${s}
46" is invalid: expected ${i}, got ${c}`)}Object.entries(t).forEach(([s,i])=>r(s,i,!1)),Object.entries(n).forEach(([s,i])=>r(s,i,!0))}function Ou(e){const t=new WeakMap;return(n,...r)=>{const s=t.get(n);if(s!==void 0)return s;const i=e(n,...r);return t.set(n,i),i}}const Pe=BigInt(0),Se=BigInt(1),Vt=BigInt(2),Nv=BigInt(3),ip=BigInt(4),ap=BigInt(5),op=BigInt(8);function ze(e,t){const n=e%t;return n>=Pe?n:t+n}function Ue(e,t,n){let r=e;for(;t-- >Pe;)r*=r,r%=n;return r}function Cu(e,t){if(e===Pe)throw new Error("invert: expected non-zero number");if(t<=Pe)throw new Error("invert: expected positive modulus, got "+t);let n=ze(e,t),r=t,s=Pe,i=Se;for(;n!==Pe;){const o=r/n,c=r%n,u=s-i*o;r=n,n=c,s=i,i=u}if(r!==Se)throw new Error("invert: does not exist");return ze(s,t)}function cp(e,t){const n=(e.ORDER+Se)/ip,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function Mv(e,t){const n=(e.ORDER-ap)/op,r=e.mul(t,Vt),s=e.pow(r,n),i=e.mul(t,s),a=e.mul(e.mul(i,Vt),s),o=e.mul(i,e.sub(a,e.ONE));if(!e.eql(e.sqr(o),t))throw new Error("Cannot find square root");return o}function Rv(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-Se,n=0;for(;t%Vt===Pe;)t/=Vt,n++;let r=Vt;const s=ii(e);for(;Bu(s,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return cp;let i=s.pow(r,t);const a=(t+Se)/Vt;return function(c,u){if(c.is0(u))return u;if(Bu(c,u)!==1)throw new Error("Cannot find square root");let l=n,d=c.mul(c.ONE,i),f=c.pow(u,t),p=c.pow(u,a);for(;!c.eql(f,c.ONE);){if(c.is0(f))return c.ZERO;let y=1,h=c.sqr(f);for(;!c.eql(h,c.ONE);)if(y++,h=c.sqr(h),y===l)throw new Error("Cannot find square root");const m=Se<<BigInt(l-y-1),g=c.pow(d,m);l=y,d=c.sqr(g),f=c.mul(f,d),p=c.mul(p,g)}return p}}function jv(e){return e%ip===Nv?cp:e%op===ap?Mv:Rv(e)}const Lv=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Uv(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Lv.reduce((r,s)=>(r[s]="function",r),t);return uc(e,n),e}function Dv(e,t,n){if(n<Pe)throw new Error("invalid exponent, negatives unsupported");if(n===Pe)return e.ONE;if(n===Se)return t;let r=e.ONE,s=t;for(;n>Pe;)n&Se&&(r=e.mul(r,s)),s=e.sqr(s),n>>=Se;return r}function up(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),s=t.reduce((a,o,c)=>e.is0(o)?a:(r[c]=a,e.mul(a,o)),e.ONE),i=e.inv(s);return t.reduceRight((a,o,c)=>e.is0(o)?a:(r[c]=e.mul(a,r[c]),e.mul(a,o)),i),r}function Bu(e,t){const n=(e.ORDER-Se)/Vt,r=e.pow(t,n),s=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),a=e.eql(r,e.neg(e.ONE));if(!s&&!i&&!a)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function zv(e,t){t!==void 0&&Ba(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ii(e,t,n=!1,r={}){if(e<=Pe)throw new Error("invalid field: expected ORDER > 0, got "+e);let s,i;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const l=t;l.BITS&&(s=l.BITS),l.sqrt&&(i=l.sqrt),typeof l.isLE=="boolean"&&(n=l.isLE)}else typeof t=="number"&&(s=t),r.sqrt&&(i=r.sqrt);const{nBitLength:a,nByteLength:o}=zv(e,s);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c;const u=Object.freeze({ORDER:e,isLE:n,BITS:a,BYTES:o,MASK:si(a),ZERO:Pe,ONE:Se,create:l=>ze(l,e),isValid:l=>{if(typeof l!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof l);return Pe<=l&&l<e},is0:l=>l===Pe,isValidNot0:l=>!u.is0(l)&&u.isValid(l),isOdd:l=>(l&Se)===Se,neg:l=>ze(-l,e),eql:(l,d)=>l===d,sqr:l=>ze(l*l,e),add:(l,d)=>ze(l+d,e),sub:(l,d)=>ze(l-d,e),mul:(l,d)=>ze(l*d,e),pow:(l,d)=>Dv(u,l,d),div:(l,d)=>ze(l*Cu(d,e),e),sqrN:l=>l*l,addN:(l,d)=>l+d,subN:(l,d)=>l-d,mulN:(l,d)=>l*d,inv:l=>Cu(l,e),sqrt:i||(l=>(c||(c=jv(e)),c(u,l))),toBytes:l=>n?sp(l,o):cc(l,o),fromBytes:l=>{if(l.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+l.length);return n?rp(l):ri(l)},invertBatch:l=>up(u,l),cmov:(l,d,f)=>f?d:l});return Object.freeze(u)}function dp(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function lp(e){const t=dp(e);return t+Math.ceil(t/2)}function Fv(e,t,n=!1){const r=e.length,s=dp(t),i=lp(t);
46if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const a=n?rp(e):ri(e),o=ze(a,t-Se)+Se;return n?sp(o,s):cc(o,s)}const Pn=BigInt(0),Wt=BigInt(1);function Xn(e,t){const n=t.negate();return e?n:t}function Hv(e,t,n){const r=a=>a.pz,s=up(e.Fp,n.map(r));return n.map((a,o)=>a.toAffine(s[o])).map(e.fromAffine)}function fp(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ti(e,t){fp(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),s=2**e,i=si(e),a=BigInt(e);return{windows:n,windowSize:r,mask:i,maxNumber:s,shiftBy:a}}function $u(e,t,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:a}=n;let o=Number(e&s),c=e>>a;o>r&&(o-=i,c+=Wt);const u=t*r,l=u+Math.abs(o)-1,d=o===0,f=o<0,p=t%2!==0;return{nextN:c,offset:l,isZero:d,isNeg:f,isNegF:p,offsetF:u}}function Gv(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function qv(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const Oi=new WeakMap,pp=new WeakMap;function Ci(e){return pp.get(e)||1}function Nu(e){if(e!==Pn)throw new Error("invalid wNAF")}function Vv(e,t){return{constTimeNegate:Xn,hasPrecomputes(n){return Ci(n)!==1},unsafeLadder(n,r,s=e.ZERO){let i=n;for(;r>Pn;)r&Wt&&(s=s.add(i)),i=i.double(),r>>=Wt;return s},precomputeWindow(n,r){const{windows:s,windowSize:i}=Ti(r,t),a=[];let o=n,c=o;for(let u=0;u<s;u++){c=o,a.push(c);for(let l=1;l<i;l++)c=c.add(o),a.push(c);o=c.double()}return a},wNAF(n,r,s){let i=e.ZERO,a=e.BASE;const o=Ti(n,t);for(let c=0;c<o.windows;c++){const{nextN:u,offset:l,isZero:d,isNeg:f,isNegF:p,offsetF:y}=$u(s,c,o);s=u,d?a=a.add(Xn(p,r[y])):i=i.add(Xn(f,r[l]))}return Nu(s),{p:i,f:a}},wNAFUnsafe(n,r,s,i=e.ZERO){const a=Ti(n,t);for(let o=0;o<a.windows&&s!==Pn;o++){const{nextN:c,offset:u,isZero:l,isNeg:d}=$u(s,o,a);if(s=c,!l){const f=r[u];i=i.add(d?f.negate():f)}}return Nu(s),i},getPrecomputes(n,r,s){let i=Oi.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&(typeof s=="function"&&(i=s(i)),Oi.set(r,i))),i},wNAFCached(n,r,s){const i=Ci(n);return this.wNAF(i,this.getPrecomputes(i,n,s),r)},wNAFCachedUnsafe(n,r,s,i){const a=Ci(n);return a===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(a,this.getPrecomputes(a,n,s),r,i)},setWindowSize(n,r){fp(r,t),pp.set(n,r),Oi.delete(n)}}}function Wv(e,t,n,r){let s=t,i=e.ZERO,a=e.ZERO;for(;n>Pn||r>Pn;)n&Wt&&(i=i.add(s)),r&Wt&&(a=a.add(s)),s=s.double(),n>>=Wt,r>>=Wt;return{p1:i,p2:a}}function Kv(e,t,n,r){Gv(n,e),qv(r,t);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,o=Bv(BigInt(s));let c=1;o>12?c=o-3:o>4?c=o-2:o>0&&(c=2);const u=si(c),l=new Array(Number(u)+1).fill(a),d=Math.floor((t.BITS-1)/c)*c;let f=a;for(let p=d;p>=0;p-=c){l.fill(a);for(let h=0;h<i;h++){const m=r[h],g=Number(m>>BigInt(p)&u);l[g]=l[g].add(n[h])}let y=a;for(let h=l.length-1,m=a;h>0;h--)m=m.add(l[h]),y=y.add(m);if(f=f.add(y),p!==0)for(let h=0;h<c;h++)f=f.double()}return f}function Mu(e,t){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Uv(t),t}else return ii(e)}function Zv(e,t,n={}){if(!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const o of["p","n","h"]){const c=t[o];if(!(typeof c=="bigint"&&c>Pn))throw new Error(`CURVE.${o} must be positive bigint`)}const r=Mu(t.p,n.Fp),s=Mu(t.n,n.Fn),a=["Gx","Gy","a","b"];for(const o of a)if(!r.isValid(t[o]))throw new Error(`CURVE.${o} must be valid field element of CURVE.Fp`);return{Fp:r,Fn:s}}function Ru(e){e.lowS!==void 0&&_s("lowS",e.lowS),e.prehash!==void 0&&_s("prehash",e.prehash)}let Yv=class extends Error{constructor(t=""){super(t)}};const yt={Err:Yv,_tlv:{encode:(e,t)=>{const{Err:n}=yt;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,s=Kr(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?Kr(s.length/2|128):"";return Kr(e)+i+s+t},decode(e,t){const{Err:n}=yt;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[r++],i=!!(s&128);let a=0;if(!i)a=s;else{const c=s&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const u=t.subarray(r,r+c);
46if(u.length!==c)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const l of u)a=a<<8|l;if(r+=c,a<128)throw new n("tlv.decode(long): not minimal encoding")}const o=t.subarray(r,r+a);if(o.length!==a)throw new n("tlv.decode: wrong value length");return{v:o,l:t.subarray(r+a)}}},_int:{encode(e){const{Err:t}=yt;if(e<er)throw new t("integer: negative integers are not allowed");let n=Kr(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=yt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return ri(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=yt,s=De("signature",e),{v:i,l:a}=r.decode(48,s);if(a.length)throw new t("invalid signature: left bytes after parsing");const{v:o,l:c}=r.decode(2,i),{v:u,l}=r.decode(2,c);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(o),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=yt,r=t.encode(2,n.encode(e.r)),s=t.encode(2,n.encode(e.s)),i=r+s;return t.encode(48,i)}},er=BigInt(0),tr=BigInt(1),Jv=BigInt(2),Zr=BigInt(3),Qv=BigInt(4);function Xv(e,t,n){function r(s){const i=e.sqr(s),a=e.mul(i,s);return e.add(e.add(a,e.mul(s,t)),n)}return r}function hp(e,t,n){const{BYTES:r}=e;function s(i){let a;if(typeof i=="bigint")a=i;else{let o=De("private key",i);if(t){if(!t.includes(o.length*2))throw new Error("invalid private key");const c=new Uint8Array(r);c.set(o,c.length-o.length),o=c}try{a=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof i}`)}}if(n&&(a=e.create(a)),!e.isValidNot0(a))throw new Error("invalid private key: out of range [1..N-1]");return a}return s}function e1(e,t={}){const{Fp:n,Fn:r}=Zv("weierstrass",e,t),{h:s,n:i}=e;uc(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:a}=t;if(a&&(!n.is0(e.a)||typeof a.beta!="bigint"||typeof a.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function o(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c($,v,C){const{x:E,y:P}=v.toAffine(),M=n.toBytes(E);if(_s("isCompressed",C),C){o();const I=!n.isOdd(P);return qt(mp(I),M)}else return qt(Uint8Array.of(4),M,n.toBytes(P))}function u($){_t($);const v=n.BYTES,C=v+1,E=2*v+1,P=$.length,M=$[0],I=$.subarray(1);if(P===C&&(M===2||M===3)){const T=n.fromBytes(I);if(!n.isValid(T))throw new Error("bad point: is not on curve, wrong x");const O=f(T);let N;try{N=n.sqrt(O)}catch(F){const U=F instanceof Error?": "+F.message:"";throw new Error("bad point: is not on curve, sqrt error"+U)}o();const B=n.isOdd(N);return(M&1)===1!==B&&(N=n.neg(N)),{x:T,y:N}}else if(P===E&&M===4){const T=n.fromBytes(I.subarray(v*0,v*1)),O=n.fromBytes(I.subarray(v*1,v*2));if(!p(T,O))throw new Error("bad point: is not on curve");return{x:T,y:O}}else throw new Error(`bad point: got length ${P}, expected compressed=${C} or uncompressed=${E}`)}const l=t.toBytes||c,d=t.fromBytes||u,f=Xv(n,e.a,e.b);function p($,v){const C=n.sqr(v),E=f($);return n.eql(C,E)}if(!p(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const y=n.mul(n.pow(e.a,Zr),Qv),h=n.mul(n.sqr(e.b),BigInt(27));if(n.is0(n.add(y,h)))throw new Error("bad curve params: a or b");function m($,v,C=!1){if(!n.isValid(v)||C&&n.is0(v))throw new Error(`bad point coordinate ${$}`);return v}function g($){if(!($ instanceof S))throw new Error("ProjectivePoint expected")}const b=Ou(($,v)=>{const{px:C,py:E,pz:P}=$;if(n.eql(P,n.ONE))return{x:C,y:E};const M=$.is0();v==null&&(v=M?n.ONE:n.inv(P));const I=n.mul(C,v),T=n.mul(E,v),O=n.mul(P,v);if(M)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:I,y:T}}),w=Ou($=>{if($.is0()){if(t.allowInfinityPoint&&!n.is0($.py))return;throw new Error("bad point: ZERO")}const{x:v,y:C}=$.toAffine();if(!n.isValid(v)||!n.isValid(C))throw new Error("bad point: x or y not field elements");if(!p(v,C))throw new Error("bad point: equation left != right");
46if(!$.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function x($,v,C,E,P){return C=new S(n.mul(C.px,$),C.py,C.pz),v=Xn(E,v),C=Xn(P,C),v.add(C)}class S{constructor(v,C,E){this.px=m("x",v),this.py=m("y",C,!0),this.pz=m("z",E),Object.freeze(this)}static fromAffine(v){const{x:C,y:E}=v||{};if(!v||!n.isValid(C)||!n.isValid(E))throw new Error("invalid affine point");if(v instanceof S)throw new Error("projective point not allowed");return n.is0(C)&&n.is0(E)?S.ZERO:new S(C,E,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){return Hv(S,"pz",v)}static fromBytes(v){return _t(v),S.fromHex(v)}static fromHex(v){const C=S.fromAffine(d(De("pointHex",v)));return C.assertValidity(),C}static fromPrivateKey(v){const C=hp(r,t.allowedPrivateKeyLengths,t.wrapPrivateKey);return S.BASE.multiply(C(v))}static msm(v,C){return Kv(S,r,v,C)}precompute(v=8,C=!0){return k.setWindowSize(this,v),C||this.multiply(Zr),this}_setWindowSize(v){this.precompute(v)}assertValidity(){w(this)}hasEvenY(){const{y:v}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(v)}equals(v){g(v);const{px:C,py:E,pz:P}=this,{px:M,py:I,pz:T}=v,O=n.eql(n.mul(C,T),n.mul(M,P)),N=n.eql(n.mul(E,T),n.mul(I,P));return O&&N}negate(){return new S(this.px,n.neg(this.py),this.pz)}double(){const{a:v,b:C}=e,E=n.mul(C,Zr),{px:P,py:M,pz:I}=this;let T=n.ZERO,O=n.ZERO,N=n.ZERO,B=n.mul(P,P),D=n.mul(M,M),F=n.mul(I,I),U=n.mul(P,M);return U=n.add(U,U),N=n.mul(P,I),N=n.add(N,N),T=n.mul(v,N),O=n.mul(E,F),O=n.add(T,O),T=n.sub(D,O),O=n.add(D,O),O=n.mul(T,O),T=n.mul(U,T),N=n.mul(E,N),F=n.mul(v,F),U=n.sub(B,F),U=n.mul(v,U),U=n.add(U,N),N=n.add(B,B),B=n.add(N,B),B=n.add(B,F),B=n.mul(B,U),O=n.add(O,B),F=n.mul(M,I),F=n.add(F,F),B=n.mul(F,U),T=n.sub(T,B),N=n.mul(F,D),N=n.add(N,N),N=n.add(N,N),new S(T,O,N)}add(v){g(v);const{px:C,py:E,pz:P}=this,{px:M,py:I,pz:T}=v;let O=n.ZERO,N=n.ZERO,B=n.ZERO;const D=e.a,F=n.mul(e.b,Zr);let U=n.mul(C,M),H=n.mul(E,I),Y=n.mul(P,T),K=n.add(C,E),Z=n.add(M,I);K=n.mul(K,Z),Z=n.add(U,H),K=n.sub(K,Z),Z=n.add(C,P);let te=n.add(M,T);return Z=n.mul(Z,te),te=n.add(U,Y),Z=n.sub(Z,te),te=n.add(E,P),O=n.add(I,T),te=n.mul(te,O),O=n.add(H,Y),te=n.sub(te,O),B=n.mul(D,Z),O=n.mul(F,Y),B=n.add(O,B),O=n.sub(H,B),B=n.add(H,B),N=n.mul(O,B),H=n.add(U,U),H=n.add(H,U),Y=n.mul(D,Y),Z=n.mul(F,Z),H=n.add(H,Y),Y=n.sub(U,Y),Y=n.mul(D,Y),Z=n.add(Z,Y),U=n.mul(H,Z),N=n.add(N,U),U=n.mul(te,Z),O=n.mul(K,O),O=n.sub(O,U),U=n.mul(K,H),B=n.mul(te,B),B=n.add(B,U),new S(O,N,B)}subtract(v){return this.add(v.negate())}is0(){return this.equals(S.ZERO)}multiply(v){const{endo:C}=t;if(!r.isValidNot0(v))throw new Error("invalid scalar: out of range");let E,P;const M=I=>k.wNAFCached(this,I,S.normalizeZ);if(C){const{k1neg:I,k1:T,k2neg:O,k2:N}=C.splitScalar(v),{p:B,f:D}=M(T),{p:F,f:U}=M(N);P=D.add(U),E=x(C.beta,B,F,I,O)}else{const{p:I,f:T}=M(v);E=I,P=T}return S.normalizeZ([E,P])[0]}multiplyUnsafe(v){const{endo:C}=t,E=this;if(!r.isValid(v))throw new Error("invalid scalar: out of range");if(v===er||E.is0())return S.ZERO;if(v===tr)return E;if(k.hasPrecomputes(this))return this.multiply(v);if(C){const{k1neg:P,k1:M,k2neg:I,k2:T}=C.splitScalar(v),{p1:O,p2:N}=Wv(S,E,M,T);return x(C.beta,O,N,P,I)}else return k.wNAFCachedUnsafe(E,v)}multiplyAndAddUnsafe(v,C,E){const P=this.multiplyUnsafe(C).add(v.multiplyUnsafe(E));return P.is0()?void 0:P}toAffine(v){return b(this,v)}isTorsionFree(){const{isTorsionFree:v}=t;return s===tr?!0:v?v(S,this):k.wNAFCachedUnsafe(this,i).is0()}clearCofactor(){const{clearCofactor:v}=t;return s===tr?this:v?v(S,this):this.multiplyUnsafe(s)}toBytes(v=!0){return _s("isCompressed",v),this.assertValidity(),l(S,this,v)}toRawBytes(v=!0){return this.toBytes(v)}toHex(v=!0){return Pr(this.toBytes(v))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}S.BASE=new S(e.Gx,e.Gy,n.ONE),S.ZERO=new S(n.ZERO,n.ONE,n.ZERO),S.Fp=n,S.Fn=r;const A=r.BITS,k=Vv(S,t.endo?Math.ceil(A/2):A);return S}function mp(e){return Uint8Array.of(e?2:3)}function t1(e,t,n={}){uc(t,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=t.randomBytes||Ev,s=t.hmac||((E,...P)=>tp(t.hash,E,qt(...P))),{Fp:i,Fn:a}=e,{ORDER:o,BITS:c}=a;function u(E){const P=o>>tr;return E>P}function l(E){return u(E)?a.neg(E):E}function d(E,P){if(!a.isValidNot0(P))throw new Error(`invalid signature ${E}: out of range 1..CURVE.n`)}class f{constructor(P,M,I){d("r",P),d("s",M),this.r=P,this.s=M,I!=null&&(this.recovery=I),Object.freeze(this)}static fromCompact(P){const M=a.BYTES,I=De("compactSignature",P,M*2);return new f(a.fromBytes(I.subarray(0,M)),a.fromBytes(I.subarray(M,M*2)))}static fromDER(P){const{r:M,s:I}=yt.toSig(De("DER",P));return new f(M,I)}assertValidity(){}addRecoveryBit(P){return new f(this.r,this.s,P)}recoverPublicKey(P){const M=i.ORDER,{r:I,s:T,recovery:O}=this;if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");if(o*Jv<M&&O>1)throw new Error("recovery id is ambiguous for h>1 curve");const B=O===2||O===3?I+o:I;if(!i.isValid(B))throw new Error("recovery id 2 or 3 invalid");const D=i.toBytes(B),F=e.fromHex(qt(mp((O&1)===0),D)),U=a.inv(B),H=w(De("msgHash",P)),Y=a.create(-H*U),K=a.create(T*U),Z=e.BASE.multiplyUnsafe(Y).add(F.multiplyUnsafe(K));if(Z.is0())throw new Error("point at infinify");return Z.assertValidity(),Z}hasHighS(){return u(this.s)}normalizeS(){return this.hasHighS()?new f(this.r,a.neg(this.s),this.recovery):this}toBytes(P){if(P==="compact")return qt(a.toBytes(this.r),a.toBytes(this.s));if(P==="der")return ic(yt.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Pr(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Pr(this.toBytes("compact"))}}const p=hp(a,n.allowedPrivateKeyLengths,n.wrapPrivateKey),y={isValidPrivateKey(E){try{return p(E),!0}catch{return!1}},normPrivateKeyToScalar:p,randomPrivateKey:()=>{const E=o;return Fv(r(lp(E)),E)},precompute(E=8,P=e.BASE){return P.precompute(E,!1)}};function h(E,P=!0){return e.fromPrivateKey(E).toBytes(P)}function m(E){if(typeof E=="bigint")return!1;if(E instanceof e)return!0;const M=De("key",E).length,I=i.BYTES,T=I+1,O=2*I+1;if(!(n.allowedPrivateKeyLengths||a.BYTES===T))return M===T||M===O}function g(E,P,M=!0){if(m(E)===!0)throw new Error("first arg must be private key");if(m(P)===!1)throw new Error("second arg must be public key");
46return e.fromHex(P).multiply(p(E)).toBytes(M)}const b=t.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");const P=ri(E),M=E.length*8-c;return M>0?P>>BigInt(M):P},w=t.bits2int_modN||function(E){return a.create(b(E))},x=si(c);function S(E){return Cv("num < 2^"+c,E,er,x),a.toBytes(E)}function A(E,P,M=k){if(["recovered","canonical"].some(K=>K in M))throw new Error("sign() legacy options not supported");const{hash:I}=t;let{lowS:T,prehash:O,extraEntropy:N}=M;T==null&&(T=!0),E=De("msgHash",E),Ru(M),O&&(E=De("prehashed msgHash",I(E)));const B=w(E),D=p(P),F=[S(D),S(B)];if(N!=null&&N!==!1){const K=N===!0?r(i.BYTES):N;F.push(De("extraEntropy",K))}const U=qt(...F),H=B;function Y(K){const Z=b(K);if(!a.isValidNot0(Z))return;const te=a.inv(Z),ut=e.BASE.multiply(Z).toAffine(),ke=a.create(ut.x);if(ke===er)return;const Ie=a.create(te*a.create(H+ke*D));if(Ie===er)return;let Lt=(ut.x===ke?0:2)|Number(ut.y&tr),je=Ie;return T&&u(Ie)&&(je=l(Ie),Lt^=1),new f(ke,je,Lt)}return{seed:U,k2sig:Y}}const k={lowS:t.lowS,prehash:!1},$={lowS:t.lowS,prehash:!1};function v(E,P,M=k){const{seed:I,k2sig:T}=A(E,P,M);return $v(t.hash.outputLen,a.BYTES,s)(I,T)}e.BASE.precompute(8);function C(E,P,M,I=$){const T=E;P=De("msgHash",P),M=De("publicKey",M),Ru(I);const{lowS:O,prehash:N,format:B}=I;if("strict"in I)throw new Error("options.strict was renamed to lowS");if(B!==void 0&&!["compact","der","js"].includes(B))throw new Error('format must be "compact", "der" or "js"');const D=typeof T=="string"||sc(T),F=!D&&!B&&typeof T=="object"&&T!==null&&typeof T.r=="bigint"&&typeof T.s=="bigint";if(!D&&!F)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let U,H;try{if(F)if(B===void 0||B==="js")U=new f(T.r,T.s);else throw new Error("invalid format");if(D){try{B!=="compact"&&(U=f.fromDER(T))}catch(je){if(!(je instanceof yt.Err))throw je}!U&&B!=="der"&&(U=f.fromCompact(T))}H=e.fromHex(M)}catch{return!1}if(!U||O&&U.hasHighS())return!1;N&&(P=t.hash(P));const{r:Y,s:K}=U,Z=w(P),te=a.inv(K),ut=a.create(Z*te),ke=a.create(Y*te),Ie=e.BASE.multiplyUnsafe(ut).add(H.multiplyUnsafe(ke));return Ie.is0()?!1:a.create(Ie.x)===Y}return Object.freeze({getPublicKey:h,getSharedSecret:g,sign:v,verify:C,utils:y,Point:e,Signature:f})}function n1(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=ii(t.n,e.nBitLength),s={Fp:n,Fn:r,allowedPrivateKeyLengths:e.allowedPrivateKeyLengths,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,wrapPrivateKey:e.wrapPrivateKey,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:s}}function r1(e){const{CURVE:t,curveOpts:n}=n1(e),r={hash:e.hash,hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,ecdsaOpts:r}}function s1(e,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:e})}function i1(e){const{CURVE:t,curveOpts:n,ecdsaOpts:r}=r1(e),s=e1(t,n),i=t1(s,r,n);return s1(e,i)}function a1(e,t){const n=r=>i1({...e,hash:r});return{...n(t),create:n}}const Ss={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")};BigInt(0);const o1=BigInt(1),Na=BigInt(2),ju=(e,t)=>(e+t/Na)/t;function c1(e){const t=Ss.p,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),a=BigInt(23),o=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,d=Ue(l,n,t)*l%t,f=Ue(d,n,t)*l%t,p=Ue(f,Na,t)*u%t,y=Ue(p,s,t)*p%t,h=Ue(y,i,t)*y%t,m=Ue(h,o,t)*h%t,g=Ue(m,c,t)*m%t,b=Ue(g,o,t)*h%t,w=Ue(b,n,t)*l%t,x=Ue(w,a,t)*y%t,S=Ue(x,r,t)*u%t,A=Ue(S,Na,t);if(!Ma.eql(Ma.sqr(A),e))throw new Error("Cannot find square root");return A}const Ma=ii(Ss.p,void 0,void 0,{sqrt:c1}),dc=a1({...Ss,Fp:Ma,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Ss.n,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-o1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,a=BigInt("0x100000000000000000000000000000000"),o=ju(i*e,t),c=ju(-r*e,t);let u=ze(e-o*n-c*s,t),l=ze(-o*r-c*i,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}}}},Tv),u1=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:dc},Symbol.toStringTag,{value:"Module"}));function d1({r:e,s:t,to:n="hex",v:r,yParity:s}){const i=(()=>
46{if(s===0||s===1)return s;if(r&&(r===27n||r===28n||r>=35n))return r%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),a=`0x${new dc.Signature(de(e),de(t)).toCompactHex()}${i===0?"1b":"1c"}`;return n==="hex"?a:Ae(a)}async function lc(e,t){const{address:n,factory:r,factoryData:s,hash:i,signature:a,universalSignatureVerifierAddress:o=e.chain?.contracts?.universalSignatureVerifier?.address,...c}=t,u=we(a)?a:typeof a=="object"&&"r"in a&&"s"in a?d1(a):pe(a),l=await(async()=>!r&&!s||$w(u)?u:ds({address:r,data:s,signature:u}))();try{const d=o?{to:o,data:he({abi:Eu,functionName:"isValidSig",args:[n,i,l]}),...c}:{data:Ko({abi:Eu,args:[n,i,l],bytecode:gb}),...c},{data:f}=await z(e,Ys,"call")(d);return Vm(f??"0x0")}catch(d){try{if(Rr(oa(n),await Zl({hash:i,signature:a})))return!0}catch{}if(d instanceof Vl)return!1;throw d}}async function l1(e,{address:t,message:n,factory:r,factoryData:s,signature:i,...a}){const o=ti(n);return lc(e,{address:t,factory:r,factoryData:s,hash:o,signature:i,...a})}async function f1(e,t){const{address:n,factory:r,factoryData:s,signature:i,message:a,primaryType:o,types:c,domain:u,...l}=t,d=Lr({message:a,primaryType:o,types:c,domain:u});return lc(e,{address:n,factory:r,factoryData:s,hash:d,signature:i,...l})}function yp(e,{emitOnBegin:t=!1,emitMissed:n=!1,onBlockNumber:r,onError:s,poll:i,pollingInterval:a=e.pollingInterval}){const o=typeof i<"u"?i:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].c
46onfig.type==="webSocket"||e.transport.transports[0].config.type==="ipc"));let c;return o?(()=>{const d=fe(["watchBlockNumber",e.uid,t,n,a]);return ct(d,{onBlockNumber:r,onError:s},f=>dn(async()=>{try{const p=await z(e,jr,"getBlockNumber")({cacheTime:0});if(c){if(p===c)return;if(p-c>1&&n)for(let y=c+1n;y<p;y++)f.onBlockNumber(y,c),c=y}(!c||p>c)&&(f.onBlockNumber(p,c),c=p)}catch(p){f.onError?.(p)}},{emitOnBegin:t,interval:a}))})():(()=>{const d=fe(["watchBlockNumber",e.uid,t,n]);return ct(d,{onBlockNumber:r,onError:s},f=>{let p=!0,y=()=>p=!1;return(async()=>{try{const h=(()=>{if(e.transport.type==="fallback"){const g=e.transport.transports.find(b=>b.config.type==="webSocket"||b.config.type==="ipc");return g?g.value:e.transport}return e.transport})(),{unsubscribe:m}=await h.subscribe({params:["newHeads"],onData(g){if(!p)return;const b=de(g.result?.number);f.onBlockNumber(b,c),c=b},onError(g){f.onError?.(g)}});y=m,p||y()}catch(h){s?.(h)}})(),()=>y()})})()}async function p1(e,t){const{checkReplacement:n=!0,confirmations:r=1,hash:s,onReplaced:i,retryCount:a=6,retryDelay:o=({count:S})=>~~(1<<S)*200,timeout:c=18e4}=t,u=fe(["waitForTransactionReceipt",e.uid,s]),l=t.pollingInterval?t.pollingInterval:e.chain?.experimental_preconfirmationTime?e.chain.experimental_preconfirmationTime:e.pollingInterval;let d,f,p,y=!1,h,m;const{promise:g,resolve:b,reject:w}=Zo(),x=c?setTimeout(()=>{m(),h(),w(new tg({hash:s}))},c):void 0;return h=ct(u,{onReplaced:i,resolve:b,reject:w},async S=>{if(p=await z(e,ls,"getTransactionReceipt")({hash:s}).catch(()=>{}),p&&r<=1){clearTimeout(x),S.resolve(p),h();return}m=z(e,yp,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:l,async onBlockNumber(A){const k=v=>{clearTimeout(x),m(),v(),h()};let $=A;if(!y)try{if(p){if(r>1&&(!p.blockNumber||$-p.blockNumber+1n<r))return;k(()=>S.resolve(p));return}if(n&&!d&&(y=!0,await Aa(async()=>{d=await z(e,tc,"getTransaction")({hash:s}),d.blockNumber&&($=d.blockNumber)},{delay:o,retryCount:a}),y=!1),p=await z(e,ls,"getTransactionReceipt")({hash:s}),r>1&&(!p.blockNumber||$-p.blockNumber+1n<r))return;k(()=>S.resolve(p))}catch(v){if(v instanceof Gl||v instanceof ql){if(!d){y=!1;return}try{f=d,y=!0;const C=await Aa(()=>z(e,st,"getBlock")({blockNumber:$,includeTransactions:!0}),{delay:o,retryCount:a,shouldRetry:({error:M})=>M instanceof Ql});y=!1;const E=C.transactions.find(({from:M,nonce:I})=>M===f.from&&I===f.nonce);if(!E||(p=await z(e,ls,"getTransactionReceipt")({hash:E.hash}),r>1&&(!p.blockNumber||$-p.blockNumber+1n<r)))return;let P="replaced";E.to===f.to&&E.value===f.value&&E.input===f.input?P="repriced":E.from===E.to&&E.value===0n&&(P="cancelled"),k(()=>{S.onReplaced?.({reason:P,replacedTransaction:f,transaction:E,transactionReceipt:p}),S.resolve(p)})}catch(C){k(()=>S.reject(C))}}else k(()=>S.reject(v))}}})}),g}function h1(e,{blockTag:t=e.experimental_blockTag??"latest",emitMissed:n=!1,emitOnBegin:r=!1,onBlock:s,onError:i,includeTransactions:a,poll:o,pollingInterval:c=e.pollingInterval}){const u=typeof o<"u"?o:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].c
46onfig.type==="webSocket"||e.transport.transports[0].config.type==="ipc")),l=a??!1;let d;return u?(()=>{const y=fe(["watchBlocks",e.uid,t,n,r,l,c]);return ct(y,{onBlock:s,onError:i},h=>dn(async()=>{try{const m=await z(e,st,"getBlock")({blockTag:t,includeTransactions:l});if(m.number!==null&&d?.number!=null){if(m.number===d.number)return;if(m.number-d.number>1&&n)for(let g=d?.number+1n;g<m.number;g++){const b=await z(e,st,"getBlock")({blockNumber:g,includeTransactions:l});h.onBlock(b,d),d=b}}(d?.number==null||t==="pending"&&m?.number==null||m.number!==null&&m.number>d.number)&&(h.onBlock(m,d),d=m)}catch(m){h.onError?.(m)}},{emitOnBegin:r,interval:c}))})():(()=>{let y=!0,h=!0,m=()=>y=!1;return(async()=>{try{r&&z(e,st,"getBlock")({blockTag:t,includeTransactions:l}).then(w=>{y&&h&&(s(w,void 0),h=!1)}).catch(i);const g=(()=>{if(e.transport.type==="fallback"){const w=e.transport.transports.find(x=>x.config.type==="webSocket"||x.config.type==="ipc");return w?w.value:e.transport}return e.transport})(),{unsubscribe:b}=await g.subscribe({params:["newHeads"],async onData(w){if(!y)return;const x=await z(e,st,"getBlock")({blockNumber:w.result?.number,includeTransactions:l}).catch(()=>{});y&&(s(x,d),h=!1,d=x)},onError(w){i?.(w)}});m=b,y||m()}catch(g){i?.(g)}})(),()=>m()})()}function m1(e,{address:t,args:n,batch:r=!0,event:s,events:i,fromBlock:a,onError:o,onLogs:c,poll:u,pollingInterval:l=e.pollingInterval,strict:d}){const f=typeof u<"u"?u:typeof a=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].c
46onfig.type==="webSocket"||e.transport.transports[0].config.type==="ipc")),p=d??!1;return f?(()=>{const m=fe(["watchEvent",t,n,r,e.uid,s,l,a]);return ct(m,{onLogs:c,onError:o},g=>{let b;a!==void 0&&(b=a-1n);let w,x=!1;const S=dn(async()=>{if(!x){try{w=await z(e,Mf,"createEventFilter")({address:t,args:n,event:s,events:i,strict:p,fromBlock:a})}catch{}x=!0;return}try{let A;if(w)A=await z(e,Js,"getFilterChanges")({filter:w});else{const k=await z(e,jr,"getBlockNumber")({});b&&b!==k?A=await z(e,Go,"getLogs")({address:t,args:n,event:s,events:i,fromBlock:b+1n,toBlock:k}):A=[],b=k}if(A.length===0)return;if(r)g.onLogs(A);else for(const k of A)g.onLogs([k])}catch(A){w&&A instanceof nn&&(x=!1),g.onError?.(A)}},{emitOnBegin:!0,interval:l});return async()=>{w&&await z(e,Qs,"uninstallFilter")({filter:w}),S()}})})():(()=>{let m=!0,g=()=>m=!1;return(async()=>{try{const b=(()=>{if(e.transport.type==="fallback"){const A=e.transport.transports.find(k=>k.config.type==="webSocket"||k.config.type==="ipc");return A?A.value:e.transport}return e.transport})(),w=i??(s?[s]:void 0);let x=[];w&&(x=[w.flatMap(k=>Br({abi:[k],eventName:k.name,args:n}))],s&&(x=x[0]));const{unsubscribe:S}=await b.subscribe({params:["logs",{address:t,topics:x}],onData(A){if(!m)return;const k=A.result;try{const{eventName:$,args:v}=Fo({abi:w??[],data:k.data,topics:k.topics,strict:p}),C=at(k,{args:v,eventName:$});c([C])}catch($){let v,C;if($ instanceof sr||$ instanceof zs){if(d)return;v=$.abiItem.name,C=$.abiItem.inputs?.some(P=>!("name"in P&&P.name))}const E=at(k,{args:C?[]:{},eventName:v});c([E])}},onError(A){o?.(A)}});g=S,m||g()}catch(b){o?.(b)}})(),()=>g()})()}function y1(e,{batch:t=!0,onError:n,onTransactions:r,poll:s,pollingInterval:i=e.pollingInterval}){return(typeof s<"u"?s:e.transport.type!=="webSocket"&&e.transport.type!=="ipc")?(()=>{const u=fe(["watchPendingTransactions",e.uid,t,i]);return ct(u,{onTransactions:r,onError:n},l=>{let d;const f=dn(async()=>{try{if(!d)try{d=await z(e,Rf,"createPendingTransactionFilter")({});return}catch(y){throw f(),y}const p=await z(e,Js,"getFilterChanges")({filter:d});if(p.length===0)return;if(t)l.onTransactions(p);else for(const y of p)l.onTransactions([y])}catch(p){l.onError?.(p)}},{emitOnBegin:!0,interval:i});return async()=>{d&&await z(e,Qs,"uninstallFilter")({filter:d}),f()}})})():(()=>{let u=!0,l=()=>u=!1;return(async()=>{try{const{unsubscribe:d}=await e.transport.subscribe({params:["newPendingTransactions"],onData(f){if(!u)return;const p=f.result;r([p])},onError(f){n?.(f)}});l=d,u||l()}catch(d){n?.(d)}})(),()=>l()})()}function g1(e){const{scheme:t,statement:n,...r}=e.match(b1)?.groups??{},{chainId:s,expirationTime:i,issuedAt:a,notBefore:o,requestId:c,...u}=e.match(w1)?.groups??{},l=e.split("Resources:")[1]?.split(` 47- `).slice(1);return{...r,...u,...s?{chainId:Number(s)}:{},...i?{expirationTime:new Date(i)}:{},...a?{issuedAt:new Date(a)}:{},...o?{notBefore:new Date(o)}:{},...c?{requestId:c}:{},...l?{resources:l}:{},...t?{scheme:t}:{},...n?{statement:n}:{}}}const b1=/^(?:(?<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)?/,w1=/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;function v1(e){const{address:t,domain:n,message:r,nonce:s,scheme:i,time:a=new Date}=e;if(n&&r.domain!==n||s&&r.nonce!==s||i&&r.scheme!==i||r.expirationTime&&a>=r.expirationTime||r.notBefore&&a<r.notBefore)return!1;try{if(!r.address||!be(r.address,{strict:!1})||t&&!Rr(r.address,t))return!1}catch{return!1}return!0}async function x1(e,t){const{address:n,domain:r,message:s,nonce:i,scheme:a,signature:o,time:c=new Date,...u}=t,l=g1(s);if(!l.address||!v1({address:n,domain:r,message:l,nonce:i,scheme:a,time:c}))return!1;const f=ti(s);return lc(e,{address:l.address,hash:f,signature:o,...u})}function E1(e){return{call:t=>Ys(e,t),createAccessList:t=>Nf(e,t),createBlockFilter:()=>lw(e),createContractEventFilter:t=>Rl(e,t),createEventFilter:t=>Mf(e,t),createPendingTransactionFilter:()=>Rf(e),estimateContractGas:t=>zg(e,t),estimateGas:t=>zo(e,t),getBalance:t=>df(e,t),getBlobBaseFee:()=>fw(e),getBlock:t=>st(e,t),getBlockNumber:t=>jr(e,t),getBlockTransactionCount:t=>pw(e,t),getBytecode:t=>vs(e,t),getChainId:()=>Mr(e),getCode:t=>vs(e,t),getContractEvents:t=>lf(e,t),getEip712Domain:t=>mw(e,t),getEnsAddress:t=>Zb(e,t),getEnsAvatar:t=>cw(e,t),getEnsName:t=>uw(e,t),getEnsResolver:t=>dw(e,t),getEnsText:t=>$f(e,t),getFeeHistory:t=>bw(e,t),estimateFeesPerGas:t=>rf(e,t),getFilterChanges:t=>Js(e,t),getFilterLogs:t=>ww(e,t),getGasPrice:()=>Lo(e),getLogs:t=>Go(e,t),getProof:t=>jw(e,t),estimateMaxPriorityFeePerGas:t=>_g(e,t),getStorageAt:t=>Lw(e,t),getTransaction:t=>tc(e,t),getTransactionConfirmations:t=>Uw(e,t),getTransactionCount:t=>Uo(e,t),getTransactionReceipt:t=>ls(e,t),multicall:t=>Dw(e,t),prepareTransactionRequest:t=>uf(e,t),readContract:t=>qe(e,t),sendRawTransaction:t=>Cb(e,t),simulate:t=>ka(e,t),simulateBlocks:t=>ka(e,t),simulateCalls:t=>yv(e,t),simulateContract:t=>_b(e,t),verifyMessage:t=>l1(e,t),verifySiweMessage:t=>x1(e,t),verifyTypedData:t=>f1(e,t),uninstallFilter:t=>Qs(e,t),waitForTransactionReceipt:t=>p1(e,t),watchBlocks:t=>h1(e,t),watchBlockNumber:t=>yp(e,t),watchContractEvent:t=>Ob(e,t),watchEvent:t=>m1(e,t),watchPendingTransactions:t=>y1(e,t)}}function _1(e){const{key:t="public",name:n="Public Client"}=e;return Tf({...e,key:t,name:n,type:"publicClient"}).extend(E1)}async function S1(e,t){const{account:n=e.account,chainId:r,nonce:s}
47=t;if(!n)throw new Xs({docsPath:"/docs/eip7702/prepareAuthorization"});const i=xe(n),a=(()=>{if(t.executor)return t.executor==="self"?t.executor:xe(t.executor)})(),o={address:t.contractAddress??t.address,chainId:r,nonce:s};return typeof o.chainId>"u"&&(o.chainId=e.chain?.id??await z(e,Mr,"getChainId")({})),typeof o.nonce>"u"&&(o.nonce=await z(e,Uo,"getTransactionCount")({address:i.address,blockTag:"pending"}),(a==="self"||a?.address&&Rr(a.address,i.address))&&(o.nonce+=1)),o}function A1(e){const{r:t,s:n}=dc.Signature.fromCompact(e.slice(2,130)),r=+`0x${e.slice(130)}`,[s,i]=(()=>{if(r===0||r===1)return[void 0,r];if(r===27)return[BigInt(r),0];if(r===28)return[BigInt(r),1];throw new Error("Invalid yParityOrV value")})();return typeof s<"u"?{r:R(t,{size:32}),s:R(n,{size:32}),v:s,yParity:i}:{r:R(t,{size:32}),s:R(n,{size:32}),yParity:i}}const k1=({method:e,correlationId:t})=>{var n;W("scw_signer.handshake.started",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=L.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},V.high)},I1=({method:e,correlationId:t,errorMessage:n})=>{var r;W("scw_signer.handshake.error",{action:q.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=L.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},V.high)},P1=({method:e,correlationId:t})=>{var n;W("scw_signer.handshake.completed",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=L.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},V.high)},T1=({method:e,correlationId:t})=>{var n;W("scw_signer.request.started",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=L.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},V.high)},O1=({method:e,correlationId:t,errorMessage:n})=>{var r;W("scw_signer.request.error",{action:q.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=L.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},V.high)},C1=({method:e,correlationId:t})=>{var n;W("scw_signer.request.completed",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=L.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},V.high)},B1=({method:e,correlationId:t})=>{var n;W("scw_sub_account.request.started",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=L.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},V.high)},$1=({method:e,correlationId:t})=>{var n;W("scw_sub_account.request.completed",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=L.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},V.high)},N1=({method:e,correlationId:t,errorMessage:n})=>{var r;W("scw_sub_account.request.error",{action:q.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=L.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},V.high)},M1=({method:e,correlationId:t})=>{var n;W("scw_sub_account.add_owner.started",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=L.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},V.high)},R1=({method:e,correlationId:t})=>{var n;W("scw_sub_account.add_owner.completed",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=L.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},V.high)},j1=({method:e,correlationId:t,errorMessage:n})=>{var r;W("scw_sub_account.add_owner.error",{action:q.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=L.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},V.high)},L1=({method:e,correlationId:t})=>{var n;W("scw_sub_account.insufficient_balance.error_handling.started",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=L.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},V.high)},U1=({method:e,correlationId:t})=>{var n;W("scw_sub_account.insufficient_balance.error_handling.completed",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=L.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},V.high)},D1=({method:e,correlationId:t,errorMessage:n})=>{var r;W("scw_sub_account.insufficient_balance.error_handling.error",{action:q.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=L.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},V.high)},Ft=e=>"message"in e&&typeof e.message=="string"?e.message:"",z1=[{inputs:[{name:"preOpGas",type:"uint256"},{name:"paid",type:"uint256"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"targetSuccess",type:"bool"},{name:"targetResult",type:"bytes"}],name:"ExecutionResult",type:"error"},{inputs:[{name:"opIndex",type:"uint256"},{name:"reason",type:"string"}],name:"FailedOp",type:"error"},{inputs:[{name:"sender",type:"address"}],name:"SenderAddressResult",type:"error"},{inputs:[{name:"aggregator",type:"address"}],name:"SignatureValidationFailed",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"}],name:"ValidationResult",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"},{components:[{name:"aggregator",type:"address"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"stakeInfo",type:"tuple"}],name:"aggregatorInfo",type:"tuple"}],name:"ValidationResultWithAggregation",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"factory",type:"address"},{indexed:!1,name:"paymaster",type:"address"}],name:"AccountDeployed",type:"event"},{anonymous:!1,inputs:[],name:"BeforeExecution",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalDeposit",type:"uint256"}],name:"Deposited",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"aggregator",type:"address"}],name:"SignatureAggregatorChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalStaked",type:"uint256"},{indexed:!1,name:"unstakeDelaySec",type:"uint256"}],name:"StakeLocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawTime",type:"uint256"}],name:"StakeUnlocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"StakeWithdrawn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!0,name:"paymaster",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"success",type:"bool"},{indexed:!1,name:"actualGasCost",type:"uint256"},{indexed:!1,name:"actualGasUsed",type:"uint256"}],name:"UserOperationEvent",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"revertReason",type:"bytes"}],name:"UserOperationRevertReason",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"Withdrawn",type:"event"},{inputs:[],name:"SIG_VALIDATION_FAILED",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"},{name:"sender",type:"address"},{name:"paymasterAndData",type:"bytes"}],name:"_validateSenderAndPaymaster",outputs:[],stateMutability:"view",type:"function"},{inputs:[{name:"unstakeDelaySec",type:"uint32"}],name:"addStake",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"depositTo",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"",type:"address"}],name:"deposits",outputs:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"getDepositInfo",outputs:[{components:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],name:"info",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{name:"sender",type:"address"},{name:"key",type:"uint192"}],name:"getNonce",outputs:[{name:"nonce",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"}],name:"getSenderAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOps",type:"tuple[]"},{name:"aggregator",type:"address"},{name:"signature",type:"bytes"}],name:"opsPerAggregator",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleAggregatedOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"ops",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"key",type:"uint192"}],name:"incrementNonce",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"callData",type:"bytes"},{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"paymaster",type:"address"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"}],name:"mUserOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"prefund",type:"uint256"},{name:"contextOffset",type:"uint256"},{name:"preOpGas",type:"uint256"}],name:"opInfo",type:"tuple"},{name:"context",type:"bytes"}],name:"innerHandleOp",outputs:[{name:"actualGasCost",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"",type:"address"},{name:"",type:"uint192"}],name:"nonceSequenceNumber",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"op",type:"tuple"},{name:"target",type:"address"},{name:"targetCallData",type:"bytes"}],name:"simulateHandleOp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"simulateValidation",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unlockStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"}],name:"withdrawStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"},{name:"withdrawAmount",type:"uint256"}],name:"withdrawTo",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}];function gp(e){const{authorization:t,factory:n,factoryData:r}=e;if(n==="0x7702"||n==="0x7702000000000000000000000000000000000000"){if(!t)return"0x7702000000000000000000000000000000000000";const s=t.address;return ve([s,r??"0x"])}return n?ve([n,r??"0x"]):"0x"}function bp(e){const{callGasLimit:t,callData:n,maxPriorityFeePerGas:r,maxFeePerGas:s,paymaster:i,paymasterData:a,paymasterPostOpGasLimit:o,paymasterVerificationGasLimit:c,sender:u,signature:l="0x",verificationGasLimit:d}=e,f=ve([le(R(d||0n),{size:16}),le(R(t||0n),{size:16})]),p=gp(e),y=ve([le(R(r||0n),{size:16}),le(R(s||0n),{size:16})]),h=e.nonce??0n,m=i?ve([i,le(R(c||0n),{size:16}),le(R(o||0n),{size:16}),a||"0x"]):"0x",g=e.preVerificationGas??0n;return{accountGasLimits:f,callData:n,initCode:p,gasFees:y,nonce:h,paymasterAndData:m,preVerificationGas:g,sender:u,signature:l}}const F1={PackedUserOperation:[{type:"address",name:"sender"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"bytes32",name:"accountGasLimits"},{type:"uint256",name:"preVerificationGas"},{type:"bytes32",name:"gasFees"},{type:"bytes",name:"paymasterAndData"}]};function H1(e){const{chainId:t,entryPointAddress:n,userOperation:r}=e,s=bp(r);return{types:F1,primaryType:"PackedUserOperation",domain:{name:"ERC4337",version:"1",chainId:t,verifyingContract:n},message:s}}function G1(e){const{chainId:t,entryPointAddress:n,entryPointVersion:r}=e,s=e.userOperation,{authorization:i,callData:a="0x",callGasLimit:o,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:l,paymasterAndData:d="0x",preVerificationGas:f,sen
47der:p,verificationGasLimit:y}=s;if(r==="0.8")return Lr(H1({chainId:t,entryPointAddress:n,userOperation:s}));const h=(()=>{if(r==="0.6"){const m=s.initCode?.slice(0,42),g=s.initCode?.slice(42),b=gp({authorization:i,factory:m,factoryData:g});return $e([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"bytes32"}],[p,l,X(b),X(a),o,y,f,c,u,X(d)])}if(r==="0.7"){const m=bp(s);return $e([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[m.sender,m.nonce,X(m.initCode),X(m.callData),m.accountGasLimits,m.preVerificationGas,m.gasFees,X(m.paymasterAndData)])}throw new Error(`entryPointVersion "${r}" not supported.`)})();return X($e([{type:"bytes32"},{type:"address"},{type:"uint256"}],[X(h),n,BigInt(t)]))}async function q1(e){const{extend:t,nonceKeyManager:n=Nw({source:{get(){return Date.now()},set(){}}}),...r}=e;let s=!1;const i=await e.getAddress();return{...t,...r,address:i,async getFactoryArgs(){return"isDeployed"in this&&await this.isDeployed()?{factory:void 0,factoryData:void 0}:e.getFactoryArgs()},async getNonce(a){const o=a?.key??BigInt(await n.consume({address:i,chainId:e.client.chain.id,client:e.client}));return e.getNonce?await e.getNonce({...a,key:o}):await qe(e.client,{abi:po(["function getNonce(address, uint192) pure returns (uint256)"]),address:e.entryPoint.address,functionName:"getNonce",args:[i,o]})},async isDeployed(){return s?!0:(s=!!await z(e.client,vs,"getCode")({address:i}),s)},...e.sign?{async sign(a){const[{factory:o,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.sign(a)]);return o&&c?ds({address:o,data:c,signature:u}):u}}:{},async signMessage(a){const[{factory:o,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.signMessage(a)]);return o&&c&&o!=="0x7702"?ds({address:o,data:c,signature:u}):u},async signTypedData(a){const[{factory:o,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.signTypedData(a)]);return o&&c&&o!=="0x7702"?ds({address:o,data:c,signature:u}):u},type:"smart"}}class Ra extends _{constructor({cause:t}){super("Smart Account is not deployed.",{cause:t,metaMessages:["This could arise when:","- No `factory`/`factoryData` or `initCode` properties are provided for Smart Account deployment.","- An incorrect `sender` address is provided."],name:"AccountNotDeployedError"})}}Object.defineProperty(Ra,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa20/});class Tn extends _{constructor({cause:t,data:n,message:r}={}){const s=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${s?`with reason: ${s}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n}}Object.defineProperty(Tn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32521});Object.defineProperty(Tn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class ja extends _{constructor({cause:t}){super("Failed to send funds to beneficiary.",{cause:t,name:"FailedToSendToBeneficiaryError"})}}Object.defineProperty(ja,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa91/});class La extends _{constructor({cause:t}){super("Gas value overflowed.",{cause:t,metaMessages:["This could arise when:","- one of the gas values exceeded 2**120 (uint120)"].filter(
vendor: 8,654 bytes, lines 47-50
47Boolean),name:"GasValuesOverflowError"})}}Object.defineProperty(La,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa94/});class Ua extends _{constructor({cause:t}){super("The `handleOps` function was called by the Bundler with a gas limit too low.",{cause:t,name:"HandleOpsOutOfGasError"})}}Object.defineProperty(Ua,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa95/});class Da extends _{constructor({cause:t,factory:n,factoryData:r,initCode:s}){super("Failed to simulate deployment for Smart Account.",{cause:t,metaMessages:["This could arise when:","- Invalid `factory`/`factoryData` or `initCode` properties are present","- Smart Account deployment execution ran out of gas (low `verificationGasLimit` value)",`- Smart Account deployment execution reverted with an error 48`,n&&`factory: ${n}`,r&&`factoryData: ${r}`,s&&`initCode: ${s}`].filter(Boolean),name:"InitCodeFailedError"})}}Object.defineProperty(Da,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa13/});class za extends _{constructor({cause:t,factory:n,factoryData:r,initCode:s}){super("Smart Account initialization implementation did not create an account.",{cause:t,metaMessages:["This could arise when:","- `factory`/`factoryData` or `initCode` properties are invalid",`- Smart Account initialization implementation is incorrect 49`,n&&`factory: ${n}`,r&&`factoryData: ${r}`,s&&`initCode: ${s}`].filter(Boolean),name:"InitCodeMustCreateSenderError"})}}Object.defineProperty(za,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa15/});class Fa extends _{constructor({cause:t,factory:n,factoryData:r,initCode:s,sender:i}){super("Smart Account initialization implementation does not return the expected sender.",{cause:t,metaMessages:["This could arise when:",`Smart Account initialization implementation does not return a sender address 50`,n&&`factory: ${n}`,r&&`factoryData: ${r}`,s&&`initCode: ${s}`,i&&`sender: ${i}`].filter(Boolean),name:"InitCodeMustReturnSenderError"})}}Object.defineProperty(Fa,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa14/});class Ha extends _{constructor({cause:t}){super("Smart Account does not have sufficient funds to execute the User Operation.",{cause:t,metaMessages:["This could arise when:","- the Smart Account does not have sufficient funds to cover the required prefund, or","- a Paymaster was not provided"].filter(Boolean),name:"InsufficientPrefundError"})}}Object.defineProperty(Ha,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa21/});class Ga extends _{constructor({cause:t}){super("Bundler attempted to call an invalid function on the EntryPoint.",{cause:t,name:"InternalCallOnlyError"})}}Object.defineProperty(Ga,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa92/});class qa extends _{constructor({cause:t}){super("Bundler used an invalid aggregator for handling aggregated User Operations.",{cause:t,name:"InvalidAggregatorError"})}}Object.defineProperty(qa,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa96/});class Va extends _{constructor({cause:t,nonce:n}){super("Invalid Smart Account nonce used for User Operation.",{cause:t,metaMessages:[n&&`nonce: ${n}`].filter(Boolean),name:"InvalidAccountNonceError"})}}Object.defineProperty(Va,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa25/});class Wa extends _{constructor({cause:t}){super("Bundler has not set a beneficiary address.",{cause:t,name:"InvalidBeneficiaryError"})}}Object.defineProperty(Wa,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa90/});class As extends _{constructor({cause:t}){super("Invalid fields set on User Operation.",{cause:t,name:"InvalidFieldsError"})}}Object.defineProperty(As,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Ka extends _{constructor({cause:t,paymasterAndData:n}){super("Paymaster properties provided are invalid.",{cause:t,metaMessages:["This could arise when:","- the `paymasterAndData` property is of an incorrect length\n",n&&`paymasterAndData: ${n}`].filter(Boolean),name:"InvalidPaymasterAndDataError"})}}Object.defineProperty(Ka,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa93/});class Kt extends _{constructor({cause:t}){super("Paymaster deposit for the User Operation is too low.",{cause:t,metaMessages:["This could arise when:","- the Paymaster has deposited less than the expected amount via the `deposit` function"].filter(Boolean),name:"PaymasterDepositTooLowError"})}}Object.defineProperty(Kt,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32508});Object.defineProperty(Kt,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa31/});class Za extends _{constructor({cause:t}){super("The `validatePaymasterUserOp` function on the Paymaster reverted.",{cause:t,name:"PaymasterFunctionRevertedError"})}}Object.defineProperty(Za,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa33/});class Ya extends _{constructor({cause:t}){super("The Paymaster contract has not been deployed.",{cause:t,name:"PaymasterNotDeployedError"})}}Object.defineProperty(Ya,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa30/});class ks extends _{constructor({cause:t}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:t,name:"PaymasterRateLimitError"})}}Object.defineProperty(ks,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32504});class Is extends _{constructor({cause:t}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:t,name:"PaymasterStakeTooLowError"})}}Object.defineProperty(Is,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32505});class Ja extends _{constructor({cause:t}){super("Paymaster `postOp` function reverted.",{cause:t,name:"PaymasterPostOpFunctionRevertedError"})}}Object.defineProperty(Ja,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa50/});class Qa extends _{constructor({cause:t,factory:n,factoryData:r,initCode:s}){super("Smart Account has already been deployed.",{cause:t,metaMessages:["Remove the following properties and try again:",n&&"`factory`",r&&"`factoryData`",s&&"`initCode`"].filter(Boolean),name:"SenderAlreadyConstructedError"})}}Object.defineProperty(Qa,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa10/});class Ps extends _{constructor({cause:t}){super("UserOperation rejected because account signature check failed (or paymaster signature, if the paymaster uses its data as signature).",{cause:t,name:"SignatureCheckFailedError"})}}Object.defineProperty(Ps,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32507});class Xa extends _{constructor({cause:t}){super("The `validateUserOp` function on the Smart Account reverted.",{cause:t,name:"SmartAccountFunctionRevertedError"})}}Object.defineProperty(Xa,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa23/});class Ts extends _{constructor({cause:t}){super("UserOperation rejected because account specified unsupported signature aggregator.",{cause:t,name:"UnsupportedSignatureAggregatorError"})}}Object.defineProperty(Ts,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32506});class eo extends _{constructor({cause:t}){super("User Operation expired.",{cause:t,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validateUserOp` on the Smart Account are not satisfied"].filter(Boolean),name:"UserOperationExpiredError"})}}Object.defineProperty(eo,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa22/});class to extends _{constructor({cause:t}){super("Paymaster for User Operation expired.",{cause:t,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validatePaymasterUserOp` on the Paymaster are not satisfied"].filter(Boolean),name:"UserOperationPaymasterExpiredError"})}}Object.defineProperty(to,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa32/});class no extends _{constructor({cause:t}){super("Signature provided for the User Operation is invalid.",{cause:t,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Smart Account"].filter(Boolean),name:"UserOperationSignatureError"})}}Object.defineProperty(no,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa24/});class ro extends _{constructor({cause:t}){super("Signature provided for the User Operation is invalid.",{cause:t,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Paymaster"].filter(
50Boolean),name:"UserOperationPaymasterSignatureError"})}}Object.defineProperty(ro,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa34/});class Os extends _{constructor({cause:t}){super("User Operation rejected by EntryPoint's `simulateValidation` during account creation or validation.",{cause:t,name:"UserOperationRejectedByEntryPointError"})}}Object.defineProperty(Os,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32500});class Cs extends _{constructor({cause:t}){super("User Operation rejected by Paymaster's `validatePaymasterUserOp`.",{cause:t,name:"UserOperationRejectedByPaymasterError"})}}Object.defineProperty(Cs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32501});class Bs extends _{constructor({cause:t}){super("User Operation rejected with op code validation error.",{cause:t,name:"UserOperationRejectedByOpCodeError"})}}Object.defineProperty(Bs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32502});class $s extends _{constructor({cause:t}){super("UserOperation out of time-range: either wallet or paymaster returned a time-range, and it is already expired (or will expire soon).",{cause:t,name:"UserOperationOutOfTimeRangeError"})}}Object.defineProperty($s,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32503});class V1 extends _{constructor({cause:t}){super(`An error occurred while executing user operation: ${t?.shortMessage}`,{cause:t,name:"UnknownBundlerError"})}}class so extends _{constructor({cause:t}){super("User Operation verification gas limit exceeded.",{cause:t,metaMessages:["This could arise when:","- the gas used for verification exceeded the `verificationGasLimit`"].filter(Boolean),name:"VerificationGasLimitExceededError"})}}Object.defineProperty(so,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa40/});class io extends _{constructor({cause:t}){super("User Operation verification gas limit is too low.",{cause:t,metaMessages:["This could arise when:","- the `verificationGasLimit` is too low to verify the User Operation"].filter(Boolean),name:"VerificationGasLimitTooLowError"})}}Object.defineProperty(io,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa41/});class W1 extends _{constructor(t,{callData:n,callGasLimit:r,docsPath:s,factory:i,factoryData:a,initCode:o,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:l,paymaster:d,paymasterAndData:f,paymasterData:p,paymasterPostOpGasLimit:y,paymasterVerificationGasLimit:h,preVerificationGas:m,sender:g,signature:b,verificationGasLimit:w}){const x=$r({callData:n,callGasLimit:r,factory:i,factoryData:a,initCode:o,maxFeePerGas:typeof c<"u"&&`${Ne(c)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${Ne(u)} gwei`,nonce:l,paymaster:d,paymasterAndData:f,paymasterData:p,paymasterPostOpGasLimit:y,paymasterVerificationGasLimit:h,preVerificationGas:m,sender:g,signature:b,verificationGasLimit:w});super(t.shortMessage,{cause:t,docsPath:s,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Request Arguments:",x].filter(Boolean),name:"UserOperationExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class K1 extends _{constructor({hash:t}){super(`User Operation receipt with hash "${t}" could not be found. The User Operation may not have been processed yet.`,{name:"UserOperationReceiptNotFoundError"})}}class Z1 extends _{constructor({hash:t}){super(`User Operation with hash "${t}" could not be found.`,{name:"UserOperationNotFoundError"})}}class Lu extends _{constructor({hash:t}){super(`Timed out while waiting for User Operation with hash "${t}" to be confirmed.`,{name:"WaitForUserOperationReceiptTimeoutError"})}}const Y1=[Tn,As,Kt,ks,Is,Ps,Ts,$s,Os,Cs,Bs];function J1(e,t){const n=(e.details||"").toLowerCase();if(Ra.message.test(n))return new Ra({cause:e});if(ja.message.test(n))return new ja({cause:e});if(La.message.test(n))return new La({cause:e});if(Ua.message.test(n))return new Ua({cause:e});if(Da.message.test(n))return new Da({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(za.message.test(n))return new za({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(Fa.message.test(n))return new Fa({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode,sender:t.sender});if(Ha.message.test(n))return new Ha({cause:e});if(Ga.message.test(n))return new Ga({cause:e});if(Va.message.test(n))return new Va({cause:e,nonce:t.nonce});if(qa.message.test(n))return new qa({cause:e});if(Wa.message.test(n))return new Wa({cause:e});if(Ka.message.test(n))return new Ka({cause:e});if(Kt.message.test(n))return new Kt({cause:e});if(Za.message.test(n))return new Za({cause:e});if(Ya.message.test(n))return new Ya({cause:e});if(Ja.message.test(n))return new Ja({cause:e});if(Xa.message.test(n))return new Xa({cause:e});if(Qa.message.test(n))return new Qa({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(eo.message.test(n))return new eo({cause:e});if(to.message.test(n))return new to({cause:e});if(ro.message.test(n))return new ro({cause:e});if(no.message.test(n))return new no({cause:e});if(so.message.test(n))return new so({cause:e});if(io.message.test(n))return new io({cause:e});const r=e.walk(s=>Y1.some(i=>i.code===s.code));if(r){if(r.code===Tn.code)return new Tn({cause:e,data:r.data,message:r.details});if(r.code===As.code)return new As({cause:e});if(r.code===Kt.code)return new Kt({cause:e});if(r.code===ks.code)return new ks({cause:e});if(r.code===Is.code)return new Is({cause:e});if(r.code===Ps.code)return new Ps({cause:e});if(r.code===Ts.code)return new Ts({cause:e});if(r.code===$s.code)return new $s({cause:e});if(r.code===Os.code)return new Os({cause:e});if(r.code===Cs.code)return new Cs({cause:e});if(r.code===Bs.code)return new Bs({cause:e})}return new V1({cause:e})}function wp(e,{calls:t,docsPath:n,...r}){const s=(()=>{const i=J1(e,r);if(t&&i instanceof Tn){const a=Q1(i),o=t?.filter(c=>c.abi);if(a&&o.length>0)return X1({calls:o,revertData:a})}return i})();return new W1(s,{docsPath:n,...r})}function Q1(e){let t;return e.walk(n=>{const r=n;
50if(typeof r.data=="string"||typeof r.data?.revertData=="string"||!(r instanceof _)&&typeof r.message=="string"){const s=(r.data?.revertData||r.data||r.message).match?.(/(0x[A-Za-z0-9]*)/);if(s)return t=s[1],!0}return!1}),t}function X1(e){const{calls:t,revertData:n}=e,{abi:r,functionName:s,args:i,to:a}=(()=>{const c=t?.filter(l=>!!l.abi);if(c.length===1)return c[0];const u=c.filter(l=>{try{return!!Dl({abi:l.abi,data:n})}catch{return!1}});return u.length===1?u[0]:{abi:[],functionName:c.reduce((l,d)=>`${l?`${l} | `:""}${d.functionName}`,""),args:void 0,to:void 0}})(),o=n==="0x"?new Kl({functionName:s}):new gs({abi:r,data:n,functionName:s});return new Wl(o,{abi:r,args:i,contractAddress:a,functionName:s})}function e2(e){const t={};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),t}function ai(e){const t={};return typeof e.callData<"u"&&(t.callData=e.callData),typeof e.callGasLimit<"u"&&(t.callGasLimit=R(e.callGasLimit)),typeof e.factory<"u"&&(t.factory=e.factory),typeof e.factoryData<"u"&&(t.factoryData=e.factoryData),typeof e.initCode<"u"&&(t.initCode=e.initCode),typeof e.maxFeePerGas<"u"&&(t.maxFeePerGas=R(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(t.maxPriorityFeePerGas=R(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(t.nonce=R(e.nonce)),typeof e.paymaster<"u"&&(t.paymaster=e.paymaster),typeof e.paymasterAndData<"u"&&(t.paymasterAndData=e.paymasterAndData||"0x"),typeof e.paymasterData<"u"&&(t.paymasterData=e.paymasterData),typeof e.paymasterPostOpGasLimit<"u"&&(t.paymasterPostOpGasLimit=R(e.paymasterPostOpGasLimit)),typeof e.paymasterVerificationGasLimit<"u"&&(t.paymasterVerificationGasLimit=R(e.paymasterVerificationGasLimit)),typeof e.preVerificationGas<"u"&&(t.preVerificationGas=R(e.preVerificationGas)),typeof e.sender<"u"&&(t.sender=e.sender),typeof e.signature<"u"&&(t.signature=e.signature),typeof e.verificationGasLimit<"u"&&(t.verificationGasLimit=R(e.verificationGasLimit)),typeof e.authorization<"u"&&(t.eip7702Auth=t2(e.authorization)),t}function t2(e){return{address:e.address,chainId:R(e.chainId),nonce:R(e.nonce),r:e.r?R(BigInt(e.r),{size:32}):le("0x",{size:32}),s:e.s?R(BigInt(e.s),{size:32}):le("0x",{size:32}),yParity:e.yParity?R(e.yParity,{size:1}):le("0x",{size:32})}}async function n2(e,t){const{chainId:n,entryPointAddress:r,context:s,...i}=t,a=ai(i),{paymasterPostOpGasLimit:o,paymasterVerificationGasLimit:c,...u}=await e.request({method:"pm_getPaymasterData",params:[{...a,callGasLimit:a.callGasLimit??"0x0",verificationGasLimit:a.verificationGasLimit??"0x0",preVerificationGas:a.preVerificationGas??"0x0"},r,R(n),s]});return{...u,...o&&{paymasterPostOpGasLimit:de(o)},...c&&{paymasterVerificationGasLimit:de(c)}}}async function r2(e,t){const{chainId:n,entryPointAddress:r,context:s,...i}=t,a=ai(i),{paymasterPostOpGasLimit:o,paymasterVerificationGasLimit:c,...u}=await e.request({method:"pm_getPaymasterStubData",params:[{...a,callGasLimit:a.callGasLimit??"0x0",verificationGasLimit:a.verificationGasLimit??"0x0",preVerificationGas:a.preVerificationGas??"0x0"},r,R(n),s]});return{...u,...o&&{paymasterPostOpGasLimit:de(o)},...c&&{paymasterVerificationGasLimit:de(c)}}}const s2=["factory","fees","gas","paymaster","nonce","signature","authorization"];async function fc(e,t){const n=t,{account:r=e.account,parameters:s=s2,stateOverride:i}=n;if(!r)throw new Xs;const a=xe(r),o=e,c=n.paymaster??o?.paymaster,u=typeof c=="string"?c:void 0,{getPaymasterStubData:l,getPaymasterData:d}=(()=>{if(c===!0)return{getPaymasterStubData:A=>z(o,r2,"getPaymasterStubData")(A),getPaymasterData:A=>z(o,n2,"getPaymasterData")(A)};if(typeof c=="object"){const{getPaymasterStubData:A,getPaymasterData:k}=c;return{getPaymasterStubData:k&&A?A:k,getPaymasterData:k&&A?k:void 0}}return{getPaymasterStubData:void 0,getPaymasterData:void 0}})(),f=n.paymasterContext?n.paymasterContext:o?.paymasterContext;let p={...n,paymaster:u,sender:a.address};const[y,h,m,g,b]=await Promise.all([(async()=>n.calls?a.encodeCalls(n.calls.map(A=>{const k=A;return k.abi?{data:he(k),to:k.to,value:k.value}:k})):n.callData)(),(async()=>
50{if(!s.includes("factory"))return;if(n.initCode)return{initCode:n.initCode};if(n.factory&&n.factoryData)return{factory:n.factory,factoryData:n.factoryData};const{factory:A,factoryData:k}=await a.getFactoryArgs();return a.entryPoint.version==="0.6"?{initCode:A&&k?ve([A,k]):void 0}:{factory:A,factoryData:k}})(),(async()=>{if(s.includes("fees")){if(typeof n.maxFeePerGas=="bigint"&&typeof n.maxPriorityFeePerGas=="bigint")return p;if(o?.userOperation?.estimateFeesPerGas){const A=await o.userOperation.estimateFeesPerGas({account:a,bundlerClient:o,userOperation:p});return{...p,...A}}try{const A=o.client??e,k=await z(A,rf,"estimateFeesPerGas")({chain:A.chain,type:"eip1559"});return{maxFeePerGas:typeof n.maxFeePerGas=="bigint"?n.maxFeePerGas:BigInt(2n*k.maxFeePerGas),maxPriorityFeePerGas:typeof n.maxPriorityFeePerGas=="bigint"?n.maxPriorityFeePerGas:BigInt(2n*k.maxPriorityFeePerGas)}}catch{return}}})(),(async()=>{if(s.includes("nonce"))return typeof n.nonce=="bigint"?n.nonce:a.getNonce()})(),(async()=>{if(s.includes("authorization")){if(typeof n.authorization=="object")return n.authorization;if(a.authorization&&!await a.isDeployed())return{...await S1(a.client,a.authorization),r:"0xfffffffffffffffffffffffffffffff000000000000000000000000000000000",s:"0x7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",yParity:1}}})()]);typeof y<"u"&&(p.callData=y),typeof h<"u"&&(p={...p,...h}),typeof m<"u"&&(p={...p,...m}),typeof g<"u"&&(p.nonce=g),typeof b<"u"&&(p.authorization=b),s.includes("signature")&&(typeof n.signature<"u"?p.signature=n.signature:p.signature=await a.getStubSignature(p)),a.entryPoint.version==="0.6"&&!p.initCode&&(p.initCode="0x");let w;async function x(){return w||(e.chain?e.chain.id:(w=await z(e,Mr,"getChainId")({}),w))}let S=!1;if(s.includes("paymaster")&&l&&!u&&!n.paymasterAndData){const{isFinal:A=!1,sponsor:k,...$}=await l({chainId:await x(),entryPointAddress:a.entryPoint.address,context:f,...p});S=A,p={...p,...$}}if(a.entryPoint.version==="0.6"&&!p.paymasterAndData&&(p.paymasterAndData="0x"),s.includes("gas")){if(a.userOperation?.estimateGas){const A=await a.userOperation.estimateGas(p);p={...p,...A}}if(typeof p.callGasLimit>"u"||typeof p.preVerificationGas>"u"||typeof p.verificationGasLimit>"u"||p.paymaster&&typeof p.paymasterPostOpGasLimit>"u"||p.paymaster&&typeof p.paymasterVerificationGasLimit>"u"){const A=await z(o,vp,"estimateUserOperationGas")({account:a,callGasLimit:0n,preVerificationGas:0n,verificationGasLimit:0n,stateOverride:i,...p.paymaster?{paymasterPostOpGasLimit:0n,paymasterVerificationGasLimit:0n}:{},...p});p={...p,callGasLimit:p.callGasLimit??A.callGasLimit,preVerificationGas:p.preVerificationGas??A.preVerificationGas,verificationGasLimit:p.verificationGasLimit??A.verificationGasLimit,paymasterPostOpGasLimit:p.paymasterPostOpGasLimit??A.paymasterPostOpGasLimit,paymasterVerificationGasLimit:p.paymasterVerificationGasLimit??A.paymasterVerificationGasLimit}}}if(s.includes("paymaster")&&d&&!u&&!n.paymasterAndData&&!S){const A=await d({chainId:await x(),entryPointAddress:a.entryPoint.address,context:f,...p});p={...p,...A}}return delete p.calls,delete p.parameters,delete p.paymasterContext,typeof p.paymaster!="string"&&delete p.paymaster,p}async function vp(e,t){const{account:n=e.account,entryPointAddress:r,stateOverride:s}=t;if(!n&&!t.sender)throw new Xs;const i=n?xe(n):void 0,a=Zs(s),o=i?await z(e,fc,"prepareUserOperation")({...t,parameters:["authorization","factory","nonce","paymaster","signature"]}):t;try{const c=[ai(o),r??i?.entryPoint?.address],u=await e.request({method:"eth_estimateUserOperationGas",params:a?[...c,a]:[...c]});return e2(u)}catch(c){const u=t.calls;throw wp(c,{...o,...u?{calls:u}:{}})}}function i2(e){return e.request({method:"eth_supportedEntryPoints"})}function a2(e){const t={...e};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.maxFeePerGas&&(t.maxFeePerGas=BigInt(e.maxFeePerGas)),e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=BigInt(e.maxPriorityFeePerGas)),e.nonce&&(t.nonce=BigInt(e.nonce)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),t}async function o2(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationByHash",params:[t]},{dedupe:!0});if(!n)throw new Z1({hash:t});const{blockHash:r,blockNumber:s,entryPoint:i,transactionHash:a,userOperation:o}=n;return{blockHash:r,blockNumber:BigInt(s),entryPoint:i,transactionHash:a,userOperation:a2(o)}}function c2(e){const t={...e};return e.actualGasCost&&(t.actualGasCost=BigInt(e.actualGasCost)),e.actualGasUsed&&(t.actualGasUsed=BigInt(e.actualGasUsed)),e.logs&&(t.logs=e.logs.map(n=>
50at(n))),e.receipt&&(t.receipt=kf(t.receipt)),t}async function xp(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationReceipt",params:[t]},{dedupe:!0});if(!n)throw new K1({hash:t});return c2(n)}async function u2(e,t){const{account:n=e.account,entryPointAddress:r}=t;if(!n&&!t.sender)throw new Xs;const s=n?xe(n):void 0,i=s?await z(e,fc,"prepareUserOperation")(t):t,a=t.signature||await s?.signUserOperation?.(i),o=ai({...i,signature:a});try{return await e.request({method:"eth_sendUserOperation",params:[o,r??s?.entryPoint?.address]},{retryCount:0})}catch(c){const u=t.calls;throw wp(c,{...i,...u?{calls:u}:{},signature:a})}}function d2(e,t){const{hash:n,pollingInterval:r=e.pollingInterval,retryCount:s,timeout:i=12e4}=t;let a=0;const o=fe(["waitForUserOperationReceipt",e.uid,n]);return new Promise((c,u)=>{const l=ct(o,{resolve:c,reject:u},d=>{const f=y=>{p(),y(),l()},p=dn(async()=>{s&&a>=s&&f(()=>d.reject(new Lu({hash:n})));try{const y=await z(e,xp,"getUserOperationReceipt")({hash:n});f(()=>d.resolve(y))}catch(y){const h=y;h.name!=="UserOperationReceiptNotFoundError"&&f(()=>d.reject(h))}a++},{emitOnBegin:!0,interval:r});return i&&setTimeout(()=>f(()=>d.reject(new Lu({hash:n}))),i),p})})}function l2(e){return{estimateUserOperationGas:t=>vp(e,t),getChainId:()=>Mr(e),getSupportedEntryPoints:()=>i2(e),getUserOperation:t=>o2(e,t),getUserOperationReceipt:t=>xp(e,t),prepareUserOperation:t=>fc(e,t),sendUserOperation:t=>u2(e,t),waitForUserOperationReceipt:t=>d2(e,t)}}function f2(e){const{client:t,key:n="bundler",name:r="Bundler Client",paymaster:s,paymasterContext:i,transport:a,userOperation:o}=e;return Object.assign(Tf({...e,chain:e.chain??t?.chain,key:n,name:r,transport:a,type:"bundlerClient"}),{client:t,paymaster:s,paymasterContext:i,userOperation:o}).extend(l2)}const p2="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",Ep=lo(()=>({}));function Uu(e){e.forEach(t=>{var n,r,s,i,a,o,c,u;if(!t.rpcUrl)return;const l=vw({id:t.id,rpcUrls:{default:{http:[t.rpcUrl]}},name:(r=(n=t.nativeCurrency)===null||n===void 0?void 0:n.name)!==null&&r!==void 0?r:"",nativeCurrency:{name:(i=(s=t.nativeCurrency)===null||s===void 0?void 0:s.name)!==null&&i!==void 0?i:"",symbol:(o=(a=t.nativeCurrency)===null||a===void 0?void 0:a.symbol)!==null&&o!==void 0?o:"",decimals:(u=(c=t.nativeCurrency)===null||c===void 0?void 0:c.decimal)!==null&&u!==void 0?u:18}}),d=_1({chain:l,transport:Au(t.rpcUrl)}),f=f2({client:d,transport:Au(t.rpcUrl)});Ep.setState({[t.id]:{client:d,bundlerClient:f}})})}function _p(e){var t;return(t=Ep.getState()[e])===null||t===void 0?void 0:t.client}function Be(e,t,n){if(e==null)throw t??j.rpc.invalidParams({message:"value must be present",data:e})}function Bt(e,t){if(!Array.isArray(e))throw j.rpc.invalidParams({message:t??"value must be an array",data:e})}function Yr(e){if(typeof e!="object"||e===null)throw j.rpc.internal("sub account info is not an object");if(!("address"in e))throw j.rpc.internal("sub account is invalid");if("address"in e&&typeof e.address=="string"&&!be(e.address))throw j.rpc.internal("sub account address is invalid");if("factory"in e&&typeof e.factory=="string"&&!be(e.factory))throw j.rpc.internal("sub account factory address is invalid");if("factoryData"in e&&typeof e.factoryData=="string"&&!we(e.factoryData))throw j.rpc.internal("sub account factory data is invalid")}async function h2(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function m2(e,t){return crypto.subtle.deriveKey({name:"ECDH",public:t},e,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function y2(e,t){const n=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:n},e,new TextEncoder().encode(t));return{iv:n,cipherText:r}}async function g2(e,{iv:t,cipherText:n}){const r=await crypto.subtle.decrypt({name:"AES-GCM",iv:t},e,n);return new TextDecoder().decode(r)}function Sp(e){switch(e){case"public":return"spki";case"private":return"pkcs8"}}async function Ap(e,t){const n=Sp(e),r=await crypto.subtle.exportKey(n,t);return vo(new Uint8Array(r))}async function kp(e,t){const n=Sp(e),r=cs(t).buffer;return await crypto.subtle.importKey(n,new Uint8Array(r),{name:"ECDH",namedCurve:"P-256"},!0,e==="private"?["deriveKey"]:[])}async function b2(e,t){const n=JSON.stringify(e,(r,s)=>{if(!(s instanceof Error))return s;const i=s;return Object.assign(Object.assign({},i.code?{code:i.code}:{}),{message:i.message})});return y2(t,n)}async function w2(e,t){return JSON.parse(await g2(t,e))}const v2="0.1.1";function x2(){return v2}
50class ne extends Error{constructor(t,n={}){const r=(()=>{if(n.cause instanceof ne){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause?.message?n.cause.message:n.details})(),s=n.cause instanceof ne&&n.cause.docsPath||n.docsPath,a=`https://oxlib.sh${s??""}`,o=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||s?["",r?`Details: ${r}`:void 0,s?`See: ${a}`:void 0]:[]].filter(c=>typeof c=="string").join(` 51`);super(o,n.cause?{cause:n.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@${x2()}`}),this.cause=n.cause,this.details=r,this.docs=a,this.docsPath=s,this.shortMessage=t}walk(t){return Ip(this,t)}}function Ip(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?Ip(e.cause,t):t?null:e}function Du(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function E2(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function oi(e,...t){if(!E2(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function _2(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Du(e.outputLen),Du(e.blockLen)}function Ns(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 S2(e,t){oi(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}const mn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Bi(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rt(e,t){return e<<32-t|e>>>t}function A2(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function pc(e){return typeof e=="string"&&(e=A2(e)),oi(e),e}function k2(...e){let t=0;for(let r=0;r<e.length;r++){const s=e[r];oi(s),t+=s.length}const n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const i=e[r];n.set(i,s),s+=i.length}return n}class Pp{clone(){return this._cloneInto()}}function I2(e){const t=r=>e().update(pc(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function P2(e=32){if(mn&&typeof mn.getRandomValues=="function")return mn.getRandomValues(new Uint8Array(e));if(mn&&typeof mn.randomBytes=="function")return mn.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function T2(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),a=Number(n>>s&i),o=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,o,r)}function O2(e,t,n){return e&t^~e&n}function C2(e,t,n){return e&t^e&n^t&n}class B2 extends Pp{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Bi(this.buffer)}update(t){Ns(this);const{view:n,buffer:r,blockLen:s}=this;t=pc(t);const i=t.length;for(let a=0;a<i;){const o=Math.min(s-this.pos,i-a);if(o===s){const c=Bi(t);for(;s<=i-a;a+=s)this.process(c,a);continue}r.set(t.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ns(this),S2(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:i}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>s-a&&(this.process(r,0),a=0);for(let d=a;d<s;d++)n[d]=0;T2(r,s-8,BigInt(this.length*8),i),this.process(r,0);const o=Bi(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)o.setUint32(4*d,l[d],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:i,destroyed:a,pos:o}=this;return t.length=s,t.pos=o,t.finished=i,t.destroyed=a,s%n&&t.buffer.set(r),t}}
51const $2=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ot=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ct=new Uint32Array(64);class N2 extends B2{constructor(){super(64,32,8,!1),this.A=Ot[0]|0,this.B=Ot[1]|0,this.C=Ot[2]|0,this.D=Ot[3]|0,this.E=Ot[4]|0,this.F=Ot[5]|0,this.G=Ot[6]|0,this.H=Ot[7]|0}get(){const{A:t,B:n,C:r,D:s,E:i,F:a,G:o,H:c}=this;return[t,n,r,s,i,a,o,c]}set(t,n,r,s,i,a,o,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=c|0}process(t,n){for(let d=0;d<16;d++,n+=4)Ct[d]=t.getUint32(n,!1);for(let d=16;d<64;d++){const f=Ct[d-15],p=Ct[d-2],y=rt(f,7)^rt(f,18)^f>>>3,h=rt(p,17)^rt(p,19)^p>>>10;Ct[d]=h+Ct[d-7]+y+Ct[d-16]|0}let{A:r,B:s,C:i,D:a,E:o,F:c,G:u,H:l}=this;for(let d=0;d<64;d++){const f=rt(o,6)^rt(o,11)^rt(o,25),p=l+f+O2(o,c,u)+$2[d]+Ct[d]|0,h=(rt(r,2)^rt(r,13)^rt(r,22))+C2(r,s,i)|0;l=u,u=c,c=o,o=a+p|0,a=i,i=s,s=r,r=p+h|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,i,a,o,c,u,l)}roundClean(){Ct.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Tp=I2(()=>new N2);const ci=BigInt(0),ui=BigInt(1),M2=BigInt(2);function an(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ur(e){if(!an(e))throw new Error("Uint8Array expected")}function On(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}const R2=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Cn(e){Ur(e);let t="";for(let n=0;n<e.length;n++)t+=R2[e[n]];return t}function wn(e){const t=e.toString(16);return t.length&1?"0"+t:t}function hc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ci:BigInt("0x"+e)}const pt={_0:48,_9:57,A:65,F:70,a:97,f:102};function zu(e){if(e>=pt._0&&e<=pt._9)return e-pt._0;if(e>=pt.A&&e<=pt.F)return e-(pt.A-10);if(e>=pt.a&&e<=pt.f)return e-(pt.a-10)}function Bn(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof 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 s=0,i=0;s<n;s++,i+=2){const a=zu(e.charCodeAt(i)),o=zu(e.charCodeAt(i+1));if(a===void 0||o===void 0){const c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}r[s]=a*16+o}return r}function Zt(e){return hc(Cn(e))}function mc(e){return Ur(e),hc(Cn(Uint8Array.from(e).reverse()))}function $n(e,t){return Bn(e.toString(16).padStart(t*2,"0"))}function yc(e,t){return $n(e,t).reverse()}function j2(e){return Bn(wn(e))}function We(e,t,n){let r;if(typeof t=="string")try{r=Bn(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(an(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return r}function Tr(...e){let t=0;for(let r=0;r<e.length;r++){const s=e[r];Ur(s),t+=s.length}const n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const i=e[r];n.set(i,s),s+=i.length}return n}function L2(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function U2(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}const $i=e=>typeof e=="bigint"&&ci<=e;function di(e,t,n){return $i(e)&&$i(t)&&$i(n)&&t<=e&&e<n}function Yt(e,t,n,r){if(!di(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Op(e){let t;for(t=0;e>ci;e>>=ui,t+=1);return t}function D2(e,t){return e>>BigInt(t)&ui}function z2(e,t,n){return e|(n?ui:ci)<<BigInt(t)}const gc=e=>(M2<<BigInt(e-1))-ui,Ni=e=>new Uint8Array(e),Fu=e=>Uint8Array.from(e);
51function Cp(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Ni(e),s=Ni(e),i=0;const a=()=>{r.fill(1),s.fill(0),i=0},o=(...d)=>n(s,r,...d),c=(d=Ni())=>{s=o(Fu([0]),d),r=o(),d.length!==0&&(s=o(Fu([1]),d),r=o())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const f=[];for(;d<t;){r=o();const p=r.slice();f.push(p),d+=r.length}return Tr(...f)};return(d,f)=>{a(),c(d);let p;for(;!(p=f(u()));)c();return a(),p}}const F2={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||an(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function Dr(e,t,n={}){const r=(s,i,a)=>{const o=F2[i];if(typeof o!="function")throw new Error("invalid validator function");const c=e[s];if(!(a&&c===void 0)&&!o(c,e))throw new Error("param "+String(s)+" is invalid. Expected "+i+", got "+c)};for(const[s,i]of Object.entries(t))r(s,i,!1);for(const[s,i]of Object.entries(n))r(s,i,!0);return e}const H2=()=>{throw new Error("not implemented")};function ao(e){const t=new WeakMap;return(n,...r)=>{const s=t.get(n);if(s!==void 0)return s;const i=e(n,...r);return t.set(n,i),i}}const G2=Object.freeze(Object.defineProperty({__proto__:null,aInRange:Yt,abool:On,abytes:Ur,bitGet:D2,bitLen:Op,bitMask:gc,bitSet:z2,bytesToHex:Cn,bytesToNumberBE:Zt,bytesToNumberLE:mc,concatBytes:Tr,createHmacDrbg:Cp,ensureBytes:We,equalBytes:L2,hexToBytes:Bn,hexToNumber:hc,inRange:di,isBytes:an,memoized:ao,notImplemented:H2,numberToBytesBE:$n,numberToBytesLE:yc,numberToHexUnpadded:wn,numberToVarBytesBE:j2,utf8ToBytes:U2,validateObject:Dr},Symbol.toStringTag,{value:"Module"})),q2="#__bigint";function li(e,t,n){return JSON.stringify(e,(r,s)=>typeof s=="bigint"?s.toString()+q2:s,n)}function V2(e,t){if(Mn(e)>t)throw new cx({givenSize:Mn(e),maxSize:t})}function W2(e,t){if(typeof t=="number"&&t>0&&t>Mn(e)-1)throw new Dp({offset:t,position:"start",size:Mn(e)})}function K2(e,t,n){if(typeof t=="number"&&typeof n=="number"&&Mn(e)!==n-t)throw new Dp({offset:n,position:"end",size:Mn(e)})}const ht={zero:48,nine:57,A:65,F:70,a:97,f:102};function Hu(e){if(e>=ht.zero&&e<=ht.nine)return e-ht.zero;if(e>=ht.A&&e<=ht.F)return e-(ht.A-10);if(e>=ht.a&&e<=ht.f)return e-(ht.a-10)}function bc(e,t){if(Rt(e)>t)throw new sx({givenSize:Rt(e),maxSize:t})}function Z2(e,t){if(typeof t=="number"&&t>0&&t>Rt(e)-1)throw new Rp({offset:t,position:"start",size:Rt(e)})}function Y2(e,t,n){if(typeof t=="number"&&typeof n=="number"&&Rt(e)!==n-t)throw new Rp({offset:n,position:"end",size:Rt(e)})}function Bp(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const s=e.replace("0x","");if(s.length>r*2)throw new ix({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s[n==="right"?"padEnd":"padStart"](r*2,"0")}`}const J2=new TextEncoder,Q2=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function X2(e,t={}){const{strict:n=!1}=t;if(!e)throw new Gu(e);if(typeof e!="string")throw new Gu(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new qu(e);if(!e.startsWith("0x"))throw new qu(e)}function fi(...e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function $p(e){return e instanceof Uint8Array?Nn(e):Array.isArray(e)?Nn(new Uint8Array(e)):e}function Nn(e,t={}){let n="";for(let s=0;s<e.length;s++)n+=Q2[e[s]];const r=`0x${n}`;return typeof t.size=="number"?(bc(r,t.size),Mp(r,t.size)):r}function Mt(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<a){const u=typeof e=="bigint"?"n":"";throw new rx({max:i?`${i}${u}`:void 0,min:`${a}${u}`,signed:n,size:r,value:`${e}${u}`})}const c=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?ex(c,r):c}function Np(e,t={}){return Nn(J2.encode(e),t)}function ex(e,t){return Bp(e,{dir:"left",size:t})}function Mp(e,t){return Bp(e,{dir:"right",size:t})}function Fe(e,t,n,r={}){const{strict:s}=r;Z2(e,t);const i=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return s&&Y2(i,t,n),i}function Rt(e){return Math.ceil((e.length-2)/2)}function tx(e,t={}){const{signed:n}=t;t.size&&bc(e,t.size);const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,i=(1n<<BigInt(s)*8n)-1n,a=i>>1n;return r<=a?r:r-i-1n}function nx(e,t={}){const{strict:n=!1}=t;try{return X2(e,{strict:n}),!0}catch{return!1}}class rx extends ne{constructor({max:t,min:n,signed:r,size:s,value:i}
51){super(`Number \`${i}\` is not in safe${s?` ${s*8}-bit`:""}${r?" signed":" unsigned"} integer range ${t?`(\`${n}\` to \`${t}\`)`:`(above \`${n}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class Gu extends ne{constructor(t){super(`Value \`${typeof t=="object"?li(t):t}\` of type \`${typeof t}\` 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 qu extends ne{constructor(t){super(`Value \`${t}\` 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"})}}let sx=class extends ne{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}},Rp=class extends ne{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}};class ix extends ne{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function ax(e){if(!(e instanceof Uint8Array)){if(!e)throw new Jr(e);if(typeof e!="object")throw new Jr(e);if(!("BYTES_PER_ELEMENT"in e))throw new Jr(e);if(e.BYTES_PER_ELEMENT!==1||e.constructor.name!=="Uint8Array")throw new Jr(e)}}function jp(e){return e instanceof Uint8Array?e:typeof e=="string"?Up(e):Lp(e)}function Lp(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function Up(e,t={}){const{size:n}=t;let r=e;n&&(bc(e,n),r=Mp(e,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,a=new Uint8Array(i);for(let o=0,c=0;o<i;o++){const u=Hu(s.charCodeAt(c++)),l=Hu(s.charCodeAt(c++));if(u===void 0||l===void 0)throw new ne(`Invalid byte sequence ("${s[c-2]}${s[c-1]}" in "${s}").`);a[o]=u*16+l}return a}function Mn(e){return e.length}function Vu(e,t,n,r={}){const{strict:s}=r;W2(e,t);const i=e.slice(t,n);return s&&K2(i,t,n),i}function Wu(e,t={}){const{size:n}=t;typeof n<"u"&&V2(e,n);const r=Nn(e,t);return tx(r,t)}function ox(e){try{return ax(e),!0}catch{return!1}}class Jr extends ne{constructor(t){super(`Value \`${typeof t=="object"?li(t):t}\` of type \`${typeof t}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class cx extends ne{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Dp extends ne{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}}function zp(e,t={}){const{as:n=typeof e=="string"?"Hex":"Bytes"}=t,r=Tp(jp(e));return n==="Bytes"?r:Nn(r)}function Fp(e,t={}){const{compressed:n}=t,{prefix:r,x:s,y:i}=e;if(n===!1||typeof s=="bigint"&&typeof i=="bigint"){if(r!==4)throw new Ku({prefix:r,cause:new px});return}if(n===!0||typeof s=="bigint"&&typeof i>"u"){if(r!==3&&r!==2)throw new Ku({prefix:r,cause:new fx});return}throw new lx({publicKey:e})}function ux(e){const t=(()=>{if(nx(e))return Hp(e);if(ox(e))return dx(e);const{prefix:n,x:r,y:s}=e;return typeof r=="bigint"&&typeof s=="bigint"?{prefix:n??4,x:r,y:s}:{prefix:n,x:r}})();return Fp(t),t}function dx(e){return Hp(Nn(e))}function Hp(e){if(e.length!==132&&e.length!==130&&e.length!==68)throw new hx({publicKey:e});if(e.length===130){const r=BigInt(Fe(e,0,32)),s=BigInt(Fe(e,32,64));return{prefix:4,x:r,y:s}}if(e.length===132){const r=Number(Fe(e,0,1)),s=BigInt(Fe(e,1,33)),i=BigInt(Fe(e,33,65));return{prefix:r,x:s,y:i}}const t=Number(Fe(e,0,1)),n=BigInt(Fe(e,1,33));return{prefix:t,x:n}}function wc(e,t={}){Fp(e);const{prefix:n,x:r,y:s}=e,{includePrefix:i=!0}=t;return fi(i?Mt(n,{size:1}):"0x",Mt(r,{size:32}),typeof s=="bigint"?Mt(s,{size:32}):"0x")}class lx extends ne{constructor({publicKey:t}){super(`Value \`${li(t)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class Ku extends ne{constructor({prefix:t,cause:n}){super(`Prefix "${t}
51" is invalid.`,{cause:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class fx extends ne{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class px extends ne{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let hx=class extends ne{constructor({publicKey:t}){super(`Value \`${t}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${Rt($p(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const Zu=2n**256n-1n;class Gp extends Pp{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,_2(t);const r=pc(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?t.create().update(r).digest():r);for(let a=0;a<i.length;a++)i[a]^=54;this.iHash.update(i),this.oHash=t.create();for(let a=0;a<i.length;a++)i[a]^=106;this.oHash.update(i),i.fill(0)}update(t){return Ns(this),this.iHash.update(t),this}digestInto(t){Ns(this),oi(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:s,destroyed:i,blockLen:a,outputLen:o}=this;return t=t,t.finished=s,t.destroyed=i,t.blockLen=a,t.outputLen=o,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const qp=(e,t,n)=>new Gp(e,t).update(n).digest();qp.create=(e,t)=>new Gp(e,t);const ge=BigInt(0),ae=BigInt(1),Ht=BigInt(2),mx=BigInt(3),oo=BigInt(4),Yu=BigInt(5),Ju=BigInt(8);function He(e,t){const n=e%t;return n>=ge?n:t+n}function yx(e,t,n){if(t<ge)throw new Error("invalid exponent, negatives unsupported");if(n<=ge)throw new Error("invalid modulus");if(n===ae)return ge;let r=ae;for(;t>ge;)t&ae&&(r=r*e%n),e=e*e%n,t>>=ae;return r}function co(e,t){if(e===ge)throw new Error("invert: expected non-zero number");if(t<=ge)throw new Error("invert: expected positive modulus, got "+t);let n=He(e,t),r=t,s=ge,i=ae;for(;n!==ge;){const o=r/n,c=r%n,u=s-i*o;r=n,n=c,s=i,i=u}if(r!==ae)throw new Error("invert: does not exist");return He(s,t)}function gx(e){const t=(e-ae)/Ht;let n,r,s;for(n=e-ae,r=0;n%Ht===ge;n/=Ht,r++);for(s=Ht;s<e&&yx(s,t,e)!==e-ae;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const a=(e+ae)/oo;return function(c,u){const l=c.pow(u,a);if(!c.eql(c.sqr(l),u))throw new Error("Cannot find square root");return l}}const i=(n+ae)/Ht;return function(o,c){if(o.pow(c,t)===o.neg(o.ONE))throw new Error("Cannot find square root");let u=r,l=o.pow(o.mul(o.ONE,s),n),d=o.pow(c,i),f=o.pow(c,n);for(;!o.eql(f,o.ONE);){if(o.eql(f,o.ZERO))return o.ZERO;let p=1;for(let h=o.sqr(f);p<u&&!o.eql(h,o.ONE);p++)h=o.sqr(h);const y=o.pow(l,ae<<BigInt(u-p-1));l=o.sqr(y),d=o.mul(d,y),f=o.mul(f,l),u=p}return d}}function bx(e){if(e%oo===mx){const t=(e+ae)/oo;return function(r,s){const i=r.pow(s,t);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(e%Ju===Yu){const t=(e-Yu)/Ju;return function(r,s){const i=r.mul(s,Ht),a=r.pow(i,t),o=r.mul(s,a),c=r.mul(r.mul(o,Ht),a),u=r.mul(o,r.sub(c,r.ONE));if(!r.eql(r.sqr(u),s))throw new Error("Cannot find square root");return u}}return gx(e)}const wx=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function vx(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=wx.reduce((r,s)=>(r[s]="function",r),t);return Dr(e,n)}
51function xx(e,t,n){if(n<ge)throw new Error("invalid exponent, negatives unsupported");if(n===ge)return e.ONE;if(n===ae)return t;let r=e.ONE,s=t;for(;n>ge;)n&ae&&(r=e.mul(r,s)),s=e.sqr(s),n>>=ae;return r}function Ex(e,t){const n=new Array(t.length),r=t.reduce((i,a,o)=>e.is0(a)?i:(n[o]=i,e.mul(i,a)),e.ONE),s=e.inv(r);return t.reduceRight((i,a,o)=>e.is0(a)?i:(n[o]=e.mul(i,n[o]),e.mul(i,a)),s),n}function Vp(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Wp(e,t,n=!1,r={}){if(e<=ge)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:s,nByteLength:i}=Vp(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const o=Object.freeze({ORDER:e,isLE:n,BITS:s,BYTES:i,MASK:gc(s),ZERO:ge,ONE:ae,create:c=>He(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ge<=c&&c<e},is0:c=>c===ge,isOdd:c=>(c&ae)===ae,neg:c=>He(-c,e),eql:(c,u)=>c===u,sqr:c=>He(c*c,e),add:(c,u)=>He(c+u,e),sub:(c,u)=>He(c-u,e),mul:(c,u)=>He(c*u,e),pow:(c,u)=>xx(o,c,u),div:(c,u)=>He(c*co(u,e),e),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>co(c,e),sqrt:r.sqrt||(c=>(a||(a=bx(e)),a(o,c))),invertBatch:c=>Ex(o,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>n?yc(c,i):$n(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return n?mc(c):Zt(c)}});return Object.freeze(o)}function Kp(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Zp(e){const t=Kp(e);return t+Math.ceil(t/2)}function _x(e,t,n=!1){const r=e.length,s=Kp(t),i=Zp(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const a=n?mc(e):Zt(e),o=He(a,t-ae)+ae;return n?yc(o,s):$n(o,s)}const Qu=BigInt(0),Qr=BigInt(1);function Mi(e,t){const n=t.negate();return e?n:t}function Yp(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ri(e,t){Yp(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1);return{windows:n,windowSize:r}}function Sx(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function Ax(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const ji=new WeakMap,Jp=new WeakMap;function Li(e){return Jp.get(e)||1}function kx(e,t){return{constTimeNegate:Mi,hasPrecomputes(n){return Li(n)!==1},unsafeLadder(n,r,s=e.ZERO){let i=n;for(;r>Qu;)r&Qr&&(s=s.add(i)),i=i.double(),r>>=Qr;return s},precomputeWindow(n,r){const{windows:s,windowSize:i}=Ri(r,t),a=[];let o=n,c=o;for(let u=0;u<s;u++){c=o,a.push(c);for(let l=1;l<i;l++)c=c.add(o),a.push(c);o=c.double()}return a},wNAF(n,r,s){const{windows:i,windowSize:a}=Ri(n,t);let o=e.ZERO,c=e.BASE;const u=BigInt(2**n-1),l=2**n,d=BigInt(n);for(let f=0;f<i;f++){const p=f*a;let y=Number(s&u);s>>=d,y>a&&(y-=l,s+=Qr);const h=p,m=p+Math.abs(y)-1,g=f%2!==0,b=y<0;y===0?c=c.add(Mi(g,r[h])):o=o.add(Mi(b,r[m]))}return{p:o,f:c}},wNAFUnsafe(n,r,s,i=e.ZERO){const{windows:a,windowSize:o}=Ri(n,t),c=BigInt(2**n-1),u=2**n,l=BigInt(n);for(let d=0;d<a;d++){const f=d*o;if(s===Qu)break;let p=Number(s&c);if(s>>=l,p>o&&(p-=u,s+=Qr),p===0)continue;let y=r[f+Math.abs(p)-1];p<0&&(y=y.negate()),i=i.add(y)}return i},getPrecomputes(n,r,s){let i=ji.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&ji.set(r,s(i))),i},wNAFCached(n,r,s){const i=Li(n);return this.wNAF(i,this.getPrecomputes(i,n,s),r)},wNAFCachedUnsafe(n,r,s,i){const a=Li(n);return a===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(a,this.getPrecomputes(a,n,s),r,i)},setWindowSize(n,r){Yp(r,t),Jp.set(n,r),ji.delete(n)}}}function Ix(e,t,n,r){if(Sx(n,e),Ax(r,t),n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,i=Op(BigInt(n.length)),a=i>12?i-3:i>4?i-2:i?2:1,o=(1<<a)-1,c=new Array(o+1).fill(s),u=Math.floor((t.BITS-1)/a)*a;let l=s;for(let d=u;d>=0;d-=a){c.fill(s);for(let p=0;p<r.length;p++){const y=r[p],h=Number(y>>BigInt(d)&BigInt(o));c[h]=c[h].add(n[p])}let f=s;for(let p=c.length-1,y=s;p>0;p--)y=y.add(c[p]),f=f.add(y);if(l=l.add(f),d!==0)for(let p=0;p<a;p++)l=l.double()}return l}function Qp(e){return vx(e.Fp),Dr(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Vp(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function Xu(e){e.lowS!==void 0&&On("lowS",e.lowS),e.prehash!==void 0&&On("prehash",e.prehash)}function Px(e){const t=Qp(e);Dr(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});
51const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:Tx,hexToBytes:Ox}=G2;class Cx extends Error{constructor(t=""){super(t)}}const gt={Err:Cx,_tlv:{encode:(e,t)=>{const{Err:n}=gt;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,s=wn(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?wn(s.length/2|128):"";return wn(e)+i+s+t},decode(e,t){const{Err:n}=gt;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[r++],i=!!(s&128);let a=0;if(!i)a=s;else{const c=s&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const u=t.subarray(r,r+c);if(u.length!==c)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const l of u)a=a<<8|l;if(r+=c,a<128)throw new n("tlv.decode(long): not minimal encoding")}const o=t.subarray(r,r+a);if(o.length!==a)throw new n("tlv.decode: wrong value length");return{v:o,l:t.subarray(r+a)}}},_int:{encode(e){const{Err:t}=gt;if(e<wt)throw new t("integer: negative integers are not allowed");let n=wn(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=gt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Tx(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=gt,s=typeof e=="string"?Ox(e):e;Ur(s);const{v:i,l:a}=r.decode(48,s);if(a.length)throw new t("invalid signature: left bytes after parsing");const{v:o,l:c}=r.decode(2,i),{v:u,l}=r.decode(2,c);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(o),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=gt,r=t.encode(2,n.encode(e.r)),s=t.encode(2,n.encode(e.s)),i=r+s;return t.encode(48,i)}},wt=BigInt(0),me=BigInt(1);BigInt(2);const ed=BigInt(3);BigInt(4);function Bx(e){const t=Px(e),{Fp:n}=t,r=Wp(t.n,t.nBitLength),s=t.toBytes||((h,m,g)=>{const b=m.toAffine();return Tr(Uint8Array.from([4]),n.toBytes(b.x),n.toBytes(b.y))}),i=t.fromBytes||(h=>{const m=h.subarray(1),g=n.fromBytes(m.subarray(0,n.BYTES)),b=n.fromBytes(m.subarray(n.BYTES,2*n.BYTES));return{x:g,y:b}});function a(h){const{a:m,b:g}=t,b=n.sqr(h),w=n.mul(b,h);return n.add(n.add(w,n.mul(h,m)),g)}if(!n.eql(n.sqr(t.Gy),a(t.Gx)))throw new Error("bad generator point: equation left != right");function o(h){return di(h,me,t.n)}function c(h){const{allowedPrivateKeyLengths:m,nByteLength:g,wrapPrivateKey:b,n:w}=t;if(m&&typeof h!="bigint"){if(an(h)&&(h=Cn(h)),typeof h!="string"||!m.includes(h.length))throw new Error("invalid private key");h=h.padStart(g*2,"0")}let x;try{x=typeof h=="bigint"?h:Zt(We("private key",h,g))}catch{throw new Error("invalid private key, expected hex or "+g+" bytes, got "+typeof h)}return b&&(x=He(x,w)),Yt("private key",x,me,w),x}function u(h){if(!(h instanceof f))throw new Error("ProjectivePoint expected")}const l=ao((h,m)=>{const{px:g,py:b,pz:w}=h;if(n.eql(w,n.ONE))return{x:g,y:b};const x=h.is0();m==null&&(m=x?n.ONE:n.inv(w));const S=n.mul(g,m),A=n.mul(b,m),k=n.mul(w,m);if(x)return{x:n.ZERO,y:n.ZERO};if(!n.eql(k,n.ONE))throw new Error("invZ was invalid");return{x:S,y:A}}),d=ao(h=>{if(h.is0()){if(t.allowInfinityPoint&&!n.is0(h.py))return;throw new Error("bad point: ZERO")}const{x:m,y:g}=h.toAffine();if(!n.isValid(m)||!n.isValid(g))throw new Error("bad point: x or y not FE");const b=n.sqr(g),w=a(m);if(!n.eql(b,w))throw new Error("bad point: equation left != right");if(!h.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class f{constructor(m,g,b){if(this.px=m,this.py=g,this.pz=b,m==null||!n.isValid(m))throw new Error("x required");if(g==null||!n.isValid(g))throw new Error("y required");if(b==null||!n.isValid(b))throw new Error("z required");Object.freeze(this)}static fromAffine(m){const{x:g,y:b}=m||{};if(!m||!n.isValid(g)||!n.isValid(b))throw new Error("invalid affine point");if(m instanceof f)throw new Error("projective point not allowed");const w=x=>n.eql(x,n.ZERO);return w(g)&&w(b)?f.ZERO:new f(g,b,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const g=n.invertBatch(m.map(b=>b.pz));return m.map((b,w)=>b.toAffine(g[w])).map(f.fromAffine)}static fromHex(m){const g=f.fromAffine(i(We("pointHex",m)));return g.assertValidity(),g}static fromPrivateKey(m){return f.BASE.multiply(c(m))}static msm(m,g){return Ix(f,r,m,g)}_setWindowSize(m){y.setWindowSize(this,m)}assertValidity(){d(this)}hasEvenY(){const{y:m}=this.toAffine();if(n.isOdd)return!n.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){u(m);const{px:g,py:b,pz:w}=this,{px:x,py:S,pz:A}=m,k=n.eql(n.mul(g,A),n.mul(x,w)),$=n.eql(n.mul(b,A),n.mul(S,w));return k&&$}negate(){return new f(this.px,n.neg(this.py),this.pz)}double(){const{a:m,b:g}=t,b=n.mul(g,ed),{px:w,py:x,pz:S}=this;let A=n.ZERO,k=n.ZERO,$=n.ZERO,v=n.mul(w,w),C=n.mul(x,x),E=n.mul(S,S),P=n.mul(w,x);return P=n.add(P,P),$=n.mul(w,S),$=n.add($,$),A=n.mul(m,$),k=n.mul(b,E),k=n.add(A,k),A=n.sub(C,k),k=n.add(C,k),k=n.mul(A,k),A=n.mul(P,A),$=n.mul(b,$),E=n.mul(m,E),P=n.sub(v,E),P=n.mul(m,P),P=n.add(P,$),$=n.add(v,v),v=n.add($,v),v=n.add(v,E),v=n.mul(v,P),k=n.add(k,v),E=n.mul(x,S),E=n.add(E,E),v=n.mul(E,P),A=n.sub(A,v),$=n.mul(E,C),$=n.add($,$),$=n.add($,$),new f(A,k,$)}add(m){u(m);const{px:g,py:b,pz:w}=this,{px:x,py:S,pz:A}=m;let k=n.ZERO,$=n.ZERO,v=n.ZERO;const C=t.a,E=n.mul(t.b,ed);let P=n.mul(g,x),M=n.mul(b,S),I=n.mul(w,A),T=n.add(g,b),O=n.add(x,S);T=n.mul(T,O),O=n.add(P,M),T=n.sub(T,O),O=n.add(g,w);let N=n.add(x,A);return O=n.mul(O,N),N=n.add(P,I),O=n.sub(O,N),N=n.add(b,w),k=n.add(S,A),N=n.mul(N,k),k=n.add(M,I),N=n.sub(N,k),v=n.mul(C,O),k=n.mul(E,I),v=n.add(k,v),k=n.sub(M,v),v=n.add(M,v),$=n.mul(k,v),M=n.add(P,P),M=n.add(M,P),I=n.mul(C,I),O=n.mul(E,O),M=n.add(M,I),I=n.sub(P,I),I=n.mul(C,I),O=n.add(O,I),P=n.mul(M,O),$=n.add($,P),P=n.mul(N,O),k=n.mul(T,k),k=n.sub(k,P),P=n.mul(T,M),v=n.mul(N,v),v=n.add(v,P),new f(k,$,v)}
51subtract(m){return this.add(m.negate())}is0(){return this.equals(f.ZERO)}wNAF(m){return y.wNAFCached(this,m,f.normalizeZ)}multiplyUnsafe(m){const{endo:g,n:b}=t;Yt("scalar",m,wt,b);const w=f.ZERO;if(m===wt)return w;if(this.is0()||m===me)return this;if(!g||y.hasPrecomputes(this))return y.wNAFCachedUnsafe(this,m,f.normalizeZ);let{k1neg:x,k1:S,k2neg:A,k2:k}=g.splitScalar(m),$=w,v=w,C=this;for(;S>wt||k>wt;)S&me&&($=$.add(C)),k&me&&(v=v.add(C)),C=C.double(),S>>=me,k>>=me;return x&&($=$.negate()),A&&(v=v.negate()),v=new f(n.mul(v.px,g.beta),v.py,v.pz),$.add(v)}multiply(m){const{endo:g,n:b}=t;Yt("scalar",m,me,b);let w,x;if(g){const{k1neg:S,k1:A,k2neg:k,k2:$}=g.splitScalar(m);let{p:v,f:C}=this.wNAF(A),{p:E,f:P}=this.wNAF($);v=y.constTimeNegate(S,v),E=y.constTimeNegate(k,E),E=new f(n.mul(E.px,g.beta),E.py,E.pz),w=v.add(E),x=C.add(P)}else{const{p:S,f:A}=this.wNAF(m);w=S,x=A}return f.normalizeZ([w,x])[0]}multiplyAndAddUnsafe(m,g,b){const w=f.BASE,x=(A,k)=>k===wt||k===me||!A.equals(w)?A.multiplyUnsafe(k):A.multiply(k),S=x(this,g).add(x(m,b));return S.is0()?void 0:S}toAffine(m){return l(this,m)}isTorsionFree(){const{h:m,isTorsionFree:g}=t;if(m===me)return!0;if(g)return g(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:g}=t;return m===me?this:g?g(f,this):this.multiplyUnsafe(t.h)}toRawBytes(m=!0){return On("isCompressed",m),this.assertValidity(),s(f,this,m)}toHex(m=!0){return On("isCompressed",m),Cn(this.toRawBytes(m))}}f.BASE=new f(t.Gx,t.Gy,n.ONE),f.ZERO=new f(n.ZERO,n.ONE,n.ZERO);const p=t.nBitLength,y=kx(f,t.endo?Math.ceil(p/2):p);return{CURVE:t,ProjectivePoint:f,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function $x(e){const t=Qp(e);return Dr(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Nx(e){const t=$x(e),{Fp:n,n:r}=t,s=n.BYTES+1,i=2*n.BYTES+1;function a(I){return He(I,r)}function o(I){return co(I,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:d}=Bx({...t,toBytes(I,T,O){const N=T.toAffine(),B=n.toBytes(N.x),D=Tr;return On("isCompressed",O),O?D(Uint8Array.from([T.hasEvenY()?2:3]),B):D(Uint8Array.from([4]),B,n.toBytes(N.y))},fromBytes(I){const T=I.length,O=I[0],N=I.subarray(1);if(T===s&&(O===2||O===3)){const B=Zt(N);if(!di(B,me,n.ORDER))throw new Error("Point is not on curve");const D=l(B);let F;try{F=n.sqrt(D)}catch(Y){const K=Y instanceof Error?": "+Y.message:"";throw new Error("Point is not on curve"+K)}const U=(F&me)===me;return(O&1)===1!==U&&(F=n.neg(F)),{x:B,y:F}}else if(T===i&&O===4){const B=n.fromBytes(N.subarray(0,n.BYTES)),D=n.fromBytes(N.subarray(n.BYTES,2*n.BYTES));return{x:B,y:D}}else{const B=s,D=i;throw new Error("invalid Point, expected length of "+B+", or uncompressed "+D+", got "+T)}}}),f=I=>Cn($n(I,t.nByteLength));function p(I){const T=r>>me;return I>T}function y(I){return p(I)?a(-I):I}const h=(I,T,O)=>Zt(I.slice(T,O));class m{constructor(T,O,N){this.r=T,this.s=O,this.recovery=N,this.assertValidity()}static fromCompact(T){const O=t.nByteLength;return T=We("compactSignature",T,O*2),new m(h(T,0,O),h(T,O,2*O))}static fromDER(T){const{r:O,s:N}=gt.toSig(We("DER",T));return new m(O,N)}assertValidity(){Yt("r",this.r,me,r),Yt("s",this.s,me,r)}addRecoveryBit(T){return new m(this.r,this.s,T)}recoverPublicKey(T){const{r:O,s:N,recovery:B}=this,D=A(We("msgHash",T));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");const F=B===2||B===3?O+t.n:O;if(F>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const U=(B&1)===0?"02":"03",H=c.fromHex(U+f(F)),Y=o(F),K=a(-D*Y),Z=a(N*Y),te=c.BASE.multiplyAndAddUnsafe(H,K,Z);if(!te)throw new Error("point at infinify");return te.assertValidity(),te}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Bn(this.toDERHex())}toDERHex(){return gt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Bn(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}
51const g={isValidPrivateKey(I){try{return u(I),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const I=Zp(t.n);return _x(t.randomBytes(I),t.n)},precompute(I=8,T=c.BASE){return T._setWindowSize(I),T.multiply(BigInt(3)),T}};function b(I,T=!0){return c.fromPrivateKey(I).toRawBytes(T)}function w(I){const T=an(I),O=typeof I=="string",N=(T||O)&&I.length;return T?N===s||N===i:O?N===2*s||N===2*i:I instanceof c}function x(I,T,O=!0){if(w(I))throw new Error("first arg must be private key");if(!w(T))throw new Error("second arg must be public key");return c.fromHex(T).multiply(u(I)).toRawBytes(O)}const S=t.bits2int||function(I){if(I.length>8192)throw new Error("input is too large");const T=Zt(I),O=I.length*8-t.nBitLength;return O>0?T>>BigInt(O):T},A=t.bits2int_modN||function(I){return a(S(I))},k=gc(t.nBitLength);function $(I){return Yt("num < 2^"+t.nBitLength,I,wt,k),$n(I,t.nByteLength)}function v(I,T,O=C){if(["recovered","canonical"].some(ke=>ke in O))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:B}=t;let{lowS:D,prehash:F,extraEntropy:U}=O;D==null&&(D=!0),I=We("msgHash",I),Xu(O),F&&(I=We("prehashed msgHash",N(I)));const H=A(I),Y=u(T),K=[$(Y),$(H)];if(U!=null&&U!==!1){const ke=U===!0?B(n.BYTES):U;K.push(We("extraEntropy",ke))}const Z=Tr(...K),te=H;function ut(ke){const Ie=S(ke);if(!d(Ie))return;const Lt=o(Ie),je=c.BASE.multiply(Ie).toAffine(),Ut=a(je.x);if(Ut===wt)return;const zn=a(Lt*a(te+Ut*Y));if(zn===wt)return;let ln=(je.x===Ut?0:2)|Number(je.y&me),Ec=zn;return D&&p(zn)&&(Ec=y(zn),ln^=1),new m(Ut,Ec,ln)}return{seed:Z,k2sig:ut}}const C={lowS:t.lowS,prehash:!1},E={lowS:t.lowS,prehash:!1};function P(I,T,O=C){const{seed:N,k2sig:B}=v(I,T,O),D=t;return Cp(D.hash.outputLen,D.nByteLength,D.hmac)(N,B)}c.BASE._setWindowSize(8);function M(I,T,O,N=E){const B=I;T=We("msgHash",T),O=We("publicKey",O);const{lowS:D,prehash:F,format:U}=N;if(Xu(N),"strict"in N)throw new Error("options.strict was renamed to lowS");if(U!==void 0&&U!=="compact"&&U!=="der")throw new Error("format must be compact or der");const H=typeof B=="string"||an(B),Y=!H&&!U&&typeof B=="object"&&B!==null&&typeof B.r=="bigint"&&typeof B.s=="bigint";if(!H&&!Y)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,Z;try{if(Y&&(K=new m(B.r,B.s)),H){try{U!=="compact"&&(K=m.fromDER(B))}catch(ln){if(!(ln instanceof gt.Err))throw ln}!K&&U!=="der"&&(K=m.fromCompact(B))}Z=c.fromHex(O)}catch{return!1}if(!K||D&&K.hasHighS())return!1;F&&(T=t.hash(T));const{r:te,s:ut}=K,ke=A(T),Ie=o(ut),Lt=a(ke*Ie),je=a(te*Ie),Ut=c.BASE.multiplyAndAddUnsafe(Z,Lt,je)?.toAffine();return Ut?a(Ut.x)===te:!1}return{CURVE:t,getPublicKey:b,getSharedSecret:x,sign:P,verify:M,ProjectivePoint:c,Signature:m,utils:g}}function Mx(e){return{hash:e,hmac:(t,...n)=>qp(e,t,k2(...n)),randomBytes:P2}}function Rx(e,t){const n=r=>Nx({...e,...Mx(r)});return{...n(t),create:n}}function jx(e,t={}){const{recovered:n}=t;if(typeof e.r>"u")throw new Ui({signature:e});if(typeof e.s>"u")throw new Ui({signature:e});if(n&&typeof e.yParity>"u")throw new Ui({signature:e});if(e.r<0n||e.r>Zu)throw new Fx({value:e.r});if(e.s<0n||e.s>Zu)throw new Hx({value:e.s});if(typeof e.yParity=="number"&&e.yParity!==0&&e.yParity!==1)throw new vc({value:e.yParity})}function Xp(e){if(e.length!==130&&e.length!==132)throw new zx({signature:e});const t=BigInt(Fe(e,0,32)),n=BigInt(Fe(e,32,64)),r=(()=>{const s=+`0x${e.slice(130)}`;if(!Number.isNaN(s))try{return Ux(s)}catch{throw new vc({value:s})}})();return typeof r>"u"?{r:t,s:n}:{r:t,s:n,yParity:r}}function Lx(e){jx(e);const t=e.r,n=e.s;return fi(Mt(t,{size:32}),Mt(n,{size:32}),typeof e.yParity=="number"?Mt(Dx(e.yParity),{size:1}):"0x")}function Ux(e){if(e===0||e===27)return 0;if(e===1||e===28)return 1;if(e>=35)return e%2===0?1:0;throw new Gx({value:e})}function Dx(e){if(e===0)return 27;if(e===1)return 28;throw new vc({value:e})}class zx extends ne{constructor({signature:t}){super(`Value \`${t}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${Rt($p(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class Ui extends ne{constructor({signature:t}){super(`Signature \`${li(t)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class Fx extends ne{constructor({value:t}){super(`Value \`${t}
51\` 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 Hx extends ne{constructor({value:t}){super(`Value \`${t}\` 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 vc extends ne{constructor({value:t}){super(`Value \`${t}\` 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 Gx extends ne{constructor({value:t}){super(`Value \`${t}\` 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"})}}const qx=new TextDecoder,Xr=Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[t,e.charCodeAt(0)]));({...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[e.charCodeAt(0),t]))});function Vx(e,t={}){const{pad:n=!0,url:r=!1}=t,s=new Uint8Array(Math.ceil(e.length/3)*4);for(let c=0,u=0;u<e.length;c+=4,u+=3){const l=(e[u]<<16)+(e[u+1]<<8)+(e[u+2]|0);s[c]=Xr[l>>18],s[c+1]=Xr[l>>12&63],s[c+2]=Xr[l>>6&63],s[c+3]=Xr[l&63]}const i=e.length%3,a=Math.floor(e.length/3)*4+(i&&i+1);let o=qx.decode(new Uint8Array(s.buffer,0,a));return n&&i===1&&(o+="=="),n&&i===2&&(o+="="),r&&(o=o.replaceAll("+","-").replaceAll("/","_")),o}function Wx(e,t={}){return Vx(Up(e),t)}const eh=Wp(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Kx=eh.create(BigInt("-3")),Zx=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),td=Rx({a:Kx,b:Zx,Fp:eh,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Tp);Uint8Array.from([105,171,180,181,160,222,75,198,42,42,32,31,141,37,186,233]);function Yx(e={}){const{flag:t=5,rpId:n=window.location.hostname,signCount:r=0}=e,s=zp(Np(n)),i=Mt(t,{size:1}),a=Mt(r,{size:4});return fi(s,i,a)}function Jx(e){const{challenge:t,crossOrigin:n=!1,extraClientData:r,origin:s=window.location.origin}=e;return JSON.stringify({type:"webauthn.get",challenge:Wx(t,{url:!0,pad:!1}),origin:s,crossOrigin:n,...r})}function Qx(e){const{challenge:t,crossOrigin:n,extraClientData:r,flag:s,origin:i,rpId:a,signCount:o,userVerification:c="required"}=e,u=Yx({flag:s,rpId:a,signCount:o}),l=Jx({challenge:t,crossOrigin:n,extraClientData:r,origin:i}),d=zp(Np(l)),f=l.indexOf('"challenge"'),p=l.indexOf('"type"'),y={authenticatorData:u,clientDataJSON:l,challengeIndex:f,typeIndex:p,userVerificationRequired:c==="required"},h=fi(u,d);return{metadata:y,payload:h}}async function Xx(e={}){const{extractable:t=!1}=e,n=await globalThis.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},t,["sign","verify"]),r=await globalThis.crypto.subtle.exportKey("raw",n.publicKey),s=ux(new Uint8Array(r));return{privateKey:n.privateKey,publicKey:s}}async function eE(e){const{payload:t,privateKey:n}=e,r=await globalThis.crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},n,jp(t)),s=Lp(new Uint8Array(r)),i=Wu(Vu(s,0,32));let a=Wu(Vu(s,32,64));return a>td.CURVE.n/2n&&(a=td.CURVE.n-a),{r:i,s:a}}function tE(e,t){const n=typeof indexedDB<"u"?yh(e,t):void 0;return{getItem:async r=>{const s=await wh(r,n);return s||null},removeItem:async r=>bh(r,n),setItem:async(r,s)=>gh(r,s,n)}}const nE="cbwsdk",rE="keys",xc="activeId",Rn=tE(nE,rE);async function sE(){const e=await Xx({extractable:!1}),t=Fe(wc(e.publicKey),1);return await Rn.setItem(t,e),await Rn.setItem(xc,t),e}async function iE(){const e=await Rn.getItem(xc);if(!e)return null;const t=await Rn.getItem(e);return t||null}async function aE(){const e=await iE();if(!e){const t=await sE(),n=Fe(wc(t.publicKey),1);return await Rn.setItem(n,t),await Rn.setItem(xc,n),t}return e}async function oE(){const e=await aE(),t=Fe(wc(e.publicKey),1),n=async r=>{const{payload:s,metadata:i}=Qx({challenge:r,origin:"https://keys.coinbase.com",userVerification:"preferred"}),a=await eE({payload:s,privateKey:e.privateKey});return{signature:Lx(a),raw:{},webauthn:i}};return{id:t,publicKey:t,async sign({hash:r}){return n(r)},async signMessage({message:r}){return n(ti(r))},async signTypedData(r){return n(Lr(r))},type:"webAuthn"}}async function Ms(){return{account:await oE()}}const nd={storageKey:"ownPrivateKey",keyType:"private"},rd={storageKey:"ownPublicKey",keyType:"public"},sd={storageKey:"peerPublicKey",keyType:"public"};class cE{constructor(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(t){this.sharedSecret=null,this.peerPublicKey=t,await this.storeKey(sd,t),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,L.keys.clear()}async generateKeyPair(){const t=await h2();this.ownPrivateKey=t.privateKey,this.ownPublicKey=t.publicKey,await this.storeKey(nd,t.privateKey),await this.storeKey(rd,t.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(nd)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(rd)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(sd)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await m2(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(t){const n=L.keys.get(t.storageKey);return n?kp(t.keyType,n):null}async storeKey(t,n){const r=await Ap(t.keyType,n);L.keys.set(t.storageKey,r)}}function Wn(e,t){if(!(typeof e!="object"||e===null))return t.split(/[.[\]]+/).filter(
51Boolean).reduce((n,r)=>{if(typeof n=="object"&&n!==null)return n[r]},e)}const th="0x0ba5ed0c6aa8c49038f819e587e2633c4a9f428a",nh="0xf85210B21cC50302F477BA56686d2019dC9b67Ad",Ye=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"owner",type:"bytes"}],name:"AlreadyOwner",type:"error"},{inputs:[],name:"Initialized",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidEthereumAddressOwner",type:"error"},{inputs:[{name:"key",type:"uint256"}],name:"InvalidNonceKey",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidOwnerBytesLength",type:"error"},{inputs:[],name:"LastOwner",type:"error"},{inputs:[{name:"index",type:"uint256"}],name:"NoOwnerAtIndex",type:"error"},{inputs:[{name:"ownersRemaining",type:"uint256"}],name:"NotLastOwner",type:"error"},{inputs:[{name:"selector",type:"bytes4"}],name:"SelectorNotAllowed",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"UnauthorizedCallContext",type:"error"},{inputs:[],name:"UpgradeFailed",type:"error"},{inputs:[{name:"index",type:"uint256"},{name:"expectedOwner",type:"bytes"},{name:"actualOwner",type:"bytes"}],name:"WrongOwnerAtIndex",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"AddOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"RemoveOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"REPLAYABLE_NONCE_KEY",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"addOwnerAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"addOwnerPublicKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"functionSelector",type:"bytes4"}],name:"canSkipChainIdValidation",outputs:[{name:"",type:"bool"}],stateMutability:"pure",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{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"},{inputs:[],name:"entryPoint",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"execute",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"executeBatch",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"calls",type:"bytes[]"}],name:"executeWithoutChainIdValidation",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHashWithoutChainId",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"$",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"owners",type:"bytes[]"}],name:"initialize",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"isOwnerAddress",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"bytes"}],name:"isOwnerBytes",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"isOwnerPublicKey",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"result",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextOwnerIndex",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"}],name:"ownerAtIndex",outputs:[{name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"ownerCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeLastOwner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeOwnerAtIndex",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"removedOwnersCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"}],name:"replaySafeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"newImplementation",type:"address"},{name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"missingAccountFunds",type:"uint256"}],name:"validateUserOp",outputs:[{name:"validationData",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],rh=[{inputs:[{name:"implementation_",type:"address"}],stateMutability:"payable",type:"constructor"},{inputs:[],name:"OwnerRequired",type:"error"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"createAccount",outputs:[{name:"account",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"getAddress",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initCodeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"}];function id(e){var t;if(!Array.isArray(e.params))return null;switch(e.method){case"personal_sign":return e.params[1];case"eth_signTypedData_v4":return e.params[0];case"eth_signTransaction":case"eth_sendTransaction":case"wallet_sendCalls":return(t=e.params[0])===null||t===void 0?void 0:t.from;default:return null}}function uE(e,t){if(!Array.isArray(e.params))throw j.rpc.invalidParams();const n=[...e.params];switch(e.method){case"eth_signTransaction":case"eth_sendTransaction":case"wallet_sendCalls":n[0].from=t;break;case"eth_signTypedData_v4":n[0]=t;break;case"personal_sign":n[1]=t;break}return Object.assign(Object.assign({},e),{params:n})}function ad(e){var t;if(!e||!Array.isArray(e)||!(!((t=e[0])===null||t===void 0)&&t.chainId)||typeof e[0].chainId!="string"&&typeof e[0].chainId!="number")throw j.rpc.invalidParams()}function dE(e){if(!e||!Array.isArray(e)||e.length!==1&&e.length!==2||typeof e[0]!="str
51ing"||!be(e[0]))throw j.rpc.invalidParams();if(e.length===2){if(!Array.isArray(e[1]))throw j.rpc.invalidParams();for(const t of e[1])if(typeof t!="string"||!t.startsWith("0x"))throw j.rpc.invalidParams()}}function Rs(e,t){const n=Object.assign({},e);if(t&&e.method.startsWith("wallet_")){let r=Wn(n,"params.0.capabilities");if(typeof r>"u"&&(r={}),typeof r!="object")throw j.rpc.invalidParams();r=Object.assign(Object.assign({},t),r),n.params&&Array.isArray(n.params)&&(n.params[0]=Object.assign(Object.assign({},n.params[0]),{capabilities:r}))}return n}async function Di(){var e;const t=(e=L.subAccountsConfig.get())!==null&&e!==void 0?e:{},n={};if(t.enableAutoSubAccounts){const{account:r}=t.toOwnerAccount?await t.toOwnerAccount():await Ms();if(!r)throw j.provider.unauthorized("No owner account found");n.addSubAccount={account:{type:"create",keys:[{type:r.address?"address":"webauthn-p256",publicKey:r.address||r.publicKey}]}}}L.subAccountsConfig.set({capabilities:n})}function lE(e){if(!(e.method==="coinbase_fetchPermissions"&&e.params===void 0)){if(e.method==="coinbase_fetchPermissions"&&Array.isArray(e.params)&&e.params.length===1&&typeof e.params[0]=="object"){if(typeof e.params[0].account!="string"||!e.params[0].chainId.startsWith("0x"))throw j.rpc.invalidParams("FetchPermissions - Invalid params: params[0].account must be a hex string");if(typeof e.params[0].chainId!="string"||!e.params[0].chainId.startsWith("0x"))throw j.rpc.invalidParams("FetchPermissions - Invalid params: params[0].chainId must be a hex string");if(typeof e.params[0].spender!="string"||!e.params[0].spender.startsWith("0x"))throw j.rpc.invalidParams("FetchPermissions - Invalid params: params[0].spender must be a hex string");return}throw j.rpc.invalidParams()}}function fE(e){var t,n,r;if(e.params!==void 0)return e;const s=(t=L.getState().account.accounts)===null||t===void 0?void 0:t[0],i=(n=L.getState().account.chain)===null||n===void 0?void 0:n.id,a=(r=L.getState().subAccount)===null||r===void 0?void 0:r.address;if(!s||!a||!i)throw j.rpc.invalidParams("FetchPermissions - one or more of account, sub account, or chain id is missing, connect to sub account via wallet_connect first");return{method:"coinbase_fetchPermissions",params:[{account:s,chainId:R(i),spender:a}]}}function pE({spendPermission:e,chainId:t}){return{domain:{name:"Spend Permission Manager",version:"1",chainId:t,verifyingContract:nh},types:{SpendPermission:[{name:"account",type:"address"},{name:"spender",type:"address"},{name:"token",type:"address"},{name:"allowance",type:"uint160"},{name:"period",type:"uint48"},{name:"start",type:"uint48"},{name:"end",type:"uint48"},{name:"salt",type:"uint256"},{name:"extraData",type:"bytes"}]},primaryType:"SpendPermission",message:{account:e.account,spender:e.spender,token:e.token,allowance:e.allowance,period:e.period,start:e.start,end:e.end,salt:e.salt,extraData:e.extraData}}}function hE({spendPermissionBatch:e,chainId:t}){return{domain:{name:"Spend Permission Manager",version:"1",chainId:t,verifyingContract:nh},types:{SpendPermissionBatch:[{name:"account",type:"address"},{name:"period",type:"uint48"},{name:"start",type:"uint48"},{name:"end",type:"uint48"},{name:"permissions",type:"PermissionDetails[]"}],PermissionDetails:[{name:"spender",type:"address"},{name:"token",type:"address"},{name:"allowance",type:"uint160"},{name:"salt",type:"uint256"},{name:"extraData",type:"bytes"}]},primaryType:"SpendPermissionBatch",message:{account:e.account,period:e.period,start:e.start,end:e.end,permissions:e.permissions.map(n=>({spender:n.spender,token:n.token,allowance:n.allowance,salt:n.salt,extraData:n.extraData}))}}}async function sh({client:e,id:t}){var n;const r=await If(e,{id:t});if(r.status==="success")return(n=r.receipts)===null||n===void 0?void 0:n[0].transactionHash;throw j.rpc.internal("failed to send transaction")}function ih({calls:e,from:t,chainId:n,capabilities:r}){const s=Wd.get().paymasterUrls;let i={method:"wallet_sendCalls",params:[{version:"1.0",calls:e,chainId:R(n),from:t,atomicRequired:!0,capabilities:r}]};return s?.[n]&&(i=Rs(i,{paymasterService:{url:s?.[n]}})),i}async function mE(){const e=So();return await new Promise(n=>{_o({snackbarContext:"sub_account_insufficient_balance"}),e.presentItem({autoExpand:!0,message:"Insufficient spend permission. Choose how to proceed:",menuItems:[{isRed:!1,info:"Create new Spend Permission",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{vn({snackbarContext:"sub_account_insufficient_balance",snackbarAction:"create_permission"}),e.clear(),n("update_permission")}},{isRed:!1,info:"Continue in Popup",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{vn({snackbarContext:"sub_account_insufficient_balance",snackbarAction:"continue_in_popup"}),e.clear(),n("continue_popup")}},{isRed:!0,info:"Cancel",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{vn({snackbarContext:"sub_account_insufficient_balance",snackbarAction:"cancel"}),e.clear(),n("cancel")}}]})})}function yE({errorData:e,sourceAddress:t}){var n;const r=[];for(const[s,{amount:i,sources:a}]of Object.entries((n=e?.required)!==null&&n!==void 0?n:{}
51)){if(a.filter(c=>de(c.balance)>=de(i)&&c.address.toLowerCase()===t?.toLowerCase()).length===0)throw new Error("Source address has insufficient balance for a token");r.push({token:s,requiredAmount:de(i)})}return r}function gE(e){return typeof e=="object"&&e!==null&&"calls"in e}function bE(e){return Array.isArray(e)&&e.length===1&&typeof e[0]=="object"&&e[0]!==null&&"to"in e[0]}function wE(e){return en(X(_e(e)),0,16)}function vE({attribution:e,dappOrigin:t}){if(e){if("auto"in e&&e.auto&&t)return wE(t);if("dataSuffix"in e)return e.dataSuffix}}function xE(e,t){var n;if(!Array.isArray(e?.params))return!1;const r=(n=e.params[0])===null||n===void 0?void 0:n.capabilities;return!r||typeof r!="object"?!1:t in r}function es(e,t){const n=e.filter(r=>r!==t);return[t,...n]}function ts(e,t){return[...e.filter(r=>r!==t),t]}async function EE(){const e=L.spendPermissions.get(),t=L.subAccounts.get(),n=L.account.get().accounts;return n?{accounts:n?.map(s=>({address:s,capabilities:{subAccounts:t?[t]:void 0,spendPermissions:e.length>0?{permissions:e}:void 0}}))}:null}function _E(e){return e.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function ns(e){const t=btoa(String.fromCharCode(...new Uint8Array(e)));return _E(t)}function SE({webauthn:e,signature:t,id:n}){const r=Xp(t);return{id:n,rawId:ns(vt(n)),response:{authenticatorData:ns(Ae(e.authenticatorData)),clientDataJSON:ns(vt(e.clientDataJSON)),signature:ns(AE(r.r,r.s))},type:JSON.parse(e.clientDataJSON).type}}function AE(e,t){const n=Ae(Je(R(e))),r=Ae(Je(R(t))),s=n.length,i=r.length,a=s+i+4,o=new Uint8Array(a+2);return o[0]=48,o[1]=a,o[2]=2,o[3]=s,o.set(n,4),o[s+4]=2,o[s+5]=i,o.set(r,s+6),o}var kE=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n};async function IE(e){const{owner:t,ownerIndex:n,address:r,client:s,factoryData:i}=e,a={abi:z1,address:p2,version:"0.6"},o={abi:rh,address:th};return q1({client:s,entryPoint:a,extend:{abi:Ye,factory:o},async decodeCalls(c){const u=Jo({abi:Ye,data:c});if(u.functionName==="execute")return[{to:u.args[0],value:u.args[1],data:u.args[2]}];if(u.functionName==="executeBatch")return u.args[0].map(l=>({to:l.target,value:l.value,data:l.data}));throw new _(`unable to decode calls for "${u.functionName}"`)},async encodeCalls(c){var u,l;return c.length===1?he({abi:Ye,functionName:"execute",args:[c[0].to,(u=c[0].value)!==null&&u!==void 0?u:BigInt(0),(l=c[0].data)!==null&&l!==void 0?l:"0x"]}):he({abi:Ye,functionName:"executeBatch",args:[c.map(d=>{var f,p;return{data:(f=d.data)!==null&&f!==void 0?f:"0x",target:d.to,value:(p=d.value)!==null&&p!==void 0?p:BigInt(0)}})]})},async getAddress(){return r},async getFactoryArgs(){return i?{factory:o.address,factoryData:i}:{factory:o.address,factoryData:i}},async getStubSignature(){return t.type==="webAuthn"?"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000":Vn({ownerIndex:n,signature:"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"})},async sign(c){const u=await this.getAddress(),l=zi({address:u,chainId:s.chain.id,hash:c.hash}),d=await rs({hash:l,owner:t});return Vn({ownerIndex:n,signature:d})},async signMessage(c){const{message:u}=c,l=await this.getAddress(),d=zi({address:l,chainId:s.chain.id,hash:ti(u)}),f=await rs({hash:d,owner:t});return Vn({ownerIndex:n,signature:f})},async signTypedData(c){const{domain:u,types:l,primaryType:d,message:f}=c,p=await this.getAddress(),y=zi({address:p,chainId:s.chain.id,hash:Lr({domain:u,message:f,primaryType:d,types:l})}),h=await rs({hash:y,owner:t});return Vn({ownerIndex:n,signature:h})},async signUserOperation(c){const{chainId:u=s.chain.id}=c,l=kE(c,["chainId"]),d=await this.getAddress(),f=G1({chainId:u,entryPointAddress:a.address,entryPointVersion:a.version,userOperation:Object.assign(Object.assign({},l),{sender:d})}),p=await rs({hash:f,owner:t});return Vn({ownerIndex:n,signature:p})},userOperation:{async estimateGas(c){var u;if(t.type==="webAuthn")return{verificationGasLimit:BigInt(Math.max(Number((u=c.verificationGasLimit)!==null&&u!==void 0?u:BigInt(0)),8e5))}}}})}async function rs({hash:e,owner:t}){if(t.type==="webAuthn"){const{signature:n,webauthn:r}=await t.sign({hash:e});return PE({signature:n,webauthn:r})}if(t.sign)return t.sign({hash:e});throw new _("`owner` does not support raw sign.")}function zi({address:e,chainId:t,hash:n}){return Lr({domain:{chainId:t,name:"Coinbase Smart Wallet",verifyingContract:e,version:"1"},types:{CoinbaseSmartWalletMessage:[{name:"hash",type:"bytes32"}]}
51,primaryType:"CoinbaseSmartWalletMessage",message:{hash:n}})}function PE({webauthn:e,signature:t}){const{r:n,s:r}=Xp(t);return $e([{components:[{name:"authenticatorData",type:"bytes"},{name:"clientDataJSON",type:"bytes"},{name:"challengeIndex",type:"uint256"},{name:"typeIndex",type:"uint256"},{name:"r",type:"uint256"},{name:"s",type:"uint256"}],type:"tuple"}],[{authenticatorData:e.authenticatorData,clientDataJSON:Xt(e.clientDataJSON),challengeIndex:BigInt(e.challengeIndex),typeIndex:BigInt(e.typeIndex),r:n,s:r}])}function Vn(e){const{ownerIndex:t=0}=e,n=(()=>{if(re(e.signature)!==65)return e.signature;const r=A1(e.signature);return Ow(["bytes32","bytes32","uint8"],[r.r,r.s,r.yParity===0?27:28])})();return $e([{components:[{name:"ownerIndex",type:"uint8"},{name:"signatureData",type:"bytes"}],type:"tuple"}],[{ownerIndex:t,signatureData:n}])}async function TE({address:e,client:t,factory:n,factoryData:r,owner:s,ownerIndex:i,parentAddress:a,attribution:o}){var c;const u={address:e,factory:n,factoryData:r},l=(c=t.chain)===null||c===void 0?void 0:c.id;if(!l)throw j.rpc.internal("chainId not found");const d=await IE({owner:s,ownerIndex:i??1,address:e,client:t,factoryData:r}),f=async p=>{var y,h,m,g,b,w;try{switch(p.method){case"wallet_addSubAccount":return u;case"eth_accounts":return[u.address];case"eth_coinbase":return u.address;case"net_version":return l.toString();case"eth_chainId":return R(l);case"eth_sendTransaction":{Bt(p.params);const x=p.params[0];Be(x.to,j.rpc.invalidParams("to is required"));const S={to:x.to,data:sa((y=x.data)!==null&&y!==void 0?y:"0x",!0),value:sa((h=x.value)!==null&&h!==void 0?h:"0x",!0),from:(m=x.from)!==null&&m!==void 0?m:u.address},A=ih({calls:[S],chainId:l,from:S.from}),k=await f(A);return sh({client:t,id:k})}case"wallet_sendCalls":{Bt(p.params);const x=Wn(p.params[0],"chainId");if(!x)throw j.rpc.invalidParams("chainId is required");if(!we(x))throw j.rpc.invalidParams("chainId must be a hex encoded integer");if(!p.params[0])throw j.rpc.invalidParams("params are required");if(!("calls"in p.params[0]))throw j.rpc.invalidParams("calls are required");let S={method:"wallet_prepareCalls",params:[{version:"1.0",calls:p.params[0].calls,chainId:x,from:u.address,capabilities:"capabilities"in p.params[0]?p.params[0].capabilities:{}}]};a&&(S=Rs(S,{funding:[{type:"spendPermission",data:{autoApply:!0,sources:[a],preference:"PREFER_DIRECT_BALANCE"}}]}));let A=await f(S);const k=await((b=(g=s).sign)===null||b===void 0?void 0:b.call(g,{hash:Yc(A.signatureRequest.hash)}));let $;if(!k)throw j.rpc.internal("signature not found");return we(k)?$={type:"secp256k1",data:{address:s.address,signature:k}}:$={type:"webauthn",data:{signature:JSON.stringify(SE(Object.assign({id:(w=s.id)!==null&&w!==void 0?w:"1"},k))),publicKey:s.publicKey}},(await f({method:"wallet_sendPreparedCalls",params:[{version:"1.0",type:A.type,data:A.userOp,chainId:A.chainId,signature:$}]}))[0]}case"wallet_sendPreparedCalls":{Bt(p.params);const x=Wn(p.params[0],"chainId");if(!x)throw j.rpc.invalidParams("chainId is required");if(!we(x))throw j.rpc.invalidParams("chainId must be a hex encoded integer");return await t.request({method:"wallet_sendPreparedCalls",params:p.params})}case"wallet_prepareCalls":{Bt(p.params);const x=Wn(p.params[0],"chainId");if(!x)throw j.rpc.invalidParams("chainId is required");if(!we(x))throw j.rpc.invalidParams("chainId must be a hex encoded integer");if(!p.params[0])throw j.rpc.invalidParams("params are required");if(!Wn(p.params[0],"calls"))throw j.rpc.invalidParams("calls are required");const S=p.params[0];return o&&S.capabilities&&!("attribution"in S.capabilities)&&(S.capabilities.attribution=o),await t.request({method:"wallet_prepareCalls",params:[Object.assign(Object.assign({},p.params[0]),{chainId:x})]})}case"personal_sign":{if(Bt(p.params),!we(p.params[0]))throw j.rpc.invalidParams("message must be a hex encoded string");const x=Yc(p.params[0]);return d.signMessage({message:x})}case"eth_signTypedData_v4":{Bt(p.params);const x=typeof p.params[1]=="string"?JSON.parse(p.params[1]):p.params[1];return d.signTypedData(x)}case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":default:throw j.rpc.methodNotSupported()}}
51catch(x){if(Qd(x)){const S=D0(x);if(S)throw S}throw x}};return{request:f}}async function ah({address:e,client:t,publicKey:n,factory:r,factoryData:s}){if(!await vs(t,{address:e})&&r&&s){if(oa(r)!==oa(th))throw j.rpc.internal("unknown factory address");const o=Jo({abi:rh,data:s});if(o.functionName!=="createAccount")throw j.rpc.internal("unknown factory function");const[c]=o.args;return c.findIndex(u=>u.toLowerCase()===od(n).toLowerCase())}const a=await qe(t,{address:e,abi:Ye,functionName:"ownerCount"});for(let o=Number(a)-1;o>=0;o--){const c=await qe(t,{address:e,abi:Ye,functionName:"ownerAtIndex",args:[BigInt(o)]}),u=od(n);if(c.toLowerCase()===u.toLowerCase())return o}return-1}function od(e){return be(e)?le(e):e}async function OE(){const e=So();return new Promise(t=>{_o({snackbarContext:"sub_account_add_owner"}),e.presentItem({autoExpand:!0,message:"App requires a signer update",menuItems:[{isRed:!1,info:"Confirm",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{vn({snackbarContext:"sub_account_add_owner",snackbarAction:"confirm"}),e.clear(),t("authenticate")}},{isRed:!0,info:"Cancel",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{vn({snackbarContext:"sub_account_add_owner",snackbarAction:"cancel"}),e.clear(),t("cancel")}}]})})}async function CE({ownerAccount:e,globalAccountRequest:t}){var n,r;const s=L.account.get(),i=L.subAccounts.get(),a=(n=s.accounts)===null||n===void 0?void 0:n.find(y=>y.toLowerCase()!==i?.address.toLowerCase());Be(a,j.provider.unauthorized("no global account")),Be((r=s.chain)===null||r===void 0?void 0:r.id,j.provider.unauthorized("no chain id")),Be(i?.address,j.provider.unauthorized("no sub account"));const o=[];if(e.type==="local"&&e.address&&o.push({to:i.address,data:he({abi:Ye,functionName:"addOwnerAddress",args:[e.address]}),value:_e(0)}),e.publicKey){const[y,h]=cn([{type:"bytes32"},{type:"bytes32"}],e.publicKey);o.push({to:i.address,data:he({abi:Ye,functionName:"addOwnerPublicKey",args:[y,h]}),value:_e(0)})}const c={method:"wallet_sendCalls",params:[{version:"1",calls:o,chainId:R(84532),from:a}]};if(await OE()==="cancel")throw j.provider.unauthorized("user cancelled");const l=await t(c),d=_p(s.chain.id);if(Be(d,j.rpc.internal(`client not found for chainId ${s.chain.id}`)),(await If(d,{id:l})).status!=="success")throw j.rpc.internal("add owner call failed");const p=await ah({address:i.address,publicKey:e.type==="local"&&e.address?e.address:e.publicKey,client:d});if(p===-1)throw j.rpc.internal("failed to find owner index");return p}async function BE({errorData:e,globalAccountAddress:t,subAccountAddress:n,client:r,request:s,subAccountRequest:i,globalAccountRequest:a}){var o;const c=(o=r.chain)===null||o===void 0?void 0:o.id;Be(c,j.rpc.internal("invalid chainId"));const u=yE({errorData:e,sourceAddress:t}),l=await mE();if(l==="cancel")throw new Error("User cancelled funding");let d;const f=3600*24,p=3;if(l==="update_permission"){if(u.length===1){const w=u[0],x=pE({spendPermission:{token:w.token,allowance:R(w.requiredAmount*BigInt(p)),period:f,account:t,spender:n,start:0,end:0xffffffffffff,salt:R(BigInt(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),extraData:"0x"},chainId:c});d={method:"eth_signTypedData_v4",params:[t,x]}}else{const w=hE({spendPermissionBatch:{account:t,period:f,start:0,end:0xffffffffffff,permissions:u.map(x=>({token:x.token,allowance:R(x.requiredAmount*BigInt(p)),period:f,account:t,spender:n,salt:"0x0",extraData:"0x"}))},chainId:c});d={method:"eth_signTypedData_v4",params:[t,w]}}try{await a(d)}catch(w){throw console.error(w),new Error("User denied spend permission request")}return i(s)}const y=u.map(w=>w.token.toLowerCase()==="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE".toLowerCase()?{to:n,value:R(w.requiredAmount),data:"0x"}:{to:w.token,value:"0x0",data:he({abi:hb,functionName:"transfer",args:[n,w.requiredAmount]})});let h;if(s.method==="wallet_sendCalls"&&gE(s.params))h=s.params[0];else if(s.method==="eth_sendTransaction"&&bE(s.params))h=ih({calls:[s.params[0]],chainId:c,from:s.params[0].from}).params[0];else throw new Error("Could not get original call");const m=he({abi:Ye,functionName:"executeBatch",args:[h.calls.map(w=>{var x,S;return{target:w.to,value:de((x=w.value)!==null&&x!==void 0?x:"0x0"),data:(S=w.data)!==null&&S!==void 0?S:"0x"}})]}),g=[...y,{data:m,to:n,value:"0x0"}],b=await a({method:"wallet_sendCalls",params:[Object.assign(Object.assign({},h),{calls:g,from:t})]});return s.method==="eth_sendTransaction"?sh({client:r,id:b}):b}class oh{constructor(t){var n,r,s,i;this.communicator=t.communicator,this.callback=t.callback,this.keyManager=new cE;const{account:a,chains:o}=L.getState();this.accounts=(n=a.accounts)!==null&&n!==void 0?n:[],this.chain=(r=a.chain)!==null&&r!==void 0?r:{id:(i=(s=t.metadata.appChainIds)===null||s===void 0?void 0:s[0])!==null&&i!==void 0?i:1},o&&Uu(o)}async handshake(t){var n,r,s;const i=Ke.get(t);k1({method:t.method,correlationId:i});try{await((r=(n=this.communicator).waitForPopupLoaded)===null||r===void 0?void 0:r.call(n));const a=await this.createRequestMessage({handshake:{method:t.method,params:(s=t.params)!==null&&s!==void 0?s:[]}}
51,i),o=await this.communicator.postRequestAndWaitForResponse(a);if("failure"in o.content)throw o.content.failure;const c=await kp("public",o.sender);await this.keyManager.setPeerPublicKey(c);const u=await this.decryptResponseMessage(o);this.handleResponse(t,u),P1({method:t.method,correlationId:i})}catch(a){throw I1({method:t.method,correlationId:i,errorMessage:Ft(a)}),a}}async request(t){const n=Ke.get(t);T1({method:t.method,correlationId:n});try{const r=await this._request(t);return C1({method:t.method,correlationId:n}),r}catch(r){throw O1({method:t.method,correlationId:n,errorMessage:Ft(r)}),r}}async _request(t){var n,r,s,i,a,o,c,u,l,d,f,p,y,h;if(this.accounts.length===0)switch(t.method){case"eth_requestAccounts":return await((r=(n=this.communicator).waitForPopupLoaded)===null||r===void 0?void 0:r.call(n)),await Di(),await this.request({method:"wallet_connect",params:[{version:"1",capabilities:Object.assign({},(i=(s=L.subAccountsConfig.get())===null||s===void 0?void 0:s.capabilities)!==null&&i!==void 0?i:{})}]}),this.accounts;case"wallet_switchEthereumChain":{ad(t.params),this.chain.id=Number(t.params[0].chainId);return}case"wallet_connect":{await((o=(a=this.communicator).waitForPopupLoaded)===null||o===void 0?void 0:o.call(a)),await Di();let m={};xE(t,"addSubAccount")&&(m=(u=(c=L.subAccountsConfig.get())===null||c===void 0?void 0:c.capabilities)!==null&&u!==void 0?u:{});const g=Rs(t,m);return this.sendRequestToPopup(g)}case"wallet_sendCalls":case"wallet_sign":return this.sendRequestToPopup(t);default:throw j.provider.unauthorized()}if(this.shouldRequestUseSubAccountSigner(t)){const m=Ke.get(t);B1({method:t.method,correlationId:m});try{const g=await this.sendRequestToSubAccountSigner(t);return $1({method:t.method,correlationId:m}),g}catch(g){throw N1({method:t.method,correlationId:m,errorMessage:Ft(g)}),g}}switch(t.method){case"eth_requestAccounts":case"eth_accounts":{const m=L.subAccounts.get(),g=L.subAccountsConfig.get();return m?.address&&(this.accounts=g?.enableAutoSubAccounts?es(this.accounts,m.address):ts(this.accounts,m.address)),(l=this.callback)===null||l===void 0||l.call(this,"connect",{chainId:R(this.chain.id)}),this.accounts}case"eth_coinbase":return this.accounts[0];case"net_version":return this.chain.id;case"eth_chainId":return R(this.chain.id);case"wallet_getCapabilities":return this.handleGetCapabilitiesRequest(t);case"wallet_switchEthereumChain":return this.handleSwitchChainRequest(t);case"eth_ecRecover":case"personal_sign":case"wallet_sign":case"personal_ecRecover":case"eth_signTransaction":case"eth_sendTransaction":case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":case"wallet_addEthereumChain":case"wallet_watchAsset":case"wallet_sendCalls":case"wallet_showCallsStatus":case"wallet_grantPermissions":return this.sendRequestToPopup(t);case"wallet_connect":{const m=await EE();if(m)return m;await((f=(d=this.communicator).waitForPopupLoaded)===null||f===void 0?void 0:f.call(d)),await Di();const g=L.subAccountsConfig.get(),b=Rs(t,(p=g?.capabilities)!==null&&p!==void 0?p:{});return(y=this.callback)===null||y===void 0||y.call(this,"connect",{chainId:R(this.chain.id)}),this.sendRequestToPopup(b)}case"wallet_getSubAccounts":{const m=L.subAccounts.get();if(m?.address)return{subAccounts:[m]};if(!this.chain.rpcUrl)throw j.rpc.internal("No RPC URL set for chain");const g=await Jn(t,this.chain.rpcUrl);if(Bt(g.subAccounts,"subAccounts"),g.subAccounts.length>0){Yr(g.subAccounts[0]);const b=g.subAccounts[0];L.subAccounts.set({address:b.address,factory:b.factory,factoryData:b.factoryData})}return g}case"wallet_addSubAccount":return this.addSubAccount(t);case"coinbase_fetchPermissions":{lE(t);const m=fE(t),g=await Jn(m,sl),b=Te((h=m.params)===null||h===void 0?void 0:h[0].chainId);return L.spendPermissions.set(g.permissions.map(w=>Object.assign(Object.assign({},w),{chainId:b}))),g}default:if(!this.chain.rpcUrl)throw j.rpc.internal("No RPC URL set for chain");return Jn(t,this.chain.rpcUrl)}}async sendRequestToPopup(t){var n,r;await((r=(n=this.communicator).waitForPopupLoaded)===null||r===void 0?void 0:r.call(n));const s=await this.sendEncryptedRequest(t),i=await this.decryptResponseMessage(s);return this.handleResponse(t,i)}async handleResponse(t,n){var r,s,i,a,o;const c=n.result;if("error"in c)throw c.error;switch(t.method){case"eth_requestAccounts":{const u=c.value;this.accounts=u,L.account.set({accounts:u,chain:this.chain}),(r=this.callback)===null||r===void 0||r.call(this,"accountsChanged",u);break}case"wallet_connect":{const u=c.value,l=u.accounts.map(g=>g.address);this.accounts=l,L.account.set({accounts:l});const d=u.accounts.at(0),f=d?.capabilities;if(f?.subAccounts){const g=f?.subAccounts;Bt(g,"subAccounts"),Yr(g[0]),L.subAccounts.set({address:g[0].address,factory:g[0].factory,factoryData:g[0].factoryData})}let p=[this.accounts[0]];const y=L.subAccounts.get(),h=L.subAccountsConfig.get();y?.address&&(this.accounts=h?.enableAutoSubAccounts?es(this.accounts,y.address):ts(this.accounts,y.address));const m=(i=(s=u?.accounts)===null||s===void 0?void 0:s[0].capabilities)===null||i===void 0?void 0:i.spendPermissions;m&&"permissions"in m&&L.spendPermissions.set(m?.permissions),(a=this.callback)===null||a===void 0||a.call(this,"accountsChanged",p);break}case"wallet_addSubAccount":{Yr(c.value);const u=c.value;L.subAccounts.set(u);const l=L.subAccountsConfig.get();this.accounts=l?.enableAutoSubAccounts?es(this.accounts,u.address):ts(this.accounts,u.address),(o=this.callback)===null||o===void 0||o.call(this,"accountsChanged",this.accounts);break}}return c.value}async cleanup(){var t,n;const r=L.config.get().metadata;await this.keyManager.clear(),L.account.clear(),L.subAccounts.clear(),L.spendPermissions.clear(),L.chains.clear(),this.accounts=[],this.chain={id:(n=(t=r?.appChainIds)===null||t===void 0?void 0:t[0])!==null&&n!==void 0?n:1}}async handleSwitchChainRequest(t){ad(t.params);const n=Yn(t.params[0].chainId);if(this.updateChain(n))return null;const s=await this.sendRequestToPopup(t);return s===null&&this.updateChain(n),s}async handleGetCapabilitiesRequest(t){dE(t.params);const n=t.params[0],r=t.params[1];if(!this.accounts.some(o=>Rr(o,n)))throw j.provider.unauthorized("no active account found when getting capabilities");const s=L.getState().account.capabilities;if(!s)return{};if(!r||r.length===0)return s;const i=new Set(r.map(o=>Te(o)));return Object.fromEntries(Object.entries(s).filter(([o])=>{try{const c=Te(o);return i.has(c)}catch{return!1}}
51))}async sendEncryptedRequest(t){const n=await this.keyManager.getSharedSecret();if(!n)throw j.provider.unauthorized("No shared secret found when encrypting request");const r=await b2({action:t,chainId:this.chain.id},n),s=Ke.get(t),i=await this.createRequestMessage({encrypted:r},s);return this.communicator.postRequestAndWaitForResponse(i)}async createRequestMessage(t,n){const r=await Ap("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),correlationId:n,sender:r,content:t,timestamp:new Date}}async decryptResponseMessage(t){var n,r,s;const i=t.content;if("failure"in i)throw i.failure;const a=await this.keyManager.getSharedSecret();if(!a)throw j.provider.unauthorized("Invalid session: no shared secret found when decrypting response");const o=await w2(i.encrypted,a),c=(n=o.data)===null||n===void 0?void 0:n.chains;if(c){const l=(r=o.data)===null||r===void 0?void 0:r.nativeCurrencies,d=Object.entries(c).map(([f,p])=>{const y=l?.[Number(f)];return Object.assign({id:Number(f),rpcUrl:p},y?{nativeCurrency:y}:{})});L.chains.set(d),this.updateChain(this.chain.id,d),Uu(d)}const u=(s=o.data)===null||s===void 0?void 0:s.capabilities;return u&&L.account.set({capabilities:u}),o}updateChain(t,n){var r;const s=L.getState(),i=n??s.chains,a=i?.find(o=>o.id===t);return a?(a!==this.chain&&(this.chain=a,L.account.set({chain:a}),(r=this.callback)===null||r===void 0||r.call(this,"chainChanged",yn(a.id))),!0):!1}async addSubAccount(t){var n,r,s,i;const o=L.getState().subAccount,c=L.subAccountsConfig.get();if(o?.address)return this.accounts=c?.enableAutoSubAccounts?es(this.accounts,o.address):ts(this.accounts,o.address),(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",this.accounts),o;if(await((s=(r=this.communicator).waitForPopupLoaded)===null||s===void 0?void 0:s.call(r)),Array.isArray(t.params)&&t.params.length>0&&t.params[0].account&&t.params[0].account.type==="create"){let l;if(t.params[0].account.keys&&t.params[0].account.keys.length>0)l=t.params[0].account.keys;else{const d=(i=L.subAccountsConfig.get())!==null&&i!==void 0?i:{},{account:f}=d.toOwnerAccount?await d.toOwnerAccount():await Ms();if(!f)throw j.provider.unauthorized("could not get subaccount owner account when adding sub account");l=[{type:f.address?"address":"webauthn-p256",publicKey:f.address||f.publicKey}]}t.params[0].account.keys=l}const u=await this.sendRequestToPopup(t);return Yr(u),u}shouldRequestUseSubAccountSigner(t){const n=id(t),r=L.subAccounts.get();return n?n.toLowerCase()===r?.address.toLowerCase():!1}async sendRequestToSubAccountSigner(t){var n;const r=L.subAccounts.get(),s=L.subAccountsConfig.get(),i=L.config.get();Be(r?.address,j.provider.unauthorized("no active sub account when sending request to sub account signer"));const a=s?.toOwnerAccount?await s.toOwnerAccount():await Ms();Be(a?.account,j.provider.unauthorized("no active sub account owner when sending request to sub account signer")),id(t)===void 0&&(t=uE(t,r.address));const c=_p(this.chain.id);Be(c,j.rpc.internal(`client not found for chainId ${this.chain.id} when sending request to sub account signer`));const u=this.accounts.find(y=>y.toLowerCase()!==r.address.toLowerCase());Be(u,j.provider.unauthorized("no global account found when sending request to sub account signer"));const l=vE({attribution:(n=i.preference)===null||n===void 0?void 0:n.attribution,dappOrigin:window.location.origin}),d=a.account.type==="local"?a.account.address:a.account.publicKey;let f=await ah({address:r.address,factory:r.factory,factoryData:r.factoryData,publicKey:d,client:c});if(f===-1){const y=Ke.get(t);M1({method:t.method,correlationId:y});try{f=await CE({ownerAccount:a.account,globalAccountRequest:this.sendRequestToPopup.bind(this)}),R1({method:t.method,correlationId:y})}catch(h){return j1({method:t.method,correlationId:y,errorMessage:Ft(h)}),j.provider.unauthorized("failed to add sub account owner when sending request to sub account signer")}}const{request:p}=await TE({address:r.address,owner:a.account,client:c,factory:r.factory,factoryData:r.factoryData,parentAddress:u,attribution:l?{suffix:l}:void 0,ownerIndex:f});try{return await p(t)}catch(y){let h;if(Qd(y))h=JSON.parse(y.details);else if(zc(y))h=y;else throw y;if(!(zc(h)&&h.data)||!h.data)throw y;const m=Ke.get(t);L1({method:t.method,correlationId:m});try{const g=await BE({errorData:h.data,globalAccountAddress:u,subAccountAddress:r.address,client:c,request:t,subAccountRequest:p,globalAccountRequest:this.request.bind(this)});return U1({method:t.method,correlationId:m}),g}catch(g){throw console.error(g),D1({method:t.method,correlationId:m,errorMessage:Ft(g)}),y}}}}const $E=({method:e,correlationId:t})=>{W("walletlink_signer.handshake.started",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t}
51,V.high)},NE=({method:e,correlationId:t,errorMessage:n})=>{W("walletlink_signer.handshake.error",{action:q.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n},V.high)},ME=({method:e,correlationId:t})=>{W("walletlink_signer.handshake.completed",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t},V.high)},RE=({method:e,correlationId:t})=>{W("walletlink_signer.request.started",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t},V.high)},jE=({method:e,correlationId:t,errorMessage:n})=>{W("walletlink_signer.request.error",{action:q.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n},V.high)},LE=({method:e,correlationId:t})=>{W("walletlink_signer.request.completed",{action:q.unknown,componentType:G.unknown,method:e,correlationId:t},V.high)},cd=()=>{W("walletlink_signer.walletlink_connection.connection_failed",{action:q.measurement,componentType:G.unknown},V.high)},UE=()=>{W("walletlink_signer.walletlink_connection.fetch_unseen_events_failed",{action:q.measurement,componentType:G.unknown},V.high)};var Fi,ud;function ch(){if(ud)return Fi;ud=1;const{keccak_256:e}=vh();function t(h){return Q.allocUnsafe(h).fill(0)}function n(h){return`0x${h.toString(16)}`}function r(h){const m=n(h);return new Q(f(m.slice(2)),"hex")}function s(h){return h.toString(2).length}function i(h,m){let g=h.toString(16);g.length%2!==0&&(g="0"+g);const b=g.match(/.{1,2}/g).map(w=>parseInt(w,16));for(;b.length<m;)b.unshift(0);return Q.from(b)}function a(h,m){const g=h<0n;let b;if(g){const w=(1n<<BigInt(m))-1n;b=(~h&w)+1n}else b=h;return b&=(1n<<BigInt(m))-1n,b}function o(h,m,g){const b=t(m);return h=u(h),g?h.length<m?(h.copy(b),b):h.slice(0,m):h.length<m?(h.copy(b,m-h.length),b):h.slice(-m)}function c(h,m){return o(h,m,!0)}function u(h){if(!Q.isBuffer(h))if(Array.isArray(h))h=Q.from(h);else if(typeof h=="string")p(h)?h=Q.from(f(y(h)),"hex"):h=Q.from(h);else if(typeof h=="number")h=r(h);else if(h==null)h=Q.allocUnsafe(0);else if(typeof h=="bigint")h=i(h);else if(h.toArray)h=Q.from(h.toArray());else throw new Error("invalid type");return h}function l(h){return h=u(h),"0x"+h.toString("hex")}function d(h,m){if(h=u(h),m||(m=256),m!==256)throw new Error("unsupported");return Q.from(e(new Uint8Array(h)))}function f(h){return h.length%2?"0"+h:h}function p(h){return typeof h=="string"&&h.match(/^0x[0-9A-Fa-f]*$/)}function y(h){return typeof h=="string"&&h.startsWith("0x")?h.slice(2):h}return Fi={zeros:t,setLength:o,setLengthRight:c,isHexString:p,stripHexPrefix:y,toBuffer:u,bufferToHex:l,keccak:d,bitLengthFromBigInt:s,bufferBEFromBigInt:i,twosFromBigInt:a},Fi}var Hi,dd;function DE(){if(dd)return Hi;dd=1;const e=ch();function t(f){return f.startsWith("int[")?"int256"+f.slice(3):f==="int"?"int256":f.startsWith("uint[")?"uint256"+f.slice(4):f==="uint"?"uint256":f.startsWith("fixed[")?"fixed128x128"+f.slice(5):f==="fixed"?"fixed128x128":f.startsWith("ufixed[")?"ufixed128x128"+f.slice(6):f==="ufixed"?"ufixed128x128":f}function n(f){return Number.parseInt(/^\D+(\d+)$/.exec(f)[1],10)}function r(f){var p=/^\D+(\d+)x(\d+)$/.exec(f);return[Number.parseInt(p[1],10),Number.parseInt(p[2],10)]}function s(f){var p=f.match(/(.*)\[(.*?)\]$/);return p?p[2]===""?"dynamic":Number.parseInt(p[2],10):null}function i(f){var p=typeof f;if(p==="string"||p==="number")return BigInt(f);if(p==="bigint")return f;throw new Error("Argument is not a number")}function a(f,p){var y,h,m,g;if(f==="address")return a("uint160",i(p));if(f==="bool")return a("uint8",p?1:0);if(f==="string")return a("bytes",new Q(p,"utf8"));if(c(f)){if(typeof p.length>"u")throw new Error("Not an array?");if(y=s(f),y!=="dynamic"&&y!==0&&p.length>y)throw new Error("Elements exceed array size: "+y);m=[],f=f.slice(0,f.lastIndexOf("[")),typeof p=="string"&&(p=JSON.parse(p));for(g in p)m.push(a(f,p[g]));if(y==="dynamic"){var b=a("uint256",p.length);m.unshift(b)}return Q.concat(m)}else{if(f==="bytes")return p=new Q(p),m=Q.concat([a("uint256",p.length),p]),p.length%32!==0&&(m=Q.concat([m,e.zeros(32-p.length%32)])),m;if(f.startsWith("bytes")){if(y=n(f),y<1||y>32)throw new Error("Invalid bytes<N> width: "+y);return e.setLengthRight(p,32)}else if(f.startsWith("uint")){if(y=n(f),y%8||y<8||y>256)throw new Error("Invalid uint<N> width: "+y);h=i(p);const w=e.bitLengthFromBigInt(h);if(w>y)throw new Error("Supplied uint exceeds width: "+y+" vs "+w);if(h<0)throw new Error("Supplied uint is negative");return e.bufferBEFromBigInt(h,32)}else if(f.startsWith("int")){if(y=n(f),y%8||y<8||y>256)throw new Error("Invalid int<N> width: "+y);h=i(p);const w=e.bitLengthFromBigInt(h);if(w>y)throw new Error("Supplied int exceeds width: "+y+" vs "+w);const x=e.twosFromBigInt(h,256);return e.bufferBEFromBigInt(x,32)}else if(f.startsWith("ufixed")){if(y=r(f),h=i(p),h<0)throw new Error("Supplied ufixed is negative");return a("uint256",h*BigInt(2)**BigInt(y[1]))}else if(f.startsWith("fixed"))return y=r(f),a("int256",i(p)*BigInt(2)**BigInt(y[1]))}throw new Error("Unsupported or invalid type: "+f)}function o(f){return f==="string"||f==="bytes"||s(f)==="dynamic"}function c(f){return f.lastIndexOf("]")===f.length-1}function u(f,p){var y=[],h=[],m=32*f.length;for(var g in f){var b=t(f[g]),w=p[g],x=a(b,w);o(b)?(y.push(a("uint256",m)),h.push(x),m+=x.length):y.push(x)}return Q.concat(y.concat(h))}function l(f,p){if(f.length!==p.length)throw new Error("Number of types are not matching the values");for(var y,h,m=[],g=0;g<f.length;g++){var b=t(f[g]),w=p[g];if(b==="bytes")m.push(w);else if(b==="string")m.push(new Q(w,"utf8"));else if(b==="bool")m.push(new Q(w?"01":"00","hex"));else if(b==="address")m.push(e.setLength(w,20));else if(b.startsWith("bytes")){if(y=n(b),y<1||y>32)throw new Error("Invalid bytes<N> width: "+y);m.push(e.setLengthRight(w,y))}else if(b.startsWith("uint")){if(y=n(b),y%8||y<8||y>256)throw new Error("Invalid uint<N> width: "+y);h=i(w);const x=e.bitLengthFromBigInt(h);if(x>y)throw new Error("Supplied uint exceeds width: "+y+" vs "+x);m.push(e.bufferBEFromBigInt(h,y/8))}else if(b.startsWith("int")){if(y=n(b),y%8||y<8||y>256)throw new Error("Invalid int<N> width: "+y);h=i(w);const x=e.bitLengthFromBigInt(h);if(x>y)throw new Error("Supplied int exceeds width: "+y+" vs "+x);const S=e.twosFromBigInt(h,y);m.push(e.bufferBEFromBigInt(S,y/8))}else throw new Error("Unsupported or invalid type: "+b)}return Q.concat(m)}function d(f,p){return e.keccak(l(f,p))}return Hi={rawEncode:u,solidityPack:l,soliditySHA3:d},Hi}var Gi,ld;function zE(){if(ld)return Gi;ld=1;const e=ch(),t=DE(),n={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},r={encodeData(i,a,o,c=!0){const u=["bytes32"],l=[this.hashType(i,o)];if(c){const d=(f,p,y)=>{if(o[p]!==void 0)return["bytes32",y==null?"0x0000000000000000000000000000000000000000000000000000000000000000":e.keccak(this.encodeData(p,y,o,c))];if(y===void 0)throw new Error(`missing value for field ${f} of type ${p}`);
51if(p==="bytes")return["bytes32",e.keccak(y)];if(p==="string")return typeof y=="string"&&(y=Q.from(y,"utf8")),["bytes32",e.keccak(y)];if(p.lastIndexOf("]")===p.length-1){const h=p.slice(0,p.lastIndexOf("[")),m=y.map(g=>d(f,h,g));return["bytes32",e.keccak(t.rawEncode(m.map(([g])=>g),m.map(([,g])=>g)))]}return[p,y]};for(const f of o[i]){const[p,y]=d(f.name,f.type,a[f.name]);u.push(p),l.push(y)}}else for(const d of o[i]){let f=a[d.name];if(f!==void 0)if(d.type==="bytes")u.push("bytes32"),f=e.keccak(f),l.push(f);else if(d.type==="string")u.push("bytes32"),typeof f=="string"&&(f=Q.from(f,"utf8")),f=e.keccak(f),l.push(f);else if(o[d.type]!==void 0)u.push("bytes32"),f=e.keccak(this.encodeData(d.type,f,o,c)),l.push(f);else{if(d.type.lastIndexOf("]")===d.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");u.push(d.type),l.push(f)}}return t.rawEncode(u,l)},encodeType(i,a){let o="",c=this.findTypeDependencies(i,a).filter(u=>u!==i);c=[i].concat(c.sort());for(const u of c){if(!a[u])throw new Error("No type definition specified: "+u);o+=u+"("+a[u].map(({name:d,type:f})=>f+" "+d).join(",")+")"}return o},findTypeDependencies(i,a,o=[]){if(i=i.match(/^\w*/)[0],o.includes(i)||a[i]===void 0)return o;o.push(i);for(const c of a[i])for(const u of this.findTypeDependencies(c.type,a,o))!o.includes(u)&&o.push(u);return o},hashStruct(i,a,o,c=!0){return e.keccak(this.encodeData(i,a,o,c))},hashType(i,a){return e.keccak(this.encodeType(i,a))},sanitizeData(i){const a={};for(const o in n.properties)i[o]&&(a[o]=i[o]);return a.types&&(a.types=Object.assign({EIP712Domain:[]},a.types)),a},hash(i,a=!0){const o=this.sanitizeData(i),c=[Q.from("1901","hex")];return c.push(this.hashStruct("EIP712Domain",o.domain,o.types,a)),o.primaryType!=="EIP712Domain"&&c.push(this.hashStruct(o.primaryType,o.message,o.types,a)),e.keccak(Q.concat(c))}};Gi={TYPED_MESSAGE_SCHEMA:n,TypedDataUtils:r,hashForSignTypedDataLegacy:function(i){return s(i.data)},hashForSignTypedData_v3:function(i){return r.hash(i.data,!1)},hashForSignTypedData_v4:function(i){return r.hash(i.data)}};function s(i){const a=new Error("Expect argument to be non-empty array");if(typeof i!="object"||!i.length)throw a;const o=i.map(function(l){return l.type==="bytes"?e.toBuffer(l.value):l.value}),c=i.map(function(l){return l.type}),u=i.map(function(l){if(!l.name)throw a;return l.type+" "+l.name});return t.soliditySHA3(["bytes32","bytes32"],[t.soliditySHA3(new Array(i.length).fill("string"),u),t.soliditySHA3(c,o)])}return Gi}var FE=zE();const ss=ph(FE),HE="walletUsername",uo="Addresses",GE="AppVersion";class qE{constructor(t){this.secret=t}async encrypt(t){const n=this.secret;if(n.length!==64)throw new Error("secret must be 256 bits");const r=crypto.getRandomValues(new Uint8Array(12)),s=await crypto.subtle.importKey("raw",cs(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),i=new TextEncoder,a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},s,i.encode(t)),o=16,c=a.slice(a.byteLength-o),u=a.slice(0,a.byteLength-o),l=new Uint8Array(c),d=new Uint8Array(u),f=new Uint8Array([...r,...l,...d]);return vo(f)}async decrypt(t){const n=this.secret;if(n.length!==64)throw new Error("secret must be 256 bits");return new Promise((r,s)=>{(async()=>{const i=await crypto.subtle.importKey("raw",cs(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=cs(t),o=a.slice(0,12),c=a.slice(12,28),u=a.slice(28),l=new Uint8Array([...u,...c]),d={name:"AES-GCM",iv:new Uint8Array(o)};try{const f=await window.crypto.subtle.decrypt(d,i,l),p=new TextDecoder;r(p.decode(f))}catch(f){s(f)}})()})}}class VE{constructor(t,n,r){this.linkAPIUrl=t,this.sessionId=n;const s=`${n}:${r}`;this.auth=`Basic ${btoa(s)}`}async markUnseenEventsAsSeen(t){return Promise.all(t.map(n=>fetch(`${this.linkAPIUrl}/events/${n.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(n=>console.error("Unable to mark events as seen:",n))}async fetchUnseenEvents(){var t;const n=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(n.ok){const{events:r,error:s}=await n.json();if(s)throw new Error(`Check unseen events failed: ${s}`);const i=(t=r?.filter(a=>a.event==="Web3Response").map(a=>({type:"Event",sessionId:this.sessionId,eventId:a.id,event:a.event,data:a.data})))!==null&&t!==void 0?t:[];return this.markUnseenEventsAsSeen(i),i}throw new Error(`Check unseen events failed: ${n.status}`)}}var it;(function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED"})(it||(it={}));class Ce{setConnectionStateListener(t){this.connectionStateListener=t}setIncomingDataListener(t){this.incomingDataListener=t}constructor(t,n=WebSocket){this.WebSocketClass=n,this.webSocket=null,this.isDisconnecting=!1,this.url=t.replace(/^http/,"ws"),this.instanceId=Ce.instanceCounter++,Ce.activeInstances.add(this.instanceId)}
51async connect(){if(this.webSocket)throw new Error("webSocket object is not null");if(this.isDisconnecting)throw new Error("WebSocket is disconnecting, cannot reconnect on same instance");return new Promise((t,n)=>{var r;let s;try{this.webSocket=s=new this.WebSocketClass(this.url)}catch(i){n(i);return}(r=this.connectionStateListener)===null||r===void 0||r.call(this,it.CONNECTING),s.onclose=i=>{var a;this.clearWebSocket(),s.readyState!==WebSocket.OPEN&&n(new Error(`websocket error ${i.code}: ${i.reason}`)),(a=this.connectionStateListener)===null||a===void 0||a.call(this,it.DISCONNECTED)},s.onopen=i=>{var a;t(),(a=this.connectionStateListener)===null||a===void 0||a.call(this,it.CONNECTED),Ce.pendingData.length>0&&([...Ce.pendingData].forEach(c=>this.sendData(c)),Ce.pendingData=[])},s.onmessage=i=>{var a,o;if(i.data==="h")(a=this.incomingDataListener)===null||a===void 0||a.call(this,{type:"Heartbeat"});else try{const c=JSON.parse(i.data);(o=this.incomingDataListener)===null||o===void 0||o.call(this,c)}catch{}}})}disconnect(){var t;const{webSocket:n}=this;if(n){this.isDisconnecting=!0,this.clearWebSocket(),(t=this.connectionStateListener)===null||t===void 0||t.call(this,it.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{n.close()}catch{}}}sendData(t){const{webSocket:n}=this;if(!n){Ce.pendingData.push(t),this.isDisconnecting||this.connect();return}if(n.readyState!==WebSocket.OPEN){Ce.pendingData.push(t);return}n.send(t)}clearWebSocket(){const{webSocket:t}=this;t&&(this.webSocket=null,t.onclose=null,t.onerror=null,t.onmessage=null,t.onopen=null)}cleanup(){Ce.activeInstances.delete(this.instanceId)}}Ce.instanceCounter=0;Ce.activeInstances=new Set;Ce.pendingData=[];const fd=1e4,WE=6e4;class KE{constructor({session:t,linkAPIUrl:n,listener:r}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=mt(1),this.reconnectAttempts=0,this.isReconnecting=!1,this._connected=!1,this._linked=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=i=>{if(!i)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",o=>i.JsonRpcUrl&&this.handleChainUpdated(o,i.JsonRpcUrl)]]).forEach((o,c)=>{const u=i[c];u!==void 0&&o(u)})},this.handleDestroyed=i=>{var a;i==="1"&&((a=this.listener)===null||a===void 0||a.resetAndReload())},this.handleAccountUpdated=async i=>{var a;try{const o=await this.cipher.decrypt(i);(a=this.listener)===null||a===void 0||a.accountUpdated(o)}catch{}},this.handleMetadataUpdated=async(i,a)=>{var o;try{const c=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.metadataUpdated(i,c)}catch{}},this.handleWalletUsernameUpdated=async i=>{this.handleMetadataUpdated(HE,i)},this.handleAppVersionUpdated=async i=>{this.handleMetadataUpdated(GE,i)},this.handleChainUpdated=async(i,a)=>{var o;try{const c=await this.cipher.decrypt(i),u=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.chainUpdated(c,u)}catch{}},this.session=t,this.cipher=new qE(t.secret),this.listener=r,this.linkAPIUrl=n,this.WebSocketClass=WebSocket;const s=this.createWebSocket();this.ws=s,this.http=new VE(n,t.id,t.key),this.setupVisibilityChangeHandler()}createWebSocket(){const t=new Ce(`${this.linkAPIUrl}/rpc`,this.WebSocketClass);return this.activeWsInstance=t,t.setConnectionStateListener(async n=>{if(t!==this.activeWsInstance)return;let r=!1;switch(n){case it.DISCONNECTED:this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.lastHeartbeatResponse=0,r=!1,this.destroyed||(async()=>{if(this.isReconnecting)return;this.isReconnecting=!0;const i=this.reconnectAttempts===0?0:3e3;await new Promise(a=>setTimeout(a,i)),!this.destroyed&&t===this.activeWsInstance?(this.reconnectAttempts++,"cleanup"in this.ws&&typeof this.ws.cleanup=="function"&&this.ws.cleanup(),this.ws=this.createWebSocket(),this.ws.connect().catch(()=>{cd()}).finally(()=>{this.isReconnecting=!1})):this.isReconnecting=!1})();break;case it.CONNECTED:this.reconnectAttempts=0;try{r=await this.handleConnected(),this.fetchUnseenEventsAPI().catch(()=>{})}catch{break}this.connected=r,this.updateLastHeartbeat(),this.heartbeatIntervalId&&clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=window.setInterval(()=>{this.heartbeat()},fd),setTimeout(()=>{this.heartbeat()},100);break;case it.CONNECTING:break}n!==it.CONNECTED&&(this.connected=r)}),t.setIncomingDataListener(n=>{var r;switch(n.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const s=n.type==="IsLinkedOK"?n.linked:void 0;this.linked=s||n.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(n.metadata);break}case"Event":{this.handleIncomingEvent(n);break}}n.id!==void 0&&((r=this.requestResolutions.get(n.id))===null||r===void 0||r(n))}),t}setupVisibilityChangeHandler(){this.visibilityChangeHandler=()=>{!document.hidden&&!this.destroyed&&(this.connected?this.heartbeat():this.reconnectWithFreshWebSocket())},this.focusHandler=()=>{!this.destroyed&&!this.connected&&this.reconnectWithFreshWebSocket()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),window.addEventListener("focus",this.focusHandler),window.addEventListener("pageshow",t=>{t.persisted&&this.focusHandler&&this.focusHandler()})}reconnectWithFreshWebSocket(){if(this.destroyed)return;const t=this.ws;this.activeWsInstance=void 0,t.disconnect(),"cleanup"in t&&typeof t.cleanup=="function"&&t.cleanup(),this.ws=this.createWebSocket(),this.ws.connect().catch(()=>{cd()})}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}
51async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:mt(this.nextReqId++),sessionId:this.session.id,metadata:{__destroyed:"1"}},{timeout:1e3}),this.destroyed=!0,this.activeWsInstance=void 0,this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.visibilityChangeHandler&&document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.focusHandler&&window.removeEventListener("focus",this.focusHandler),this.ws.disconnect(),"cleanup"in this.ws&&typeof this.ws.cleanup=="function"&&this.ws.cleanup(),this.listener=void 0)}get connected(){return this._connected}set connected(t){this._connected=t}get linked(){return this._linked}set linked(t){var n,r;this._linked=t,t&&((n=this.onceLinked)===null||n===void 0||n.call(this)),(r=this.listener)===null||r===void 0||r.linkedUpdated(t)}setOnceLinked(t){return new Promise(n=>{this.linked?t().then(n):this.onceLinked=()=>{t().then(n),this.onceLinked=void 0}})}async handleIncomingEvent(t){var n;if(!(t.type!=="Event"||t.event!=="Web3Response"))try{const r=await this.cipher.decrypt(t.data),s=JSON.parse(r);if(s.type!=="WEB3_RESPONSE")return;(n=this.listener)===null||n===void 0||n.handleWeb3ResponseMessage(s.id,s.response)}catch{}}async checkUnseenEvents(){await new Promise(t=>setTimeout(t,250));try{await this.fetchUnseenEventsAPI()}catch(t){console.error("Unable to check for unseen events",t)}}async fetchUnseenEventsAPI(){try{(await this.http.fetchUnseenEvents()).forEach(n=>{this.handleIncomingEvent(n)})}catch{UE()}}async publishEvent(t,n,r=!1){const s=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},n),{origin:location.origin,location:location.href,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),i={type:"PublishEvent",id:mt(this.nextReqId++),sessionId:this.session.id,event:t,data:s,callWebhook:r};return this.setOnceLinked(async()=>{const a=await this.makeRequest(i);if(a.type==="Fail")throw new Error(a.error||"failed to publish event");return a.eventId})}sendData(t){this.ws.sendData(JSON.stringify(t))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>fd*2){this.ws.disconnect();return}if(this.connected)try{this.ws.sendData("h")}catch{}}async makeRequest(t,n={timeout:WE}){const r=t.id;this.sendData(t);let s;return Promise.race([new Promise((i,a)=>{s=window.setTimeout(()=>{a(new Error(`request ${r} timed out`))},n.timeout)}),new Promise(i=>{this.requestResolutions.set(r,a=>{clearTimeout(s),i(a),this.requestResolutions.delete(r)})})])}async handleConnected(){return(await this.makeRequest({type:"HostSession",id:mt(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type==="Fail"?!1:(this.sendData({type:"IsLinked",id:mt(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:mt(this.nextReqId++),sessionId:this.session.id}),!0)}}class ZE{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const t=this._nextRequestId,n=rl(t.toString(16));return this.callbacks.get(n)&&this.callbacks.delete(n),t}}const pd="session:id",hd="session:secret",md="session:linked";class _n{constructor(t,n,r,s=!1){this.storage=t,this.id=n,this.secret=r,this.key=hh(mh(`${n}, ${r} WalletLink`)),this._linked=!!s}static create(t){const n=zt(16),r=zt(32);return new _n(t,n,r).save()}static load(t){const n=t.getItem(pd),r=t.getItem(md),s=t.getItem(hd);return n&&s?new _n(t,n,s,r==="1"):null}get linked(){return this._linked}set linked(t){this._linked=t,this.persistLinked()}save(){return this.storage.setItem(pd,this.id),this.storage.setItem(hd,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(md,this._linked?"1":"0")}}const YE=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}
51.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";class JE{constructor(){this.root=null,this.darkMode=al()}attach(){const t=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",t.appendChild(this.root),il()}present(t){this.render(t)}clear(){this.render(null)}render(t){this.root&&(Xi(null,this.root),t&&Xi(J(QE,Object.assign({},t,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const QE=({title:e,buttonText:t,darkMode:n,onButtonClick:r,onDismiss:s})=>{const i=n?"dark":"light";return J(cl,{darkMode:n},J("div",{class:"-cbwsdk-redirect-dialog"},J("style",null,YE),J("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:s}),J("div",{class:Kn("-cbwsdk-redirect-dialog-box",i)},J("p",null,e),J("button",{onClick:r},t))))};class yd{constructor(){this.attached=!1,this.redirectDialog=new JE}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(t){const n=new URL(em);n.searchParams.append("redirect_url",am().href),t&&n.searchParams.append("wl_url",t);const r=document.createElement("a");r.target="cbw-opener",r.href=n.href,r.rel="noreferrer noopener",r.click()}openCoinbaseWalletDeeplink(t){this.redirectToCoinbaseWallet(t),setTimeout(()=>{this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(t)}})},99)}showConnecting(t){return()=>{this.redirectDialog.clear()}}}class bt{constructor(t){this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=om(),this.linkedUpdated=i=>{this.isLinked=i;const a=this.storage.getItem(uo);if(i&&(this._session.linked=i),this.isUnlinkedErrorState=!1,a){const o=a.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";o[0]!==""&&!i&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(i,a)=>{this.storage.setItem(i,a)},this.chainUpdated=(i,a)=>{this.chainCallbackParams.chainId===i&&this.chainCallbackParams.jsonRpcUrl===a||(this.chainCallbackParams={chainId:i,jsonRpcUrl:a},this.chainCallback&&this.chainCallback(a,Number.parseInt(i,10)))},this.accountUpdated=i=>{this.accountsCallback&&this.accountsCallback([i]),bt.accountRequestCallbackIds.size>0&&(Array.from(bt.accountRequestCallbackIds.values()).forEach(a=>{this.invokeCallback(a,{method:"requestEthereumAccounts",result:[i]})}),bt.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=t.linkAPIUrl,this.storage=t.storage,this.metadata=t.metadata,this.accountsCallback=t.accountsCallback,this.chainCallback=t.chainCallback;const{session:n,ui:r,connection:s}=this.subscribe();this._session=n,this.connection=s,this.relayEventManager=new ZE,this.ui=r,this.ui.attach()}subscribe(){const t=_n.load(this.storage)||_n.create(this.storage),{linkAPIUrl:n}=this,r=new KE({session:t,linkAPIUrl:n,listener:this}),s=this.isMobileWeb?new yd:new fm;return r.connect(),{session:t,ui:s,connection:r}}resetAndReload(){this.connection.destroy().then(()=>{const t=_n.load(this.storage);t?.id===this._session.id&&Qt.clearAll(),document.location.reload()}).catch(t=>{})}signEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:Xe(t.weiValue),data:Zn(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?Xe(t.gasPriceInWei):null,maxFeePerGas:t.gasPriceInWei?Xe(t.gasPriceInWei):null,maxPriorityFeePerGas:t.gasPriceInWei?Xe(t.gasPriceInWei):null,gasLimit:t.gasLimit?Xe(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:Xe(t.weiValue),data:Zn(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?Xe(t.gasPriceInWei):null,maxFeePerGas:t.maxFeePerGas?Xe(t.maxFeePerGas):null,maxPriorityFeePerGas:t.maxPriorityFeePerGas?Xe(t.maxPriorityFeePerGas):null,gasLimit:t.gasLimit?Xe(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!0}})}submitEthereumTransaction(t,n){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:Zn(t,!0),chainId:n}})}getWalletLinkSession(){return this._session}sendRequest(t){let n=null;const r=zt(8),s=i=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,t.method,i),n?.()};return new Promise((i,a)=>{n=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:s,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(r,o=>{if(n?.(),ye(o))return a(new Error(o.errorMessage));i(o)}),this.publishWeb3RequestEvent(r,t)})}publishWeb3RequestEvent(t,n){const r={type:"WEB3_REQUEST",id:t,request:n};this.publishEvent("Web3Request",r,!0).then(s=>{}).catch(s=>{this.handleWeb3ResponseMessage(r.id,{method:n.method,errorMessage:s.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(n.method)}openCoinbaseWalletDeeplink(t){if(this.ui instanceof yd)switch(t){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(t){const n={type:"WEB3_REQUEST_CANCELED",id:t};this.publishEvent("Web3RequestCanceled",n,!1).then()}publishEvent(t,n,r){return this.connection.publishEvent(t,n,r)}handleWeb3ResponseMessage(t,n){if(n.method==="requestEthereumAccounts"){bt.accountRequestCallbackIds.forEach(r=>this.invokeCallback(r,n)),bt.accountRequestCallbackIds.clear();return}this.invokeCallback(t,n)}handleErrorResponse(t,n,r){var s;const i=(s=r?.message)!==null&&s!==void 0?s:"Unspecified error message.";this.handleWeb3ResponseMessage(t,{method:n,errorMessage:i})}invokeCallback(t,n){const r=this.relayEventManager.callbacks.get(t);r&&(r(n),this.relayEventManager.callbacks.delete(t))}requestEthereumAccounts(){const{appName:t,appLogoUrl:n}=this.metadata,r={method:"requestEthereumAccounts",params:{appName:t,appLogoUrl:n}},s=zt(8);return new Promise((i,a)=>{this.relayEventManager.callbacks.set(s,o=>{if(ye(o))return a(new Error(o.errorMessage));i(o)}),bt.accountRequestCallbackIds.add(s),this.publishWeb3RequestEvent(s,r)})}watchAsset(t,n,r,s,i,a){const o={method:"watchAsset",params:{type:t,options:{address:n,symbol:r,decimals:s,image:i},chainId:a}};let c=null;const u=zt(8),l=d=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,o.method,d),c?.()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:l,onResetConnection:this.resetAndReload}),new Promise((d,f)=>{this.relayEventManager.callbacks.set(u,p=>{if(c?.(),ye(p))return f(new Error(p.errorMessage));d(p)}),this.publishWeb3RequestEvent(u,o)})}addEthereumChain(t,n,r,s,i,a){const o={method:"addEthereumChain",params:{chainId:t,rpcUrls:n,blockExplorerUrls:s,chainName:i,iconUrls:r,nativeCurrency:a}};let c=null;const u=zt(8),l=d=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,o.method,d),c?.()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:l,onResetConnection:this.resetAndReload}),new Promise((d,f)=>{this.relayEventManager.callbacks.set(u,p=>{if(c?.(),ye(p))return f(new Error(p.errorMessage));d(p)}),this.publishWeb3RequestEvent(u,o)})}switchEthereumChain(t,n){const r={method:"switchEthereumChain",params:Object.assign({chainId:t},{address:n})};let s=null;const i=zt(8),a=o=>{this.publishWeb3RequestCanceledEvent(i),this.handleErrorResponse(i,r.method,o),s?.()};return s=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:a,onResetConnection:this.resetAndReload}),new Promise((o,c)=>{this.relayEventManager.callbacks.set(i,u=>{if(s?.(),ye(u)&&u.errorCode)return c(j.provider.custom({code:u.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if(ye(u))return c(new Error(u.errorMessage));o(u)}),this.publishWeb3RequestEvent(i,r)})}}bt.accountRequestCallbackIds=new Set;const gd="DefaultChainId",bd="DefaultJsonRpcUrl";class uh{constructor(t){this._relay=null,this._addresses=[],this.metadata=t.metadata,this._storage=new Qt("walletlink",Hc),this.callback=t.callback||null;const n=this._storage.getItem(uo);if(n){const r=n.split(" ");r[0]!==""&&(this._addresses=r.map(s=>At(s)))}this.initializeRelay()}getSession(){const t=this.initializeRelay(),{id:n,secret:r}=t.getWalletLinkSession();return{id:n,secret:r}}async handshake(t){const n="eth_requestAccounts",r=Ke.get(t);$E({method:n,correlationId:r});try{await this._eth_requestAccounts(),ME({method:n,correlationId:r})}catch(s){throw NE({method:n,correlationId:r,errorMessage:Ft(s)}),s}}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var t;return(t=this._storage.getItem(bd))!==null&&t!==void 0?t:void 0}set jsonRpcUrl(t){this._storage.setItem(bd,t)}updateProviderInfo(t,n){var r;this.jsonRpcUrl=t;const s=this.getChainId();this._storage.setItem(gd,n.toString(10)),Yn(n)!==s&&((r=this.callback)===null||r===void 0||r.call(this,"chainChanged",yn(n)))}async watchAsset(t){const n=Array.isArray(t)?t[0]:t;if(!n.type)throw j.rpc.invalidParams("Type is required");if(n?.type!=="ERC20")throw j.rpc.invalidParams(`Asset of type '${n.type}' is not supported`);if(!n?.options)throw j.rpc.invalidParams("Options are required");if(!n?.options.address)throw j.rpc.invalidParams("Address is required");const r=this.getChainId(),{address:s,symbol:i,image:a,decimals:o}=n.options,u=await this.initializeRelay().watchAsset(n.type,s,i,o,a,r?.toString());return ye(u)?!1:!!u.result}async addEthereumChain(t){var n,r;const s=t[0];if(((n=s.rpcUrls)===null||n===void 0?void 0:n.length)===0)throw j.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!s.chainName||s.chainName.trim()==="")throw j.rpc.invalidParams("chainName is a required field");if(!s.nativeCurrency)throw j.rpc.invalidParams("nativeCurrency is a required field");const i=Number.parseInt(s.chainId,16);if(i===this.getChainId())return!1;const a=this.initializeRelay(),{rpcUrls:o=[],blockExplorerUrls:c=[],chainName:u,iconUrls:l=[],nativeCurrency:d}=s,f=await a.addEthereumChain(i.toString(),o,l,c,u,d);if(ye(f))return!1;if(((r=f.result)===null||r===void 0?void 0:r.isApproved)===!0)return this.updateProviderInfo(o[0],i),null;throw j.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(t){const n=t[0],r=Number.parseInt(n.chainId,16),i=await this.initializeRelay().switchEthereumChain(r.toString(10),this.selectedAddress||void 0);if(ye(i))throw i;const a=i.result;return a.isApproved&&a.rpcUrl.length>0&&this.updateProviderInfo(a.rpcUrl,r),null}async cleanup(){this.callback=null,this._relay&&this._relay.resetAndReload(),this._storage.clear()}_setAddresses(t,n){var r;if(!Array.isArray(t))throw new Error("addresses is not an array");const s=t.map(i=>At(i));JSON.stringify(s)!==JSON.stringify(this._addresses)&&(this._addresses=s,(r=this.callback)===null||r===void 0||r.call(this,"accountsChanged",s),this._storage.setItem(uo,s.join(" ")))}async request(t){const n=Ke.get(t);RE({method:t.method,correlationId:n});try{const r=await this._request(t);return LE({method:t.method,correlationId:n}),r}catch(r){throw jE({method:t.method,correlationId:n,errorMessage:Ft(r)}),r}}async _request(t){const n=t.params||[];switch(t.method){case"eth_accounts":return[...this._addresses];case"eth_coinbase":return this.selectedAddress||null;case"net_version":return this.getChainId().toString(10);case"eth_chainId":return yn(this.getChainId());case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_ecRecover":case"personal_ecRecover":return this.ecRecover(t);case"personal_sign":return this.personalSign(t);case"eth_signTransaction":return this._eth_signTransaction(n);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(n);case"eth_sendTransaction":return this._eth_sendTransaction(n);case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":return this.signTypedData(t);case"wallet_addEthereumChain":return this.addEthereumChain(n);case"wallet_switchEthereumChain":return this.switchEthereumChain(n);case"wallet_watchAsset":return this.watchAsset(n);default:if(!this.jsonRpcUrl)throw j.rpc.internal("No RPC URL set for chain");return Jn(t,this.jsonRpcUrl)}}_ensureKnownAddress(t){const n=At(t);if(!this._addresses.map(s=>At(s)).includes(n))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(t){const n=t.from?At(t.from):this.selectedAddress;if(!n)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(n);const r=t.to?At(t.to):null,s=t.value!=null?Hn(t.value):BigInt(0),i=t.data?ia(t.data):Q.alloc(0),a=t.nonce!=null?Yn(t.nonce):null,o=t.gasPrice!=null?Hn(t.gasPrice):null,c=t.maxFeePerGas!=null?Hn(t.maxFeePerGas):null,u=t.maxPriorityFeePerGas!=null?Hn(t.maxPriorityFeePerGas):null,l=t.gas!=null?Hn(t.gas):null,d=t.chainId?Yn(t.chainId):this.getChainId();return{fromAddress:n,toAddress:r,weiValue:s,data:i,nonce:a,gasPriceInWei:o,maxFeePerGas:c,maxPriorityFeePerGas:u,gasLim
51it:l,chainId:d}}async ecRecover(t){const{method:n,params:r}=t;if(!Array.isArray(r))throw j.rpc.invalidParams();const i=await this.initializeRelay().sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:mi(r[0]),signature:mi(r[1]),addPrefix:n==="personal_ecRecover"}});if(ye(i))throw i;return i.result}getChainId(){var t;return Number.parseInt((t=this._storage.getItem(gd))!==null&&t!==void 0?t:"1",10)}async _eth_requestAccounts(){var t,n;if(this._addresses.length>0)return(t=this.callback)===null||t===void 0||t.call(this,"connect",{chainId:yn(this.getChainId())}),this._addresses;const s=await this.initializeRelay().requestEthereumAccounts();if(ye(s))throw s;if(!s.result)throw new Error("accounts received is empty");return this._setAddresses(s.result),(n=this.callback)===null||n===void 0||n.call(this,"connect",{chainId:yn(this.getChainId())}),this._addresses}async personalSign({params:t}){if(!Array.isArray(t))throw j.rpc.invalidParams();const n=t[1],r=t[0];this._ensureKnownAddress(n);const i=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:At(n),message:mi(r),addPrefix:!0,typedDataJson:null}});if(ye(i))throw i;return i.result}async _eth_signTransaction(t){const n=this._prepareTransactionParams(t[0]||{}),s=await this.initializeRelay().signEthereumTransaction(n);if(ye(s))throw s;return s.result}async _eth_sendRawTransaction(t){const n=ia(t[0]),s=await this.initializeRelay().submitEthereumTransaction(n,this.getChainId());if(ye(s))throw s;return s.result}async _eth_sendTransaction(t){const n=this._prepareTransactionParams(t[0]||{}),s=await this.initializeRelay().signAndSubmitEthereumTransaction(n);if(ye(s))throw s;return s.result}async signTypedData(t){const{method:n,params:r}=t;if(!Array.isArray(r))throw j.rpc.invalidParams();const s=u=>{const l={eth_signTypedData_v1:ss.hashForSignTypedDataLegacy,eth_signTypedData_v3:ss.hashForSignTypedData_v3,eth_signTypedData_v4:ss.hashForSignTypedData_v4,eth_signTypedData:ss.hashForSignTypedData_v4};return Zn(l[n]({data:F0(u)}),!0)},i=r[n==="eth_signTypedData_v1"?1:0],a=r[n==="eth_signTypedData_v1"?0:1];this._ensureKnownAddress(i);const c=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:At(i),message:s(a),typedDataJson:JSON.stringify(a,null,2),addPrefix:!1}});if(ye(c))throw c;return c.result}initializeRelay(){return this._relay||(this._relay=new bt({linkAPIUrl:Hc,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}const dh="SignerType",lh=new Qt("CBWSDK","SignerConfigurator");function XE(){return lh.getItem(dh)}function e_(e){lh.setItem(dh,e)}function wd(e){if(e)return e instanceof oh?"scw":"walletlink"}async function t_(e){const{communicator:t,metadata:n,handshakeRequest:r,callback:s}=e;r_(t,n,s,r).catch(()=>{});const i={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},e.preference),{handshakeRequest:r})},{data:a}=await t.postRequestAndWaitForResponse(i);return a}function n_(e){const{signerType:t,metadata:n,communicator:r,callback:s}=e;switch(t){case"scw":return new oh({metadata:n,callback:s,communicator:r});case"walletlink":return new uh({metadata:n,callback:s})}}async function r_(e,t,n,r){await e.onMessage(({event:i})=>i==="WalletLinkSessionRequest");const s=new uh({metadata:t,callback:n});e.postMessage({event:"WalletLinkUpdate",data:{session:s.getSession()}}),await s.handshake(r),e.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}var s_=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n};class i_ extends xm{constructor(t){var{metadata:n}=t,r=t.preference,{keysUrl:s}=r,i=s_(r,["keysUrl"]);super(),this.signer=null,this.isCoinbaseWallet=!0,this.metadata=n,this.preference=i,this.communicator=new bm({url:s,metadata:n,preference:i});const a=XE();a&&(this.signer=this.initSigner(a),Em({signerType:a}))}async request(t){const n=crypto.randomUUID();Ke.set(t,n),_m({method:t.method,correlationId:n});try{const r=await this._request(t);return Am({method:t.method,signerType:wd(this.signer),correlationId:n}),r}catch(r){throw Sm({method:t.method,correlationId:n,signerType:wd(this.signer),errorMessage:r instanceof Error?r.message:""}),r}finally{Ke.delete(t)}}async _request(t){try{if(J0(t),!this.signer)switch(t.method){case"eth_requestAccounts":{let r;const s=L.subAccountsConfig.get();s?.enableAutoSubAccounts?r="scw":r=await this.requestSignerSelection(t);const i=this.initSigner(r);r==="scw"&&s?.enableAutoSubAccounts?(await i.handshake({method:"handshake"}),await i.request(t)):await i.handshake(t),this.signer=i,e_(r);break}case"wallet_connect":{const r=this.initSigner("scw");await r.handshake({method:"handshake"});const s=await r.request(t);return this.signer=r,s}case"wallet_sendCalls":case"wallet_sign":{const r=this.initSigner("scw");await r.handshake({method:"handshake"});const s=await r.request(t);return await r.cleanup(),s}case"wallet_getCallsStatus":return await Jn(t,sl);case"net_version":return 1;case"eth_chainId":return yn(1);default:throw j.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")}return await this.signer.request(t)}catch(n){const{code:r}=n;return r===se.provider.unauthorized&&this.disconnect(),Promise.reject(wm(n))}}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),km(),await this.request({method:"eth_requestAccounts"})}async disconnect(){var t;await((t=this.signer)===null||t===void 0?void 0:t.cleanup()),this.signer=null,Qt.clearAll(),Ke.clear(),this.emit
51("disconnect",j.provider.disconnected("User initiated disconnection"))}async requestSignerSelection(t){Im();const n=await t_({communicator:this.communicator,preference:this.preference,metadata:this.metadata,handshakeRequest:t,callback:this.emit.bind(this)});return Pm(n),n}initSigner(t){return n_({signerType:t,metadata:this.metadata,communicator:this.communicator,callback:this.emit.bind(this)})}}function a_(e){var t;const n={metadata:e.metadata,preference:e.preference};return(t=Y0(n))!==null&&t!==void 0?t:new i_(n)}const o_={options:"all"};function c_(e){var t,n,r,s;const i={metadata:{appName:e.appName||"Dapp",appLogoUrl:e.appLogoUrl||"",appChainIds:e.appChainIds||[]},preference:Object.assign(o_,(t=e.preference)!==null&&t!==void 0?t:{}),paymasterUrls:e.paymasterUrls};!((n=e.subAccounts)===null||n===void 0)&&n.toOwnerAccount&&Fc(e.subAccounts.toOwnerAccount),L.subAccountsConfig.set({toOwnerAccount:(r=e.subAccounts)===null||r===void 0?void 0:r.toOwnerAccount,enableAutoSubAccounts:(s=e.subAccounts)===null||s===void 0?void 0:s.enableAutoSubAccounts}),L.config.set(i),L.persist.rehydrate(),V0(),i.preference.telemetry!==!1&&N0(),Q0(i.preference);let a=null;const o={getProvider(){return a||(a=a_(i)),a.sdk=o,a},subAccount:{async create(c){var u,l;const d=L.getState();return Be((u=d.subAccount)===null||u===void 0?void 0:u.address,new Error("subaccount already exists")),await((l=o.getProvider())===null||l===void 0?void 0:l.request({method:"wallet_addSubAccount",params:[{version:"1",account:c}]}))},async get(){var c,u;const l=L.subAccounts.get();if(l?.address)return l;const f=(u=(await((c=o.getProvider())===null||c===void 0?void 0:c.request({method:"wallet_connect",params:[{version:"1",capabilities:{}}]}))).accounts[0].capabilities)===null||u===void 0?void 0:u.subAccounts;return Array.isArray(f)?f[0]:null},async addOwner({address:c,publicKey:u,chainId:l}){var d,f;const p=L.subAccounts.get(),y=L.account.get();Be(y,new Error("account does not exist")),Be(p?.address,new Error("subaccount does not exist"));const h=[];if(u){const[m,g]=cn([{type:"bytes32"},{type:"bytes32"}],u);h.push({to:p.address,data:he({abi:Ye,functionName:"addOwnerPublicKey",args:[m,g]}),value:_e(0)})}return c&&h.push({to:p.address,data:he({abi:Ye,functionName:"addOwnerAddress",args:[c]}),value:_e(0)}),await((d=o.getProvider())===null||d===void 0?void 0:d.request({method:"wallet_sendCalls",params:[{calls:h,chainId:_e(l),from:(f=y.accounts)===null||f===void 0?void 0:f[0],version:"1"}]}))},setToOwnerAccount(c){Fc(c),L.subAccountsConfig.set({toOwnerAccount:c})}}};return o}const z_=Object.freeze(Object.defineProperty({__proto__:null,createCoinbaseWalletSDK:c_,getCryptoKeyAccount:Ms},Symbol.toStringTag,{value:"Module"}));export{_ as B,Qn as H,qb as a,ve as b,Ys as c,Dl as d,$e as e,we as f,$o as g,z_ as h,Rr as i,Qo as l,fe as s};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.