=P(this,Ma).length)throw new Error("out-of-bounds");return P(this,Ma)[P(this,kn)]}peekKeyword(t){const n=this.peekType("KEYWORD");return n!=null&&t.has(n)?n:null}peekType(t){if(this.length===0)return null;const n=this.peek();return n.type===t?n.text:null}pop(){const t=this.peek();return ac(this,kn)._++,t}toString(){const t=[];for(let n=P(this,kn);n`}};kn=new WeakMap,Ma=new WeakMap,um=new WeakSet,tv=function(t=0,n=0){return new cy(P(this,Ma).slice(t,n).map(i=>Object.freeze(Object.assign({},i,{match:i.match-t,linkBack:i.linkBack-t,linkNext:i.linkNext-t}))))};let os=cy;function vl(e){const t=[],n=r=>{const l=o0&&t[t.length-1].type==="NUMBER"){const u=t.pop().text;h=u+h,t[t.length-1].value=Lt(u)}if(t.length===0||t[t.length-1].type!=="BRACKET")throw new Error("missing opening bracket");t[t.length-1].text+=h}continue}if(l=r.match(KX),l){if(d.text=l[1],o+=d.text.length,$X.has(d.text)){d.type="KEYWORD";continue}if(d.text.match(WU)){d.type="TYPE";continue}d.type="ID";continue}if(l=r.match(GX),l){d.text=l[1],d.type="NUMBER",o+=d.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(r[0])} at position ${o}`)}return new os(t.map(r=>Object.freeze(r)))}function cw(e,t){let n=[];for(const i in t.keys())e.has(i)&&n.push(i);if(n.length>1)throw new Error(`conflicting types: ${n.join(", ")}`)}function Jy(e,t){if(t.peekKeyword(jU)){const n=t.pop().text;if(n!==e)throw new Error(`expected ${e}, got ${n}`)}return t.popType("ID")}function Do(e,t){const n=new Set;for(;;){const i=e.peekType("KEYWORD");if(i==null||t&&!t.has(i))break;if(e.pop(),n.has(i))throw new Error(`duplicate keywords: ${JSON.stringify(i)}`);n.add(i)}return Object.freeze(n)}function HU(e){let t=Do(e,qX);return cw(t,pi("constant payable nonpayable".split(" "))),cw(t,pi("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function To(e,t){return e.popParams().map(n=>Rn.from(n,t))}function GU(e){if(e.peekType("AT")){if(e.pop(),e.peekType("NUMBER"))return xt(e.pop().text);throw new Error("invalid gas")}return null}function Bd(e){if(e.length)throw new Error(`unexpected tokens at offset ${e.offset}: ${e.toString()}`)}const QX=new RegExp(/^(.*)\[([0-9]*)\]$/);function uw(e){const t=e.match(WU);if(z(t,"invalid type","type",e),e==="uint")return"uint256";if(e==="int")return"int256";if(t[2]){const n=parseInt(t[2]);z(n!==0&&n<=32,"invalid bytes length","type",e)}else if(t[3]){const n=parseInt(t[3]);z(n!==0&&n<=256&&n%8===0,"invalid numeric width","type",e)}return e}const Se={},Ui=Symbol.for("_ethers_internal"),hw="_ParamTypeInternal",pw="_ErrorInternal",mw="_EventInternal",fw="_ConstructorInternal",_w="_FallbackInternal",gw="_FunctionInternal",yw="_StructInternal";var Cu,L_;const la=class la{constructor(t,n,i,a,o,r,l,d){j(this,Cu);V(this,"name");V(this,"type");V(this,"baseType");V(this,"indexed");V(this,"components");V(this,"arrayLength");V(this,"arrayChildren");if(Mo(t,Se,"ParamType"),Object.defineProperty(this,Ui,{value:hw}),r&&(r=Object.freeze(r.slice())),a==="array"){if(l==null||d==null)throw new Error("")}else if(l!=null||d!=null)throw new Error("");if(a==="tuple"){if(r==null)throw new Error("")}else if(r!=null)throw new Error("");ut(this,{name:n,type:i,baseType:a,indexed:o,components:r,arrayLength:l,arrayChildren:d})}format(t){if(t==null&&(t="sighash"),t==="json"){const i=this.name||"";if(this.isArray()){const o=JSON.parse(this.arrayChildren.format("json"));return o.name=i,o.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(o)}const a={type:this.baseType==="tuple"?"tuple":this.type,name:i};return typeof this.indexed=="boolean"&&(a.indexed=this.indexed),this.isTuple()&&(a.components=this.components.map(o=>JSON.parse(o.format(t)))),JSON.stringify(a)}let n="";return this.isArray()?(n+=this.arrayChildren.format(t),n+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?n+="("+this.components.map(i=>i.format(t)).join(t==="full"?", ":",")+")":n+=this.type,t!=="sighash"&&(this.indexed===!0&&(n+=" indexed"),t==="full"&&this.name&&(n+=" "+this.name)),n}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(t,n){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const i=this;return t.map(a=>i.arrayChildren.walk(a,n))}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 i=this;return t.map((a,o)=>i.components[o].walk(a,n))}return n(this.type,t)}async walkAsync(t,n){const i=[],a=[t];return at(this,Cu,L_).call(this,i,t,n,o=>{a[0]=o}),i.length&&await Promise.all(i),a[0]}static from(t,n){if(la.isParamType(t))return t;if(typeof t=="string")try{return la.from(vl(t),n)}catch{z(!1,"invalid param type","obj",t)}else if(t instanceof os){let l="",d="",c=null;Do(t,pi(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(d="tuple",c=t.popParams().map(f=>la.from(f)),l=`tuple(${c.map(f=>f.format()).join(",")})`):(l=uw(t.popType("TYPE")),d=l);let h=null,u=null;for(;t.length&&t.peekType("BRACKET");){const f=t.pop();h=new la(Se,"",l,d,null,c,u,h),u=f.value,l+=f.text,d="array",c=null}let p=null;if(Do(t,BX).has("indexed")){if(!n)throw new Error("");p=!0}const _=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new la(Se,_,l,d,p,c,u,h)}const i=t.name;z(!i||typeof i=="string"&&i.match($U),"invalid name","obj.name",i);let a=t.indexed;a!=null&&(z(n,"parameter cannot be indexed","obj.indexed",t.indexed),a=!!a);let o=t.type,r=o.match(QX);if(r){const l=parseInt(r[2]||"-1"),d=la.from({type:r[1],components:t.components});return new la(Se,i||"",o,"array",a,null,l,d)}if(o==="tuple"||o.startsWith("tuple(")||o.startsWith("(")){const l=t.components!=null?t.components.map(c=>la.from(c)):null;return new la(Se,i||"",o,"tuple",a,l,null,null)}return o=uw(t.type),new la(Se,i||"",o,o,a,null,null,null)}static isParamType(t){return t&&t[Ui]===hw}};Cu=new WeakSet,L_=function(t,n,i,a){if(this.isArray()){if(!Array.isArray(n))throw new Error("invalid array value");if(this.arrayLength!==-1&&n.length!==this.arrayLength)throw new Error("array is wrong length");const r=this.arrayChildren,l=n.slice();l.forEach((d,c)=>{var h;at(h=r,Cu,L_).call(h,t,d,i,u=>{l[c]=u})}),a(l);return}if(this.isTuple()){const r=this.components;let l;if(Array.isArray(n))l=n.slice();else{if(n==null||typeof n!="object")throw new Error("invalid tuple value");l=r.map(d=>{if(!d.name)throw new Error("cannot use object value with unnamed components");if(!(d.name in n))throw new Error(`missing value for component ${d.name}`);return n[d.name]})}if(l.length!==this.components.length)throw new Error("array is wrong length");l.forEach((d,c)=>{var h;at(h=r[c],Cu,L_).call(h,t,d,i,u=>{l[c]=u})}),a(l);return}const o=i(this.type,n);o.then?t.push(async function(){a(await o)}()):a(o)};let Rn=la;class al{constructor(t,n,i){V(this,"type");V(this,"inputs");Mo(t,Se,"Fragment"),i=Object.freeze(i.slice()),ut(this,{type:n,inputs:i})}static from(t){if(typeof t=="string"){try{al.from(JSON.parse(t))}catch{}return al.from(vl(t))}if(t instanceof os)switch(t.peekKeyword(jU)){case"constructor":return Rs.from(t);case"error":return ui.from(t);case"event":return Ga.from(t);case"fallback":case"receive":return Ts.from(t);case"function":return Ka.from(t);case"struct":return Jr.from(t)}else if(typeof t=="object"){switch(t.type){case"constructor":return Rs.from(t);case"error":return ui.from(t);case"event":return Ga.from(t);case"fallback":case"receive":return Ts.from(t);case"function":return Ka.from(t);case"struct":return Jr.from(t)}Y(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}z(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return Rs.isFragment(t)}static isError(t){return ui.isFragment(t)}static isEvent(t){return Ga.isFragment(t)}static isFunction(t){return Ka.isFragment(t)}static isStruct(t){return Jr.isFragment(t)}}class Mm extends al{constructor(n,i,a,o){super(n,i,o);V(this,"name");z(typeof a=="string"&&a.match($U),"invalid identifier","name",a),o=Object.freeze(o.slice()),ut(this,{name:a})}}function Fp(e,t){return"("+t.map(n=>n.format(e)).join(e==="full"?", ":",")+")"}class ui extends Mm{constructor(t,n,i){super(t,"error",n,i),Object.defineProperty(this,Ui,{value:pw})}get selector(){return yi(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(t)))});const n=[];return t!=="sighash"&&n.push("error"),n.push(this.name+Fp(t,this.inputs)),n.join(" ")}static from(t){if(ui.isFragment(t))return t;if(typeof t=="string")return ui.from(vl(t));if(t instanceof os){const n=Jy("error",t),i=To(t);return Bd(t),new ui(Se,n,i)}return new ui(Se,t.name,t.inputs?t.inputs.map(Rn.from):[])}static isFragment(t){return t&&t[Ui]===pw}}class Ga extends Mm{constructor(n,i,a,o){super(n,"event",i,a);V(this,"anonymous");Object.defineProperty(this,Ui,{value:mw}),ut(this,{anonymous:o})}get topicHash(){return yi(this.format("sighash"))}format(n){if(n==null&&(n="sighash"),n==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(a=>JSON.parse(a.format(n)))});const i=[];return n!=="sighash"&&i.push("event"),i.push(this.name+Fp(n,this.inputs)),n!=="sighash"&&this.anonymous&&i.push("anonymous"),i.join(" ")}static getTopicHash(n,i){return i=(i||[]).map(o=>Rn.from(o)),new Ga(Se,n,i,!1).topicHash}static from(n){if(Ga.isFragment(n))return n;if(typeof n=="string")try{return Ga.from(vl(n))}catch{z(!1,"invalid event fragment","obj",n)}else if(n instanceof os){const i=Jy("event",n),a=To(n,!0),o=!!Do(n,pi(["anonymous"])).has("anonymous");return Bd(n),new Ga(Se,i,a,o)}return new Ga(Se,n.name,n.inputs?n.inputs.map(i=>Rn.from(i,!0)):[],!!n.anonymous)}static isFragment(n){return n&&n[Ui]===mw}}class Rs extends al{constructor(n,i,a,o,r){super(n,i,a);V(this,"payable");V(this,"gas");Object.defineProperty(this,Ui,{value:fw}),ut(this,{payable:o,gas:r})}format(n){if(Y(n!=null&&n!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),n==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(a=>JSON.parse(a.format(n)))});const i=[`constructor${Fp(n,this.inputs)}`];return this.payable&&i.push("payable"),this.gas!=null&&i.push(`@${this.gas.toString()}`),i.join(" ")}static from(n){if(Rs.isFragment(n))return n;if(typeof n=="string")try{return Rs.from(vl(n))}catch{z(!1,"invalid constuctor fragment","obj",n)}else if(n instanceof os){Do(n,pi(["constructor"]));const i=To(n),a=!!Do(n,MX).has("payable"),o=GU(n);return Bd(n),new Rs(Se,"constructor",i,a,o)}return new Rs(Se,"constructor",n.inputs?n.inputs.map(Rn.from):[],!!n.payable,n.gas!=null?n.gas:null)}static isFragment(n){return n&&n[Ui]===fw}}class Ts extends al{constructor(n,i,a){super(n,"fallback",i);V(this,"payable");Object.defineProperty(this,Ui,{value:_w}),ut(this,{payable:a})}format(n){const i=this.inputs.length===0?"receive":"fallback";if(n==="json"){const a=this.payable?"payable":"nonpayable";return JSON.stringify({type:i,stateMutability:a})}return`${i}()${this.payable?" payable":""}`}static from(n){if(Ts.isFragment(n))return n;if(typeof n=="string")try{return Ts.from(vl(n))}catch{z(!1,"invalid fallback fragment","obj",n)}else if(n instanceof os){const i=n.toString(),a=n.peekKeyword(pi(["fallback","receive"]));if(z(a,"type must be fallback or receive","obj",i),n.popKeyword(pi(["fallback","receive"]))==="receive"){const d=To(n);return z(d.length===0,"receive cannot have arguments","obj.inputs",d),Do(n,pi(["payable"])),Bd(n),new Ts(Se,[],!0)}let r=To(n);r.length?z(r.length===1&&r[0].type==="bytes","invalid fallback inputs","obj.inputs",r.map(d=>d.format("minimal")).join(", ")):r=[Rn.from("bytes")];const l=HU(n);if(z(l==="nonpayable"||l==="payable","fallback cannot be constants","obj.stateMutability",l),Do(n,pi(["returns"])).has("returns")){const d=To(n);z(d.length===1&&d[0].type==="bytes","invalid fallback outputs","obj.outputs",d.map(c=>c.format("minimal")).join(", "))}return Bd(n),new Ts(Se,r,l==="payable")}if(n.type==="receive")return new Ts(Se,[],!0);if(n.type==="fallback"){const i=[Rn.from("bytes")],a=n.stateMutability==="payable";return new Ts(Se,i,a)}z(!1,"invalid fallback description","obj",n)}static isFragment(n){return n&&n[Ui]===_w}}class Ka extends Mm{constructor(n,i,a,o,r,l){super(n,"function",i,o);V(this,"constant");V(this,"outputs");V(this,"stateMutability");V(this,"payable");V(this,"gas");Object.defineProperty(this,Ui,{value:gw}),r=Object.freeze(r.slice()),ut(this,{constant:a==="view"||a==="pure",gas:l,outputs:r,payable:a==="payable",stateMutability:a})}get selector(){return yi(this.format("sighash")).substring(0,10)}format(n){if(n==null&&(n="sighash"),n==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(a=>JSON.parse(a.format(n))),outputs:this.outputs.map(a=>JSON.parse(a.format(n)))});const i=[];return n!=="sighash"&&i.push("function"),i.push(this.name+Fp(n,this.inputs)),n!=="sighash"&&(this.stateMutability!=="nonpayable"&&i.push(this.stateMutability),this.outputs&&this.outputs.length&&(i.push("returns"),i.push(Fp(n,this.outputs))),this.gas!=null&&i.push(`@${this.gas.toString()}`)),i.join(" ")}static getSelector(n,i){return i=(i||[]).map(o=>Rn.from(o)),new Ka(Se,n,"view",i,[],null).selector}static from(n){if(Ka.isFragment(n))return n;if(typeof n=="string")try{return Ka.from(vl(n))}catch{z(!1,"invalid function fragment","obj",n)}else if(n instanceof os){const a=Jy("function",n),o=To(n),r=HU(n);let l=[];Do(n,pi(["returns"])).has("returns")&&(l=To(n));const d=GU(n);return Bd(n),new Ka(Se,a,r,o,l,d)}let i=n.stateMutability;return i==null&&(i="payable",typeof n.constant=="boolean"?(i="view",n.constant||(i="payable",typeof n.payable=="boolean"&&!n.payable&&(i="nonpayable"))):typeof n.payable=="boolean"&&!n.payable&&(i="nonpayable")),new Ka(Se,n.name,i,n.inputs?n.inputs.map(Rn.from):[],n.outputs?n.outputs.map(Rn.from):[],n.gas!=null?n.gas:null)}static isFragment(n){return n&&n[Ui]===gw}}class Jr extends Mm{constructor(t,n,i){super(t,"struct",n,i),Object.defineProperty(this,Ui,{value:yw})}format(){throw new Error("@TODO")}static from(t){if(typeof t=="string")try{return Jr.from(vl(t))}catch{z(!1,"invalid struct fragment","obj",t)}else if(t instanceof os){const n=Jy("struct",t),i=To(t);return Bd(t),new Jr(Se,n,i)}return new Jr(Se,t.name,t.inputs?t.inputs.map(Rn.from):[])}static isFragment(t){return t&&t[Ui]===yw}}const ds=new Map;ds.set(0,"GENERIC_PANIC");ds.set(1,"ASSERT_FALSE");ds.set(17,"OVERFLOW");ds.set(18,"DIVIDE_BY_ZERO");ds.set(33,"ENUM_RANGE_ERROR");ds.set(34,"BAD_STORAGE_DATA");ds.set(49,"STACK_UNDERFLOW");ds.set(50,"ARRAY_RANGE_ERROR");ds.set(65,"OUT_OF_MEMORY");ds.set(81,"UNINITIALIZED_FUNCTION_CALL");const JX=new RegExp(/^bytes([0-9]*)$/),YX=new RegExp(/^(u?int)([0-9]*)$/);let Bx=null,xw=1024;function XX(e,t,n,i){let a="missing revert data",o=null;const r=null;let l=null;if(n){a="execution reverted";const c=et(n);if(n=Q(n),c.length===0)a+=" (no data present; likely require(false) occurred",o="require(false)";else if(c.length%32!==4)a+=" (could not decode reason; invalid data length)";else if(Q(c.slice(0,4))==="0x08c379a0")try{o=i.decode(["string"],c.slice(4))[0],l={signature:"Error(string)",name:"Error",args:[o]},a+=`: ${JSON.stringify(o)}`}catch{a+=" (could not decode reason; invalid string data)"}else if(Q(c.slice(0,4))==="0x4e487b71")try{const h=Number(i.decode(["uint256"],c.slice(4))[0]);l={signature:"Panic(uint256)",name:"Panic",args:[h]},o=`Panic due to ${ds.get(h)||"UNKNOWN"}(${h})`,a+=`: ${o}`}catch{a+=" (could not decode panic code)"}else a+=" (unknown custom error)"}const d={to:t.to?Rt(t.to):null,data:t.data||"0x"};return t.from&&(d.from=Rt(t.from)),Ie(a,"CALL_EXCEPTION",{action:e,data:n,reason:o,transaction:d,invocation:r,revert:l})}var xr,Pc;const uy=class uy{constructor(){j(this,xr)}getDefaultValue(t){const n=t.map(a=>at(this,xr,Pc).call(this,Rn.from(a)));return new Hf(n,"_").defaultValue()}encode(t,n){nP(n.length,t.length,"types/values length mismatch");const i=t.map(r=>at(this,xr,Pc).call(this,Rn.from(r))),a=new Hf(i,"_"),o=new BE;return a.encode(o,n),o.data}decode(t,n,i){const a=t.map(r=>at(this,xr,Pc).call(this,Rn.from(r)));return new Hf(a,"_").decode(new jE(n,i,xw))}static _setDefaultMaxInflation(t){z(typeof t=="number"&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),xw=t}static defaultAbiCoder(){return Bx==null&&(Bx=new uy),Bx}static getBuiltinCallException(t,n,i){return XX(t,n,i,uy.defaultAbiCoder())}};xr=new WeakSet,Pc=function(t){if(t.isArray())return new xY(at(this,xr,Pc).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new Hf(t.components.map(i=>at(this,xr,Pc).call(this,i)),t.name);switch(t.baseType){case"address":return new gY(t.name);case"bool":return new EY(t.name);case"string":return new RY(t.name);case"bytes":return new vY(t.name);case"":return new bY(t.name)}let n=t.type.match(YX);if(n){let i=parseInt(n[2]||"256");return z(i!==0&&i<=256&&i%8===0,"invalid "+n[1]+" bit length","param",t),new OY(i/8,n[1]==="int",t.name)}if(n=t.type.match(JX),n){let i=parseInt(n[1]);return z(i!==0&&i<=32,"invalid bytes length","param",t),new AY(i,t.name)}z(!1,"invalid type","type",t.type)};let fn=uy;function ZX(e){const t=We(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return qy(t,32)}function tZ(e){const t=et(e,"bytes");if(t.length!==32)throw new Error("invalid bytes32 - not 32 bytes long");if(t[31]!==0)throw new Error("invalid bytes32 string - no null terminator");let n=31;for(;t[n-1]===0;)n--;return as(t.slice(0,n))}class KU{constructor(t,n,i){V(this,"fragment");V(this,"name");V(this,"signature");V(this,"topic");V(this,"args");const a=t.name,o=t.format();ut(this,{fragment:t,name:a,signature:o,topic:n,args:i})}}class QU{constructor(t,n,i,a){V(this,"fragment");V(this,"name");V(this,"args");V(this,"signature");V(this,"selector");V(this,"value");const o=t.name,r=t.format();ut(this,{fragment:t,name:o,args:i,signature:r,selector:n,value:a})}}class JU{constructor(t,n,i){V(this,"fragment");V(this,"name");V(this,"args");V(this,"signature");V(this,"selector");const a=t.name,o=t.format();ut(this,{fragment:t,name:a,args:i,signature:o,selector:n})}}class ev{constructor(t){V(this,"hash");V(this,"_isIndexed");ut(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!!(t&&t._isIndexed)}}const Ew={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},vw={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:e=>`reverted with reason string ${JSON.stringify(e)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:e=>{let t="unknown panic code";return e>=0&&e<=255&&Ew[e.toString()]&&(t=Ew[e.toString()]),`reverted with panic code 0x${e.toString(16)} (${t})`}}};var xs,Es,vs,Yn,Ss,D_,U_;const Bl=class Bl{constructor(t){j(this,Ss);V(this,"fragments");V(this,"deploy");V(this,"fallback");V(this,"receive");j(this,xs);j(this,Es);j(this,vs);j(this,Yn);let n=[];typeof t=="string"?n=JSON.parse(t):n=t,D(this,vs,new Map),D(this,xs,new Map),D(this,Es,new Map);const i=[];for(const r of n)try{i.push(al.from(r))}catch(l){console.log(`[Warning] Invalid Fragment ${JSON.stringify(r)}:`,l.message)}ut(this,{fragments:Object.freeze(i)});let a=null,o=!1;D(this,Yn,this.getAbiCoder()),this.fragments.forEach((r,l)=>{let d;switch(r.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}ut(this,{deploy:r});return;case"fallback":r.inputs.length===0?o=!0:(z(!a||r.payable!==a.payable,"conflicting fallback fragments",`fragments[${l}]`,r),a=r,o=a.payable);return;case"function":d=P(this,vs);break;case"event":d=P(this,Es);break;case"error":d=P(this,xs);break;default:return}const c=r.format();d.has(c)||d.set(c,r)}),this.deploy||ut(this,{deploy:Rs.from("constructor()")}),ut(this,{fallback:a,receive:o})}format(t){const n=t?"minimal":"full";return this.fragments.map(a=>a.format(n))}formatJson(){const t=this.fragments.map(n=>n.format("json"));return JSON.stringify(t.map(n=>JSON.parse(n)))}getAbiCoder(){return fn.defaultAbiCoder()}getFunctionName(t){const n=at(this,Ss,D_).call(this,t,null,!1);return z(n,"no matching function","key",t),n.name}hasFunction(t){return!!at(this,Ss,D_).call(this,t,null,!1)}getFunction(t,n){return at(this,Ss,D_).call(this,t,n||null,!0)}forEachFunction(t){const n=Array.from(P(this,vs).keys());n.sort((i,a)=>i.localeCompare(a));for(let i=0;i