UNPKG

@hooded-hub/abstract-name-service-snap

Version:

MetaMask Snap to resolve .abs domain names from the Abstract Naming Service.

1 lines 263 kB
(()=>{var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e),t.d(e,{onRpcRequest:()=>Yl,onTransaction:()=>_l});var n={};t.r(n),t.d(n,{OG:()=>ho,My:()=>no,Ph:()=>io,lX:()=>ao,Id:()=>uo,fg:()=>go,qj:()=>lo,aT:()=>so,lq:()=>oo,z:()=>co,Q5:()=>yo});class r extends TypeError{constructor(t,e){let n;const{message:r,explanation:s,...i}=t,{path:a}=t,o=0===a.length?r:`At path: ${a.join(".")} -- ${r}`;super(s??o),null!=s&&(this.cause=o),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...e()])}}function s(t){return"object"==typeof t&&null!==t}function i(t){return"symbol"==typeof t?t.toString():"string"==typeof t?JSON.stringify(t):`${t}`}function a(t,e,n,r){if(!0===t)return;!1===t?t={}:"string"==typeof t&&(t={message:t});const{path:s,branch:a}=e,{type:o}=n,{refinement:c,message:l=`Expected a value of type \`${o}\`${c?` with refinement \`${c}\``:""}, but received: \`${i(r)}\``}=t;return{value:r,type:o,refinement:c,key:s[s.length-1],path:s,branch:a,...t,message:l}}function*o(t,e,n,r){(function(t){return s(t)&&"function"==typeof t[Symbol.iterator]})(t)||(t=[t]);for(const s of t){const t=a(s,e,n,r);t&&(yield t)}}function*c(t,e,n={}){const{path:r=[],branch:i=[t],coerce:a=!1,mask:o=!1}=n,l={path:r,branch:i};if(a&&(t=e.coercer(t,l),o&&"type"!==e.type&&s(e.schema)&&s(t)&&!Array.isArray(t)))for(const n in t)void 0===e.schema[n]&&delete t[n];let u="valid";for(const r of e.validator(t,l))r.explanation=n.message,u="not_valid",yield[r,void 0];for(let[h,f,d]of e.entries(t,l)){const e=c(f,d,{path:void 0===h?r:[...r,h],branch:void 0===h?i:[...i,f],coerce:a,mask:o,message:n.message});for(const n of e)n[0]?(u=null===n[0].refinement||void 0===n[0].refinement?"not_valid":"not_refined",yield[n[0],void 0]):a&&(f=n[1],void 0===h?t=f:t instanceof Map?t.set(h,f):t instanceof Set?t.add(f):s(t)&&(void 0!==f||h in t)&&(t[h]=f))}if("not_valid"!==u)for(const r of e.refiner(t,l))r.explanation=n.message,u="not_refined",yield[r,void 0];"valid"===u&&(yield[void 0,t])}class l{constructor(t){const{type:e,schema:n,validator:r,refiner:s,coercer:i=t=>t,entries:a=function*(){}}=t;this.type=e,this.schema=n,this.entries=a,this.coercer=i,this.validator=r?(t,e)=>o(r(t,e),e,this,t):()=>[],this.refiner=s?(t,e)=>o(s(t,e),e,this,t):()=>[]}assert(t,e){return u(t,this,e)}create(t,e){return function(t,e,n){const r=f(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}(t,this,e)}is(t){return h(t,this)}mask(t,e){return function(t,e,n){const r=f(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(t,this,e)}validate(t,e={}){return f(t,this,e)}}function u(t,e,n){const r=f(t,e,{message:n});if(r[0])throw r[0]}function h(t,e){return!f(t,e)[0]}function f(t,e,n={}){const s=c(t,e,n),i=function(t){const{done:e,value:n}=t.next();return e?void 0:n}(s);if(i[0]){return[new r(i[0],(function*(){for(const t of s)t[0]&&(yield t[0])})),void 0]}return[void 0,i[1]]}function d(t){return new l({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||`Expected an array value, but received: ${i(t)}`})}function p(){return E("boolean",(t=>"boolean"==typeof t))}function g(t){const e=i(t),n=typeof t;return new l({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?t:null,validator:n=>n===t||`Expected the literal \`${e}\`, but received: ${i(n)}`})}function m(){return E("never",(()=>!1))}function y(t){const e=t?Object.keys(t):[],n=m();return new l({type:"object",schema:t??null,*entries(r){if(t&&s(r)){const s=new Set(Object.keys(r));for(const n of e)s.delete(n),yield[n,r[n],t[n]];for(const t of s)yield[t,r[t],n]}},validator:t=>s(t)||`Expected an object, but received: ${i(t)}`,coercer:t=>s(t)?{...t}:t})}function w(t){return new l({...t,validator:(e,n)=>void 0===e||t.validator(e,n),refiner:(e,n)=>void 0===e||t.refiner(e,n)})}function b(){return E("string",(t=>"string"==typeof t||`Expected a string, but received: ${i(t)}`))}function A(t){const e=t.map((t=>t.type)).join(" | ");return new l({type:"union",schema:null,coercer(e){for(const n of t){const[t,r]=n.validate(e,{coerce:!0});if(!t)return r}return e},validator(n,r){const s=[];for(const e of t){const[...t]=c(n,e,r),[i]=t;if(!i?.[0])return[];for(const[e]of t)e&&s.push(e)}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${i(n)}`,...s]}})}function v(...t){const e="type"===t[0]?.type,n=t.map((({schema:t})=>t)),r=Object.assign({},...n);return e?function(t){const e=Object.keys(t);return new l({type:"type",schema:t,*entries(n){if(s(n))for(const r of e)yield[r,n[r],t[r]]},validator:t=>s(t)||`Expected an object, but received: ${i(t)}`,coercer:t=>s(t)?{...t}:t})}(r):y(r)}function E(t,e){return new l({type:t,schema:null,validator:e})}const x=(t,e)=>Object.hasOwnProperty.call(t,e);var k;!function(t){t[t.Null=4]="Null",t[t.Comma=1]="Comma",t[t.Wrapper=1]="Wrapper",t[t.True=4]="True",t[t.False=5]="False",t[t.Quote=1]="Quote",t[t.Colon=1]="Colon",t[t.Date=24]="Date"}(k=k||(k={}));function P(t){if("object"!=typeof t||null===t)return!1;try{let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}catch(t){return!1}}function N(t){return e=t,E(JSON.stringify(e),g(e).validator);var e}Error;function B(t){return function(t){return function(t){return"object"==typeof t&&null!==t&&"message"in t}(t)&&"string"==typeof t.message?t.message:null==t?"":String(t)}(t).replace(/\.$/u,"")}function I(t,e){return n=t,Boolean("string"==typeof n?.prototype?.constructor?.name)?new t({message:e}):t({message:e});var n}class C extends Error{constructor(t){super(t.message),this.code="ERR_ASSERTION"}}function O(t,e,n="Assertion failed",r=C){try{u(t,e)}catch(t){throw I(r,`${n}: ${B(t)}.`)}}function R(t,e,n=[]){return(...r)=>{if(1===r.length&&P(r[0])){const n={...r[0],type:t};return O(n,e,`Invalid ${t} component`),n}const s=n.reduce(((t,e,n)=>void 0!==r[n]?{...t,[e]:r[n]}:t),{type:t});return O(s,e,`Invalid ${t} component`),s}}var T;!function(t){t.Copyable="copyable",t.Divider="divider",t.Heading="heading",t.Panel="panel",t.Spinner="spinner",t.Text="text",t.Image="image",t.Row="row",t.Address="address",t.Button="button",t.Input="input",t.Form="form"}(T||(T={}));const S=y({type:b()}),F=v(S,y({value:E("unknown",(()=>!0))}));function D(t,e){return U(t,"pattern",(n=>e.test(n)||`Expected a ${t.type} matching \`/${e.source}/\` but received "${n}"`))}function U(t,e,n){return new l({...t,*refiner(r,s){yield*t.refiner(r,s);const i=o(n(r,s),s,t,r);for(const t of i)yield{...t,refinement:e}}})}D(b(),/^(?:0x)?[0-9a-f]+$/iu),D(b(),/^0x[0-9a-f]+$/iu),D(b(),/^0x[0-9a-f]{40}$/u);const L=D(b(),/^0x[0-9a-fA-F]{40}$/u);const M=v(F,y({type:g(T.Address),value:L}));R(T.Address,M,["value"]);var G,H;!function(t){t.Primary="primary",t.Secondary="secondary"}(G||(G={})),function(t){t.Button="button",t.Submit="submit"}(H||(H={}));const Q=v(F,y({type:g(T.Button),value:b(),variant:w(A([N(G.Primary),N(G.Secondary)])),buttonType:w(A([N(H.Button),N(H.Submit)])),name:w(b())})),j=(R(T.Button,Q,["value","buttonType","name","variant"]),v(F,y({type:g(T.Copyable),value:b(),sensitive:w(p())}))),z=R(T.Copyable,j,["value","sensitive"]),V=v(S,y({type:g(T.Divider)})),J=R(T.Divider,V);var K;!function(t){t.Text="text",t.Number="number",t.Password="password"}(K||(K={}));const q=v(F,y({type:g(T.Input),value:w(b()),name:b(),inputType:w(A([N(K.Text),N(K.Password),N(K.Number)])),placeholder:w(b()),label:w(b()),error:w(b())})),Z=(R(T.Input,q,["name","inputType","placeholder","value","label"]),A([q,Q])),_=v(S,y({type:g(T.Form),children:d(Z),name:b()})),Y=(R(T.Form,_,["name","children"]),v(F,y({type:g(T.Heading),value:b()}))),W=R(T.Heading,Y,["value"]);const X=v(S,y({type:g(T.Image),value:U(b(),"SVG",(t=>!!t.includes("<svg")||"Value is not a valid SVG."))})),$=(R(T.Image,X,["value"]),v(F,y({type:g(T.Text),value:b(),markdown:w(p())}))),tt=R(T.Text,$,["value","markdown"]);var et;!function(t){t.Default="default",t.Critical="critical",t.Warning="warning"}(et||(et={}));const nt=A([X,$,M]),rt=v(F,y({type:g(T.Row),variant:w(A([N(et.Default),N(et.Critical),N(et.Warning)])),label:b(),value:nt})),st=(R(T.Row,rt,["label","value","variant"]),v(S,y({type:g(T.Spinner)}))),it=(R(T.Spinner,st),v(S,y({children:d(function(t){let e;return new l({type:"lazy",schema:null,*entries(n,r){e??(e=t()),yield*e.entries(n,r)},validator:(n,r)=>(e??(e=t()),e.validator(n,r)),coercer:(n,r)=>(e??(e=t()),e.coercer(n,r)),refiner:(n,r)=>(e??(e=t()),e.refiner(n,r))})}((()=>ct)))}))),at=v(it,y({type:g(T.Panel)})),ot=R(T.Panel,at,["children"]),ct=function(t){const e=t.map((t=>"union"===t.type&&Array.isArray(t.schema)?t.schema:t)).flat(1/0),n=e.map((({schema:t})=>t.type.type));return new l({type:"union",schema:e,*entries(t,n){if(!P(t)||!x(t,"type"))return;const{type:r}=t,s=e.find((({schema:t})=>h(r,t.type)));if(s)for(const e of s.entries(t,n))yield e},coercer(t,n){if(!P(t)||!x(t,"type"))return t;const{type:r}=t,s=e.find((({schema:t})=>h(r,t.type)));return s?s.coercer(t,n):t},*refiner(t,n){const r=e.find((({schema:e})=>h(t.type,e.type)));yield*r.refiner(t,n)},validator(t,r){if(!P(t)||!x(t,"type")||"string"!=typeof t.type)return`Expected type to be one of: ${n.join(", ")}, but received: undefined`;const{type:s}=t,i=e.find((({schema:t})=>h(s,t.type)));return i?i.validator(t,r):`Expected type to be one of: ${n.join(", ")}, but received: "${s}"`}})}([j,V,Y,X,at,st,$,rt,M,q,_,Q]),lt="0x0ebc94534Eda78332E49F3bFa3a2471e52FaDfbf",ut="https://api.mainnet.abs.xyz/",ht="abs";function ft(t,e,n){const r=e.split("|").map((t=>t.trim()));for(let n=0;n<r.length;n++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof t===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${n}`,s.value=t,s}async function dt(t){const e=Object.keys(t);return(await Promise.all(e.map((e=>Promise.resolve(t[e]))))).reduce(((t,n,r)=>(t[e[r]]=n,t)),{})}function pt(t,e,n){for(let r in e){let s=e[r];const i=n?n[r]:null;i&&ft(s,i,r),Object.defineProperty(t,r,{enumerable:!0,value:s,writable:!1})}}function gt(t){if(null==t)return"null";if(Array.isArray(t))return"[ "+t.map(gt).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let n="0x";for(let r=0;r<t.length;r++)n+=e[t[r]>>4],n+=e[15&t[r]];return n}if("object"==typeof t&&"function"==typeof t.toJSON)return gt(t.toJSON());switch(typeof t){case"boolean":case"symbol":case"number":return t.toString();case"bigint":return BigInt(t).toString();case"string":return JSON.stringify(t);case"object":{const e=Object.keys(t);return e.sort(),"{ "+e.map((e=>`${gt(e)}: ${gt(t[e])}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function mt(t,e){return t&&t.code===e}function yt(t){return mt(t,"CALL_EXCEPTION")}function wt(t,e,n){let r,s=t;{const r=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${gt(n)}`);for(const t in n){if("shortMessage"===t)continue;const e=n[t];r.push(t+"="+gt(e))}}r.push(`code=${e}`),r.push("version=6.13.6"),r.length&&(t+=" ("+r.join(", ")+")")}switch(e){case"INVALID_ARGUMENT":r=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(t);break;default:r=new Error(t)}return pt(r,{code:e}),n&&Object.assign(r,n),null==r.shortMessage&&pt(r,{shortMessage:s}),r}function bt(t,e,n,r){if(!t)throw wt(e,n,r)}function At(t,e,n,r){bt(t,e,"INVALID_ARGUMENT",{argument:n,value:r})}function vt(t,e,n){null==n&&(n=""),n&&(n=": "+n),bt(t>=e,"missing argument"+n,"MISSING_ARGUMENT",{count:t,expectedCount:e}),bt(t<=e,"too many arguments"+n,"UNEXPECTED_ARGUMENT",{count:t,expectedCount:e})}const Et=["NFD","NFC","NFKD","NFKC"].reduce(((t,e)=>{try{if("test"!=="test".normalize(e))throw new Error("bad");if("NFD"===e){const t=String.fromCharCode(233).normalize("NFD");if(t!==String.fromCharCode(101,769))throw new Error("broken")}t.push(e)}catch(t){}return t}),[]);function xt(t,e,n){if(null==n&&(n=""),t!==e){let t=n,e="new";n&&(t+=".",e+=" "+n),bt(!1,`private constructor; use ${t}from* methods`,"UNSUPPORTED_OPERATION",{operation:e})}}function kt(t,e,n){if(t instanceof Uint8Array)return n?new Uint8Array(t):t;if("string"==typeof t&&t.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const e=new Uint8Array((t.length-2)/2);let n=2;for(let r=0;r<e.length;r++)e[r]=parseInt(t.substring(n,n+2),16),n+=2;return e}At(!1,"invalid BytesLike value",e||"value",t)}function Pt(t,e){return kt(t,e,!1)}function Nt(t,e){return kt(t,e,!0)}function Bt(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(("number"!=typeof e||t.length===2+2*e)&&(!0!==e||t.length%2==0))}function It(t){return Bt(t,!0)||t instanceof Uint8Array}const Ct="0123456789abcdef";function Ot(t){const e=Pt(t);let n="0x";for(let t=0;t<e.length;t++){const r=e[t];n+=Ct[(240&r)>>4]+Ct[15&r]}return n}function Rt(t){return"0x"+t.map((t=>Ot(t).substring(2))).join("")}function Tt(t){return Bt(t,!0)?(t.length-2)/2:Pt(t).length}function St(t,e,n){const r=Pt(t);return null!=n&&n>r.length&&bt(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n}),Ot(r.slice(null==e?0:e,null==n?r.length:n))}function Ft(t,e,n){const r=Pt(t);bt(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),n?s.set(r,e-r.length):s.set(r,0),Ot(s)}function Dt(t,e){return Ft(t,e,!0)}const Ut=BigInt(0),Lt=BigInt(1),Mt=9007199254740991;function Gt(t,e){let n=Qt(t,"value");const r=BigInt(Jt(e,"width")),s=Lt<<r-Lt;if(n<Ut){n=-n,bt(n<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});return(~n&(Lt<<r)-Lt)+Lt}return bt(n<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),n}function Ht(t,e){const n=jt(t,"value"),r=BigInt(Jt(e,"bits"));return n&(Lt<<r)-Lt}function Qt(t,e){switch(typeof t){case"bigint":return t;case"number":return At(Number.isInteger(t),"underflow",e||"value",t),At(t>=-Mt&&t<=Mt,"overflow",e||"value",t),BigInt(t);case"string":try{if(""===t)throw new Error("empty string");return"-"===t[0]&&"-"!==t[1]?-BigInt(t.substring(1)):BigInt(t)}catch(n){At(!1,`invalid BigNumberish string: ${n.message}`,e||"value",t)}}At(!1,"invalid BigNumberish value",e||"value",t)}function jt(t,e){const n=Qt(t,e);return bt(n>=Ut,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),n}const zt="0123456789abcdef";function Vt(t){if(t instanceof Uint8Array){let e="0x0";for(const n of t)e+=zt[n>>4],e+=zt[15&n];return BigInt(e)}return Qt(t)}function Jt(t,e){switch(typeof t){case"bigint":return At(t>=-Mt&&t<=Mt,"overflow",e||"value",t),Number(t);case"number":return At(Number.isInteger(t),"underflow",e||"value",t),At(t>=-Mt&&t<=Mt,"overflow",e||"value",t),t;case"string":try{if(""===t)throw new Error("empty string");return Jt(BigInt(t),e)}catch(n){At(!1,`invalid numeric string: ${n.message}`,e||"value",t)}}At(!1,"invalid numeric value",e||"value",t)}function Kt(t,e){let n=jt(t,"value").toString(16);if(null==e)n.length%2&&(n="0"+n);else{const r=Jt(e,"width");for(bt(2*r>=n.length,`value exceeds width (${r} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});n.length<2*r;)n="0"+n}return"0x"+n}function qt(t){const e=jt(t,"value");if(e===Ut)return new Uint8Array([]);let n=e.toString(16);n.length%2&&(n="0"+n);const r=new Uint8Array(n.length/2);for(let t=0;t<r.length;t++){const e=2*t;r[t]=parseInt(n.substring(e,e+2),16)}return r}function Zt(t){let e=Ot(It(t)?t:qt(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return""===e&&(e="0"),"0x"+e}const _t=32,Yt=new Uint8Array(_t),Wt=["then"],Xt={},$t=new WeakMap;function te(t){return $t.get(t)}function ee(t,e){$t.set(t,e)}function ne(t,e){const n=new Error(`deferred error during ABI decoding triggered accessing ${t}`);throw n.error=e,n}function re(t,e,n){return t.indexOf(null)>=0?e.map(((t,e)=>t instanceof se?re(te(t),t,n):t)):t.reduce(((t,r,s)=>{let i=e.getValue(r);return r in t||(n&&i instanceof se&&(i=re(te(i),i,n)),t[r]=i),t}),{})}class se extends Array{#t;constructor(...t){const e=t[0];let n=t[1],r=(t[2]||[]).slice(),s=!0;e!==Xt&&(n=t,r=[],s=!1),super(n.length),n.forEach(((t,e)=>{this[e]=t}));const i=r.reduce(((t,e)=>("string"==typeof e&&t.set(e,(t.get(e)||0)+1),t)),new Map);if(ee(this,Object.freeze(n.map(((t,e)=>{const n=r[e];return null!=n&&1===i.get(n)?n:null})))),this.#t=[],null==this.#t&&this.#t,!s)return;Object.freeze(this);const a=new Proxy(this,{get:(t,e,n)=>{if("string"==typeof e){if(e.match(/^[0-9]+$/)){const n=Jt(e,"%index");if(n<0||n>=this.length)throw new RangeError("out of result range");const r=t[n];return r instanceof Error&&ne(`index ${n}`,r),r}if(Wt.indexOf(e)>=0)return Reflect.get(t,e,n);const r=t[e];if(r instanceof Function)return function(...e){return r.apply(this===n?t:this,e)};if(!(e in t))return t.getValue.apply(this===n?t:this,[e])}return Reflect.get(t,e,n)}});return ee(a,te(this)),a}toArray(t){const e=[];return this.forEach(((n,r)=>{n instanceof Error&&ne(`index ${r}`,n),t&&n instanceof se&&(n=n.toArray(t)),e.push(n)})),e}toObject(t){const e=te(this);return e.reduce(((n,r,s)=>(bt(null!=r,`value at index ${s} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),re(e,this,t))),{})}slice(t,e){null==t&&(t=0),t<0&&(t+=this.length)<0&&(t=0),null==e&&(e=this.length),e<0&&(e+=this.length)<0&&(e=0),e>this.length&&(e=this.length);const n=te(this),r=[],s=[];for(let i=t;i<e;i++)r.push(this[i]),s.push(n[i]);return new se(Xt,r,s)}filter(t,e){const n=te(this),r=[],s=[];for(let i=0;i<this.length;i++){const a=this[i];a instanceof Error&&ne(`index ${i}`,a),t.call(e,a,i,this)&&(r.push(a),s.push(n[i]))}return new se(Xt,r,s)}map(t,e){const n=[];for(let r=0;r<this.length;r++){const s=this[r];s instanceof Error&&ne(`index ${r}`,s),n.push(t.call(e,s,r,this))}return n}getValue(t){const e=te(this).indexOf(t);if(-1===e)return;const n=this[e];return n instanceof Error&&ne(`property ${JSON.stringify(t)}`,n.error),n}static fromItems(t,e){return new se(Xt,t,e)}}function ie(t){let e=qt(t);return bt(e.length<=_t,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:_t,offset:e.length}),e.length!==_t&&(e=Nt(Rt([Yt.slice(e.length%_t),e]))),e}class ae{name;type;localName;dynamic;constructor(t,e,n,r){pt(this,{name:t,type:e,localName:n,dynamic:r},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){At(!1,t,this.localName,e)}}class oe{#e;#n;constructor(){this.#e=[],this.#n=0}get data(){return Rt(this.#e)}get length(){return this.#n}#r(t){return this.#e.push(t),this.#n+=t.length,t.length}appendWriter(t){return this.#r(Nt(t.data))}writeBytes(t){let e=Nt(t);const n=e.length%_t;return n&&(e=Nt(Rt([e,Yt.slice(n)]))),this.#r(e)}writeValue(t){return this.#r(ie(t))}writeUpdatableValue(){const t=this.#e.length;return this.#e.push(Yt),this.#n+=_t,e=>{this.#e[t]=ie(e)}}}class ce{allowLoose;#e;#s;#i;#a;#o;constructor(t,e,n){pt(this,{allowLoose:!!e}),this.#e=Nt(t),this.#i=0,this.#a=null,this.#o=null!=n?n:1024,this.#s=0}get data(){return Ot(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#s}get bytes(){return new Uint8Array(this.#e)}#c(t){if(this.#a)return this.#a.#c(t);this.#i+=t,bt(this.#o<1||this.#i<=this.#o*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#o} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Nt(this.#e),offset:this.#s,length:t,info:{bytesRead:this.#i,dataLength:this.dataLength}})}#l(t,e,n){let r=Math.ceil(e/_t)*_t;return this.#s+r>this.#e.length&&(this.allowLoose&&n&&this.#s+e<=this.#e.length?r=e:bt(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Nt(this.#e),length:this.#e.length,offset:this.#s+r})),this.#e.slice(this.#s,this.#s+r)}subReader(t){const e=new ce(this.#e.slice(this.#s+t),this.allowLoose,this.#o);return e.#a=this,e}readBytes(t,e){let n=this.#l(0,t,!!e);return this.#c(t),this.#s+=n.length,n.slice(0,t)}readValue(){return Vt(this.readBytes(_t))}readIndex(){return Jt(Vt(this.readBytes(_t)))}}function le(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function ue(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function he(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");le(t.outputLen),le(t.blockLen)}function fe(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function de(t,e){ue(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const pe=BigInt(2**32-1),ge=BigInt(32);function me(t,e=!1){return e?{h:Number(t&pe),l:Number(t>>ge&pe)}:{h:0|Number(t>>ge&pe),l:0|Number(t&pe)}}function ye(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:i,l:a}=me(t[s],e);[n[s],r[s]]=[i,a]}return[n,r]}const we=(t,e,n)=>t<<n|e>>>32-n,be=(t,e,n)=>e<<n|t>>>32-n,Ae=(t,e,n)=>e<<n-32|t>>>64-n,ve=(t,e,n)=>t<<n-32|e>>>64-n;const Ee={fromBig:me,split:ye,toBig:(t,e)=>BigInt(t>>>0)<<ge|BigInt(e>>>0),shrSH:(t,e,n)=>t>>>n,shrSL:(t,e,n)=>t<<32-n|e>>>n,rotrSH:(t,e,n)=>t>>>n|e<<32-n,rotrSL:(t,e,n)=>t<<32-n|e>>>n,rotrBH:(t,e,n)=>t<<64-n|e>>>n-32,rotrBL:(t,e,n)=>t>>>n-32|e<<64-n,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:we,rotlSL:be,rotlBH:Ae,rotlBL:ve,add:function(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:0|s}},add3L:(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),add3H:(t,e,n,r)=>e+n+r+(t/2**32|0)|0,add4L:(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),add4H:(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,add5H:(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,add5L:(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0)},xe="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,ke=t=>t instanceof Uint8Array,Pe=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ne=(t,e)=>t<<32-e|t>>>e;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function Be(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!ke(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class Ie{clone(){return this._cloneInto()}}function Ce(t){const e=e=>t().update(Be(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Oe(t=32){if(xe&&"function"==typeof xe.getRandomValues)return xe.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}const[Re,Te,Se]=[[],[],[]],Fe=BigInt(0),De=BigInt(1),Ue=BigInt(2),Le=BigInt(7),Me=BigInt(256),Ge=BigInt(113);for(let t=0,e=De,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Re.push(2*(5*r+n)),Te.push((t+1)*(t+2)/2%64);let s=Fe;for(let t=0;t<7;t++)e=(e<<De^(e>>Le)*Ge)%Me,e&Ue&&(s^=De<<(De<<BigInt(t))-De);Se.push(s)}const[He,Qe]=ye(Se,!0),je=(t,e,n)=>n>32?Ae(t,e,n):we(t,e,n),ze=(t,e,n)=>n>32?ve(t,e,n):be(t,e,n);class Ve extends Ie{constructor(t,e,n,r=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,le(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var i;this.state=new Uint8Array(200),this.state32=(i=this.state,new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)))}keccak(){!function(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const r=(e+8)%10,s=(e+2)%10,i=n[s],a=n[s+1],o=je(i,a,1)^n[r],c=ze(i,a,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=o,t[e+n+1]^=c}let e=t[2],s=t[3];for(let n=0;n<24;n++){const r=Te[n],i=je(e,s,r),a=ze(e,s,r),o=Re[n];e=t[o],s=t[o+1],t[o]=i,t[o+1]=a}for(let e=0;e<50;e+=10){for(let r=0;r<10;r++)n[r]=t[e+r];for(let r=0;r<10;r++)t[e+r]^=~n[(r+2)%10]&n[(r+4)%10]}t[0]^=He[r],t[1]^=Qe[r]}n.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){fe(this);const{blockLen:e,state:n}=this,r=(t=Be(t)).length;for(let s=0;s<r;){const i=Math.min(e-this.pos,r-s);for(let e=0;e<i;e++)n[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:r}=this;t[n]^=e,128&e&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){fe(this,!1),ue(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,s=t.length;r<s;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);t.set(e.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return le(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(de(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,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return t||(t=new Ve(e,n,r,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=r,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Je=(t,e,n)=>Ce((()=>new Ve(e,t,n))),Ke=Je(1,136,32);let qe=!1;const Ze=function(t){return Ke(t)};let _e=Ze;function Ye(t){const e=Pt(t,"data");return Ot(_e(e))}Ye._=Ze,Ye.lock=function(){qe=!0},Ye.register=function(t){if(qe)throw new TypeError("keccak256 is locked");_e=t},Object.freeze(Ye);const We=BigInt(0),Xe=BigInt(36);function $e(t){const e=(t=t.toLowerCase()).substring(2).split(""),n=new Uint8Array(40);for(let t=0;t<40;t++)n[t]=e[t].charCodeAt(0);const r=Pt(Ye(n));for(let t=0;t<40;t+=2)r[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&r[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const tn={};for(let t=0;t<10;t++)tn[String(t)]=String(t);for(let t=0;t<26;t++)tn[String.fromCharCode(65+t)]=String(10+t);function en(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>tn[t])).join("");for(;e.length>=15;){let t=e.substring(0,15);e=parseInt(t,10)%97+e.substring(t.length)}let n=String(98-parseInt(e,10)%97);for(;n.length<2;)n="0"+n;return n}const nn=function(){const t={};for(let e=0;e<36;e++){t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e)}return t}();function rn(t){if(At("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=$e(t);return At(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===t,"bad address checksum","address",t),e}if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){At(t.substring(2,4)===en(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=We;for(let n=0;n<t.length;n++)e=e*Xe+nn[t[n]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return $e("0x"+e)}At(!1,"invalid address","address",t)}const sn={};function an(t,e){let n=!1;return e<0&&(n=!0,e*=-1),new ln(sn,`${n?"":"u"}int${e}`,t,{signed:n,width:e})}function on(t,e){return new ln(sn,`bytes${e||""}`,t,{size:e})}const cn=Symbol.for("_ethers_typed");class ln{type;value;#u;_typedSymbol;constructor(t,e,n,r){null==r&&(r=null),xt(sn,t,"Typed"),pt(this,{_typedSymbol:cn,type:e,value:n}),this.#u=r,this.format()}format(){if("array"===this.type)throw new Error("");if("dynamicArray"===this.type)throw new Error("");return"tuple"===this.type?`tuple(${this.value.map((t=>t.format())).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return"string"===this.type}get tupleName(){if("tuple"!==this.type)throw TypeError("not a tuple");return this.#u}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===this.#u?-1:!1===this.#u?this.value.length:null}static from(t,e){return new ln(sn,t,e)}static uint8(t){return an(t,8)}static uint16(t){return an(t,16)}static uint24(t){return an(t,24)}static uint32(t){return an(t,32)}static uint40(t){return an(t,40)}static uint48(t){return an(t,48)}static uint56(t){return an(t,56)}static uint64(t){return an(t,64)}static uint72(t){return an(t,72)}static uint80(t){return an(t,80)}static uint88(t){return an(t,88)}static uint96(t){return an(t,96)}static uint104(t){return an(t,104)}static uint112(t){return an(t,112)}static uint120(t){return an(t,120)}static uint128(t){return an(t,128)}static uint136(t){return an(t,136)}static uint144(t){return an(t,144)}static uint152(t){return an(t,152)}static uint160(t){return an(t,160)}static uint168(t){return an(t,168)}static uint176(t){return an(t,176)}static uint184(t){return an(t,184)}static uint192(t){return an(t,192)}static uint200(t){return an(t,200)}static uint208(t){return an(t,208)}static uint216(t){return an(t,216)}static uint224(t){return an(t,224)}static uint232(t){return an(t,232)}static uint240(t){return an(t,240)}static uint248(t){return an(t,248)}static uint256(t){return an(t,256)}static uint(t){return an(t,256)}static int8(t){return an(t,-8)}static int16(t){return an(t,-16)}static int24(t){return an(t,-24)}static int32(t){return an(t,-32)}static int40(t){return an(t,-40)}static int48(t){return an(t,-48)}static int56(t){return an(t,-56)}static int64(t){return an(t,-64)}static int72(t){return an(t,-72)}static int80(t){return an(t,-80)}static int88(t){return an(t,-88)}static int96(t){return an(t,-96)}static int104(t){return an(t,-104)}static int112(t){return an(t,-112)}static int120(t){return an(t,-120)}static int128(t){return an(t,-128)}static int136(t){return an(t,-136)}static int144(t){return an(t,-144)}static int152(t){return an(t,-152)}static int160(t){return an(t,-160)}static int168(t){return an(t,-168)}static int176(t){return an(t,-176)}static int184(t){return an(t,-184)}static int192(t){return an(t,-192)}static int200(t){return an(t,-200)}static int208(t){return an(t,-208)}static int216(t){return an(t,-216)}static int224(t){return an(t,-224)}static int232(t){return an(t,-232)}static int240(t){return an(t,-240)}static int248(t){return an(t,-248)}static int256(t){return an(t,-256)}static int(t){return an(t,-256)}static bytes1(t){return on(t,1)}static bytes2(t){return on(t,2)}static bytes3(t){return on(t,3)}static bytes4(t){return on(t,4)}static bytes5(t){return on(t,5)}static bytes6(t){return on(t,6)}static bytes7(t){return on(t,7)}static bytes8(t){return on(t,8)}static bytes9(t){return on(t,9)}static bytes10(t){return on(t,10)}static bytes11(t){return on(t,11)}static bytes12(t){return on(t,12)}static bytes13(t){return on(t,13)}static bytes14(t){return on(t,14)}static bytes15(t){return on(t,15)}static bytes16(t){return on(t,16)}static bytes17(t){return on(t,17)}static bytes18(t){return on(t,18)}static bytes19(t){return on(t,19)}static bytes20(t){return on(t,20)}static bytes21(t){return on(t,21)}static bytes22(t){return on(t,22)}static bytes23(t){return on(t,23)}static bytes24(t){return on(t,24)}static bytes25(t){return on(t,25)}static bytes26(t){return on(t,26)}static bytes27(t){return on(t,27)}static bytes28(t){return on(t,28)}static bytes29(t){return on(t,29)}static bytes30(t){return on(t,30)}static bytes31(t){return on(t,31)}static bytes32(t){return on(t,32)}static address(t){return new ln(sn,"address",t)}static bool(t){return new ln(sn,"bool",!!t)}static bytes(t){return new ln(sn,"bytes",t)}static string(t){return new ln(sn,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new ln(sn,"overrides",Object.assign({},t))}static isTyped(t){return t&&"object"==typeof t&&"_typedSymbol"in t&&t._typedSymbol===cn}static dereference(t,e){if(ln.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}}class un extends ae{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let n=ln.dereference(e,"string");try{n=rn(n)}catch(t){return this._throwError(t.message,e)}return t.writeValue(n)}decode(t){return rn(Kt(t.readValue(),20))}}class hn extends ae{coder;constructor(t){super(t.name,t.type,"_",t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function fn(t,e,n){let r=[];if(Array.isArray(n))r=n;else if(n&&"object"==typeof n){let t={};r=e.map((e=>{const r=e.localName;return bt(r,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:n}),bt(!t[r],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:n}),t[r]=!0,n[r]}))}else At(!1,"invalid tuple value","tuple",n);At(e.length===r.length,"types/value length mismatch","tuple",n);let s=new oe,i=new oe,a=[];e.forEach(((t,e)=>{let n=r[e];if(t.dynamic){let e=i.length;t.encode(i,n);let r=s.writeUpdatableValue();a.push((t=>{r(t+e)}))}else t.encode(s,n)})),a.forEach((t=>{t(s.length)}));let o=t.appendWriter(s);return o+=t.appendWriter(i),o}function dn(t,e){let n=[],r=[],s=t.subReader(0);return e.forEach((e=>{let i=null;if(e.dynamic){let n=t.readIndex(),r=s.subReader(n);try{i=e.decode(r)}catch(t){if(mt(t,"BUFFER_OVERRUN"))throw t;i=t,i.baseType=e.name,i.name=e.localName,i.type=e.type}}else try{i=e.decode(t)}catch(t){if(mt(t,"BUFFER_OVERRUN"))throw t;i=t,i.baseType=e.name,i.name=e.localName,i.type=e.type}if(null==i)throw new Error("investigate");n.push(i),r.push(e.localName||null)})),se.fromItems(n,r)}class pn extends ae{coder;length;constructor(t,e,n){super("array",t.type+"["+(e>=0?e:"")+"]",n,-1===e||t.dynamic),pt(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let n=0;n<this.length;n++)e.push(t);return e}encode(t,e){const n=ln.dereference(e,"array");Array.isArray(n)||this._throwError("expected array value",n);let r=this.length;-1===r&&(r=n.length,t.writeValue(n.length)),vt(n.length,r,"coder array"+(this.localName?" "+this.localName:""));let s=[];for(let t=0;t<n.length;t++)s.push(this.coder);return fn(t,s,n)}decode(t){let e=this.length;-1===e&&(e=t.readIndex(),bt(e*_t<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*_t,length:t.dataLength}));let n=[];for(let t=0;t<e;t++)n.push(new hn(this.coder));return dn(t,n)}}class gn extends ae{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const n=ln.dereference(e,"bool");return t.writeValue(n?1:0)}decode(t){return!!t.readValue()}}class mn extends ae{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=Nt(e);let n=t.writeValue(e.length);return n+=t.writeBytes(e),n}decode(t){return t.readBytes(t.readIndex(),!0)}}class yn extends mn{constructor(t){super("bytes",t)}decode(t){return Ot(super.decode(t))}}class wn extends ae{size;constructor(t,e){let n="bytes"+String(t);super(n,n,e,!1),pt(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let n=Nt(ln.dereference(e,this.type));return n.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(n)}decode(t){return Ot(t.readBytes(this.size))}}const bn=new Uint8Array([]);class An extends ae{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes(bn)}decode(t){return t.readBytes(0),null}}const vn=BigInt(0),En=BigInt(1),xn=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class kn extends ae{size;signed;constructor(t,e,n){const r=(e?"int":"uint")+8*t;super(r,r,n,!1),pt(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let n=Qt(ln.dereference(e,this.type)),r=Ht(xn,256);if(this.signed){let t=Ht(r,8*this.size-1);(n>t||n<-(t+En))&&this._throwError("value out-of-bounds",e),n=Gt(n,256)}else(n<vn||n>Ht(r,8*this.size))&&this._throwError("value out-of-bounds",e);return t.writeValue(n)}decode(t){let e=Ht(t.readValue(),8*this.size);return this.signed&&(e=function(t,e){const n=jt(t,"value"),r=BigInt(Jt(e,"width"));if(bt(n>>r===Ut,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:t}),n>>r-Lt)return-((~n&(Lt<<r)-Lt)+Lt);return n}(e,8*this.size)),e}}function Pn(t,e,n,r,s){if("BAD_PREFIX"===t||"UNEXPECTED_CONTINUE"===t){let t=0;for(let r=e+1;r<n.length&&n[r]>>6==2;r++)t++;return t}return"OVERRUN"===t?n.length-e-1:0}const Nn=Object.freeze({error:function(t,e,n,r,s){At(!1,`invalid codepoint at offset ${e}; ${t}`,"bytes",n)},ignore:Pn,replace:function(t,e,n,r,s){return"OVERLONG"===t?(At("number"==typeof s,"invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),Pn(t,e,n))}});function Bn(t,e){null==e&&(e=Nn.error);const n=Pt(t,"bytes"),r=[];let s=0;for(;s<n.length;){const t=n[s++];if(!(t>>7)){r.push(t);continue}let i=null,a=null;if(192==(224&t))i=1,a=127;else if(224==(240&t))i=2,a=2047;else{if(240!=(248&t)){s+=e(128==(192&t)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",s-1,n,r);continue}i=3,a=65535}if(s-1+i>=n.length){s+=e("OVERRUN",s-1,n,r);continue}let o=t&(1<<8-i-1)-1;for(let t=0;t<i;t++){let t=n[s];if(128!=(192&t)){s+=e("MISSING_CONTINUE",s,n,r),o=null;break}o=o<<6|63&t,s++}null!==o&&(o>1114111?s+=e("OUT_OF_RANGE",s-1-i,n,r,o):o>=55296&&o<=57343?s+=e("UTF16_SURROGATE",s-1-i,n,r,o):o<=a?s+=e("OVERLONG",s-1-i,n,r,o):r.push(o))}return r}function In(t,e){At("string"==typeof t,"invalid string value","str",t),null!=e&&(!function(t){bt(Et.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}(e),t=t.normalize(e));let n=[];for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);if(r<128)n.push(r);else if(r<2048)n.push(r>>6|192),n.push(63&r|128);else if(55296==(64512&r)){e++;const s=t.charCodeAt(e);At(e<t.length&&56320==(64512&s),"invalid surrogate pair","str",t);const i=65536+((1023&r)<<10)+(1023&s);n.push(i>>18|240),n.push(i>>12&63|128),n.push(i>>6&63|128),n.push(63&i|128)}else n.push(r>>12|224),n.push(r>>6&63|128),n.push(63&r|128)}return new Uint8Array(n)}function Cn(t,e){return Bn(t,e).map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}class On extends mn{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,In(ln.dereference(e,"string")))}decode(t){return Cn(super.decode(t))}}class Rn extends ae{coders;constructor(t,e){let n=!1;const r=[];t.forEach((t=>{t.dynamic&&(n=!0),r.push(t.type)}));super("tuple","tuple("+r.join(",")+")",e,n),pt(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach((e=>{t.push(e.defaultValue())}));const e=this.coders.reduce(((t,e)=>{const n=e.localName;return n&&(t[n]||(t[n]=0),t[n]++),t}),{});return this.coders.forEach(((n,r)=>{let s=n.localName;s&&1===e[s]&&("length"===s&&(s="_length"),null==t[s]&&(t[s]=t[r]))})),Object.freeze(t)}encode(t,e){const n=ln.dereference(e,"tuple");return fn(t,this.coders,n)}decode(t){return dn(t,this.coders)}}function Tn(t){return Ye(In(t))}function Sn(t){const e=new Set;return t.forEach((t=>e.add(t))),Object.freeze(e)}const Fn=Sn("external public payable override".split(" ")),Dn="constant external internal payable private public pure view override",Un=Sn(Dn.split(" ")),Ln="constructor error event fallback function receive struct",Mn=Sn(Ln.split(" ")),Gn="calldata memory storage payable indexed",Hn=Sn(Gn.split(" ")),Qn=Sn([Ln,Gn,"tuple returns",Dn].join(" ").split(" ")),jn={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},zn=new RegExp("^(\\s*)"),Vn=new RegExp("^([0-9]+)"),Jn=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),Kn=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),qn=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class Zn{#s;#h;get offset(){return this.#s}get length(){return this.#h.length-this.#s}constructor(t){this.#s=0,this.#h=t.slice()}clone(){return new Zn(this.#h)}reset(){this.#s=0}#f(t=0,e=0){return new Zn(this.#h.slice(t,e).map((e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t})))))}popKeyword(t){const e=this.peek();if("KEYWORD"!==e.type||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=this.#f(this.#s+1,t.match+1);return this.#s=t.match+1,e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;this.#s<t.match-1;){const t=this.peek().linkNext;e.push(this.#f(this.#s+1,t)),this.#s=t}return this.#s=t.match+1,e}peek(){if(this.#s>=this.#h.length)throw new Error("out-of-bounds");return this.#h[this.#s]}peekKeyword(t){const e=this.peekType("KEYWORD");return null!=e&&t.has(e)?e:null}peekType(t){if(0===this.length)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return this.#s++,t}toString(){const t=[];for(let e=this.#s;e<this.#h.length;e++){const n=this.#h[e];t.push(`${n.type}:${n.text}`)}return`<TokenString ${t.join(" ")}>`}}function _n(t){const e=[],n=e=>{const n=i<t.length?JSON.stringify(t[i]):"$EOI";throw new Error(`invalid token ${n} at ${i}: ${e}`)};let r=[],s=[],i=0;for(;i<t.length;){let a=t.substring(i),o=a.match(zn);o&&(i+=o[1].length,a=t.substring(i));const c={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(c);let l=jn[a[0]]||"";if(l){if(c.type=l,c.text=a[0],i++,"OPEN_PAREN"===l)r.push(e.length-1),s.push(e.length-1);else if("CLOSE_PAREN"==l)0===r.length&&n("no matching open bracket"),c.match=r.pop(),e[c.match].match=e.length-1,c.depth--,c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1;else if("COMMA"===l)c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1,s.push(e.length-1);else if("OPEN_BRACKET"===l)c.type="BRACKET";else if("CLOSE_BRACKET"===l){let t=e.pop().text;if(e.length>0&&"NUMBER"===e[e.length-1].type){const n=e.pop().text;t=n+t,e[e.length-1].value=Jt(n)}if(0===e.length||"BRACKET"!==e[e.length-1].type)throw new Error("missing opening bracket");e[e.length-1].text+=t}}else if(o=a.match(Jn),o){if(c.text=o[1],i+=c.text.length,Qn.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(qn)){c.type="TYPE";continue}c.type="ID"}else{if(o=a.match(Vn),!o)throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${i}`);c.text=o[1],c.type="NUMBER",i+=c.text.length}}return new Zn(e.map((t=>Object.freeze(t))))}function Yn(t,e){let n=[];for(const r in e.keys())t.has(r)&&n.push(r);if(n.length>1)throw new Error(`conflicting types: ${n.join(", ")}`)}function Wn(t,e){if(e.peekKeyword(Mn)){const n=e.pop().text;if(n!==t)throw new Error(`expected ${t}, got ${n}`)}return e.popType("ID")}function Xn(t,e){const n=new Set;for(;;){const r=t.peekType("KEYWORD");if(null==r||e&&!e.has(r))break;if(t.pop(),n.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);n.add(r)}return Object.freeze(n)}function $n(t){let e=Xn(t,Un);return Yn(e,Sn("constant payable nonpayable".split(" "))),Yn(e,Sn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function tr(t,e){return t.popParams().map((t=>pr.from(t,e)))}function er(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return Qt(t.pop().text);throw new Error("invalid gas")}return null}function nr(t){if(t.length)throw new Error(`unexpected tokens at offset ${t.offset}: ${t.toString()}`)}const rr=new RegExp(/^(.*)\[([0-9]*)\]$/);function sr(t){const e=t.match(qn);if(At(e,"invalid type","type",t),"uint"===t)return"uint256";if("int"===t)return"int256";if(e[2]){const n=parseInt(e[2]);At(0!==n&&n<=32,"invalid bytes length","type",t)}else if(e[3]){const n=parseInt(e[3]);At(0!==n&&n<=256&&n%8==0,"invalid numeric width","type",t)}return t}const ir={},ar=Symbol.for("_ethers_internal"),or="_ParamTypeInternal",cr="_ErrorInternal",lr="_EventInternal",ur="_ConstructorInternal",hr="_FallbackInternal",fr="_FunctionInternal",dr="_StructInternal";class pr{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(t,e,n,r,s,i,a,o){if(xt(t,ir,"ParamType"),Object.defineProperty(this,ar,{value:or}),i&&(i=Object.freeze(i.slice())),"array"===r){if(null==a||null==o)throw new Error("")}else if(null!=a||null!=o)throw new Error("");if("tuple"===r){if(null==i)throw new Error("")}else if(null!=i)throw new Error("");pt(this,{name:e,type:n,baseType:r,indexed:s,components:i,arrayLength:a,arrayChildren:o})}format(t){if(null==t&&(t="sighash"),"json"===t){const e=this.name||"";if(this.isArray()){const t=JSON.parse(this.arrayChildren.format("json"));return t.name=e,t.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(t)}const n={type:"tuple"===this.baseType?"tuple":this.type,name:e};return"boolean"==typeof this.indexed&&(n.indexed=this.indexed),this.isTuple()&&(n.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(n)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map((e=>e.format(t))).join("full"===t?", ":",")+")":e+=this.type,"sighash"!==t&&(!0===this.indexed&&(e+=" indexed"),"full"===t&&this.name&&(e+=" "+this.name)),e}isArray(){return"array"===this.baseType}isTuple(){return"tuple"===this.baseType}isIndexable(){return null!=this.indexed}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(-1!==this.arrayLength&&t.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return t.map((t=>n.arrayChildren.walk(t,e)))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const n=this;return t.map(((t,r)=>n.components[r].walk(t,e)))}return e(this.type,t)}#d(t,e,n,r){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(-1!==this.arrayLength&&e.length!==this.arrayLength)throw new Error("array is wrong length");const s=this.arrayChildren,i=e.slice();return i.forEach(((e,r)=>{s.#d(t,e,n,(t=>{i[r]=t}))})),void r(i)}if(this.isTuple()){const s=this.components;let i;if(Array.isArray(e))i=e.slice();else{if(null==e||"object"!=typeof e)throw new Error("invalid tuple value");i=s.map((t=>{if(!t.name)throw new Error("cannot use object value with unnamed components");if(!(t.name in e))throw new Error(`missing value for component ${t.name}`);return e[t.name]}))}if(i.length!==this.components.length)throw new Error("array is wrong length");return i.forEach(((e,r)=>{s[r].#d(t,e,n,(t=>{i[r]=t}))})),void r(i)}const s=n(this.type,e);s.then?t.push(async function(){r(await s)}()):r(s)}async walkAsync(t,e){const n=[],r=[t];return this.#d(n,t,e,(t=>{r[0]=t})),n.length&&await Promise.all(n),r[0]}static from(t,e){if(pr.isParamType(t))return t;if("string"==typeof t)try{return pr.from(_n(t),e)}catch(e){At(!1,"invalid param type","obj",t)}else if(t instanceof Zn){let n="",r="",s=null;Xn(t,Sn(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(r="tuple",s=t.popParams().map((t=>pr.from(t))),n=`tuple(${s.map((t=>t.format())).join(",")})`):(n=sr(t.popType("TYPE")),r=n);let i=null,a=null;for(;t.length&&t.peekType("BRACKET");){const e=t.pop();i=new pr(ir,"",n,r,null,s,a,i),a=e.value,n+=e.text,r="array",s=null}let o=null;if(Xn(t,Hn).has("indexed")){if(!e)throw new Error("");o=!0}const c=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new pr(ir,c,n,r,o,s,a,i)}const n=t.name;At(!n||"string"==typeof n&&n.match(Kn),"invalid name","obj.name",n);let r=t.indexed;null!=r&&(At(e,"parameter cannot be indexed","obj.indexed",t.indexed),r=!!r);let s=t.type,i=s.match(rr);if(i){const e=parseInt(i[2]||"-1"),a=pr.from({type:i[1],components:t.components});return new pr(ir,n||"",s,"array",r,null,e,a)}if("tuple"===s||s.startsWith("tuple(")||s.startsWith("(")){const e=null!=t.components?t.components.map((t=>pr.from(t))):null;return new pr(ir,n||"",s,"tuple",r,e,null,null)}return s=sr(t.type),new pr(ir,n||"",s,s,r,null,null,null)}static isParamType(t){return t&&t[ar]===or}}class gr{type;inputs;constructor(t,e,n){xt(t,ir,"Fragment"),pt(this,{type:e,inputs:n=Object.freeze(n.slice())})}static from(t){if("string"==typeof t){try{gr.from(JSON.parse(t))}catch(t){}return gr.from(_n(t))}if(t instanceof Zn){switch(t.peekKeyword(Mn)){case"constructor":return Ar.from(t);case"error":return wr.from(t);case"event":return br.from(t);case"fallback":case"receive":return vr.from(t);case"function":return Er.from(t);case"struct":return xr.from(t)}}else if("object"==typeof t){switch(t.type){case"constructor":return Ar.from(t);case"error":return wr.from(t);case"event":return br.from(t);case"fallback":case"receive":return vr.from(t);case"function":return Er.from(t);case"struct":return xr.from(t)}bt(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from