@0xpolygonid/js-sdk 1.0.0-beta.4 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/circuits/models.js +2 -2
- package/dist/cjs/circuits/models.js.map +1 -1
- package/dist/cjs/storage/blockchain/state-abi.json +65 -16
- package/dist/esm/circuits/models.js +2 -2
- package/dist/esm/circuits/models.js.map +1 -1
- package/dist/esm/storage/blockchain/state-abi.json +65 -16
- package/dist/esm_esbuild/index.js +113 -64
- package/dist/esm_esbuild/index.js.map +3 -3
- package/dist/umd/index.js +2 -2
- package/dist/umd/index.js.map +3 -3
- package/package.json +1 -1
package/dist/umd/index.js
CHANGED
|
@@ -343,10 +343,10 @@ GraphViz of the MerkleTree with RootKey ${e.bigInt().toString(10)}
|
|
|
343
343
|
"required": [
|
|
344
344
|
"id"
|
|
345
345
|
]
|
|
346
|
-
}`;var YE=c=>{switch(c){case p1.Index:return"index";case p1.Value:return"value";default:return""}},Ane=(c,e)=>!c&&!c.serialization?ja.None:e!=null&&e!==ja.None?e:ja.Index;s();x();s();x();var Zu,Sne=new Uint8Array(16);function XE(){if(!Zu&&(Zu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Zu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Zu(Sne)}s();x();var df=[];for(let c=0;c<256;++c)df.push((c+256).toString(16).slice(1));function Uq(c,e=0){return(df[c[e+0]]+df[c[e+1]]+df[c[e+2]]+df[c[e+3]]+"-"+df[c[e+4]]+df[c[e+5]]+"-"+df[c[e+6]]+df[c[e+7]]+"-"+df[c[e+8]]+df[c[e+9]]+"-"+df[c[e+10]]+df[c[e+11]]+df[c[e+12]]+df[c[e+13]]+df[c[e+14]]+df[c[e+15]]).toLowerCase()}s();x();s();x();var Ine=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),eA={randomUUID:Ine};function Lne(c,e,a){if(eA.randomUUID&&!e&&!c)return eA.randomUUID();c=c||{};let f=c.random||(c.rng||XE)();if(f[6]=f[6]&15|64,f[8]=f[8]&63|128,e){a=a||0;for(let d=0;d<16;++d)e[a+d]=f[d];return e}return Uq(f)}var If=Lne;s();x();s();x();var _G=Fe(wG()),Une="slots overflow",qne=c=>c.reverse();function vG(c){let e;if(typeof c=="string")e=BigInt(c);else if(typeof c=="number")e=BigInt(Math.trunc(c));else throw new Error("field type is not supported");return H0.intToBytes(e)}function EG(c,e){return Nd(H0.bytesToInt(Uint8Array.from([...c,...e])))}function Gne(c){return Nd(H0.bytesToInt(c))}var gA=c=>{let e=R0.decodeString((0,_G.keccak256)(c));return new kc(e.slice(e.length-16,e.length))},P9=(c,e)=>{let a=Uint8Array.from([]);if(!e)return new Uint8Array(32);let f=c[e];if(!f)throw new Error(`${e} field is not in data`);let d=vG(f);if(EG(a,d))a=Uint8Array.from([...a,...d]);else throw new Error(Une);return a};s();x();s();x();var S4=class{async parseClaim(e,a,f,d){d||(d={revNonce:0,version:0,subjectPosition:"index",merklizedRootPosition:"",updatable:!1});let b=e.credentialSubject.id,t=this.parseSlots(e,f),r=gA(new TextEncoder().encode(a)),o=Uf.newClaim(r,m1.withIndexDataBytes(t.indexA,t.indexB),m1.withValueDataBytes(t.valueA,t.valueB),m1.withRevocationNonce(BigInt(d.revNonce)),m1.withVersion(d.version));if(d.updatable&&o.setFlagUpdatable(d.updatable),e.expirationDate&&o.setExpirationDate(new Date(e.expirationDate)),b){let n=sc.parse(b.toString());switch(d.subjectPosition){case"":case"index":o.setIndexId(n.id);break;case"value":o.setValueId(n.id);break;default:throw new Error("unknown subject position")}}switch(d.merklizedRootPosition){case"index":{let n=await e.merklize();o.setIndexMerklizedRoot((await n.root()).bigInt());break}case"value":{let n=await e.merklize();o.setValueMerklizedRoot((await n.root()).bigInt());break}case"":break;default:throw new Error("unknown merklized root position")}return o}parseSlots(e,a){let f=JSON.parse(new TextDecoder().decode(a));return f?.$metadata?.serialization?this.assignSlots(e.credentialSubject,f.$metadata.serialization):{indexA:new Uint8Array(32),indexB:new Uint8Array(32),valueA:new Uint8Array(32),valueB:new Uint8Array(32)}}assignSlots(e,a){let f={indexA:new Uint8Array(32),indexB:new Uint8Array(32),valueA:new Uint8Array(32),valueB:new Uint8Array(32)};return f.indexA=P9(e,a.indexDataSlotA),f.indexB=P9(e,a.indexDataSlotB),f.valueA=P9(e,a.valueDataSlotA),f.valueB=P9(e,a.valueDataSlotB),f}getFieldSlotIndex(e,a){let f=JSON.parse(new TextDecoder().decode(a));if(!f?.$metadata?.serialization)throw new Error("serialization info is not set");switch(e){case f.$metadata?.serialization?.indexDataSlotA:return 2;case f.$metadata?.serialization?.indexDataSlotB:return 3;case f.$metadata?.serialization?.valueDataSlotA:return 6;case f.$metadata?.serialization?.valueDataSlotB:return 7;default:throw new Error(`field ${e} not specified in serialization info`)}}};s();x();var Sj=Fe(Aj()),jA=class{_ajv;constructor(){this._ajv=new Sj.default({logger:!1})}async validate(e,a){let f=JSON.parse(new TextDecoder().decode(a)),d=JSON.parse(new TextDecoder().decode(e)),b=this._ajv.compile(f);if(!await b(d))throw new Error(b.errors?.map(r=>r.message).join(", "));return!0}};s();x();var T9=(f=>(f[f.Claims=0]="Claims",f[f.Revocations=1]="Revocations",f[f.Roots=2]="Roots",f))(T9||{});s();x();s();x();Ah();var woe=new Function("try {return this===window;}catch(e){ return false;}"),HA=class{constructor(e){this.dir=e}async load(e){if(woe())throw new Error("can not use fs loader in the browser");let a=await(void 0)(`${this.dir}/${e}`);return new Uint8Array(a)}};s();x();s();x();s();x();var _oe=c=>Promise.reject(new Error(`No base found for "${c}"`)),Sh=class{constructor(e){this._basesByName={},this._basesByPrefix={},this._loadBase=e.loadBase||_oe;for(let a of e.bases)this.addBase(a)}addBase(e){if(this._basesByName[e.name]||this._basesByPrefix[e.prefix])throw new Error(`Codec already exists for codec "${e.name}"`);this._basesByName[e.name]=e,this._basesByPrefix[e.prefix]=e}removeBase(e){delete this._basesByName[e.name],delete this._basesByPrefix[e.prefix]}async getBase(e){if(this._basesByName[e])return this._basesByName[e];if(this._basesByPrefix[e])return this._basesByPrefix[e];let a=await this._loadBase(e);return this._basesByName[a.name]==null&&this._basesByPrefix[a.prefix]==null&&this.addBase(a),a}listBases(){return Object.values(this._basesByName)}};s();x();var voe=c=>Promise.reject(new Error(`No codec found for "${c}"`)),Ih=class{constructor(e){this._codecsByName={},this._codecsByCode={},this._loadCodec=e.loadCodec||voe;for(let a of e.codecs)this.addCodec(a)}addCodec(e){if(this._codecsByName[e.name]||this._codecsByCode[e.code])throw new Error(`Resolver already exists for codec "${e.name}"`);this._codecsByName[e.name]=e,this._codecsByCode[e.code]=e}removeCodec(e){delete this._codecsByName[e.name],delete this._codecsByCode[e.code]}async getCodec(e){let a=typeof e=="string"?this._codecsByName:this._codecsByCode;if(a[e])return a[e];let f=await this._loadCodec(e);return a[e]==null&&this.addCodec(f),f}listCodecs(){return Object.values(this._codecsByName)}};s();x();var Eoe=c=>Promise.reject(new Error(`No hasher found for "${c}"`)),Lh=class{constructor(e){this._hashersByName={},this._hashersByCode={},this._loadHasher=e.loadHasher||Eoe;for(let a of e.hashers)this.addHasher(a)}addHasher(e){if(this._hashersByName[e.name]||this._hashersByCode[e.code])throw new Error(`Resolver already exists for codec "${e.name}"`);this._hashersByName[e.name]=e,this._hashersByCode[e.code]=e}removeHasher(e){delete this._hashersByName[e.name],delete this._hashersByCode[e.code]}async getHasher(e){let a=typeof e=="string"?this._hashersByName:this._hashersByCode;if(a[e])return a[e];let f=await this._loadHasher(e);return a[e]==null&&this.addHasher(f),f}listHashers(){return Object.values(this._hashersByName)}};var cS={};v0(cS,{code:()=>wse,createLink:()=>Qj,createNode:()=>Kj,decode:()=>vse,encode:()=>_se,name:()=>yse,prepare:()=>eS,validate:()=>aS});s();x();F0();s();x();var ise=new TextDecoder;function YA(c,e){let a=0;for(let f=0;;f+=7){if(f>=64)throw new Error("protobuf: varint overflow");if(e>=c.length)throw new Error("protobuf: unexpected end of data");let d=c[e++];if(a+=f<28?(d&127)<<f:(d&127)*2**f,d<128)break}return[a,e]}function Nh(c,e){let a;[a,e]=YA(c,e);let f=e+a;if(a<0||f<0)throw new Error("protobuf: invalid length");if(f>c.length)throw new Error("protobuf: unexpected end of data");return[c.subarray(e,f),f]}function Uj(c,e){let a;return[a,e]=YA(c,e),[a&7,a>>3,e]}function ose(c){let e={},a=c.length,f=0;for(;f<a;){let d,b;if([d,b,f]=Uj(c,f),b===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(d!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${d}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,f]=Nh(c,f)}else if(b===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(d!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${d}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let t;[t,f]=Nh(c,f),e.Name=ise.decode(t)}else if(b===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(d!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${d}) for Tsize`);[e.Tsize,f]=YA(c,f)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${b}`)}if(f>a)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function qj(c){let e=c.length,a=0,f,d=!1,b;for(;a<e;){let r,o;if([r,o,a]=Uj(c,a),r!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${r}`);if(o===1){if(b)throw new Error("protobuf: (PBNode) duplicate Data section");[b,a]=Nh(c,a),f&&(d=!0)}else if(o===2){if(d)throw new Error("protobuf: (PBNode) duplicate Links section");f||(f=[]);let n;[n,a]=Nh(c,a),f.push(ose(n))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${o}`)}if(a>e)throw new Error("protobuf: (PBNode) unexpected end of data");let t={};return b&&(t.Data=b),t.Links=f||[],t}s();x();var zj=new TextEncoder,Gj=2**32,sse=2**31;function xse(c,e){let a=e.length;if(typeof c.Tsize=="number"){if(c.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(c.Tsize))throw new Error("Tsize too large for encoding");a=Ti(e,a,c.Tsize)-1,e[a]=24}if(typeof c.Name=="string"){let f=zj.encode(c.Name);a-=f.length,e.set(f,a),a=Ti(e,a,f.length)-1,e[a]=18}return c.Hash&&(a-=c.Hash.length,e.set(c.Hash,a),a=Ti(e,a,c.Hash.length)-1,e[a]=10),e.length-a}function jj(c){let e=use(c),a=new Uint8Array(e),f=e;if(c.Data&&(f-=c.Data.length,a.set(c.Data,f),f=Ti(a,f,c.Data.length)-1,a[f]=10),c.Links)for(let d=c.Links.length-1;d>=0;d--){let b=xse(c.Links[d],a.subarray(0,f));f-=b,f=Ti(a,f,b)-1,a[f]=18}return a}function lse(c){let e=0;if(c.Hash){let a=c.Hash.length;e+=1+a+U9(a)}if(typeof c.Name=="string"){let a=zj.encode(c.Name).length;e+=1+a+U9(a)}return typeof c.Tsize=="number"&&(e+=1+U9(c.Tsize)),e}function use(c){let e=0;if(c.Data){let a=c.Data.length;e+=1+a+U9(a)}if(c.Links)for(let a of c.Links){let f=lse(a);e+=1+f+U9(f)}return e}function Ti(c,e,a){e-=U9(a);let f=e;for(;a>=sse;)c[e++]=a&127|128,a/=128;for(;a>=128;)c[e++]=a&127|128,a>>>=7;return c[e]=a,f}function U9(c){return c%2===0&&c++,Math.floor((hse(c)+6)/7)}function hse(c){let e=0;return c>=Gj&&(c=Math.floor(c/Gj),e=32),c>=1<<16&&(c>>>=16,e+=16),c>=1<<8&&(c>>>=8,e+=8),e+pse[c]}var pse=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];s();x();F0();var mse=["Data","Links"],gse=["Hash","Name","Tsize"],XA=new TextEncoder;function $j(c,e){if(c===e)return 0;let a=c.Name?XA.encode(c.Name):[],f=e.Name?XA.encode(e.Name):[],d=a.length,b=f.length;for(let t=0,r=Math.min(d,b);t<r;++t)if(a[t]!==f[t]){d=a[t],b=f[t];break}return d<b?-1:b<d?1:0}function Hj(c,e){return!Object.keys(c).some(a=>!e.includes(a))}function Vj(c){if(typeof c.asCID=="object"){let a=Re.asCID(c);if(!a)throw new TypeError("Invalid DAG-PB form");return{Hash:a}}if(typeof c!="object"||Array.isArray(c))throw new TypeError("Invalid DAG-PB form");let e={};if(c.Hash){let a=Re.asCID(c.Hash);try{a||(typeof c.Hash=="string"?a=Re.parse(c.Hash):c.Hash instanceof Uint8Array&&(a=Re.decode(c.Hash)))}catch(f){throw new TypeError(`Invalid DAG-PB form: ${f.message}`)}a&&(e.Hash=a)}if(!e.Hash)throw new TypeError("Invalid DAG-PB form");return typeof c.Name=="string"&&(e.Name=c.Name),typeof c.Tsize=="number"&&(e.Tsize=c.Tsize),e}function eS(c){if((c instanceof Uint8Array||typeof c=="string")&&(c={Data:c}),typeof c!="object"||Array.isArray(c))throw new TypeError("Invalid DAG-PB form");let e={};if(c.Data!==void 0)if(typeof c.Data=="string")e.Data=XA.encode(c.Data);else if(c.Data instanceof Uint8Array)e.Data=c.Data;else throw new TypeError("Invalid DAG-PB form");if(c.Links!==void 0)if(Array.isArray(c.Links))e.Links=c.Links.map(Vj),e.Links.sort($j);else throw new TypeError("Invalid DAG-PB form");else e.Links=[];return e}function aS(c){if(!c||typeof c!="object"||Array.isArray(c))throw new TypeError("Invalid DAG-PB form");if(!Hj(c,mse))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(c.Data!==void 0&&!(c.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be a Uint8Array)");if(!Array.isArray(c.Links))throw new TypeError("Invalid DAG-PB form (Links must be an array)");for(let e=0;e<c.Links.length;e++){let a=c.Links[e];if(!a||typeof a!="object"||Array.isArray(a))throw new TypeError("Invalid DAG-PB form (bad link object)");if(!Hj(a,gse))throw new TypeError("Invalid DAG-PB form (extraneous properties on link object)");if(!a.Hash)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(a.Hash.asCID!==a.Hash)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(a.Name!==void 0&&typeof a.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(a.Tsize!==void 0&&(typeof a.Tsize!="number"||a.Tsize%1!==0))throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(e>0&&$j(a,c.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function Kj(c,e=[]){return eS({Data:c,Links:e})}function Qj(c,e,a){return Vj({Hash:a,Name:c,Tsize:e})}var yse="dag-pb",wse=112;function _se(c){aS(c);let e={};return c.Links&&(e.Links=c.Links.map(a=>{let f={};return a.Hash&&(f.Hash=a.Hash.bytes),a.Name!==void 0&&(f.Name=a.Name),a.Tsize!==void 0&&(f.Tsize=a.Tsize),f})),c.Data&&(e.Data=c.Data),jj(e)}function vse(c){let e=qj(c),a={};return e.Data&&(a.Data=e.Data),e.Links&&(a.Links=e.Links.map(f=>{let d={};try{d.Hash=Re.decode(f.Hash)}catch{}if(!d.Hash)throw new Error("Invalid Hash field found in link, expected CID");return f.Name!==void 0&&(d.Name=f.Name),f.Tsize!==void 0&&(d.Tsize=f.Tsize),d})),a}var wS={};v0(wS,{code:()=>cxe,decode:()=>dxe,encode:()=>fxe,name:()=>axe});s();x();Qh();F0();var a$=42;function Jse(c){if(c.asCID!==c)return null;let e=Re.asCID(c);if(!e)return null;let a=new Uint8Array(e.bytes.byteLength+1);return a.set(e.bytes,1),[new Ne(xe.tag,a$),new Ne(xe.bytes,a)]}function Zse(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Yse(c){if(Number.isNaN(c))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(c===1/0||c===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var Xse={float64:!0,typeEncoders:{Object:Jse,undefined:Zse,number:Yse}};function exe(c){if(c[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return Re.decode(c.subarray(1))}var c$={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};c$.tags[a$]=exe;var axe="dag-cbor",cxe=113,fxe=c=>Ui(c,Xse),dxe=c=>B4(c,c$);var RS={};v0(RS,{code:()=>hxe,decode:()=>mxe,encode:()=>pxe,name:()=>uxe});s();x();AS();zi();Qh();s();x();s();x();Zf();mS();Zd();F7();var SS=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let a=this.inRecursive[this.inRecursive.length-1];a&&(a.type===xe.array&&(a.elements++,a.elements!==1&&e.push([44])),a.type===xe.map&&(a.elements++,a.elements!==1&&(a.elements%2===1?e.push([44]):e.push([58]))))}[xe.uint.major](e,a){this.prefix(e);let f=String(a.value),d=[];for(let b=0;b<f.length;b++)d[b]=f.charCodeAt(b);e.push(d)}[xe.negint.major](e,a){this[xe.uint.major](e,a)}[xe.bytes.major](e,a){throw new Error(`${W3} unsupported type: Uint8Array`)}[xe.string.major](e,a){this.prefix(e);let f=Dh(JSON.stringify(a.value));e.push(f.length>32?Oi(f):f)}[xe.array.major](e,a){this.prefix(e),this.inRecursive.push({type:xe.array,elements:0}),e.push([91])}[xe.map.major](e,a){this.prefix(e),this.inRecursive.push({type:xe.map,elements:0}),e.push([123])}[xe.tag.major](e,a){}[xe.float.major](e,a){if(a.type.name==="break"){let t=this.inRecursive.pop();if(t){if(t.type===xe.array)e.push([93]);else if(t.type===xe.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(a.value===void 0)throw new Error(`${W3} unsupported type: undefined`);if(this.prefix(e),a.type.name==="true"){e.push([116,114,117,101]);return}else if(a.type.name==="false"){e.push([102,97,108,115,101]);return}else if(a.type.name==="null"){e.push([110,117,108,108]);return}let f=String(a.value),d=[],b=!1;for(let t=0;t<f.length;t++)d[t]=f.charCodeAt(t),!b&&(d[t]===46||d[t]===101||d[t]===69)&&(b=!0);b||(d.push(46),d.push(48)),e.push(d)}};function rxe(c,e){if(Array.isArray(c[0])||Array.isArray(e[0]))throw new Error(`${W3} complex map keys are not supported`);let a=c[0],f=e[0];if(a.type!==xe.string||f.type!==xe.string)throw new Error(`${W3} non-string map keys are not supported`);if(a<f)return-1;if(a>f)return 1;throw new Error(`${W3} unexpected duplicate map keys, this is not supported`)}var nxe={addBreakTokens:!0,mapSorter:rxe};function IS(c,e){return e=Object.assign({},nxe,e),pS(c,new SS,e)}s();x();yS();Zf();F7();Zd();var V9=class{constructor(e,a={}){this.pos=0,this.data=e,this.options=a,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this.pos]}expect(e){if(this.data.length-this.pos<e.length)throw new Error(`${f0} unexpected end of input at position ${this.pos}`);for(let a=0;a<e.length;a++)if(this.data[this.pos++]!==e[a])throw new Error(`${f0} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this.pos,a=!1,f=!1,d=r=>{for(;!this.done();){let o=this.ch();if(r.includes(o))this.pos++;else break}};if(this.ch()===45&&(a=!0,this.pos++),this.ch()===48)if(this.pos++,this.ch()===46)this.pos++,f=!0;else return new Ne(xe.uint,0,this.pos-e);if(d([48,49,50,51,52,53,54,55,56,57]),a&&this.pos===e+1)throw new Error(`${f0} unexpected token at position ${this.pos}`);if(!this.done()&&this.ch()===46){if(f)throw new Error(`${f0} unexpected token at position ${this.pos}`);f=!0,this.pos++,d([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(f=!0,this.pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this.pos++,d([48,49,50,51,52,53,54,55,56,57]));let b=String.fromCharCode.apply(null,this.data.subarray(e,this.pos)),t=parseFloat(b);return f?new Ne(xe.float,t,this.pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(t)?new Ne(t>=0?xe.uint:xe.negint,t,this.pos-e):new Ne(t>=0?xe.uint:xe.negint,BigInt(b),this.pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${f0} unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let b=this.pos,t=0;b<this.data.length&&t<65536;b++,t++){let r=this.data[b];if(r===92||r<32||r>=128)break;if(r===34){let o=String.fromCharCode.apply(null,this.data.subarray(this.pos,b));return this.pos=b+1,new Ne(xe.string,o,t)}}let e=this.pos,a=[],f=()=>{if(this.pos+4>=this.data.length)throw new Error(`${f0} unexpected end of unicode escape sequence at position ${this.pos}`);let b=0;for(let t=0;t<4;t++){let r=this.ch();if(r>=48&&r<=57)r-=48;else if(r>=97&&r<=102)r=r-97+10;else if(r>=65&&r<=70)r=r-65+10;else throw new Error(`${f0} unexpected unicode escape character at position ${this.pos}`);b=b*16+r,this.pos++}return b},d=()=>{let b=this.ch(),t=null,r=b>239?4:b>223?3:b>191?2:1;if(this.pos+r>this.data.length)throw new Error(`${f0} unexpected unicode sequence at position ${this.pos}`);let o,n,i,l;switch(r){case 1:b<128&&(t=b);break;case 2:o=this.data[this.pos+1],(o&192)===128&&(l=(b&31)<<6|o&63,l>127&&(t=l));break;case 3:o=this.data[this.pos+1],n=this.data[this.pos+2],(o&192)===128&&(n&192)===128&&(l=(b&15)<<12|(o&63)<<6|n&63,l>2047&&(l<55296||l>57343)&&(t=l));break;case 4:o=this.data[this.pos+1],n=this.data[this.pos+2],i=this.data[this.pos+3],(o&192)===128&&(n&192)===128&&(i&192)===128&&(l=(b&15)<<18|(o&63)<<12|(n&63)<<6|i&63,l>65535&&l<1114112&&(t=l))}t===null?(t=65533,r=1):t>65535&&(t-=65536,a.push(t>>>10&1023|55296),t=56320|t&1023),a.push(t),this.pos+=r};for(;!this.done();){let b=this.ch(),t;switch(b){case 92:if(this.pos++,this.done())throw new Error(`${f0} unexpected string termination at position ${this.pos}`);switch(t=this.ch(),this.pos++,t){case 34:case 39:case 92:case 47:a.push(t);break;case 98:a.push(8);break;case 116:a.push(9);break;case 110:a.push(10);break;case 102:a.push(12);break;case 114:a.push(13);break;case 117:a.push(f());break;default:throw new Error(`${f0} unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new Ne(xe.string,fS(a),this.pos-e);default:if(b<32)throw new Error(`${f0} invalid control character at position ${this.pos}`);b<128?(a.push(b),this.pos++):d()}}throw new Error(`${f0} unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new Ne(xe.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new Ne(xe.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new Ne(xe.null,null,4);case 102:return this.expect([102,97,108,115,101]),new Ne(xe.false,!1,5);case 116:return this.expect([116,114,117,101]),new Ne(xe.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${f0} unexpected character at position ${this.pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this.pos++,this.skipWhitespace(),new Ne(xe.break,void 0,1);if(this.ch()!==44)throw new Error(`${f0} unexpected character at position ${this.pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this.pos++,this.skipWhitespace(),new Ne(xe.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this.pos++,this.skipWhitespace(),new Ne(xe.break,void 0,1);if(this.ch()!==44)throw new Error(`${f0} unexpected character at position ${this.pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this.pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this.pos++,this.skipWhitespace(),new Ne(xe.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${f0} unexpected character at position ${this.pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${f0} unexpected parse state at position ${this.pos}; this shouldn't happen`)}}};function LS(c,e){return e=Object.assign({tokenizer:new V9(c,e)},e),B4(c,e)}function oxe(c){if(c.asCID!==c)return null;let e=Re.asCID(c);if(!e)return null;let a=e.toString();return[new Ne(xe.map,1/0,1),new Ne(xe.string,"/",1),new Ne(xe.string,a,a.length),new Ne(xe.break,void 0,1)]}function d$(c){let e=Wh.encode(c).slice(1);return[new Ne(xe.map,1/0,1),new Ne(xe.string,"/",1),new Ne(xe.map,1/0,1),new Ne(xe.string,"bytes",5),new Ne(xe.string,e,e.length),new Ne(xe.break,void 0,1),new Ne(xe.break,void 0,1)]}function sxe(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function xxe(c){if(Number.isNaN(c))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(c===1/0||c===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var lxe={typeEncoders:{Object:oxe,Uint8Array:d$,Buffer:d$,undefined:sxe,number:xxe}},FS=class extends V9{constructor(e,a){super(e,a),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===xe.map){let a=this._next();if(a.type===xe.string&&a.value==="/"){let f=this._next();if(f.type===xe.string){if(this._next().type!==xe.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(f),new Ne(xe.tag,42,0)}if(f.type===xe.map){let d=this._next();if(d.type===xe.string&&d.value==="bytes"){let b=this._next();if(b.type===xe.string){for(let r=0;r<2;r++)if(this._next().type!==xe.break)throw new Error("Invalid encoded Bytes form");let t=Wh.decode(`m${b.value}`);return new Ne(xe.bytes,t,b.value.length)}this.tokenBuffer.push(b)}this.tokenBuffer.push(d)}this.tokenBuffer.push(f)}this.tokenBuffer.push(a)}return e}},CS={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};CS.tags[42]=Re.parse;var uxe="dag-json",hxe=297,pxe=c=>IS(c,lxe),mxe=c=>{let e=Object.assign(CS,{tokenizer:new FS(c,CS)});return LS(c,e)};var xpe=Fe(m$(),1);kS();WS();s();x();s();x();F0();s();x();s();x();var RI=Fe(Yf(),1),Nb=Fe(lI(),1);s();x();var pue=/(-?(?:\d+\.?\d*|\d*\.?\d+)(?:e[-+]?\d+)?)\s*([\p{L}]*)/uig;U0.nanosecond=U0.ns=1/1e6;U0.\u00B5s=U0.\u03BCs=U0.us=U0.microsecond=1/1e3;U0.millisecond=U0.ms=U0[""]=1;U0.second=U0.sec=U0.s=U0.ms*1e3;U0.minute=U0.min=U0.m=U0.s*60;U0.hour=U0.hr=U0.h=U0.m*60;U0.day=U0.d=U0.h*24;U0.week=U0.wk=U0.w=U0.d*7;U0.month=U0.b=U0.d*(365.25/12);U0.year=U0.yr=U0.y=U0.d*365.25;function U0(c="",e="ms"){var a=null;return c=(c+"").replace(/(\d)[,_](\d)/g,"$1$2"),c.replace(pue,function(f,d,b){b=OV(b),b&&(a=(a||0)+parseFloat(d,10)*b)}),a&&a/(OV(e)||1)}function OV(c){return U0[c]||U0[c.toLowerCase().replace(/s$/,"")]}var NV=U0;var SK=Fe(uI(),1),k4=Fe(mp(),1);s();x();var pK=Fe(EI(),1),mK=pK.default;s();x();var wK=Fe(Yf(),1),_K=Fe(yK(),1);function CI(c){try{c=(0,_K.default)(new wK.Multiaddr(c))}catch{}return c=c.toString(),c}s();x();var vK=()=>{};var EK=(0,SK.default)("ipfs-http-client:lib:error-handler"),mhe=mK.bind({ignoreUndefined:!0}),ghe=Nb.isBrowser||Nb.isWebWorker?location.protocol:"http",yhe=Nb.isBrowser||Nb.isWebWorker?location.hostname:"localhost",whe=Nb.isBrowser||Nb.isWebWorker?location.port:"5001",_he=(c={})=>{let e,a={},f;if(typeof c=="string"||RI.Multiaddr.isMultiaddr(c))e=new URL(CI(c));else if(c instanceof URL)e=c;else if(typeof c.url=="string"||RI.Multiaddr.isMultiaddr(c.url))e=new URL(CI(c.url)),a=c;else if(c.url instanceof URL)e=c.url,a=c;else{a=c||{};let d=(a.protocol||ghe).replace(":",""),b=(a.host||yhe).split(":")[0],t=a.port||whe;e=new URL(`${d}://${b}:${t}`)}if(a.apiPath?e.pathname=a.apiPath:(e.pathname==="/"||e.pathname===void 0)&&(e.pathname="api/v0"),Nb.isNode){let d=vK(e);f=a.agent||new d({keepAlive:!0,maxSockets:6})}return{...a,host:e.host,protocol:e.protocol.replace(":",""),port:Number(e.port),apiPath:e.pathname,url:e,agent:f}},vhe=async c=>{let e;try{if((c.headers.get("Content-Type")||"").startsWith("application/json")){let f=await c.json();EK(f),e=f.Message||f.message}else e=await c.text()}catch(f){EK("Failed to parse error response",f),e=f.message}let a=new k4.default.HTTPError(c);throw e&&(e.includes("deadline has elapsed")&&(a=new k4.default.TimeoutError),e&&e.includes("context deadline exceeded")&&(a=new k4.default.TimeoutError)),e&&e.includes("request timed out")&&(a=new k4.default.TimeoutError),e&&(a.message=e),a},Ehe=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,AK=c=>c.replace(Ehe,function(e){return"-"+e.toLowerCase()}),Ahe=c=>typeof c=="string"?NV(c):c,T7=class extends k4.default{constructor(e={}){let a=_he(e);super({timeout:Ahe(a.timeout||0)||void 0,headers:a.headers,base:`${a.url}`,handleError:vhe,transformSearchParams:d=>{let b=new URLSearchParams;for(let[t,r]of d)r!=="undefined"&&r!=="null"&&t!=="signal"&&b.append(AK(t),r),t==="timeout"&&!isNaN(r)&&b.append(AK(t),r);return b},agent:a.agent}),delete this.get,delete this.put,delete this.delete,delete this.options;let f=this.fetch;this.fetch=(d,b={})=>(typeof d=="string"&&!d.startsWith("/")&&(d=`${a.url}/${d}`),f.call(this,d,mhe(b,{method:"POST"})))}},$b0=k4.default.HTTPError;var ne=c=>e=>c(new T7(e),e);s();x();s();x();function yp(c){if(c!=null)return typeof c=="string"?c:c.toString(8).padStart(4,"0")}s();x();var IK=Fe(Ed(),1);function wp(c){if(c==null)return;let e;if(c.secs!=null&&(e={secs:c.secs,nsecs:c.nsecs}),c.Seconds!=null&&(e={secs:c.Seconds,nsecs:c.FractionalNanoseconds}),Array.isArray(c)&&(e={secs:c[0],nsecs:c[1]}),c instanceof Date){let a=c.getTime(),f=Math.floor(a/1e3);e={secs:f,nsecs:(a-f*1e3)*1e3}}if(!!Object.prototype.hasOwnProperty.call(e,"secs")){if(e!=null&&e.nsecs!=null&&(e.nsecs<0||e.nsecs>999999999))throw(0,IK.default)(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return e}}function oe({arg:c,searchParams:e,hashAlg:a,mtime:f,mode:d,...b}={}){e&&(b={...b,...e}),a&&(b.hash=a),f!=null&&(f=wp(f),b.mtime=f.secs,b.mtimeNsecs=f.nsecs),d!=null&&(b.mode=yp(d)),b.timeout&&!isNaN(b.timeout)&&(b.timeout=`${b.timeout}ms`),c==null?c=[]:Array.isArray(c)||(c=[c]);let t=new URLSearchParams(b);return c.forEach(r=>t.append("arg",r)),t}var LK=ne(c=>{async function e(a={}){return((await(await c.post("bitswap/wantlist",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).Keys||[]).map(d=>Re.parse(d["/"]))}return e});s();x();F0();var FK=ne(c=>{async function e(a,f={}){return((await(await c.post("bitswap/wantlist",{signal:f.signal,searchParams:oe({...f,peer:a.toString()}),headers:f.headers})).json()).Keys||[]).map(b=>Re.parse(b["/"]))}return e});s();x();F0();var _p=ne(c=>{async function e(a={}){let f=await c.post("bitswap/stat",{searchParams:oe(a),signal:a.signal,headers:a.headers});return She(await f.json())}return e});function She(c){return{provideBufLen:c.ProvideBufLen,wantlist:(c.Wantlist||[]).map(e=>Re.parse(e["/"])),peers:c.Peers||[],blocksReceived:BigInt(c.BlocksReceived),dataReceived:BigInt(c.DataReceived),blocksSent:BigInt(c.BlocksSent),dataSent:BigInt(c.DataSent),dupBlksReceived:BigInt(c.DupBlksReceived),dupDataReceived:BigInt(c.DupDataReceived)}}s();x();var CK=ne(c=>{async function e(a,f={}){return(await c.post("bitswap/unwant",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers})).json()}return e});function RK(c){return{wantlist:LK(c),wantlistForPeer:FK(c),unwant:CK(c),stat:_p(c)}}s();x();s();x();var vp=ne(c=>{async function e(a,f={}){let d=await c.post("block/get",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers});return new Uint8Array(await d.arrayBuffer())}return e});s();x();F0();s();x();s();x();s();x();var TK=Fe(Ed(),1),OK=Fe(Zi(),1),NK=Fe(D4(),1),MK=Fe(pp(),1);s();x();function H2(c){return ArrayBuffer.isView(c)||c instanceof ArrayBuffer}function Z3(c){return c.constructor&&(c.constructor.name==="Blob"||c.constructor.name==="File")&&typeof c.stream=="function"}function Yi(c){return typeof c=="object"&&(c.path||c.content)}var Y3=c=>c&&typeof c.getReader=="function";async function DK(c){if(H2(c))return new Blob([c]);if(typeof c=="string"||c instanceof String)return new Blob([c.toString()]);if(Z3(c))return c;if(Y3(c)&&(c=(0,NK.default)(c)),Symbol.iterator in c||Symbol.asyncIterator in c){let e=(0,OK.default)(c),{value:a,done:f}=await e.peek();if(f)return PK(e);if(e.push(a),Number.isInteger(a))return new Blob([Uint8Array.from(await(0,MK.default)(e))]);if(H2(a)||typeof a=="string"||a instanceof String)return PK(e)}throw(0,TK.default)(new Error(`Unexpected input: ${c}`),"ERR_UNEXPECTED_INPUT")}async function PK(c){let e=[];for await(let a of c)e.push(a);return new Blob(e)}s();x();var co=Fe(Ed(),1),DQ=Fe(D4(),1),kQ=Fe(Zi(),1),KI=Fe(BI(),1);s();x();var MQ=Fe(Ed(),1);s();x();var X3=Fe(NQ(),1),bt=X3.default.Reader,$I=X3.default.Writer,u0=X3.default.util,tf=X3.default.roots["ipfs-unixfs"]||(X3.default.roots["ipfs-unixfs"]={}),Dhe=tf.Data=(()=>{function c(e){if(this.blocksizes=[],e)for(var a=Object.keys(e),f=0;f<a.length;++f)e[a[f]]!=null&&(this[a[f]]=e[a[f]])}return c.prototype.Type=0,c.prototype.Data=u0.newBuffer([]),c.prototype.filesize=u0.Long?u0.Long.fromBits(0,0,!0):0,c.prototype.blocksizes=u0.emptyArray,c.prototype.hashType=u0.Long?u0.Long.fromBits(0,0,!0):0,c.prototype.fanout=u0.Long?u0.Long.fromBits(0,0,!0):0,c.prototype.mode=0,c.prototype.mtime=null,c.encode=function(a,f){if(f||(f=$I.create()),f.uint32(8).int32(a.Type),a.Data!=null&&Object.hasOwnProperty.call(a,"Data")&&f.uint32(18).bytes(a.Data),a.filesize!=null&&Object.hasOwnProperty.call(a,"filesize")&&f.uint32(24).uint64(a.filesize),a.blocksizes!=null&&a.blocksizes.length)for(var d=0;d<a.blocksizes.length;++d)f.uint32(32).uint64(a.blocksizes[d]);return a.hashType!=null&&Object.hasOwnProperty.call(a,"hashType")&&f.uint32(40).uint64(a.hashType),a.fanout!=null&&Object.hasOwnProperty.call(a,"fanout")&&f.uint32(48).uint64(a.fanout),a.mode!=null&&Object.hasOwnProperty.call(a,"mode")&&f.uint32(56).uint32(a.mode),a.mtime!=null&&Object.hasOwnProperty.call(a,"mtime")&&tf.UnixTime.encode(a.mtime,f.uint32(66).fork()).ldelim(),f},c.decode=function(a,f){a instanceof bt||(a=bt.create(a));for(var d=f===void 0?a.len:a.pos+f,b=new tf.Data;a.pos<d;){var t=a.uint32();switch(t>>>3){case 1:b.Type=a.int32();break;case 2:b.Data=a.bytes();break;case 3:b.filesize=a.uint64();break;case 4:if(b.blocksizes&&b.blocksizes.length||(b.blocksizes=[]),(t&7)===2)for(var r=a.uint32()+a.pos;a.pos<r;)b.blocksizes.push(a.uint64());else b.blocksizes.push(a.uint64());break;case 5:b.hashType=a.uint64();break;case 6:b.fanout=a.uint64();break;case 7:b.mode=a.uint32();break;case 8:b.mtime=tf.UnixTime.decode(a,a.uint32());break;default:a.skipType(t&7);break}}if(!b.hasOwnProperty("Type"))throw u0.ProtocolError("missing required 'Type'",{instance:b});return b},c.fromObject=function(a){if(a instanceof tf.Data)return a;var f=new tf.Data;switch(a.Type){case"Raw":case 0:f.Type=0;break;case"Directory":case 1:f.Type=1;break;case"File":case 2:f.Type=2;break;case"Metadata":case 3:f.Type=3;break;case"Symlink":case 4:f.Type=4;break;case"HAMTShard":case 5:f.Type=5;break}if(a.Data!=null&&(typeof a.Data=="string"?u0.base64.decode(a.Data,f.Data=u0.newBuffer(u0.base64.length(a.Data)),0):a.Data.length&&(f.Data=a.Data)),a.filesize!=null&&(u0.Long?(f.filesize=u0.Long.fromValue(a.filesize)).unsigned=!0:typeof a.filesize=="string"?f.filesize=parseInt(a.filesize,10):typeof a.filesize=="number"?f.filesize=a.filesize:typeof a.filesize=="object"&&(f.filesize=new u0.LongBits(a.filesize.low>>>0,a.filesize.high>>>0).toNumber(!0))),a.blocksizes){if(!Array.isArray(a.blocksizes))throw TypeError(".Data.blocksizes: array expected");f.blocksizes=[];for(var d=0;d<a.blocksizes.length;++d)u0.Long?(f.blocksizes[d]=u0.Long.fromValue(a.blocksizes[d])).unsigned=!0:typeof a.blocksizes[d]=="string"?f.blocksizes[d]=parseInt(a.blocksizes[d],10):typeof a.blocksizes[d]=="number"?f.blocksizes[d]=a.blocksizes[d]:typeof a.blocksizes[d]=="object"&&(f.blocksizes[d]=new u0.LongBits(a.blocksizes[d].low>>>0,a.blocksizes[d].high>>>0).toNumber(!0))}if(a.hashType!=null&&(u0.Long?(f.hashType=u0.Long.fromValue(a.hashType)).unsigned=!0:typeof a.hashType=="string"?f.hashType=parseInt(a.hashType,10):typeof a.hashType=="number"?f.hashType=a.hashType:typeof a.hashType=="object"&&(f.hashType=new u0.LongBits(a.hashType.low>>>0,a.hashType.high>>>0).toNumber(!0))),a.fanout!=null&&(u0.Long?(f.fanout=u0.Long.fromValue(a.fanout)).unsigned=!0:typeof a.fanout=="string"?f.fanout=parseInt(a.fanout,10):typeof a.fanout=="number"?f.fanout=a.fanout:typeof a.fanout=="object"&&(f.fanout=new u0.LongBits(a.fanout.low>>>0,a.fanout.high>>>0).toNumber(!0))),a.mode!=null&&(f.mode=a.mode>>>0),a.mtime!=null){if(typeof a.mtime!="object")throw TypeError(".Data.mtime: object expected");f.mtime=tf.UnixTime.fromObject(a.mtime)}return f},c.toObject=function(a,f){f||(f={});var d={};if((f.arrays||f.defaults)&&(d.blocksizes=[]),f.defaults){if(d.Type=f.enums===String?"Raw":0,f.bytes===String?d.Data="":(d.Data=[],f.bytes!==Array&&(d.Data=u0.newBuffer(d.Data))),u0.Long){var b=new u0.Long(0,0,!0);d.filesize=f.longs===String?b.toString():f.longs===Number?b.toNumber():b}else d.filesize=f.longs===String?"0":0;if(u0.Long){var b=new u0.Long(0,0,!0);d.hashType=f.longs===String?b.toString():f.longs===Number?b.toNumber():b}else d.hashType=f.longs===String?"0":0;if(u0.Long){var b=new u0.Long(0,0,!0);d.fanout=f.longs===String?b.toString():f.longs===Number?b.toNumber():b}else d.fanout=f.longs===String?"0":0;d.mode=0,d.mtime=null}if(a.Type!=null&&a.hasOwnProperty("Type")&&(d.Type=f.enums===String?tf.Data.DataType[a.Type]:a.Type),a.Data!=null&&a.hasOwnProperty("Data")&&(d.Data=f.bytes===String?u0.base64.encode(a.Data,0,a.Data.length):f.bytes===Array?Array.prototype.slice.call(a.Data):a.Data),a.filesize!=null&&a.hasOwnProperty("filesize")&&(typeof a.filesize=="number"?d.filesize=f.longs===String?String(a.filesize):a.filesize:d.filesize=f.longs===String?u0.Long.prototype.toString.call(a.filesize):f.longs===Number?new u0.LongBits(a.filesize.low>>>0,a.filesize.high>>>0).toNumber(!0):a.filesize),a.blocksizes&&a.blocksizes.length){d.blocksizes=[];for(var t=0;t<a.blocksizes.length;++t)typeof a.blocksizes[t]=="number"?d.blocksizes[t]=f.longs===String?String(a.blocksizes[t]):a.blocksizes[t]:d.blocksizes[t]=f.longs===String?u0.Long.prototype.toString.call(a.blocksizes[t]):f.longs===Number?new u0.LongBits(a.blocksizes[t].low>>>0,a.blocksizes[t].high>>>0).toNumber(!0):a.blocksizes[t]}return a.hashType!=null&&a.hasOwnProperty("hashType")&&(typeof a.hashType=="number"?d.hashType=f.longs===String?String(a.hashType):a.hashType:d.hashType=f.longs===String?u0.Long.prototype.toString.call(a.hashType):f.longs===Number?new u0.LongBits(a.hashType.low>>>0,a.hashType.high>>>0).toNumber(!0):a.hashType),a.fanout!=null&&a.hasOwnProperty("fanout")&&(typeof a.fanout=="number"?d.fanout=f.longs===String?String(a.fanout):a.fanout:d.fanout=f.longs===String?u0.Long.prototype.toString.call(a.fanout):f.longs===Number?new u0.LongBits(a.fanout.low>>>0,a.fanout.high>>>0).toNumber(!0):a.fanout),a.mode!=null&&a.hasOwnProperty("mode")&&(d.mode=a.mode),a.mtime!=null&&a.hasOwnProperty("mtime")&&(d.mtime=tf.UnixTime.toObject(a.mtime,f)),d},c.prototype.toJSON=function(){return this.constructor.toObject(this,X3.default.util.toJSONOptions)},c.DataType=function(){let e={},a=Object.create(e);return a[e[0]="Raw"]=0,a[e[1]="Directory"]=1,a[e[2]="File"]=2,a[e[3]="Metadata"]=3,a[e[4]="Symlink"]=4,a[e[5]="HAMTShard"]=5,a}(),c})(),f70=tf.UnixTime=(()=>{function c(e){if(e)for(var a=Object.keys(e),f=0;f<a.length;++f)e[a[f]]!=null&&(this[a[f]]=e[a[f]])}return c.prototype.Seconds=u0.Long?u0.Long.fromBits(0,0,!1):0,c.prototype.FractionalNanoseconds=0,c.encode=function(a,f){return f||(f=$I.create()),f.uint32(8).int64(a.Seconds),a.FractionalNanoseconds!=null&&Object.hasOwnProperty.call(a,"FractionalNanoseconds")&&f.uint32(21).fixed32(a.FractionalNanoseconds),f},c.decode=function(a,f){a instanceof bt||(a=bt.create(a));for(var d=f===void 0?a.len:a.pos+f,b=new tf.UnixTime;a.pos<d;){var t=a.uint32();switch(t>>>3){case 1:b.Seconds=a.int64();break;case 2:b.FractionalNanoseconds=a.fixed32();break;default:a.skipType(t&7);break}}if(!b.hasOwnProperty("Seconds"))throw u0.ProtocolError("missing required 'Seconds'",{instance:b});return b},c.fromObject=function(a){if(a instanceof tf.UnixTime)return a;var f=new tf.UnixTime;return a.Seconds!=null&&(u0.Long?(f.Seconds=u0.Long.fromValue(a.Seconds)).unsigned=!1:typeof a.Seconds=="string"?f.Seconds=parseInt(a.Seconds,10):typeof a.Seconds=="number"?f.Seconds=a.Seconds:typeof a.Seconds=="object"&&(f.Seconds=new u0.LongBits(a.Seconds.low>>>0,a.Seconds.high>>>0).toNumber())),a.FractionalNanoseconds!=null&&(f.FractionalNanoseconds=a.FractionalNanoseconds>>>0),f},c.toObject=function(a,f){f||(f={});var d={};if(f.defaults){if(u0.Long){var b=new u0.Long(0,0,!1);d.Seconds=f.longs===String?b.toString():f.longs===Number?b.toNumber():b}else d.Seconds=f.longs===String?"0":0;d.FractionalNanoseconds=0}return a.Seconds!=null&&a.hasOwnProperty("Seconds")&&(typeof a.Seconds=="number"?d.Seconds=f.longs===String?String(a.Seconds):a.Seconds:d.Seconds=f.longs===String?u0.Long.prototype.toString.call(a.Seconds):f.longs===Number?new u0.LongBits(a.Seconds.low>>>0,a.Seconds.high>>>0).toNumber():a.Seconds),a.FractionalNanoseconds!=null&&a.hasOwnProperty("FractionalNanoseconds")&&(d.FractionalNanoseconds=a.FractionalNanoseconds),d},c.prototype.toJSON=function(){return this.constructor.toObject(this,X3.default.util.toJSONOptions)},c})(),d70=tf.Metadata=(()=>{function c(e){if(e)for(var a=Object.keys(e),f=0;f<a.length;++f)e[a[f]]!=null&&(this[a[f]]=e[a[f]])}return c.prototype.MimeType="",c.encode=function(a,f){return f||(f=$I.create()),a.MimeType!=null&&Object.hasOwnProperty.call(a,"MimeType")&&f.uint32(10).string(a.MimeType),f},c.decode=function(a,f){a instanceof bt||(a=bt.create(a));for(var d=f===void 0?a.len:a.pos+f,b=new tf.Metadata;a.pos<d;){var t=a.uint32();switch(t>>>3){case 1:b.MimeType=a.string();break;default:a.skipType(t&7);break}}return b},c.fromObject=function(a){if(a instanceof tf.Metadata)return a;var f=new tf.Metadata;return a.MimeType!=null&&(f.MimeType=String(a.MimeType)),f},c.toObject=function(a,f){f||(f={});var d={};return f.defaults&&(d.MimeType=""),a.MimeType!=null&&a.hasOwnProperty("MimeType")&&(d.MimeType=a.MimeType),d},c.prototype.toJSON=function(){return this.constructor.toObject(this,X3.default.util.toJSONOptions)},c})();var r70=parseInt("0644",8),n70=parseInt("0755",8);function Lp(c){if(c!=null)return typeof c=="number"?c&4095:(c=c.toString(),c.substring(0,1)==="0"?parseInt(c,8)&4095:parseInt(c,10)&4095)}function Fp(c){if(c==null)return;let e;if(c.secs!=null&&(e={secs:c.secs,nsecs:c.nsecs}),c.Seconds!=null&&(e={secs:c.Seconds,nsecs:c.FractionalNanoseconds}),Array.isArray(c)&&(e={secs:c[0],nsecs:c[1]}),c instanceof Date){let a=c.getTime(),f=Math.floor(a/1e3);e={secs:f,nsecs:(a-f*1e3)*1e3}}if(!!Object.prototype.hasOwnProperty.call(e,"secs")){if(e!=null&&e.nsecs!=null&&(e.nsecs<0||e.nsecs>999999999))throw(0,MQ.default)(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return e}}async function*UQ(c,e){if(typeof c=="string"||c instanceof String||H2(c)||Z3(c)||c._readableState)throw(0,co.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT");if(Y3(c)&&(c=(0,DQ.default)(c)),Symbol.iterator in c||Symbol.asyncIterator in c){let a=(0,kQ.default)(c),{value:f,done:d}=await a.peek();if(d){yield*[];return}if(a.push(f),Number.isInteger(f))throw(0,co.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT");if(f._readableState){yield*(0,KI.default)(a,b=>VI({content:b},e));return}if(H2(f)){yield VI({content:a},e);return}if(Yi(f)||f[Symbol.iterator]||f[Symbol.asyncIterator]||Y3(f)||Z3(f)){yield*(0,KI.default)(a,b=>VI(b,e));return}}throw Yi(c)?(0,co.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT"):(0,co.default)(new Error("Unexpected input: "+typeof c),"ERR_UNEXPECTED_INPUT")}async function VI(c,e){let{path:a,mode:f,mtime:d,content:b}=c,t={path:a||"",mode:Lp(f),mtime:Fp(d)};return b?t.content=await e(b):a||(t.content=await e(c)),t}function qQ(c){return UQ(c,DK,!0)}s();x();function GQ(c){if(c!=null)return typeof c=="string"?c:c.toString(8).padStart(4,"0")}async function _c(c,e,a={}){let f=[],d=new FormData,b=0,t=0;for await(let{content:r,path:o,mode:n,mtime:i}of qQ(c)){let l="",h=r?"file":"dir";b>0&&(l=`-${b}`);let u=h+l,g=[];if(n!=null&&g.push(`mode=${GQ(n)}`),i!=null){let{secs:E,nsecs:_}=i;g.push(`mtime=${E}`),_!=null&&g.push(`mtime-nsecs=${_}`)}if(g.length&&(u=`${u}?${g.join("&")}`),r){d.set(u,r,o!=null?encodeURIComponent(o):void 0);let E=t+r.size;f.push({name:o,start:t,end:E}),t=E}else if(o!=null)d.set(u,new File([""],encodeURIComponent(o),{type:"application/x-directory"}));else throw new Error("path or content or both must be set");b++}return{total:t,parts:f,headers:a,body:d}}s();x();var zQ=Fe(LI(),1);function Uhe(c){return c.filter(Boolean)}function vc(...c){return(0,zQ.anySignal)(Uhe(c))}var jQ=ne(c=>{async function e(a,f={}){let d=new AbortController,b=vc(d.signal,f.signal),t;try{t=await(await c.post("block/put",{signal:b,searchParams:oe(f),...await _c([a],d,f.headers)})).json()}catch(r){if(f.format==="dag-pb")return e(a,{...f,format:"protobuf"});if(f.format==="dag-cbor")return e(a,{...f,format:"cbor"});throw r}return Re.parse(t.Key)}return e});s();x();F0();var HQ=ne(c=>{async function*e(a,f={}){Array.isArray(a)||(a=[a]);let d=await c.post("block/rm",{signal:f.signal,searchParams:oe({arg:a.map(b=>b.toString()),"stream-channels":!0,...f}),headers:f.headers});for await(let b of d.ndjson())yield qhe(b)}return e});function qhe(c){let e={cid:Re.parse(c.Hash)};return c.Error&&(e.error=new Error(c.Error)),e}s();x();F0();var $Q=ne(c=>{async function e(a,f={}){let b=await(await c.post("block/stat",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers})).json();return{cid:Re.parse(b.Key),size:b.Size}}return e});function VQ(c){return{get:vp(c),put:jQ(c),rm:HQ(c),stat:$Q(c)}}s();x();s();x();var KQ=Fe(Yf(),1),QQ=ne(c=>{async function e(a,f={}){let d=await c.post("bootstrap/add",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),{Peers:b}=await d.json();return{Peers:b.map(t=>new KQ.Multiaddr(t))}}return e});s();x();var WQ=Fe(Yf(),1),JQ=ne(c=>{async function e(a={}){let f=await c.post("bootstrap/rm",{signal:a.signal,searchParams:oe({...a,all:!0}),headers:a.headers}),{Peers:d}=await f.json();return{Peers:d.map(b=>new WQ.Multiaddr(b))}}return e});s();x();var ZQ=Fe(Yf(),1),YQ=ne(c=>{async function e(a={}){let f=await c.post("bootstrap/list",{signal:a.signal,searchParams:oe(a),headers:a.headers}),{Peers:d}=await f.json();return{Peers:d.map(b=>new ZQ.Multiaddr(b))}}return e});s();x();var XQ=Fe(Yf(),1),eW=ne(c=>{async function e(a={}){let f=await c.post("bootstrap/add",{signal:a.signal,searchParams:oe({...a,default:!0}),headers:a.headers}),{Peers:d}=await f.json();return{Peers:d.map(b=>new XQ.Multiaddr(b))}}return e});s();x();var aW=Fe(Yf(),1),cW=ne(c=>{async function e(a,f={}){let d=await c.post("bootstrap/rm",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),{Peers:b}=await d.json();return{Peers:b.map(t=>new aW.Multiaddr(t))}}return e});function fW(c){return{add:QQ(c),clear:JQ(c),list:YQ(c),reset:eW(c),rm:cW(c)}}s();x();s();x();s();x();var dW=ne(c=>{async function e(a,f={}){let b=await(await c.post("config/profile/apply",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json();return{original:b.OldCfg,updated:b.NewCfg}}return e});s();x();s();x();function V0(c){if(c==null)return c;let e=/^[A-Z]+$/,a={};return Object.keys(c).reduce((f,d)=>(e.test(d)?f[d.toLowerCase()]=c[d]:e.test(d[0])?f[d[0].toLowerCase()+d.slice(1)]=c[d]:f[d]=c[d],f),a)}var bW=ne(c=>{async function e(a={}){return(await(await c.post("config/profile/list",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).map(b=>V0(b))}return e});function tW(c){return{apply:dW(c),list:bW(c)}}s();x();var rW=ne(c=>async(a,f={})=>{if(!a)throw new Error("key argument is required");return(await(await c.post("config",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json()).Value});s();x();var nW=ne(c=>async(a={})=>await(await c.post("config/show",{signal:a.signal,searchParams:oe({...a}),headers:a.headers})).json());s();x();O4();var iW=ne(c=>async(a,f={})=>{let d=new AbortController,b=vc(d.signal,f.signal);await(await c.post("config/replace",{signal:b,searchParams:oe(f),...await _c([M1(JSON.stringify(a))],d,f.headers)})).text()});s();x();var oW=ne(c=>async(a,f,d={})=>{if(typeof a!="string")throw new Error("Invalid key type");let b={...d,...Ghe(a,f)};await(await c.post("config",{signal:d.signal,searchParams:oe(b),headers:d.headers})).text()}),Ghe=(c,e)=>{switch(typeof e){case"boolean":return{arg:[c,e.toString()],bool:!0};case"string":return{arg:[c,e]};default:return{arg:[c,JSON.stringify(e)],json:!0}}};function sW(c){return{getAll:nW(c),get:rW(c),set:oW(c),replace:iW(c),profiles:tW(c)}}s();x();s();x();var xW=ne(c=>{async function*e(a,f={}){yield*(await c.post("dag/export",{signal:f.signal,searchParams:oe({arg:a.toString()}),headers:f.headers})).iterator()}return e});s();x();s();x();F0();var QI=Fe(Ed(),1);async function*WI(c,e,a,f,d){let b=async n=>{let i=await a.getCodec(n.code),l=await f(n,d);return i.decode(l)},t=e.split("/").filter(Boolean),r=await b(c),o=c;for(;t.length;){let n=t.shift();if(!n)throw(0,QI.default)(new Error(`Could not resolve path "${e}"`),"ERR_INVALID_PATH");if(Object.prototype.hasOwnProperty.call(r,n))r=r[n],yield{value:r,remainderPath:t.join("/")};else throw(0,QI.default)(new Error(`no link named "${n}" under ${o}`),"ERR_NO_LINK");let i=Re.asCID(r);i&&(o=i,r=await b(r))}yield{value:r,remainderPath:""}}var pW=Fe(uW(),1),mW=Fe(fo(),1),gW=Fe(Ed(),1);var yW=(c,e)=>ne((f,d)=>{let b=vp(d);return async(r,o={})=>{if(o.path){let u=o.localResolve?await(0,pW.default)(WI(r,o.path,c,b,o)):await(0,mW.default)(WI(r,o.path,c,b,o));if(!u)throw(0,gW.default)(new Error("Not found"),"ERR_NOT_FOUND");return u}let n=await c.getCodec(r.code),i=await b(r,o);return{value:n.decode(i),remainderPath:""}}})(e);s();x();F0();var wW=ne(c=>{async function*e(a,f={}){let d=new AbortController,b=vc(d.signal,f.signal),{headers:t,body:r}=await _c(a,d,f.headers),o=await c.post("dag/import",{signal:b,headers:t,body:r,searchParams:oe({"pin-roots":f.pinRoots})});for await(let{Root:n}of o.ndjson())if(n!==void 0){let{Cid:{"/":i},PinErrorMsg:l}=n;yield{root:{cid:Re.parse(i),pinErrorMsg:l}}}}return e});s();x();F0();var Cp=(c,e)=>ne(f=>async(b,t={})=>{let r={storeCodec:"dag-cbor",hashAlg:"sha2-256",...t},o;if(r.inputCodec){if(!(b instanceof Uint8Array))throw new Error("Can only inputCodec on raw bytes that can be decoded");o=b}else o=(await c.getCodec(r.storeCodec)).encode(b),r.inputCodec=r.storeCodec;let n=new AbortController,i=vc(n.signal,r.signal),h=await(await f.post("dag/put",{timeout:r.timeout,signal:i,searchParams:oe(r),...await _c([o],n,r.headers)})).json();return Re.parse(h.Cid["/"])})(e);s();x();F0();var _W=ne(c=>async(a,f={})=>{let b=await(await c.post("dag/resolve",{signal:f.signal,searchParams:oe({arg:`${a}${f.path?`/${f.path}`.replace(/\/[/]+/g,"/"):""}`,...f}),headers:f.headers})).json();return{cid:Re.parse(b.Cid["/"]),remainderPath:b.RemPath}});function vW(c,e){return{export:xW(e),get:yW(c,e),import:wW(e),put:Cp(c,e),resolve:_W(e)}}s();x();s();x();s();x();O4();s();x();var bo=Fe(Yf(),1),V2=c=>{if(c.Type===0)return{to:c.ID,name:"SENDING_QUERY",type:c.Type};if(c.Type===1)return{from:c.ID,name:"PEER_RESPONSE",type:c.Type,messageType:0,messageName:"PUT_VALUE",closer:(c.Responses||[]).map(({ID:e,Addrs:a})=>({id:e,multiaddrs:a.map(f=>new bo.Multiaddr(f))})),providers:(c.Responses||[]).map(({ID:e,Addrs:a})=>({id:e,multiaddrs:a.map(f=>new bo.Multiaddr(f))}))};if(c.Type===2){let e={id:c.ID,multiaddrs:[]};return c.Responses&&c.Responses.length&&(e={id:c.Responses[0].ID,multiaddrs:c.Responses[0].Addrs.map(a=>new bo.Multiaddr(a))}),{from:c.ID,name:"FINAL_PEER",type:c.Type,peer:e}}if(c.Type===3)return{from:c.ID,name:"QUERY_ERROR",type:c.Type,error:new Error(c.Extra)};if(c.Type===4)return{from:c.ID,name:"PROVIDER",type:c.Type,providers:c.Responses.map(({ID:e,Addrs:a})=>({id:e,multiaddrs:a.map(f=>new bo.Multiaddr(f))}))};if(c.Type===5)return{from:c.ID,name:"VALUE",type:c.Type,value:M1(c.Extra,"base64pad")};if(c.Type===6){let e=c.Responses.map(({ID:a})=>a);if(!e.length)throw new Error("No peer found");return{name:"ADDING_PEER",type:c.Type,peer:e[0]}}if(c.Type===7)return{name:"DIALING_PEER",type:c.Type,peer:c.ID};throw new Error("Unknown DHT event type")};var EW=ne(c=>{async function*e(a,f={}){let d=await c.post("dht/findpeer",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers});for await(let b of d.ndjson())yield V2(b)}return e});s();x();var AW=ne(c=>{async function*e(a,f={}){let d=await c.post("dht/findprovs",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers});for await(let b of d.ndjson())yield V2(b)}return e});s();x();P7();var SW=ne(c=>{async function*e(a,f={}){let d=await c.post("dht/get",{signal:f.signal,searchParams:oe({arg:a instanceof Uint8Array?T4(a):a.toString(),...f}),headers:f.headers});for await(let b of d.ndjson())yield V2(b)}return e});s();x();var IW=ne(c=>{async function*e(a,f={recursive:!1}){let d=Array.isArray(a)?a:[a],b=await c.post("dht/provide",{signal:f.signal,searchParams:oe({arg:d.map(t=>t.toString()),...f}),headers:f.headers});for await(let t of b.ndjson())yield V2(t)}return e});s();x();P7();var LW=ne(c=>{async function*e(a,f,d={}){let b=new AbortController,t=vc(b.signal,d.signal),r=await c.post("dht/put",{signal:t,searchParams:oe({arg:a instanceof Uint8Array?T4(a):a.toString(),...d}),...await _c([f],b,d.headers)});for await(let o of r.ndjson())yield V2(o)}return e});s();x();var FW=ne(c=>{async function*e(a,f={}){let d=await c.post("dht/query",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers});for await(let b of d.ndjson())yield V2(b)}return e});function CW(c){return{findPeer:EW(c),findProvs:AW(c),get:SW(c),provide:IW(c),put:LW(c),query:FW(c)}}s();x();s();x();var RW=ne(c=>{async function e(a={}){return(await c.post("diag/cmds",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()}return e});s();x();var BW=ne(c=>{async function e(a={}){return(await c.post("diag/net",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()}return e});s();x();var PW=ne(c=>{async function e(a={}){return(await c.post("diag/sys",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()}return e});function TW(c){return{cmds:RW(c),net:BW(c),sys:PW(c)}}s();x();s();x();var OW=ne(c=>{async function e(a,f,d={}){await(await c.post("files/chmod",{signal:d.signal,searchParams:oe({arg:a,mode:f,...d}),headers:d.headers})).text()}return e});s();x();F0();var NW=ne(c=>{async function e(a,f,d={}){let b=Array.isArray(a)?a:[a];await(await c.post("files/cp",{signal:d.signal,searchParams:oe({arg:b.concat(f).map(r=>Re.asCID(r)?`/ipfs/${r}`:r),...d}),headers:d.headers})).text()}return e});s();x();F0();var MW=ne(c=>{async function e(a,f={}){if(!a||typeof a!="string")throw new Error("ipfs.files.flush requires a path");let b=await(await c.post("files/flush",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json();return Re.parse(b.Cid)}return e});s();x();F0();s();x();function to(c){let e=V0(c);return Object.prototype.hasOwnProperty.call(e,"mode")&&(e.mode=parseInt(e.mode,8)),Object.prototype.hasOwnProperty.call(e,"mtime")&&(e.mtime={secs:e.mtime,nsecs:e.mtimeNsecs||0},delete e.mtimeNsecs),e}var kW=ne(c=>{async function*e(a,f={}){if(!a)throw new Error("ipfs.files.ls requires a path");let d=await c.post("files/ls",{signal:f.signal,searchParams:oe({arg:Re.asCID(a)?`/ipfs/${a}`:a,long:!0,...f,stream:!0}),headers:f.headers});for await(let b of d.ndjson())if("Entries"in b)for(let t of b.Entries||[])yield DW(to(t));else yield DW(to(b))}return e});function DW(c){return c.hash&&(c.cid=Re.parse(c.hash)),delete c.hash,c.type=c.type===1?"directory":"file",c}s();x();var UW=ne(c=>{async function e(a,f={}){await(await c.post("files/mkdir",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).text()}return e});s();x();var qW=ne(c=>{async function e(a,f,d={}){Array.isArray(a)||(a=[a]),await(await c.post("files/mv",{signal:d.signal,searchParams:oe({arg:a.concat(f),...d}),headers:d.headers})).text()}return e});s();x();var jW=Fe(zW(),1),HW=ne(c=>{async function*e(a,f={}){let d=await c.post("files/read",{signal:f.signal,searchParams:oe({arg:a,count:f.length,...f}),headers:f.headers});yield*(0,jW.default)(d.body)}return e});s();x();var $W=Fe(mp(),1),VW=ne(c=>{async function e(a,f={}){let d=await c.post("files/rm",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),b=await d.text();if(b!==""){let t=new $W.default.HTTPError(d);throw t.message=b,t}}return e});s();x();F0();var Rp=ne(c=>{async function e(a,f={}){let b=await(await c.post("files/stat",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json();return b.WithLocality=b.WithLocality||!1,Yhe(to(b))}return e});function Yhe(c){return c.cid=Re.parse(c.hash),delete c.hash,c}s();x();var KW=ne(c=>{async function e(a,f={}){await(await c.post("files/touch",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).text()}return e});s();x();var QW=ne(c=>{async function e(a,f,d={}){let b=new AbortController,t=vc(b.signal,d.signal);await(await c.post("files/write",{signal:t,searchParams:oe({arg:a,streamChannels:!0,count:d.length,...d}),...await _c([{content:f,path:"arg",mode:yp(d.mode),mtime:wp(d.mtime)}],b,d.headers)})).text()}return e});function WW(c){return{chmod:OW(c),cp:NW(c),flush:MW(c),ls:kW(c),mkdir:UW(c),mv:qW(c),read:HW(c),rm:VW(c),stat:Rp(c),touch:KW(c),write:QW(c)}}s();x();s();x();var JW=Fe(Ed(),1),ZW=ne(c=>async(a,f,d={})=>{throw(0,JW.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});s();x();var YW=ne(c=>{async function e(a,f={type:"rsa",size:2048}){let b=await(await c.post("key/gen",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json();return V0(b)}return e});s();x();var XW=ne(c=>{async function e(a,f,d,b={}){let r=await(await c.post("key/import",{signal:b.signal,searchParams:oe({arg:a,pem:f,password:d,...b}),headers:b.headers})).json();return V0(r)}return e});s();x();var eJ=Fe(Ed(),1),aJ=ne(c=>async(a,f={})=>{throw(0,eJ.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});s();x();var cJ=ne(c=>{async function e(a={}){return((await(await c.post("key/list",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).Keys||[]).map(b=>V0(b))}return e});s();x();var fJ=ne(c=>{async function e(a,f,d={}){let b=await c.post("key/rename",{signal:d.signal,searchParams:oe({arg:[a,f],...d}),headers:d.headers});return V0(await b.json())}return e});s();x();var dJ=ne(c=>{async function e(a,f={}){let b=await(await c.post("key/rm",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json();return V0(b.Keys[0])}return e});function bJ(c){return{export:ZW(c),gen:YW(c),import:XW(c),info:aJ(c),list:cJ(c),rename:fJ(c),rm:dJ(c)}}s();x();s();x();var tJ=ne(c=>{async function e(a,f,d={}){let b=await c.post("log/level",{signal:d.signal,searchParams:oe({arg:[a,f],...d}),headers:d.headers});return V0(await b.json())}return e});s();x();var rJ=ne(c=>{async function e(a={}){return(await(await c.post("log/ls",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).Strings}return e});s();x();var nJ=ne(c=>{async function*e(a={}){yield*(await c.post("log/tail",{signal:a.signal,searchParams:oe(a),headers:a.headers})).ndjson()}return e});function iJ(c){return{level:tJ(c),ls:rJ(c),tail:nJ(c)}}s();x();s();x();var oJ=ne(c=>{async function e(a,f={}){let d=await c.post("name/publish",{signal:f.signal,searchParams:oe({arg:`${a}`,...f}),headers:f.headers});return V0(await d.json())}return e});s();x();var sJ=ne(c=>{async function*e(a,f={}){let d=await c.post("name/resolve",{signal:f.signal,searchParams:oe({arg:a,stream:!0,...f}),headers:f.headers});for await(let b of d.ndjson())yield b.Path}return e});s();x();s();x();var xJ=ne(c=>{async function e(a,f={}){let d=await c.post("name/pubsub/cancel",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers});return V0(await d.json())}return e});s();x();var lJ=ne(c=>{async function e(a={}){let f=await c.post("name/pubsub/state",{signal:a.signal,searchParams:oe(a),headers:a.headers});return V0(await f.json())}return e});s();x();var uJ=ne(c=>{async function e(a={}){return(await(await c.post("name/pubsub/subs",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).Strings||[]}return e});function hJ(c){return{cancel:xJ(c),state:lJ(c),subs:uJ(c)}}function pJ(c){return{publish:oJ(c),resolve:sJ(c),pubsub:hJ(c)}}s();x();s();x();F0();var mJ=ne(c=>{async function e(a,f={}){let b=await(await c.post("object/data",{signal:f.signal,searchParams:oe({arg:`${a instanceof Uint8Array?Re.decode(a):a}`,...f}),headers:f.headers})).arrayBuffer();return new Uint8Array(b,0,b.byteLength)}return e});s();x();F0();O4();var gJ=ne(c=>{async function e(a,f={}){let b=await(await c.post("object/get",{signal:f.signal,searchParams:oe({arg:`${a instanceof Uint8Array?Re.decode(a):a}`,dataEncoding:"base64",...f}),headers:f.headers})).json();return{Data:M1(b.Data,"base64pad"),Links:(b.Links||[]).map(t=>({Name:t.Name,Hash:Re.parse(t.Hash),Tsize:t.Size}))}}return e});s();x();F0();var yJ=ne(c=>{async function e(a,f={}){return((await(await c.post("object/links",{signal:f.signal,searchParams:oe({arg:`${a instanceof Uint8Array?Re.decode(a):a}`,...f}),headers:f.headers})).json()).Links||[]).map(t=>({Name:t.Name,Tsize:t.Size,Hash:Re.parse(t.Hash)}))}return e});s();x();F0();var wJ=ne(c=>{async function e(a={}){let f=await c.post("object/new",{signal:a.signal,searchParams:oe({arg:a.template,...a}),headers:a.headers}),{Hash:d}=await f.json();return Re.parse(d)}return e});s();x();var _J=(c,e)=>ne(f=>{let d=Cp(c,e);async function b(t,r={}){return d(t,{...r,storeCodec:"dag-pb",hashAlg:"sha2-256",version:1})}return b})(e);s();x();F0();var vJ=ne(c=>{async function e(a,f={}){let b=await(await c.post("object/stat",{signal:f.signal,searchParams:oe({arg:`${a}`,...f}),headers:f.headers})).json();return{...b,Hash:Re.parse(b.Hash)}}return e});s();x();s();x();F0();var EJ=ne(c=>{async function e(a,f,d={}){let b=await c.post("object/patch/add-link",{signal:d.signal,searchParams:oe({arg:[`${a}`,f.Name||f.name||"",(f.Hash||f.cid||"").toString()||null],...d}),headers:d.headers}),{Hash:t}=await b.json();return Re.parse(t)}return e});s();x();F0();var AJ=ne(c=>{async function e(a,f,d={}){let b=new AbortController,t=vc(b.signal,d.signal),r=await c.post("object/patch/append-data",{signal:t,searchParams:oe({arg:`${a}`,...d}),...await _c([f],b,d.headers)}),{Hash:o}=await r.json();return Re.parse(o)}return e});s();x();F0();var SJ=ne(c=>{async function e(a,f,d={}){let b=await c.post("object/patch/rm-link",{signal:d.signal,searchParams:oe({arg:[`${a}`,f.Name||f.name||null],...d}),headers:d.headers}),{Hash:t}=await b.json();return Re.parse(t)}return e});s();x();F0();var IJ=ne(c=>{async function e(a,f,d={}){let b=new AbortController,t=vc(b.signal,d.signal),r=await c.post("object/patch/set-data",{signal:t,searchParams:oe({arg:[`${a}`],...d}),...await _c([f],b,d.headers)}),{Hash:o}=await r.json();return Re.parse(o)}return e});function LJ(c){return{addLink:EJ(c),appendData:AJ(c),rmLink:SJ(c),setData:IJ(c)}}function FJ(c,e){return{data:mJ(e),get:gJ(e),links:yJ(e),new:wJ(e),put:_J(c,e),stat:vJ(e),patch:LJ(e)}}s();x();s();x();F0();s();x();var tt=Fe(Ed(),1);F0();async function*Bp(c){if(c==null)throw(0,tt.default)(new Error(`Unexpected input: ${c}`),"ERR_UNEXPECTED_INPUT");let e=Re.asCID(c);if(e){yield q1({cid:e});return}if(c instanceof String||typeof c=="string"){yield q1({path:c});return}if(c.cid!=null||c.path!=null)return yield q1(c);if(Symbol.iterator in c){let a=c[Symbol.iterator](),f=a.next();if(f.done)return a;if(Re.asCID(f.value)||f.value instanceof String||typeof f.value=="string"){yield q1({cid:f.value});for(let d of a)yield q1({cid:d});return}if(f.value.cid!=null||f.value.path!=null){yield q1(f.value);for(let d of a)yield q1(d);return}throw(0,tt.default)(new Error("Unexpected input: "+typeof c),"ERR_UNEXPECTED_INPUT")}if(Symbol.asyncIterator in c){let a=c[Symbol.asyncIterator](),f=await a.next();if(f.done)return a;if(Re.asCID(f.value)||f.value instanceof String||typeof f.value=="string"){yield q1({cid:f.value});for await(let d of a)yield q1({cid:d});return}if(f.value.cid!=null||f.value.path!=null){yield q1(f.value);for await(let d of a)yield q1(d);return}throw(0,tt.default)(new Error("Unexpected input: "+typeof c),"ERR_UNEXPECTED_INPUT")}throw(0,tt.default)(new Error("Unexpected input: "+typeof c),"ERR_UNEXPECTED_INPUT")}function q1(c){let e=c.cid||`${c.path}`;if(!e)throw(0,tt.default)(new Error("Unexpected input: Please path either a CID or an IPFS path"),"ERR_UNEXPECTED_INPUT");let a={path:e,recursive:c.recursive!==!1};return c.metadata!=null&&(a.metadata=c.metadata),a}var Pp=ne(c=>{async function*e(a,f={}){for await(let{path:d,recursive:b,metadata:t}of Bp(a)){let r=await c.post("pin/add",{signal:f.signal,searchParams:oe({...f,arg:d,recursive:b,metadata:t?JSON.stringify(t):void 0,stream:!0}),headers:f.headers});for await(let o of r.ndjson()){if(o.Pins){for(let n of o.Pins)yield Re.parse(n);continue}yield Re.parse(o)}}}return e});s();x();var CJ=Fe(fo(),1);function RJ(c){let e=Pp(c);return ne(()=>{async function a(f,d={}){return(0,CJ.default)(e([{path:f,...d}],d))}return a})(c)}s();x();F0();function BJ(c,e,a){let f={type:c,cid:Re.parse(e)};return a&&(f.metadata=a),f}var PJ=ne(c=>{async function*e(a={}){let f=[];a.paths&&(f=Array.isArray(a.paths)?a.paths:[a.paths]);let d=await c.post("pin/ls",{signal:a.signal,searchParams:oe({...a,arg:f.map(b=>`${b}`),stream:!0}),headers:a.headers});for await(let b of d.ndjson()){if(b.Keys){for(let t of Object.keys(b.Keys))yield BJ(b.Keys[t].Type,t,b.Keys[t].Metadata);return}yield BJ(b.Type,b.Cid,b.Metadata)}}return e});s();x();F0();var Tp=ne(c=>{async function*e(a,f={}){for await(let{path:d,recursive:b}of Bp(a)){let t=new URLSearchParams(f.searchParams);t.append("arg",`${d}`),b!=null&&t.set("recursive",String(b));let r=await c.post("pin/rm",{signal:f.signal,headers:f.headers,searchParams:oe({...f,arg:`${d}`,recursive:b})});for await(let o of r.ndjson()){if(o.Pins){yield*o.Pins.map(n=>Re.parse(n));continue}yield Re.parse(o)}}}return e});s();x();var TJ=Fe(fo(),1);var OJ=c=>{let e=Tp(c);return ne(()=>{async function a(f,d={}){return(0,TJ.default)(e([{path:f,...d}],d))}return a})(c)};s();x();s();x();s();x();F0();var Op=({Name:c,Status:e,Cid:a})=>({cid:Re.parse(a),name:c,status:e}),NJ=c=>{if(typeof c=="string"&&c!=="")return c;throw new TypeError("service name must be passed")},MJ=c=>{if(Re.asCID(c))return c.toString();throw new TypeError(`CID instance expected instead of ${typeof c}`)},rt=({service:c,cid:e,name:a,status:f,all:d})=>{let b=oe({service:NJ(c),name:a,force:d?!0:void 0});if(e)for(let t of e)b.append("cid",MJ(t));if(f)for(let t of f)b.append("status",t);return b},DJ=({cid:c,service:e,background:a,name:f,origins:d})=>{let b=oe({arg:MJ(c),service:NJ(e),name:f,background:a?!0:void 0});if(d)for(let t of d)b.append("origin",t.toString());return b};function kJ(c){async function e(a,{timeout:f,signal:d,headers:b,...t}){let r=await c.post("pin/remote/add",{timeout:f,signal:d,headers:b,searchParams:DJ({cid:a,...t})});return Op(await r.json())}return e}s();x();function UJ(c){async function*e({timeout:a,signal:f,headers:d,...b}){let t=await c.post("pin/remote/ls",{timeout:a,signal:f,headers:d,searchParams:rt(b)});for await(let r of t.ndjson())yield Op(r)}return e}s();x();function qJ(c){async function e({timeout:a,signal:f,headers:d,...b}){await c.post("pin/remote/rm",{timeout:a,signal:f,headers:d,searchParams:rt({...b,all:!1})})}return e}s();x();function GJ(c){async function e({timeout:a,signal:f,headers:d,...b}){await c.post("pin/remote/rm",{timeout:a,signal:f,headers:d,searchParams:rt({...b,all:!0})})}return e}s();x();s();x();s();x();function zJ(c){let e=String(c);if(e==="undefined")throw Error("endpoint is required");return e[e.length-1]==="/"?e.slice(0,-1):e}function jJ(c){return{service:c.Service,endpoint:new URL(c.ApiEndpoint),...c.Stat&&{stat:Xhe(c.Stat)}}}function Xhe(c){switch(c.Status){case"valid":{let{Pinning:e,Pinned:a,Queued:f,Failed:d}=c.PinCount;return{status:"valid",pinCount:{queued:f,pinning:e,pinned:a,failed:d}}}case"invalid":return{status:"invalid"};default:return{status:c.Status}}}function HJ(c){async function e(a,f){let{endpoint:d,key:b,headers:t,timeout:r,signal:o}=f;await c.post("pin/remote/service/add",{timeout:r,signal:o,searchParams:oe({arg:[a,zJ(d),b]}),headers:t})}return e}s();x();function $J(c){async function e(a={}){let{stat:f,headers:d,timeout:b,signal:t}=a,r=await c.post("pin/remote/service/ls",{timeout:b,signal:t,headers:d,searchParams:f===!0?oe({stat:f}):void 0}),{RemoteServices:o}=await r.json();return o.map(jJ)}return e}s();x();function VJ(c){async function e(a,f={}){await c.post("pin/remote/service/rm",{signal:f.signal,headers:f.headers,searchParams:oe({arg:a})})}return e}function KJ(c){let e=new T7(c);return{add:HJ(e),ls:$J(e),rm:VJ(e)}}function QJ(c){let e=new T7(c);return{add:kJ(e),ls:UJ(e),rm:qJ(e),rmAll:GJ(e),service:KJ(c)}}function WJ(c){return{addAll:Pp(c),add:RJ(c),ls:PJ(c),rmAll:Tp(c),rm:OJ(c),remote:QJ(c)}}s();x();s();x();s();x();O4();P7();zi();var Np=c=>Array.isArray(c)?c.map(epe):c,epe=c=>T4(Mp(c)),Mp=c=>Jh.decode(c),nt=c=>Jh.encode(M1(c));var JJ=ne(c=>{async function e(a={}){let{Strings:f}=await(await c.post("pubsub/ls",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json();return Np(f)||[]}return e});s();x();var ZJ=ne(c=>{async function e(a,f={}){let d=await c.post("pubsub/peers",{signal:f.signal,searchParams:oe({arg:nt(a),...f}),headers:f.headers}),{Strings:b}=await d.json();return b||[]}return e});s();x();var YJ=ne(c=>{async function e(a,f,d={}){let b=oe({arg:nt(a),...d}),t=new AbortController,r=vc(t.signal,d.signal);await(await c.post("pubsub/pub",{signal:r,searchParams:b,...await _c([f],t,d.headers)})).text()}return e});s();x();var XJ=Fe(uI(),1);var ape=(0,XJ.default)("ipfs-http-client:pubsub:subscribe"),eZ=(c,e)=>ne(a=>{async function f(d,b,t={}){t.signal=e.subscribe(d,b,t.signal);let r,o,n=new Promise((l,h)=>{r=l,o=h}),i=setTimeout(()=>r(),1e3);return a.post("pubsub/sub",{signal:t.signal,searchParams:oe({arg:nt(d),...t}),headers:t.headers}).catch(l=>{e.unsubscribe(d,b),o(l)}).then(l=>{clearTimeout(i),l&&(cpe(l,{onMessage:b,onEnd:()=>e.unsubscribe(d,b),onError:t.onError}),r())}),n}return f})(c);async function cpe(c,{onMessage:e,onEnd:a,onError:f}){f=f||ape;try{for await(let d of c.ndjson())try{if(!d.from)continue;e({from:d.from,data:Mp(d.data),seqno:Mp(d.seqno),topicIDs:Np(d.topicIDs)})}catch(b){b.message=`Failed to parse pubsub message: ${b.message}`,f(b,!1,d)}}catch(d){fpe(d)||f(d,!0)}finally{a()}}var fpe=c=>{switch(c.type){case"aborted":return!0;case"abort":return!0;default:return c.name==="AbortError"}};s();x();var aZ=(c,e)=>{async function a(f,d){e.unsubscribe(f,d)}return a};s();x();var Dp=class{constructor(){this._subs=new Map}subscribe(e,a,f){let d=this._subs.get(e)||[];if(d.find(t=>t.handler===a))throw new Error(`Already subscribed to ${e} with this handler`);let b=new AbortController;return this._subs.set(e,[{handler:a,controller:b}].concat(d)),f&&f.addEventListener("abort",()=>this.unsubscribe(e,a)),b.signal}unsubscribe(e,a){let f=this._subs.get(e)||[],d;a?(this._subs.set(e,f.filter(b=>b.handler!==a)),d=f.filter(b=>b.handler===a)):(this._subs.set(e,[]),d=f),(this._subs.get(e)||[]).length||this._subs.delete(e),d.forEach(b=>b.controller.abort())}};function cZ(c){let e=new Dp;return{ls:JJ(c),peers:ZJ(c),publish:YJ(c),subscribe:eZ(c,e),unsubscribe:aZ(c,e)}}s();x();F0();s();x();var fZ=ne(c=>{async function*e(a={}){yield*(await c.post("refs/local",{signal:a.signal,transform:V0,searchParams:oe(a),headers:a.headers})).ndjson()}return e});var dZ=ne((c,e)=>Object.assign(async function*(f,d={}){let b=Array.isArray(f)?f:[f];yield*(await c.post("refs",{signal:d.signal,searchParams:oe({arg:b.map(r=>`${r instanceof Uint8Array?Re.decode(r):r}`),...d}),headers:d.headers,transform:V0})).ndjson()},{local:fZ(e)}));s();x();s();x();F0();var bZ=ne(c=>{async function*e(a={}){yield*(await c.post("repo/gc",{signal:a.signal,searchParams:oe(a),headers:a.headers,transform:d=>({err:d.Error?new Error(d.Error):null,cid:(d.Key||{})["/"]?Re.parse(d.Key["/"]):null})})).ndjson()}return e});s();x();var kp=ne(c=>{async function e(a={}){let d=await(await c.post("repo/stat",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json();return{numObjects:BigInt(d.NumObjects),repoSize:BigInt(d.RepoSize),repoPath:d.RepoPath,version:d.Version,storageMax:BigInt(d.StorageMax)}}return e});s();x();var tZ=ne(c=>{async function e(a={}){return(await(await c.post("repo/version",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).Version}return e});function rZ(c){return{gc:bZ(c),stat:kp(c),version:tZ(c)}}s();x();s();x();var nZ=ne(c=>{async function*e(a={}){yield*(await c.post("stats/bw",{signal:a.signal,searchParams:oe(a),headers:a.headers,transform:d=>({totalIn:BigInt(d.TotalIn),totalOut:BigInt(d.TotalOut),rateIn:parseFloat(d.RateIn),rateOut:parseFloat(d.RateOut)})})).ndjson()}return e});function iZ(c){return{bitswap:_p(c),repo:kp(c),bw:nZ(c)}}s();x();s();x();var oZ=Fe(Yf(),1);var sZ=ne(c=>{async function e(a={}){let f=await c.post("swarm/addrs",{signal:a.signal,searchParams:oe(a),headers:a.headers}),{Addrs:d}=await f.json();return Object.keys(d).map(b=>({id:b,addrs:(d[b]||[]).map(t=>new oZ.Multiaddr(t))}))}return e});s();x();var xZ=ne(c=>{async function e(a,f={}){let d=await c.post("swarm/connect",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),{Strings:b}=await d.json();return b||[]}return e});s();x();var lZ=ne(c=>{async function e(a,f={}){let d=await c.post("swarm/disconnect",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),{Strings:b}=await d.json();return b||[]}return e});s();x();var uZ=Fe(Yf(),1);var hZ=ne(c=>{async function e(a={}){let f=await c.post("swarm/addrs/local",{signal:a.signal,searchParams:oe(a),headers:a.headers}),{Strings:d}=await f.json();return(d||[]).map(b=>new uZ.Multiaddr(b))}return e});s();x();var pZ=Fe(Yf(),1);var mZ=ne(c=>{async function e(a={}){let f=await c.post("swarm/peers",{signal:a.signal,searchParams:oe(a),headers:a.headers}),{Peers:d}=await f.json();return(d||[]).map(b=>({addr:new pZ.Multiaddr(b.Addr),peer:b.Peer,muxer:b.Muxer,latency:b.Latency,streams:b.Streams,direction:b.Direction==null?void 0:b.Direction===0?"inbound":"outbound"}))}return e});function gZ(c){return{addrs:sZ(c),connect:xZ(c),disconnect:lZ(c),localAddrs:hZ(c),peers:mZ(c)}}s();x();s();x();F0();var Up=ne(c=>{async function*e(a,f={}){let d=new AbortController,b=vc(d.signal,f.signal),{headers:t,body:r,total:o,parts:n}=await _c(a,d,f.headers),[i,l]=typeof f.progress=="function"?dpe(o,n,f.progress):[void 0,void 0],h=await c.post("add",{searchParams:oe({"stream-channels":!0,...f,progress:Boolean(i)}),onUploadProgress:l,signal:b,headers:t,body:r});for await(let u of h.ndjson())u=V0(u),u.hash!==void 0?yield tpe(u):i&&i(u.bytes||0,u.name)}return e}),dpe=(c,e,a)=>e?[void 0,bpe(c,e,a)]:[a,void 0],bpe=(c,e,a)=>{let f=0,d=e.length;return({loaded:b,total:t})=>{let r=Math.floor(b/t*c);for(;f<d;){let{start:o,end:n,name:i}=e[f];if(r<n){a(r-o,i);break}else a(n-o,i),f+=1}}};function tpe({name:c,hash:e,size:a,mode:f,mtime:d,mtimeNsecs:b}){let t={path:c,cid:Re.parse(e),size:parseInt(a)};return f!=null&&(t.mode=parseInt(f,8)),d!=null&&(t.mtime={secs:d,nsecs:b||0}),t}var TZ=Fe(fo(),1);s();x();s();x();var vZ=Fe(Ed(),1);O4();var EZ=Fe(D4(),1),AZ=Fe(_Z(),1),SZ=Fe(Zi(),1),IZ=Fe(pp(),1),LZ=Fe(BI(),1);async function*qp(c){yield c}async function FZ(c){if(H2(c))return qp(JI(c));if(typeof c=="string"||c instanceof String)return qp(JI(c.toString()));if(Z3(c))return(0,AZ.default)(c);if(Y3(c)&&(c=(0,EZ.default)(c)),Symbol.iterator in c||Symbol.asyncIterator in c){let e=(0,SZ.default)(c),{value:a,done:f}=await e.peek();if(f)return qp(new Uint8Array(0));if(e.push(a),Number.isInteger(a))return qp(Uint8Array.from(await(0,IZ.default)(e)));if(H2(a)||typeof a=="string"||a instanceof String)return(0,LZ.default)(e,JI)}throw(0,vZ.default)(new Error(`Unexpected input: ${c}`),"ERR_UNEXPECTED_INPUT")}function JI(c){return c instanceof Uint8Array?c:ArrayBuffer.isView(c)?new Uint8Array(c.buffer,c.byteOffset,c.byteLength):c instanceof ArrayBuffer?new Uint8Array(c):Array.isArray(c)?Uint8Array.from(c):M1(c.toString())}s();x();var zp=Fe(Ed(),1),CZ=Fe(D4(),1),RZ=Fe(Zi(),1);async function*BZ(c,e){if(c==null)throw(0,zp.default)(new Error(`Unexpected input: ${c}`),"ERR_UNEXPECTED_INPUT");if(typeof c=="string"||c instanceof String){yield Gp(c.toString(),e);return}if(H2(c)||Z3(c)){yield Gp(c,e);return}if(Y3(c)&&(c=(0,CZ.default)(c)),Symbol.iterator in c||Symbol.asyncIterator in c){let a=(0,RZ.default)(c),{value:f,done:d}=await a.peek();if(d){yield{content:[]};return}if(a.push(f),Number.isInteger(f)||H2(f)||typeof f=="string"||f instanceof String){yield Gp(a,e);return}throw(0,zp.default)(new Error("Unexpected input: multiple items passed - if you are using ipfs.add, please use ipfs.addAll instead"),"ERR_UNEXPECTED_INPUT")}if(Yi(c)){yield Gp(c,e);return}throw(0,zp.default)(new Error('Unexpected input: cannot convert "'+typeof c+'" into ImportCandidate'),"ERR_UNEXPECTED_INPUT")}async function Gp(c,e){let{path:a,mode:f,mtime:d,content:b}=c,t={path:a||"",mode:Lp(f),mtime:Fp(d)};return b?t.content=await e(b):a||(t.content=await e(c)),t}function PZ(c){return BZ(c,FZ)}function OZ(c){let e=Up(c);return ne(()=>{async function a(f,d={}){return await(0,TZ.default)(e(PZ(f),d))}return a})(c)}s();x();var NZ=ne(c=>{async function*e(a,f={}){yield*(await c.post("cat",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers})).iterator()}return e});s();x();var MZ=ne(c=>async(a={})=>(await c.post("commands",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json());s();x();var DZ=ne(c=>async(a,f={})=>(await(await c.post("dns",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json()).Path);s();x();var kZ=ne(c=>()=>{let e=new URL(c.opts.base||"");return{host:e.hostname,port:e.port,protocol:e.protocol,pathname:e.pathname,"api-path":e.pathname}});s();x();F0();var UZ=ne(c=>{async function*e(a,f={}){let d={arg:`${a instanceof Uint8Array?Re.decode(a):a}`,...f};d.compressionLevel&&(d["compression-level"]=d.compressionLevel,delete d.compressionLevel),yield*(await c.post("get",{signal:f.signal,searchParams:oe(d),headers:f.headers})).iterator()}return e});s();x();var qZ=Fe(Yf(),1);var jp=ne(c=>{async function e(a={}){let d=await(await c.post("id",{signal:a.signal,searchParams:oe({arg:a.peerId?a.peerId.toString():void 0,...a}),headers:a.headers})).json(),b={...V0(d)};return b.addresses&&(b.addresses=b.addresses.map(t=>new qZ.Multiaddr(t))),b}return e});s();x();var GZ=c=>{let e=jp(c);async function a(f={}){let d=await e(f);return Boolean(d&&d.addresses&&d.addresses.length)}return a};s();x();F0();var zZ=ne((c,e)=>{async function*a(f,d={}){let b=`${f instanceof Uint8Array?Re.decode(f):f}`;async function t(o){let n=o.Hash;if(n.includes("/")){let l=n.startsWith("/ipfs/")?n:`/ipfs/${n}`;n=(await Rp(e)(l)).cid}else n=Re.parse(n);let i={name:o.Name,path:b+(o.Name?`/${o.Name}`:""),size:o.Size,cid:n,type:npe(o)};return o.Mode&&(i.mode=parseInt(o.Mode,8)),o.Mtime!==void 0&&o.Mtime!==null&&(i.mtime={secs:o.Mtime},o.MtimeNsecs!==void 0&&o.MtimeNsecs!==null&&(i.mtime.nsecs=o.MtimeNsecs)),i}let r=await c.post("ls",{signal:d.signal,searchParams:oe({arg:b,...d}),headers:d.headers});for await(let o of r.ndjson()){if(o=o.Objects,!o)throw new Error("expected .Objects in results");if(o=o[0],!o)throw new Error("expected one array in results.Objects");let n=o.Links;if(!Array.isArray(n))throw new Error("expected one array in results.Objects[0].Links");if(!n.length){yield t(o);return}yield*n.map(t)}}return a});function npe(c){switch(c.Type){case 1:case 5:return"dir";case 2:return"file";default:return"file"}}s();x();var jZ=ne(c=>{async function e(a={}){let f=await c.post("dns",{signal:a.signal,searchParams:oe(a),headers:a.headers});return V0(await f.json())}return e});s();x();var HZ=ne(c=>{async function*e(a,f={}){yield*(await c.post("ping",{signal:f.signal,searchParams:oe({arg:`${a}`,...f}),headers:f.headers,transform:V0})).ndjson()}return e});s();x();var $Z=ne(c=>{async function e(a,f={}){let d=await c.post("resolve",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),{Path:b}=await d.json();return b}return e});s();x();var VZ=Fe(Ed(),1),KZ=ne(c=>async(a={})=>{throw(0,VZ.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});s();x();var QZ=ne(c=>{async function e(a={}){await(await c.post("shutdown",{signal:a.signal,searchParams:oe(a),headers:a.headers})).text()}return e});s();x();var WZ=ne(c=>{async function e(a={}){let f=await c.post("version",{signal:a.signal,searchParams:oe(a),headers:a.headers});return{...V0(await f.json()),"ipfs-http-client":"1.0.0"}}return e});var lpe=Fe(JZ(),1);F0();var upe=Fe(Yf(),1),hpe=Fe(YZ(),1);function XZ(c={}){let e={name:Yh.name,code:Yh.code,encode:n=>n,decode:n=>n},a=Object.values(ji);(c.ipld&&c.ipld.bases?c.ipld.bases:[]).forEach(n=>a.push(n));let f=new Sh({bases:a,loadBase:c.ipld&&c.ipld.loadBase}),d=Object.values(T$);[cS,wS,RS,xpe,e].concat(c.ipld&&c.ipld.codecs||[]).forEach(n=>d.push(n));let b=new Ih({codecs:d,loadCodec:c.ipld&&c.ipld.loadCodec}),t=Object.values(P$);(c.ipld&&c.ipld.hashers?c.ipld.hashers:[]).forEach(n=>t.push(n));let r=new Lh({hashers:t,loadHasher:c.ipld&&c.ipld.loadHasher});return{add:OZ(c),addAll:Up(c),bitswap:RK(c),block:VQ(c),bootstrap:fW(c),cat:NZ(c),commands:MZ(c),config:sW(c),dag:vW(b,c),dht:CW(c),diag:TW(c),dns:DZ(c),files:WW(c),get:UZ(c),getEndpointConfig:kZ(c),id:jp(c),isOnline:GZ(c),key:bJ(c),log:iJ(c),ls:zZ(c),mount:jZ(c),name:pJ(c),object:FJ(b,c),pin:WJ(c),ping:HZ(c),pubsub:cZ(c),refs:dZ(c),repo:rZ(c),resolve:$Z(c),start:KZ(c),stats:iZ(c),stop:QZ(c),swarm:gZ(c),version:WZ(c),bases:f,codecs:b,hashers:r}}var D7=class{constructor(e){this.ipfsUrl=e}async load(e){return await eY(e,this.ipfsUrl).load(e)}},Hp=class{async load(e){return(await Qf.get(e,{responseType:"arraybuffer"})).data}},$p=class{constructor(e){this.url=e;this.client=XZ({url:this.url})}client;async load(e){let a=new URL(e),f=this.client.cat(a.host),d=Uint8Array.from([]);for await(let b of f)d=Uint8Array.from(b);return d}};function eY(c,e){let a=new URL(c);switch(a.protocol){case"http:":case"https:":return new Hp;case"ipfs:":return new $p(e);default:throw new Error(`loader for ${a.protocol} is not supported`)}}s();x();s();x();s();x();var aY=40,cY=64,fY=64,dY=32,ppe="empty auth claim mtp proof",mpe="empty auth claim non-revocation mtp proof",gpe="empty challenge signature",ype="empty claim signature",wpe="empty claim mtp proof",_pe="empty claim non-revocation mtp proof",vpe="empty user state in relay claim non-revocation mtp proof",Epe="empty issuer auth claim mtp proof",Ape="empty issuer auth claim non-revocation mtp proof",f2=class{mtLevel;valueArraySize;mtLevelOnChain;mtLevelClaimsMerklization;getMTLevel(){return this.mtLevel?this.mtLevel:aY}getMTLevelsClaimMerklization(){return this.mtLevelClaimsMerklization?this.mtLevelClaimsMerklization:dY}getValueArrSize(){return this.valueArraySize?this.valueArraySize:cY}getMTLevelOnChain(){return this.mtLevelOnChain?this.mtLevelOnChain:fY}},tc=c=>{if(!c)return b0;let e=new ac;return e.value=D6(R0.decodeString(c)),e},ZI=(c,e,a,f)=>({state:tc(c),claimsRoot:tc(e),revocationRoot:tc(a),rootOfRoots:tc(f)}),$c=(c,e)=>{let a=c.allSiblings?c.allSiblings():c.siblings;for(let f=a.length;f<e;f++)a.push(b0);return a.map(f=>typeof f=="string"?f:f.bigInt().toString())},ro=(c,e)=>{if(c||(c=[]),c.length>e)throw new Error(`array size ${c.length} is bigger max expected size ${e}`);for(let a=c.length;a<e;a++)c.push(BigInt(0));return c},no=c=>c.map(e=>e.toString()),d2=c=>c?.existence?{key:b0,value:b0,noAux:"0"}:c?.nodeAux?.value!==void 0&&c?.nodeAux?.key!==void 0?{key:c.nodeAux.key,value:c.nodeAux.value,noAux:"0"}:{key:b0,value:b0,noAux:"1"},io=c=>c?0:1;function Spe(c){let e={};for(let a in c)c.hasOwnProperty(a)&&!a.startsWith("_")&&(e[a]=c[a]);return e}s();x();s();x();var bY=(r=>(r[r.NOOP=0]="NOOP",r[r.EQ=1]="EQ",r[r.LT=2]="LT",r[r.GT=3]="GT",r[r.IN=4]="IN",r[r.NIN=5]="NIN",r[r.NE=6]="NE",r))(bY||{}),K2={$noop:0,$eq:1,$lt:2,$gt:3,$in:4,$nin:5,$ne:6},Vp=class{constructor(e,a){this.x=e;this.y=a}compare(e){switch(e){case 1:return this.x===this.y;case 2:return this.x<this.y;case 3:return this.x>this.y;case 6:return this.x!==this.y;default:throw new Error("unknown compare type for scalar")}}},Kp=class{constructor(e,a){this.x=e;this.y=a}compare(e){switch(e){case 4:return this.y.includes(this.x);case 5:return!this.y.includes(this.x);default:throw new Error("unknown compare type for vector")}}},Ipe=(c,e,a)=>{switch(a){case 1:case 2:case 3:case 6:if(e.length!==1)throw new Error("currently we support only one value for scalar comparison");return new Vp(c,e[0]);case 4:case 5:return new Kp(c,e);default:throw new Error("unknown compare type")}};var it=class{slotIndex;values;operator;valueProof;validate(){if(this.operator!==K2.$noop&&this.values.some(e=>typeof e!="bigint"))throw new Error(G4.EmptyQueryValue)}},Qp=(d=>(d.AuthV2="authV2",d.StateTransition="stateTransition",d.AtomicQueryMTPV2="credentialAtomicQueryMTPV2",d.AtomicQuerySigV2="credentialAtomicQuerySigV2",d))(Qp||{}),oo=class{issuerId;claim;treeState;proof;nonRevProof;signatureProof},G4=(L=>(L.EmptyAuthClaimProof="empty auth claim mtp proof",L.EmptyAuthClaimProofInTheNewState="empty auth claim mtp proof in the new state",L.EmptyAuthClaimNonRevProof="empty auth claim non-revocation mtp proof",L.EmptyChallengeSignature="empty challenge signature",L.EmptyClaimSignature="empty claim signature",L.EmptyClaimProof="empty claim mtp proof",L.EmptyClaimNonRevProof="empty claim non-revocation mtp proof",L.EmptyIssuerAuthClaimProof="empty issuer auth claim mtp proof",L.EmptyIssuerAuthClaimNonRevProof="empty issuer auth claim non-revocation mtp proof",L.EmptyJsonLDQueryProof="empty JSON-LD query mtp proof",L.EmptyJsonLDQueryValue="empty JSON-LD query value",L.EmptyJsonLDQueryPath="empty JSON-LD query path",L.EmptyQueryValue="empty query value",L.EmptyJsonLDQueryValues="empty JSON-LD query values",L.EmptyId="empty Id",L.EmptyChallenge="empty challenge",L.EmptyGlobalProof="empty global identity mtp proof",L.EmptyRequestID="empty request ID",L))(G4||{}),e8=class{path;value;mtp;constructor(){this.path=BigInt(0),this.value=BigInt(0),this.mtp=new Gd}validate(){if(!this.path)throw new Error("empty JSON-LD query path");if(!this.value)throw new Error("empty JSON-LD query value");if(!this.mtp)throw new Error("empty JSON-LD query mtp proof")}};s();x();var so=class extends f2{id;profileNonce;claimSubjectProfileNonce;claim;skipClaimRevocationCheck;requestID;currentTimeStamp;query;validate(){if(!this.requestID)throw new Error("empty request ID")}inputsMarshal(){this.validate(),this.query.valueProof&&(this.query.validate(),this.query.valueProof.validate());let e=this.query.valueProof??new e8,a={requestID:this.requestID.toString(),userGenesisID:this.id.bigInt().toString(),profileNonce:this.profileNonce.toString(),claimSubjectProfileNonce:this.claimSubjectProfileNonce.toString(),issuerID:this.claim.issuerID?.bigInt().toString(),issuerClaim:this.claim.claim.marshalJson(),issuerClaimMtp:$c(this.claim.incProof.proof,this.getMTLevel()),issuerClaimClaimsTreeRoot:this.claim.incProof.treeState?.claimsRoot.bigInt().toString(),issuerClaimRevTreeRoot:this.claim.incProof.treeState?.revocationRoot.bigInt().toString(),issuerClaimRootsTreeRoot:this.claim.incProof.treeState?.rootOfRoots.bigInt().toString(),issuerClaimIdenState:this.claim.incProof.treeState?.state.bigInt().toString(),issuerClaimNonRevMtp:$c(this.claim.nonRevProof.proof,this.getMTLevel()),issuerClaimNonRevClaimsTreeRoot:this.claim.nonRevProof.treeState?.claimsRoot.bigInt().toString(),issuerClaimNonRevRevTreeRoot:this.claim.nonRevProof.treeState?.revocationRoot.bigInt().toString(),issuerClaimNonRevRootsTreeRoot:this.claim.nonRevProof.treeState?.rootOfRoots.bigInt().toString(),issuerClaimNonRevState:this.claim.nonRevProof.treeState?.state.bigInt().toString(),claimSchema:this.claim.claim.getSchemaHash().bigInt().toString(),claimPathMtp:$c(e.mtp,this.getMTLevelsClaimMerklization()),claimPathValue:e.value.toString(),operator:this.query.operator,slotIndex:this.query.slotIndex,timestamp:this.currentTimeStamp},f=d2(this.claim.nonRevProof.proof);a.issuerClaimNonRevMtpAuxHi=f.key.bigInt().toString(),a.issuerClaimNonRevMtpAuxHv=f.value.bigInt().toString(),a.issuerClaimNonRevMtpNoAux=f.noAux,a.claimPathNotExists=io(e.mtp.existence);let d=d2(e.mtp);a.claimPathMtpNoAux=d.noAux,a.claimPathMtpAuxHi=d.key.bigInt().toString(),a.claimPathMtpAuxHv=d.value.bigInt().toString(),a.claimPathKey=e.path.toString(),this.skipClaimRevocationCheck?a.isRevocationChecked=0:a.isRevocationChecked=1;let b=ro(this.query.values,this.getValueArrSize());return a.value=no(b),new TextEncoder().encode(JSON.stringify(a))}},YI=class extends f2{requestID;userID;issuerID;issuerClaimIdenState;issuerClaimNonRevState;claimSchema;slotIndex;operator;value=[];timestamp;merklized;claimPathKey;claimPathNotExists;isRevocationChecked;pubSignalsUnmarshal(e){let f=JSON.parse(new TextDecoder().decode(e));if(f.length!==13+this.getValueArrSize())throw new Error(`invalid number of Output values expected ${13+this.getValueArrSize()} got ${f.length}`);let d=0;this.merklized=parseInt(f[d]),d++,this.userID=Z0.fromBigInt(BigInt(f[d])),d++,this.requestID=BigInt(f[d]),d++,this.issuerID=Z0.fromBigInt(BigInt(f[d])),d++,this.issuerClaimIdenState=kd(f[d]),d++,this.isRevocationChecked=parseInt(f[d]),d++,this.issuerClaimNonRevState=kd(f[d]),d++,this.timestamp=parseInt(f[d]),d++,this.claimSchema=kc.newSchemaHashFromInt(BigInt(f[d])),d++,this.claimPathNotExists=parseInt(f[d]),d++,this.claimPathKey=BigInt(f[d]),d++,this.slotIndex=parseInt(f[d]),d++,this.operator=parseInt(f[d]),d++;for(let b=0;b<this.getValueArrSize();b++)this.value.push(BigInt(f[d])),d++;return this}};s();x();var xo=class extends f2{requestID;id;profileNonce;claimSubjectProfileNonce;claim;skipClaimRevocationCheck;currentTimeStamp;query;validate(){if(!this.requestID)throw new Error("empty request ID");if(!this.claim.nonRevProof.proof)throw new Error("empty claim non-revocation mtp proof");if(!this.claim.signatureProof.issuerAuthIncProof.proof)throw new Error("empty issuer auth claim mtp proof");if(!this.claim.signatureProof.issuerAuthNonRevProof.proof)throw new Error("empty issuer auth claim non-revocation mtp proof");if(!this.claim.signatureProof.signature)throw new Error("empty claim signature");if(!this.query.values&&this.query.operator!==K2.$noop)throw new Error("empty query value")}inputsMarshal(){this.validate(),this.query.valueProof&&(this.query.validate(),this.query.valueProof.validate());let e=this.query.valueProof??new e8,a={requestID:this.requestID.toString(),userGenesisID:this.id.bigInt().toString(),profileNonce:this.profileNonce.toString(),claimSubjectProfileNonce:this.claimSubjectProfileNonce.toString(),issuerID:this.claim.issuerID.bigInt().toString(),issuerClaim:this.claim.claim.marshalJson(),issuerClaimNonRevClaimsTreeRoot:this.claim.nonRevProof.treeState?.claimsRoot.bigInt().toString(),issuerClaimNonRevRevTreeRoot:this.claim.nonRevProof.treeState?.revocationRoot.bigInt().toString(),issuerClaimNonRevRootsTreeRoot:this.claim.nonRevProof.treeState?.rootOfRoots.bigInt().toString(),issuerClaimNonRevState:this.claim.nonRevProof.treeState?.state.bigInt().toString(),issuerClaimNonRevMtp:$c(this.claim.nonRevProof.proof,this.getMTLevel()),issuerClaimSignatureR8x:this.claim.signatureProof.signature.R8[0].toString(),issuerClaimSignatureR8y:this.claim.signatureProof.signature.R8[1].toString(),issuerClaimSignatureS:this.claim.signatureProof.signature.S.toString(),issuerAuthClaim:this.claim.signatureProof.issuerAuthClaim?.marshalJson(),issuerAuthClaimMtp:$c(this.claim.signatureProof.issuerAuthIncProof.proof,this.getMTLevel()),issuerAuthClaimsTreeRoot:this.claim.signatureProof.issuerAuthIncProof.treeState?.claimsRoot.bigInt().toString(),issuerAuthRevTreeRoot:this.claim.signatureProof.issuerAuthIncProof.treeState?.revocationRoot.bigInt().toString(),issuerAuthRootsTreeRoot:this.claim.signatureProof.issuerAuthIncProof.treeState?.rootOfRoots.bigInt().toString(),issuerAuthClaimNonRevMtp:$c(this.claim.signatureProof.issuerAuthNonRevProof.proof,this.getMTLevel()),claimSchema:this.claim.claim.getSchemaHash().bigInt().toString(),claimPathMtp:$c(e.mtp,this.getMTLevelsClaimMerklization()),claimPathValue:e.value.toString(),operator:this.query.operator,timestamp:this.currentTimeStamp,slotIndex:this.query.slotIndex};this.skipClaimRevocationCheck?a.isRevocationChecked=0:a.isRevocationChecked=1;let f=d2(this.claim.nonRevProof.proof);a.issuerClaimNonRevMtpAuxHi=f.key.bigInt().toString(),a.issuerClaimNonRevMtpAuxHv=f.value.bigInt().toString(),a.issuerClaimNonRevMtpNoAux=f.noAux;let d=d2(this.claim.signatureProof.issuerAuthNonRevProof.proof);a.issuerAuthClaimNonRevMtpAuxHi=d.key.bigInt().toString(),a.issuerAuthClaimNonRevMtpAuxHv=d.value.bigInt().toString(),a.issuerAuthClaimNonRevMtpNoAux=d.noAux,a.claimPathNotExists=io(e.mtp.existence);let b=d2(e.mtp);a.claimPathMtpNoAux=b.noAux,a.claimPathMtpAuxHi=b.key.bigInt().toString(),a.claimPathMtpAuxHv=b.value.bigInt().toString(),a.claimPathKey=e.path.toString(),this.skipClaimRevocationCheck?a.isRevocationChecked=0:a.isRevocationChecked=1;let t=ro(this.query.values,this.getValueArrSize());return a.value=no(t),new TextEncoder().encode(JSON.stringify(a))}},XI=class extends f2{requestID;userID;issuerID;issuerAuthState;issuerClaimNonRevState;claimSchema;slotIndex;operator;value=[];timestamp;merklized;claimPathKey;claimPathNotExists;isRevocationChecked;pubSignalsUnmarshal(e){let f=JSON.parse(new TextDecoder().decode(e));if(f.length!==13+this.getValueArrSize())throw new Error(`invalid number of Output values expected ${13+this.getValueArrSize()} got ${f.length}`);let d=0;this.merklized=parseInt(f[d]),d++,this.userID=Z0.fromBigInt(BigInt(f[d])),d++,this.issuerAuthState=kd(f[d]),d++,this.requestID=BigInt(f[d]),d++,this.issuerID=Z0.fromBigInt(BigInt(f[d])),d++,this.isRevocationChecked=parseInt(f[d]),d++,this.issuerClaimNonRevState=kd(f[d]),d++,this.timestamp=parseInt(f[d]),d++,this.claimSchema=kc.newSchemaHashFromInt(BigInt(f[d])),d++,this.claimPathNotExists=parseInt(f[d]),d++,this.claimPathKey=BigInt(f[d]),d++,this.slotIndex=parseInt(f[d]),d++,this.operator=parseInt(f[d]),d++;for(let b=0;b<this.getValueArrSize();b++)this.value.push(BigInt(f[d])),d++;return this}};s();x();var lo=class extends f2{genesisID;profileNonce;authClaim;authClaimIncMtp;authClaimNonRevMtp;treeState;gistProof;signature;challenge;validate(){if(!this.genesisID)throw new Error("empty Id");if(!this.authClaimIncMtp)throw new Error("empty auth claim mtp proof");if(!this.authClaimNonRevMtp)throw new Error("empty auth claim non-revocation mtp proof");if(!this.gistProof?.proof)throw new Error("empty global identity mtp proof");if(!this.signature)throw new Error("empty challenge signature");if(!this.challenge)throw new Error("empty challenge")}inputsMarshal(){this.validate();let e={genesisID:this.genesisID?.bigInt().toString(),profileNonce:this.profileNonce?.toString(),authClaim:this.authClaim?.marshalJson(),authClaimIncMtp:$c(this.authClaimIncMtp,this.getMTLevel()),authClaimNonRevMtp:$c(this.authClaimNonRevMtp,this.getMTLevel()),challenge:this.challenge?.toString(),challengeSignatureR8x:this.signature?.R8[0].toString(),challengeSignatureR8y:this.signature?.R8[1].toString(),challengeSignatureS:this.signature?.S.toString(),claimsTreeRoot:this.treeState?.claimsRoot.bigInt().toString(),revTreeRoot:this.treeState?.revocationRoot.bigInt().toString(),rootsTreeRoot:this.treeState?.rootOfRoots.bigInt().toString(),state:this.treeState?.state.bigInt().toString(),gistRoot:this.gistProof.root.bigInt().toString(),gistMtp:$c(this.gistProof.proof,this.getMTLevelOnChain())},a=d2(this.authClaimNonRevMtp);e.authClaimNonRevMtpAuxHi=a.key.bigInt().toString(),e.authClaimNonRevMtpAuxHv=a.value.bigInt().toString(),e.authClaimNonRevMtpNoAux=a.noAux;let f=d2(this.gistProof.proof);return e.gistMtpAuxHi=f.key.bigInt().toString(),e.gistMtpAuxHv=f.value.bigInt().toString(),e.gistMtpNoAux=f.noAux,new TextEncoder().encode(JSON.stringify(e))}},uo=class{userID;challenge;GISTRoot;pubSignalsUnmarshal(e){let f=JSON.parse(new TextDecoder().decode(e));if(f.length!==3)throw new Error(`invalid number of Output values expected ${3} got ${f.length}`);return this.userID=Z0.fromBigInt(BigInt(f[0])),this.challenge=BigInt(f[1]),this.GISTRoot=kd(f[2]),this}};s();x();var ho=class extends f2{id;oldTreeState;newTreeState;isOldStateGenesis;authClaim;authClaimNewStateIncProof;signature;inputsMarshal(){if(!this.authClaim.incProof.proof)throw new Error("empty auth claim mtp proof");if(!this.authClaimNewStateIncProof)throw new Error("empty auth claim mtp proof in the new state");if(!this.authClaim.nonRevProof.proof)throw new Error("empty auth claim non-revocation mtp proof");let e={authClaim:this.authClaim.claim.marshalJson(),authClaimMtp:$c(this.authClaim.incProof.proof,this.getMTLevel()),authClaimNonRevMtp:$c(this.authClaim.nonRevProof.proof,this.getMTLevel()),newAuthClaimMtp:$c(this.authClaimNewStateIncProof,this.getMTLevel()),userID:this.id.bigInt().toString(),newUserState:this.newTreeState.state.bigInt().toString(),claimsTreeRoot:this.oldTreeState.claimsRoot.bigInt().toString(),oldUserState:this.oldTreeState.state.bigInt().toString(),revTreeRoot:this.oldTreeState.revocationRoot.bigInt().toString(),rootsTreeRoot:this.oldTreeState.rootOfRoots.bigInt().toString(),signatureR8x:this.signature.R8[0].toString(),signatureR8y:this.signature.R8[1].toString(),signatureS:this.signature.S.toString(),newClaimsTreeRoot:this.newTreeState.claimsRoot.bigInt().toString(),newRootsTreeRoot:this.newTreeState.rootOfRoots.bigInt().toString(),newRevTreeRoot:this.newTreeState.revocationRoot.bigInt().toString()};this.isOldStateGenesis?e.isOldStateGenesis="1":e.isOldStateGenesis="0";let a=d2(this.authClaim.nonRevProof.proof);return e.authClaimNonRevMtpAuxHi=a.key.bigInt().toString(),e.authClaimNonRevMtpAuxHv=a.value.bigInt().toString(),e.authClaimNonRevMtpNoAux=a.noAux,new TextEncoder().encode(JSON.stringify(e))}},po=class{userId;oldUserState;newUserState;isOldStateGenesis;pubSignalsUnmarshal(e){let a=JSON.parse(new TextDecoder().decode(e)),f=4;if(a.length!==f)throw new Error(`invalid number of Output values expected ${f} got ${a.length}`);return this.userId=Z0.fromBigInt(BigInt(a[0])),this.oldUserState=kd(a[1]),this.newUserState=kd(a[2]),this.isOldStateGenesis=BigInt(a[3])===BigInt(1),this}};var z4=class{constructor(e=b0,a=[]){this.hash=e;this.children=a}nodeType(){return this.children.length===2?1:this.children.length===3&&this.children[2].hex()===Y0(BigInt(1)).hex()?2:this.children.length===3?3:0}toJSON(){return{hash:this.hash.hex(),children:this.children.map(e=>e.hex())}}static fromHex(e){return new z4(tc(e.hash),e.children.map(a=>tc(a)))}};async function tY(c,e,a){let f=await a.getLatestStateById(c.id.bigInt()),d=Y0(BigInt(e.revocationNonce??0)),b=Y0(BigInt(f?.state??0));return Lpe(d,b,e.id)}async function Lpe(c,e,a){if(!a)throw new Error("HTTP reverse hash service URL is not specified");let f=(await Qf.get(`${a}/node/${e.hex()}`)).data?.node;if(f.children.length!==3)throw new Error("state should has tree children");let d=e.hex(),b=f.children[0],t=f.children[1],r=f.children[2],o=tc(t);return{mtp:await Cpe(o,c,`${a}/node`),issuer:{state:d,claimsTreeRoot:b,revocationTreeRoot:t,rootOfRoots:r}}}async function Fpe(c,e,a){let f=new Gd;f.existence=c,f.nodeAux=a,f.depth=e.length;for(let d=0;d<e.length;d++){let b=e[d];JSON.stringify(e[d])!==JSON.stringify(b0)&&(k6(f.notEmpties,d),f.siblings.push(b))}return f}async function Cpe(c,e,a){let f=!1,d=[],b,t=()=>Fpe(f,d,b),r=c;for(let o=0;o<e.bytes.length*8;o++){if(r.bytes.every(l=>l===0))return t();let n=(await Qf.get(`${a}/${r.hex()}`)).data?.node,i=z4.fromHex(n);switch(i.nodeType()){case 2:return e.bytes.every((l,h)=>l===i.children[0].bytes[h])?(f=!0,t()):(b={key:i.children[0],value:i.children[1]},t());case 1:on(e.bytes,o)?(r=i.children[1],d.push(i.children[0])):(r=i.children[0],d.push(i.children[1]));break;default:throw new Error(`found unexpected node type in tree ${i.hash.hex()}`)}}throw new Error("tree depth is too high")}async function rY(c,e,a,f){let d=new eL;f&&await Ppe(d,e,f),await Bpe(d,e),c.bytes.every(b=>b===0)||d.addProofNode(new z4(c,[await e.claimsTree.root(),await e.revocationTree.root(),await e.rootsTree.root()])),d.nodes.length>0&&await Rpe(d.nodes,a)}async function Rpe(c,e){let a=c.map(f=>f.toJSON());return await(await Qf.post(e+"/node",a)).status===200}async function Bpe(c,e){let a=e.rootsTree,f=e.claimsTree;return c.addKey(a,(await f.root()).bigInt())}async function Ppe(c,e,a){let f=e.revocationTree;for(let d of a)await c.addKey(f,BigInt(d))}var eL=class{constructor(e=[],a=new Map){this.nodes=e;this.seen=a}async addKey(e,a){let{value:f,siblings:d}=await e.get(a),b=Y0(a),t=Y0(f),r=new Ud(b,t),o=await Tpe(d,r);for(let n of o)this.seen.get(n.hash.hex())||(this.nodes.push(n),this.seen.set(n.hash.hex(),!0))}addProofNode(e){let a=e.hash.hex();this.seen.get(a)||(this.nodes.push(e),this.seen.set(a,!0))}};async function Tpe(c,e){if(e.type!==1)throw new Error("node is not a leaf");let a=await e.getKey(),f=c.length,d=new Array(f+1);for(let r=0;r<d.length;r++)d[r]=new z4;d[f].hash=a;let b=Y0(BigInt(1));d[f].children=[e.entry[0],e.entry[1],b];let t=e.entry[0];for(let r=f-1;r>=0;r--){let o=on(t.bytes,r);d[r].children=new Array(2),o?(d[r].children[0]=c[r],d[r].children[1]=a):(d[r].children[0]=a,d[r].children[1]=c[r]),d[r].hash=await J8([d[r].children[0].bigInt(),d[r].children[1].bigInt()]),a=d[r].hash}return d}var Wp=class{issuer;mtp;toRevocationStatus(){let e=new Gd;e.existence=this.mtp.existence,e.nodeAux=this.mtp.node_aux?{key:Y0(BigInt(this.mtp.node_aux.key)),value:Y0(BigInt(this.mtp.node_aux.value))}:void 0;let a=this.mtp.siblings.map(f=>Y0(BigInt(f)));e.siblings=[],e.depth=a.length;for(let f=0;f<a.length;f++)a[f].bigInt()!==BigInt(0)&&(k6(e.notEmpties,f),e.siblings.push(a[f]));return{mtp:e,issuer:this.issuer}}};var aL=class{constructor(e,a,f){this._kms=e;this._storage=a;this._credentialWallet=f}async createIdentity(e,a){let f=If();await this._storage.mt.createIdentityMerkleTrees(f),a||(a={method:mb.Iden3,blockchain:N6.Polygon,networkId:M6.Mumbai}),a.seed=a.seed??u_(32);let d=await this._kms.createKeyFromSeed("BJJ",a.seed),b=await this._kms.publicKey(d),t=kc.authSchemaHash,r=Uf.newClaim(t,m1.withIndexDataInts(b.p[0],b.p[1]),m1.withRevocationNonce(BigInt(0))),o=0;r.setRevocationNonce(BigInt(o)),await this._storage.mt.addToMerkleTree(f,0,r.hiHv().hi,r.hiHv().hv);let n=await this._storage.mt.getMerkleTreeByIdentifierAndType(f,0),i=await J8([(await n.root()).bigInt(),b0.bigInt(),b0.bigInt()]),l=tn(a.method,a.blockchain,a.networkId),h=Z0.idGenesisFromIdenState(l,i.bigInt()),u=sc.parseFromId(h);await this._storage.mt.bindMerkleTreeToNewIdentifier(f,u.toString());let g=JSON.parse(Uc.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSON),E=r.getExpirationDate(),_=E?W8(E):0,F={credentialSchema:Uc.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL,type:Uc.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,credentialSubject:{x:b.p[0].toString(),y:b.p[1].toString()},subjectPosition:YE(r.getIdPosition()),version:0,expiration:_,revNonce:o};e=e.replace(/\/$/,"");let L=new U2;try{L=this._credentialWallet.createCredential(e,u,F,g,a.rhsUrl)}catch{throw new Error("Error create Iden3Credential")}let U=r.hIndex(),O=await n.root(),{proof:H}=await n.generateProof(U,O),P=O.hex(),A=i.hex(),I=new Y8({type:"Iden3SparseMerkleTreeProof",mtp:H,issuerData:new z6({id:u.toString(),state:{rootOfRoots:b0.hex(),revocationTreeRoot:b0.hex(),claimsTreeRoot:P,value:A},authCoreClaim:r.hex(),credentialStatus:L.credentialStatus,mtp:H}),coreClaim:r.hex()});return L.proof=[I],await this._storage.identity.saveIdentity({identifier:u.toString(),state:i,published:!1,genesis:!0}),await this._credentialWallet.save(L),{did:u,credential:L}}async createProfile(e,a,f){let d=e.id;if((await this._storage.identity.getProfilesByGenesisIdentifier(e.toString())).find(n=>n.nonce==a||n.verifier==f))throw new Error("profile with given nonce or verifier already exists");let r=Z0.profileId(d,BigInt(a)),o=sc.parseFromId(r);return await this._storage.identity.saveProfile({id:o.toString(),nonce:a,genesisIdentifier:e.toString(),verifier:f}),o}async generateKey(e){return await this._kms.createKeyFromSeed(e,u_(32))}async getDIDTreeModel(e){let a=await this._storage.mt.getMerkleTreeByIdentifierAndType(e.toString(),0),f=await this._storage.mt.getMerkleTreeByIdentifierAndType(e.toString(),1),d=await this._storage.mt.getMerkleTreeByIdentifierAndType(e.toString(),2);return{state:await J8([(await a.root()).bigInt(),(await f.root()).bigInt(),(await d.root()).bigInt()]),claimsTree:a,revocationTree:f,rootsTree:d}}async generateCredentialMtp(e,a,f){let d=await this.getCoreClaimFromCredential(a),b=await this.getDIDTreeModel(e),t=await this._storage.mt.getMerkleTreeByIdentifierAndType(e.toString(),0),r=await b.claimsTree.root(),o=await b.rootsTree.root(),n=await b.revocationTree.root(),{proof:i}=await t.generateProof(d.hIndex(),f?f.claimsRoot:r);return{proof:i,treeState:f??{state:b.state,claimsRoot:r,rootOfRoots:o,revocationRoot:n}}}async generateNonRevocationMtp(e,a,f){let b=(await this.getCoreClaimFromCredential(a)).getRevocationNonce(),t=await this.getDIDTreeModel(e),r=await this._storage.mt.getMerkleTreeByIdentifierAndType(e.toString(),1),o=await t.claimsTree.root(),n=await t.rootsTree.root(),i=await t.revocationTree.root(),{proof:l}=await r.generateProof(b,f?f.revocationRoot:i);return{proof:l,treeState:f??{state:t.state,claimsRoot:o,rootOfRoots:n,revocationRoot:i}}}async sign(e,a){let f=this.getKMSIdByAuthCredential(a),d=Mc.hashBytes(e),b=await this._kms.sign(f,H0.intToBytes(d));return ub.newFromCompressed(b)}async signChallenge(e,a){let f=this.getKMSIdByAuthCredential(a),d=await this._kms.sign(f,H0.intToBytes(e));return ub.newFromCompressed(d)}async issueCredential(e,a,f,d){d||(d={withRHS:""}),f=f.replace(/\/$/,"");let b=await new D7("ipfs.io").load(a.credentialSchema),t=JSON.parse(new TextDecoder().decode(b)),r=new U2,o=0;a.revNonce||(a.revNonce=Math.round(Math.random()*1e4)),a.subjectPosition=a.subjectPosition??"index",o=a.revNonce;try{r=this._credentialWallet.createCredential(f,e,a,t,d.withRHS)}catch{throw new Error("Error create Iden3Credential")}let n=await this._credentialWallet.getAuthBJJCredential(e),i={revNonce:o,subjectPosition:a.subjectPosition,merklizedRootPosition:this.defineMTRootPosition(t,a.merklizedRootPosition),updatable:!1,version:0},l=await new S4().parseClaim(r,`${t.$metadata.uris.jsonLdContext}#${a.type}`,b,i),{hi:h,hv:u}=l.hiHv(),g=Mc.hash([h,u]),E=this.getKMSIdByAuthCredential(n),_=await this._kms.sign(E,H0.intToBytes(g));if(!n.proof)throw new Error("issuer auth credential must have proof");let F=n.proof[0],L={type:"BJJSignature2021",issuerData:new z6({id:e.toString(),state:F.issuerData.state,authCoreClaim:F.coreClaim,mtp:F.mtp,credentialStatus:F.issuerData.credentialStatus}),coreClaim:l.hex(),signature:R0.encodeString(_)};return r.proof=[L],r}async revokeCredential(e,a){let f=await this.getDIDTreeModel(e),d=a.getCoreClaimFromProof("BJJSignature2021");if(!d)throw new Error("credential must have coreClaim representation in the signature proof");let b=d.getRevocationNonce();return await f.revocationTree.add(b,BigInt(0)),Number(BigInt.asUintN(64,b))}async addCredentialsToMerkleTree(e,a){let f=await this.getDIDTreeModel(a),d=await f.claimsTree.root(),b=await f.rootsTree.root(),t=await f.revocationTree.root(),r={state:f.state,claimsRoot:d,revocationRoot:t,rootOfRoots:b};for(let l=0;l<e.length;l++){let u=await e[l].getCoreClaimFromProof("BJJSignature2021");if(!u)throw new Error("credential must have coreClaim representation in the signature proof");await this._storage.mt.addToMerkleTree(a.toString(),0,u.hIndex(),u.hValue())}let n=await(await this.getDIDTreeModel(a)).claimsTree.root();await this._storage.mt.addToMerkleTree(a.toString(),2,n.bigInt(),BigInt(0));let i=await this.getDIDTreeModel(a);return d=await i.claimsTree.root(),b=await i.rootsTree.root(),t=await i.revocationTree.root(),{credentials:e,newTreeState:{state:i.state,claimsRoot:d,rootOfRoots:b,revocationRoot:t},oldTreeState:r}}async generateIden3SparseMerkleTreeProof(e,a,f,d,b){for(let t=0;t<a.length;t++){let r=a[t],o=await this.generateCredentialMtp(e,r),n=r.getCoreClaimFromProof("BJJSignature2021");if(!n)throw new Error("credential must have coreClaim representation in the signature proof");let i=new Y8({type:"Iden3SparseMerkleTreeProof",mtp:o.proof,issuerData:new z6({id:e.toString(),state:{claimsTreeRoot:o.treeState.claimsRoot.hex(),revocationTreeRoot:o.treeState.revocationRoot.hex(),rootOfRoots:o.treeState.rootOfRoots.hex(),value:o.treeState.state.hex(),txId:f,blockNumber:d,blockTimestamp:b},mtp:o.proof}),coreClaim:n.hex()});Array.isArray(a[t].proof)?a[t].proof.push(i):a[t].proof=i}return a}async publishStateToRHS(e,a,f){let d=await this.getDIDTreeModel(e);await rY(d.state,{revocationTree:d.revocationTree,claimsTree:d.claimsTree,state:d.state,rootsTree:d.rootsTree},a,f)}getKMSIdByAuthCredential(e){if(e.type.indexOf("AuthBJJCredential")===-1)throw new Error("can't sign with not AuthBJJCredential credential");let a=e.credentialSubject.x,f=e.credentialSubject.y,d=new Q8([BigInt(a),BigInt(f)]),b=il("BJJ",d.hex());return{type:"BJJ",id:b}}defineMTRootPosition(e,a){return e.$metadata?.serialization?"":a||"index"}async getCoreClaimFromCredential(e){let a=e.getCoreClaimFromProof("BJJSignature2021"),f=e.getCoreClaimFromProof("Iden3SparseMerkleTreeProof");if(f&&a&&f.hex()!==a.hex())throw new Error("core claim representations is set in both proofs but they are not equal");if(!f&&!a)throw new Error("core claim is not set in credential proofs");return f??a}};s();x();s();x();var Ope="all claims are revoked",cL=class{constructor(e){this._storage=e}async getAuthBJJCredential(e){let a=await this._storage.credential.findCredentialsByQuery({context:Uc.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL,type:Uc.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,allowedIssuers:[e.toString()]});if(!a.length)throw new Error("no auth credentials found");for(let f=0;f<a.length;f++){let d=a[f];if(!(await this.getRevocationStatusFromCredential(d)).mtp.existence)return d}throw new Error("all auth bjj credentials are revoked")}async getRevocationStatusFromCredential(e){let a=e.getIden3SparseMerkleTreeProof(),f=e.getBJJSignature2021Proof(),d=a?a.issuerData:f?.issuerData;if(!d)throw new Error("no sig / mtp proof to check issuer info");let b=sc.parse(e.issuer);return await this.getRevocationStatus(e.credentialStatus,b,d)}async getRevocationStatus(e,a,f){if(e.type==="SparseMerkleTreeProof"){let d=(await Qf.get(e.id)).data;return Object.assign(new Wp,d).toRevocationStatus()}if(e.type==="Iden3ReverseSparseMerkleTreeProof")try{return await tY(a,e,this._storage.states)}catch(d){if((d.reason??d.message).includes(Uc.ERRORS.IDENTITY_DOES_NOT_EXIST)&&nY(a.toString(),f.state.value))return{mtp:new Gd,issuer:{state:f.state.value,revocationTreeRoot:f.state.revocationTreeRoot,rootOfRoots:f.state.rootOfRoots,claimsTreeRoot:f.state.claimsTreeRoot}};if(e?.statusIssuer?.type==="SparseMerkleTreeProof")return(await Qf.get(e.id)).data;throw new Error("can't fetch revocation status")}throw new Error("revocation status unknown")}createCredential=(e,a,f,d,b)=>{if(!d.$metadata.uris.jsonLdContext)throw new Error("jsonLdContext is missing is the schema");let t=[Uc.JSONLD_SCHEMA.W3C_CREDENTIAL_2018,Uc.JSONLD_SCHEMA.IDEN3_CREDENTIAL,d.$metadata.uris.jsonLdContext],r=[Uc.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL,f.type],o=!f.expiration||f.expiration==0?null:f.expiration,n=a.toString(),i=f.credentialSubject;i.type=f.type;let l=new U2;return l.id=`${e}/${If()}`,l["@context"]=t,l.type=r,l.expirationDate=o?new Date(o*1e3).toISOString():void 0,l.issuanceDate=new Date().toISOString(),l.credentialSubject=i,l.issuer=n.toString(),l.credentialSchema={id:f.credentialSchema,type:Uc.JSON_SCHEMA_VALIDATOR},b?l.credentialStatus={id:`${b}`,revocationNonce:f.revNonce,type:"Iden3ReverseSparseMerkleTreeProof"}:l.credentialStatus={id:`${e}/revocation/${f.revNonce}`,revocationNonce:f.revNonce,type:"SparseMerkleTreeProof"},l};async findById(e){return this._storage.credential.findCredentialById(e)}async findByContextType(e,a){return this._storage.credential.findCredentialsByQuery({context:e,type:a})}async save(e){return this._storage.credential.saveCredential(e)}async saveAll(e){return this._storage.credential.saveAllCredentials(e)}async remove(e){return this._storage.credential.removeCredential(e)}async list(){return this._storage.credential.listCredentials()}async findByQuery(e){return this._storage.credential.findCredentialsByQuery(e)}async filterByCredentialSubject(e,a){return e.filter(f=>f.credentialSubject.id===a.toString())}async findNonRevokedCredential(e){for(let a of e){let f=await this.getRevocationStatusFromCredential(a);if(!f.mtp.existence)return{cred:a,revStatus:f}}throw new Error(Ope)}};function nY(c,e){let a=sc.parse(c),f=H0.hexToBytes(e),d=H0.bytesToInt(f),b=tn(a.method,a.blockchain,a.networkId);return iY(a.id.bigInt(),d,b)}function iY(c,e,a){let f=Z0.idGenesisFromIdenState(a,e);return c.toString()===f.bigInt().toString()}s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();var Qt={};v0(Qt,{BaseContract:()=>Pt,BigNumber:()=>Ee,Contract:()=>X4,ContractFactory:()=>No,FixedNumber:()=>$a,Signer:()=>fd,VoidSigner:()=>t8,Wallet:()=>V1,Wordlist:()=>f1,constants:()=>hm,errors:()=>Sd,getDefaultProvider:()=>rg,logger:()=>H0e,providers:()=>ng,utils:()=>og,version:()=>sg,wordlists:()=>a5});s();x();s();x();s();x();s();x();s();x();s();x();var vY=Fe(dL());s();x();s();x();s();x();var sY="logger/5.7.0";var xY=!1,lY=!1,Jp={debug:1,default:2,info:2,warning:3,error:4,off:5},uY=Jp.default,bL=null;function Npe(){try{let c=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{c.push(e)}}),c.length)throw new Error("missing "+c.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(c){return c.message}return null}var hY=Npe(),tL;(function(c){c.DEBUG="DEBUG",c.INFO="INFO",c.WARNING="WARNING",c.ERROR="ERROR",c.OFF="OFF"})(tL||(tL={}));var Sd;(function(c){c.UNKNOWN_ERROR="UNKNOWN_ERROR",c.NOT_IMPLEMENTED="NOT_IMPLEMENTED",c.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",c.NETWORK_ERROR="NETWORK_ERROR",c.SERVER_ERROR="SERVER_ERROR",c.TIMEOUT="TIMEOUT",c.BUFFER_OVERRUN="BUFFER_OVERRUN",c.NUMERIC_FAULT="NUMERIC_FAULT",c.MISSING_NEW="MISSING_NEW",c.INVALID_ARGUMENT="INVALID_ARGUMENT",c.MISSING_ARGUMENT="MISSING_ARGUMENT",c.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",c.CALL_EXCEPTION="CALL_EXCEPTION",c.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",c.NONCE_EXPIRED="NONCE_EXPIRED",c.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",c.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",c.TRANSACTION_REPLACED="TRANSACTION_REPLACED",c.ACTION_REJECTED="ACTION_REJECTED"})(Sd||(Sd={}));var pY="0123456789abcdef",X=class{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,a){let f=e.toLowerCase();Jp[f]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(uY>Jp[f])&&console.log.apply(console,a)}debug(...e){this._log(X.levels.DEBUG,e)}info(...e){this._log(X.levels.INFO,e)}warn(...e){this._log(X.levels.WARNING,e)}makeError(e,a,f){if(lY)return this.makeError("censored error",a,{});a||(a=X.errors.UNKNOWN_ERROR),f||(f={});let d=[];Object.keys(f).forEach(o=>{let n=f[o];try{if(n instanceof Uint8Array){let i="";for(let l=0;l<n.length;l++)i+=pY[n[l]>>4],i+=pY[n[l]&15];d.push(o+"=Uint8Array(0x"+i+")")}else d.push(o+"="+JSON.stringify(n))}catch{d.push(o+"="+JSON.stringify(f[o].toString()))}}),d.push(`code=${a}`),d.push(`version=${this.version}`);let b=e,t="";switch(a){case Sd.NUMERIC_FAULT:{t="NUMERIC_FAULT";let o=e;switch(o){case"overflow":case"underflow":case"division-by-zero":t+="-"+o;break;case"negative-power":case"negative-width":t+="-unsupported";break;case"unbound-bitwise-result":t+="-unbound-result";break}break}case Sd.CALL_EXCEPTION:case Sd.INSUFFICIENT_FUNDS:case Sd.MISSING_NEW:case Sd.NONCE_EXPIRED:case Sd.REPLACEMENT_UNDERPRICED:case Sd.TRANSACTION_REPLACED:case Sd.UNPREDICTABLE_GAS_LIMIT:t=a;break}t&&(e+=" [ See: https://links.ethers.org/v5-errors-"+t+" ]"),d.length&&(e+=" ("+d.join(", ")+")");let r=new Error(e);return r.reason=b,r.code=a,Object.keys(f).forEach(function(o){r[o]=f[o]}),r}throwError(e,a,f){throw this.makeError(e,a,f)}throwArgumentError(e,a,f){return this.throwError(e,X.errors.INVALID_ARGUMENT,{argument:a,value:f})}assert(e,a,f,d){e||this.throwError(a,f,d)}assertArgument(e,a,f,d){e||this.throwArgumentError(a,f,d)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),hY&&this.throwError("platform missing String.prototype.normalize",X.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:hY})}checkSafeUint53(e,a){typeof e=="number"&&(a==null&&(a="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(a,X.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(a,X.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,a,f){f?f=": "+f:f="",e<a&&this.throwError("missing argument"+f,X.errors.MISSING_ARGUMENT,{count:e,expectedCount:a}),e>a&&this.throwError("too many arguments"+f,X.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:a})}checkNew(e,a){(e===Object||e==null)&&this.throwError("missing new",X.errors.MISSING_NEW,{name:a.name})}checkAbstract(e,a){e===a?this.throwError("cannot instantiate abstract class "+JSON.stringify(a.name)+" directly; use a sub-class",X.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",X.errors.MISSING_NEW,{name:a.name})}static globalLogger(){return bL||(bL=new X(sY)),bL}static setCensorship(e,a){if(!e&&a&&this.globalLogger().throwError("cannot permanently disable censorship",X.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),xY){if(!e)return;this.globalLogger().throwError("error censorship permanent",X.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}lY=!!e,xY=!!a}static setLogLevel(e){let a=Jp[e.toLowerCase()];if(a==null){X.globalLogger().warn("invalid log level - "+e);return}uY=a}static from(e){return new X(e)}};X.errors=Sd;X.levels=tL;s();x();var mY="bytes/5.7.0";var rc=new X(mY);function yY(c){return!!c.toHexString}function ot(c){return c.slice||(c.slice=function(){let e=Array.prototype.slice.call(arguments);return ot(new Uint8Array(Array.prototype.slice.apply(c,e)))}),c}function a8(c){return n0(c)&&!(c.length%2)||Q2(c)}function gY(c){return typeof c=="number"&&c==c&&c%1===0}function Q2(c){if(c==null)return!1;if(c.constructor===Uint8Array)return!0;if(typeof c=="string"||!gY(c.length)||c.length<0)return!1;for(let e=0;e<c.length;e++){let a=c[e];if(!gY(a)||a<0||a>=256)return!1}return!0}function Se(c,e){if(e||(e={}),typeof c=="number"){rc.checkSafeUint53(c,"invalid arrayify value");let a=[];for(;c;)a.unshift(c&255),c=parseInt(String(c/256));return a.length===0&&a.push(0),ot(new Uint8Array(a))}if(e.allowMissingPrefix&&typeof c=="string"&&c.substring(0,2)!=="0x"&&(c="0x"+c),yY(c)&&(c=c.toHexString()),n0(c)){let a=c.substring(2);a.length%2&&(e.hexPad==="left"?a="0"+a:e.hexPad==="right"?a+="0":rc.throwArgumentError("hex data is odd-length","value",c));let f=[];for(let d=0;d<a.length;d+=2)f.push(parseInt(a.substring(d,d+2),16));return ot(new Uint8Array(f))}return Q2(c)?ot(new Uint8Array(c)):rc.throwArgumentError("invalid arrayify value","value",c)}function O0(c){let e=c.map(d=>Se(d)),a=e.reduce((d,b)=>d+b.length,0),f=new Uint8Array(a);return e.reduce((d,b)=>(f.set(b,d),d+b.length),0),ot(f)}function b2(c){let e=Se(c);if(e.length===0)return e;let a=0;for(;a<e.length&&e[a]===0;)a++;return a&&(e=e.slice(a)),e}function j4(c,e){c=Se(c),c.length>e&&rc.throwArgumentError("value out of range","value",arguments[0]);let a=new Uint8Array(e);return a.set(c,e-c.length),ot(a)}function n0(c,e){return!(typeof c!="string"||!c.match(/^0x[0-9A-Fa-f]*$/)||e&&c.length!==2+2*e)}var rL="0123456789abcdef";function Be(c,e){if(e||(e={}),typeof c=="number"){rc.checkSafeUint53(c,"invalid hexlify value");let a="";for(;c;)a=rL[c&15]+a,c=Math.floor(c/16);return a.length?(a.length%2&&(a="0"+a),"0x"+a):"0x00"}if(typeof c=="bigint")return c=c.toString(16),c.length%2?"0x0"+c:"0x"+c;if(e.allowMissingPrefix&&typeof c=="string"&&c.substring(0,2)!=="0x"&&(c="0x"+c),yY(c))return c.toHexString();if(n0(c))return c.length%2&&(e.hexPad==="left"?c="0x0"+c.substring(2):e.hexPad==="right"?c+="0":rc.throwArgumentError("hex data is odd-length","value",c)),c.toLowerCase();if(Q2(c)){let a="0x";for(let f=0;f<c.length;f++){let d=c[f];a+=rL[(d&240)>>4]+rL[d&15]}return a}return rc.throwArgumentError("invalid hexlify value","value",c)}function Cf(c){if(typeof c!="string")c=Be(c);else if(!n0(c)||c.length%2)return null;return(c.length-2)/2}function ya(c,e,a){return typeof c!="string"?c=Be(c):(!n0(c)||c.length%2)&&rc.throwArgumentError("invalid hexData","value",c),e=2+2*e,a!=null?"0x"+c.substring(e,2+2*a):"0x"+c.substring(e)}function Ec(c){let e="0x";return c.forEach(a=>{e+=Be(a).substring(2)}),e}function kb(c){let e=nL(Be(c,{hexPad:"left"}));return e==="0x"?"0x0":e}function nL(c){typeof c!="string"&&(c=Be(c)),n0(c)||rc.throwArgumentError("invalid hex string","value",c),c=c.substring(2);let e=0;for(;e<c.length&&c[e]==="0";)e++;return"0x"+c.substring(e)}function q0(c,e){for(typeof c!="string"?c=Be(c):n0(c)||rc.throwArgumentError("invalid hex string","value",c),c.length>2*e+2&&rc.throwArgumentError("value out of range","value",arguments[1]);c.length<2*e+2;)c="0x0"+c.substring(2);return c}function Ub(c){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(a8(c)){let a=Se(c);a.length===64?(e.v=27+(a[32]>>7),a[32]&=127,e.r=Be(a.slice(0,32)),e.s=Be(a.slice(32,64))):a.length===65?(e.r=Be(a.slice(0,32)),e.s=Be(a.slice(32,64)),e.v=a[64]):rc.throwArgumentError("invalid signature string","signature",c),e.v<27&&(e.v===0||e.v===1?e.v+=27:rc.throwArgumentError("signature invalid v byte","signature",c)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(a[32]|=128),e._vs=Be(a.slice(32,64))}else{if(e.r=c.r,e.s=c.s,e.v=c.v,e.recoveryParam=c.recoveryParam,e._vs=c._vs,e._vs!=null){let d=j4(Se(e._vs),32);e._vs=Be(d);let b=d[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=b:e.recoveryParam!==b&&rc.throwArgumentError("signature recoveryParam mismatch _vs","signature",c),d[0]&=127;let t=Be(d);e.s==null?e.s=t:e.s!==t&&rc.throwArgumentError("signature v mismatch _vs","signature",c)}if(e.recoveryParam==null)e.v==null?rc.throwArgumentError("signature missing v and recoveryParam","signature",c):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let d=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==d&&rc.throwArgumentError("signature recoveryParam mismatch v","signature",c)}e.r==null||!n0(e.r)?rc.throwArgumentError("signature missing or invalid r","signature",c):e.r=q0(e.r,32),e.s==null||!n0(e.s)?rc.throwArgumentError("signature missing or invalid s","signature",c):e.s=q0(e.s,32);let a=Se(e.s);a[0]>=128&&rc.throwArgumentError("signature s out of range","signature",c),e.recoveryParam&&(a[0]|=128);let f=Be(a);e._vs&&(n0(e._vs)||rc.throwArgumentError("signature invalid _vs","signature",c),e._vs=q0(e._vs,32)),e._vs==null?e._vs=f:e._vs!==f&&rc.throwArgumentError("signature _vs mismatch v and s","signature",c)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function mo(c){return c=Ub(c),Be(O0([c.r,c.s,c.recoveryParam?"0x1c":"0x1b"]))}s();x();var Zp="bignumber/5.7.0";var go=vY.default.BN,c8=new X(Zp),iL={},wY=9007199254740991;function EY(c){return c!=null&&(Ee.isBigNumber(c)||typeof c=="number"&&c%1===0||typeof c=="string"&&!!c.match(/^-?[0-9]+$/)||n0(c)||typeof c=="bigint"||Q2(c))}var _Y=!1,Ee=class{constructor(e,a){e!==iL&&c8.throwError("cannot call constructor directly; use BigNumber.from",X.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=a,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Id(K0(this).fromTwos(e))}toTwos(e){return Id(K0(this).toTwos(e))}abs(){return this._hex[0]==="-"?Ee.from(this._hex.substring(1)):this}add(e){return Id(K0(this).add(K0(e)))}sub(e){return Id(K0(this).sub(K0(e)))}div(e){return Ee.from(e).isZero()&&W2("division-by-zero","div"),Id(K0(this).div(K0(e)))}mul(e){return Id(K0(this).mul(K0(e)))}mod(e){let a=K0(e);return a.isNeg()&&W2("division-by-zero","mod"),Id(K0(this).umod(a))}pow(e){let a=K0(e);return a.isNeg()&&W2("negative-power","pow"),Id(K0(this).pow(a))}and(e){let a=K0(e);return(this.isNegative()||a.isNeg())&&W2("unbound-bitwise-result","and"),Id(K0(this).and(a))}or(e){let a=K0(e);return(this.isNegative()||a.isNeg())&&W2("unbound-bitwise-result","or"),Id(K0(this).or(a))}xor(e){let a=K0(e);return(this.isNegative()||a.isNeg())&&W2("unbound-bitwise-result","xor"),Id(K0(this).xor(a))}mask(e){return(this.isNegative()||e<0)&&W2("negative-width","mask"),Id(K0(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&W2("negative-width","shl"),Id(K0(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&W2("negative-width","shr"),Id(K0(this).shrn(e))}eq(e){return K0(this).eq(K0(e))}lt(e){return K0(this).lt(K0(e))}lte(e){return K0(this).lte(K0(e))}gt(e){return K0(this).gt(K0(e))}gte(e){return K0(this).gte(K0(e))}isNegative(){return this._hex[0]==="-"}isZero(){return K0(this).isZero()}toNumber(){try{return K0(this).toNumber()}catch{W2("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return c8.throwError("this platform does not support BigInt",X.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?_Y||(_Y=!0,c8.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?c8.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",X.errors.UNEXPECTED_ARGUMENT,{}):c8.throwError("BigNumber.toString does not accept parameters",X.errors.UNEXPECTED_ARGUMENT,{})),K0(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof Ee)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new Ee(iL,yo(e)):e.match(/^-?[0-9]+$/)?new Ee(iL,yo(new go(e))):c8.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&W2("underflow","BigNumber.from",e),(e>=wY||e<=-wY)&&W2("overflow","BigNumber.from",e),Ee.from(String(e));let a=e;if(typeof a=="bigint")return Ee.from(a.toString());if(Q2(a))return Ee.from(Be(a));if(a)if(a.toHexString){let f=a.toHexString();if(typeof f=="string")return Ee.from(f)}else{let f=a._hex;if(f==null&&a.type==="BigNumber"&&(f=a.hex),typeof f=="string"&&(n0(f)||f[0]==="-"&&n0(f.substring(1))))return Ee.from(f)}return c8.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}};function yo(c){if(typeof c!="string")return yo(c.toString(16));if(c[0]==="-")return c=c.substring(1),c[0]==="-"&&c8.throwArgumentError("invalid hex","value",c),c=yo(c),c==="0x00"?c:"-"+c;if(c.substring(0,2)!=="0x"&&(c="0x"+c),c==="0x")return"0x00";for(c.length%2&&(c="0x0"+c.substring(2));c.length>4&&c.substring(0,4)==="0x00";)c="0x"+c.substring(4);return c}function Id(c){return Ee.from(yo(c))}function K0(c){let e=Ee.from(c).toHexString();return e[0]==="-"?new go("-"+e.substring(3),16):new go(e.substring(2),16)}function W2(c,e,a){let f={fault:c,operation:e};return a!=null&&(f.value=a),c8.throwError(c,X.errors.NUMERIC_FAULT,f)}function oL(c){return new go(c,36).toString(16)}function sL(c){return new go(c,16).toString(36)}s();x();var Xf=new X(Zp),wo={},SY=Ee.from(0),IY=Ee.from(-1);function LY(c,e,a,f){let d={fault:e,operation:a};return f!==void 0&&(d.value=f),Xf.throwError(c,X.errors.NUMERIC_FAULT,d)}var _o="0";for(;_o.length<256;)_o+=_o;function xL(c){if(typeof c!="number")try{c=Ee.from(c).toNumber()}catch{}return typeof c=="number"&&c>=0&&c<=256&&!(c%1)?"1"+_o.substring(0,c):Xf.throwArgumentError("invalid decimal size","decimals",c)}function st(c,e){e==null&&(e=0);let a=xL(e);c=Ee.from(c);let f=c.lt(SY);f&&(c=c.mul(IY));let d=c.mod(a).toString();for(;d.length<a.length-1;)d="0"+d;d=d.match(/^([0-9]*[1-9]|0)(0*)/)[1];let b=c.div(a).toString();return a.length===1?c=b:c=b+"."+d,f&&(c="-"+c),c}function J2(c,e){e==null&&(e=0);let a=xL(e);(typeof c!="string"||!c.match(/^-?[0-9.]+$/))&&Xf.throwArgumentError("invalid decimal value","value",c);let f=c.substring(0,1)==="-";f&&(c=c.substring(1)),c==="."&&Xf.throwArgumentError("missing value","value",c);let d=c.split(".");d.length>2&&Xf.throwArgumentError("too many decimal points","value",c);let b=d[0],t=d[1];for(b||(b="0"),t||(t="0");t[t.length-1]==="0";)t=t.substring(0,t.length-1);for(t.length>a.length-1&&LY("fractional component exceeds decimals","underflow","parseFixed"),t===""&&(t="0");t.length<a.length-1;)t+="0";let r=Ee.from(b),o=Ee.from(t),n=r.mul(a).add(o);return f&&(n=n.mul(IY)),n}var f8=class{constructor(e,a,f,d){e!==wo&&Xf.throwError("cannot use FixedFormat constructor; use FixedFormat.from",X.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=a,this.width=f,this.decimals=d,this.name=(a?"":"u")+"fixed"+String(f)+"x"+String(d),this._multiplier=xL(d),Object.freeze(this)}static from(e){if(e instanceof f8)return e;typeof e=="number"&&(e=`fixed128x${e}`);let a=!0,f=128,d=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")a=!1;else{let b=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);b||Xf.throwArgumentError("invalid fixed format","format",e),a=b[1]!=="u",f=parseInt(b[2]),d=parseInt(b[3])}}else if(e){let b=(t,r,o)=>e[t]==null?o:(typeof e[t]!==r&&Xf.throwArgumentError("invalid fixed format ("+t+" not "+r+")","format."+t,e[t]),e[t]);a=b("signed","boolean",a),f=b("width","number",f),d=b("decimals","number",d)}return f%8&&Xf.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",f),d>80&&Xf.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",d),new f8(wo,a,f,d)}},$a=class{constructor(e,a,f,d){e!==wo&&Xf.throwError("cannot use FixedNumber constructor; use FixedNumber.from",X.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=d,this._hex=a,this._value=f,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Xf.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);let a=J2(this._value,this.format.decimals),f=J2(e._value,e.format.decimals);return $a.fromValue(a.add(f),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);let a=J2(this._value,this.format.decimals),f=J2(e._value,e.format.decimals);return $a.fromValue(a.sub(f),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);let a=J2(this._value,this.format.decimals),f=J2(e._value,e.format.decimals);return $a.fromValue(a.mul(f).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);let a=J2(this._value,this.format.decimals),f=J2(e._value,e.format.decimals);return $a.fromValue(a.mul(this.format._multiplier).div(f),this.format.decimals,this.format)}floor(){let e=this.toString().split(".");e.length===1&&e.push("0");let a=$a.from(e[0],this.format),f=!e[1].match(/^(0*)$/);return this.isNegative()&&f&&(a=a.subUnsafe(AY.toFormat(a.format))),a}ceiling(){let e=this.toString().split(".");e.length===1&&e.push("0");let a=$a.from(e[0],this.format),f=!e[1].match(/^(0*)$/);return!this.isNegative()&&f&&(a=a.addUnsafe(AY.toFormat(a.format))),a}round(e){e==null&&(e=0);let a=this.toString().split(".");if(a.length===1&&a.push("0"),(e<0||e>80||e%1)&&Xf.throwArgumentError("invalid decimal count","decimals",e),a[1].length<=e)return this;let f=$a.from("1"+_o.substring(0,e),this.format),d=Mpe.toFormat(this.format);return this.mulUnsafe(f).addUnsafe(d).floor().divUnsafe(f)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(e){if(e==null)return this._hex;e%8&&Xf.throwArgumentError("invalid byte width","width",e);let a=Ee.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return q0(a,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return $a.fromString(this._value,e)}static fromValue(e,a,f){return f==null&&a!=null&&!EY(a)&&(f=a,a=null),a==null&&(a=0),f==null&&(f="fixed"),$a.fromString(st(e,a),f8.from(f))}static fromString(e,a){a==null&&(a="fixed");let f=f8.from(a),d=J2(e,f.decimals);!f.signed&&d.lt(SY)&&LY("unsigned value cannot be negative","overflow","value",e);let b=null;f.signed?b=d.toTwos(f.width).toHexString():(b=d.toHexString(),b=q0(b,f.width/8));let t=st(d,f.decimals);return new $a(wo,b,t,f)}static fromBytes(e,a){a==null&&(a="fixed");let f=f8.from(a);if(Se(e).length>f.width/8)throw new Error("overflow");let d=Ee.from(e);f.signed&&(d=d.fromTwos(f.width));let b=d.toTwos((f.signed?0:1)+f.width).toHexString(),t=st(d,f.decimals);return new $a(wo,b,t,f)}static from(e,a){if(typeof e=="string")return $a.fromString(e,a);if(Q2(e))return $a.fromBytes(e,a);try{return $a.fromValue(e,0,a)}catch(f){if(f.code!==X.errors.INVALID_ARGUMENT)throw f}return Xf.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}},AY=$a.from(1),Mpe=$a.from("0.5");s();x();s();x();var FY="properties/5.7.0";var Dpe=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Yp=new X(FY);function he(c,e,a){Object.defineProperty(c,e,{enumerable:!0,value:a,writable:!1})}function Ka(c,e){for(let a=0;a<32;a++){if(c[e])return c[e];if(!c.prototype||typeof c.prototype!="object")break;c=Object.getPrototypeOf(c.prototype).constructor}return null}function wa(c){return Dpe(this,void 0,void 0,function*(){let e=Object.keys(c).map(f=>{let d=c[f];return Promise.resolve(d).then(b=>({key:f,value:b}))});return(yield Promise.all(e)).reduce((f,d)=>(f[d.key]=d.value,f),{})})}function xt(c,e){(!c||typeof c!="object")&&Yp.throwArgumentError("invalid object","object",c),Object.keys(c).forEach(a=>{e[a]||Yp.throwArgumentError("invalid object key - "+a,"transaction:"+a,c)})}function ea(c){let e={};for(let a in c)e[a]=c[a];return e}var kpe={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function CY(c){if(c==null||kpe[typeof c])return!0;if(Array.isArray(c)||typeof c=="object"){if(!Object.isFrozen(c))return!1;let e=Object.keys(c);for(let a=0;a<e.length;a++){let f=null;try{f=c[e[a]]}catch{continue}if(!CY(f))return!1}return!0}return Yp.throwArgumentError(`Cannot deepCopy ${typeof c}`,"object",c)}function Upe(c){if(CY(c))return c;if(Array.isArray(c))return Object.freeze(c.map(e=>Va(e)));if(typeof c=="object"){let e={};for(let a in c){let f=c[a];f!==void 0&&he(e,a,Va(f))}return e}return Yp.throwArgumentError(`Cannot deepCopy ${typeof c}`,"object",c)}function Va(c){return Upe(c)}var t2=class{constructor(e){for(let a in e)this[a]=Va(e[a])}};s();x();var qb="abi/5.7.0";var W0=new X(qb),H4={},RY={calldata:!0,memory:!0,storage:!0},qpe={calldata:!0,memory:!0};function Xp(c,e){if(c==="bytes"||c==="string"){if(RY[e])return!0}else if(c==="address"){if(e==="payable")return!0}else if((c.indexOf("[")>=0||c==="tuple")&&qpe[e])return!0;return(RY[e]||e==="payable")&&W0.throwArgumentError("invalid modifier","name",e),!1}function Gpe(c,e){let a=c;function f(r){W0.throwArgumentError(`unexpected character at position ${r}`,"param",c)}c=c.replace(/\s/g," ");function d(r){let o={type:"",name:"",parent:r,state:{allowType:!0}};return e&&(o.indexed=!1),o}let b={type:"",name:"",state:{allowType:!0}},t=b;for(let r=0;r<c.length;r++){let o=c[r];switch(o){case"(":t.state.allowType&&t.type===""?t.type="tuple":t.state.allowParams||f(r),t.state.allowType=!1,t.type=lt(t.type),t.components=[d(t)],t=t.components[0];break;case")":delete t.state,t.name==="indexed"&&(e||f(r),t.indexed=!0,t.name=""),Xp(t.type,t.name)&&(t.name=""),t.type=lt(t.type);let n=t;t=t.parent,t||f(r),delete n.parent,t.state.allowParams=!1,t.state.allowName=!0,t.state.allowArray=!0;break;case",":delete t.state,t.name==="indexed"&&(e||f(r),t.indexed=!0,t.name=""),Xp(t.type,t.name)&&(t.name=""),t.type=lt(t.type);let i=d(t.parent);t.parent.components.push(i),delete t.parent,t=i;break;case" ":t.state.allowType&&t.type!==""&&(t.type=lt(t.type),delete t.state.allowType,t.state.allowName=!0,t.state.allowParams=!0),t.state.allowName&&t.name!==""&&(t.name==="indexed"?(e||f(r),t.indexed&&f(r),t.indexed=!0,t.name=""):Xp(t.type,t.name)?t.name="":t.state.allowName=!1);break;case"[":t.state.allowArray||f(r),t.type+=o,t.state.allowArray=!1,t.state.allowName=!1,t.state.readArray=!0;break;case"]":t.state.readArray||f(r),t.type+=o,t.state.readArray=!1,t.state.allowArray=!0,t.state.allowName=!0;break;default:t.state.allowType?(t.type+=o,t.state.allowParams=!0,t.state.allowArray=!0):t.state.allowName?(t.name+=o,delete t.state.allowArray):t.state.readArray?t.type+=o:f(r)}}return t.parent&&W0.throwArgumentError("unexpected eof","param",c),delete b.state,t.name==="indexed"?(e||f(a.length-7),t.indexed&&f(a.length-7),t.indexed=!0,t.name=""):Xp(t.type,t.name)&&(t.name=""),b.type=lt(b.type),b}function em(c,e){for(let a in e)he(c,a,e[a])}var Q0=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),zpe=new RegExp(/^(.*)\[([0-9]*)\]$/),Na=class{constructor(e,a){e!==H4&&W0.throwError("use fromString",X.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),em(this,a);let f=this.type.match(zpe);f?em(this,{arrayLength:parseInt(f[2]||"-1"),arrayChildren:Na.fromObject({type:f[1],components:this.components}),baseType:"array"}):em(this,{arrayLength:null,arrayChildren:null,baseType:this.components!=null?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=Q0.sighash),Q0[e]||W0.throwArgumentError("invalid format type","format",e),e===Q0.json){let f={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(f.indexed=this.indexed),this.components&&(f.components=this.components.map(d=>JSON.parse(d.format(e)))),JSON.stringify(f)}let a="";return this.baseType==="array"?(a+=this.arrayChildren.format(e),a+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):this.baseType==="tuple"?(e!==Q0.sighash&&(a+=this.type),a+="("+this.components.map(f=>f.format(e)).join(e===Q0.full?", ":",")+")"):a+=this.type,e!==Q0.sighash&&(this.indexed===!0&&(a+=" indexed"),e===Q0.full&&this.name&&(a+=" "+this.name)),a}static from(e,a){return typeof e=="string"?Na.fromString(e,a):Na.fromObject(e)}static fromObject(e){return Na.isParamType(e)?e:new Na(H4,{name:e.name||null,type:lt(e.type),indexed:e.indexed==null?null:!!e.indexed,components:e.components?e.components.map(Na.fromObject):null})}static fromString(e,a){function f(d){return Na.fromObject({name:d.name,type:d.type,indexed:d.indexed,components:d.components})}return f(Gpe(e,!!a))}static isParamType(e){return!!(e!=null&&e._isParamType)}};function vo(c,e){return Hpe(c).map(a=>Na.fromString(a,e))}var ad=class{constructor(e,a){e!==H4&&W0.throwError("use a static from method",X.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),em(this,a),this._isFragment=!0,Object.freeze(this)}static from(e){return ad.isFragment(e)?e:typeof e=="string"?ad.fromString(e):ad.fromObject(e)}static fromObject(e){if(ad.isFragment(e))return e;switch(e.type){case"function":return Bf.fromObject(e);case"event":return ed.fromObject(e);case"constructor":return Rf.fromObject(e);case"error":return r2.fromObject(e);case"fallback":case"receive":return null}return W0.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return e=e.replace(/\s/g," "),e=e.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," "),e=e.trim(),e.split(" ")[0]==="event"?ed.fromString(e.substring(5).trim()):e.split(" ")[0]==="function"?Bf.fromString(e.substring(8).trim()):e.split("(")[0].trim()==="constructor"?Rf.fromString(e.trim()):e.split(" ")[0]==="error"?r2.fromString(e.substring(5).trim()):W0.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!!(e&&e._isFragment)}},ed=class extends ad{format(e){if(e||(e=Q0.sighash),Q0[e]||W0.throwArgumentError("invalid format type","format",e),e===Q0.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(f=>JSON.parse(f.format(e)))});let a="";return e!==Q0.sighash&&(a+="event "),a+=this.name+"("+this.inputs.map(f=>f.format(e)).join(e===Q0.full?", ":",")+") ",e!==Q0.sighash&&this.anonymous&&(a+="anonymous "),a.trim()}static from(e){return typeof e=="string"?ed.fromString(e):ed.fromObject(e)}static fromObject(e){if(ed.isEventFragment(e))return e;e.type!=="event"&&W0.throwArgumentError("invalid event object","value",e);let a={name:Eo(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(Na.fromObject):[],type:"event"};return new ed(H4,a)}static fromString(e){let a=e.match(Ao);a||W0.throwArgumentError("invalid event string","value",e);let f=!1;return a[3].split(" ").forEach(d=>{switch(d.trim()){case"anonymous":f=!0;break;case"":break;default:W0.warn("unknown modifier: "+d)}}),ed.fromObject({name:a[1].trim(),anonymous:f,inputs:vo(a[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&e.type==="event"}};function PY(c,e){e.gas=null;let a=c.split("@");return a.length!==1?(a.length>2&&W0.throwArgumentError("invalid human-readable ABI signature","value",c),a[1].match(/^[0-9]+$/)||W0.throwArgumentError("invalid human-readable ABI signature gas","value",c),e.gas=Ee.from(a[1]),a[0]):c}function TY(c,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",c.split(" ").forEach(a=>{switch(a.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"nonpayable":e.payable=!1,e.stateMutability="nonpayable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+a)}})}function OY(c){let e={constant:!1,payable:!0,stateMutability:"payable"};return c.stateMutability!=null?(e.stateMutability=c.stateMutability,e.constant=e.stateMutability==="view"||e.stateMutability==="pure",c.constant!=null&&!!c.constant!==e.constant&&W0.throwArgumentError("cannot have constant function with mutability "+e.stateMutability,"value",c),e.payable=e.stateMutability==="payable",c.payable!=null&&!!c.payable!==e.payable&&W0.throwArgumentError("cannot have payable function with mutability "+e.stateMutability,"value",c)):c.payable!=null?(e.payable=!!c.payable,c.constant==null&&!e.payable&&c.type!=="constructor"&&W0.throwArgumentError("unable to determine stateMutability","value",c),e.constant=!!c.constant,e.constant?e.stateMutability="view":e.stateMutability=e.payable?"payable":"nonpayable",e.payable&&e.constant&&W0.throwArgumentError("cannot have constant payable function","value",c)):c.constant!=null?(e.constant=!!c.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable"):c.type!=="constructor"&&W0.throwArgumentError("unable to determine stateMutability","value",c),e}var Rf=class extends ad{format(e){if(e||(e=Q0.sighash),Q0[e]||W0.throwArgumentError("invalid format type","format",e),e===Q0.json)return JSON.stringify({type:"constructor",stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(f=>JSON.parse(f.format(e)))});e===Q0.sighash&&W0.throwError("cannot format a constructor for sighash",X.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let a="constructor("+this.inputs.map(f=>f.format(e)).join(e===Q0.full?", ":",")+") ";return this.stateMutability&&this.stateMutability!=="nonpayable"&&(a+=this.stateMutability+" "),a.trim()}static from(e){return typeof e=="string"?Rf.fromString(e):Rf.fromObject(e)}static fromObject(e){if(Rf.isConstructorFragment(e))return e;e.type!=="constructor"&&W0.throwArgumentError("invalid constructor object","value",e);let a=OY(e);a.constant&&W0.throwArgumentError("constructor cannot be constant","value",e);let f={name:null,type:e.type,inputs:e.inputs?e.inputs.map(Na.fromObject):[],payable:a.payable,stateMutability:a.stateMutability,gas:e.gas?Ee.from(e.gas):null};return new Rf(H4,f)}static fromString(e){let a={type:"constructor"};e=PY(e,a);let f=e.match(Ao);return(!f||f[1].trim()!=="constructor")&&W0.throwArgumentError("invalid constructor string","value",e),a.inputs=vo(f[2].trim(),!1),TY(f[3].trim(),a),Rf.fromObject(a)}static isConstructorFragment(e){return e&&e._isFragment&&e.type==="constructor"}},Bf=class extends Rf{format(e){if(e||(e=Q0.sighash),Q0[e]||W0.throwArgumentError("invalid format type","format",e),e===Q0.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?this.gas.toNumber():void 0,inputs:this.inputs.map(f=>JSON.parse(f.format(e))),outputs:this.outputs.map(f=>JSON.parse(f.format(e)))});let a="";return e!==Q0.sighash&&(a+="function "),a+=this.name+"("+this.inputs.map(f=>f.format(e)).join(e===Q0.full?", ":",")+") ",e!==Q0.sighash&&(this.stateMutability?this.stateMutability!=="nonpayable"&&(a+=this.stateMutability+" "):this.constant&&(a+="view "),this.outputs&&this.outputs.length&&(a+="returns ("+this.outputs.map(f=>f.format(e)).join(", ")+") "),this.gas!=null&&(a+="@"+this.gas.toString()+" ")),a.trim()}static from(e){return typeof e=="string"?Bf.fromString(e):Bf.fromObject(e)}static fromObject(e){if(Bf.isFunctionFragment(e))return e;e.type!=="function"&&W0.throwArgumentError("invalid function object","value",e);let a=OY(e),f={type:e.type,name:Eo(e.name),constant:a.constant,inputs:e.inputs?e.inputs.map(Na.fromObject):[],outputs:e.outputs?e.outputs.map(Na.fromObject):[],payable:a.payable,stateMutability:a.stateMutability,gas:e.gas?Ee.from(e.gas):null};return new Bf(H4,f)}static fromString(e){let a={type:"function"};e=PY(e,a);let f=e.split(" returns ");f.length>2&&W0.throwArgumentError("invalid function string","value",e);let d=f[0].match(Ao);if(d||W0.throwArgumentError("invalid function signature","value",e),a.name=d[1].trim(),a.name&&Eo(a.name),a.inputs=vo(d[2],!1),TY(d[3].trim(),a),f.length>1){let b=f[1].match(Ao);(b[1].trim()!=""||b[3].trim()!="")&&W0.throwArgumentError("unexpected tokens","value",e),a.outputs=vo(b[2],!1)}else a.outputs=[];return Bf.fromObject(a)}static isFunctionFragment(e){return e&&e._isFragment&&e.type==="function"}};function BY(c){let e=c.format();return(e==="Error(string)"||e==="Panic(uint256)")&&W0.throwArgumentError(`cannot specify user defined ${e} error`,"fragment",c),c}var r2=class extends ad{format(e){if(e||(e=Q0.sighash),Q0[e]||W0.throwArgumentError("invalid format type","format",e),e===Q0.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(f=>JSON.parse(f.format(e)))});let a="";return e!==Q0.sighash&&(a+="error "),a+=this.name+"("+this.inputs.map(f=>f.format(e)).join(e===Q0.full?", ":",")+") ",a.trim()}static from(e){return typeof e=="string"?r2.fromString(e):r2.fromObject(e)}static fromObject(e){if(r2.isErrorFragment(e))return e;e.type!=="error"&&W0.throwArgumentError("invalid error object","value",e);let a={type:e.type,name:Eo(e.name),inputs:e.inputs?e.inputs.map(Na.fromObject):[]};return BY(new r2(H4,a))}static fromString(e){let a={type:"error"},f=e.match(Ao);return f||W0.throwArgumentError("invalid error signature","value",e),a.name=f[1].trim(),a.name&&Eo(a.name),a.inputs=vo(f[2],!1),BY(r2.fromObject(a))}static isErrorFragment(e){return e&&e._isFragment&&e.type==="error"}};function lt(c){return c.match(/^uint($|[^1-9])/)?c="uint256"+c.substring(4):c.match(/^int($|[^1-9])/)&&(c="int256"+c.substring(3)),c}var jpe=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Eo(c){return(!c||!c.match(jpe))&&W0.throwArgumentError(`invalid identifier "${c}"`,"value",c),c}var Ao=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");function Hpe(c){c=c.trim();let e=[],a="",f=0;for(let d=0;d<c.length;d++){let b=c[d];b===","&&f===0?(e.push(a),a=""):(a+=b,b==="("?f++:b===")"&&(f--,f===-1&&W0.throwArgumentError("unbalanced parenthesis","value",c)))}return a&&e.push(a),e}s();x();s();x();var lL=new X(qb);function ut(c){let e=[],a=function(f,d){if(!!Array.isArray(d))for(let b in d){let t=f.slice();t.push(b);try{a(t,d[b])}catch(r){e.push({path:t,error:r})}}};return a([],c),e}var Ac=class{constructor(e,a,f,d){this.name=e,this.type=a,this.localName=f,this.dynamic=d}_throwError(e,a){lL.throwArgumentError(e,this.localName,a)}},$4=class{constructor(e){he(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return Ec(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData(O0(e._data))}writeBytes(e){let a=Se(e),f=a.length%this.wordSize;return f&&(a=O0([a,this._padding.slice(f)])),this._writeData(a)}_getValue(e){let a=Se(Ee.from(e));return a.length>this.wordSize&&lL.throwError("value out-of-bounds",X.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:a.length}),a.length%this.wordSize&&(a=O0([this._padding.slice(a.length%this.wordSize),a])),a}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){let e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,a=>{this._data[e]=this._getValue(a)}}},V4=class{constructor(e,a,f,d){he(this,"_data",Se(e)),he(this,"wordSize",a||32),he(this,"_coerceFunc",f),he(this,"allowLoose",d),this._offset=0}get data(){return Be(this._data)}get consumed(){return this._offset}static coerce(e,a){let f=e.match("^u?int([0-9]+)$");return f&&parseInt(f[1])<=48&&(a=a.toNumber()),a}coerce(e,a){return this._coerceFunc?this._coerceFunc(e,a):V4.coerce(e,a)}_peekBytes(e,a,f){let d=Math.ceil(a/this.wordSize)*this.wordSize;return this._offset+d>this._data.length&&(this.allowLoose&&f&&this._offset+a<=this._data.length?d=a:lL.throwError("data out-of-bounds",X.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+d})),this._data.slice(this._offset,this._offset+d)}subReader(e){return new V4(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,a){let f=this._peekBytes(0,e,!!a);return this._offset+=f.length,f.slice(0,e)}readValue(){return Ee.from(this.readBytes(this.wordSize))}};s();x();s();x();s();x();var NY=Fe(cm());function N0(c){return"0x"+NY.default.keccak_256(Se(c))}var fm={};v0(fm,{decode:()=>So,encode:()=>d8});s();x();s();x();var MY="rlp/5.7.0";var Gb=new X(MY);function DY(c){let e=[];for(;c;)e.unshift(c&255),c>>=8;return e}function kY(c,e,a){let f=0;for(let d=0;d<a;d++)f=f*256+c[e+d];return f}function qY(c){if(Array.isArray(c)){let f=[];if(c.forEach(function(b){f=f.concat(qY(b))}),f.length<=55)return f.unshift(192+f.length),f;let d=DY(f.length);return d.unshift(247+d.length),d.concat(f)}a8(c)||Gb.throwArgumentError("RLP object must be BytesLike","object",c);let e=Array.prototype.slice.call(Se(c));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;let a=DY(e.length);return a.unshift(183+a.length),a.concat(e)}function d8(c){return Be(qY(c))}function UY(c,e,a,f){let d=[];for(;a<e+1+f;){let b=GY(c,a);d.push(b.result),a+=b.consumed,a>e+1+f&&Gb.throwError("child data too short",X.errors.BUFFER_OVERRUN,{})}return{consumed:1+f,result:d}}function GY(c,e){if(c.length===0&&Gb.throwError("data too short",X.errors.BUFFER_OVERRUN,{}),c[e]>=248){let a=c[e]-247;e+1+a>c.length&&Gb.throwError("data short segment too short",X.errors.BUFFER_OVERRUN,{});let f=kY(c,e+1,a);return e+1+a+f>c.length&&Gb.throwError("data long segment too short",X.errors.BUFFER_OVERRUN,{}),UY(c,e,e+1+a,a+f)}else if(c[e]>=192){let a=c[e]-192;return e+1+a>c.length&&Gb.throwError("data array too short",X.errors.BUFFER_OVERRUN,{}),UY(c,e,e+1,a)}else if(c[e]>=184){let a=c[e]-183;e+1+a>c.length&&Gb.throwError("data array too short",X.errors.BUFFER_OVERRUN,{});let f=kY(c,e+1,a);e+1+a+f>c.length&&Gb.throwError("data array too short",X.errors.BUFFER_OVERRUN,{});let d=Be(c.slice(e+1+a,e+1+a+f));return{consumed:1+a+f,result:d}}else if(c[e]>=128){let a=c[e]-128;e+1+a>c.length&&Gb.throwError("data too short",X.errors.BUFFER_OVERRUN,{});let f=Be(c.slice(e+1,e+1+a));return{consumed:1+a,result:f}}return{consumed:1,result:Be(c[e])}}function So(c){let e=Se(c),a=GY(e,0);return a.consumed!==e.length&&Gb.throwArgumentError("invalid rlp data","data",c),a.result}s();x();var zY="address/5.7.0";var k7=new X(zY);function jY(c){n0(c,20)||k7.throwArgumentError("invalid address","address",c),c=c.toLowerCase();let e=c.substring(2).split(""),a=new Uint8Array(40);for(let d=0;d<40;d++)a[d]=e[d].charCodeAt(0);let f=Se(N0(a));for(let d=0;d<40;d+=2)f[d>>1]>>4>=8&&(e[d]=e[d].toUpperCase()),(f[d>>1]&15)>=8&&(e[d+1]=e[d+1].toUpperCase());return"0x"+e.join("")}var $pe=9007199254740991;function Vpe(c){return Math.log10?Math.log10(c):Math.log(c)/Math.LN10}var uL={};for(let c=0;c<10;c++)uL[String(c)]=String(c);for(let c=0;c<26;c++)uL[String.fromCharCode(65+c)]=String(10+c);var HY=Math.floor(Vpe($pe));function $Y(c){c=c.toUpperCase(),c=c.substring(4)+c.substring(0,2)+"00";let e=c.split("").map(f=>uL[f]).join("");for(;e.length>=HY;){let f=e.substring(0,HY);e=parseInt(f,10)%97+e.substring(f.length)}let a=String(98-parseInt(e,10)%97);for(;a.length<2;)a="0"+a;return a}function M0(c){let e=null;if(typeof c!="string"&&k7.throwArgumentError("invalid address","address",c),c.match(/^(0x)?[0-9a-fA-F]{40}$/))c.substring(0,2)!=="0x"&&(c="0x"+c),e=jY(c),c.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==c&&k7.throwArgumentError("bad address checksum","address",c);else if(c.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(c.substring(2,4)!==$Y(c)&&k7.throwArgumentError("bad icap checksum","address",c),e=oL(c.substring(4));e.length<40;)e="0"+e;e=jY("0x"+e)}else k7.throwArgumentError("invalid address","address",c);return e}function VY(c){try{return M0(c),!0}catch{}return!1}function KY(c){let e=sL(M0(c).substring(2)).toUpperCase();for(;e.length<30;)e="0"+e;return"XE"+$Y("XE00"+e)+e}function K4(c){let e=null;try{e=M0(c.from)}catch{k7.throwArgumentError("missing from address","transaction",c)}let a=b2(Se(Ee.from(c.nonce).toHexString()));return M0(ya(N0(d8([e,a])),12))}function QY(c,e,a){return Cf(e)!==32&&k7.throwArgumentError("salt must be 32 bytes","salt",e),Cf(a)!==32&&k7.throwArgumentError("initCodeHash must be 32 bytes","initCodeHash",a),M0(ya(N0(O0(["0xff",M0(c),e,a])),12))}var dm=class extends Ac{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,a){try{a=M0(a)}catch(f){this._throwError(f.message,a)}return e.writeValue(a)}decode(e){return M0(q0(e.readValue().toHexString(),20))}};s();x();s();x();var bm=class extends Ac{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,a){return this.coder.encode(e,a)}decode(e){return this.coder.decode(e)}};var ht=new X(qb);function hL(c,e,a){let f=null;if(Array.isArray(a))f=a;else if(a&&typeof a=="object"){let o={};f=e.map(n=>{let i=n.localName;return i||ht.throwError("cannot encode object for signature with missing names",X.errors.INVALID_ARGUMENT,{argument:"values",coder:n,value:a}),o[i]&&ht.throwError("cannot encode object for signature with duplicate names",X.errors.INVALID_ARGUMENT,{argument:"values",coder:n,value:a}),o[i]=!0,a[i]})}else ht.throwArgumentError("invalid tuple value","tuple",a);e.length!==f.length&&ht.throwArgumentError("types/value length mismatch","tuple",a);let d=new $4(c.wordSize),b=new $4(c.wordSize),t=[];e.forEach((o,n)=>{let i=f[n];if(o.dynamic){let l=b.length;o.encode(b,i);let h=d.writeUpdatableValue();t.push(u=>{h(u+l)})}else o.encode(d,i)}),t.forEach(o=>{o(d.length)});let r=c.appendWriter(d);return r+=c.appendWriter(b),r}function pL(c,e){let a=[],f=c.subReader(0);e.forEach(b=>{let t=null;if(b.dynamic){let r=c.readValue(),o=f.subReader(r.toNumber());try{t=b.decode(o)}catch(n){if(n.code===X.errors.BUFFER_OVERRUN)throw n;t=n,t.baseType=b.name,t.name=b.localName,t.type=b.type}}else try{t=b.decode(c)}catch(r){if(r.code===X.errors.BUFFER_OVERRUN)throw r;t=r,t.baseType=b.name,t.name=b.localName,t.type=b.type}t!=null&&a.push(t)});let d=e.reduce((b,t)=>{let r=t.localName;return r&&(b[r]||(b[r]=0),b[r]++),b},{});e.forEach((b,t)=>{let r=b.localName;if(!r||d[r]!==1||(r==="length"&&(r="_length"),a[r]!=null))return;let o=a[t];o instanceof Error?Object.defineProperty(a,r,{enumerable:!0,get:()=>{throw o}}):a[r]=o});for(let b=0;b<a.length;b++){let t=a[b];t instanceof Error&&Object.defineProperty(a,b,{enumerable:!0,get:()=>{throw t}})}return Object.freeze(a)}var tm=class extends Ac{constructor(e,a,f){let d=e.type+"["+(a>=0?a:"")+"]",b=a===-1||e.dynamic;super("array",d,f,b),this.coder=e,this.length=a}defaultValue(){let e=this.coder.defaultValue(),a=[];for(let f=0;f<this.length;f++)a.push(e);return a}encode(e,a){Array.isArray(a)||this._throwError("expected array value",a);let f=this.length;f===-1&&(f=a.length,e.writeValue(a.length)),ht.checkArgumentCount(a.length,f,"coder array"+(this.localName?" "+this.localName:""));let d=[];for(let b=0;b<a.length;b++)d.push(this.coder);return hL(e,d,a)}decode(e){let a=this.length;a===-1&&(a=e.readValue().toNumber(),a*32>e._data.length&&ht.throwError("insufficient data length",X.errors.BUFFER_OVERRUN,{length:e._data.length,count:a}));let f=[];for(let d=0;d<a;d++)f.push(new bm(this.coder));return e.coerce(this.name,pL(e,f))}};s();x();var rm=class extends Ac{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,a){return e.writeValue(a?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}};s();x();var Io=class extends Ac{constructor(e,a){super(e,e,a,!0)}defaultValue(){return"0x"}encode(e,a){a=Se(a);let f=e.writeValue(a.length);return f+=e.writeBytes(a),f}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}},nm=class extends Io{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,Be(super.decode(e)))}};s();x();var im=class extends Ac{constructor(e,a){let f="bytes"+String(e);super(f,f,a,!1),this.size=e}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,a){let f=Se(a);return f.length!==this.size&&this._throwError("incorrect data length",a),e.writeBytes(f)}decode(e){return e.coerce(this.name,Be(e.readBytes(this.size)))}};s();x();var om=class extends Ac{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,a){return a!=null&&this._throwError("not null",a),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}};s();x();var hm={};v0(hm,{AddressZero:()=>sm,EtherSymbol:()=>XY,HashZero:()=>mt,MaxInt256:()=>YY,MaxUint256:()=>um,MinInt256:()=>ZY,NegativeOne:()=>xm,One:()=>lm,Two:()=>WY,WeiPerEther:()=>JY,Zero:()=>pt});s();x();s();x();var sm="0x0000000000000000000000000000000000000000";s();x();var xm=Ee.from(-1),pt=Ee.from(0),lm=Ee.from(1),WY=Ee.from(2),JY=Ee.from("1000000000000000000"),um=Ee.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),ZY=Ee.from("-0x8000000000000000000000000000000000000000000000000000000000000000"),YY=Ee.from("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");s();x();var mt="0x0000000000000000000000000000000000000000000000000000000000000000";s();x();var XY="\u039E";var pm=class extends Ac{constructor(e,a,f){let d=(a?"int":"uint")+e*8;super(d,d,f,!1),this.size=e,this.signed=a}defaultValue(){return 0}encode(e,a){let f=Ee.from(a),d=um.mask(e.wordSize*8);if(this.signed){let b=d.mask(this.size*8-1);(f.gt(b)||f.lt(b.add(lm).mul(xm)))&&this._throwError("value out-of-bounds",a)}else(f.lt(pt)||f.gt(d.mask(this.size*8)))&&this._throwError("value out-of-bounds",a);return f=f.toTwos(this.size*8).mask(this.size*8),this.signed&&(f=f.fromTwos(this.size*8).toTwos(8*e.wordSize)),e.writeValue(f)}decode(e){let a=e.readValue().mask(this.size*8);return this.signed&&(a=a.fromTwos(this.size*8)),e.coerce(this.name,a)}};s();x();s();x();s();x();s();x();s();x();var eX="strings/5.7.0";var aX=new X(eX),cd;(function(c){c.current="",c.NFC="NFC",c.NFD="NFD",c.NFKC="NFKC",c.NFKD="NFKD"})(cd||(cd={}));var Pf;(function(c){c.UNEXPECTED_CONTINUE="unexpected continuation byte",c.BAD_PREFIX="bad codepoint prefix",c.OVERRUN="string overrun",c.MISSING_CONTINUE="missing continuation byte",c.OUT_OF_RANGE="out of UTF-8 range",c.UTF16_SURROGATE="UTF-16 surrogate",c.OVERLONG="overlong representation"})(Pf||(Pf={}));function Kpe(c,e,a,f,d){return aX.throwArgumentError(`invalid codepoint at offset ${e}; ${c}`,"bytes",a)}function cX(c,e,a,f,d){if(c===Pf.BAD_PREFIX||c===Pf.UNEXPECTED_CONTINUE){let b=0;for(let t=e+1;t<a.length&&a[t]>>6===2;t++)b++;return b}return c===Pf.OVERRUN?a.length-e-1:0}function Qpe(c,e,a,f,d){return c===Pf.OVERLONG?(f.push(d),0):(f.push(65533),cX(c,e,a,f,d))}var mm=Object.freeze({error:Kpe,ignore:cX,replace:Qpe});function gL(c,e){e==null&&(e=mm.error),c=Se(c);let a=[],f=0;for(;f<c.length;){let d=c[f++];if(d>>7===0){a.push(d);continue}let b=null,t=null;if((d&224)===192)b=1,t=127;else if((d&240)===224)b=2,t=2047;else if((d&248)===240)b=3,t=65535;else{(d&192)===128?f+=e(Pf.UNEXPECTED_CONTINUE,f-1,c,a):f+=e(Pf.BAD_PREFIX,f-1,c,a);continue}if(f-1+b>=c.length){f+=e(Pf.OVERRUN,f-1,c,a);continue}let r=d&(1<<8-b-1)-1;for(let o=0;o<b;o++){let n=c[f];if((n&192)!=128){f+=e(Pf.MISSING_CONTINUE,f,c,a),r=null;break}r=r<<6|n&63,f++}if(r!==null){if(r>1114111){f+=e(Pf.OUT_OF_RANGE,f-1-b,c,a,r);continue}if(r>=55296&&r<=57343){f+=e(Pf.UTF16_SURROGATE,f-1-b,c,a,r);continue}if(r<=t){f+=e(Pf.OVERLONG,f-1-b,c,a,r);continue}a.push(r)}}return a}function J0(c,e=cd.current){e!=cd.current&&(aX.checkNormalize(),c=c.normalize(e));let a=[];for(let f=0;f<c.length;f++){let d=c.charCodeAt(f);if(d<128)a.push(d);else if(d<2048)a.push(d>>6|192),a.push(d&63|128);else if((d&64512)==55296){f++;let b=c.charCodeAt(f);if(f>=c.length||(b&64512)!==56320)throw new Error("invalid utf-8 string");let t=65536+((d&1023)<<10)+(b&1023);a.push(t>>18|240),a.push(t>>12&63|128),a.push(t>>6&63|128),a.push(t&63|128)}else a.push(d>>12|224),a.push(d>>6&63|128),a.push(d&63|128)}return Se(a)}function mL(c){let e="0000"+c.toString(16);return"\\u"+e.substring(e.length-4)}function yL(c,e){return'"'+gL(c,e).map(a=>{if(a<256){switch(a){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(a>=32&&a<127)return String.fromCharCode(a)}return a<=65535?mL(a):(a-=65536,mL((a>>10&1023)+55296)+mL((a&1023)+56320))}).join("")+'"'}function gm(c){return c.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Ld(c,e){return gm(gL(c,e))}function U7(c,e=cd.current){return gL(J0(c,e))}function wL(c){let e=J0(c);if(e.length>31)throw new Error("bytes32 string must be less than 32 bytes");return Be(O0([e,mt]).slice(0,32))}function _L(c){let e=Se(c);if(e.length!==32)throw new Error("invalid bytes32 - not 32 bytes long");if(e[31]!==0)throw new Error("invalid bytes32 string - no null terminator");let a=31;for(;e[a-1]===0;)a--;return Ld(e.slice(0,a))}s();x();function Wpe(c){if(c.length%4!==0)throw new Error("bad data");let e=[];for(let a=0;a<c.length;a+=4)e.push(parseInt(c.substring(a,a+4),16));return e}function vL(c,e){e||(e=function(d){return[parseInt(d,16)]});let a=0,f={};return c.split(",").forEach(d=>{let b=d.split(":");a+=parseInt(b[0],16),f[a]=e(b[1])}),f}function fX(c){let e=0;return c.split(",").map(a=>{let f=a.split("-");f.length===1?f[1]="0":f[1]===""&&(f[1]="1");let d=e+parseInt(f[0],16);return e=parseInt(f[1],16),{l:d,h:e}})}function EL(c,e){let a=0;for(let f=0;f<e.length;f++){let d=e[f];if(a+=d.l,c>=a&&c<=a+d.h&&(c-a)%(d.d||1)===0){if(d.e&&d.e.indexOf(c-a)!==-1)continue;return d}}return null}var Jpe=fX("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Zpe="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(c=>parseInt(c,16)),Ype=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Xpe=vL("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),eme=vL("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),ame=vL("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",Wpe),cme=fX("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function fme(c){return c.reduce((e,a)=>(a.forEach(f=>{e.push(f)}),e),[])}function dme(c){return!!EL(c,Jpe)}function bme(c){let e=EL(c,Ype);if(e)return[c+e.s];let a=Xpe[c];if(a)return a;let f=eme[c];if(f)return[c+f[0]];let d=ame[c];return d||null}function tme(c){return!!EL(c,cme)}function AL(c){if(c.match(/^[a-z0-9-]*$/i)&&c.length<=59)return c.toLowerCase();let e=U7(c);e=fme(e.map(f=>{if(Zpe.indexOf(f)>=0)return[];if(f>=65024&&f<=65039)return[];let d=bme(f);return d||[f]})),e=U7(gm(e),cd.NFKC),e.forEach(f=>{if(tme(f))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(f=>{if(dme(f))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let a=gm(e);if(a.substring(0,1)==="-"||a.substring(2,4)==="--"||a.substring(a.length-1)==="-")throw new Error("invalid hyphen");return a}var ym=class extends Io{constructor(e){super("string",e)}defaultValue(){return""}encode(e,a){return super.encode(e,J0(a))}decode(e){return Ld(super.decode(e))}};s();x();var Q4=class extends Ac{constructor(e,a){let f=!1,d=[];e.forEach(t=>{t.dynamic&&(f=!0),d.push(t.type)});let b="tuple("+d.join(",")+")";super("tuple",b,a,f),this.coders=e}defaultValue(){let e=[];this.coders.forEach(f=>{e.push(f.defaultValue())});let a=this.coders.reduce((f,d)=>{let b=d.localName;return b&&(f[b]||(f[b]=0),f[b]++),f},{});return this.coders.forEach((f,d)=>{let b=f.localName;!b||a[b]!==1||(b==="length"&&(b="_length"),e[b]==null&&(e[b]=e[d]))}),Object.freeze(e)}encode(e,a){return hL(e,this.coders,a)}decode(e){return e.coerce(this.name,pL(e,this.coders))}};var wm=new X(qb),rme=new RegExp(/^bytes([0-9]*)$/),nme=new RegExp(/^(u?int)([0-9]*)$/),gt=class{constructor(e){he(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new dm(e.name);case"bool":return new rm(e.name);case"string":return new ym(e.name);case"bytes":return new nm(e.name);case"array":return new tm(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new Q4((e.components||[]).map(f=>this._getCoder(f)),e.name);case"":return new om(e.name)}let a=e.type.match(nme);if(a){let f=parseInt(a[2]||"256");return(f===0||f>256||f%8!==0)&&wm.throwArgumentError("invalid "+a[1]+" bit length","param",e),new pm(f/8,a[1]==="int",e.name)}if(a=e.type.match(rme),a){let f=parseInt(a[1]);return(f===0||f>32)&&wm.throwArgumentError("invalid bytes length","param",e),new im(f,e.name)}return wm.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,a){return new V4(e,this._getWordSize(),this.coerceFunc,a)}_getWriter(){return new $4(this._getWordSize())}getDefaultValue(e){let a=e.map(d=>this._getCoder(Na.from(d)));return new Q4(a,"_").defaultValue()}encode(e,a){e.length!==a.length&&wm.throwError("types/values length mismatch",X.errors.INVALID_ARGUMENT,{count:{types:e.length,values:a.length},value:{types:e,values:a}});let f=e.map(t=>this._getCoder(Na.from(t))),d=new Q4(f,"_"),b=this._getWriter();return d.encode(b,a),b.data}decode(e,a,f){let d=e.map(t=>this._getCoder(Na.from(t)));return new Q4(d,"_").decode(this._getReader(Se(a),f))}},Lo=new gt;s();x();s();x();s();x();function n2(c){return N0(J0(c))}s();x();s();x();var _m="hash/5.7.0";s();x();s();x();var SL={};v0(SL,{decode:()=>yt,encode:()=>wt});s();x();s();x();function yt(c){c=atob(c);let e=[];for(let a=0;a<c.length;a++)e.push(c.charCodeAt(a));return Se(e)}function wt(c){c=Se(c);let e="";for(let a=0;a<c.length;a++)e+=String.fromCharCode(c[a]);return btoa(e)}s();x();function bX(c,e){e==null&&(e=1);let a=[],f=a.forEach,d=function(b,t){f.call(b,function(r){t>0&&Array.isArray(r)?d(r,t-1):a.push(r)})};return d(c,e),a}function ime(c){let e={};for(let a=0;a<c.length;a++){let f=c[a];e[f[0]]=f[1]}return e}function ome(c){let e=0;function a(){return c[e++]<<8|c[e++]}let f=a(),d=1,b=[0,1];for(let H=1;H<f;H++)b.push(d+=a());let t=a(),r=e;e+=t;let o=0,n=0;function i(){return o==0&&(n=n<<8|c[e++],o=8),n>>--o&1}let l=31,h=Math.pow(2,l),u=h>>>1,g=u>>1,E=h-1,_=0;for(let H=0;H<l;H++)_=_<<1|i();let F=[],L=0,U=h;for(;;){let H=Math.floor(((_-L+1)*d-1)/U),P=0,A=f;for(;A-P>1;){let j=P+A>>>1;H<b[j]?A=j:P=j}if(P==0)break;F.push(P);let I=L+Math.floor(U*b[P]/d),K=L+Math.floor(U*b[P+1]/d)-1;for(;((I^K)&u)==0;)_=_<<1&E|i(),I=I<<1&E,K=K<<1&E|1;for(;I&~K&g;)_=_&u|_<<1&E>>>1|i(),I=I<<1^u,K=(K^u)<<1|u|1;L=I,U=1+K-I}let O=f-4;return F.map(H=>{switch(H-O){case 3:return O+65792+(c[r++]<<16|c[r++]<<8|c[r++]);case 2:return O+256+(c[r++]<<8|c[r++]);case 1:return O+c[r++];default:return H-1}})}function sme(c){let e=0;return()=>c[e++]}function tX(c){return sme(ome(c))}function xme(c){return c&1?~c>>1:c>>1}function lme(c,e){let a=Array(c);for(let f=0;f<c;f++)a[f]=1+e();return a}function dX(c,e){let a=Array(c);for(let f=0,d=-1;f<c;f++)a[f]=d+=1+e();return a}function ume(c,e){let a=Array(c);for(let f=0,d=0;f<c;f++)a[f]=d+=xme(e());return a}function Fo(c,e){let a=dX(c(),c),f=c(),d=dX(f,c),b=lme(f,c);for(let t=0;t<f;t++)for(let r=0;r<b[t];r++)a.push(d[t]+r);return e?a.map(t=>e[t]):a}function rX(c){let e=[];for(;;){let a=c();if(a==0)break;e.push(pme(a,c))}for(;;){let a=c()-1;if(a<0)break;e.push(mme(a,c))}return ime(bX(e))}function hme(c){let e=[];for(;;){let a=c();if(a==0)break;e.push(a)}return e}function nX(c,e,a){let f=Array(c).fill(void 0).map(()=>[]);for(let d=0;d<e;d++)ume(c,a).forEach((b,t)=>f[t].push(b));return f}function pme(c,e){let a=1+e(),f=e(),d=hme(e),b=nX(d.length,1+c,e);return bX(b.map((t,r)=>{let o=t[0],n=t.slice(1);return Array(d[r]).fill(void 0).map((i,l)=>{let h=l*f;return[o+l*a,n.map(u=>u+h)]})}))}function mme(c,e){let a=1+e();return nX(a,1+c,e).map(d=>[d[0],d.slice(1)])}function iX(c){let e=Fo(c).sort((f,d)=>f-d);return a();function a(){let f=[];for(;;){let n=Fo(c,e);if(n.length==0)break;f.push({set:new Set(n),node:a()})}f.sort((n,i)=>i.set.size-n.set.size);let d=c(),b=d%3;d=d/3|0;let t=!!(d&1);d>>=1;let r=d==1,o=d==2;return{branches:f,valid:b,fe0f:t,save:r,check:o}}}function oX(){return tX(yt("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}var vm=oX(),gme=new Set(Fo(vm)),yme=new Set(Fo(vm)),wme=rX(vm),_me=iX(vm),sX=45,xX=95;function lX(c){return U7(c)}function vme(c){return c.filter(e=>e!=65039)}function uX(c){for(let e of c.split(".")){let a=lX(e);try{for(let f=a.lastIndexOf(xX)-1;f>=0;f--)if(a[f]!==xX)throw new Error("underscore only allowed at start");if(a.length>=4&&a.every(f=>f<128)&&a[2]===sX&&a[3]===sX)throw new Error("invalid label extension")}catch(f){throw new Error(`Invalid label "${e}": ${f.message}`)}}return c}function hX(c){return uX(Eme(c,vme))}function Eme(c,e){let a=lX(c).reverse(),f=[];for(;a.length;){let d=Sme(a);if(d){f.push(...e(d));continue}let b=a.pop();if(gme.has(b)){f.push(b);continue}if(yme.has(b))continue;let t=wme[b];if(t){f.push(...t);continue}throw new Error(`Disallowed codepoint: 0x${b.toString(16).toUpperCase()}`)}return uX(Ame(String.fromCodePoint(...f)))}function Ame(c){return c.normalize("NFC")}function Sme(c,e){var a;let f=_me,d,b,t=[],r=c.length;for(e&&(e.length=0);r;){let o=c[--r];if(f=(a=f.branches.find(n=>n.set.has(o)))===null||a===void 0?void 0:a.node,!f)break;if(f.save)b=o;else if(f.check&&o===b)break;t.push(o),f.fe0f&&(t.push(65039),r>0&&c[r-1]==65039&&r--),f.valid&&(d=t.slice(),f.valid==2&&d.splice(1,1),e&&e.push(...c.slice(r).reverse()),c.length=r)}return d}var Ime=new X(_m),mX=new Uint8Array(32);mX.fill(0);function pX(c){if(c.length===0)throw new Error("invalid ENS name; empty component");return c}function IL(c){let e=J0(hX(c)),a=[];if(c.length===0)return a;let f=0;for(let d=0;d<e.length;d++)e[d]===46&&(a.push(pX(e.slice(f,d))),f=d+1);if(f>=e.length)throw new Error("invalid ENS name; empty component");return a.push(pX(e.slice(f))),a}function LL(c){try{return IL(c).length!==0}catch{}return!1}function q7(c){typeof c!="string"&&Ime.throwArgumentError("invalid ENS name; not a string","name",c);let e=mX,a=IL(c);for(;a.length;)e=N0(O0([e,N0(a.pop())]));return Be(e)}function Co(c){return Be(O0(IL(c).map(e=>{if(e.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");let a=new Uint8Array(e.length+1);return a.set(e,1),a[0]=a.length-1,a})))+"00"}s();x();var gX=`Ethereum Signed Message:
|
|
346
|
+
}`;var YE=c=>{switch(c){case p1.Index:return"index";case p1.Value:return"value";default:return""}},Ane=(c,e)=>!c&&!c.serialization?ja.None:e!=null&&e!==ja.None?e:ja.Index;s();x();s();x();var Zu,Sne=new Uint8Array(16);function XE(){if(!Zu&&(Zu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Zu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Zu(Sne)}s();x();var df=[];for(let c=0;c<256;++c)df.push((c+256).toString(16).slice(1));function Uq(c,e=0){return(df[c[e+0]]+df[c[e+1]]+df[c[e+2]]+df[c[e+3]]+"-"+df[c[e+4]]+df[c[e+5]]+"-"+df[c[e+6]]+df[c[e+7]]+"-"+df[c[e+8]]+df[c[e+9]]+"-"+df[c[e+10]]+df[c[e+11]]+df[c[e+12]]+df[c[e+13]]+df[c[e+14]]+df[c[e+15]]).toLowerCase()}s();x();s();x();var Ine=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),eA={randomUUID:Ine};function Lne(c,e,a){if(eA.randomUUID&&!e&&!c)return eA.randomUUID();c=c||{};let f=c.random||(c.rng||XE)();if(f[6]=f[6]&15|64,f[8]=f[8]&63|128,e){a=a||0;for(let d=0;d<16;++d)e[a+d]=f[d];return e}return Uq(f)}var If=Lne;s();x();s();x();var _G=Fe(wG()),Une="slots overflow",qne=c=>c.reverse();function vG(c){let e;if(typeof c=="string")e=BigInt(c);else if(typeof c=="number")e=BigInt(Math.trunc(c));else throw new Error("field type is not supported");return H0.intToBytes(e)}function EG(c,e){return Nd(H0.bytesToInt(Uint8Array.from([...c,...e])))}function Gne(c){return Nd(H0.bytesToInt(c))}var gA=c=>{let e=R0.decodeString((0,_G.keccak256)(c));return new kc(e.slice(e.length-16,e.length))},P9=(c,e)=>{let a=Uint8Array.from([]);if(!e)return new Uint8Array(32);let f=c[e];if(!f)throw new Error(`${e} field is not in data`);let d=vG(f);if(EG(a,d))a=Uint8Array.from([...a,...d]);else throw new Error(Une);return a};s();x();s();x();var S4=class{async parseClaim(e,a,f,d){d||(d={revNonce:0,version:0,subjectPosition:"index",merklizedRootPosition:"",updatable:!1});let b=e.credentialSubject.id,t=this.parseSlots(e,f),r=gA(new TextEncoder().encode(a)),o=Uf.newClaim(r,m1.withIndexDataBytes(t.indexA,t.indexB),m1.withValueDataBytes(t.valueA,t.valueB),m1.withRevocationNonce(BigInt(d.revNonce)),m1.withVersion(d.version));if(d.updatable&&o.setFlagUpdatable(d.updatable),e.expirationDate&&o.setExpirationDate(new Date(e.expirationDate)),b){let n=sc.parse(b.toString());switch(d.subjectPosition){case"":case"index":o.setIndexId(n.id);break;case"value":o.setValueId(n.id);break;default:throw new Error("unknown subject position")}}switch(d.merklizedRootPosition){case"index":{let n=await e.merklize();o.setIndexMerklizedRoot((await n.root()).bigInt());break}case"value":{let n=await e.merklize();o.setValueMerklizedRoot((await n.root()).bigInt());break}case"":break;default:throw new Error("unknown merklized root position")}return o}parseSlots(e,a){let f=JSON.parse(new TextDecoder().decode(a));return f?.$metadata?.serialization?this.assignSlots(e.credentialSubject,f.$metadata.serialization):{indexA:new Uint8Array(32),indexB:new Uint8Array(32),valueA:new Uint8Array(32),valueB:new Uint8Array(32)}}assignSlots(e,a){let f={indexA:new Uint8Array(32),indexB:new Uint8Array(32),valueA:new Uint8Array(32),valueB:new Uint8Array(32)};return f.indexA=P9(e,a.indexDataSlotA),f.indexB=P9(e,a.indexDataSlotB),f.valueA=P9(e,a.valueDataSlotA),f.valueB=P9(e,a.valueDataSlotB),f}getFieldSlotIndex(e,a){let f=JSON.parse(new TextDecoder().decode(a));if(!f?.$metadata?.serialization)throw new Error("serialization info is not set");switch(e){case f.$metadata?.serialization?.indexDataSlotA:return 2;case f.$metadata?.serialization?.indexDataSlotB:return 3;case f.$metadata?.serialization?.valueDataSlotA:return 6;case f.$metadata?.serialization?.valueDataSlotB:return 7;default:throw new Error(`field ${e} not specified in serialization info`)}}};s();x();var Sj=Fe(Aj()),jA=class{_ajv;constructor(){this._ajv=new Sj.default({logger:!1})}async validate(e,a){let f=JSON.parse(new TextDecoder().decode(a)),d=JSON.parse(new TextDecoder().decode(e)),b=this._ajv.compile(f);if(!await b(d))throw new Error(b.errors?.map(r=>r.message).join(", "));return!0}};s();x();var T9=(f=>(f[f.Claims=0]="Claims",f[f.Revocations=1]="Revocations",f[f.Roots=2]="Roots",f))(T9||{});s();x();s();x();Ah();var woe=new Function("try {return this===window;}catch(e){ return false;}"),HA=class{constructor(e){this.dir=e}async load(e){if(woe())throw new Error("can not use fs loader in the browser");let a=await(void 0)(`${this.dir}/${e}`);return new Uint8Array(a)}};s();x();s();x();s();x();var _oe=c=>Promise.reject(new Error(`No base found for "${c}"`)),Sh=class{constructor(e){this._basesByName={},this._basesByPrefix={},this._loadBase=e.loadBase||_oe;for(let a of e.bases)this.addBase(a)}addBase(e){if(this._basesByName[e.name]||this._basesByPrefix[e.prefix])throw new Error(`Codec already exists for codec "${e.name}"`);this._basesByName[e.name]=e,this._basesByPrefix[e.prefix]=e}removeBase(e){delete this._basesByName[e.name],delete this._basesByPrefix[e.prefix]}async getBase(e){if(this._basesByName[e])return this._basesByName[e];if(this._basesByPrefix[e])return this._basesByPrefix[e];let a=await this._loadBase(e);return this._basesByName[a.name]==null&&this._basesByPrefix[a.prefix]==null&&this.addBase(a),a}listBases(){return Object.values(this._basesByName)}};s();x();var voe=c=>Promise.reject(new Error(`No codec found for "${c}"`)),Ih=class{constructor(e){this._codecsByName={},this._codecsByCode={},this._loadCodec=e.loadCodec||voe;for(let a of e.codecs)this.addCodec(a)}addCodec(e){if(this._codecsByName[e.name]||this._codecsByCode[e.code])throw new Error(`Resolver already exists for codec "${e.name}"`);this._codecsByName[e.name]=e,this._codecsByCode[e.code]=e}removeCodec(e){delete this._codecsByName[e.name],delete this._codecsByCode[e.code]}async getCodec(e){let a=typeof e=="string"?this._codecsByName:this._codecsByCode;if(a[e])return a[e];let f=await this._loadCodec(e);return a[e]==null&&this.addCodec(f),f}listCodecs(){return Object.values(this._codecsByName)}};s();x();var Eoe=c=>Promise.reject(new Error(`No hasher found for "${c}"`)),Lh=class{constructor(e){this._hashersByName={},this._hashersByCode={},this._loadHasher=e.loadHasher||Eoe;for(let a of e.hashers)this.addHasher(a)}addHasher(e){if(this._hashersByName[e.name]||this._hashersByCode[e.code])throw new Error(`Resolver already exists for codec "${e.name}"`);this._hashersByName[e.name]=e,this._hashersByCode[e.code]=e}removeHasher(e){delete this._hashersByName[e.name],delete this._hashersByCode[e.code]}async getHasher(e){let a=typeof e=="string"?this._hashersByName:this._hashersByCode;if(a[e])return a[e];let f=await this._loadHasher(e);return a[e]==null&&this.addHasher(f),f}listHashers(){return Object.values(this._hashersByName)}};var cS={};v0(cS,{code:()=>wse,createLink:()=>Qj,createNode:()=>Kj,decode:()=>vse,encode:()=>_se,name:()=>yse,prepare:()=>eS,validate:()=>aS});s();x();F0();s();x();var ise=new TextDecoder;function YA(c,e){let a=0;for(let f=0;;f+=7){if(f>=64)throw new Error("protobuf: varint overflow");if(e>=c.length)throw new Error("protobuf: unexpected end of data");let d=c[e++];if(a+=f<28?(d&127)<<f:(d&127)*2**f,d<128)break}return[a,e]}function Nh(c,e){let a;[a,e]=YA(c,e);let f=e+a;if(a<0||f<0)throw new Error("protobuf: invalid length");if(f>c.length)throw new Error("protobuf: unexpected end of data");return[c.subarray(e,f),f]}function Uj(c,e){let a;return[a,e]=YA(c,e),[a&7,a>>3,e]}function ose(c){let e={},a=c.length,f=0;for(;f<a;){let d,b;if([d,b,f]=Uj(c,f),b===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(d!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${d}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,f]=Nh(c,f)}else if(b===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(d!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${d}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let t;[t,f]=Nh(c,f),e.Name=ise.decode(t)}else if(b===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(d!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${d}) for Tsize`);[e.Tsize,f]=YA(c,f)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${b}`)}if(f>a)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function qj(c){let e=c.length,a=0,f,d=!1,b;for(;a<e;){let r,o;if([r,o,a]=Uj(c,a),r!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${r}`);if(o===1){if(b)throw new Error("protobuf: (PBNode) duplicate Data section");[b,a]=Nh(c,a),f&&(d=!0)}else if(o===2){if(d)throw new Error("protobuf: (PBNode) duplicate Links section");f||(f=[]);let n;[n,a]=Nh(c,a),f.push(ose(n))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${o}`)}if(a>e)throw new Error("protobuf: (PBNode) unexpected end of data");let t={};return b&&(t.Data=b),t.Links=f||[],t}s();x();var zj=new TextEncoder,Gj=2**32,sse=2**31;function xse(c,e){let a=e.length;if(typeof c.Tsize=="number"){if(c.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(c.Tsize))throw new Error("Tsize too large for encoding");a=Ti(e,a,c.Tsize)-1,e[a]=24}if(typeof c.Name=="string"){let f=zj.encode(c.Name);a-=f.length,e.set(f,a),a=Ti(e,a,f.length)-1,e[a]=18}return c.Hash&&(a-=c.Hash.length,e.set(c.Hash,a),a=Ti(e,a,c.Hash.length)-1,e[a]=10),e.length-a}function jj(c){let e=use(c),a=new Uint8Array(e),f=e;if(c.Data&&(f-=c.Data.length,a.set(c.Data,f),f=Ti(a,f,c.Data.length)-1,a[f]=10),c.Links)for(let d=c.Links.length-1;d>=0;d--){let b=xse(c.Links[d],a.subarray(0,f));f-=b,f=Ti(a,f,b)-1,a[f]=18}return a}function lse(c){let e=0;if(c.Hash){let a=c.Hash.length;e+=1+a+U9(a)}if(typeof c.Name=="string"){let a=zj.encode(c.Name).length;e+=1+a+U9(a)}return typeof c.Tsize=="number"&&(e+=1+U9(c.Tsize)),e}function use(c){let e=0;if(c.Data){let a=c.Data.length;e+=1+a+U9(a)}if(c.Links)for(let a of c.Links){let f=lse(a);e+=1+f+U9(f)}return e}function Ti(c,e,a){e-=U9(a);let f=e;for(;a>=sse;)c[e++]=a&127|128,a/=128;for(;a>=128;)c[e++]=a&127|128,a>>>=7;return c[e]=a,f}function U9(c){return c%2===0&&c++,Math.floor((hse(c)+6)/7)}function hse(c){let e=0;return c>=Gj&&(c=Math.floor(c/Gj),e=32),c>=1<<16&&(c>>>=16,e+=16),c>=1<<8&&(c>>>=8,e+=8),e+pse[c]}var pse=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];s();x();F0();var mse=["Data","Links"],gse=["Hash","Name","Tsize"],XA=new TextEncoder;function $j(c,e){if(c===e)return 0;let a=c.Name?XA.encode(c.Name):[],f=e.Name?XA.encode(e.Name):[],d=a.length,b=f.length;for(let t=0,r=Math.min(d,b);t<r;++t)if(a[t]!==f[t]){d=a[t],b=f[t];break}return d<b?-1:b<d?1:0}function Hj(c,e){return!Object.keys(c).some(a=>!e.includes(a))}function Vj(c){if(typeof c.asCID=="object"){let a=Re.asCID(c);if(!a)throw new TypeError("Invalid DAG-PB form");return{Hash:a}}if(typeof c!="object"||Array.isArray(c))throw new TypeError("Invalid DAG-PB form");let e={};if(c.Hash){let a=Re.asCID(c.Hash);try{a||(typeof c.Hash=="string"?a=Re.parse(c.Hash):c.Hash instanceof Uint8Array&&(a=Re.decode(c.Hash)))}catch(f){throw new TypeError(`Invalid DAG-PB form: ${f.message}`)}a&&(e.Hash=a)}if(!e.Hash)throw new TypeError("Invalid DAG-PB form");return typeof c.Name=="string"&&(e.Name=c.Name),typeof c.Tsize=="number"&&(e.Tsize=c.Tsize),e}function eS(c){if((c instanceof Uint8Array||typeof c=="string")&&(c={Data:c}),typeof c!="object"||Array.isArray(c))throw new TypeError("Invalid DAG-PB form");let e={};if(c.Data!==void 0)if(typeof c.Data=="string")e.Data=XA.encode(c.Data);else if(c.Data instanceof Uint8Array)e.Data=c.Data;else throw new TypeError("Invalid DAG-PB form");if(c.Links!==void 0)if(Array.isArray(c.Links))e.Links=c.Links.map(Vj),e.Links.sort($j);else throw new TypeError("Invalid DAG-PB form");else e.Links=[];return e}function aS(c){if(!c||typeof c!="object"||Array.isArray(c))throw new TypeError("Invalid DAG-PB form");if(!Hj(c,mse))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(c.Data!==void 0&&!(c.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be a Uint8Array)");if(!Array.isArray(c.Links))throw new TypeError("Invalid DAG-PB form (Links must be an array)");for(let e=0;e<c.Links.length;e++){let a=c.Links[e];if(!a||typeof a!="object"||Array.isArray(a))throw new TypeError("Invalid DAG-PB form (bad link object)");if(!Hj(a,gse))throw new TypeError("Invalid DAG-PB form (extraneous properties on link object)");if(!a.Hash)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(a.Hash.asCID!==a.Hash)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(a.Name!==void 0&&typeof a.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(a.Tsize!==void 0&&(typeof a.Tsize!="number"||a.Tsize%1!==0))throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(e>0&&$j(a,c.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function Kj(c,e=[]){return eS({Data:c,Links:e})}function Qj(c,e,a){return Vj({Hash:a,Name:c,Tsize:e})}var yse="dag-pb",wse=112;function _se(c){aS(c);let e={};return c.Links&&(e.Links=c.Links.map(a=>{let f={};return a.Hash&&(f.Hash=a.Hash.bytes),a.Name!==void 0&&(f.Name=a.Name),a.Tsize!==void 0&&(f.Tsize=a.Tsize),f})),c.Data&&(e.Data=c.Data),jj(e)}function vse(c){let e=qj(c),a={};return e.Data&&(a.Data=e.Data),e.Links&&(a.Links=e.Links.map(f=>{let d={};try{d.Hash=Re.decode(f.Hash)}catch{}if(!d.Hash)throw new Error("Invalid Hash field found in link, expected CID");return f.Name!==void 0&&(d.Name=f.Name),f.Tsize!==void 0&&(d.Tsize=f.Tsize),d})),a}var wS={};v0(wS,{code:()=>cxe,decode:()=>dxe,encode:()=>fxe,name:()=>axe});s();x();Qh();F0();var a$=42;function Jse(c){if(c.asCID!==c)return null;let e=Re.asCID(c);if(!e)return null;let a=new Uint8Array(e.bytes.byteLength+1);return a.set(e.bytes,1),[new Ne(xe.tag,a$),new Ne(xe.bytes,a)]}function Zse(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Yse(c){if(Number.isNaN(c))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(c===1/0||c===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var Xse={float64:!0,typeEncoders:{Object:Jse,undefined:Zse,number:Yse}};function exe(c){if(c[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return Re.decode(c.subarray(1))}var c$={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};c$.tags[a$]=exe;var axe="dag-cbor",cxe=113,fxe=c=>Ui(c,Xse),dxe=c=>B4(c,c$);var RS={};v0(RS,{code:()=>hxe,decode:()=>mxe,encode:()=>pxe,name:()=>uxe});s();x();AS();zi();Qh();s();x();s();x();Zf();mS();Zd();F7();var SS=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let a=this.inRecursive[this.inRecursive.length-1];a&&(a.type===xe.array&&(a.elements++,a.elements!==1&&e.push([44])),a.type===xe.map&&(a.elements++,a.elements!==1&&(a.elements%2===1?e.push([44]):e.push([58]))))}[xe.uint.major](e,a){this.prefix(e);let f=String(a.value),d=[];for(let b=0;b<f.length;b++)d[b]=f.charCodeAt(b);e.push(d)}[xe.negint.major](e,a){this[xe.uint.major](e,a)}[xe.bytes.major](e,a){throw new Error(`${W3} unsupported type: Uint8Array`)}[xe.string.major](e,a){this.prefix(e);let f=Dh(JSON.stringify(a.value));e.push(f.length>32?Oi(f):f)}[xe.array.major](e,a){this.prefix(e),this.inRecursive.push({type:xe.array,elements:0}),e.push([91])}[xe.map.major](e,a){this.prefix(e),this.inRecursive.push({type:xe.map,elements:0}),e.push([123])}[xe.tag.major](e,a){}[xe.float.major](e,a){if(a.type.name==="break"){let t=this.inRecursive.pop();if(t){if(t.type===xe.array)e.push([93]);else if(t.type===xe.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(a.value===void 0)throw new Error(`${W3} unsupported type: undefined`);if(this.prefix(e),a.type.name==="true"){e.push([116,114,117,101]);return}else if(a.type.name==="false"){e.push([102,97,108,115,101]);return}else if(a.type.name==="null"){e.push([110,117,108,108]);return}let f=String(a.value),d=[],b=!1;for(let t=0;t<f.length;t++)d[t]=f.charCodeAt(t),!b&&(d[t]===46||d[t]===101||d[t]===69)&&(b=!0);b||(d.push(46),d.push(48)),e.push(d)}};function rxe(c,e){if(Array.isArray(c[0])||Array.isArray(e[0]))throw new Error(`${W3} complex map keys are not supported`);let a=c[0],f=e[0];if(a.type!==xe.string||f.type!==xe.string)throw new Error(`${W3} non-string map keys are not supported`);if(a<f)return-1;if(a>f)return 1;throw new Error(`${W3} unexpected duplicate map keys, this is not supported`)}var nxe={addBreakTokens:!0,mapSorter:rxe};function IS(c,e){return e=Object.assign({},nxe,e),pS(c,new SS,e)}s();x();yS();Zf();F7();Zd();var V9=class{constructor(e,a={}){this.pos=0,this.data=e,this.options=a,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this.pos]}expect(e){if(this.data.length-this.pos<e.length)throw new Error(`${f0} unexpected end of input at position ${this.pos}`);for(let a=0;a<e.length;a++)if(this.data[this.pos++]!==e[a])throw new Error(`${f0} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this.pos,a=!1,f=!1,d=r=>{for(;!this.done();){let o=this.ch();if(r.includes(o))this.pos++;else break}};if(this.ch()===45&&(a=!0,this.pos++),this.ch()===48)if(this.pos++,this.ch()===46)this.pos++,f=!0;else return new Ne(xe.uint,0,this.pos-e);if(d([48,49,50,51,52,53,54,55,56,57]),a&&this.pos===e+1)throw new Error(`${f0} unexpected token at position ${this.pos}`);if(!this.done()&&this.ch()===46){if(f)throw new Error(`${f0} unexpected token at position ${this.pos}`);f=!0,this.pos++,d([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(f=!0,this.pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this.pos++,d([48,49,50,51,52,53,54,55,56,57]));let b=String.fromCharCode.apply(null,this.data.subarray(e,this.pos)),t=parseFloat(b);return f?new Ne(xe.float,t,this.pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(t)?new Ne(t>=0?xe.uint:xe.negint,t,this.pos-e):new Ne(t>=0?xe.uint:xe.negint,BigInt(b),this.pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${f0} unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let b=this.pos,t=0;b<this.data.length&&t<65536;b++,t++){let r=this.data[b];if(r===92||r<32||r>=128)break;if(r===34){let o=String.fromCharCode.apply(null,this.data.subarray(this.pos,b));return this.pos=b+1,new Ne(xe.string,o,t)}}let e=this.pos,a=[],f=()=>{if(this.pos+4>=this.data.length)throw new Error(`${f0} unexpected end of unicode escape sequence at position ${this.pos}`);let b=0;for(let t=0;t<4;t++){let r=this.ch();if(r>=48&&r<=57)r-=48;else if(r>=97&&r<=102)r=r-97+10;else if(r>=65&&r<=70)r=r-65+10;else throw new Error(`${f0} unexpected unicode escape character at position ${this.pos}`);b=b*16+r,this.pos++}return b},d=()=>{let b=this.ch(),t=null,r=b>239?4:b>223?3:b>191?2:1;if(this.pos+r>this.data.length)throw new Error(`${f0} unexpected unicode sequence at position ${this.pos}`);let o,n,i,l;switch(r){case 1:b<128&&(t=b);break;case 2:o=this.data[this.pos+1],(o&192)===128&&(l=(b&31)<<6|o&63,l>127&&(t=l));break;case 3:o=this.data[this.pos+1],n=this.data[this.pos+2],(o&192)===128&&(n&192)===128&&(l=(b&15)<<12|(o&63)<<6|n&63,l>2047&&(l<55296||l>57343)&&(t=l));break;case 4:o=this.data[this.pos+1],n=this.data[this.pos+2],i=this.data[this.pos+3],(o&192)===128&&(n&192)===128&&(i&192)===128&&(l=(b&15)<<18|(o&63)<<12|(n&63)<<6|i&63,l>65535&&l<1114112&&(t=l))}t===null?(t=65533,r=1):t>65535&&(t-=65536,a.push(t>>>10&1023|55296),t=56320|t&1023),a.push(t),this.pos+=r};for(;!this.done();){let b=this.ch(),t;switch(b){case 92:if(this.pos++,this.done())throw new Error(`${f0} unexpected string termination at position ${this.pos}`);switch(t=this.ch(),this.pos++,t){case 34:case 39:case 92:case 47:a.push(t);break;case 98:a.push(8);break;case 116:a.push(9);break;case 110:a.push(10);break;case 102:a.push(12);break;case 114:a.push(13);break;case 117:a.push(f());break;default:throw new Error(`${f0} unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new Ne(xe.string,fS(a),this.pos-e);default:if(b<32)throw new Error(`${f0} invalid control character at position ${this.pos}`);b<128?(a.push(b),this.pos++):d()}}throw new Error(`${f0} unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new Ne(xe.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new Ne(xe.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new Ne(xe.null,null,4);case 102:return this.expect([102,97,108,115,101]),new Ne(xe.false,!1,5);case 116:return this.expect([116,114,117,101]),new Ne(xe.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${f0} unexpected character at position ${this.pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this.pos++,this.skipWhitespace(),new Ne(xe.break,void 0,1);if(this.ch()!==44)throw new Error(`${f0} unexpected character at position ${this.pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this.pos++,this.skipWhitespace(),new Ne(xe.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this.pos++,this.skipWhitespace(),new Ne(xe.break,void 0,1);if(this.ch()!==44)throw new Error(`${f0} unexpected character at position ${this.pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this.pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this.pos++,this.skipWhitespace(),new Ne(xe.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${f0} unexpected character at position ${this.pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${f0} unexpected parse state at position ${this.pos}; this shouldn't happen`)}}};function LS(c,e){return e=Object.assign({tokenizer:new V9(c,e)},e),B4(c,e)}function oxe(c){if(c.asCID!==c)return null;let e=Re.asCID(c);if(!e)return null;let a=e.toString();return[new Ne(xe.map,1/0,1),new Ne(xe.string,"/",1),new Ne(xe.string,a,a.length),new Ne(xe.break,void 0,1)]}function d$(c){let e=Wh.encode(c).slice(1);return[new Ne(xe.map,1/0,1),new Ne(xe.string,"/",1),new Ne(xe.map,1/0,1),new Ne(xe.string,"bytes",5),new Ne(xe.string,e,e.length),new Ne(xe.break,void 0,1),new Ne(xe.break,void 0,1)]}function sxe(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function xxe(c){if(Number.isNaN(c))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(c===1/0||c===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var lxe={typeEncoders:{Object:oxe,Uint8Array:d$,Buffer:d$,undefined:sxe,number:xxe}},FS=class extends V9{constructor(e,a){super(e,a),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===xe.map){let a=this._next();if(a.type===xe.string&&a.value==="/"){let f=this._next();if(f.type===xe.string){if(this._next().type!==xe.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(f),new Ne(xe.tag,42,0)}if(f.type===xe.map){let d=this._next();if(d.type===xe.string&&d.value==="bytes"){let b=this._next();if(b.type===xe.string){for(let r=0;r<2;r++)if(this._next().type!==xe.break)throw new Error("Invalid encoded Bytes form");let t=Wh.decode(`m${b.value}`);return new Ne(xe.bytes,t,b.value.length)}this.tokenBuffer.push(b)}this.tokenBuffer.push(d)}this.tokenBuffer.push(f)}this.tokenBuffer.push(a)}return e}},CS={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};CS.tags[42]=Re.parse;var uxe="dag-json",hxe=297,pxe=c=>IS(c,lxe),mxe=c=>{let e=Object.assign(CS,{tokenizer:new FS(c,CS)});return LS(c,e)};var xpe=Fe(m$(),1);kS();WS();s();x();s();x();F0();s();x();s();x();var RI=Fe(Yf(),1),Nb=Fe(lI(),1);s();x();var pue=/(-?(?:\d+\.?\d*|\d*\.?\d+)(?:e[-+]?\d+)?)\s*([\p{L}]*)/uig;U0.nanosecond=U0.ns=1/1e6;U0.\u00B5s=U0.\u03BCs=U0.us=U0.microsecond=1/1e3;U0.millisecond=U0.ms=U0[""]=1;U0.second=U0.sec=U0.s=U0.ms*1e3;U0.minute=U0.min=U0.m=U0.s*60;U0.hour=U0.hr=U0.h=U0.m*60;U0.day=U0.d=U0.h*24;U0.week=U0.wk=U0.w=U0.d*7;U0.month=U0.b=U0.d*(365.25/12);U0.year=U0.yr=U0.y=U0.d*365.25;function U0(c="",e="ms"){var a=null;return c=(c+"").replace(/(\d)[,_](\d)/g,"$1$2"),c.replace(pue,function(f,d,b){b=OV(b),b&&(a=(a||0)+parseFloat(d,10)*b)}),a&&a/(OV(e)||1)}function OV(c){return U0[c]||U0[c.toLowerCase().replace(/s$/,"")]}var NV=U0;var SK=Fe(uI(),1),k4=Fe(mp(),1);s();x();var pK=Fe(EI(),1),mK=pK.default;s();x();var wK=Fe(Yf(),1),_K=Fe(yK(),1);function CI(c){try{c=(0,_K.default)(new wK.Multiaddr(c))}catch{}return c=c.toString(),c}s();x();var vK=()=>{};var EK=(0,SK.default)("ipfs-http-client:lib:error-handler"),mhe=mK.bind({ignoreUndefined:!0}),ghe=Nb.isBrowser||Nb.isWebWorker?location.protocol:"http",yhe=Nb.isBrowser||Nb.isWebWorker?location.hostname:"localhost",whe=Nb.isBrowser||Nb.isWebWorker?location.port:"5001",_he=(c={})=>{let e,a={},f;if(typeof c=="string"||RI.Multiaddr.isMultiaddr(c))e=new URL(CI(c));else if(c instanceof URL)e=c;else if(typeof c.url=="string"||RI.Multiaddr.isMultiaddr(c.url))e=new URL(CI(c.url)),a=c;else if(c.url instanceof URL)e=c.url,a=c;else{a=c||{};let d=(a.protocol||ghe).replace(":",""),b=(a.host||yhe).split(":")[0],t=a.port||whe;e=new URL(`${d}://${b}:${t}`)}if(a.apiPath?e.pathname=a.apiPath:(e.pathname==="/"||e.pathname===void 0)&&(e.pathname="api/v0"),Nb.isNode){let d=vK(e);f=a.agent||new d({keepAlive:!0,maxSockets:6})}return{...a,host:e.host,protocol:e.protocol.replace(":",""),port:Number(e.port),apiPath:e.pathname,url:e,agent:f}},vhe=async c=>{let e;try{if((c.headers.get("Content-Type")||"").startsWith("application/json")){let f=await c.json();EK(f),e=f.Message||f.message}else e=await c.text()}catch(f){EK("Failed to parse error response",f),e=f.message}let a=new k4.default.HTTPError(c);throw e&&(e.includes("deadline has elapsed")&&(a=new k4.default.TimeoutError),e&&e.includes("context deadline exceeded")&&(a=new k4.default.TimeoutError)),e&&e.includes("request timed out")&&(a=new k4.default.TimeoutError),e&&(a.message=e),a},Ehe=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,AK=c=>c.replace(Ehe,function(e){return"-"+e.toLowerCase()}),Ahe=c=>typeof c=="string"?NV(c):c,T7=class extends k4.default{constructor(e={}){let a=_he(e);super({timeout:Ahe(a.timeout||0)||void 0,headers:a.headers,base:`${a.url}`,handleError:vhe,transformSearchParams:d=>{let b=new URLSearchParams;for(let[t,r]of d)r!=="undefined"&&r!=="null"&&t!=="signal"&&b.append(AK(t),r),t==="timeout"&&!isNaN(r)&&b.append(AK(t),r);return b},agent:a.agent}),delete this.get,delete this.put,delete this.delete,delete this.options;let f=this.fetch;this.fetch=(d,b={})=>(typeof d=="string"&&!d.startsWith("/")&&(d=`${a.url}/${d}`),f.call(this,d,mhe(b,{method:"POST"})))}},$b0=k4.default.HTTPError;var ne=c=>e=>c(new T7(e),e);s();x();s();x();function yp(c){if(c!=null)return typeof c=="string"?c:c.toString(8).padStart(4,"0")}s();x();var IK=Fe(Ed(),1);function wp(c){if(c==null)return;let e;if(c.secs!=null&&(e={secs:c.secs,nsecs:c.nsecs}),c.Seconds!=null&&(e={secs:c.Seconds,nsecs:c.FractionalNanoseconds}),Array.isArray(c)&&(e={secs:c[0],nsecs:c[1]}),c instanceof Date){let a=c.getTime(),f=Math.floor(a/1e3);e={secs:f,nsecs:(a-f*1e3)*1e3}}if(!!Object.prototype.hasOwnProperty.call(e,"secs")){if(e!=null&&e.nsecs!=null&&(e.nsecs<0||e.nsecs>999999999))throw(0,IK.default)(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return e}}function oe({arg:c,searchParams:e,hashAlg:a,mtime:f,mode:d,...b}={}){e&&(b={...b,...e}),a&&(b.hash=a),f!=null&&(f=wp(f),b.mtime=f.secs,b.mtimeNsecs=f.nsecs),d!=null&&(b.mode=yp(d)),b.timeout&&!isNaN(b.timeout)&&(b.timeout=`${b.timeout}ms`),c==null?c=[]:Array.isArray(c)||(c=[c]);let t=new URLSearchParams(b);return c.forEach(r=>t.append("arg",r)),t}var LK=ne(c=>{async function e(a={}){return((await(await c.post("bitswap/wantlist",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).Keys||[]).map(d=>Re.parse(d["/"]))}return e});s();x();F0();var FK=ne(c=>{async function e(a,f={}){return((await(await c.post("bitswap/wantlist",{signal:f.signal,searchParams:oe({...f,peer:a.toString()}),headers:f.headers})).json()).Keys||[]).map(b=>Re.parse(b["/"]))}return e});s();x();F0();var _p=ne(c=>{async function e(a={}){let f=await c.post("bitswap/stat",{searchParams:oe(a),signal:a.signal,headers:a.headers});return She(await f.json())}return e});function She(c){return{provideBufLen:c.ProvideBufLen,wantlist:(c.Wantlist||[]).map(e=>Re.parse(e["/"])),peers:c.Peers||[],blocksReceived:BigInt(c.BlocksReceived),dataReceived:BigInt(c.DataReceived),blocksSent:BigInt(c.BlocksSent),dataSent:BigInt(c.DataSent),dupBlksReceived:BigInt(c.DupBlksReceived),dupDataReceived:BigInt(c.DupDataReceived)}}s();x();var CK=ne(c=>{async function e(a,f={}){return(await c.post("bitswap/unwant",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers})).json()}return e});function RK(c){return{wantlist:LK(c),wantlistForPeer:FK(c),unwant:CK(c),stat:_p(c)}}s();x();s();x();var vp=ne(c=>{async function e(a,f={}){let d=await c.post("block/get",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers});return new Uint8Array(await d.arrayBuffer())}return e});s();x();F0();s();x();s();x();s();x();var TK=Fe(Ed(),1),OK=Fe(Zi(),1),NK=Fe(D4(),1),MK=Fe(pp(),1);s();x();function H2(c){return ArrayBuffer.isView(c)||c instanceof ArrayBuffer}function Z3(c){return c.constructor&&(c.constructor.name==="Blob"||c.constructor.name==="File")&&typeof c.stream=="function"}function Yi(c){return typeof c=="object"&&(c.path||c.content)}var Y3=c=>c&&typeof c.getReader=="function";async function DK(c){if(H2(c))return new Blob([c]);if(typeof c=="string"||c instanceof String)return new Blob([c.toString()]);if(Z3(c))return c;if(Y3(c)&&(c=(0,NK.default)(c)),Symbol.iterator in c||Symbol.asyncIterator in c){let e=(0,OK.default)(c),{value:a,done:f}=await e.peek();if(f)return PK(e);if(e.push(a),Number.isInteger(a))return new Blob([Uint8Array.from(await(0,MK.default)(e))]);if(H2(a)||typeof a=="string"||a instanceof String)return PK(e)}throw(0,TK.default)(new Error(`Unexpected input: ${c}`),"ERR_UNEXPECTED_INPUT")}async function PK(c){let e=[];for await(let a of c)e.push(a);return new Blob(e)}s();x();var co=Fe(Ed(),1),DQ=Fe(D4(),1),kQ=Fe(Zi(),1),KI=Fe(BI(),1);s();x();var MQ=Fe(Ed(),1);s();x();var X3=Fe(NQ(),1),bt=X3.default.Reader,$I=X3.default.Writer,u0=X3.default.util,tf=X3.default.roots["ipfs-unixfs"]||(X3.default.roots["ipfs-unixfs"]={}),Dhe=tf.Data=(()=>{function c(e){if(this.blocksizes=[],e)for(var a=Object.keys(e),f=0;f<a.length;++f)e[a[f]]!=null&&(this[a[f]]=e[a[f]])}return c.prototype.Type=0,c.prototype.Data=u0.newBuffer([]),c.prototype.filesize=u0.Long?u0.Long.fromBits(0,0,!0):0,c.prototype.blocksizes=u0.emptyArray,c.prototype.hashType=u0.Long?u0.Long.fromBits(0,0,!0):0,c.prototype.fanout=u0.Long?u0.Long.fromBits(0,0,!0):0,c.prototype.mode=0,c.prototype.mtime=null,c.encode=function(a,f){if(f||(f=$I.create()),f.uint32(8).int32(a.Type),a.Data!=null&&Object.hasOwnProperty.call(a,"Data")&&f.uint32(18).bytes(a.Data),a.filesize!=null&&Object.hasOwnProperty.call(a,"filesize")&&f.uint32(24).uint64(a.filesize),a.blocksizes!=null&&a.blocksizes.length)for(var d=0;d<a.blocksizes.length;++d)f.uint32(32).uint64(a.blocksizes[d]);return a.hashType!=null&&Object.hasOwnProperty.call(a,"hashType")&&f.uint32(40).uint64(a.hashType),a.fanout!=null&&Object.hasOwnProperty.call(a,"fanout")&&f.uint32(48).uint64(a.fanout),a.mode!=null&&Object.hasOwnProperty.call(a,"mode")&&f.uint32(56).uint32(a.mode),a.mtime!=null&&Object.hasOwnProperty.call(a,"mtime")&&tf.UnixTime.encode(a.mtime,f.uint32(66).fork()).ldelim(),f},c.decode=function(a,f){a instanceof bt||(a=bt.create(a));for(var d=f===void 0?a.len:a.pos+f,b=new tf.Data;a.pos<d;){var t=a.uint32();switch(t>>>3){case 1:b.Type=a.int32();break;case 2:b.Data=a.bytes();break;case 3:b.filesize=a.uint64();break;case 4:if(b.blocksizes&&b.blocksizes.length||(b.blocksizes=[]),(t&7)===2)for(var r=a.uint32()+a.pos;a.pos<r;)b.blocksizes.push(a.uint64());else b.blocksizes.push(a.uint64());break;case 5:b.hashType=a.uint64();break;case 6:b.fanout=a.uint64();break;case 7:b.mode=a.uint32();break;case 8:b.mtime=tf.UnixTime.decode(a,a.uint32());break;default:a.skipType(t&7);break}}if(!b.hasOwnProperty("Type"))throw u0.ProtocolError("missing required 'Type'",{instance:b});return b},c.fromObject=function(a){if(a instanceof tf.Data)return a;var f=new tf.Data;switch(a.Type){case"Raw":case 0:f.Type=0;break;case"Directory":case 1:f.Type=1;break;case"File":case 2:f.Type=2;break;case"Metadata":case 3:f.Type=3;break;case"Symlink":case 4:f.Type=4;break;case"HAMTShard":case 5:f.Type=5;break}if(a.Data!=null&&(typeof a.Data=="string"?u0.base64.decode(a.Data,f.Data=u0.newBuffer(u0.base64.length(a.Data)),0):a.Data.length&&(f.Data=a.Data)),a.filesize!=null&&(u0.Long?(f.filesize=u0.Long.fromValue(a.filesize)).unsigned=!0:typeof a.filesize=="string"?f.filesize=parseInt(a.filesize,10):typeof a.filesize=="number"?f.filesize=a.filesize:typeof a.filesize=="object"&&(f.filesize=new u0.LongBits(a.filesize.low>>>0,a.filesize.high>>>0).toNumber(!0))),a.blocksizes){if(!Array.isArray(a.blocksizes))throw TypeError(".Data.blocksizes: array expected");f.blocksizes=[];for(var d=0;d<a.blocksizes.length;++d)u0.Long?(f.blocksizes[d]=u0.Long.fromValue(a.blocksizes[d])).unsigned=!0:typeof a.blocksizes[d]=="string"?f.blocksizes[d]=parseInt(a.blocksizes[d],10):typeof a.blocksizes[d]=="number"?f.blocksizes[d]=a.blocksizes[d]:typeof a.blocksizes[d]=="object"&&(f.blocksizes[d]=new u0.LongBits(a.blocksizes[d].low>>>0,a.blocksizes[d].high>>>0).toNumber(!0))}if(a.hashType!=null&&(u0.Long?(f.hashType=u0.Long.fromValue(a.hashType)).unsigned=!0:typeof a.hashType=="string"?f.hashType=parseInt(a.hashType,10):typeof a.hashType=="number"?f.hashType=a.hashType:typeof a.hashType=="object"&&(f.hashType=new u0.LongBits(a.hashType.low>>>0,a.hashType.high>>>0).toNumber(!0))),a.fanout!=null&&(u0.Long?(f.fanout=u0.Long.fromValue(a.fanout)).unsigned=!0:typeof a.fanout=="string"?f.fanout=parseInt(a.fanout,10):typeof a.fanout=="number"?f.fanout=a.fanout:typeof a.fanout=="object"&&(f.fanout=new u0.LongBits(a.fanout.low>>>0,a.fanout.high>>>0).toNumber(!0))),a.mode!=null&&(f.mode=a.mode>>>0),a.mtime!=null){if(typeof a.mtime!="object")throw TypeError(".Data.mtime: object expected");f.mtime=tf.UnixTime.fromObject(a.mtime)}return f},c.toObject=function(a,f){f||(f={});var d={};if((f.arrays||f.defaults)&&(d.blocksizes=[]),f.defaults){if(d.Type=f.enums===String?"Raw":0,f.bytes===String?d.Data="":(d.Data=[],f.bytes!==Array&&(d.Data=u0.newBuffer(d.Data))),u0.Long){var b=new u0.Long(0,0,!0);d.filesize=f.longs===String?b.toString():f.longs===Number?b.toNumber():b}else d.filesize=f.longs===String?"0":0;if(u0.Long){var b=new u0.Long(0,0,!0);d.hashType=f.longs===String?b.toString():f.longs===Number?b.toNumber():b}else d.hashType=f.longs===String?"0":0;if(u0.Long){var b=new u0.Long(0,0,!0);d.fanout=f.longs===String?b.toString():f.longs===Number?b.toNumber():b}else d.fanout=f.longs===String?"0":0;d.mode=0,d.mtime=null}if(a.Type!=null&&a.hasOwnProperty("Type")&&(d.Type=f.enums===String?tf.Data.DataType[a.Type]:a.Type),a.Data!=null&&a.hasOwnProperty("Data")&&(d.Data=f.bytes===String?u0.base64.encode(a.Data,0,a.Data.length):f.bytes===Array?Array.prototype.slice.call(a.Data):a.Data),a.filesize!=null&&a.hasOwnProperty("filesize")&&(typeof a.filesize=="number"?d.filesize=f.longs===String?String(a.filesize):a.filesize:d.filesize=f.longs===String?u0.Long.prototype.toString.call(a.filesize):f.longs===Number?new u0.LongBits(a.filesize.low>>>0,a.filesize.high>>>0).toNumber(!0):a.filesize),a.blocksizes&&a.blocksizes.length){d.blocksizes=[];for(var t=0;t<a.blocksizes.length;++t)typeof a.blocksizes[t]=="number"?d.blocksizes[t]=f.longs===String?String(a.blocksizes[t]):a.blocksizes[t]:d.blocksizes[t]=f.longs===String?u0.Long.prototype.toString.call(a.blocksizes[t]):f.longs===Number?new u0.LongBits(a.blocksizes[t].low>>>0,a.blocksizes[t].high>>>0).toNumber(!0):a.blocksizes[t]}return a.hashType!=null&&a.hasOwnProperty("hashType")&&(typeof a.hashType=="number"?d.hashType=f.longs===String?String(a.hashType):a.hashType:d.hashType=f.longs===String?u0.Long.prototype.toString.call(a.hashType):f.longs===Number?new u0.LongBits(a.hashType.low>>>0,a.hashType.high>>>0).toNumber(!0):a.hashType),a.fanout!=null&&a.hasOwnProperty("fanout")&&(typeof a.fanout=="number"?d.fanout=f.longs===String?String(a.fanout):a.fanout:d.fanout=f.longs===String?u0.Long.prototype.toString.call(a.fanout):f.longs===Number?new u0.LongBits(a.fanout.low>>>0,a.fanout.high>>>0).toNumber(!0):a.fanout),a.mode!=null&&a.hasOwnProperty("mode")&&(d.mode=a.mode),a.mtime!=null&&a.hasOwnProperty("mtime")&&(d.mtime=tf.UnixTime.toObject(a.mtime,f)),d},c.prototype.toJSON=function(){return this.constructor.toObject(this,X3.default.util.toJSONOptions)},c.DataType=function(){let e={},a=Object.create(e);return a[e[0]="Raw"]=0,a[e[1]="Directory"]=1,a[e[2]="File"]=2,a[e[3]="Metadata"]=3,a[e[4]="Symlink"]=4,a[e[5]="HAMTShard"]=5,a}(),c})(),f70=tf.UnixTime=(()=>{function c(e){if(e)for(var a=Object.keys(e),f=0;f<a.length;++f)e[a[f]]!=null&&(this[a[f]]=e[a[f]])}return c.prototype.Seconds=u0.Long?u0.Long.fromBits(0,0,!1):0,c.prototype.FractionalNanoseconds=0,c.encode=function(a,f){return f||(f=$I.create()),f.uint32(8).int64(a.Seconds),a.FractionalNanoseconds!=null&&Object.hasOwnProperty.call(a,"FractionalNanoseconds")&&f.uint32(21).fixed32(a.FractionalNanoseconds),f},c.decode=function(a,f){a instanceof bt||(a=bt.create(a));for(var d=f===void 0?a.len:a.pos+f,b=new tf.UnixTime;a.pos<d;){var t=a.uint32();switch(t>>>3){case 1:b.Seconds=a.int64();break;case 2:b.FractionalNanoseconds=a.fixed32();break;default:a.skipType(t&7);break}}if(!b.hasOwnProperty("Seconds"))throw u0.ProtocolError("missing required 'Seconds'",{instance:b});return b},c.fromObject=function(a){if(a instanceof tf.UnixTime)return a;var f=new tf.UnixTime;return a.Seconds!=null&&(u0.Long?(f.Seconds=u0.Long.fromValue(a.Seconds)).unsigned=!1:typeof a.Seconds=="string"?f.Seconds=parseInt(a.Seconds,10):typeof a.Seconds=="number"?f.Seconds=a.Seconds:typeof a.Seconds=="object"&&(f.Seconds=new u0.LongBits(a.Seconds.low>>>0,a.Seconds.high>>>0).toNumber())),a.FractionalNanoseconds!=null&&(f.FractionalNanoseconds=a.FractionalNanoseconds>>>0),f},c.toObject=function(a,f){f||(f={});var d={};if(f.defaults){if(u0.Long){var b=new u0.Long(0,0,!1);d.Seconds=f.longs===String?b.toString():f.longs===Number?b.toNumber():b}else d.Seconds=f.longs===String?"0":0;d.FractionalNanoseconds=0}return a.Seconds!=null&&a.hasOwnProperty("Seconds")&&(typeof a.Seconds=="number"?d.Seconds=f.longs===String?String(a.Seconds):a.Seconds:d.Seconds=f.longs===String?u0.Long.prototype.toString.call(a.Seconds):f.longs===Number?new u0.LongBits(a.Seconds.low>>>0,a.Seconds.high>>>0).toNumber():a.Seconds),a.FractionalNanoseconds!=null&&a.hasOwnProperty("FractionalNanoseconds")&&(d.FractionalNanoseconds=a.FractionalNanoseconds),d},c.prototype.toJSON=function(){return this.constructor.toObject(this,X3.default.util.toJSONOptions)},c})(),d70=tf.Metadata=(()=>{function c(e){if(e)for(var a=Object.keys(e),f=0;f<a.length;++f)e[a[f]]!=null&&(this[a[f]]=e[a[f]])}return c.prototype.MimeType="",c.encode=function(a,f){return f||(f=$I.create()),a.MimeType!=null&&Object.hasOwnProperty.call(a,"MimeType")&&f.uint32(10).string(a.MimeType),f},c.decode=function(a,f){a instanceof bt||(a=bt.create(a));for(var d=f===void 0?a.len:a.pos+f,b=new tf.Metadata;a.pos<d;){var t=a.uint32();switch(t>>>3){case 1:b.MimeType=a.string();break;default:a.skipType(t&7);break}}return b},c.fromObject=function(a){if(a instanceof tf.Metadata)return a;var f=new tf.Metadata;return a.MimeType!=null&&(f.MimeType=String(a.MimeType)),f},c.toObject=function(a,f){f||(f={});var d={};return f.defaults&&(d.MimeType=""),a.MimeType!=null&&a.hasOwnProperty("MimeType")&&(d.MimeType=a.MimeType),d},c.prototype.toJSON=function(){return this.constructor.toObject(this,X3.default.util.toJSONOptions)},c})();var r70=parseInt("0644",8),n70=parseInt("0755",8);function Lp(c){if(c!=null)return typeof c=="number"?c&4095:(c=c.toString(),c.substring(0,1)==="0"?parseInt(c,8)&4095:parseInt(c,10)&4095)}function Fp(c){if(c==null)return;let e;if(c.secs!=null&&(e={secs:c.secs,nsecs:c.nsecs}),c.Seconds!=null&&(e={secs:c.Seconds,nsecs:c.FractionalNanoseconds}),Array.isArray(c)&&(e={secs:c[0],nsecs:c[1]}),c instanceof Date){let a=c.getTime(),f=Math.floor(a/1e3);e={secs:f,nsecs:(a-f*1e3)*1e3}}if(!!Object.prototype.hasOwnProperty.call(e,"secs")){if(e!=null&&e.nsecs!=null&&(e.nsecs<0||e.nsecs>999999999))throw(0,MQ.default)(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return e}}async function*UQ(c,e){if(typeof c=="string"||c instanceof String||H2(c)||Z3(c)||c._readableState)throw(0,co.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT");if(Y3(c)&&(c=(0,DQ.default)(c)),Symbol.iterator in c||Symbol.asyncIterator in c){let a=(0,kQ.default)(c),{value:f,done:d}=await a.peek();if(d){yield*[];return}if(a.push(f),Number.isInteger(f))throw(0,co.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT");if(f._readableState){yield*(0,KI.default)(a,b=>VI({content:b},e));return}if(H2(f)){yield VI({content:a},e);return}if(Yi(f)||f[Symbol.iterator]||f[Symbol.asyncIterator]||Y3(f)||Z3(f)){yield*(0,KI.default)(a,b=>VI(b,e));return}}throw Yi(c)?(0,co.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT"):(0,co.default)(new Error("Unexpected input: "+typeof c),"ERR_UNEXPECTED_INPUT")}async function VI(c,e){let{path:a,mode:f,mtime:d,content:b}=c,t={path:a||"",mode:Lp(f),mtime:Fp(d)};return b?t.content=await e(b):a||(t.content=await e(c)),t}function qQ(c){return UQ(c,DK,!0)}s();x();function GQ(c){if(c!=null)return typeof c=="string"?c:c.toString(8).padStart(4,"0")}async function _c(c,e,a={}){let f=[],d=new FormData,b=0,t=0;for await(let{content:r,path:o,mode:n,mtime:i}of qQ(c)){let l="",h=r?"file":"dir";b>0&&(l=`-${b}`);let u=h+l,g=[];if(n!=null&&g.push(`mode=${GQ(n)}`),i!=null){let{secs:E,nsecs:_}=i;g.push(`mtime=${E}`),_!=null&&g.push(`mtime-nsecs=${_}`)}if(g.length&&(u=`${u}?${g.join("&")}`),r){d.set(u,r,o!=null?encodeURIComponent(o):void 0);let E=t+r.size;f.push({name:o,start:t,end:E}),t=E}else if(o!=null)d.set(u,new File([""],encodeURIComponent(o),{type:"application/x-directory"}));else throw new Error("path or content or both must be set");b++}return{total:t,parts:f,headers:a,body:d}}s();x();var zQ=Fe(LI(),1);function Uhe(c){return c.filter(Boolean)}function vc(...c){return(0,zQ.anySignal)(Uhe(c))}var jQ=ne(c=>{async function e(a,f={}){let d=new AbortController,b=vc(d.signal,f.signal),t;try{t=await(await c.post("block/put",{signal:b,searchParams:oe(f),...await _c([a],d,f.headers)})).json()}catch(r){if(f.format==="dag-pb")return e(a,{...f,format:"protobuf"});if(f.format==="dag-cbor")return e(a,{...f,format:"cbor"});throw r}return Re.parse(t.Key)}return e});s();x();F0();var HQ=ne(c=>{async function*e(a,f={}){Array.isArray(a)||(a=[a]);let d=await c.post("block/rm",{signal:f.signal,searchParams:oe({arg:a.map(b=>b.toString()),"stream-channels":!0,...f}),headers:f.headers});for await(let b of d.ndjson())yield qhe(b)}return e});function qhe(c){let e={cid:Re.parse(c.Hash)};return c.Error&&(e.error=new Error(c.Error)),e}s();x();F0();var $Q=ne(c=>{async function e(a,f={}){let b=await(await c.post("block/stat",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers})).json();return{cid:Re.parse(b.Key),size:b.Size}}return e});function VQ(c){return{get:vp(c),put:jQ(c),rm:HQ(c),stat:$Q(c)}}s();x();s();x();var KQ=Fe(Yf(),1),QQ=ne(c=>{async function e(a,f={}){let d=await c.post("bootstrap/add",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),{Peers:b}=await d.json();return{Peers:b.map(t=>new KQ.Multiaddr(t))}}return e});s();x();var WQ=Fe(Yf(),1),JQ=ne(c=>{async function e(a={}){let f=await c.post("bootstrap/rm",{signal:a.signal,searchParams:oe({...a,all:!0}),headers:a.headers}),{Peers:d}=await f.json();return{Peers:d.map(b=>new WQ.Multiaddr(b))}}return e});s();x();var ZQ=Fe(Yf(),1),YQ=ne(c=>{async function e(a={}){let f=await c.post("bootstrap/list",{signal:a.signal,searchParams:oe(a),headers:a.headers}),{Peers:d}=await f.json();return{Peers:d.map(b=>new ZQ.Multiaddr(b))}}return e});s();x();var XQ=Fe(Yf(),1),eW=ne(c=>{async function e(a={}){let f=await c.post("bootstrap/add",{signal:a.signal,searchParams:oe({...a,default:!0}),headers:a.headers}),{Peers:d}=await f.json();return{Peers:d.map(b=>new XQ.Multiaddr(b))}}return e});s();x();var aW=Fe(Yf(),1),cW=ne(c=>{async function e(a,f={}){let d=await c.post("bootstrap/rm",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),{Peers:b}=await d.json();return{Peers:b.map(t=>new aW.Multiaddr(t))}}return e});function fW(c){return{add:QQ(c),clear:JQ(c),list:YQ(c),reset:eW(c),rm:cW(c)}}s();x();s();x();s();x();var dW=ne(c=>{async function e(a,f={}){let b=await(await c.post("config/profile/apply",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json();return{original:b.OldCfg,updated:b.NewCfg}}return e});s();x();s();x();function V0(c){if(c==null)return c;let e=/^[A-Z]+$/,a={};return Object.keys(c).reduce((f,d)=>(e.test(d)?f[d.toLowerCase()]=c[d]:e.test(d[0])?f[d[0].toLowerCase()+d.slice(1)]=c[d]:f[d]=c[d],f),a)}var bW=ne(c=>{async function e(a={}){return(await(await c.post("config/profile/list",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).map(b=>V0(b))}return e});function tW(c){return{apply:dW(c),list:bW(c)}}s();x();var rW=ne(c=>async(a,f={})=>{if(!a)throw new Error("key argument is required");return(await(await c.post("config",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json()).Value});s();x();var nW=ne(c=>async(a={})=>await(await c.post("config/show",{signal:a.signal,searchParams:oe({...a}),headers:a.headers})).json());s();x();O4();var iW=ne(c=>async(a,f={})=>{let d=new AbortController,b=vc(d.signal,f.signal);await(await c.post("config/replace",{signal:b,searchParams:oe(f),...await _c([M1(JSON.stringify(a))],d,f.headers)})).text()});s();x();var oW=ne(c=>async(a,f,d={})=>{if(typeof a!="string")throw new Error("Invalid key type");let b={...d,...Ghe(a,f)};await(await c.post("config",{signal:d.signal,searchParams:oe(b),headers:d.headers})).text()}),Ghe=(c,e)=>{switch(typeof e){case"boolean":return{arg:[c,e.toString()],bool:!0};case"string":return{arg:[c,e]};default:return{arg:[c,JSON.stringify(e)],json:!0}}};function sW(c){return{getAll:nW(c),get:rW(c),set:oW(c),replace:iW(c),profiles:tW(c)}}s();x();s();x();var xW=ne(c=>{async function*e(a,f={}){yield*(await c.post("dag/export",{signal:f.signal,searchParams:oe({arg:a.toString()}),headers:f.headers})).iterator()}return e});s();x();s();x();F0();var QI=Fe(Ed(),1);async function*WI(c,e,a,f,d){let b=async n=>{let i=await a.getCodec(n.code),l=await f(n,d);return i.decode(l)},t=e.split("/").filter(Boolean),r=await b(c),o=c;for(;t.length;){let n=t.shift();if(!n)throw(0,QI.default)(new Error(`Could not resolve path "${e}"`),"ERR_INVALID_PATH");if(Object.prototype.hasOwnProperty.call(r,n))r=r[n],yield{value:r,remainderPath:t.join("/")};else throw(0,QI.default)(new Error(`no link named "${n}" under ${o}`),"ERR_NO_LINK");let i=Re.asCID(r);i&&(o=i,r=await b(r))}yield{value:r,remainderPath:""}}var pW=Fe(uW(),1),mW=Fe(fo(),1),gW=Fe(Ed(),1);var yW=(c,e)=>ne((f,d)=>{let b=vp(d);return async(r,o={})=>{if(o.path){let u=o.localResolve?await(0,pW.default)(WI(r,o.path,c,b,o)):await(0,mW.default)(WI(r,o.path,c,b,o));if(!u)throw(0,gW.default)(new Error("Not found"),"ERR_NOT_FOUND");return u}let n=await c.getCodec(r.code),i=await b(r,o);return{value:n.decode(i),remainderPath:""}}})(e);s();x();F0();var wW=ne(c=>{async function*e(a,f={}){let d=new AbortController,b=vc(d.signal,f.signal),{headers:t,body:r}=await _c(a,d,f.headers),o=await c.post("dag/import",{signal:b,headers:t,body:r,searchParams:oe({"pin-roots":f.pinRoots})});for await(let{Root:n}of o.ndjson())if(n!==void 0){let{Cid:{"/":i},PinErrorMsg:l}=n;yield{root:{cid:Re.parse(i),pinErrorMsg:l}}}}return e});s();x();F0();var Cp=(c,e)=>ne(f=>async(b,t={})=>{let r={storeCodec:"dag-cbor",hashAlg:"sha2-256",...t},o;if(r.inputCodec){if(!(b instanceof Uint8Array))throw new Error("Can only inputCodec on raw bytes that can be decoded");o=b}else o=(await c.getCodec(r.storeCodec)).encode(b),r.inputCodec=r.storeCodec;let n=new AbortController,i=vc(n.signal,r.signal),h=await(await f.post("dag/put",{timeout:r.timeout,signal:i,searchParams:oe(r),...await _c([o],n,r.headers)})).json();return Re.parse(h.Cid["/"])})(e);s();x();F0();var _W=ne(c=>async(a,f={})=>{let b=await(await c.post("dag/resolve",{signal:f.signal,searchParams:oe({arg:`${a}${f.path?`/${f.path}`.replace(/\/[/]+/g,"/"):""}`,...f}),headers:f.headers})).json();return{cid:Re.parse(b.Cid["/"]),remainderPath:b.RemPath}});function vW(c,e){return{export:xW(e),get:yW(c,e),import:wW(e),put:Cp(c,e),resolve:_W(e)}}s();x();s();x();s();x();O4();s();x();var bo=Fe(Yf(),1),V2=c=>{if(c.Type===0)return{to:c.ID,name:"SENDING_QUERY",type:c.Type};if(c.Type===1)return{from:c.ID,name:"PEER_RESPONSE",type:c.Type,messageType:0,messageName:"PUT_VALUE",closer:(c.Responses||[]).map(({ID:e,Addrs:a})=>({id:e,multiaddrs:a.map(f=>new bo.Multiaddr(f))})),providers:(c.Responses||[]).map(({ID:e,Addrs:a})=>({id:e,multiaddrs:a.map(f=>new bo.Multiaddr(f))}))};if(c.Type===2){let e={id:c.ID,multiaddrs:[]};return c.Responses&&c.Responses.length&&(e={id:c.Responses[0].ID,multiaddrs:c.Responses[0].Addrs.map(a=>new bo.Multiaddr(a))}),{from:c.ID,name:"FINAL_PEER",type:c.Type,peer:e}}if(c.Type===3)return{from:c.ID,name:"QUERY_ERROR",type:c.Type,error:new Error(c.Extra)};if(c.Type===4)return{from:c.ID,name:"PROVIDER",type:c.Type,providers:c.Responses.map(({ID:e,Addrs:a})=>({id:e,multiaddrs:a.map(f=>new bo.Multiaddr(f))}))};if(c.Type===5)return{from:c.ID,name:"VALUE",type:c.Type,value:M1(c.Extra,"base64pad")};if(c.Type===6){let e=c.Responses.map(({ID:a})=>a);if(!e.length)throw new Error("No peer found");return{name:"ADDING_PEER",type:c.Type,peer:e[0]}}if(c.Type===7)return{name:"DIALING_PEER",type:c.Type,peer:c.ID};throw new Error("Unknown DHT event type")};var EW=ne(c=>{async function*e(a,f={}){let d=await c.post("dht/findpeer",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers});for await(let b of d.ndjson())yield V2(b)}return e});s();x();var AW=ne(c=>{async function*e(a,f={}){let d=await c.post("dht/findprovs",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers});for await(let b of d.ndjson())yield V2(b)}return e});s();x();P7();var SW=ne(c=>{async function*e(a,f={}){let d=await c.post("dht/get",{signal:f.signal,searchParams:oe({arg:a instanceof Uint8Array?T4(a):a.toString(),...f}),headers:f.headers});for await(let b of d.ndjson())yield V2(b)}return e});s();x();var IW=ne(c=>{async function*e(a,f={recursive:!1}){let d=Array.isArray(a)?a:[a],b=await c.post("dht/provide",{signal:f.signal,searchParams:oe({arg:d.map(t=>t.toString()),...f}),headers:f.headers});for await(let t of b.ndjson())yield V2(t)}return e});s();x();P7();var LW=ne(c=>{async function*e(a,f,d={}){let b=new AbortController,t=vc(b.signal,d.signal),r=await c.post("dht/put",{signal:t,searchParams:oe({arg:a instanceof Uint8Array?T4(a):a.toString(),...d}),...await _c([f],b,d.headers)});for await(let o of r.ndjson())yield V2(o)}return e});s();x();var FW=ne(c=>{async function*e(a,f={}){let d=await c.post("dht/query",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers});for await(let b of d.ndjson())yield V2(b)}return e});function CW(c){return{findPeer:EW(c),findProvs:AW(c),get:SW(c),provide:IW(c),put:LW(c),query:FW(c)}}s();x();s();x();var RW=ne(c=>{async function e(a={}){return(await c.post("diag/cmds",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()}return e});s();x();var BW=ne(c=>{async function e(a={}){return(await c.post("diag/net",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()}return e});s();x();var PW=ne(c=>{async function e(a={}){return(await c.post("diag/sys",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()}return e});function TW(c){return{cmds:RW(c),net:BW(c),sys:PW(c)}}s();x();s();x();var OW=ne(c=>{async function e(a,f,d={}){await(await c.post("files/chmod",{signal:d.signal,searchParams:oe({arg:a,mode:f,...d}),headers:d.headers})).text()}return e});s();x();F0();var NW=ne(c=>{async function e(a,f,d={}){let b=Array.isArray(a)?a:[a];await(await c.post("files/cp",{signal:d.signal,searchParams:oe({arg:b.concat(f).map(r=>Re.asCID(r)?`/ipfs/${r}`:r),...d}),headers:d.headers})).text()}return e});s();x();F0();var MW=ne(c=>{async function e(a,f={}){if(!a||typeof a!="string")throw new Error("ipfs.files.flush requires a path");let b=await(await c.post("files/flush",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json();return Re.parse(b.Cid)}return e});s();x();F0();s();x();function to(c){let e=V0(c);return Object.prototype.hasOwnProperty.call(e,"mode")&&(e.mode=parseInt(e.mode,8)),Object.prototype.hasOwnProperty.call(e,"mtime")&&(e.mtime={secs:e.mtime,nsecs:e.mtimeNsecs||0},delete e.mtimeNsecs),e}var kW=ne(c=>{async function*e(a,f={}){if(!a)throw new Error("ipfs.files.ls requires a path");let d=await c.post("files/ls",{signal:f.signal,searchParams:oe({arg:Re.asCID(a)?`/ipfs/${a}`:a,long:!0,...f,stream:!0}),headers:f.headers});for await(let b of d.ndjson())if("Entries"in b)for(let t of b.Entries||[])yield DW(to(t));else yield DW(to(b))}return e});function DW(c){return c.hash&&(c.cid=Re.parse(c.hash)),delete c.hash,c.type=c.type===1?"directory":"file",c}s();x();var UW=ne(c=>{async function e(a,f={}){await(await c.post("files/mkdir",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).text()}return e});s();x();var qW=ne(c=>{async function e(a,f,d={}){Array.isArray(a)||(a=[a]),await(await c.post("files/mv",{signal:d.signal,searchParams:oe({arg:a.concat(f),...d}),headers:d.headers})).text()}return e});s();x();var jW=Fe(zW(),1),HW=ne(c=>{async function*e(a,f={}){let d=await c.post("files/read",{signal:f.signal,searchParams:oe({arg:a,count:f.length,...f}),headers:f.headers});yield*(0,jW.default)(d.body)}return e});s();x();var $W=Fe(mp(),1),VW=ne(c=>{async function e(a,f={}){let d=await c.post("files/rm",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),b=await d.text();if(b!==""){let t=new $W.default.HTTPError(d);throw t.message=b,t}}return e});s();x();F0();var Rp=ne(c=>{async function e(a,f={}){let b=await(await c.post("files/stat",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json();return b.WithLocality=b.WithLocality||!1,Yhe(to(b))}return e});function Yhe(c){return c.cid=Re.parse(c.hash),delete c.hash,c}s();x();var KW=ne(c=>{async function e(a,f={}){await(await c.post("files/touch",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).text()}return e});s();x();var QW=ne(c=>{async function e(a,f,d={}){let b=new AbortController,t=vc(b.signal,d.signal);await(await c.post("files/write",{signal:t,searchParams:oe({arg:a,streamChannels:!0,count:d.length,...d}),...await _c([{content:f,path:"arg",mode:yp(d.mode),mtime:wp(d.mtime)}],b,d.headers)})).text()}return e});function WW(c){return{chmod:OW(c),cp:NW(c),flush:MW(c),ls:kW(c),mkdir:UW(c),mv:qW(c),read:HW(c),rm:VW(c),stat:Rp(c),touch:KW(c),write:QW(c)}}s();x();s();x();var JW=Fe(Ed(),1),ZW=ne(c=>async(a,f,d={})=>{throw(0,JW.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});s();x();var YW=ne(c=>{async function e(a,f={type:"rsa",size:2048}){let b=await(await c.post("key/gen",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json();return V0(b)}return e});s();x();var XW=ne(c=>{async function e(a,f,d,b={}){let r=await(await c.post("key/import",{signal:b.signal,searchParams:oe({arg:a,pem:f,password:d,...b}),headers:b.headers})).json();return V0(r)}return e});s();x();var eJ=Fe(Ed(),1),aJ=ne(c=>async(a,f={})=>{throw(0,eJ.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});s();x();var cJ=ne(c=>{async function e(a={}){return((await(await c.post("key/list",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).Keys||[]).map(b=>V0(b))}return e});s();x();var fJ=ne(c=>{async function e(a,f,d={}){let b=await c.post("key/rename",{signal:d.signal,searchParams:oe({arg:[a,f],...d}),headers:d.headers});return V0(await b.json())}return e});s();x();var dJ=ne(c=>{async function e(a,f={}){let b=await(await c.post("key/rm",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json();return V0(b.Keys[0])}return e});function bJ(c){return{export:ZW(c),gen:YW(c),import:XW(c),info:aJ(c),list:cJ(c),rename:fJ(c),rm:dJ(c)}}s();x();s();x();var tJ=ne(c=>{async function e(a,f,d={}){let b=await c.post("log/level",{signal:d.signal,searchParams:oe({arg:[a,f],...d}),headers:d.headers});return V0(await b.json())}return e});s();x();var rJ=ne(c=>{async function e(a={}){return(await(await c.post("log/ls",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).Strings}return e});s();x();var nJ=ne(c=>{async function*e(a={}){yield*(await c.post("log/tail",{signal:a.signal,searchParams:oe(a),headers:a.headers})).ndjson()}return e});function iJ(c){return{level:tJ(c),ls:rJ(c),tail:nJ(c)}}s();x();s();x();var oJ=ne(c=>{async function e(a,f={}){let d=await c.post("name/publish",{signal:f.signal,searchParams:oe({arg:`${a}`,...f}),headers:f.headers});return V0(await d.json())}return e});s();x();var sJ=ne(c=>{async function*e(a,f={}){let d=await c.post("name/resolve",{signal:f.signal,searchParams:oe({arg:a,stream:!0,...f}),headers:f.headers});for await(let b of d.ndjson())yield b.Path}return e});s();x();s();x();var xJ=ne(c=>{async function e(a,f={}){let d=await c.post("name/pubsub/cancel",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers});return V0(await d.json())}return e});s();x();var lJ=ne(c=>{async function e(a={}){let f=await c.post("name/pubsub/state",{signal:a.signal,searchParams:oe(a),headers:a.headers});return V0(await f.json())}return e});s();x();var uJ=ne(c=>{async function e(a={}){return(await(await c.post("name/pubsub/subs",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).Strings||[]}return e});function hJ(c){return{cancel:xJ(c),state:lJ(c),subs:uJ(c)}}function pJ(c){return{publish:oJ(c),resolve:sJ(c),pubsub:hJ(c)}}s();x();s();x();F0();var mJ=ne(c=>{async function e(a,f={}){let b=await(await c.post("object/data",{signal:f.signal,searchParams:oe({arg:`${a instanceof Uint8Array?Re.decode(a):a}`,...f}),headers:f.headers})).arrayBuffer();return new Uint8Array(b,0,b.byteLength)}return e});s();x();F0();O4();var gJ=ne(c=>{async function e(a,f={}){let b=await(await c.post("object/get",{signal:f.signal,searchParams:oe({arg:`${a instanceof Uint8Array?Re.decode(a):a}`,dataEncoding:"base64",...f}),headers:f.headers})).json();return{Data:M1(b.Data,"base64pad"),Links:(b.Links||[]).map(t=>({Name:t.Name,Hash:Re.parse(t.Hash),Tsize:t.Size}))}}return e});s();x();F0();var yJ=ne(c=>{async function e(a,f={}){return((await(await c.post("object/links",{signal:f.signal,searchParams:oe({arg:`${a instanceof Uint8Array?Re.decode(a):a}`,...f}),headers:f.headers})).json()).Links||[]).map(t=>({Name:t.Name,Tsize:t.Size,Hash:Re.parse(t.Hash)}))}return e});s();x();F0();var wJ=ne(c=>{async function e(a={}){let f=await c.post("object/new",{signal:a.signal,searchParams:oe({arg:a.template,...a}),headers:a.headers}),{Hash:d}=await f.json();return Re.parse(d)}return e});s();x();var _J=(c,e)=>ne(f=>{let d=Cp(c,e);async function b(t,r={}){return d(t,{...r,storeCodec:"dag-pb",hashAlg:"sha2-256",version:1})}return b})(e);s();x();F0();var vJ=ne(c=>{async function e(a,f={}){let b=await(await c.post("object/stat",{signal:f.signal,searchParams:oe({arg:`${a}`,...f}),headers:f.headers})).json();return{...b,Hash:Re.parse(b.Hash)}}return e});s();x();s();x();F0();var EJ=ne(c=>{async function e(a,f,d={}){let b=await c.post("object/patch/add-link",{signal:d.signal,searchParams:oe({arg:[`${a}`,f.Name||f.name||"",(f.Hash||f.cid||"").toString()||null],...d}),headers:d.headers}),{Hash:t}=await b.json();return Re.parse(t)}return e});s();x();F0();var AJ=ne(c=>{async function e(a,f,d={}){let b=new AbortController,t=vc(b.signal,d.signal),r=await c.post("object/patch/append-data",{signal:t,searchParams:oe({arg:`${a}`,...d}),...await _c([f],b,d.headers)}),{Hash:o}=await r.json();return Re.parse(o)}return e});s();x();F0();var SJ=ne(c=>{async function e(a,f,d={}){let b=await c.post("object/patch/rm-link",{signal:d.signal,searchParams:oe({arg:[`${a}`,f.Name||f.name||null],...d}),headers:d.headers}),{Hash:t}=await b.json();return Re.parse(t)}return e});s();x();F0();var IJ=ne(c=>{async function e(a,f,d={}){let b=new AbortController,t=vc(b.signal,d.signal),r=await c.post("object/patch/set-data",{signal:t,searchParams:oe({arg:[`${a}`],...d}),...await _c([f],b,d.headers)}),{Hash:o}=await r.json();return Re.parse(o)}return e});function LJ(c){return{addLink:EJ(c),appendData:AJ(c),rmLink:SJ(c),setData:IJ(c)}}function FJ(c,e){return{data:mJ(e),get:gJ(e),links:yJ(e),new:wJ(e),put:_J(c,e),stat:vJ(e),patch:LJ(e)}}s();x();s();x();F0();s();x();var tt=Fe(Ed(),1);F0();async function*Bp(c){if(c==null)throw(0,tt.default)(new Error(`Unexpected input: ${c}`),"ERR_UNEXPECTED_INPUT");let e=Re.asCID(c);if(e){yield q1({cid:e});return}if(c instanceof String||typeof c=="string"){yield q1({path:c});return}if(c.cid!=null||c.path!=null)return yield q1(c);if(Symbol.iterator in c){let a=c[Symbol.iterator](),f=a.next();if(f.done)return a;if(Re.asCID(f.value)||f.value instanceof String||typeof f.value=="string"){yield q1({cid:f.value});for(let d of a)yield q1({cid:d});return}if(f.value.cid!=null||f.value.path!=null){yield q1(f.value);for(let d of a)yield q1(d);return}throw(0,tt.default)(new Error("Unexpected input: "+typeof c),"ERR_UNEXPECTED_INPUT")}if(Symbol.asyncIterator in c){let a=c[Symbol.asyncIterator](),f=await a.next();if(f.done)return a;if(Re.asCID(f.value)||f.value instanceof String||typeof f.value=="string"){yield q1({cid:f.value});for await(let d of a)yield q1({cid:d});return}if(f.value.cid!=null||f.value.path!=null){yield q1(f.value);for await(let d of a)yield q1(d);return}throw(0,tt.default)(new Error("Unexpected input: "+typeof c),"ERR_UNEXPECTED_INPUT")}throw(0,tt.default)(new Error("Unexpected input: "+typeof c),"ERR_UNEXPECTED_INPUT")}function q1(c){let e=c.cid||`${c.path}`;if(!e)throw(0,tt.default)(new Error("Unexpected input: Please path either a CID or an IPFS path"),"ERR_UNEXPECTED_INPUT");let a={path:e,recursive:c.recursive!==!1};return c.metadata!=null&&(a.metadata=c.metadata),a}var Pp=ne(c=>{async function*e(a,f={}){for await(let{path:d,recursive:b,metadata:t}of Bp(a)){let r=await c.post("pin/add",{signal:f.signal,searchParams:oe({...f,arg:d,recursive:b,metadata:t?JSON.stringify(t):void 0,stream:!0}),headers:f.headers});for await(let o of r.ndjson()){if(o.Pins){for(let n of o.Pins)yield Re.parse(n);continue}yield Re.parse(o)}}}return e});s();x();var CJ=Fe(fo(),1);function RJ(c){let e=Pp(c);return ne(()=>{async function a(f,d={}){return(0,CJ.default)(e([{path:f,...d}],d))}return a})(c)}s();x();F0();function BJ(c,e,a){let f={type:c,cid:Re.parse(e)};return a&&(f.metadata=a),f}var PJ=ne(c=>{async function*e(a={}){let f=[];a.paths&&(f=Array.isArray(a.paths)?a.paths:[a.paths]);let d=await c.post("pin/ls",{signal:a.signal,searchParams:oe({...a,arg:f.map(b=>`${b}`),stream:!0}),headers:a.headers});for await(let b of d.ndjson()){if(b.Keys){for(let t of Object.keys(b.Keys))yield BJ(b.Keys[t].Type,t,b.Keys[t].Metadata);return}yield BJ(b.Type,b.Cid,b.Metadata)}}return e});s();x();F0();var Tp=ne(c=>{async function*e(a,f={}){for await(let{path:d,recursive:b}of Bp(a)){let t=new URLSearchParams(f.searchParams);t.append("arg",`${d}`),b!=null&&t.set("recursive",String(b));let r=await c.post("pin/rm",{signal:f.signal,headers:f.headers,searchParams:oe({...f,arg:`${d}`,recursive:b})});for await(let o of r.ndjson()){if(o.Pins){yield*o.Pins.map(n=>Re.parse(n));continue}yield Re.parse(o)}}}return e});s();x();var TJ=Fe(fo(),1);var OJ=c=>{let e=Tp(c);return ne(()=>{async function a(f,d={}){return(0,TJ.default)(e([{path:f,...d}],d))}return a})(c)};s();x();s();x();s();x();F0();var Op=({Name:c,Status:e,Cid:a})=>({cid:Re.parse(a),name:c,status:e}),NJ=c=>{if(typeof c=="string"&&c!=="")return c;throw new TypeError("service name must be passed")},MJ=c=>{if(Re.asCID(c))return c.toString();throw new TypeError(`CID instance expected instead of ${typeof c}`)},rt=({service:c,cid:e,name:a,status:f,all:d})=>{let b=oe({service:NJ(c),name:a,force:d?!0:void 0});if(e)for(let t of e)b.append("cid",MJ(t));if(f)for(let t of f)b.append("status",t);return b},DJ=({cid:c,service:e,background:a,name:f,origins:d})=>{let b=oe({arg:MJ(c),service:NJ(e),name:f,background:a?!0:void 0});if(d)for(let t of d)b.append("origin",t.toString());return b};function kJ(c){async function e(a,{timeout:f,signal:d,headers:b,...t}){let r=await c.post("pin/remote/add",{timeout:f,signal:d,headers:b,searchParams:DJ({cid:a,...t})});return Op(await r.json())}return e}s();x();function UJ(c){async function*e({timeout:a,signal:f,headers:d,...b}){let t=await c.post("pin/remote/ls",{timeout:a,signal:f,headers:d,searchParams:rt(b)});for await(let r of t.ndjson())yield Op(r)}return e}s();x();function qJ(c){async function e({timeout:a,signal:f,headers:d,...b}){await c.post("pin/remote/rm",{timeout:a,signal:f,headers:d,searchParams:rt({...b,all:!1})})}return e}s();x();function GJ(c){async function e({timeout:a,signal:f,headers:d,...b}){await c.post("pin/remote/rm",{timeout:a,signal:f,headers:d,searchParams:rt({...b,all:!0})})}return e}s();x();s();x();s();x();function zJ(c){let e=String(c);if(e==="undefined")throw Error("endpoint is required");return e[e.length-1]==="/"?e.slice(0,-1):e}function jJ(c){return{service:c.Service,endpoint:new URL(c.ApiEndpoint),...c.Stat&&{stat:Xhe(c.Stat)}}}function Xhe(c){switch(c.Status){case"valid":{let{Pinning:e,Pinned:a,Queued:f,Failed:d}=c.PinCount;return{status:"valid",pinCount:{queued:f,pinning:e,pinned:a,failed:d}}}case"invalid":return{status:"invalid"};default:return{status:c.Status}}}function HJ(c){async function e(a,f){let{endpoint:d,key:b,headers:t,timeout:r,signal:o}=f;await c.post("pin/remote/service/add",{timeout:r,signal:o,searchParams:oe({arg:[a,zJ(d),b]}),headers:t})}return e}s();x();function $J(c){async function e(a={}){let{stat:f,headers:d,timeout:b,signal:t}=a,r=await c.post("pin/remote/service/ls",{timeout:b,signal:t,headers:d,searchParams:f===!0?oe({stat:f}):void 0}),{RemoteServices:o}=await r.json();return o.map(jJ)}return e}s();x();function VJ(c){async function e(a,f={}){await c.post("pin/remote/service/rm",{signal:f.signal,headers:f.headers,searchParams:oe({arg:a})})}return e}function KJ(c){let e=new T7(c);return{add:HJ(e),ls:$J(e),rm:VJ(e)}}function QJ(c){let e=new T7(c);return{add:kJ(e),ls:UJ(e),rm:qJ(e),rmAll:GJ(e),service:KJ(c)}}function WJ(c){return{addAll:Pp(c),add:RJ(c),ls:PJ(c),rmAll:Tp(c),rm:OJ(c),remote:QJ(c)}}s();x();s();x();s();x();O4();P7();zi();var Np=c=>Array.isArray(c)?c.map(epe):c,epe=c=>T4(Mp(c)),Mp=c=>Jh.decode(c),nt=c=>Jh.encode(M1(c));var JJ=ne(c=>{async function e(a={}){let{Strings:f}=await(await c.post("pubsub/ls",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json();return Np(f)||[]}return e});s();x();var ZJ=ne(c=>{async function e(a,f={}){let d=await c.post("pubsub/peers",{signal:f.signal,searchParams:oe({arg:nt(a),...f}),headers:f.headers}),{Strings:b}=await d.json();return b||[]}return e});s();x();var YJ=ne(c=>{async function e(a,f,d={}){let b=oe({arg:nt(a),...d}),t=new AbortController,r=vc(t.signal,d.signal);await(await c.post("pubsub/pub",{signal:r,searchParams:b,...await _c([f],t,d.headers)})).text()}return e});s();x();var XJ=Fe(uI(),1);var ape=(0,XJ.default)("ipfs-http-client:pubsub:subscribe"),eZ=(c,e)=>ne(a=>{async function f(d,b,t={}){t.signal=e.subscribe(d,b,t.signal);let r,o,n=new Promise((l,h)=>{r=l,o=h}),i=setTimeout(()=>r(),1e3);return a.post("pubsub/sub",{signal:t.signal,searchParams:oe({arg:nt(d),...t}),headers:t.headers}).catch(l=>{e.unsubscribe(d,b),o(l)}).then(l=>{clearTimeout(i),l&&(cpe(l,{onMessage:b,onEnd:()=>e.unsubscribe(d,b),onError:t.onError}),r())}),n}return f})(c);async function cpe(c,{onMessage:e,onEnd:a,onError:f}){f=f||ape;try{for await(let d of c.ndjson())try{if(!d.from)continue;e({from:d.from,data:Mp(d.data),seqno:Mp(d.seqno),topicIDs:Np(d.topicIDs)})}catch(b){b.message=`Failed to parse pubsub message: ${b.message}`,f(b,!1,d)}}catch(d){fpe(d)||f(d,!0)}finally{a()}}var fpe=c=>{switch(c.type){case"aborted":return!0;case"abort":return!0;default:return c.name==="AbortError"}};s();x();var aZ=(c,e)=>{async function a(f,d){e.unsubscribe(f,d)}return a};s();x();var Dp=class{constructor(){this._subs=new Map}subscribe(e,a,f){let d=this._subs.get(e)||[];if(d.find(t=>t.handler===a))throw new Error(`Already subscribed to ${e} with this handler`);let b=new AbortController;return this._subs.set(e,[{handler:a,controller:b}].concat(d)),f&&f.addEventListener("abort",()=>this.unsubscribe(e,a)),b.signal}unsubscribe(e,a){let f=this._subs.get(e)||[],d;a?(this._subs.set(e,f.filter(b=>b.handler!==a)),d=f.filter(b=>b.handler===a)):(this._subs.set(e,[]),d=f),(this._subs.get(e)||[]).length||this._subs.delete(e),d.forEach(b=>b.controller.abort())}};function cZ(c){let e=new Dp;return{ls:JJ(c),peers:ZJ(c),publish:YJ(c),subscribe:eZ(c,e),unsubscribe:aZ(c,e)}}s();x();F0();s();x();var fZ=ne(c=>{async function*e(a={}){yield*(await c.post("refs/local",{signal:a.signal,transform:V0,searchParams:oe(a),headers:a.headers})).ndjson()}return e});var dZ=ne((c,e)=>Object.assign(async function*(f,d={}){let b=Array.isArray(f)?f:[f];yield*(await c.post("refs",{signal:d.signal,searchParams:oe({arg:b.map(r=>`${r instanceof Uint8Array?Re.decode(r):r}`),...d}),headers:d.headers,transform:V0})).ndjson()},{local:fZ(e)}));s();x();s();x();F0();var bZ=ne(c=>{async function*e(a={}){yield*(await c.post("repo/gc",{signal:a.signal,searchParams:oe(a),headers:a.headers,transform:d=>({err:d.Error?new Error(d.Error):null,cid:(d.Key||{})["/"]?Re.parse(d.Key["/"]):null})})).ndjson()}return e});s();x();var kp=ne(c=>{async function e(a={}){let d=await(await c.post("repo/stat",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json();return{numObjects:BigInt(d.NumObjects),repoSize:BigInt(d.RepoSize),repoPath:d.RepoPath,version:d.Version,storageMax:BigInt(d.StorageMax)}}return e});s();x();var tZ=ne(c=>{async function e(a={}){return(await(await c.post("repo/version",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json()).Version}return e});function rZ(c){return{gc:bZ(c),stat:kp(c),version:tZ(c)}}s();x();s();x();var nZ=ne(c=>{async function*e(a={}){yield*(await c.post("stats/bw",{signal:a.signal,searchParams:oe(a),headers:a.headers,transform:d=>({totalIn:BigInt(d.TotalIn),totalOut:BigInt(d.TotalOut),rateIn:parseFloat(d.RateIn),rateOut:parseFloat(d.RateOut)})})).ndjson()}return e});function iZ(c){return{bitswap:_p(c),repo:kp(c),bw:nZ(c)}}s();x();s();x();var oZ=Fe(Yf(),1);var sZ=ne(c=>{async function e(a={}){let f=await c.post("swarm/addrs",{signal:a.signal,searchParams:oe(a),headers:a.headers}),{Addrs:d}=await f.json();return Object.keys(d).map(b=>({id:b,addrs:(d[b]||[]).map(t=>new oZ.Multiaddr(t))}))}return e});s();x();var xZ=ne(c=>{async function e(a,f={}){let d=await c.post("swarm/connect",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),{Strings:b}=await d.json();return b||[]}return e});s();x();var lZ=ne(c=>{async function e(a,f={}){let d=await c.post("swarm/disconnect",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),{Strings:b}=await d.json();return b||[]}return e});s();x();var uZ=Fe(Yf(),1);var hZ=ne(c=>{async function e(a={}){let f=await c.post("swarm/addrs/local",{signal:a.signal,searchParams:oe(a),headers:a.headers}),{Strings:d}=await f.json();return(d||[]).map(b=>new uZ.Multiaddr(b))}return e});s();x();var pZ=Fe(Yf(),1);var mZ=ne(c=>{async function e(a={}){let f=await c.post("swarm/peers",{signal:a.signal,searchParams:oe(a),headers:a.headers}),{Peers:d}=await f.json();return(d||[]).map(b=>({addr:new pZ.Multiaddr(b.Addr),peer:b.Peer,muxer:b.Muxer,latency:b.Latency,streams:b.Streams,direction:b.Direction==null?void 0:b.Direction===0?"inbound":"outbound"}))}return e});function gZ(c){return{addrs:sZ(c),connect:xZ(c),disconnect:lZ(c),localAddrs:hZ(c),peers:mZ(c)}}s();x();s();x();F0();var Up=ne(c=>{async function*e(a,f={}){let d=new AbortController,b=vc(d.signal,f.signal),{headers:t,body:r,total:o,parts:n}=await _c(a,d,f.headers),[i,l]=typeof f.progress=="function"?dpe(o,n,f.progress):[void 0,void 0],h=await c.post("add",{searchParams:oe({"stream-channels":!0,...f,progress:Boolean(i)}),onUploadProgress:l,signal:b,headers:t,body:r});for await(let u of h.ndjson())u=V0(u),u.hash!==void 0?yield tpe(u):i&&i(u.bytes||0,u.name)}return e}),dpe=(c,e,a)=>e?[void 0,bpe(c,e,a)]:[a,void 0],bpe=(c,e,a)=>{let f=0,d=e.length;return({loaded:b,total:t})=>{let r=Math.floor(b/t*c);for(;f<d;){let{start:o,end:n,name:i}=e[f];if(r<n){a(r-o,i);break}else a(n-o,i),f+=1}}};function tpe({name:c,hash:e,size:a,mode:f,mtime:d,mtimeNsecs:b}){let t={path:c,cid:Re.parse(e),size:parseInt(a)};return f!=null&&(t.mode=parseInt(f,8)),d!=null&&(t.mtime={secs:d,nsecs:b||0}),t}var TZ=Fe(fo(),1);s();x();s();x();var vZ=Fe(Ed(),1);O4();var EZ=Fe(D4(),1),AZ=Fe(_Z(),1),SZ=Fe(Zi(),1),IZ=Fe(pp(),1),LZ=Fe(BI(),1);async function*qp(c){yield c}async function FZ(c){if(H2(c))return qp(JI(c));if(typeof c=="string"||c instanceof String)return qp(JI(c.toString()));if(Z3(c))return(0,AZ.default)(c);if(Y3(c)&&(c=(0,EZ.default)(c)),Symbol.iterator in c||Symbol.asyncIterator in c){let e=(0,SZ.default)(c),{value:a,done:f}=await e.peek();if(f)return qp(new Uint8Array(0));if(e.push(a),Number.isInteger(a))return qp(Uint8Array.from(await(0,IZ.default)(e)));if(H2(a)||typeof a=="string"||a instanceof String)return(0,LZ.default)(e,JI)}throw(0,vZ.default)(new Error(`Unexpected input: ${c}`),"ERR_UNEXPECTED_INPUT")}function JI(c){return c instanceof Uint8Array?c:ArrayBuffer.isView(c)?new Uint8Array(c.buffer,c.byteOffset,c.byteLength):c instanceof ArrayBuffer?new Uint8Array(c):Array.isArray(c)?Uint8Array.from(c):M1(c.toString())}s();x();var zp=Fe(Ed(),1),CZ=Fe(D4(),1),RZ=Fe(Zi(),1);async function*BZ(c,e){if(c==null)throw(0,zp.default)(new Error(`Unexpected input: ${c}`),"ERR_UNEXPECTED_INPUT");if(typeof c=="string"||c instanceof String){yield Gp(c.toString(),e);return}if(H2(c)||Z3(c)){yield Gp(c,e);return}if(Y3(c)&&(c=(0,CZ.default)(c)),Symbol.iterator in c||Symbol.asyncIterator in c){let a=(0,RZ.default)(c),{value:f,done:d}=await a.peek();if(d){yield{content:[]};return}if(a.push(f),Number.isInteger(f)||H2(f)||typeof f=="string"||f instanceof String){yield Gp(a,e);return}throw(0,zp.default)(new Error("Unexpected input: multiple items passed - if you are using ipfs.add, please use ipfs.addAll instead"),"ERR_UNEXPECTED_INPUT")}if(Yi(c)){yield Gp(c,e);return}throw(0,zp.default)(new Error('Unexpected input: cannot convert "'+typeof c+'" into ImportCandidate'),"ERR_UNEXPECTED_INPUT")}async function Gp(c,e){let{path:a,mode:f,mtime:d,content:b}=c,t={path:a||"",mode:Lp(f),mtime:Fp(d)};return b?t.content=await e(b):a||(t.content=await e(c)),t}function PZ(c){return BZ(c,FZ)}function OZ(c){let e=Up(c);return ne(()=>{async function a(f,d={}){return await(0,TZ.default)(e(PZ(f),d))}return a})(c)}s();x();var NZ=ne(c=>{async function*e(a,f={}){yield*(await c.post("cat",{signal:f.signal,searchParams:oe({arg:a.toString(),...f}),headers:f.headers})).iterator()}return e});s();x();var MZ=ne(c=>async(a={})=>(await c.post("commands",{signal:a.signal,searchParams:oe(a),headers:a.headers})).json());s();x();var DZ=ne(c=>async(a,f={})=>(await(await c.post("dns",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers})).json()).Path);s();x();var kZ=ne(c=>()=>{let e=new URL(c.opts.base||"");return{host:e.hostname,port:e.port,protocol:e.protocol,pathname:e.pathname,"api-path":e.pathname}});s();x();F0();var UZ=ne(c=>{async function*e(a,f={}){let d={arg:`${a instanceof Uint8Array?Re.decode(a):a}`,...f};d.compressionLevel&&(d["compression-level"]=d.compressionLevel,delete d.compressionLevel),yield*(await c.post("get",{signal:f.signal,searchParams:oe(d),headers:f.headers})).iterator()}return e});s();x();var qZ=Fe(Yf(),1);var jp=ne(c=>{async function e(a={}){let d=await(await c.post("id",{signal:a.signal,searchParams:oe({arg:a.peerId?a.peerId.toString():void 0,...a}),headers:a.headers})).json(),b={...V0(d)};return b.addresses&&(b.addresses=b.addresses.map(t=>new qZ.Multiaddr(t))),b}return e});s();x();var GZ=c=>{let e=jp(c);async function a(f={}){let d=await e(f);return Boolean(d&&d.addresses&&d.addresses.length)}return a};s();x();F0();var zZ=ne((c,e)=>{async function*a(f,d={}){let b=`${f instanceof Uint8Array?Re.decode(f):f}`;async function t(o){let n=o.Hash;if(n.includes("/")){let l=n.startsWith("/ipfs/")?n:`/ipfs/${n}`;n=(await Rp(e)(l)).cid}else n=Re.parse(n);let i={name:o.Name,path:b+(o.Name?`/${o.Name}`:""),size:o.Size,cid:n,type:npe(o)};return o.Mode&&(i.mode=parseInt(o.Mode,8)),o.Mtime!==void 0&&o.Mtime!==null&&(i.mtime={secs:o.Mtime},o.MtimeNsecs!==void 0&&o.MtimeNsecs!==null&&(i.mtime.nsecs=o.MtimeNsecs)),i}let r=await c.post("ls",{signal:d.signal,searchParams:oe({arg:b,...d}),headers:d.headers});for await(let o of r.ndjson()){if(o=o.Objects,!o)throw new Error("expected .Objects in results");if(o=o[0],!o)throw new Error("expected one array in results.Objects");let n=o.Links;if(!Array.isArray(n))throw new Error("expected one array in results.Objects[0].Links");if(!n.length){yield t(o);return}yield*n.map(t)}}return a});function npe(c){switch(c.Type){case 1:case 5:return"dir";case 2:return"file";default:return"file"}}s();x();var jZ=ne(c=>{async function e(a={}){let f=await c.post("dns",{signal:a.signal,searchParams:oe(a),headers:a.headers});return V0(await f.json())}return e});s();x();var HZ=ne(c=>{async function*e(a,f={}){yield*(await c.post("ping",{signal:f.signal,searchParams:oe({arg:`${a}`,...f}),headers:f.headers,transform:V0})).ndjson()}return e});s();x();var $Z=ne(c=>{async function e(a,f={}){let d=await c.post("resolve",{signal:f.signal,searchParams:oe({arg:a,...f}),headers:f.headers}),{Path:b}=await d.json();return b}return e});s();x();var VZ=Fe(Ed(),1),KZ=ne(c=>async(a={})=>{throw(0,VZ.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});s();x();var QZ=ne(c=>{async function e(a={}){await(await c.post("shutdown",{signal:a.signal,searchParams:oe(a),headers:a.headers})).text()}return e});s();x();var WZ=ne(c=>{async function e(a={}){let f=await c.post("version",{signal:a.signal,searchParams:oe(a),headers:a.headers});return{...V0(await f.json()),"ipfs-http-client":"1.0.0"}}return e});var lpe=Fe(JZ(),1);F0();var upe=Fe(Yf(),1),hpe=Fe(YZ(),1);function XZ(c={}){let e={name:Yh.name,code:Yh.code,encode:n=>n,decode:n=>n},a=Object.values(ji);(c.ipld&&c.ipld.bases?c.ipld.bases:[]).forEach(n=>a.push(n));let f=new Sh({bases:a,loadBase:c.ipld&&c.ipld.loadBase}),d=Object.values(T$);[cS,wS,RS,xpe,e].concat(c.ipld&&c.ipld.codecs||[]).forEach(n=>d.push(n));let b=new Ih({codecs:d,loadCodec:c.ipld&&c.ipld.loadCodec}),t=Object.values(P$);(c.ipld&&c.ipld.hashers?c.ipld.hashers:[]).forEach(n=>t.push(n));let r=new Lh({hashers:t,loadHasher:c.ipld&&c.ipld.loadHasher});return{add:OZ(c),addAll:Up(c),bitswap:RK(c),block:VQ(c),bootstrap:fW(c),cat:NZ(c),commands:MZ(c),config:sW(c),dag:vW(b,c),dht:CW(c),diag:TW(c),dns:DZ(c),files:WW(c),get:UZ(c),getEndpointConfig:kZ(c),id:jp(c),isOnline:GZ(c),key:bJ(c),log:iJ(c),ls:zZ(c),mount:jZ(c),name:pJ(c),object:FJ(b,c),pin:WJ(c),ping:HZ(c),pubsub:cZ(c),refs:dZ(c),repo:rZ(c),resolve:$Z(c),start:KZ(c),stats:iZ(c),stop:QZ(c),swarm:gZ(c),version:WZ(c),bases:f,codecs:b,hashers:r}}var D7=class{constructor(e){this.ipfsUrl=e}async load(e){return await eY(e,this.ipfsUrl).load(e)}},Hp=class{async load(e){return(await Qf.get(e,{responseType:"arraybuffer"})).data}},$p=class{constructor(e){this.url=e;this.client=XZ({url:this.url})}client;async load(e){let a=new URL(e),f=this.client.cat(a.host),d=Uint8Array.from([]);for await(let b of f)d=Uint8Array.from(b);return d}};function eY(c,e){let a=new URL(c);switch(a.protocol){case"http:":case"https:":return new Hp;case"ipfs:":return new $p(e);default:throw new Error(`loader for ${a.protocol} is not supported`)}}s();x();s();x();s();x();var aY=40,cY=64,fY=64,dY=32,ppe="empty auth claim mtp proof",mpe="empty auth claim non-revocation mtp proof",gpe="empty challenge signature",ype="empty claim signature",wpe="empty claim mtp proof",_pe="empty claim non-revocation mtp proof",vpe="empty user state in relay claim non-revocation mtp proof",Epe="empty issuer auth claim mtp proof",Ape="empty issuer auth claim non-revocation mtp proof",f2=class{mtLevel;valueArraySize;mtLevelOnChain;mtLevelClaimsMerklization;getMTLevel(){return this.mtLevel?this.mtLevel:aY}getMTLevelsClaimMerklization(){return this.mtLevelClaimsMerklization?this.mtLevelClaimsMerklization:dY}getValueArrSize(){return this.valueArraySize?this.valueArraySize:cY}getMTLevelOnChain(){return this.mtLevelOnChain?this.mtLevelOnChain:fY}},tc=c=>{if(!c)return b0;let e=new ac;return e.value=D6(R0.decodeString(c)),e},ZI=(c,e,a,f)=>({state:tc(c),claimsRoot:tc(e),revocationRoot:tc(a),rootOfRoots:tc(f)}),$c=(c,e)=>{let a=c.allSiblings?c.allSiblings():c.siblings;for(let f=a.length;f<e;f++)a.push(b0);return a.map(f=>typeof f=="string"?f:f.bigInt().toString())},ro=(c,e)=>{if(c||(c=[]),c.length>e)throw new Error(`array size ${c.length} is bigger max expected size ${e}`);for(let a=c.length;a<e;a++)c.push(BigInt(0));return c},no=c=>c.map(e=>e.toString()),d2=c=>c?.existence?{key:b0,value:b0,noAux:"0"}:c?.nodeAux?.value!==void 0&&c?.nodeAux?.key!==void 0?{key:c.nodeAux.key,value:c.nodeAux.value,noAux:"0"}:{key:b0,value:b0,noAux:"1"},io=c=>c?0:1;function Spe(c){let e={};for(let a in c)c.hasOwnProperty(a)&&!a.startsWith("_")&&(e[a]=c[a]);return e}s();x();s();x();var bY=(r=>(r[r.NOOP=0]="NOOP",r[r.EQ=1]="EQ",r[r.LT=2]="LT",r[r.GT=3]="GT",r[r.IN=4]="IN",r[r.NIN=5]="NIN",r[r.NE=6]="NE",r))(bY||{}),K2={$noop:0,$eq:1,$lt:2,$gt:3,$in:4,$nin:5,$ne:6},Vp=class{constructor(e,a){this.x=e;this.y=a}compare(e){switch(e){case 1:return this.x===this.y;case 2:return this.x<this.y;case 3:return this.x>this.y;case 6:return this.x!==this.y;default:throw new Error("unknown compare type for scalar")}}},Kp=class{constructor(e,a){this.x=e;this.y=a}compare(e){switch(e){case 4:return this.y.includes(this.x);case 5:return!this.y.includes(this.x);default:throw new Error("unknown compare type for vector")}}},Ipe=(c,e,a)=>{switch(a){case 1:case 2:case 3:case 6:if(e.length!==1)throw new Error("currently we support only one value for scalar comparison");return new Vp(c,e[0]);case 4:case 5:return new Kp(c,e);default:throw new Error("unknown compare type")}};var it=class{slotIndex;values;operator;valueProof;validate(){if(this.operator!==K2.$noop&&this.values.some(e=>typeof e!="bigint"))throw new Error(G4.EmptyQueryValue)}},Qp=(d=>(d.AuthV2="authV2",d.StateTransition="stateTransition",d.AtomicQueryMTPV2="credentialAtomicQueryMTPV2",d.AtomicQuerySigV2="credentialAtomicQuerySigV2",d))(Qp||{}),oo=class{issuerId;claim;treeState;proof;nonRevProof;signatureProof},G4=(L=>(L.EmptyAuthClaimProof="empty auth claim mtp proof",L.EmptyAuthClaimProofInTheNewState="empty auth claim mtp proof in the new state",L.EmptyAuthClaimNonRevProof="empty auth claim non-revocation mtp proof",L.EmptyChallengeSignature="empty challenge signature",L.EmptyClaimSignature="empty claim signature",L.EmptyClaimProof="empty claim mtp proof",L.EmptyClaimNonRevProof="empty claim non-revocation mtp proof",L.EmptyIssuerAuthClaimProof="empty issuer auth claim mtp proof",L.EmptyIssuerAuthClaimNonRevProof="empty issuer auth claim non-revocation mtp proof",L.EmptyJsonLDQueryProof="empty JSON-LD query mtp proof",L.EmptyJsonLDQueryValue="empty JSON-LD query value",L.EmptyJsonLDQueryPath="empty JSON-LD query path",L.EmptyQueryValue="empty query value",L.EmptyJsonLDQueryValues="empty JSON-LD query values",L.EmptyId="empty Id",L.EmptyChallenge="empty challenge",L.EmptyGlobalProof="empty global identity mtp proof",L.EmptyRequestID="empty request ID",L))(G4||{}),e8=class{path;value;mtp;constructor(){this.path=BigInt(0),this.value=BigInt(0),this.mtp=new Gd}validate(){if(typeof this.path!="bigint")throw new Error("empty JSON-LD query path");if(typeof this.value!="bigint")throw new Error("empty JSON-LD query value");if(!this.mtp)throw new Error("empty JSON-LD query mtp proof")}};s();x();var so=class extends f2{id;profileNonce;claimSubjectProfileNonce;claim;skipClaimRevocationCheck;requestID;currentTimeStamp;query;validate(){if(!this.requestID)throw new Error("empty request ID")}inputsMarshal(){this.validate(),this.query.valueProof&&(this.query.validate(),this.query.valueProof.validate());let e=this.query.valueProof??new e8,a={requestID:this.requestID.toString(),userGenesisID:this.id.bigInt().toString(),profileNonce:this.profileNonce.toString(),claimSubjectProfileNonce:this.claimSubjectProfileNonce.toString(),issuerID:this.claim.issuerID?.bigInt().toString(),issuerClaim:this.claim.claim.marshalJson(),issuerClaimMtp:$c(this.claim.incProof.proof,this.getMTLevel()),issuerClaimClaimsTreeRoot:this.claim.incProof.treeState?.claimsRoot.bigInt().toString(),issuerClaimRevTreeRoot:this.claim.incProof.treeState?.revocationRoot.bigInt().toString(),issuerClaimRootsTreeRoot:this.claim.incProof.treeState?.rootOfRoots.bigInt().toString(),issuerClaimIdenState:this.claim.incProof.treeState?.state.bigInt().toString(),issuerClaimNonRevMtp:$c(this.claim.nonRevProof.proof,this.getMTLevel()),issuerClaimNonRevClaimsTreeRoot:this.claim.nonRevProof.treeState?.claimsRoot.bigInt().toString(),issuerClaimNonRevRevTreeRoot:this.claim.nonRevProof.treeState?.revocationRoot.bigInt().toString(),issuerClaimNonRevRootsTreeRoot:this.claim.nonRevProof.treeState?.rootOfRoots.bigInt().toString(),issuerClaimNonRevState:this.claim.nonRevProof.treeState?.state.bigInt().toString(),claimSchema:this.claim.claim.getSchemaHash().bigInt().toString(),claimPathMtp:$c(e.mtp,this.getMTLevelsClaimMerklization()),claimPathValue:e.value.toString(),operator:this.query.operator,slotIndex:this.query.slotIndex,timestamp:this.currentTimeStamp},f=d2(this.claim.nonRevProof.proof);a.issuerClaimNonRevMtpAuxHi=f.key.bigInt().toString(),a.issuerClaimNonRevMtpAuxHv=f.value.bigInt().toString(),a.issuerClaimNonRevMtpNoAux=f.noAux,a.claimPathNotExists=io(e.mtp.existence);let d=d2(e.mtp);a.claimPathMtpNoAux=d.noAux,a.claimPathMtpAuxHi=d.key.bigInt().toString(),a.claimPathMtpAuxHv=d.value.bigInt().toString(),a.claimPathKey=e.path.toString(),this.skipClaimRevocationCheck?a.isRevocationChecked=0:a.isRevocationChecked=1;let b=ro(this.query.values,this.getValueArrSize());return a.value=no(b),new TextEncoder().encode(JSON.stringify(a))}},YI=class extends f2{requestID;userID;issuerID;issuerClaimIdenState;issuerClaimNonRevState;claimSchema;slotIndex;operator;value=[];timestamp;merklized;claimPathKey;claimPathNotExists;isRevocationChecked;pubSignalsUnmarshal(e){let f=JSON.parse(new TextDecoder().decode(e));if(f.length!==13+this.getValueArrSize())throw new Error(`invalid number of Output values expected ${13+this.getValueArrSize()} got ${f.length}`);let d=0;this.merklized=parseInt(f[d]),d++,this.userID=Z0.fromBigInt(BigInt(f[d])),d++,this.requestID=BigInt(f[d]),d++,this.issuerID=Z0.fromBigInt(BigInt(f[d])),d++,this.issuerClaimIdenState=kd(f[d]),d++,this.isRevocationChecked=parseInt(f[d]),d++,this.issuerClaimNonRevState=kd(f[d]),d++,this.timestamp=parseInt(f[d]),d++,this.claimSchema=kc.newSchemaHashFromInt(BigInt(f[d])),d++,this.claimPathNotExists=parseInt(f[d]),d++,this.claimPathKey=BigInt(f[d]),d++,this.slotIndex=parseInt(f[d]),d++,this.operator=parseInt(f[d]),d++;for(let b=0;b<this.getValueArrSize();b++)this.value.push(BigInt(f[d])),d++;return this}};s();x();var xo=class extends f2{requestID;id;profileNonce;claimSubjectProfileNonce;claim;skipClaimRevocationCheck;currentTimeStamp;query;validate(){if(!this.requestID)throw new Error("empty request ID");if(!this.claim.nonRevProof.proof)throw new Error("empty claim non-revocation mtp proof");if(!this.claim.signatureProof.issuerAuthIncProof.proof)throw new Error("empty issuer auth claim mtp proof");if(!this.claim.signatureProof.issuerAuthNonRevProof.proof)throw new Error("empty issuer auth claim non-revocation mtp proof");if(!this.claim.signatureProof.signature)throw new Error("empty claim signature");if(!this.query.values&&this.query.operator!==K2.$noop)throw new Error("empty query value")}inputsMarshal(){this.validate(),this.query.valueProof&&(this.query.validate(),this.query.valueProof.validate());let e=this.query.valueProof??new e8,a={requestID:this.requestID.toString(),userGenesisID:this.id.bigInt().toString(),profileNonce:this.profileNonce.toString(),claimSubjectProfileNonce:this.claimSubjectProfileNonce.toString(),issuerID:this.claim.issuerID.bigInt().toString(),issuerClaim:this.claim.claim.marshalJson(),issuerClaimNonRevClaimsTreeRoot:this.claim.nonRevProof.treeState?.claimsRoot.bigInt().toString(),issuerClaimNonRevRevTreeRoot:this.claim.nonRevProof.treeState?.revocationRoot.bigInt().toString(),issuerClaimNonRevRootsTreeRoot:this.claim.nonRevProof.treeState?.rootOfRoots.bigInt().toString(),issuerClaimNonRevState:this.claim.nonRevProof.treeState?.state.bigInt().toString(),issuerClaimNonRevMtp:$c(this.claim.nonRevProof.proof,this.getMTLevel()),issuerClaimSignatureR8x:this.claim.signatureProof.signature.R8[0].toString(),issuerClaimSignatureR8y:this.claim.signatureProof.signature.R8[1].toString(),issuerClaimSignatureS:this.claim.signatureProof.signature.S.toString(),issuerAuthClaim:this.claim.signatureProof.issuerAuthClaim?.marshalJson(),issuerAuthClaimMtp:$c(this.claim.signatureProof.issuerAuthIncProof.proof,this.getMTLevel()),issuerAuthClaimsTreeRoot:this.claim.signatureProof.issuerAuthIncProof.treeState?.claimsRoot.bigInt().toString(),issuerAuthRevTreeRoot:this.claim.signatureProof.issuerAuthIncProof.treeState?.revocationRoot.bigInt().toString(),issuerAuthRootsTreeRoot:this.claim.signatureProof.issuerAuthIncProof.treeState?.rootOfRoots.bigInt().toString(),issuerAuthClaimNonRevMtp:$c(this.claim.signatureProof.issuerAuthNonRevProof.proof,this.getMTLevel()),claimSchema:this.claim.claim.getSchemaHash().bigInt().toString(),claimPathMtp:$c(e.mtp,this.getMTLevelsClaimMerklization()),claimPathValue:e.value.toString(),operator:this.query.operator,timestamp:this.currentTimeStamp,slotIndex:this.query.slotIndex};this.skipClaimRevocationCheck?a.isRevocationChecked=0:a.isRevocationChecked=1;let f=d2(this.claim.nonRevProof.proof);a.issuerClaimNonRevMtpAuxHi=f.key.bigInt().toString(),a.issuerClaimNonRevMtpAuxHv=f.value.bigInt().toString(),a.issuerClaimNonRevMtpNoAux=f.noAux;let d=d2(this.claim.signatureProof.issuerAuthNonRevProof.proof);a.issuerAuthClaimNonRevMtpAuxHi=d.key.bigInt().toString(),a.issuerAuthClaimNonRevMtpAuxHv=d.value.bigInt().toString(),a.issuerAuthClaimNonRevMtpNoAux=d.noAux,a.claimPathNotExists=io(e.mtp.existence);let b=d2(e.mtp);a.claimPathMtpNoAux=b.noAux,a.claimPathMtpAuxHi=b.key.bigInt().toString(),a.claimPathMtpAuxHv=b.value.bigInt().toString(),a.claimPathKey=e.path.toString(),this.skipClaimRevocationCheck?a.isRevocationChecked=0:a.isRevocationChecked=1;let t=ro(this.query.values,this.getValueArrSize());return a.value=no(t),new TextEncoder().encode(JSON.stringify(a))}},XI=class extends f2{requestID;userID;issuerID;issuerAuthState;issuerClaimNonRevState;claimSchema;slotIndex;operator;value=[];timestamp;merklized;claimPathKey;claimPathNotExists;isRevocationChecked;pubSignalsUnmarshal(e){let f=JSON.parse(new TextDecoder().decode(e));if(f.length!==13+this.getValueArrSize())throw new Error(`invalid number of Output values expected ${13+this.getValueArrSize()} got ${f.length}`);let d=0;this.merklized=parseInt(f[d]),d++,this.userID=Z0.fromBigInt(BigInt(f[d])),d++,this.issuerAuthState=kd(f[d]),d++,this.requestID=BigInt(f[d]),d++,this.issuerID=Z0.fromBigInt(BigInt(f[d])),d++,this.isRevocationChecked=parseInt(f[d]),d++,this.issuerClaimNonRevState=kd(f[d]),d++,this.timestamp=parseInt(f[d]),d++,this.claimSchema=kc.newSchemaHashFromInt(BigInt(f[d])),d++,this.claimPathNotExists=parseInt(f[d]),d++,this.claimPathKey=BigInt(f[d]),d++,this.slotIndex=parseInt(f[d]),d++,this.operator=parseInt(f[d]),d++;for(let b=0;b<this.getValueArrSize();b++)this.value.push(BigInt(f[d])),d++;return this}};s();x();var lo=class extends f2{genesisID;profileNonce;authClaim;authClaimIncMtp;authClaimNonRevMtp;treeState;gistProof;signature;challenge;validate(){if(!this.genesisID)throw new Error("empty Id");if(!this.authClaimIncMtp)throw new Error("empty auth claim mtp proof");if(!this.authClaimNonRevMtp)throw new Error("empty auth claim non-revocation mtp proof");if(!this.gistProof?.proof)throw new Error("empty global identity mtp proof");if(!this.signature)throw new Error("empty challenge signature");if(!this.challenge)throw new Error("empty challenge")}inputsMarshal(){this.validate();let e={genesisID:this.genesisID?.bigInt().toString(),profileNonce:this.profileNonce?.toString(),authClaim:this.authClaim?.marshalJson(),authClaimIncMtp:$c(this.authClaimIncMtp,this.getMTLevel()),authClaimNonRevMtp:$c(this.authClaimNonRevMtp,this.getMTLevel()),challenge:this.challenge?.toString(),challengeSignatureR8x:this.signature?.R8[0].toString(),challengeSignatureR8y:this.signature?.R8[1].toString(),challengeSignatureS:this.signature?.S.toString(),claimsTreeRoot:this.treeState?.claimsRoot.bigInt().toString(),revTreeRoot:this.treeState?.revocationRoot.bigInt().toString(),rootsTreeRoot:this.treeState?.rootOfRoots.bigInt().toString(),state:this.treeState?.state.bigInt().toString(),gistRoot:this.gistProof.root.bigInt().toString(),gistMtp:$c(this.gistProof.proof,this.getMTLevelOnChain())},a=d2(this.authClaimNonRevMtp);e.authClaimNonRevMtpAuxHi=a.key.bigInt().toString(),e.authClaimNonRevMtpAuxHv=a.value.bigInt().toString(),e.authClaimNonRevMtpNoAux=a.noAux;let f=d2(this.gistProof.proof);return e.gistMtpAuxHi=f.key.bigInt().toString(),e.gistMtpAuxHv=f.value.bigInt().toString(),e.gistMtpNoAux=f.noAux,new TextEncoder().encode(JSON.stringify(e))}},uo=class{userID;challenge;GISTRoot;pubSignalsUnmarshal(e){let f=JSON.parse(new TextDecoder().decode(e));if(f.length!==3)throw new Error(`invalid number of Output values expected ${3} got ${f.length}`);return this.userID=Z0.fromBigInt(BigInt(f[0])),this.challenge=BigInt(f[1]),this.GISTRoot=kd(f[2]),this}};s();x();var ho=class extends f2{id;oldTreeState;newTreeState;isOldStateGenesis;authClaim;authClaimNewStateIncProof;signature;inputsMarshal(){if(!this.authClaim.incProof.proof)throw new Error("empty auth claim mtp proof");if(!this.authClaimNewStateIncProof)throw new Error("empty auth claim mtp proof in the new state");if(!this.authClaim.nonRevProof.proof)throw new Error("empty auth claim non-revocation mtp proof");let e={authClaim:this.authClaim.claim.marshalJson(),authClaimMtp:$c(this.authClaim.incProof.proof,this.getMTLevel()),authClaimNonRevMtp:$c(this.authClaim.nonRevProof.proof,this.getMTLevel()),newAuthClaimMtp:$c(this.authClaimNewStateIncProof,this.getMTLevel()),userID:this.id.bigInt().toString(),newUserState:this.newTreeState.state.bigInt().toString(),claimsTreeRoot:this.oldTreeState.claimsRoot.bigInt().toString(),oldUserState:this.oldTreeState.state.bigInt().toString(),revTreeRoot:this.oldTreeState.revocationRoot.bigInt().toString(),rootsTreeRoot:this.oldTreeState.rootOfRoots.bigInt().toString(),signatureR8x:this.signature.R8[0].toString(),signatureR8y:this.signature.R8[1].toString(),signatureS:this.signature.S.toString(),newClaimsTreeRoot:this.newTreeState.claimsRoot.bigInt().toString(),newRootsTreeRoot:this.newTreeState.rootOfRoots.bigInt().toString(),newRevTreeRoot:this.newTreeState.revocationRoot.bigInt().toString()};this.isOldStateGenesis?e.isOldStateGenesis="1":e.isOldStateGenesis="0";let a=d2(this.authClaim.nonRevProof.proof);return e.authClaimNonRevMtpAuxHi=a.key.bigInt().toString(),e.authClaimNonRevMtpAuxHv=a.value.bigInt().toString(),e.authClaimNonRevMtpNoAux=a.noAux,new TextEncoder().encode(JSON.stringify(e))}},po=class{userId;oldUserState;newUserState;isOldStateGenesis;pubSignalsUnmarshal(e){let a=JSON.parse(new TextDecoder().decode(e)),f=4;if(a.length!==f)throw new Error(`invalid number of Output values expected ${f} got ${a.length}`);return this.userId=Z0.fromBigInt(BigInt(a[0])),this.oldUserState=kd(a[1]),this.newUserState=kd(a[2]),this.isOldStateGenesis=BigInt(a[3])===BigInt(1),this}};var z4=class{constructor(e=b0,a=[]){this.hash=e;this.children=a}nodeType(){return this.children.length===2?1:this.children.length===3&&this.children[2].hex()===Y0(BigInt(1)).hex()?2:this.children.length===3?3:0}toJSON(){return{hash:this.hash.hex(),children:this.children.map(e=>e.hex())}}static fromHex(e){return new z4(tc(e.hash),e.children.map(a=>tc(a)))}};async function tY(c,e,a){let f=await a.getLatestStateById(c.id.bigInt()),d=Y0(BigInt(e.revocationNonce??0)),b=Y0(BigInt(f?.state??0));return Lpe(d,b,e.id)}async function Lpe(c,e,a){if(!a)throw new Error("HTTP reverse hash service URL is not specified");let f=(await Qf.get(`${a}/node/${e.hex()}`)).data?.node;if(f.children.length!==3)throw new Error("state should has tree children");let d=e.hex(),b=f.children[0],t=f.children[1],r=f.children[2],o=tc(t);return{mtp:await Cpe(o,c,`${a}/node`),issuer:{state:d,claimsTreeRoot:b,revocationTreeRoot:t,rootOfRoots:r}}}async function Fpe(c,e,a){let f=new Gd;f.existence=c,f.nodeAux=a,f.depth=e.length;for(let d=0;d<e.length;d++){let b=e[d];JSON.stringify(e[d])!==JSON.stringify(b0)&&(k6(f.notEmpties,d),f.siblings.push(b))}return f}async function Cpe(c,e,a){let f=!1,d=[],b,t=()=>Fpe(f,d,b),r=c;for(let o=0;o<e.bytes.length*8;o++){if(r.bytes.every(l=>l===0))return t();let n=(await Qf.get(`${a}/${r.hex()}`)).data?.node,i=z4.fromHex(n);switch(i.nodeType()){case 2:return e.bytes.every((l,h)=>l===i.children[0].bytes[h])?(f=!0,t()):(b={key:i.children[0],value:i.children[1]},t());case 1:on(e.bytes,o)?(r=i.children[1],d.push(i.children[0])):(r=i.children[0],d.push(i.children[1]));break;default:throw new Error(`found unexpected node type in tree ${i.hash.hex()}`)}}throw new Error("tree depth is too high")}async function rY(c,e,a,f){let d=new eL;f&&await Ppe(d,e,f),await Bpe(d,e),c.bytes.every(b=>b===0)||d.addProofNode(new z4(c,[await e.claimsTree.root(),await e.revocationTree.root(),await e.rootsTree.root()])),d.nodes.length>0&&await Rpe(d.nodes,a)}async function Rpe(c,e){let a=c.map(f=>f.toJSON());return await(await Qf.post(e+"/node",a)).status===200}async function Bpe(c,e){let a=e.rootsTree,f=e.claimsTree;return c.addKey(a,(await f.root()).bigInt())}async function Ppe(c,e,a){let f=e.revocationTree;for(let d of a)await c.addKey(f,BigInt(d))}var eL=class{constructor(e=[],a=new Map){this.nodes=e;this.seen=a}async addKey(e,a){let{value:f,siblings:d}=await e.get(a),b=Y0(a),t=Y0(f),r=new Ud(b,t),o=await Tpe(d,r);for(let n of o)this.seen.get(n.hash.hex())||(this.nodes.push(n),this.seen.set(n.hash.hex(),!0))}addProofNode(e){let a=e.hash.hex();this.seen.get(a)||(this.nodes.push(e),this.seen.set(a,!0))}};async function Tpe(c,e){if(e.type!==1)throw new Error("node is not a leaf");let a=await e.getKey(),f=c.length,d=new Array(f+1);for(let r=0;r<d.length;r++)d[r]=new z4;d[f].hash=a;let b=Y0(BigInt(1));d[f].children=[e.entry[0],e.entry[1],b];let t=e.entry[0];for(let r=f-1;r>=0;r--){let o=on(t.bytes,r);d[r].children=new Array(2),o?(d[r].children[0]=c[r],d[r].children[1]=a):(d[r].children[0]=a,d[r].children[1]=c[r]),d[r].hash=await J8([d[r].children[0].bigInt(),d[r].children[1].bigInt()]),a=d[r].hash}return d}var Wp=class{issuer;mtp;toRevocationStatus(){let e=new Gd;e.existence=this.mtp.existence,e.nodeAux=this.mtp.node_aux?{key:Y0(BigInt(this.mtp.node_aux.key)),value:Y0(BigInt(this.mtp.node_aux.value))}:void 0;let a=this.mtp.siblings.map(f=>Y0(BigInt(f)));e.siblings=[],e.depth=a.length;for(let f=0;f<a.length;f++)a[f].bigInt()!==BigInt(0)&&(k6(e.notEmpties,f),e.siblings.push(a[f]));return{mtp:e,issuer:this.issuer}}};var aL=class{constructor(e,a,f){this._kms=e;this._storage=a;this._credentialWallet=f}async createIdentity(e,a){let f=If();await this._storage.mt.createIdentityMerkleTrees(f),a||(a={method:mb.Iden3,blockchain:N6.Polygon,networkId:M6.Mumbai}),a.seed=a.seed??u_(32);let d=await this._kms.createKeyFromSeed("BJJ",a.seed),b=await this._kms.publicKey(d),t=kc.authSchemaHash,r=Uf.newClaim(t,m1.withIndexDataInts(b.p[0],b.p[1]),m1.withRevocationNonce(BigInt(0))),o=0;r.setRevocationNonce(BigInt(o)),await this._storage.mt.addToMerkleTree(f,0,r.hiHv().hi,r.hiHv().hv);let n=await this._storage.mt.getMerkleTreeByIdentifierAndType(f,0),i=await J8([(await n.root()).bigInt(),b0.bigInt(),b0.bigInt()]),l=tn(a.method,a.blockchain,a.networkId),h=Z0.idGenesisFromIdenState(l,i.bigInt()),u=sc.parseFromId(h);await this._storage.mt.bindMerkleTreeToNewIdentifier(f,u.toString());let g=JSON.parse(Uc.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSON),E=r.getExpirationDate(),_=E?W8(E):0,F={credentialSchema:Uc.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL,type:Uc.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,credentialSubject:{x:b.p[0].toString(),y:b.p[1].toString()},subjectPosition:YE(r.getIdPosition()),version:0,expiration:_,revNonce:o};e=e.replace(/\/$/,"");let L=new U2;try{L=this._credentialWallet.createCredential(e,u,F,g,a.rhsUrl)}catch{throw new Error("Error create Iden3Credential")}let U=r.hIndex(),O=await n.root(),{proof:H}=await n.generateProof(U,O),P=O.hex(),A=i.hex(),I=new Y8({type:"Iden3SparseMerkleTreeProof",mtp:H,issuerData:new z6({id:u.toString(),state:{rootOfRoots:b0.hex(),revocationTreeRoot:b0.hex(),claimsTreeRoot:P,value:A},authCoreClaim:r.hex(),credentialStatus:L.credentialStatus,mtp:H}),coreClaim:r.hex()});return L.proof=[I],await this._storage.identity.saveIdentity({identifier:u.toString(),state:i,published:!1,genesis:!0}),await this._credentialWallet.save(L),{did:u,credential:L}}async createProfile(e,a,f){let d=e.id;if((await this._storage.identity.getProfilesByGenesisIdentifier(e.toString())).find(n=>n.nonce==a||n.verifier==f))throw new Error("profile with given nonce or verifier already exists");let r=Z0.profileId(d,BigInt(a)),o=sc.parseFromId(r);return await this._storage.identity.saveProfile({id:o.toString(),nonce:a,genesisIdentifier:e.toString(),verifier:f}),o}async generateKey(e){return await this._kms.createKeyFromSeed(e,u_(32))}async getDIDTreeModel(e){let a=await this._storage.mt.getMerkleTreeByIdentifierAndType(e.toString(),0),f=await this._storage.mt.getMerkleTreeByIdentifierAndType(e.toString(),1),d=await this._storage.mt.getMerkleTreeByIdentifierAndType(e.toString(),2);return{state:await J8([(await a.root()).bigInt(),(await f.root()).bigInt(),(await d.root()).bigInt()]),claimsTree:a,revocationTree:f,rootsTree:d}}async generateCredentialMtp(e,a,f){let d=await this.getCoreClaimFromCredential(a),b=await this.getDIDTreeModel(e),t=await this._storage.mt.getMerkleTreeByIdentifierAndType(e.toString(),0),r=await b.claimsTree.root(),o=await b.rootsTree.root(),n=await b.revocationTree.root(),{proof:i}=await t.generateProof(d.hIndex(),f?f.claimsRoot:r);return{proof:i,treeState:f??{state:b.state,claimsRoot:r,rootOfRoots:o,revocationRoot:n}}}async generateNonRevocationMtp(e,a,f){let b=(await this.getCoreClaimFromCredential(a)).getRevocationNonce(),t=await this.getDIDTreeModel(e),r=await this._storage.mt.getMerkleTreeByIdentifierAndType(e.toString(),1),o=await t.claimsTree.root(),n=await t.rootsTree.root(),i=await t.revocationTree.root(),{proof:l}=await r.generateProof(b,f?f.revocationRoot:i);return{proof:l,treeState:f??{state:t.state,claimsRoot:o,rootOfRoots:n,revocationRoot:i}}}async sign(e,a){let f=this.getKMSIdByAuthCredential(a),d=Mc.hashBytes(e),b=await this._kms.sign(f,H0.intToBytes(d));return ub.newFromCompressed(b)}async signChallenge(e,a){let f=this.getKMSIdByAuthCredential(a),d=await this._kms.sign(f,H0.intToBytes(e));return ub.newFromCompressed(d)}async issueCredential(e,a,f,d){d||(d={withRHS:""}),f=f.replace(/\/$/,"");let b=await new D7("ipfs.io").load(a.credentialSchema),t=JSON.parse(new TextDecoder().decode(b)),r=new U2,o=0;a.revNonce||(a.revNonce=Math.round(Math.random()*1e4)),a.subjectPosition=a.subjectPosition??"index",o=a.revNonce;try{r=this._credentialWallet.createCredential(f,e,a,t,d.withRHS)}catch{throw new Error("Error create Iden3Credential")}let n=await this._credentialWallet.getAuthBJJCredential(e),i={revNonce:o,subjectPosition:a.subjectPosition,merklizedRootPosition:this.defineMTRootPosition(t,a.merklizedRootPosition),updatable:!1,version:0},l=await new S4().parseClaim(r,`${t.$metadata.uris.jsonLdContext}#${a.type}`,b,i),{hi:h,hv:u}=l.hiHv(),g=Mc.hash([h,u]),E=this.getKMSIdByAuthCredential(n),_=await this._kms.sign(E,H0.intToBytes(g));if(!n.proof)throw new Error("issuer auth credential must have proof");let F=n.proof[0],L={type:"BJJSignature2021",issuerData:new z6({id:e.toString(),state:F.issuerData.state,authCoreClaim:F.coreClaim,mtp:F.mtp,credentialStatus:F.issuerData.credentialStatus}),coreClaim:l.hex(),signature:R0.encodeString(_)};return r.proof=[L],r}async revokeCredential(e,a){let f=await this.getDIDTreeModel(e),d=a.getCoreClaimFromProof("BJJSignature2021");if(!d)throw new Error("credential must have coreClaim representation in the signature proof");let b=d.getRevocationNonce();return await f.revocationTree.add(b,BigInt(0)),Number(BigInt.asUintN(64,b))}async addCredentialsToMerkleTree(e,a){let f=await this.getDIDTreeModel(a),d=await f.claimsTree.root(),b=await f.rootsTree.root(),t=await f.revocationTree.root(),r={state:f.state,claimsRoot:d,revocationRoot:t,rootOfRoots:b};for(let l=0;l<e.length;l++){let u=await e[l].getCoreClaimFromProof("BJJSignature2021");if(!u)throw new Error("credential must have coreClaim representation in the signature proof");await this._storage.mt.addToMerkleTree(a.toString(),0,u.hIndex(),u.hValue())}let n=await(await this.getDIDTreeModel(a)).claimsTree.root();await this._storage.mt.addToMerkleTree(a.toString(),2,n.bigInt(),BigInt(0));let i=await this.getDIDTreeModel(a);return d=await i.claimsTree.root(),b=await i.rootsTree.root(),t=await i.revocationTree.root(),{credentials:e,newTreeState:{state:i.state,claimsRoot:d,rootOfRoots:b,revocationRoot:t},oldTreeState:r}}async generateIden3SparseMerkleTreeProof(e,a,f,d,b){for(let t=0;t<a.length;t++){let r=a[t],o=await this.generateCredentialMtp(e,r),n=r.getCoreClaimFromProof("BJJSignature2021");if(!n)throw new Error("credential must have coreClaim representation in the signature proof");let i=new Y8({type:"Iden3SparseMerkleTreeProof",mtp:o.proof,issuerData:new z6({id:e.toString(),state:{claimsTreeRoot:o.treeState.claimsRoot.hex(),revocationTreeRoot:o.treeState.revocationRoot.hex(),rootOfRoots:o.treeState.rootOfRoots.hex(),value:o.treeState.state.hex(),txId:f,blockNumber:d,blockTimestamp:b},mtp:o.proof}),coreClaim:n.hex()});Array.isArray(a[t].proof)?a[t].proof.push(i):a[t].proof=i}return a}async publishStateToRHS(e,a,f){let d=await this.getDIDTreeModel(e);await rY(d.state,{revocationTree:d.revocationTree,claimsTree:d.claimsTree,state:d.state,rootsTree:d.rootsTree},a,f)}getKMSIdByAuthCredential(e){if(e.type.indexOf("AuthBJJCredential")===-1)throw new Error("can't sign with not AuthBJJCredential credential");let a=e.credentialSubject.x,f=e.credentialSubject.y,d=new Q8([BigInt(a),BigInt(f)]),b=il("BJJ",d.hex());return{type:"BJJ",id:b}}defineMTRootPosition(e,a){return e.$metadata?.serialization?"":a||"index"}async getCoreClaimFromCredential(e){let a=e.getCoreClaimFromProof("BJJSignature2021"),f=e.getCoreClaimFromProof("Iden3SparseMerkleTreeProof");if(f&&a&&f.hex()!==a.hex())throw new Error("core claim representations is set in both proofs but they are not equal");if(!f&&!a)throw new Error("core claim is not set in credential proofs");return f??a}};s();x();s();x();var Ope="all claims are revoked",cL=class{constructor(e){this._storage=e}async getAuthBJJCredential(e){let a=await this._storage.credential.findCredentialsByQuery({context:Uc.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL,type:Uc.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,allowedIssuers:[e.toString()]});if(!a.length)throw new Error("no auth credentials found");for(let f=0;f<a.length;f++){let d=a[f];if(!(await this.getRevocationStatusFromCredential(d)).mtp.existence)return d}throw new Error("all auth bjj credentials are revoked")}async getRevocationStatusFromCredential(e){let a=e.getIden3SparseMerkleTreeProof(),f=e.getBJJSignature2021Proof(),d=a?a.issuerData:f?.issuerData;if(!d)throw new Error("no sig / mtp proof to check issuer info");let b=sc.parse(e.issuer);return await this.getRevocationStatus(e.credentialStatus,b,d)}async getRevocationStatus(e,a,f){if(e.type==="SparseMerkleTreeProof"){let d=(await Qf.get(e.id)).data;return Object.assign(new Wp,d).toRevocationStatus()}if(e.type==="Iden3ReverseSparseMerkleTreeProof")try{return await tY(a,e,this._storage.states)}catch(d){if((d.reason??d.message).includes(Uc.ERRORS.IDENTITY_DOES_NOT_EXIST)&&nY(a.toString(),f.state.value))return{mtp:new Gd,issuer:{state:f.state.value,revocationTreeRoot:f.state.revocationTreeRoot,rootOfRoots:f.state.rootOfRoots,claimsTreeRoot:f.state.claimsTreeRoot}};if(e?.statusIssuer?.type==="SparseMerkleTreeProof")return(await Qf.get(e.id)).data;throw new Error("can't fetch revocation status")}throw new Error("revocation status unknown")}createCredential=(e,a,f,d,b)=>{if(!d.$metadata.uris.jsonLdContext)throw new Error("jsonLdContext is missing is the schema");let t=[Uc.JSONLD_SCHEMA.W3C_CREDENTIAL_2018,Uc.JSONLD_SCHEMA.IDEN3_CREDENTIAL,d.$metadata.uris.jsonLdContext],r=[Uc.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL,f.type],o=!f.expiration||f.expiration==0?null:f.expiration,n=a.toString(),i=f.credentialSubject;i.type=f.type;let l=new U2;return l.id=`${e}/${If()}`,l["@context"]=t,l.type=r,l.expirationDate=o?new Date(o*1e3).toISOString():void 0,l.issuanceDate=new Date().toISOString(),l.credentialSubject=i,l.issuer=n.toString(),l.credentialSchema={id:f.credentialSchema,type:Uc.JSON_SCHEMA_VALIDATOR},b?l.credentialStatus={id:`${b}`,revocationNonce:f.revNonce,type:"Iden3ReverseSparseMerkleTreeProof"}:l.credentialStatus={id:`${e}/revocation/${f.revNonce}`,revocationNonce:f.revNonce,type:"SparseMerkleTreeProof"},l};async findById(e){return this._storage.credential.findCredentialById(e)}async findByContextType(e,a){return this._storage.credential.findCredentialsByQuery({context:e,type:a})}async save(e){return this._storage.credential.saveCredential(e)}async saveAll(e){return this._storage.credential.saveAllCredentials(e)}async remove(e){return this._storage.credential.removeCredential(e)}async list(){return this._storage.credential.listCredentials()}async findByQuery(e){return this._storage.credential.findCredentialsByQuery(e)}async filterByCredentialSubject(e,a){return e.filter(f=>f.credentialSubject.id===a.toString())}async findNonRevokedCredential(e){for(let a of e){let f=await this.getRevocationStatusFromCredential(a);if(!f.mtp.existence)return{cred:a,revStatus:f}}throw new Error(Ope)}};function nY(c,e){let a=sc.parse(c),f=H0.hexToBytes(e),d=H0.bytesToInt(f),b=tn(a.method,a.blockchain,a.networkId);return iY(a.id.bigInt(),d,b)}function iY(c,e,a){let f=Z0.idGenesisFromIdenState(a,e);return c.toString()===f.bigInt().toString()}s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();var Qt={};v0(Qt,{BaseContract:()=>Pt,BigNumber:()=>Ee,Contract:()=>X4,ContractFactory:()=>No,FixedNumber:()=>$a,Signer:()=>fd,VoidSigner:()=>t8,Wallet:()=>V1,Wordlist:()=>f1,constants:()=>hm,errors:()=>Sd,getDefaultProvider:()=>rg,logger:()=>H0e,providers:()=>ng,utils:()=>og,version:()=>sg,wordlists:()=>a5});s();x();s();x();s();x();s();x();s();x();s();x();var vY=Fe(dL());s();x();s();x();s();x();var sY="logger/5.7.0";var xY=!1,lY=!1,Jp={debug:1,default:2,info:2,warning:3,error:4,off:5},uY=Jp.default,bL=null;function Npe(){try{let c=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{c.push(e)}}),c.length)throw new Error("missing "+c.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(c){return c.message}return null}var hY=Npe(),tL;(function(c){c.DEBUG="DEBUG",c.INFO="INFO",c.WARNING="WARNING",c.ERROR="ERROR",c.OFF="OFF"})(tL||(tL={}));var Sd;(function(c){c.UNKNOWN_ERROR="UNKNOWN_ERROR",c.NOT_IMPLEMENTED="NOT_IMPLEMENTED",c.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",c.NETWORK_ERROR="NETWORK_ERROR",c.SERVER_ERROR="SERVER_ERROR",c.TIMEOUT="TIMEOUT",c.BUFFER_OVERRUN="BUFFER_OVERRUN",c.NUMERIC_FAULT="NUMERIC_FAULT",c.MISSING_NEW="MISSING_NEW",c.INVALID_ARGUMENT="INVALID_ARGUMENT",c.MISSING_ARGUMENT="MISSING_ARGUMENT",c.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",c.CALL_EXCEPTION="CALL_EXCEPTION",c.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",c.NONCE_EXPIRED="NONCE_EXPIRED",c.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",c.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",c.TRANSACTION_REPLACED="TRANSACTION_REPLACED",c.ACTION_REJECTED="ACTION_REJECTED"})(Sd||(Sd={}));var pY="0123456789abcdef",X=class{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,a){let f=e.toLowerCase();Jp[f]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(uY>Jp[f])&&console.log.apply(console,a)}debug(...e){this._log(X.levels.DEBUG,e)}info(...e){this._log(X.levels.INFO,e)}warn(...e){this._log(X.levels.WARNING,e)}makeError(e,a,f){if(lY)return this.makeError("censored error",a,{});a||(a=X.errors.UNKNOWN_ERROR),f||(f={});let d=[];Object.keys(f).forEach(o=>{let n=f[o];try{if(n instanceof Uint8Array){let i="";for(let l=0;l<n.length;l++)i+=pY[n[l]>>4],i+=pY[n[l]&15];d.push(o+"=Uint8Array(0x"+i+")")}else d.push(o+"="+JSON.stringify(n))}catch{d.push(o+"="+JSON.stringify(f[o].toString()))}}),d.push(`code=${a}`),d.push(`version=${this.version}`);let b=e,t="";switch(a){case Sd.NUMERIC_FAULT:{t="NUMERIC_FAULT";let o=e;switch(o){case"overflow":case"underflow":case"division-by-zero":t+="-"+o;break;case"negative-power":case"negative-width":t+="-unsupported";break;case"unbound-bitwise-result":t+="-unbound-result";break}break}case Sd.CALL_EXCEPTION:case Sd.INSUFFICIENT_FUNDS:case Sd.MISSING_NEW:case Sd.NONCE_EXPIRED:case Sd.REPLACEMENT_UNDERPRICED:case Sd.TRANSACTION_REPLACED:case Sd.UNPREDICTABLE_GAS_LIMIT:t=a;break}t&&(e+=" [ See: https://links.ethers.org/v5-errors-"+t+" ]"),d.length&&(e+=" ("+d.join(", ")+")");let r=new Error(e);return r.reason=b,r.code=a,Object.keys(f).forEach(function(o){r[o]=f[o]}),r}throwError(e,a,f){throw this.makeError(e,a,f)}throwArgumentError(e,a,f){return this.throwError(e,X.errors.INVALID_ARGUMENT,{argument:a,value:f})}assert(e,a,f,d){e||this.throwError(a,f,d)}assertArgument(e,a,f,d){e||this.throwArgumentError(a,f,d)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),hY&&this.throwError("platform missing String.prototype.normalize",X.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:hY})}checkSafeUint53(e,a){typeof e=="number"&&(a==null&&(a="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(a,X.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(a,X.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,a,f){f?f=": "+f:f="",e<a&&this.throwError("missing argument"+f,X.errors.MISSING_ARGUMENT,{count:e,expectedCount:a}),e>a&&this.throwError("too many arguments"+f,X.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:a})}checkNew(e,a){(e===Object||e==null)&&this.throwError("missing new",X.errors.MISSING_NEW,{name:a.name})}checkAbstract(e,a){e===a?this.throwError("cannot instantiate abstract class "+JSON.stringify(a.name)+" directly; use a sub-class",X.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",X.errors.MISSING_NEW,{name:a.name})}static globalLogger(){return bL||(bL=new X(sY)),bL}static setCensorship(e,a){if(!e&&a&&this.globalLogger().throwError("cannot permanently disable censorship",X.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),xY){if(!e)return;this.globalLogger().throwError("error censorship permanent",X.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}lY=!!e,xY=!!a}static setLogLevel(e){let a=Jp[e.toLowerCase()];if(a==null){X.globalLogger().warn("invalid log level - "+e);return}uY=a}static from(e){return new X(e)}};X.errors=Sd;X.levels=tL;s();x();var mY="bytes/5.7.0";var rc=new X(mY);function yY(c){return!!c.toHexString}function ot(c){return c.slice||(c.slice=function(){let e=Array.prototype.slice.call(arguments);return ot(new Uint8Array(Array.prototype.slice.apply(c,e)))}),c}function a8(c){return n0(c)&&!(c.length%2)||Q2(c)}function gY(c){return typeof c=="number"&&c==c&&c%1===0}function Q2(c){if(c==null)return!1;if(c.constructor===Uint8Array)return!0;if(typeof c=="string"||!gY(c.length)||c.length<0)return!1;for(let e=0;e<c.length;e++){let a=c[e];if(!gY(a)||a<0||a>=256)return!1}return!0}function Se(c,e){if(e||(e={}),typeof c=="number"){rc.checkSafeUint53(c,"invalid arrayify value");let a=[];for(;c;)a.unshift(c&255),c=parseInt(String(c/256));return a.length===0&&a.push(0),ot(new Uint8Array(a))}if(e.allowMissingPrefix&&typeof c=="string"&&c.substring(0,2)!=="0x"&&(c="0x"+c),yY(c)&&(c=c.toHexString()),n0(c)){let a=c.substring(2);a.length%2&&(e.hexPad==="left"?a="0"+a:e.hexPad==="right"?a+="0":rc.throwArgumentError("hex data is odd-length","value",c));let f=[];for(let d=0;d<a.length;d+=2)f.push(parseInt(a.substring(d,d+2),16));return ot(new Uint8Array(f))}return Q2(c)?ot(new Uint8Array(c)):rc.throwArgumentError("invalid arrayify value","value",c)}function O0(c){let e=c.map(d=>Se(d)),a=e.reduce((d,b)=>d+b.length,0),f=new Uint8Array(a);return e.reduce((d,b)=>(f.set(b,d),d+b.length),0),ot(f)}function b2(c){let e=Se(c);if(e.length===0)return e;let a=0;for(;a<e.length&&e[a]===0;)a++;return a&&(e=e.slice(a)),e}function j4(c,e){c=Se(c),c.length>e&&rc.throwArgumentError("value out of range","value",arguments[0]);let a=new Uint8Array(e);return a.set(c,e-c.length),ot(a)}function n0(c,e){return!(typeof c!="string"||!c.match(/^0x[0-9A-Fa-f]*$/)||e&&c.length!==2+2*e)}var rL="0123456789abcdef";function Be(c,e){if(e||(e={}),typeof c=="number"){rc.checkSafeUint53(c,"invalid hexlify value");let a="";for(;c;)a=rL[c&15]+a,c=Math.floor(c/16);return a.length?(a.length%2&&(a="0"+a),"0x"+a):"0x00"}if(typeof c=="bigint")return c=c.toString(16),c.length%2?"0x0"+c:"0x"+c;if(e.allowMissingPrefix&&typeof c=="string"&&c.substring(0,2)!=="0x"&&(c="0x"+c),yY(c))return c.toHexString();if(n0(c))return c.length%2&&(e.hexPad==="left"?c="0x0"+c.substring(2):e.hexPad==="right"?c+="0":rc.throwArgumentError("hex data is odd-length","value",c)),c.toLowerCase();if(Q2(c)){let a="0x";for(let f=0;f<c.length;f++){let d=c[f];a+=rL[(d&240)>>4]+rL[d&15]}return a}return rc.throwArgumentError("invalid hexlify value","value",c)}function Cf(c){if(typeof c!="string")c=Be(c);else if(!n0(c)||c.length%2)return null;return(c.length-2)/2}function ya(c,e,a){return typeof c!="string"?c=Be(c):(!n0(c)||c.length%2)&&rc.throwArgumentError("invalid hexData","value",c),e=2+2*e,a!=null?"0x"+c.substring(e,2+2*a):"0x"+c.substring(e)}function Ec(c){let e="0x";return c.forEach(a=>{e+=Be(a).substring(2)}),e}function kb(c){let e=nL(Be(c,{hexPad:"left"}));return e==="0x"?"0x0":e}function nL(c){typeof c!="string"&&(c=Be(c)),n0(c)||rc.throwArgumentError("invalid hex string","value",c),c=c.substring(2);let e=0;for(;e<c.length&&c[e]==="0";)e++;return"0x"+c.substring(e)}function q0(c,e){for(typeof c!="string"?c=Be(c):n0(c)||rc.throwArgumentError("invalid hex string","value",c),c.length>2*e+2&&rc.throwArgumentError("value out of range","value",arguments[1]);c.length<2*e+2;)c="0x0"+c.substring(2);return c}function Ub(c){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(a8(c)){let a=Se(c);a.length===64?(e.v=27+(a[32]>>7),a[32]&=127,e.r=Be(a.slice(0,32)),e.s=Be(a.slice(32,64))):a.length===65?(e.r=Be(a.slice(0,32)),e.s=Be(a.slice(32,64)),e.v=a[64]):rc.throwArgumentError("invalid signature string","signature",c),e.v<27&&(e.v===0||e.v===1?e.v+=27:rc.throwArgumentError("signature invalid v byte","signature",c)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(a[32]|=128),e._vs=Be(a.slice(32,64))}else{if(e.r=c.r,e.s=c.s,e.v=c.v,e.recoveryParam=c.recoveryParam,e._vs=c._vs,e._vs!=null){let d=j4(Se(e._vs),32);e._vs=Be(d);let b=d[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=b:e.recoveryParam!==b&&rc.throwArgumentError("signature recoveryParam mismatch _vs","signature",c),d[0]&=127;let t=Be(d);e.s==null?e.s=t:e.s!==t&&rc.throwArgumentError("signature v mismatch _vs","signature",c)}if(e.recoveryParam==null)e.v==null?rc.throwArgumentError("signature missing v and recoveryParam","signature",c):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let d=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==d&&rc.throwArgumentError("signature recoveryParam mismatch v","signature",c)}e.r==null||!n0(e.r)?rc.throwArgumentError("signature missing or invalid r","signature",c):e.r=q0(e.r,32),e.s==null||!n0(e.s)?rc.throwArgumentError("signature missing or invalid s","signature",c):e.s=q0(e.s,32);let a=Se(e.s);a[0]>=128&&rc.throwArgumentError("signature s out of range","signature",c),e.recoveryParam&&(a[0]|=128);let f=Be(a);e._vs&&(n0(e._vs)||rc.throwArgumentError("signature invalid _vs","signature",c),e._vs=q0(e._vs,32)),e._vs==null?e._vs=f:e._vs!==f&&rc.throwArgumentError("signature _vs mismatch v and s","signature",c)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function mo(c){return c=Ub(c),Be(O0([c.r,c.s,c.recoveryParam?"0x1c":"0x1b"]))}s();x();var Zp="bignumber/5.7.0";var go=vY.default.BN,c8=new X(Zp),iL={},wY=9007199254740991;function EY(c){return c!=null&&(Ee.isBigNumber(c)||typeof c=="number"&&c%1===0||typeof c=="string"&&!!c.match(/^-?[0-9]+$/)||n0(c)||typeof c=="bigint"||Q2(c))}var _Y=!1,Ee=class{constructor(e,a){e!==iL&&c8.throwError("cannot call constructor directly; use BigNumber.from",X.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=a,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Id(K0(this).fromTwos(e))}toTwos(e){return Id(K0(this).toTwos(e))}abs(){return this._hex[0]==="-"?Ee.from(this._hex.substring(1)):this}add(e){return Id(K0(this).add(K0(e)))}sub(e){return Id(K0(this).sub(K0(e)))}div(e){return Ee.from(e).isZero()&&W2("division-by-zero","div"),Id(K0(this).div(K0(e)))}mul(e){return Id(K0(this).mul(K0(e)))}mod(e){let a=K0(e);return a.isNeg()&&W2("division-by-zero","mod"),Id(K0(this).umod(a))}pow(e){let a=K0(e);return a.isNeg()&&W2("negative-power","pow"),Id(K0(this).pow(a))}and(e){let a=K0(e);return(this.isNegative()||a.isNeg())&&W2("unbound-bitwise-result","and"),Id(K0(this).and(a))}or(e){let a=K0(e);return(this.isNegative()||a.isNeg())&&W2("unbound-bitwise-result","or"),Id(K0(this).or(a))}xor(e){let a=K0(e);return(this.isNegative()||a.isNeg())&&W2("unbound-bitwise-result","xor"),Id(K0(this).xor(a))}mask(e){return(this.isNegative()||e<0)&&W2("negative-width","mask"),Id(K0(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&W2("negative-width","shl"),Id(K0(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&W2("negative-width","shr"),Id(K0(this).shrn(e))}eq(e){return K0(this).eq(K0(e))}lt(e){return K0(this).lt(K0(e))}lte(e){return K0(this).lte(K0(e))}gt(e){return K0(this).gt(K0(e))}gte(e){return K0(this).gte(K0(e))}isNegative(){return this._hex[0]==="-"}isZero(){return K0(this).isZero()}toNumber(){try{return K0(this).toNumber()}catch{W2("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return c8.throwError("this platform does not support BigInt",X.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?_Y||(_Y=!0,c8.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?c8.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",X.errors.UNEXPECTED_ARGUMENT,{}):c8.throwError("BigNumber.toString does not accept parameters",X.errors.UNEXPECTED_ARGUMENT,{})),K0(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof Ee)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new Ee(iL,yo(e)):e.match(/^-?[0-9]+$/)?new Ee(iL,yo(new go(e))):c8.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&W2("underflow","BigNumber.from",e),(e>=wY||e<=-wY)&&W2("overflow","BigNumber.from",e),Ee.from(String(e));let a=e;if(typeof a=="bigint")return Ee.from(a.toString());if(Q2(a))return Ee.from(Be(a));if(a)if(a.toHexString){let f=a.toHexString();if(typeof f=="string")return Ee.from(f)}else{let f=a._hex;if(f==null&&a.type==="BigNumber"&&(f=a.hex),typeof f=="string"&&(n0(f)||f[0]==="-"&&n0(f.substring(1))))return Ee.from(f)}return c8.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}};function yo(c){if(typeof c!="string")return yo(c.toString(16));if(c[0]==="-")return c=c.substring(1),c[0]==="-"&&c8.throwArgumentError("invalid hex","value",c),c=yo(c),c==="0x00"?c:"-"+c;if(c.substring(0,2)!=="0x"&&(c="0x"+c),c==="0x")return"0x00";for(c.length%2&&(c="0x0"+c.substring(2));c.length>4&&c.substring(0,4)==="0x00";)c="0x"+c.substring(4);return c}function Id(c){return Ee.from(yo(c))}function K0(c){let e=Ee.from(c).toHexString();return e[0]==="-"?new go("-"+e.substring(3),16):new go(e.substring(2),16)}function W2(c,e,a){let f={fault:c,operation:e};return a!=null&&(f.value=a),c8.throwError(c,X.errors.NUMERIC_FAULT,f)}function oL(c){return new go(c,36).toString(16)}function sL(c){return new go(c,16).toString(36)}s();x();var Xf=new X(Zp),wo={},SY=Ee.from(0),IY=Ee.from(-1);function LY(c,e,a,f){let d={fault:e,operation:a};return f!==void 0&&(d.value=f),Xf.throwError(c,X.errors.NUMERIC_FAULT,d)}var _o="0";for(;_o.length<256;)_o+=_o;function xL(c){if(typeof c!="number")try{c=Ee.from(c).toNumber()}catch{}return typeof c=="number"&&c>=0&&c<=256&&!(c%1)?"1"+_o.substring(0,c):Xf.throwArgumentError("invalid decimal size","decimals",c)}function st(c,e){e==null&&(e=0);let a=xL(e);c=Ee.from(c);let f=c.lt(SY);f&&(c=c.mul(IY));let d=c.mod(a).toString();for(;d.length<a.length-1;)d="0"+d;d=d.match(/^([0-9]*[1-9]|0)(0*)/)[1];let b=c.div(a).toString();return a.length===1?c=b:c=b+"."+d,f&&(c="-"+c),c}function J2(c,e){e==null&&(e=0);let a=xL(e);(typeof c!="string"||!c.match(/^-?[0-9.]+$/))&&Xf.throwArgumentError("invalid decimal value","value",c);let f=c.substring(0,1)==="-";f&&(c=c.substring(1)),c==="."&&Xf.throwArgumentError("missing value","value",c);let d=c.split(".");d.length>2&&Xf.throwArgumentError("too many decimal points","value",c);let b=d[0],t=d[1];for(b||(b="0"),t||(t="0");t[t.length-1]==="0";)t=t.substring(0,t.length-1);for(t.length>a.length-1&&LY("fractional component exceeds decimals","underflow","parseFixed"),t===""&&(t="0");t.length<a.length-1;)t+="0";let r=Ee.from(b),o=Ee.from(t),n=r.mul(a).add(o);return f&&(n=n.mul(IY)),n}var f8=class{constructor(e,a,f,d){e!==wo&&Xf.throwError("cannot use FixedFormat constructor; use FixedFormat.from",X.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=a,this.width=f,this.decimals=d,this.name=(a?"":"u")+"fixed"+String(f)+"x"+String(d),this._multiplier=xL(d),Object.freeze(this)}static from(e){if(e instanceof f8)return e;typeof e=="number"&&(e=`fixed128x${e}`);let a=!0,f=128,d=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")a=!1;else{let b=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);b||Xf.throwArgumentError("invalid fixed format","format",e),a=b[1]!=="u",f=parseInt(b[2]),d=parseInt(b[3])}}else if(e){let b=(t,r,o)=>e[t]==null?o:(typeof e[t]!==r&&Xf.throwArgumentError("invalid fixed format ("+t+" not "+r+")","format."+t,e[t]),e[t]);a=b("signed","boolean",a),f=b("width","number",f),d=b("decimals","number",d)}return f%8&&Xf.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",f),d>80&&Xf.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",d),new f8(wo,a,f,d)}},$a=class{constructor(e,a,f,d){e!==wo&&Xf.throwError("cannot use FixedNumber constructor; use FixedNumber.from",X.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=d,this._hex=a,this._value=f,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Xf.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);let a=J2(this._value,this.format.decimals),f=J2(e._value,e.format.decimals);return $a.fromValue(a.add(f),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);let a=J2(this._value,this.format.decimals),f=J2(e._value,e.format.decimals);return $a.fromValue(a.sub(f),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);let a=J2(this._value,this.format.decimals),f=J2(e._value,e.format.decimals);return $a.fromValue(a.mul(f).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);let a=J2(this._value,this.format.decimals),f=J2(e._value,e.format.decimals);return $a.fromValue(a.mul(this.format._multiplier).div(f),this.format.decimals,this.format)}floor(){let e=this.toString().split(".");e.length===1&&e.push("0");let a=$a.from(e[0],this.format),f=!e[1].match(/^(0*)$/);return this.isNegative()&&f&&(a=a.subUnsafe(AY.toFormat(a.format))),a}ceiling(){let e=this.toString().split(".");e.length===1&&e.push("0");let a=$a.from(e[0],this.format),f=!e[1].match(/^(0*)$/);return!this.isNegative()&&f&&(a=a.addUnsafe(AY.toFormat(a.format))),a}round(e){e==null&&(e=0);let a=this.toString().split(".");if(a.length===1&&a.push("0"),(e<0||e>80||e%1)&&Xf.throwArgumentError("invalid decimal count","decimals",e),a[1].length<=e)return this;let f=$a.from("1"+_o.substring(0,e),this.format),d=Mpe.toFormat(this.format);return this.mulUnsafe(f).addUnsafe(d).floor().divUnsafe(f)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(e){if(e==null)return this._hex;e%8&&Xf.throwArgumentError("invalid byte width","width",e);let a=Ee.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return q0(a,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return $a.fromString(this._value,e)}static fromValue(e,a,f){return f==null&&a!=null&&!EY(a)&&(f=a,a=null),a==null&&(a=0),f==null&&(f="fixed"),$a.fromString(st(e,a),f8.from(f))}static fromString(e,a){a==null&&(a="fixed");let f=f8.from(a),d=J2(e,f.decimals);!f.signed&&d.lt(SY)&&LY("unsigned value cannot be negative","overflow","value",e);let b=null;f.signed?b=d.toTwos(f.width).toHexString():(b=d.toHexString(),b=q0(b,f.width/8));let t=st(d,f.decimals);return new $a(wo,b,t,f)}static fromBytes(e,a){a==null&&(a="fixed");let f=f8.from(a);if(Se(e).length>f.width/8)throw new Error("overflow");let d=Ee.from(e);f.signed&&(d=d.fromTwos(f.width));let b=d.toTwos((f.signed?0:1)+f.width).toHexString(),t=st(d,f.decimals);return new $a(wo,b,t,f)}static from(e,a){if(typeof e=="string")return $a.fromString(e,a);if(Q2(e))return $a.fromBytes(e,a);try{return $a.fromValue(e,0,a)}catch(f){if(f.code!==X.errors.INVALID_ARGUMENT)throw f}return Xf.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}},AY=$a.from(1),Mpe=$a.from("0.5");s();x();s();x();var FY="properties/5.7.0";var Dpe=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Yp=new X(FY);function he(c,e,a){Object.defineProperty(c,e,{enumerable:!0,value:a,writable:!1})}function Ka(c,e){for(let a=0;a<32;a++){if(c[e])return c[e];if(!c.prototype||typeof c.prototype!="object")break;c=Object.getPrototypeOf(c.prototype).constructor}return null}function wa(c){return Dpe(this,void 0,void 0,function*(){let e=Object.keys(c).map(f=>{let d=c[f];return Promise.resolve(d).then(b=>({key:f,value:b}))});return(yield Promise.all(e)).reduce((f,d)=>(f[d.key]=d.value,f),{})})}function xt(c,e){(!c||typeof c!="object")&&Yp.throwArgumentError("invalid object","object",c),Object.keys(c).forEach(a=>{e[a]||Yp.throwArgumentError("invalid object key - "+a,"transaction:"+a,c)})}function ea(c){let e={};for(let a in c)e[a]=c[a];return e}var kpe={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function CY(c){if(c==null||kpe[typeof c])return!0;if(Array.isArray(c)||typeof c=="object"){if(!Object.isFrozen(c))return!1;let e=Object.keys(c);for(let a=0;a<e.length;a++){let f=null;try{f=c[e[a]]}catch{continue}if(!CY(f))return!1}return!0}return Yp.throwArgumentError(`Cannot deepCopy ${typeof c}`,"object",c)}function Upe(c){if(CY(c))return c;if(Array.isArray(c))return Object.freeze(c.map(e=>Va(e)));if(typeof c=="object"){let e={};for(let a in c){let f=c[a];f!==void 0&&he(e,a,Va(f))}return e}return Yp.throwArgumentError(`Cannot deepCopy ${typeof c}`,"object",c)}function Va(c){return Upe(c)}var t2=class{constructor(e){for(let a in e)this[a]=Va(e[a])}};s();x();var qb="abi/5.7.0";var W0=new X(qb),H4={},RY={calldata:!0,memory:!0,storage:!0},qpe={calldata:!0,memory:!0};function Xp(c,e){if(c==="bytes"||c==="string"){if(RY[e])return!0}else if(c==="address"){if(e==="payable")return!0}else if((c.indexOf("[")>=0||c==="tuple")&&qpe[e])return!0;return(RY[e]||e==="payable")&&W0.throwArgumentError("invalid modifier","name",e),!1}function Gpe(c,e){let a=c;function f(r){W0.throwArgumentError(`unexpected character at position ${r}`,"param",c)}c=c.replace(/\s/g," ");function d(r){let o={type:"",name:"",parent:r,state:{allowType:!0}};return e&&(o.indexed=!1),o}let b={type:"",name:"",state:{allowType:!0}},t=b;for(let r=0;r<c.length;r++){let o=c[r];switch(o){case"(":t.state.allowType&&t.type===""?t.type="tuple":t.state.allowParams||f(r),t.state.allowType=!1,t.type=lt(t.type),t.components=[d(t)],t=t.components[0];break;case")":delete t.state,t.name==="indexed"&&(e||f(r),t.indexed=!0,t.name=""),Xp(t.type,t.name)&&(t.name=""),t.type=lt(t.type);let n=t;t=t.parent,t||f(r),delete n.parent,t.state.allowParams=!1,t.state.allowName=!0,t.state.allowArray=!0;break;case",":delete t.state,t.name==="indexed"&&(e||f(r),t.indexed=!0,t.name=""),Xp(t.type,t.name)&&(t.name=""),t.type=lt(t.type);let i=d(t.parent);t.parent.components.push(i),delete t.parent,t=i;break;case" ":t.state.allowType&&t.type!==""&&(t.type=lt(t.type),delete t.state.allowType,t.state.allowName=!0,t.state.allowParams=!0),t.state.allowName&&t.name!==""&&(t.name==="indexed"?(e||f(r),t.indexed&&f(r),t.indexed=!0,t.name=""):Xp(t.type,t.name)?t.name="":t.state.allowName=!1);break;case"[":t.state.allowArray||f(r),t.type+=o,t.state.allowArray=!1,t.state.allowName=!1,t.state.readArray=!0;break;case"]":t.state.readArray||f(r),t.type+=o,t.state.readArray=!1,t.state.allowArray=!0,t.state.allowName=!0;break;default:t.state.allowType?(t.type+=o,t.state.allowParams=!0,t.state.allowArray=!0):t.state.allowName?(t.name+=o,delete t.state.allowArray):t.state.readArray?t.type+=o:f(r)}}return t.parent&&W0.throwArgumentError("unexpected eof","param",c),delete b.state,t.name==="indexed"?(e||f(a.length-7),t.indexed&&f(a.length-7),t.indexed=!0,t.name=""):Xp(t.type,t.name)&&(t.name=""),b.type=lt(b.type),b}function em(c,e){for(let a in e)he(c,a,e[a])}var Q0=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),zpe=new RegExp(/^(.*)\[([0-9]*)\]$/),Na=class{constructor(e,a){e!==H4&&W0.throwError("use fromString",X.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),em(this,a);let f=this.type.match(zpe);f?em(this,{arrayLength:parseInt(f[2]||"-1"),arrayChildren:Na.fromObject({type:f[1],components:this.components}),baseType:"array"}):em(this,{arrayLength:null,arrayChildren:null,baseType:this.components!=null?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=Q0.sighash),Q0[e]||W0.throwArgumentError("invalid format type","format",e),e===Q0.json){let f={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(f.indexed=this.indexed),this.components&&(f.components=this.components.map(d=>JSON.parse(d.format(e)))),JSON.stringify(f)}let a="";return this.baseType==="array"?(a+=this.arrayChildren.format(e),a+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):this.baseType==="tuple"?(e!==Q0.sighash&&(a+=this.type),a+="("+this.components.map(f=>f.format(e)).join(e===Q0.full?", ":",")+")"):a+=this.type,e!==Q0.sighash&&(this.indexed===!0&&(a+=" indexed"),e===Q0.full&&this.name&&(a+=" "+this.name)),a}static from(e,a){return typeof e=="string"?Na.fromString(e,a):Na.fromObject(e)}static fromObject(e){return Na.isParamType(e)?e:new Na(H4,{name:e.name||null,type:lt(e.type),indexed:e.indexed==null?null:!!e.indexed,components:e.components?e.components.map(Na.fromObject):null})}static fromString(e,a){function f(d){return Na.fromObject({name:d.name,type:d.type,indexed:d.indexed,components:d.components})}return f(Gpe(e,!!a))}static isParamType(e){return!!(e!=null&&e._isParamType)}};function vo(c,e){return Hpe(c).map(a=>Na.fromString(a,e))}var ad=class{constructor(e,a){e!==H4&&W0.throwError("use a static from method",X.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),em(this,a),this._isFragment=!0,Object.freeze(this)}static from(e){return ad.isFragment(e)?e:typeof e=="string"?ad.fromString(e):ad.fromObject(e)}static fromObject(e){if(ad.isFragment(e))return e;switch(e.type){case"function":return Bf.fromObject(e);case"event":return ed.fromObject(e);case"constructor":return Rf.fromObject(e);case"error":return r2.fromObject(e);case"fallback":case"receive":return null}return W0.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return e=e.replace(/\s/g," "),e=e.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," "),e=e.trim(),e.split(" ")[0]==="event"?ed.fromString(e.substring(5).trim()):e.split(" ")[0]==="function"?Bf.fromString(e.substring(8).trim()):e.split("(")[0].trim()==="constructor"?Rf.fromString(e.trim()):e.split(" ")[0]==="error"?r2.fromString(e.substring(5).trim()):W0.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!!(e&&e._isFragment)}},ed=class extends ad{format(e){if(e||(e=Q0.sighash),Q0[e]||W0.throwArgumentError("invalid format type","format",e),e===Q0.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(f=>JSON.parse(f.format(e)))});let a="";return e!==Q0.sighash&&(a+="event "),a+=this.name+"("+this.inputs.map(f=>f.format(e)).join(e===Q0.full?", ":",")+") ",e!==Q0.sighash&&this.anonymous&&(a+="anonymous "),a.trim()}static from(e){return typeof e=="string"?ed.fromString(e):ed.fromObject(e)}static fromObject(e){if(ed.isEventFragment(e))return e;e.type!=="event"&&W0.throwArgumentError("invalid event object","value",e);let a={name:Eo(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(Na.fromObject):[],type:"event"};return new ed(H4,a)}static fromString(e){let a=e.match(Ao);a||W0.throwArgumentError("invalid event string","value",e);let f=!1;return a[3].split(" ").forEach(d=>{switch(d.trim()){case"anonymous":f=!0;break;case"":break;default:W0.warn("unknown modifier: "+d)}}),ed.fromObject({name:a[1].trim(),anonymous:f,inputs:vo(a[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&e.type==="event"}};function PY(c,e){e.gas=null;let a=c.split("@");return a.length!==1?(a.length>2&&W0.throwArgumentError("invalid human-readable ABI signature","value",c),a[1].match(/^[0-9]+$/)||W0.throwArgumentError("invalid human-readable ABI signature gas","value",c),e.gas=Ee.from(a[1]),a[0]):c}function TY(c,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",c.split(" ").forEach(a=>{switch(a.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"nonpayable":e.payable=!1,e.stateMutability="nonpayable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+a)}})}function OY(c){let e={constant:!1,payable:!0,stateMutability:"payable"};return c.stateMutability!=null?(e.stateMutability=c.stateMutability,e.constant=e.stateMutability==="view"||e.stateMutability==="pure",c.constant!=null&&!!c.constant!==e.constant&&W0.throwArgumentError("cannot have constant function with mutability "+e.stateMutability,"value",c),e.payable=e.stateMutability==="payable",c.payable!=null&&!!c.payable!==e.payable&&W0.throwArgumentError("cannot have payable function with mutability "+e.stateMutability,"value",c)):c.payable!=null?(e.payable=!!c.payable,c.constant==null&&!e.payable&&c.type!=="constructor"&&W0.throwArgumentError("unable to determine stateMutability","value",c),e.constant=!!c.constant,e.constant?e.stateMutability="view":e.stateMutability=e.payable?"payable":"nonpayable",e.payable&&e.constant&&W0.throwArgumentError("cannot have constant payable function","value",c)):c.constant!=null?(e.constant=!!c.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable"):c.type!=="constructor"&&W0.throwArgumentError("unable to determine stateMutability","value",c),e}var Rf=class extends ad{format(e){if(e||(e=Q0.sighash),Q0[e]||W0.throwArgumentError("invalid format type","format",e),e===Q0.json)return JSON.stringify({type:"constructor",stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(f=>JSON.parse(f.format(e)))});e===Q0.sighash&&W0.throwError("cannot format a constructor for sighash",X.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let a="constructor("+this.inputs.map(f=>f.format(e)).join(e===Q0.full?", ":",")+") ";return this.stateMutability&&this.stateMutability!=="nonpayable"&&(a+=this.stateMutability+" "),a.trim()}static from(e){return typeof e=="string"?Rf.fromString(e):Rf.fromObject(e)}static fromObject(e){if(Rf.isConstructorFragment(e))return e;e.type!=="constructor"&&W0.throwArgumentError("invalid constructor object","value",e);let a=OY(e);a.constant&&W0.throwArgumentError("constructor cannot be constant","value",e);let f={name:null,type:e.type,inputs:e.inputs?e.inputs.map(Na.fromObject):[],payable:a.payable,stateMutability:a.stateMutability,gas:e.gas?Ee.from(e.gas):null};return new Rf(H4,f)}static fromString(e){let a={type:"constructor"};e=PY(e,a);let f=e.match(Ao);return(!f||f[1].trim()!=="constructor")&&W0.throwArgumentError("invalid constructor string","value",e),a.inputs=vo(f[2].trim(),!1),TY(f[3].trim(),a),Rf.fromObject(a)}static isConstructorFragment(e){return e&&e._isFragment&&e.type==="constructor"}},Bf=class extends Rf{format(e){if(e||(e=Q0.sighash),Q0[e]||W0.throwArgumentError("invalid format type","format",e),e===Q0.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?this.gas.toNumber():void 0,inputs:this.inputs.map(f=>JSON.parse(f.format(e))),outputs:this.outputs.map(f=>JSON.parse(f.format(e)))});let a="";return e!==Q0.sighash&&(a+="function "),a+=this.name+"("+this.inputs.map(f=>f.format(e)).join(e===Q0.full?", ":",")+") ",e!==Q0.sighash&&(this.stateMutability?this.stateMutability!=="nonpayable"&&(a+=this.stateMutability+" "):this.constant&&(a+="view "),this.outputs&&this.outputs.length&&(a+="returns ("+this.outputs.map(f=>f.format(e)).join(", ")+") "),this.gas!=null&&(a+="@"+this.gas.toString()+" ")),a.trim()}static from(e){return typeof e=="string"?Bf.fromString(e):Bf.fromObject(e)}static fromObject(e){if(Bf.isFunctionFragment(e))return e;e.type!=="function"&&W0.throwArgumentError("invalid function object","value",e);let a=OY(e),f={type:e.type,name:Eo(e.name),constant:a.constant,inputs:e.inputs?e.inputs.map(Na.fromObject):[],outputs:e.outputs?e.outputs.map(Na.fromObject):[],payable:a.payable,stateMutability:a.stateMutability,gas:e.gas?Ee.from(e.gas):null};return new Bf(H4,f)}static fromString(e){let a={type:"function"};e=PY(e,a);let f=e.split(" returns ");f.length>2&&W0.throwArgumentError("invalid function string","value",e);let d=f[0].match(Ao);if(d||W0.throwArgumentError("invalid function signature","value",e),a.name=d[1].trim(),a.name&&Eo(a.name),a.inputs=vo(d[2],!1),TY(d[3].trim(),a),f.length>1){let b=f[1].match(Ao);(b[1].trim()!=""||b[3].trim()!="")&&W0.throwArgumentError("unexpected tokens","value",e),a.outputs=vo(b[2],!1)}else a.outputs=[];return Bf.fromObject(a)}static isFunctionFragment(e){return e&&e._isFragment&&e.type==="function"}};function BY(c){let e=c.format();return(e==="Error(string)"||e==="Panic(uint256)")&&W0.throwArgumentError(`cannot specify user defined ${e} error`,"fragment",c),c}var r2=class extends ad{format(e){if(e||(e=Q0.sighash),Q0[e]||W0.throwArgumentError("invalid format type","format",e),e===Q0.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(f=>JSON.parse(f.format(e)))});let a="";return e!==Q0.sighash&&(a+="error "),a+=this.name+"("+this.inputs.map(f=>f.format(e)).join(e===Q0.full?", ":",")+") ",a.trim()}static from(e){return typeof e=="string"?r2.fromString(e):r2.fromObject(e)}static fromObject(e){if(r2.isErrorFragment(e))return e;e.type!=="error"&&W0.throwArgumentError("invalid error object","value",e);let a={type:e.type,name:Eo(e.name),inputs:e.inputs?e.inputs.map(Na.fromObject):[]};return BY(new r2(H4,a))}static fromString(e){let a={type:"error"},f=e.match(Ao);return f||W0.throwArgumentError("invalid error signature","value",e),a.name=f[1].trim(),a.name&&Eo(a.name),a.inputs=vo(f[2],!1),BY(r2.fromObject(a))}static isErrorFragment(e){return e&&e._isFragment&&e.type==="error"}};function lt(c){return c.match(/^uint($|[^1-9])/)?c="uint256"+c.substring(4):c.match(/^int($|[^1-9])/)&&(c="int256"+c.substring(3)),c}var jpe=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Eo(c){return(!c||!c.match(jpe))&&W0.throwArgumentError(`invalid identifier "${c}"`,"value",c),c}var Ao=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");function Hpe(c){c=c.trim();let e=[],a="",f=0;for(let d=0;d<c.length;d++){let b=c[d];b===","&&f===0?(e.push(a),a=""):(a+=b,b==="("?f++:b===")"&&(f--,f===-1&&W0.throwArgumentError("unbalanced parenthesis","value",c)))}return a&&e.push(a),e}s();x();s();x();var lL=new X(qb);function ut(c){let e=[],a=function(f,d){if(!!Array.isArray(d))for(let b in d){let t=f.slice();t.push(b);try{a(t,d[b])}catch(r){e.push({path:t,error:r})}}};return a([],c),e}var Ac=class{constructor(e,a,f,d){this.name=e,this.type=a,this.localName=f,this.dynamic=d}_throwError(e,a){lL.throwArgumentError(e,this.localName,a)}},$4=class{constructor(e){he(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return Ec(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData(O0(e._data))}writeBytes(e){let a=Se(e),f=a.length%this.wordSize;return f&&(a=O0([a,this._padding.slice(f)])),this._writeData(a)}_getValue(e){let a=Se(Ee.from(e));return a.length>this.wordSize&&lL.throwError("value out-of-bounds",X.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:a.length}),a.length%this.wordSize&&(a=O0([this._padding.slice(a.length%this.wordSize),a])),a}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){let e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,a=>{this._data[e]=this._getValue(a)}}},V4=class{constructor(e,a,f,d){he(this,"_data",Se(e)),he(this,"wordSize",a||32),he(this,"_coerceFunc",f),he(this,"allowLoose",d),this._offset=0}get data(){return Be(this._data)}get consumed(){return this._offset}static coerce(e,a){let f=e.match("^u?int([0-9]+)$");return f&&parseInt(f[1])<=48&&(a=a.toNumber()),a}coerce(e,a){return this._coerceFunc?this._coerceFunc(e,a):V4.coerce(e,a)}_peekBytes(e,a,f){let d=Math.ceil(a/this.wordSize)*this.wordSize;return this._offset+d>this._data.length&&(this.allowLoose&&f&&this._offset+a<=this._data.length?d=a:lL.throwError("data out-of-bounds",X.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+d})),this._data.slice(this._offset,this._offset+d)}subReader(e){return new V4(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,a){let f=this._peekBytes(0,e,!!a);return this._offset+=f.length,f.slice(0,e)}readValue(){return Ee.from(this.readBytes(this.wordSize))}};s();x();s();x();s();x();var NY=Fe(cm());function N0(c){return"0x"+NY.default.keccak_256(Se(c))}var fm={};v0(fm,{decode:()=>So,encode:()=>d8});s();x();s();x();var MY="rlp/5.7.0";var Gb=new X(MY);function DY(c){let e=[];for(;c;)e.unshift(c&255),c>>=8;return e}function kY(c,e,a){let f=0;for(let d=0;d<a;d++)f=f*256+c[e+d];return f}function qY(c){if(Array.isArray(c)){let f=[];if(c.forEach(function(b){f=f.concat(qY(b))}),f.length<=55)return f.unshift(192+f.length),f;let d=DY(f.length);return d.unshift(247+d.length),d.concat(f)}a8(c)||Gb.throwArgumentError("RLP object must be BytesLike","object",c);let e=Array.prototype.slice.call(Se(c));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;let a=DY(e.length);return a.unshift(183+a.length),a.concat(e)}function d8(c){return Be(qY(c))}function UY(c,e,a,f){let d=[];for(;a<e+1+f;){let b=GY(c,a);d.push(b.result),a+=b.consumed,a>e+1+f&&Gb.throwError("child data too short",X.errors.BUFFER_OVERRUN,{})}return{consumed:1+f,result:d}}function GY(c,e){if(c.length===0&&Gb.throwError("data too short",X.errors.BUFFER_OVERRUN,{}),c[e]>=248){let a=c[e]-247;e+1+a>c.length&&Gb.throwError("data short segment too short",X.errors.BUFFER_OVERRUN,{});let f=kY(c,e+1,a);return e+1+a+f>c.length&&Gb.throwError("data long segment too short",X.errors.BUFFER_OVERRUN,{}),UY(c,e,e+1+a,a+f)}else if(c[e]>=192){let a=c[e]-192;return e+1+a>c.length&&Gb.throwError("data array too short",X.errors.BUFFER_OVERRUN,{}),UY(c,e,e+1,a)}else if(c[e]>=184){let a=c[e]-183;e+1+a>c.length&&Gb.throwError("data array too short",X.errors.BUFFER_OVERRUN,{});let f=kY(c,e+1,a);e+1+a+f>c.length&&Gb.throwError("data array too short",X.errors.BUFFER_OVERRUN,{});let d=Be(c.slice(e+1+a,e+1+a+f));return{consumed:1+a+f,result:d}}else if(c[e]>=128){let a=c[e]-128;e+1+a>c.length&&Gb.throwError("data too short",X.errors.BUFFER_OVERRUN,{});let f=Be(c.slice(e+1,e+1+a));return{consumed:1+a,result:f}}return{consumed:1,result:Be(c[e])}}function So(c){let e=Se(c),a=GY(e,0);return a.consumed!==e.length&&Gb.throwArgumentError("invalid rlp data","data",c),a.result}s();x();var zY="address/5.7.0";var k7=new X(zY);function jY(c){n0(c,20)||k7.throwArgumentError("invalid address","address",c),c=c.toLowerCase();let e=c.substring(2).split(""),a=new Uint8Array(40);for(let d=0;d<40;d++)a[d]=e[d].charCodeAt(0);let f=Se(N0(a));for(let d=0;d<40;d+=2)f[d>>1]>>4>=8&&(e[d]=e[d].toUpperCase()),(f[d>>1]&15)>=8&&(e[d+1]=e[d+1].toUpperCase());return"0x"+e.join("")}var $pe=9007199254740991;function Vpe(c){return Math.log10?Math.log10(c):Math.log(c)/Math.LN10}var uL={};for(let c=0;c<10;c++)uL[String(c)]=String(c);for(let c=0;c<26;c++)uL[String.fromCharCode(65+c)]=String(10+c);var HY=Math.floor(Vpe($pe));function $Y(c){c=c.toUpperCase(),c=c.substring(4)+c.substring(0,2)+"00";let e=c.split("").map(f=>uL[f]).join("");for(;e.length>=HY;){let f=e.substring(0,HY);e=parseInt(f,10)%97+e.substring(f.length)}let a=String(98-parseInt(e,10)%97);for(;a.length<2;)a="0"+a;return a}function M0(c){let e=null;if(typeof c!="string"&&k7.throwArgumentError("invalid address","address",c),c.match(/^(0x)?[0-9a-fA-F]{40}$/))c.substring(0,2)!=="0x"&&(c="0x"+c),e=jY(c),c.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==c&&k7.throwArgumentError("bad address checksum","address",c);else if(c.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(c.substring(2,4)!==$Y(c)&&k7.throwArgumentError("bad icap checksum","address",c),e=oL(c.substring(4));e.length<40;)e="0"+e;e=jY("0x"+e)}else k7.throwArgumentError("invalid address","address",c);return e}function VY(c){try{return M0(c),!0}catch{}return!1}function KY(c){let e=sL(M0(c).substring(2)).toUpperCase();for(;e.length<30;)e="0"+e;return"XE"+$Y("XE00"+e)+e}function K4(c){let e=null;try{e=M0(c.from)}catch{k7.throwArgumentError("missing from address","transaction",c)}let a=b2(Se(Ee.from(c.nonce).toHexString()));return M0(ya(N0(d8([e,a])),12))}function QY(c,e,a){return Cf(e)!==32&&k7.throwArgumentError("salt must be 32 bytes","salt",e),Cf(a)!==32&&k7.throwArgumentError("initCodeHash must be 32 bytes","initCodeHash",a),M0(ya(N0(O0(["0xff",M0(c),e,a])),12))}var dm=class extends Ac{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,a){try{a=M0(a)}catch(f){this._throwError(f.message,a)}return e.writeValue(a)}decode(e){return M0(q0(e.readValue().toHexString(),20))}};s();x();s();x();var bm=class extends Ac{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,a){return this.coder.encode(e,a)}decode(e){return this.coder.decode(e)}};var ht=new X(qb);function hL(c,e,a){let f=null;if(Array.isArray(a))f=a;else if(a&&typeof a=="object"){let o={};f=e.map(n=>{let i=n.localName;return i||ht.throwError("cannot encode object for signature with missing names",X.errors.INVALID_ARGUMENT,{argument:"values",coder:n,value:a}),o[i]&&ht.throwError("cannot encode object for signature with duplicate names",X.errors.INVALID_ARGUMENT,{argument:"values",coder:n,value:a}),o[i]=!0,a[i]})}else ht.throwArgumentError("invalid tuple value","tuple",a);e.length!==f.length&&ht.throwArgumentError("types/value length mismatch","tuple",a);let d=new $4(c.wordSize),b=new $4(c.wordSize),t=[];e.forEach((o,n)=>{let i=f[n];if(o.dynamic){let l=b.length;o.encode(b,i);let h=d.writeUpdatableValue();t.push(u=>{h(u+l)})}else o.encode(d,i)}),t.forEach(o=>{o(d.length)});let r=c.appendWriter(d);return r+=c.appendWriter(b),r}function pL(c,e){let a=[],f=c.subReader(0);e.forEach(b=>{let t=null;if(b.dynamic){let r=c.readValue(),o=f.subReader(r.toNumber());try{t=b.decode(o)}catch(n){if(n.code===X.errors.BUFFER_OVERRUN)throw n;t=n,t.baseType=b.name,t.name=b.localName,t.type=b.type}}else try{t=b.decode(c)}catch(r){if(r.code===X.errors.BUFFER_OVERRUN)throw r;t=r,t.baseType=b.name,t.name=b.localName,t.type=b.type}t!=null&&a.push(t)});let d=e.reduce((b,t)=>{let r=t.localName;return r&&(b[r]||(b[r]=0),b[r]++),b},{});e.forEach((b,t)=>{let r=b.localName;if(!r||d[r]!==1||(r==="length"&&(r="_length"),a[r]!=null))return;let o=a[t];o instanceof Error?Object.defineProperty(a,r,{enumerable:!0,get:()=>{throw o}}):a[r]=o});for(let b=0;b<a.length;b++){let t=a[b];t instanceof Error&&Object.defineProperty(a,b,{enumerable:!0,get:()=>{throw t}})}return Object.freeze(a)}var tm=class extends Ac{constructor(e,a,f){let d=e.type+"["+(a>=0?a:"")+"]",b=a===-1||e.dynamic;super("array",d,f,b),this.coder=e,this.length=a}defaultValue(){let e=this.coder.defaultValue(),a=[];for(let f=0;f<this.length;f++)a.push(e);return a}encode(e,a){Array.isArray(a)||this._throwError("expected array value",a);let f=this.length;f===-1&&(f=a.length,e.writeValue(a.length)),ht.checkArgumentCount(a.length,f,"coder array"+(this.localName?" "+this.localName:""));let d=[];for(let b=0;b<a.length;b++)d.push(this.coder);return hL(e,d,a)}decode(e){let a=this.length;a===-1&&(a=e.readValue().toNumber(),a*32>e._data.length&&ht.throwError("insufficient data length",X.errors.BUFFER_OVERRUN,{length:e._data.length,count:a}));let f=[];for(let d=0;d<a;d++)f.push(new bm(this.coder));return e.coerce(this.name,pL(e,f))}};s();x();var rm=class extends Ac{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,a){return e.writeValue(a?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}};s();x();var Io=class extends Ac{constructor(e,a){super(e,e,a,!0)}defaultValue(){return"0x"}encode(e,a){a=Se(a);let f=e.writeValue(a.length);return f+=e.writeBytes(a),f}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}},nm=class extends Io{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,Be(super.decode(e)))}};s();x();var im=class extends Ac{constructor(e,a){let f="bytes"+String(e);super(f,f,a,!1),this.size=e}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,a){let f=Se(a);return f.length!==this.size&&this._throwError("incorrect data length",a),e.writeBytes(f)}decode(e){return e.coerce(this.name,Be(e.readBytes(this.size)))}};s();x();var om=class extends Ac{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,a){return a!=null&&this._throwError("not null",a),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}};s();x();var hm={};v0(hm,{AddressZero:()=>sm,EtherSymbol:()=>XY,HashZero:()=>mt,MaxInt256:()=>YY,MaxUint256:()=>um,MinInt256:()=>ZY,NegativeOne:()=>xm,One:()=>lm,Two:()=>WY,WeiPerEther:()=>JY,Zero:()=>pt});s();x();s();x();var sm="0x0000000000000000000000000000000000000000";s();x();var xm=Ee.from(-1),pt=Ee.from(0),lm=Ee.from(1),WY=Ee.from(2),JY=Ee.from("1000000000000000000"),um=Ee.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),ZY=Ee.from("-0x8000000000000000000000000000000000000000000000000000000000000000"),YY=Ee.from("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");s();x();var mt="0x0000000000000000000000000000000000000000000000000000000000000000";s();x();var XY="\u039E";var pm=class extends Ac{constructor(e,a,f){let d=(a?"int":"uint")+e*8;super(d,d,f,!1),this.size=e,this.signed=a}defaultValue(){return 0}encode(e,a){let f=Ee.from(a),d=um.mask(e.wordSize*8);if(this.signed){let b=d.mask(this.size*8-1);(f.gt(b)||f.lt(b.add(lm).mul(xm)))&&this._throwError("value out-of-bounds",a)}else(f.lt(pt)||f.gt(d.mask(this.size*8)))&&this._throwError("value out-of-bounds",a);return f=f.toTwos(this.size*8).mask(this.size*8),this.signed&&(f=f.fromTwos(this.size*8).toTwos(8*e.wordSize)),e.writeValue(f)}decode(e){let a=e.readValue().mask(this.size*8);return this.signed&&(a=a.fromTwos(this.size*8)),e.coerce(this.name,a)}};s();x();s();x();s();x();s();x();s();x();var eX="strings/5.7.0";var aX=new X(eX),cd;(function(c){c.current="",c.NFC="NFC",c.NFD="NFD",c.NFKC="NFKC",c.NFKD="NFKD"})(cd||(cd={}));var Pf;(function(c){c.UNEXPECTED_CONTINUE="unexpected continuation byte",c.BAD_PREFIX="bad codepoint prefix",c.OVERRUN="string overrun",c.MISSING_CONTINUE="missing continuation byte",c.OUT_OF_RANGE="out of UTF-8 range",c.UTF16_SURROGATE="UTF-16 surrogate",c.OVERLONG="overlong representation"})(Pf||(Pf={}));function Kpe(c,e,a,f,d){return aX.throwArgumentError(`invalid codepoint at offset ${e}; ${c}`,"bytes",a)}function cX(c,e,a,f,d){if(c===Pf.BAD_PREFIX||c===Pf.UNEXPECTED_CONTINUE){let b=0;for(let t=e+1;t<a.length&&a[t]>>6===2;t++)b++;return b}return c===Pf.OVERRUN?a.length-e-1:0}function Qpe(c,e,a,f,d){return c===Pf.OVERLONG?(f.push(d),0):(f.push(65533),cX(c,e,a,f,d))}var mm=Object.freeze({error:Kpe,ignore:cX,replace:Qpe});function gL(c,e){e==null&&(e=mm.error),c=Se(c);let a=[],f=0;for(;f<c.length;){let d=c[f++];if(d>>7===0){a.push(d);continue}let b=null,t=null;if((d&224)===192)b=1,t=127;else if((d&240)===224)b=2,t=2047;else if((d&248)===240)b=3,t=65535;else{(d&192)===128?f+=e(Pf.UNEXPECTED_CONTINUE,f-1,c,a):f+=e(Pf.BAD_PREFIX,f-1,c,a);continue}if(f-1+b>=c.length){f+=e(Pf.OVERRUN,f-1,c,a);continue}let r=d&(1<<8-b-1)-1;for(let o=0;o<b;o++){let n=c[f];if((n&192)!=128){f+=e(Pf.MISSING_CONTINUE,f,c,a),r=null;break}r=r<<6|n&63,f++}if(r!==null){if(r>1114111){f+=e(Pf.OUT_OF_RANGE,f-1-b,c,a,r);continue}if(r>=55296&&r<=57343){f+=e(Pf.UTF16_SURROGATE,f-1-b,c,a,r);continue}if(r<=t){f+=e(Pf.OVERLONG,f-1-b,c,a,r);continue}a.push(r)}}return a}function J0(c,e=cd.current){e!=cd.current&&(aX.checkNormalize(),c=c.normalize(e));let a=[];for(let f=0;f<c.length;f++){let d=c.charCodeAt(f);if(d<128)a.push(d);else if(d<2048)a.push(d>>6|192),a.push(d&63|128);else if((d&64512)==55296){f++;let b=c.charCodeAt(f);if(f>=c.length||(b&64512)!==56320)throw new Error("invalid utf-8 string");let t=65536+((d&1023)<<10)+(b&1023);a.push(t>>18|240),a.push(t>>12&63|128),a.push(t>>6&63|128),a.push(t&63|128)}else a.push(d>>12|224),a.push(d>>6&63|128),a.push(d&63|128)}return Se(a)}function mL(c){let e="0000"+c.toString(16);return"\\u"+e.substring(e.length-4)}function yL(c,e){return'"'+gL(c,e).map(a=>{if(a<256){switch(a){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(a>=32&&a<127)return String.fromCharCode(a)}return a<=65535?mL(a):(a-=65536,mL((a>>10&1023)+55296)+mL((a&1023)+56320))}).join("")+'"'}function gm(c){return c.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Ld(c,e){return gm(gL(c,e))}function U7(c,e=cd.current){return gL(J0(c,e))}function wL(c){let e=J0(c);if(e.length>31)throw new Error("bytes32 string must be less than 32 bytes");return Be(O0([e,mt]).slice(0,32))}function _L(c){let e=Se(c);if(e.length!==32)throw new Error("invalid bytes32 - not 32 bytes long");if(e[31]!==0)throw new Error("invalid bytes32 string - no null terminator");let a=31;for(;e[a-1]===0;)a--;return Ld(e.slice(0,a))}s();x();function Wpe(c){if(c.length%4!==0)throw new Error("bad data");let e=[];for(let a=0;a<c.length;a+=4)e.push(parseInt(c.substring(a,a+4),16));return e}function vL(c,e){e||(e=function(d){return[parseInt(d,16)]});let a=0,f={};return c.split(",").forEach(d=>{let b=d.split(":");a+=parseInt(b[0],16),f[a]=e(b[1])}),f}function fX(c){let e=0;return c.split(",").map(a=>{let f=a.split("-");f.length===1?f[1]="0":f[1]===""&&(f[1]="1");let d=e+parseInt(f[0],16);return e=parseInt(f[1],16),{l:d,h:e}})}function EL(c,e){let a=0;for(let f=0;f<e.length;f++){let d=e[f];if(a+=d.l,c>=a&&c<=a+d.h&&(c-a)%(d.d||1)===0){if(d.e&&d.e.indexOf(c-a)!==-1)continue;return d}}return null}var Jpe=fX("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Zpe="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(c=>parseInt(c,16)),Ype=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Xpe=vL("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),eme=vL("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),ame=vL("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",Wpe),cme=fX("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function fme(c){return c.reduce((e,a)=>(a.forEach(f=>{e.push(f)}),e),[])}function dme(c){return!!EL(c,Jpe)}function bme(c){let e=EL(c,Ype);if(e)return[c+e.s];let a=Xpe[c];if(a)return a;let f=eme[c];if(f)return[c+f[0]];let d=ame[c];return d||null}function tme(c){return!!EL(c,cme)}function AL(c){if(c.match(/^[a-z0-9-]*$/i)&&c.length<=59)return c.toLowerCase();let e=U7(c);e=fme(e.map(f=>{if(Zpe.indexOf(f)>=0)return[];if(f>=65024&&f<=65039)return[];let d=bme(f);return d||[f]})),e=U7(gm(e),cd.NFKC),e.forEach(f=>{if(tme(f))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(f=>{if(dme(f))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let a=gm(e);if(a.substring(0,1)==="-"||a.substring(2,4)==="--"||a.substring(a.length-1)==="-")throw new Error("invalid hyphen");return a}var ym=class extends Io{constructor(e){super("string",e)}defaultValue(){return""}encode(e,a){return super.encode(e,J0(a))}decode(e){return Ld(super.decode(e))}};s();x();var Q4=class extends Ac{constructor(e,a){let f=!1,d=[];e.forEach(t=>{t.dynamic&&(f=!0),d.push(t.type)});let b="tuple("+d.join(",")+")";super("tuple",b,a,f),this.coders=e}defaultValue(){let e=[];this.coders.forEach(f=>{e.push(f.defaultValue())});let a=this.coders.reduce((f,d)=>{let b=d.localName;return b&&(f[b]||(f[b]=0),f[b]++),f},{});return this.coders.forEach((f,d)=>{let b=f.localName;!b||a[b]!==1||(b==="length"&&(b="_length"),e[b]==null&&(e[b]=e[d]))}),Object.freeze(e)}encode(e,a){return hL(e,this.coders,a)}decode(e){return e.coerce(this.name,pL(e,this.coders))}};var wm=new X(qb),rme=new RegExp(/^bytes([0-9]*)$/),nme=new RegExp(/^(u?int)([0-9]*)$/),gt=class{constructor(e){he(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new dm(e.name);case"bool":return new rm(e.name);case"string":return new ym(e.name);case"bytes":return new nm(e.name);case"array":return new tm(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new Q4((e.components||[]).map(f=>this._getCoder(f)),e.name);case"":return new om(e.name)}let a=e.type.match(nme);if(a){let f=parseInt(a[2]||"256");return(f===0||f>256||f%8!==0)&&wm.throwArgumentError("invalid "+a[1]+" bit length","param",e),new pm(f/8,a[1]==="int",e.name)}if(a=e.type.match(rme),a){let f=parseInt(a[1]);return(f===0||f>32)&&wm.throwArgumentError("invalid bytes length","param",e),new im(f,e.name)}return wm.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,a){return new V4(e,this._getWordSize(),this.coerceFunc,a)}_getWriter(){return new $4(this._getWordSize())}getDefaultValue(e){let a=e.map(d=>this._getCoder(Na.from(d)));return new Q4(a,"_").defaultValue()}encode(e,a){e.length!==a.length&&wm.throwError("types/values length mismatch",X.errors.INVALID_ARGUMENT,{count:{types:e.length,values:a.length},value:{types:e,values:a}});let f=e.map(t=>this._getCoder(Na.from(t))),d=new Q4(f,"_"),b=this._getWriter();return d.encode(b,a),b.data}decode(e,a,f){let d=e.map(t=>this._getCoder(Na.from(t)));return new Q4(d,"_").decode(this._getReader(Se(a),f))}},Lo=new gt;s();x();s();x();s();x();function n2(c){return N0(J0(c))}s();x();s();x();var _m="hash/5.7.0";s();x();s();x();var SL={};v0(SL,{decode:()=>yt,encode:()=>wt});s();x();s();x();function yt(c){c=atob(c);let e=[];for(let a=0;a<c.length;a++)e.push(c.charCodeAt(a));return Se(e)}function wt(c){c=Se(c);let e="";for(let a=0;a<c.length;a++)e+=String.fromCharCode(c[a]);return btoa(e)}s();x();function bX(c,e){e==null&&(e=1);let a=[],f=a.forEach,d=function(b,t){f.call(b,function(r){t>0&&Array.isArray(r)?d(r,t-1):a.push(r)})};return d(c,e),a}function ime(c){let e={};for(let a=0;a<c.length;a++){let f=c[a];e[f[0]]=f[1]}return e}function ome(c){let e=0;function a(){return c[e++]<<8|c[e++]}let f=a(),d=1,b=[0,1];for(let H=1;H<f;H++)b.push(d+=a());let t=a(),r=e;e+=t;let o=0,n=0;function i(){return o==0&&(n=n<<8|c[e++],o=8),n>>--o&1}let l=31,h=Math.pow(2,l),u=h>>>1,g=u>>1,E=h-1,_=0;for(let H=0;H<l;H++)_=_<<1|i();let F=[],L=0,U=h;for(;;){let H=Math.floor(((_-L+1)*d-1)/U),P=0,A=f;for(;A-P>1;){let j=P+A>>>1;H<b[j]?A=j:P=j}if(P==0)break;F.push(P);let I=L+Math.floor(U*b[P]/d),K=L+Math.floor(U*b[P+1]/d)-1;for(;((I^K)&u)==0;)_=_<<1&E|i(),I=I<<1&E,K=K<<1&E|1;for(;I&~K&g;)_=_&u|_<<1&E>>>1|i(),I=I<<1^u,K=(K^u)<<1|u|1;L=I,U=1+K-I}let O=f-4;return F.map(H=>{switch(H-O){case 3:return O+65792+(c[r++]<<16|c[r++]<<8|c[r++]);case 2:return O+256+(c[r++]<<8|c[r++]);case 1:return O+c[r++];default:return H-1}})}function sme(c){let e=0;return()=>c[e++]}function tX(c){return sme(ome(c))}function xme(c){return c&1?~c>>1:c>>1}function lme(c,e){let a=Array(c);for(let f=0;f<c;f++)a[f]=1+e();return a}function dX(c,e){let a=Array(c);for(let f=0,d=-1;f<c;f++)a[f]=d+=1+e();return a}function ume(c,e){let a=Array(c);for(let f=0,d=0;f<c;f++)a[f]=d+=xme(e());return a}function Fo(c,e){let a=dX(c(),c),f=c(),d=dX(f,c),b=lme(f,c);for(let t=0;t<f;t++)for(let r=0;r<b[t];r++)a.push(d[t]+r);return e?a.map(t=>e[t]):a}function rX(c){let e=[];for(;;){let a=c();if(a==0)break;e.push(pme(a,c))}for(;;){let a=c()-1;if(a<0)break;e.push(mme(a,c))}return ime(bX(e))}function hme(c){let e=[];for(;;){let a=c();if(a==0)break;e.push(a)}return e}function nX(c,e,a){let f=Array(c).fill(void 0).map(()=>[]);for(let d=0;d<e;d++)ume(c,a).forEach((b,t)=>f[t].push(b));return f}function pme(c,e){let a=1+e(),f=e(),d=hme(e),b=nX(d.length,1+c,e);return bX(b.map((t,r)=>{let o=t[0],n=t.slice(1);return Array(d[r]).fill(void 0).map((i,l)=>{let h=l*f;return[o+l*a,n.map(u=>u+h)]})}))}function mme(c,e){let a=1+e();return nX(a,1+c,e).map(d=>[d[0],d.slice(1)])}function iX(c){let e=Fo(c).sort((f,d)=>f-d);return a();function a(){let f=[];for(;;){let n=Fo(c,e);if(n.length==0)break;f.push({set:new Set(n),node:a()})}f.sort((n,i)=>i.set.size-n.set.size);let d=c(),b=d%3;d=d/3|0;let t=!!(d&1);d>>=1;let r=d==1,o=d==2;return{branches:f,valid:b,fe0f:t,save:r,check:o}}}function oX(){return tX(yt("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}var vm=oX(),gme=new Set(Fo(vm)),yme=new Set(Fo(vm)),wme=rX(vm),_me=iX(vm),sX=45,xX=95;function lX(c){return U7(c)}function vme(c){return c.filter(e=>e!=65039)}function uX(c){for(let e of c.split(".")){let a=lX(e);try{for(let f=a.lastIndexOf(xX)-1;f>=0;f--)if(a[f]!==xX)throw new Error("underscore only allowed at start");if(a.length>=4&&a.every(f=>f<128)&&a[2]===sX&&a[3]===sX)throw new Error("invalid label extension")}catch(f){throw new Error(`Invalid label "${e}": ${f.message}`)}}return c}function hX(c){return uX(Eme(c,vme))}function Eme(c,e){let a=lX(c).reverse(),f=[];for(;a.length;){let d=Sme(a);if(d){f.push(...e(d));continue}let b=a.pop();if(gme.has(b)){f.push(b);continue}if(yme.has(b))continue;let t=wme[b];if(t){f.push(...t);continue}throw new Error(`Disallowed codepoint: 0x${b.toString(16).toUpperCase()}`)}return uX(Ame(String.fromCodePoint(...f)))}function Ame(c){return c.normalize("NFC")}function Sme(c,e){var a;let f=_me,d,b,t=[],r=c.length;for(e&&(e.length=0);r;){let o=c[--r];if(f=(a=f.branches.find(n=>n.set.has(o)))===null||a===void 0?void 0:a.node,!f)break;if(f.save)b=o;else if(f.check&&o===b)break;t.push(o),f.fe0f&&(t.push(65039),r>0&&c[r-1]==65039&&r--),f.valid&&(d=t.slice(),f.valid==2&&d.splice(1,1),e&&e.push(...c.slice(r).reverse()),c.length=r)}return d}var Ime=new X(_m),mX=new Uint8Array(32);mX.fill(0);function pX(c){if(c.length===0)throw new Error("invalid ENS name; empty component");return c}function IL(c){let e=J0(hX(c)),a=[];if(c.length===0)return a;let f=0;for(let d=0;d<e.length;d++)e[d]===46&&(a.push(pX(e.slice(f,d))),f=d+1);if(f>=e.length)throw new Error("invalid ENS name; empty component");return a.push(pX(e.slice(f))),a}function LL(c){try{return IL(c).length!==0}catch{}return!1}function q7(c){typeof c!="string"&&Ime.throwArgumentError("invalid ENS name; not a string","name",c);let e=mX,a=IL(c);for(;a.length;)e=N0(O0([e,N0(a.pop())]));return Be(e)}function Co(c){return Be(O0(IL(c).map(e=>{if(e.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");let a=new Uint8Array(e.length+1);return a.set(e,1),a[0]=a.length-1,a})))+"00"}s();x();var gX=`Ethereum Signed Message:
|
|
347
347
|
`;function _t(c){return typeof c=="string"&&(c=J0(c)),N0(O0([J0(gX),J0(String(c.length)),c]))}s();x();var Lme=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Qa=new X(_m),vX=new Uint8Array(32);vX.fill(0);var Fme=Ee.from(-1),EX=Ee.from(0),AX=Ee.from(1),Cme=Ee.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function Rme(c){let e=Se(c),a=e.length%32;return a?Ec([e,vX.slice(a)]):Be(e)}var Bme=q0(AX.toHexString(),32),Pme=q0(EX.toHexString(),32),yX={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},FL=["name","version","chainId","verifyingContract","salt"];function wX(c){return function(e){return typeof e!="string"&&Qa.throwArgumentError(`invalid domain value for ${JSON.stringify(c)}`,`domain.${c}`,e),e}}var Tme={name:wX("name"),version:wX("version"),chainId:function(c){try{return Ee.from(c).toString()}catch{}return Qa.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",c)},verifyingContract:function(c){try{return M0(c).toLowerCase()}catch{}return Qa.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",c)},salt:function(c){try{let e=Se(c);if(e.length!==32)throw new Error("bad length");return Be(e)}catch{}return Qa.throwArgumentError('invalid domain value "salt"',"domain.salt",c)}};function CL(c){{let e=c.match(/^(u?)int(\d*)$/);if(e){let a=e[1]==="",f=parseInt(e[2]||"256");(f%8!==0||f>256||e[2]&&e[2]!==String(f))&&Qa.throwArgumentError("invalid numeric width","type",c);let d=Cme.mask(a?f-1:f),b=a?d.add(AX).mul(Fme):EX;return function(t){let r=Ee.from(t);return(r.lt(b)||r.gt(d))&&Qa.throwArgumentError(`value out-of-bounds for ${c}`,"value",t),q0(r.toTwos(256).toHexString(),32)}}}{let e=c.match(/^bytes(\d+)$/);if(e){let a=parseInt(e[1]);return(a===0||a>32||e[1]!==String(a))&&Qa.throwArgumentError("invalid bytes width","type",c),function(f){return Se(f).length!==a&&Qa.throwArgumentError(`invalid length for ${c}`,"value",f),Rme(f)}}}switch(c){case"address":return function(e){return q0(M0(e),32)};case"bool":return function(e){return e?Bme:Pme};case"bytes":return function(e){return N0(e)};case"string":return function(e){return n2(e)}}return null}function _X(c,e){return`${c}(${e.map(({name:a,type:f})=>f+" "+a).join(",")})`}var Wa=class{constructor(e){he(this,"types",Object.freeze(Va(e))),he(this,"_encoderCache",{}),he(this,"_types",{});let a={},f={},d={};Object.keys(e).forEach(r=>{a[r]={},f[r]=[],d[r]={}});for(let r in e){let o={};e[r].forEach(n=>{o[n.name]&&Qa.throwArgumentError(`duplicate variable name ${JSON.stringify(n.name)} in ${JSON.stringify(r)}`,"types",e),o[n.name]=!0;let i=n.type.match(/^([^\x5b]*)(\x5b|$)/)[1];i===r&&Qa.throwArgumentError(`circular type reference to ${JSON.stringify(i)}`,"types",e),!CL(i)&&(f[i]||Qa.throwArgumentError(`unknown type ${JSON.stringify(i)}`,"types",e),f[i].push(r),a[r][i]=!0)})}let b=Object.keys(f).filter(r=>f[r].length===0);b.length===0?Qa.throwArgumentError("missing primary type","types",e):b.length>1&&Qa.throwArgumentError(`ambiguous primary types or unused types: ${b.map(r=>JSON.stringify(r)).join(", ")}`,"types",e),he(this,"primaryType",b[0]);function t(r,o){o[r]&&Qa.throwArgumentError(`circular type reference to ${JSON.stringify(r)}`,"types",e),o[r]=!0,Object.keys(a[r]).forEach(n=>{!f[n]||(t(n,o),Object.keys(o).forEach(i=>{d[i][n]=!0}))}),delete o[r]}t(this.primaryType,{});for(let r in d){let o=Object.keys(d[r]);o.sort(),this._types[r]=_X(r,e[r])+o.map(n=>_X(n,e[n])).join("")}}getEncoder(e){let a=this._encoderCache[e];return a||(a=this._encoderCache[e]=this._getEncoder(e)),a}_getEncoder(e){{let d=CL(e);if(d)return d}let a=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(a){let d=a[1],b=this.getEncoder(d),t=parseInt(a[3]);return r=>{t>=0&&r.length!==t&&Qa.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",r);let o=r.map(b);return this._types[d]&&(o=o.map(N0)),N0(Ec(o))}}let f=this.types[e];if(f){let d=n2(this._types[e]);return b=>{let t=f.map(({name:r,type:o})=>{let n=this.getEncoder(o)(b[r]);return this._types[o]?N0(n):n});return t.unshift(d),Ec(t)}}return Qa.throwArgumentError(`unknown type: ${e}`,"type",e)}encodeType(e){let a=this._types[e];return a||Qa.throwArgumentError(`unknown type: ${JSON.stringify(e)}`,"name",e),a}encodeData(e,a){return this.getEncoder(e)(a)}hashStruct(e,a){return N0(this.encodeData(e,a))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,a,f){if(CL(e))return f(e,a);let d=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(d){let t=d[1],r=parseInt(d[3]);return r>=0&&a.length!==r&&Qa.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",a),a.map(o=>this._visit(t,o,f))}let b=this.types[e];return b?b.reduce((t,{name:r,type:o})=>(t[r]=this._visit(o,a[r],f),t),{}):Qa.throwArgumentError(`unknown type: ${e}`,"type",e)}visit(e,a){return this._visit(this.primaryType,e,a)}static from(e){return new Wa(e)}static getPrimaryType(e){return Wa.from(e).primaryType}static hashStruct(e,a,f){return Wa.from(a).hashStruct(e,f)}static hashDomain(e){let a=[];for(let f in e){let d=yX[f];d||Qa.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(f)}`,"domain",e),a.push({name:f,type:d})}return a.sort((f,d)=>FL.indexOf(f.name)-FL.indexOf(d.name)),Wa.hashStruct("EIP712Domain",{EIP712Domain:a},e)}static encode(e,a,f){return Ec(["0x1901",Wa.hashDomain(e),Wa.from(a).hash(f)])}static hash(e,a,f){return N0(Wa.encode(e,a,f))}static resolveNames(e,a,f,d){return Lme(this,void 0,void 0,function*(){e=ea(e);let b={};e.verifyingContract&&!n0(e.verifyingContract,20)&&(b[e.verifyingContract]="0x");let t=Wa.from(a);t.visit(f,(r,o)=>(r==="address"&&!n0(o,20)&&(b[o]="0x"),o));for(let r in b)b[r]=yield d(r);return e.verifyingContract&&b[e.verifyingContract]&&(e.verifyingContract=b[e.verifyingContract]),f=t.visit(f,(r,o)=>r==="address"&&b[o]?b[o]:o),{domain:e,value:f}})}static getPayload(e,a,f){Wa.hashDomain(e);let d={},b=[];FL.forEach(o=>{let n=e[o];n!=null&&(d[o]=Tme[o](n),b.push({name:o,type:yX[o]}))});let t=Wa.from(a),r=ea(a);return r.EIP712Domain?Qa.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",a):r.EIP712Domain=b,t.encode(f),{types:r,domain:d,primaryType:t.primaryType,message:t.visit(f,(o,n)=>{if(o.match(/^bytes(\d*)/))return Be(Se(n));if(o.match(/^u?int/))return Ee.from(n).toString();switch(o){case"address":return n.toLowerCase();case"bool":return!!n;case"string":return typeof n!="string"&&Qa.throwArgumentError("invalid string","value",n),n}return Qa.throwArgumentError("unsupported type","type",o)})}}};var Ja=new X(qb);var vt=class extends t2{},Et=class extends t2{},RL=class extends t2{},b8=class extends t2{static isIndexed(e){return!!(e&&e._isIndexed)}},Ome={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function SX(c,e){let a=new Error(`deferred error during ABI decoding triggered accessing ${c}`);return a.error=e,a}var G7=class{constructor(e){let a=[];typeof e=="string"?a=JSON.parse(e):a=e,he(this,"fragments",a.map(f=>ad.from(f)).filter(f=>f!=null)),he(this,"_abiCoder",Ka(new.target,"getAbiCoder")()),he(this,"functions",{}),he(this,"errors",{}),he(this,"events",{}),he(this,"structs",{}),this.fragments.forEach(f=>{let d=null;switch(f.type){case"constructor":if(this.deploy){Ja.warn("duplicate definition - constructor");return}he(this,"deploy",f);return;case"function":d=this.functions;break;case"event":d=this.events;break;case"error":d=this.errors;break;default:return}let b=f.format();if(d[b]){Ja.warn("duplicate definition - "+b);return}d[b]=f}),this.deploy||he(this,"deploy",Rf.from({payable:!1,type:"constructor"})),he(this,"_isInterface",!0)}format(e){e||(e=Q0.full),e===Q0.sighash&&Ja.throwArgumentError("interface does not support formatting sighash","format",e);let a=this.fragments.map(f=>f.format(e));return e===Q0.json?JSON.stringify(a.map(f=>JSON.parse(f))):a}static getAbiCoder(){return Lo}static getAddress(e){return M0(e)}static getSighash(e){return ya(n2(e.format()),0,4)}static getEventTopic(e){return n2(e.format())}getFunction(e){if(n0(e)){for(let f in this.functions)if(e===this.getSighash(f))return this.functions[f];Ja.throwArgumentError("no matching function","sighash",e)}if(e.indexOf("(")===-1){let f=e.trim(),d=Object.keys(this.functions).filter(b=>b.split("(")[0]===f);return d.length===0?Ja.throwArgumentError("no matching function","name",f):d.length>1&&Ja.throwArgumentError("multiple matching functions","name",f),this.functions[d[0]]}let a=this.functions[Bf.fromString(e).format()];return a||Ja.throwArgumentError("no matching function","signature",e),a}getEvent(e){if(n0(e)){let f=e.toLowerCase();for(let d in this.events)if(f===this.getEventTopic(d))return this.events[d];Ja.throwArgumentError("no matching event","topichash",f)}if(e.indexOf("(")===-1){let f=e.trim(),d=Object.keys(this.events).filter(b=>b.split("(")[0]===f);return d.length===0?Ja.throwArgumentError("no matching event","name",f):d.length>1&&Ja.throwArgumentError("multiple matching events","name",f),this.events[d[0]]}let a=this.events[ed.fromString(e).format()];return a||Ja.throwArgumentError("no matching event","signature",e),a}getError(e){if(n0(e)){let f=Ka(this.constructor,"getSighash");for(let d in this.errors){let b=this.errors[d];if(e===f(b))return this.errors[d]}Ja.throwArgumentError("no matching error","sighash",e)}if(e.indexOf("(")===-1){let f=e.trim(),d=Object.keys(this.errors).filter(b=>b.split("(")[0]===f);return d.length===0?Ja.throwArgumentError("no matching error","name",f):d.length>1&&Ja.throwArgumentError("multiple matching errors","name",f),this.errors[d[0]]}let a=this.errors[Bf.fromString(e).format()];return a||Ja.throwArgumentError("no matching error","signature",e),a}getSighash(e){if(typeof e=="string")try{e=this.getFunction(e)}catch(a){try{e=this.getError(e)}catch{throw a}}return Ka(this.constructor,"getSighash")(e)}getEventTopic(e){return typeof e=="string"&&(e=this.getEvent(e)),Ka(this.constructor,"getEventTopic")(e)}_decodeParams(e,a){return this._abiCoder.decode(e,a)}_encodeParams(e,a){return this._abiCoder.encode(e,a)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,a){typeof e=="string"&&(e=this.getError(e));let f=Se(a);return Be(f.slice(0,4))!==this.getSighash(e)&&Ja.throwArgumentError(`data signature does not match error ${e.name}.`,"data",Be(f)),this._decodeParams(e.inputs,f.slice(4))}encodeErrorResult(e,a){return typeof e=="string"&&(e=this.getError(e)),Be(O0([this.getSighash(e),this._encodeParams(e.inputs,a||[])]))}decodeFunctionData(e,a){typeof e=="string"&&(e=this.getFunction(e));let f=Se(a);return Be(f.slice(0,4))!==this.getSighash(e)&&Ja.throwArgumentError(`data signature does not match function ${e.name}.`,"data",Be(f)),this._decodeParams(e.inputs,f.slice(4))}encodeFunctionData(e,a){return typeof e=="string"&&(e=this.getFunction(e)),Be(O0([this.getSighash(e),this._encodeParams(e.inputs,a||[])]))}decodeFunctionResult(e,a){typeof e=="string"&&(e=this.getFunction(e));let f=Se(a),d=null,b="",t=null,r=null,o=null;switch(f.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,f)}catch{}break;case 4:{let n=Be(f.slice(0,4)),i=Ome[n];if(i)t=this._abiCoder.decode(i.inputs,f.slice(4)),r=i.name,o=i.signature,i.reason&&(d=t[0]),r==="Error"?b=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(t[0])}`:r==="Panic"&&(b=`; VM Exception while processing transaction: reverted with panic code ${t[0]}`);else try{let l=this.getError(n);t=this._abiCoder.decode(l.inputs,f.slice(4)),r=l.name,o=l.format()}catch{}break}}return Ja.throwError("call revert exception"+b,X.errors.CALL_EXCEPTION,{method:e.format(),data:Be(a),errorArgs:t,errorName:r,errorSignature:o,reason:d})}encodeFunctionResult(e,a){return typeof e=="string"&&(e=this.getFunction(e)),Be(this._abiCoder.encode(e.outputs,a||[]))}encodeFilterTopics(e,a){typeof e=="string"&&(e=this.getEvent(e)),a.length>e.inputs.length&&Ja.throwError("too many arguments for "+e.format(),X.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:a});let f=[];e.anonymous||f.push(this.getEventTopic(e));let d=(b,t)=>b.type==="string"?n2(t):b.type==="bytes"?N0(Be(t)):(b.type==="bool"&&typeof t=="boolean"&&(t=t?"0x01":"0x00"),b.type.match(/^u?int/)&&(t=Ee.from(t).toHexString()),b.type==="address"&&this._abiCoder.encode(["address"],[t]),q0(Be(t),32));for(a.forEach((b,t)=>{let r=e.inputs[t];if(!r.indexed){b!=null&&Ja.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+r.name,b);return}b==null?f.push(null):r.baseType==="array"||r.baseType==="tuple"?Ja.throwArgumentError("filtering with tuples or arrays not supported","contract."+r.name,b):Array.isArray(b)?f.push(b.map(o=>d(r,o))):f.push(d(r,b))});f.length&&f[f.length-1]===null;)f.pop();return f}encodeEventLog(e,a){typeof e=="string"&&(e=this.getEvent(e));let f=[],d=[],b=[];return e.anonymous||f.push(this.getEventTopic(e)),a.length!==e.inputs.length&&Ja.throwArgumentError("event arguments/values mismatch","values",a),e.inputs.forEach((t,r)=>{let o=a[r];if(t.indexed)if(t.type==="string")f.push(n2(o));else if(t.type==="bytes")f.push(N0(o));else{if(t.baseType==="tuple"||t.baseType==="array")throw new Error("not implemented");f.push(this._abiCoder.encode([t.type],[o]))}else d.push(t),b.push(o)}),{data:this._abiCoder.encode(d,b),topics:f}}decodeEventLog(e,a,f){if(typeof e=="string"&&(e=this.getEvent(e)),f!=null&&!e.anonymous){let h=this.getEventTopic(e);(!n0(f[0],32)||f[0].toLowerCase()!==h)&&Ja.throwError("fragment/topic mismatch",X.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:h,value:f[0]}),f=f.slice(1)}let d=[],b=[],t=[];e.inputs.forEach((h,u)=>{h.indexed?h.type==="string"||h.type==="bytes"||h.baseType==="tuple"||h.baseType==="array"?(d.push(Na.fromObject({type:"bytes32",name:h.name})),t.push(!0)):(d.push(h),t.push(!1)):(b.push(h),t.push(!1))});let r=f!=null?this._abiCoder.decode(d,O0(f)):null,o=this._abiCoder.decode(b,a,!0),n=[],i=0,l=0;e.inputs.forEach((h,u)=>{if(h.indexed)if(r==null)n[u]=new b8({_isIndexed:!0,hash:null});else if(t[u])n[u]=new b8({_isIndexed:!0,hash:r[l++]});else try{n[u]=r[l++]}catch(g){n[u]=g}else try{n[u]=o[i++]}catch(g){n[u]=g}if(h.name&&n[h.name]==null){let g=n[u];g instanceof Error?Object.defineProperty(n,h.name,{enumerable:!0,get:()=>{throw SX(`property ${JSON.stringify(h.name)}`,g)}}):n[h.name]=g}});for(let h=0;h<n.length;h++){let u=n[h];u instanceof Error&&Object.defineProperty(n,h,{enumerable:!0,get:()=>{throw SX(`index ${h}`,u)}})}return Object.freeze(n)}parseTransaction(e){let a=this.getFunction(e.data.substring(0,10).toLowerCase());return a?new Et({args:this._abiCoder.decode(a.inputs,"0x"+e.data.substring(10)),functionFragment:a,name:a.name,signature:a.format(),sighash:this.getSighash(a),value:Ee.from(e.value||"0")}):null}parseLog(e){let a=this.getEvent(e.topics[0]);return!a||a.anonymous?null:new vt({eventFragment:a,name:a.name,signature:a.format(),topic:this.getEventTopic(a),args:this.decodeEventLog(a,e.data,e.topics)})}parseError(e){let a=Be(e),f=this.getError(a.substring(0,10).toLowerCase());return f?new RL({args:this._abiCoder.decode(f.inputs,"0x"+a.substring(10)),errorFragment:f,name:f.name,signature:f.format(),sighash:this.getSighash(f)}):null}static isInterface(e){return!!(e&&e._isInterface)}};s();x();s();x();var IX="abstract-provider/5.7.0";var Nme=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Mme=new X(IX),Em=class extends t2{static isForkEvent(e){return!!(e&&e._isForkEvent)}};var Fd=class{constructor(){Mme.checkAbstract(new.target,Fd),he(this,"_isProvider",!0)}getFeeData(){return Nme(this,void 0,void 0,function*(){let{block:e,gasPrice:a}=yield wa({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(t=>null)}),f=null,d=null,b=null;return e&&e.baseFeePerGas&&(f=e.baseFeePerGas,b=Ee.from("1500000000"),d=e.baseFeePerGas.mul(2).add(b)),{lastBaseFeePerGas:f,maxFeePerGas:d,maxPriorityFeePerGas:b,gasPrice:a}})}addListener(e,a){return this.on(e,a)}removeListener(e,a){return this.off(e,a)}static isProvider(e){return!!(e&&e._isProvider)}};s();x();s();x();var LX="abstract-signer/5.7.0";var G1=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Z2=new X(LX),Dme=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],kme=[X.errors.INSUFFICIENT_FUNDS,X.errors.NONCE_EXPIRED,X.errors.REPLACEMENT_UNDERPRICED],fd=class{constructor(){Z2.checkAbstract(new.target,fd),he(this,"_isSigner",!0)}getBalance(e){return G1(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),e)})}getTransactionCount(e){return G1(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),e)})}estimateGas(e){return G1(this,void 0,void 0,function*(){this._checkProvider("estimateGas");let a=yield wa(this.checkTransaction(e));return yield this.provider.estimateGas(a)})}call(e,a){return G1(this,void 0,void 0,function*(){this._checkProvider("call");let f=yield wa(this.checkTransaction(e));return yield this.provider.call(f,a)})}sendTransaction(e){return G1(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");let a=yield this.populateTransaction(e),f=yield this.signTransaction(a);return yield this.provider.sendTransaction(f)})}getChainId(){return G1(this,void 0,void 0,function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId})}getGasPrice(){return G1(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return G1(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(e){return G1(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(e)})}checkTransaction(e){for(let f in e)Dme.indexOf(f)===-1&&Z2.throwArgumentError("invalid transaction key: "+f,"transaction",e);let a=ea(e);return a.from==null?a.from=this.getAddress():a.from=Promise.all([Promise.resolve(a.from),this.getAddress()]).then(f=>(f[0].toLowerCase()!==f[1].toLowerCase()&&Z2.throwArgumentError("from address mismatch","transaction",e),f[0])),a}populateTransaction(e){return G1(this,void 0,void 0,function*(){let a=yield wa(this.checkTransaction(e));a.to!=null&&(a.to=Promise.resolve(a.to).then(d=>G1(this,void 0,void 0,function*(){if(d==null)return null;let b=yield this.resolveName(d);return b==null&&Z2.throwArgumentError("provided ENS name resolves to null","tx.to",d),b})),a.to.catch(d=>{}));let f=a.maxFeePerGas!=null||a.maxPriorityFeePerGas!=null;if(a.gasPrice!=null&&(a.type===2||f)?Z2.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",e):(a.type===0||a.type===1)&&f&&Z2.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",e),(a.type===2||a.type==null)&&a.maxFeePerGas!=null&&a.maxPriorityFeePerGas!=null)a.type=2;else if(a.type===0||a.type===1)a.gasPrice==null&&(a.gasPrice=this.getGasPrice());else{let d=yield this.getFeeData();if(a.type==null)if(d.maxFeePerGas!=null&&d.maxPriorityFeePerGas!=null)if(a.type=2,a.gasPrice!=null){let b=a.gasPrice;delete a.gasPrice,a.maxFeePerGas=b,a.maxPriorityFeePerGas=b}else a.maxFeePerGas==null&&(a.maxFeePerGas=d.maxFeePerGas),a.maxPriorityFeePerGas==null&&(a.maxPriorityFeePerGas=d.maxPriorityFeePerGas);else d.gasPrice!=null?(f&&Z2.throwError("network does not support EIP-1559",X.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),a.gasPrice==null&&(a.gasPrice=d.gasPrice),a.type=0):Z2.throwError("failed to get consistent fee data",X.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else a.type===2&&(a.maxFeePerGas==null&&(a.maxFeePerGas=d.maxFeePerGas),a.maxPriorityFeePerGas==null&&(a.maxPriorityFeePerGas=d.maxPriorityFeePerGas))}return a.nonce==null&&(a.nonce=this.getTransactionCount("pending")),a.gasLimit==null&&(a.gasLimit=this.estimateGas(a).catch(d=>{if(kme.indexOf(d.code)>=0)throw d;return Z2.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",X.errors.UNPREDICTABLE_GAS_LIMIT,{error:d,tx:a})})),a.chainId==null?a.chainId=this.getChainId():a.chainId=Promise.all([Promise.resolve(a.chainId),this.getChainId()]).then(d=>(d[1]!==0&&d[0]!==d[1]&&Z2.throwArgumentError("chainId address mismatch","transaction",e),d[0])),yield wa(a)})}_checkProvider(e){this.provider||Z2.throwError("missing provider",X.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})}static isSigner(e){return!!(e&&e._isSigner)}},t8=class extends fd{constructor(e,a){super(),he(this,"address",e),he(this,"provider",a||null)}getAddress(){return Promise.resolve(this.address)}_fail(e,a){return Promise.resolve().then(()=>{Z2.throwError(e,X.errors.UNSUPPORTED_OPERATION,{operation:a})})}signMessage(e){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(e,a,f){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(e){return new t8(this.address,e)}};s();x();s();x();s();x();var C0=Fe(dL()),Qb=Fe(UL());function Bt(c,e,a){return a={path:e,exports:{},require:function(f,d){return rye(f,d??a.path)}},c(a,a.exports),a.exports}function rye(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var jL=oee;function oee(c,e){if(!c)throw new Error(e||"Assertion failed")}oee.equal=function(e,a,f){if(e!=a)throw new Error(f||"Assertion failed: "+e+" != "+a)};var $1=Bt(function(c,e){"use strict";var a=e;function f(t,r){if(Array.isArray(t))return t.slice();if(!t)return[];var o=[];if(typeof t!="string"){for(var n=0;n<t.length;n++)o[n]=t[n]|0;return o}if(r==="hex"){t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t);for(var n=0;n<t.length;n+=2)o.push(parseInt(t[n]+t[n+1],16))}else for(var n=0;n<t.length;n++){var i=t.charCodeAt(n),l=i>>8,h=i&255;l?o.push(l,h):o.push(h)}return o}a.toArray=f;function d(t){return t.length===1?"0"+t:t}a.zero2=d;function b(t){for(var r="",o=0;o<t.length;o++)r+=d(t[o].toString(16));return r}a.toHex=b,a.encode=function(r,o){return o==="hex"?b(r):r}}),i2=Bt(function(c,e){"use strict";var a=e;a.assert=jL,a.toArray=$1.toArray,a.zero2=$1.zero2,a.toHex=$1.toHex,a.encode=$1.encode;function f(o,n,i){var l=new Array(Math.max(o.bitLength(),i)+1);l.fill(0);for(var h=1<<n+1,u=o.clone(),g=0;g<l.length;g++){var E,_=u.andln(h-1);u.isOdd()?(_>(h>>1)-1?E=(h>>1)-_:E=_,u.isubn(E)):E=0,l[g]=E,u.iushrn(1)}return l}a.getNAF=f;function d(o,n){var i=[[],[]];o=o.clone(),n=n.clone();for(var l=0,h=0,u;o.cmpn(-l)>0||n.cmpn(-h)>0;){var g=o.andln(3)+l&3,E=n.andln(3)+h&3;g===3&&(g=-1),E===3&&(E=-1);var _;(g&1)===0?_=0:(u=o.andln(7)+l&7,(u===3||u===5)&&E===2?_=-g:_=g),i[0].push(_);var F;(E&1)===0?F=0:(u=n.andln(7)+h&7,(u===3||u===5)&&g===2?F=-E:F=E),i[1].push(F),2*l===_+1&&(l=1-l),2*h===F+1&&(h=1-h),o.iushrn(1),n.iushrn(1)}return i}a.getJSF=d;function b(o,n,i){var l="_"+n;o.prototype[n]=function(){return this[l]!==void 0?this[l]:this[l]=i.call(this)}}a.cachedProperty=b;function t(o){return typeof o=="string"?a.toArray(o,"hex"):o}a.parseBytes=t;function r(o){return new C0.default(o,"hex","le")}a.intFromLE=r}),Fm=i2.getNAF,nye=i2.getJSF,Cm=i2.assert;function H7(c,e){this.type=c,this.p=new C0.default(e.p,16),this.red=e.prime?C0.default.red(e.prime):C0.default.mont(this.p),this.zero=new C0.default(0).toRed(this.red),this.one=new C0.default(1).toRed(this.red),this.two=new C0.default(2).toRed(this.red),this.n=e.n&&new C0.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var a=this.n&&this.p.div(this.n);!a||a.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var J4=H7;H7.prototype.point=function(){throw new Error("Not implemented")};H7.prototype.validate=function(){throw new Error("Not implemented")};H7.prototype._fixedNafMul=function(e,a){Cm(e.precomputed);var f=e._getDoubles(),d=Fm(a,1,this._bitLength),b=(1<<f.step+1)-(f.step%2===0?2:1);b/=3;var t=[],r,o;for(r=0;r<d.length;r+=f.step){o=0;for(var n=r+f.step-1;n>=r;n--)o=(o<<1)+d[n];t.push(o)}for(var i=this.jpoint(null,null,null),l=this.jpoint(null,null,null),h=b;h>0;h--){for(r=0;r<t.length;r++)o=t[r],o===h?l=l.mixedAdd(f.points[r]):o===-h&&(l=l.mixedAdd(f.points[r].neg()));i=i.add(l)}return i.toP()};H7.prototype._wnafMul=function(e,a){var f=4,d=e._getNAFPoints(f);f=d.wnd;for(var b=d.points,t=Fm(a,f,this._bitLength),r=this.jpoint(null,null,null),o=t.length-1;o>=0;o--){for(var n=0;o>=0&&t[o]===0;o--)n++;if(o>=0&&n++,r=r.dblp(n),o<0)break;var i=t[o];Cm(i!==0),e.type==="affine"?i>0?r=r.mixedAdd(b[i-1>>1]):r=r.mixedAdd(b[-i-1>>1].neg()):i>0?r=r.add(b[i-1>>1]):r=r.add(b[-i-1>>1].neg())}return e.type==="affine"?r.toP():r};H7.prototype._wnafMulAdd=function(e,a,f,d,b){var t=this._wnafT1,r=this._wnafT2,o=this._wnafT3,n=0,i,l,h;for(i=0;i<d;i++){h=a[i];var u=h._getNAFPoints(e);t[i]=u.wnd,r[i]=u.points}for(i=d-1;i>=1;i-=2){var g=i-1,E=i;if(t[g]!==1||t[E]!==1){o[g]=Fm(f[g],t[g],this._bitLength),o[E]=Fm(f[E],t[E],this._bitLength),n=Math.max(o[g].length,n),n=Math.max(o[E].length,n);continue}var _=[a[g],null,null,a[E]];a[g].y.cmp(a[E].y)===0?(_[1]=a[g].add(a[E]),_[2]=a[g].toJ().mixedAdd(a[E].neg())):a[g].y.cmp(a[E].y.redNeg())===0?(_[1]=a[g].toJ().mixedAdd(a[E]),_[2]=a[g].add(a[E].neg())):(_[1]=a[g].toJ().mixedAdd(a[E]),_[2]=a[g].toJ().mixedAdd(a[E].neg()));var F=[-3,-1,-5,-7,0,7,5,1,3],L=nye(f[g],f[E]);for(n=Math.max(L[0].length,n),o[g]=new Array(n),o[E]=new Array(n),l=0;l<n;l++){var U=L[0][l]|0,O=L[1][l]|0;o[g][l]=F[(U+1)*3+(O+1)],o[E][l]=0,r[g]=_}}var H=this.jpoint(null,null,null),P=this._wnafT4;for(i=n;i>=0;i--){for(var A=0;i>=0;){var I=!0;for(l=0;l<d;l++)P[l]=o[l][i]|0,P[l]!==0&&(I=!1);if(!I)break;A++,i--}if(i>=0&&A++,H=H.dblp(A),i<0)break;for(l=0;l<d;l++){var K=P[l];K!==0&&(K>0?h=r[l][K-1>>1]:K<0&&(h=r[l][-K-1>>1].neg()),h.type==="affine"?H=H.mixedAdd(h):H=H.add(h))}}for(i=0;i<d;i++)r[i]=null;return b?H:H.toP()};function X2(c,e){this.curve=c,this.type=e,this.precomputed=null}H7.BasePoint=X2;X2.prototype.eq=function(){throw new Error("Not implemented")};X2.prototype.validate=function(){return this.curve.validate(this)};H7.prototype.decodePoint=function(e,a){e=i2.toArray(e,a);var f=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*f){e[0]===6?Cm(e[e.length-1]%2===0):e[0]===7&&Cm(e[e.length-1]%2===1);var d=this.point(e.slice(1,1+f),e.slice(1+f,1+2*f));return d}else if((e[0]===2||e[0]===3)&&e.length-1===f)return this.pointFromX(e.slice(1,1+f),e[0]===3);throw new Error("Unknown point format")};X2.prototype.encodeCompressed=function(e){return this.encode(e,!0)};X2.prototype._encode=function(e){var a=this.curve.p.byteLength(),f=this.getX().toArray("be",a);return e?[this.getY().isEven()?2:3].concat(f):[4].concat(f,this.getY().toArray("be",a))};X2.prototype.encode=function(e,a){return i2.encode(this._encode(a),e)};X2.prototype.precompute=function(e){if(this.precomputed)return this;var a={doubles:null,naf:null,beta:null};return a.naf=this._getNAFPoints(8),a.doubles=this._getDoubles(4,e),a.beta=this._getBeta(),this.precomputed=a,this};X2.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var a=this.precomputed.doubles;return a?a.points.length>=Math.ceil((e.bitLength()+1)/a.step):!1};X2.prototype._getDoubles=function(e,a){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var f=[this],d=this,b=0;b<a;b+=e){for(var t=0;t<e;t++)d=d.dbl();f.push(d)}return{step:e,points:f}};X2.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var a=[this],f=(1<<e)-1,d=f===1?null:this.dbl(),b=1;b<f;b++)a[b]=a[b-1].add(d);return{wnd:e,points:a}};X2.prototype._getBeta=function(){return null};X2.prototype.dblp=function(e){for(var a=this,f=0;f<e;f++)a=a.dbl();return a};var HL=Bt(function(c){typeof Object.create=="function"?c.exports=function(a,f){f&&(a.super_=f,a.prototype=Object.create(f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:c.exports=function(a,f){if(f){a.super_=f;var d=function(){};d.prototype=f.prototype,a.prototype=new d,a.prototype.constructor=a}}}),iye=i2.assert;function e1(c){J4.call(this,"short",c),this.a=new C0.default(c.a,16).toRed(this.red),this.b=new C0.default(c.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(c),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}HL(e1,J4);var oye=e1;e1.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var a,f;if(e.beta)a=new C0.default(e.beta,16).toRed(this.red);else{var d=this._getEndoRoots(this.p);a=d[0].cmp(d[1])<0?d[0]:d[1],a=a.toRed(this.red)}if(e.lambda)f=new C0.default(e.lambda,16);else{var b=this._getEndoRoots(this.n);this.g.mul(b[0]).x.cmp(this.g.x.redMul(a))===0?f=b[0]:(f=b[1],iye(this.g.mul(f).x.cmp(this.g.x.redMul(a))===0))}var t;return e.basis?t=e.basis.map(function(r){return{a:new C0.default(r.a,16),b:new C0.default(r.b,16)}}):t=this._getEndoBasis(f),{beta:a,lambda:f,basis:t}}};e1.prototype._getEndoRoots=function(e){var a=e===this.p?this.red:C0.default.mont(e),f=new C0.default(2).toRed(a).redInvm(),d=f.redNeg(),b=new C0.default(3).toRed(a).redNeg().redSqrt().redMul(f),t=d.redAdd(b).fromRed(),r=d.redSub(b).fromRed();return[t,r]};e1.prototype._getEndoBasis=function(e){for(var a=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=e,d=this.n.clone(),b=new C0.default(1),t=new C0.default(0),r=new C0.default(0),o=new C0.default(1),n,i,l,h,u,g,E,_=0,F,L;f.cmpn(0)!==0;){var U=d.div(f);F=d.sub(U.mul(f)),L=r.sub(U.mul(b));var O=o.sub(U.mul(t));if(!l&&F.cmp(a)<0)n=E.neg(),i=b,l=F.neg(),h=L;else if(l&&++_===2)break;E=F,d=f,f=F,r=b,b=L,o=t,t=O}u=F.neg(),g=L;var H=l.sqr().add(h.sqr()),P=u.sqr().add(g.sqr());return P.cmp(H)>=0&&(u=n,g=i),l.negative&&(l=l.neg(),h=h.neg()),u.negative&&(u=u.neg(),g=g.neg()),[{a:l,b:h},{a:u,b:g}]};e1.prototype._endoSplit=function(e){var a=this.endo.basis,f=a[0],d=a[1],b=d.b.mul(e).divRound(this.n),t=f.b.neg().mul(e).divRound(this.n),r=b.mul(f.a),o=t.mul(d.a),n=b.mul(f.b),i=t.mul(d.b),l=e.sub(r).sub(o),h=n.add(i).neg();return{k1:l,k2:h}};e1.prototype.pointFromX=function(e,a){e=new C0.default(e,16),e.red||(e=e.toRed(this.red));var f=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),d=f.redSqrt();if(d.redSqr().redSub(f).cmp(this.zero)!==0)throw new Error("invalid point");var b=d.fromRed().isOdd();return(a&&!b||!a&&b)&&(d=d.redNeg()),this.point(e,d)};e1.prototype.validate=function(e){if(e.inf)return!0;var a=e.x,f=e.y,d=this.a.redMul(a),b=a.redSqr().redMul(a).redIAdd(d).redIAdd(this.b);return f.redSqr().redISub(b).cmpn(0)===0};e1.prototype._endoWnafMulAdd=function(e,a,f){for(var d=this._endoWnafT1,b=this._endoWnafT2,t=0;t<e.length;t++){var r=this._endoSplit(a[t]),o=e[t],n=o._getBeta();r.k1.negative&&(r.k1.ineg(),o=o.neg(!0)),r.k2.negative&&(r.k2.ineg(),n=n.neg(!0)),d[t*2]=o,d[t*2+1]=n,b[t*2]=r.k1,b[t*2+1]=r.k2}for(var i=this._wnafMulAdd(1,d,b,t*2,f),l=0;l<t*2;l++)d[l]=null,b[l]=null;return i};function Vc(c,e,a,f){J4.BasePoint.call(this,c,"affine"),e===null&&a===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new C0.default(e,16),this.y=new C0.default(a,16),f&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}HL(Vc,J4.BasePoint);e1.prototype.point=function(e,a,f){return new Vc(this,e,a,f)};e1.prototype.pointFromJSON=function(e,a){return Vc.fromJSON(this,e,a)};Vc.prototype._getBeta=function(){if(!!this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var a=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var f=this.curve,d=function(b){return f.point(b.x.redMul(f.endo.beta),b.y)};e.beta=a,a.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(d)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(d)}}}return a}};Vc.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]};Vc.fromJSON=function(e,a,f){typeof a=="string"&&(a=JSON.parse(a));var d=e.point(a[0],a[1],f);if(!a[2])return d;function b(r){return e.point(r[0],r[1],f)}var t=a[2];return d.precomputed={beta:null,doubles:t.doubles&&{step:t.doubles.step,points:[d].concat(t.doubles.points.map(b))},naf:t.naf&&{wnd:t.naf.wnd,points:[d].concat(t.naf.points.map(b))}},d};Vc.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"};Vc.prototype.isInfinity=function(){return this.inf};Vc.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var a=this.y.redSub(e.y);a.cmpn(0)!==0&&(a=a.redMul(this.x.redSub(e.x).redInvm()));var f=a.redSqr().redISub(this.x).redISub(e.x),d=a.redMul(this.x.redSub(f)).redISub(this.y);return this.curve.point(f,d)};Vc.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var a=this.curve.a,f=this.x.redSqr(),d=e.redInvm(),b=f.redAdd(f).redIAdd(f).redIAdd(a).redMul(d),t=b.redSqr().redISub(this.x.redAdd(this.x)),r=b.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,r)};Vc.prototype.getX=function(){return this.x.fromRed()};Vc.prototype.getY=function(){return this.y.fromRed()};Vc.prototype.mul=function(e){return e=new C0.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};Vc.prototype.mulAdd=function(e,a,f){var d=[this,a],b=[e,f];return this.curve.endo?this.curve._endoWnafMulAdd(d,b):this.curve._wnafMulAdd(1,d,b,2)};Vc.prototype.jmulAdd=function(e,a,f){var d=[this,a],b=[e,f];return this.curve.endo?this.curve._endoWnafMulAdd(d,b,!0):this.curve._wnafMulAdd(1,d,b,2,!0)};Vc.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};Vc.prototype.neg=function(e){if(this.inf)return this;var a=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var f=this.precomputed,d=function(b){return b.neg()};a.precomputed={naf:f.naf&&{wnd:f.naf.wnd,points:f.naf.points.map(d)},doubles:f.doubles&&{step:f.doubles.step,points:f.doubles.points.map(d)}}}return a};Vc.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function nf(c,e,a,f){J4.BasePoint.call(this,c,"jacobian"),e===null&&a===null&&f===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new C0.default(0)):(this.x=new C0.default(e,16),this.y=new C0.default(a,16),this.z=new C0.default(f,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}HL(nf,J4.BasePoint);e1.prototype.jpoint=function(e,a,f){return new nf(this,e,a,f)};nf.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),a=e.redSqr(),f=this.x.redMul(a),d=this.y.redMul(a).redMul(e);return this.curve.point(f,d)};nf.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};nf.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var a=e.z.redSqr(),f=this.z.redSqr(),d=this.x.redMul(a),b=e.x.redMul(f),t=this.y.redMul(a.redMul(e.z)),r=e.y.redMul(f.redMul(this.z)),o=d.redSub(b),n=t.redSub(r);if(o.cmpn(0)===0)return n.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var i=o.redSqr(),l=i.redMul(o),h=d.redMul(i),u=n.redSqr().redIAdd(l).redISub(h).redISub(h),g=n.redMul(h.redISub(u)).redISub(t.redMul(l)),E=this.z.redMul(e.z).redMul(o);return this.curve.jpoint(u,g,E)};nf.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var a=this.z.redSqr(),f=this.x,d=e.x.redMul(a),b=this.y,t=e.y.redMul(a).redMul(this.z),r=f.redSub(d),o=b.redSub(t);if(r.cmpn(0)===0)return o.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var n=r.redSqr(),i=n.redMul(r),l=f.redMul(n),h=o.redSqr().redIAdd(i).redISub(l).redISub(l),u=o.redMul(l.redISub(h)).redISub(b.redMul(i)),g=this.z.redMul(r);return this.curve.jpoint(h,u,g)};nf.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var a;if(this.curve.zeroA||this.curve.threeA){var f=this;for(a=0;a<e;a++)f=f.dbl();return f}var d=this.curve.a,b=this.curve.tinv,t=this.x,r=this.y,o=this.z,n=o.redSqr().redSqr(),i=r.redAdd(r);for(a=0;a<e;a++){var l=t.redSqr(),h=i.redSqr(),u=h.redSqr(),g=l.redAdd(l).redIAdd(l).redIAdd(d.redMul(n)),E=t.redMul(h),_=g.redSqr().redISub(E.redAdd(E)),F=E.redISub(_),L=g.redMul(F);L=L.redIAdd(L).redISub(u);var U=i.redMul(o);a+1<e&&(n=n.redMul(u)),t=_,o=U,i=L}return this.curve.jpoint(t,i.redMul(b),o)};nf.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};nf.prototype._zeroDbl=function(){var e,a,f;if(this.zOne){var d=this.x.redSqr(),b=this.y.redSqr(),t=b.redSqr(),r=this.x.redAdd(b).redSqr().redISub(d).redISub(t);r=r.redIAdd(r);var o=d.redAdd(d).redIAdd(d),n=o.redSqr().redISub(r).redISub(r),i=t.redIAdd(t);i=i.redIAdd(i),i=i.redIAdd(i),e=n,a=o.redMul(r.redISub(n)).redISub(i),f=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),h=this.y.redSqr(),u=h.redSqr(),g=this.x.redAdd(h).redSqr().redISub(l).redISub(u);g=g.redIAdd(g);var E=l.redAdd(l).redIAdd(l),_=E.redSqr(),F=u.redIAdd(u);F=F.redIAdd(F),F=F.redIAdd(F),e=_.redISub(g).redISub(g),a=E.redMul(g.redISub(e)).redISub(F),f=this.y.redMul(this.z),f=f.redIAdd(f)}return this.curve.jpoint(e,a,f)};nf.prototype._threeDbl=function(){var e,a,f;if(this.zOne){var d=this.x.redSqr(),b=this.y.redSqr(),t=b.redSqr(),r=this.x.redAdd(b).redSqr().redISub(d).redISub(t);r=r.redIAdd(r);var o=d.redAdd(d).redIAdd(d).redIAdd(this.curve.a),n=o.redSqr().redISub(r).redISub(r);e=n;var i=t.redIAdd(t);i=i.redIAdd(i),i=i.redIAdd(i),a=o.redMul(r.redISub(n)).redISub(i),f=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),h=this.y.redSqr(),u=this.x.redMul(h),g=this.x.redSub(l).redMul(this.x.redAdd(l));g=g.redAdd(g).redIAdd(g);var E=u.redIAdd(u);E=E.redIAdd(E);var _=E.redAdd(E);e=g.redSqr().redISub(_),f=this.y.redAdd(this.z).redSqr().redISub(h).redISub(l);var F=h.redSqr();F=F.redIAdd(F),F=F.redIAdd(F),F=F.redIAdd(F),a=g.redMul(E.redISub(e)).redISub(F)}return this.curve.jpoint(e,a,f)};nf.prototype._dbl=function(){var e=this.curve.a,a=this.x,f=this.y,d=this.z,b=d.redSqr().redSqr(),t=a.redSqr(),r=f.redSqr(),o=t.redAdd(t).redIAdd(t).redIAdd(e.redMul(b)),n=a.redAdd(a);n=n.redIAdd(n);var i=n.redMul(r),l=o.redSqr().redISub(i.redAdd(i)),h=i.redISub(l),u=r.redSqr();u=u.redIAdd(u),u=u.redIAdd(u),u=u.redIAdd(u);var g=o.redMul(h).redISub(u),E=f.redAdd(f).redMul(d);return this.curve.jpoint(l,g,E)};nf.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),a=this.y.redSqr(),f=this.z.redSqr(),d=a.redSqr(),b=e.redAdd(e).redIAdd(e),t=b.redSqr(),r=this.x.redAdd(a).redSqr().redISub(e).redISub(d);r=r.redIAdd(r),r=r.redAdd(r).redIAdd(r),r=r.redISub(t);var o=r.redSqr(),n=d.redIAdd(d);n=n.redIAdd(n),n=n.redIAdd(n),n=n.redIAdd(n);var i=b.redIAdd(r).redSqr().redISub(t).redISub(o).redISub(n),l=a.redMul(i);l=l.redIAdd(l),l=l.redIAdd(l);var h=this.x.redMul(o).redISub(l);h=h.redIAdd(h),h=h.redIAdd(h);var u=this.y.redMul(i.redMul(n.redISub(i)).redISub(r.redMul(o)));u=u.redIAdd(u),u=u.redIAdd(u),u=u.redIAdd(u);var g=this.z.redAdd(r).redSqr().redISub(f).redISub(o);return this.curve.jpoint(h,u,g)};nf.prototype.mul=function(e,a){return e=new C0.default(e,a),this.curve._wnafMul(this,e)};nf.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var a=this.z.redSqr(),f=e.z.redSqr();if(this.x.redMul(f).redISub(e.x.redMul(a)).cmpn(0)!==0)return!1;var d=a.redMul(this.z),b=f.redMul(e.z);return this.y.redMul(b).redISub(e.y.redMul(d)).cmpn(0)===0};nf.prototype.eqXToP=function(e){var a=this.z.redSqr(),f=e.toRed(this.curve.red).redMul(a);if(this.x.cmp(f)===0)return!0;for(var d=e.clone(),b=this.curve.redN.redMul(a);;){if(d.iadd(this.curve.n),d.cmp(this.curve.p)>=0)return!1;if(f.redIAdd(b),this.x.cmp(f)===0)return!0}};nf.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"};nf.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Im=Bt(function(c,e){"use strict";var a=e;a.base=J4,a.short=oye,a.mont=null,a.edwards=null}),Lm=Bt(function(c,e){"use strict";var a=e,f=i2.assert;function d(r){r.type==="short"?this.curve=new Im.short(r):r.type==="edwards"?this.curve=new Im.edwards(r):this.curve=new Im.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,f(this.g.validate(),"Invalid curve"),f(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}a.PresetCurve=d;function b(r,o){Object.defineProperty(a,r,{configurable:!0,enumerable:!0,get:function(){var n=new d(o);return Object.defineProperty(a,r,{configurable:!0,enumerable:!0,value:n}),n}})}b("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Qb.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),b("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Qb.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),b("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Qb.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),b("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Qb.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),b("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Qb.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),b("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Qb.default.sha256,gRed:!1,g:["9"]}),b("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Qb.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var t;try{t=null.crash()}catch{t=void 0}b("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Qb.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",t]})});function j7(c){if(!(this instanceof j7))return new j7(c);this.hash=c.hash,this.predResist=!!c.predResist,this.outLen=this.hash.outSize,this.minEntropy=c.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=$1.toArray(c.entropy,c.entropyEnc||"hex"),a=$1.toArray(c.nonce,c.nonceEnc||"hex"),f=$1.toArray(c.pers,c.persEnc||"hex");jL(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,a,f)}var see=j7;j7.prototype._init=function(e,a,f){var d=e.concat(a).concat(f);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var b=0;b<this.V.length;b++)this.K[b]=0,this.V[b]=1;this._update(d),this._reseed=1,this.reseedInterval=281474976710656};j7.prototype._hmac=function(){return new Qb.default.hmac(this.hash,this.K)};j7.prototype._update=function(e){var a=this._hmac().update(this.V).update([0]);e&&(a=a.update(e)),this.K=a.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())};j7.prototype.reseed=function(e,a,f,d){typeof a!="string"&&(d=f,f=a,a=null),e=$1.toArray(e,a),f=$1.toArray(f,d),jL(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(f||[])),this._reseed=1};j7.prototype.generate=function(e,a,f,d){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof a!="string"&&(d=f,f=a,a=null),f&&(f=$1.toArray(f,d||"hex"),this._update(f));for(var b=[];b.length<e;)this.V=this._hmac().update(this.V).digest(),b=b.concat(this.V);var t=b.slice(0,e);return this._update(f),this._reseed++,$1.encode(t,a)};var zL=i2.assert;function Tf(c,e){this.ec=c,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var $L=Tf;Tf.fromPublic=function(e,a,f){return a instanceof Tf?a:new Tf(e,{pub:a,pubEnc:f})};Tf.fromPrivate=function(e,a,f){return a instanceof Tf?a:new Tf(e,{priv:a,privEnc:f})};Tf.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Tf.prototype.getPublic=function(e,a){return typeof e=="string"&&(a=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),a?this.pub.encode(a,e):this.pub};Tf.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Tf.prototype._importPrivate=function(e,a){this.priv=new C0.default(e,a||16),this.priv=this.priv.umod(this.ec.curve.n)};Tf.prototype._importPublic=function(e,a){if(e.x||e.y){this.ec.curve.type==="mont"?zL(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&zL(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,a)};Tf.prototype.derive=function(e){return e.validate()||zL(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Tf.prototype.sign=function(e,a,f){return this.ec.sign(e,this,a,f)};Tf.prototype.verify=function(e,a){return this.ec.verify(e,a,this)};Tf.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var sye=i2.assert;function Rm(c,e){if(c instanceof Rm)return c;this._importDER(c,e)||(sye(c.r&&c.s,"Signature without r or s"),this.r=new C0.default(c.r,16),this.s=new C0.default(c.s,16),c.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=c.recoveryParam)}var Bm=Rm;function xye(){this.place=0}function qL(c,e){var a=c[e.place++];if(!(a&128))return a;var f=a&15;if(f===0||f>4)return!1;for(var d=0,b=0,t=e.place;b<f;b++,t++)d<<=8,d|=c[t],d>>>=0;return d<=127?!1:(e.place=t,d)}function iee(c){for(var e=0,a=c.length-1;!c[e]&&!(c[e+1]&128)&&e<a;)e++;return e===0?c:c.slice(e)}Rm.prototype._importDER=function(e,a){e=i2.toArray(e,a);var f=new xye;if(e[f.place++]!==48)return!1;var d=qL(e,f);if(d===!1||d+f.place!==e.length||e[f.place++]!==2)return!1;var b=qL(e,f);if(b===!1)return!1;var t=e.slice(f.place,b+f.place);if(f.place+=b,e[f.place++]!==2)return!1;var r=qL(e,f);if(r===!1||e.length!==r+f.place)return!1;var o=e.slice(f.place,r+f.place);if(t[0]===0)if(t[1]&128)t=t.slice(1);else return!1;if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;return this.r=new C0.default(t),this.s=new C0.default(o),this.recoveryParam=null,!0};function GL(c,e){if(e<128){c.push(e);return}var a=1+(Math.log(e)/Math.LN2>>>3);for(c.push(a|128);--a;)c.push(e>>>(a<<3)&255);c.push(e)}Rm.prototype.toDER=function(e){var a=this.r.toArray(),f=this.s.toArray();for(a[0]&128&&(a=[0].concat(a)),f[0]&128&&(f=[0].concat(f)),a=iee(a),f=iee(f);!f[0]&&!(f[1]&128);)f=f.slice(1);var d=[2];GL(d,a.length),d=d.concat(a),d.push(2),GL(d,f.length);var b=d.concat(f),t=[48];return GL(t,b.length),t=t.concat(b),i2.encode(t,e)};var lye=function(){throw new Error("unsupported")},xee=i2.assert;function Y2(c){if(!(this instanceof Y2))return new Y2(c);typeof c=="string"&&(xee(Object.prototype.hasOwnProperty.call(Lm,c),"Unknown curve "+c),c=Lm[c]),c instanceof Lm.PresetCurve&&(c={curve:c}),this.curve=c.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=c.curve.g,this.g.precompute(c.curve.n.bitLength()+1),this.hash=c.hash||c.curve.hash}var uye=Y2;Y2.prototype.keyPair=function(e){return new $L(this,e)};Y2.prototype.keyFromPrivate=function(e,a){return $L.fromPrivate(this,e,a)};Y2.prototype.keyFromPublic=function(e,a){return $L.fromPublic(this,e,a)};Y2.prototype.genKeyPair=function(e){e||(e={});for(var a=new see({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||lye(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),f=this.n.byteLength(),d=this.n.sub(new C0.default(2));;){var b=new C0.default(a.generate(f));if(!(b.cmp(d)>0))return b.iaddn(1),this.keyFromPrivate(b)}};Y2.prototype._truncateToN=function(e,a){var f=e.byteLength()*8-this.n.bitLength();return f>0&&(e=e.ushrn(f)),!a&&e.cmp(this.n)>=0?e.sub(this.n):e};Y2.prototype.sign=function(e,a,f,d){typeof f=="object"&&(d=f,f=null),d||(d={}),a=this.keyFromPrivate(a,f),e=this._truncateToN(new C0.default(e,16));for(var b=this.n.byteLength(),t=a.getPrivate().toArray("be",b),r=e.toArray("be",b),o=new see({hash:this.hash,entropy:t,nonce:r,pers:d.pers,persEnc:d.persEnc||"utf8"}),n=this.n.sub(new C0.default(1)),i=0;;i++){var l=d.k?d.k(i):new C0.default(o.generate(this.n.byteLength()));if(l=this._truncateToN(l,!0),!(l.cmpn(1)<=0||l.cmp(n)>=0)){var h=this.g.mul(l);if(!h.isInfinity()){var u=h.getX(),g=u.umod(this.n);if(g.cmpn(0)!==0){var E=l.invm(this.n).mul(g.mul(a.getPrivate()).iadd(e));if(E=E.umod(this.n),E.cmpn(0)!==0){var _=(h.getY().isOdd()?1:0)|(u.cmp(g)!==0?2:0);return d.canonical&&E.cmp(this.nh)>0&&(E=this.n.sub(E),_^=1),new Bm({r:g,s:E,recoveryParam:_})}}}}}};Y2.prototype.verify=function(e,a,f,d){e=this._truncateToN(new C0.default(e,16)),f=this.keyFromPublic(f,d),a=new Bm(a,"hex");var b=a.r,t=a.s;if(b.cmpn(1)<0||b.cmp(this.n)>=0||t.cmpn(1)<0||t.cmp(this.n)>=0)return!1;var r=t.invm(this.n),o=r.mul(e).umod(this.n),n=r.mul(b).umod(this.n),i;return this.curve._maxwellTrick?(i=this.g.jmulAdd(o,f.getPublic(),n),i.isInfinity()?!1:i.eqXToP(b)):(i=this.g.mulAdd(o,f.getPublic(),n),i.isInfinity()?!1:i.getX().umod(this.n).cmp(b)===0)};Y2.prototype.recoverPubKey=function(c,e,a,f){xee((3&a)===a,"The recovery param is more than two bits"),e=new Bm(e,f);var d=this.n,b=new C0.default(c),t=e.r,r=e.s,o=a&1,n=a>>1;if(t.cmp(this.curve.p.umod(this.curve.n))>=0&&n)throw new Error("Unable to find sencond key candinate");n?t=this.curve.pointFromX(t.add(this.curve.n),o):t=this.curve.pointFromX(t,o);var i=e.r.invm(d),l=d.sub(b).mul(i).umod(d),h=r.mul(i).umod(d);return this.g.mulAdd(l,t,h)};Y2.prototype.getKeyRecoveryParam=function(c,e,a,f){if(e=new Bm(e,f),e.recoveryParam!==null)return e.recoveryParam;for(var d=0;d<4;d++){var b;try{b=this.recoverPubKey(c,e,d)}catch{continue}if(b.eq(a))return d}throw new Error("Unable to find valid recovery factor")};var hye=Bt(function(c,e){"use strict";var a=e;a.version="6.5.4",a.utils=i2,a.rand=function(){throw new Error("unsupported")},a.curve=Im,a.curves=Lm,a.ec=uye,a.eddsa=null}),lee=hye.ec;s();x();var uee="signing-key/5.7.0";var KL=new X(uee),VL=null;function Wb(){return VL||(VL=new lee("secp256k1")),VL}var a1=class{constructor(e){he(this,"curve","secp256k1"),he(this,"privateKey",Be(e)),Cf(this.privateKey)!==32&&KL.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let a=Wb().keyFromPrivate(Se(this.privateKey));he(this,"publicKey","0x"+a.getPublic(!1,"hex")),he(this,"compressedPublicKey","0x"+a.getPublic(!0,"hex")),he(this,"_isSigningKey",!0)}_addPoint(e){let a=Wb().keyFromPublic(Se(this.publicKey)),f=Wb().keyFromPublic(Se(e));return"0x"+a.pub.add(f.pub).encodeCompressed("hex")}signDigest(e){let a=Wb().keyFromPrivate(Se(this.privateKey)),f=Se(e);f.length!==32&&KL.throwArgumentError("bad digest length","digest",e);let d=a.sign(f,{canonical:!0});return Ub({recoveryParam:d.recoveryParam,r:q0("0x"+d.r.toString(16),32),s:q0("0x"+d.s.toString(16),32)})}computeSharedSecret(e){let a=Wb().keyFromPrivate(Se(this.privateKey)),f=Wb().keyFromPublic(Se(Po(e)));return q0("0x"+a.derive(f.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};function Pm(c,e){let a=Ub(e),f={r:Se(a.r),s:Se(a.s)};return"0x"+Wb().recoverPubKey(Se(c),f,a.recoveryParam).encode("hex",!1)}function Po(c,e){let a=Se(c);if(a.length===32){let f=new a1(a);return e?"0x"+Wb().keyFromPrivate(a).getPublic(!0,"hex"):f.publicKey}else{if(a.length===33)return e?Be(a):"0x"+Wb().keyFromPublic(a).getPublic(!1,"hex");if(a.length===65)return e?"0x"+Wb().keyFromPublic(a).getPublic(!0,"hex"):Be(a)}return KL.throwArgumentError("invalid public or private key","key","[REDACTED]")}s();x();var hee="transactions/5.7.0";var Nf=new X(hee),Tm;(function(c){c[c.legacy=0]="legacy",c[c.eip2930=1]="eip2930",c[c.eip1559=2]="eip1559"})(Tm||(Tm={}));function WL(c){return c==="0x"?null:M0(c)}function Of(c){return c==="0x"?pt:Ee.from(c)}var pye=[{name:"nonce",maxLength:32,numeric:!0},{name:"gasPrice",maxLength:32,numeric:!0},{name:"gasLimit",maxLength:32,numeric:!0},{name:"to",length:20},{name:"value",maxLength:32,numeric:!0},{name:"data"}],mye={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,type:!0,value:!0};function c1(c){let e=Po(c);return M0(ya(N0(ya(e,1)),12))}function Z4(c,e){return c1(Pm(Se(c),e))}function o2(c,e){let a=b2(Ee.from(c).toHexString());return a.length>32&&Nf.throwArgumentError("invalid length for "+e,"transaction:"+e,c),a}function QL(c,e){return{address:M0(c),storageKeys:(e||[]).map((a,f)=>(Cf(a)!==32&&Nf.throwArgumentError("invalid access list storageKey",`accessList[${c}:${f}]`,a),a.toLowerCase()))}}function s2(c){if(Array.isArray(c))return c.map((a,f)=>Array.isArray(a)?(a.length>2&&Nf.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${f}]`,a),QL(a[0],a[1])):QL(a.address,a.storageKeys));let e=Object.keys(c).map(a=>{let f=c[a].reduce((d,b)=>(d[b]=!0,d),{});return QL(a,Object.keys(f).sort())});return e.sort((a,f)=>a.address.localeCompare(f.address)),e}function pee(c){return s2(c).map(e=>[e.address,e.storageKeys])}function mee(c,e){if(c.gasPrice!=null){let f=Ee.from(c.gasPrice),d=Ee.from(c.maxFeePerGas||0);f.eq(d)||Nf.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:f,maxFeePerGas:d})}let a=[o2(c.chainId||0,"chainId"),o2(c.nonce||0,"nonce"),o2(c.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),o2(c.maxFeePerGas||0,"maxFeePerGas"),o2(c.gasLimit||0,"gasLimit"),c.to!=null?M0(c.to):"0x",o2(c.value||0,"value"),c.data||"0x",pee(c.accessList||[])];if(e){let f=Ub(e);a.push(o2(f.recoveryParam,"recoveryParam")),a.push(b2(f.r)),a.push(b2(f.s))}return Ec(["0x02",d8(a)])}function gee(c,e){let a=[o2(c.chainId||0,"chainId"),o2(c.nonce||0,"nonce"),o2(c.gasPrice||0,"gasPrice"),o2(c.gasLimit||0,"gasLimit"),c.to!=null?M0(c.to):"0x",o2(c.value||0,"value"),c.data||"0x",pee(c.accessList||[])];if(e){let f=Ub(e);a.push(o2(f.recoveryParam,"recoveryParam")),a.push(b2(f.r)),a.push(b2(f.s))}return Ec(["0x01",d8(a)])}function gye(c,e){xt(c,mye);let a=[];pye.forEach(function(t){let r=c[t.name]||[],o={};t.numeric&&(o.hexPad="left"),r=Se(Be(r,o)),t.length&&r.length!==t.length&&r.length>0&&Nf.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,r),t.maxLength&&(r=b2(r),r.length>t.maxLength&&Nf.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,r)),a.push(Be(r))});let f=0;if(c.chainId!=null?(f=c.chainId,typeof f!="number"&&Nf.throwArgumentError("invalid transaction.chainId","transaction",c)):e&&!a8(e)&&e.v>28&&(f=Math.floor((e.v-35)/2)),f!==0&&(a.push(Be(f)),a.push("0x"),a.push("0x")),!e)return d8(a);let d=Ub(e),b=27+d.recoveryParam;return f!==0?(a.pop(),a.pop(),a.pop(),b+=f*2+8,d.v>28&&d.v!==b&&Nf.throwArgumentError("transaction.chainId/signature.v mismatch","signature",e)):d.v!==b&&Nf.throwArgumentError("transaction.chainId/signature.v mismatch","signature",e),a.push(Be(b)),a.push(b2(Se(d.r))),a.push(b2(Se(d.s))),d8(a)}function To(c,e){if(c.type==null||c.type===0)return c.accessList!=null&&Nf.throwArgumentError("untyped transactions do not support accessList; include type: 1","transaction",c),gye(c,e);switch(c.type){case 1:return gee(c,e);case 2:return mee(c,e);default:break}return Nf.throwError(`unsupported transaction type: ${c.type}`,X.errors.UNSUPPORTED_OPERATION,{operation:"serializeTransaction",transactionType:c.type})}function yee(c,e,a){try{let f=Of(e[0]).toNumber();if(f!==0&&f!==1)throw new Error("bad recid");c.v=f}catch{Nf.throwArgumentError("invalid v for transaction type: 1","v",e[0])}c.r=q0(e[1],32),c.s=q0(e[2],32);try{let f=N0(a(c));c.from=Z4(f,{r:c.r,s:c.s,recoveryParam:c.v})}catch{}}function yye(c){let e=So(c.slice(1));e.length!==9&&e.length!==12&&Nf.throwArgumentError("invalid component count for transaction type: 2","payload",Be(c));let a=Of(e[2]),f=Of(e[3]),d={type:2,chainId:Of(e[0]).toNumber(),nonce:Of(e[1]).toNumber(),maxPriorityFeePerGas:a,maxFeePerGas:f,gasPrice:null,gasLimit:Of(e[4]),to:WL(e[5]),value:Of(e[6]),data:e[7],accessList:s2(e[8])};return e.length===9||(d.hash=N0(c),yee(d,e.slice(9),mee)),d}function wye(c){let e=So(c.slice(1));e.length!==8&&e.length!==11&&Nf.throwArgumentError("invalid component count for transaction type: 1","payload",Be(c));let a={type:1,chainId:Of(e[0]).toNumber(),nonce:Of(e[1]).toNumber(),gasPrice:Of(e[2]),gasLimit:Of(e[3]),to:WL(e[4]),value:Of(e[5]),data:e[6],accessList:s2(e[7])};return e.length===8||(a.hash=N0(c),yee(a,e.slice(8),gee)),a}function _ye(c){let e=So(c);e.length!==9&&e.length!==6&&Nf.throwArgumentError("invalid raw transaction","rawTransaction",c);let a={nonce:Of(e[0]).toNumber(),gasPrice:Of(e[1]),gasLimit:Of(e[2]),to:WL(e[3]),value:Of(e[4]),data:e[5],chainId:0};if(e.length===6)return a;try{a.v=Ee.from(e[6]).toNumber()}catch{return a}if(a.r=q0(e[7],32),a.s=q0(e[8],32),Ee.from(a.r).isZero()&&Ee.from(a.s).isZero())a.chainId=a.v,a.v=0;else{a.chainId=Math.floor((a.v-35)/2),a.chainId<0&&(a.chainId=0);let f=a.v-27,d=e.slice(0,6);a.chainId!==0&&(d.push(Be(a.chainId)),d.push("0x"),d.push("0x"),f-=a.chainId*2+8);let b=N0(d8(d));try{a.from=Z4(b,{r:Be(a.r),s:Be(a.s),recoveryParam:f})}catch{}a.hash=N0(c)}return a.type=null,a}function Om(c){let e=Se(c);if(e[0]>127)return _ye(e);switch(e[0]){case 1:return wye(e);case 2:return yye(e);default:break}return Nf.throwError(`unsupported transaction type: ${e[0]}`,X.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:e[0]})}s();x();var wee="contracts/5.7.0";var $7=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},La=new X(wee),vye={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0,customData:!0,ccipReadEnabled:!0};function Nm(c,e){return $7(this,void 0,void 0,function*(){let a=yield e;typeof a!="string"&&La.throwArgumentError("invalid address or ENS name","name",a);try{return M0(a)}catch{}c||La.throwError("a provider or signer is needed to resolve ENS names",X.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});let f=yield c.resolveName(a);return f==null&&La.throwArgumentError("resolver or addr is not configured for ENS name","name",a),f})}function Oo(c,e,a){return $7(this,void 0,void 0,function*(){return Array.isArray(a)?yield Promise.all(a.map((f,d)=>Oo(c,Array.isArray(e)?e[d]:e[f.name],f))):a.type==="address"?yield Nm(c,e):a.type==="tuple"?yield Oo(c,e,a.components):a.baseType==="array"?Array.isArray(e)?yield Promise.all(e.map(f=>Oo(c,f,a.arrayChildren))):Promise.reject(La.makeError("invalid value for array",X.errors.INVALID_ARGUMENT,{argument:"value",value:e})):e})}function km(c,e,a){return $7(this,void 0,void 0,function*(){let f={};a.length===e.inputs.length+1&&typeof a[a.length-1]=="object"&&(f=ea(a.pop())),La.checkArgumentCount(a.length,e.inputs.length,"passed to contract"),c.signer?f.from?f.from=wa({override:Nm(c.signer,f.from),signer:c.signer.getAddress()}).then(n=>$7(this,void 0,void 0,function*(){return M0(n.signer)!==n.override&&La.throwError("Contract with a Signer cannot override from",X.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),n.override})):f.from=c.signer.getAddress():f.from&&(f.from=Nm(c.provider,f.from));let d=yield wa({args:Oo(c.signer||c.provider,a,e.inputs),address:c.resolvedAddress,overrides:wa(f)||{}}),b=c.interface.encodeFunctionData(e,d.args),t={data:b,to:d.address},r=d.overrides;if(r.nonce!=null&&(t.nonce=Ee.from(r.nonce).toNumber()),r.gasLimit!=null&&(t.gasLimit=Ee.from(r.gasLimit)),r.gasPrice!=null&&(t.gasPrice=Ee.from(r.gasPrice)),r.maxFeePerGas!=null&&(t.maxFeePerGas=Ee.from(r.maxFeePerGas)),r.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=Ee.from(r.maxPriorityFeePerGas)),r.from!=null&&(t.from=r.from),r.type!=null&&(t.type=r.type),r.accessList!=null&&(t.accessList=s2(r.accessList)),t.gasLimit==null&&e.gas!=null){let n=21e3,i=Se(b);for(let l=0;l<i.length;l++)n+=4,i[l]&&(n+=64);t.gasLimit=Ee.from(e.gas).add(n)}if(r.value){let n=Ee.from(r.value);!n.isZero()&&!e.payable&&La.throwError("non-payable method cannot override value",X.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:f.value}),t.value=n}r.customData&&(t.customData=ea(r.customData)),r.ccipReadEnabled&&(t.ccipReadEnabled=!!r.ccipReadEnabled),delete f.nonce,delete f.gasLimit,delete f.gasPrice,delete f.from,delete f.value,delete f.type,delete f.accessList,delete f.maxFeePerGas,delete f.maxPriorityFeePerGas,delete f.customData,delete f.ccipReadEnabled;let o=Object.keys(f).filter(n=>f[n]!=null);return o.length&&La.throwError(`cannot override ${o.map(n=>JSON.stringify(n)).join(",")}`,X.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:o}),t})}function Eye(c,e){return function(...a){return km(c,e,a)}}function Aye(c,e){let a=c.signer||c.provider;return function(...f){return $7(this,void 0,void 0,function*(){a||La.throwError("estimate require a provider or signer",X.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});let d=yield km(c,e,f);return yield a.estimateGas(d)})}}function vee(c,e){let a=e.wait.bind(e);e.wait=f=>a(f).then(d=>(d.events=d.logs.map(b=>{let t=Va(b),r=null;try{r=c.interface.parseLog(b)}catch{}return r&&(t.args=r.args,t.decode=(o,n)=>c.interface.decodeEventLog(r.eventFragment,o,n),t.event=r.name,t.eventSignature=r.signature),t.removeListener=()=>c.provider,t.getBlock=()=>c.provider.getBlock(d.blockHash),t.getTransaction=()=>c.provider.getTransaction(d.transactionHash),t.getTransactionReceipt=()=>Promise.resolve(d),t}),d))}function Eee(c,e,a){let f=c.signer||c.provider;return function(...d){return $7(this,void 0,void 0,function*(){let b;if(d.length===e.inputs.length+1&&typeof d[d.length-1]=="object"){let o=ea(d.pop());o.blockTag!=null&&(b=yield o.blockTag),delete o.blockTag,d.push(o)}c.deployTransaction!=null&&(yield c._deployed(b));let t=yield km(c,e,d),r=yield f.call(t,b);try{let o=c.interface.decodeFunctionResult(e,r);return a&&e.outputs.length===1&&(o=o[0]),o}catch(o){throw o.code===X.errors.CALL_EXCEPTION&&(o.address=c.address,o.args=d,o.transaction=t),o}})}}function Sye(c,e){return function(...a){return $7(this,void 0,void 0,function*(){c.signer||La.throwError("sending a transaction requires a signer",X.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),c.deployTransaction!=null&&(yield c._deployed());let f=yield km(c,e,a),d=yield c.signer.sendTransaction(f);return vee(c,d),d})}}function _ee(c,e,a){return e.constant?Eee(c,e,a):Sye(c,e)}function Aee(c){return c.address&&(c.topics==null||c.topics.length===0)?"*":(c.address||"*")+"@"+(c.topics?c.topics.map(e=>Array.isArray(e)?e.join("|"):e).join(":"):"")}var Y4=class{constructor(e,a){he(this,"tag",e),he(this,"filter",a),this._listeners=[]}addListener(e,a){this._listeners.push({listener:e,once:a})}removeListener(e){let a=!1;this._listeners=this._listeners.filter(f=>a||f.listener!==e?!0:(a=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(e=>e.listener)}listenerCount(){return this._listeners.length}run(e){let a=this.listenerCount();return this._listeners=this._listeners.filter(f=>{let d=e.slice();return setTimeout(()=>{f.listener.apply(this,d)},0),!f.once}),a}prepareEvent(e){}getEmit(e){return[e]}},JL=class extends Y4{constructor(){super("error",null)}},Mm=class extends Y4{constructor(e,a,f,d){let b={address:e},t=a.getEventTopic(f);d?(t!==d[0]&&La.throwArgumentError("topic mismatch","topics",d),b.topics=d.slice()):b.topics=[t],super(Aee(b),b),he(this,"address",e),he(this,"interface",a),he(this,"fragment",f)}prepareEvent(e){super.prepareEvent(e),e.event=this.fragment.name,e.eventSignature=this.fragment.format(),e.decode=(a,f)=>this.interface.decodeEventLog(this.fragment,a,f);try{e.args=this.interface.decodeEventLog(this.fragment,e.data,e.topics)}catch(a){e.args=null,e.decodeError=a}}getEmit(e){let a=ut(e.args);if(a.length)throw a[0].error;let f=(e.args||[]).slice();return f.push(e),f}},Dm=class extends Y4{constructor(e,a){super("*",{address:e}),he(this,"address",e),he(this,"interface",a)}prepareEvent(e){super.prepareEvent(e);try{let a=this.interface.parseLog(e);e.event=a.name,e.eventSignature=a.signature,e.decode=(f,d)=>this.interface.decodeEventLog(a.eventFragment,f,d),e.args=a.args}catch{}}},Pt=class{constructor(e,a,f){he(this,"interface",Ka(new.target,"getInterface")(a)),f==null?(he(this,"provider",null),he(this,"signer",null)):fd.isSigner(f)?(he(this,"provider",f.provider||null),he(this,"signer",f)):Fd.isProvider(f)?(he(this,"provider",f),he(this,"signer",null)):La.throwArgumentError("invalid signer or provider","signerOrProvider",f),he(this,"callStatic",{}),he(this,"estimateGas",{}),he(this,"functions",{}),he(this,"populateTransaction",{}),he(this,"filters",{});{let t={};Object.keys(this.interface.events).forEach(r=>{let o=this.interface.events[r];he(this.filters,r,(...n)=>({address:this.address,topics:this.interface.encodeFilterTopics(o,n)})),t[o.name]||(t[o.name]=[]),t[o.name].push(r)}),Object.keys(t).forEach(r=>{let o=t[r];o.length===1?he(this.filters,r,this.filters[o[0]]):La.warn(`Duplicate definition of ${r} (${o.join(", ")})`)})}if(he(this,"_runningEvents",{}),he(this,"_wrappedEmits",{}),e==null&&La.throwArgumentError("invalid contract address or ENS name","addressOrName",e),he(this,"address",e),this.provider)he(this,"resolvedAddress",Nm(this.provider,e));else try{he(this,"resolvedAddress",Promise.resolve(M0(e)))}catch{La.throwError("provider is required to use ENS name as contract address",X.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}this.resolvedAddress.catch(t=>{});let d={},b={};Object.keys(this.interface.functions).forEach(t=>{let r=this.interface.functions[t];if(b[t]){La.warn(`Duplicate ABI entry for ${JSON.stringify(t)}`);return}b[t]=!0;{let o=r.name;d[`%${o}`]||(d[`%${o}`]=[]),d[`%${o}`].push(t)}this[t]==null&&he(this,t,_ee(this,r,!0)),this.functions[t]==null&&he(this.functions,t,_ee(this,r,!1)),this.callStatic[t]==null&&he(this.callStatic,t,Eee(this,r,!0)),this.populateTransaction[t]==null&&he(this.populateTransaction,t,Eye(this,r)),this.estimateGas[t]==null&&he(this.estimateGas,t,Aye(this,r))}),Object.keys(d).forEach(t=>{let r=d[t];if(r.length>1)return;t=t.substring(1);let o=r[0];try{this[t]==null&&he(this,t,this[o])}catch{}this.functions[t]==null&&he(this.functions,t,this.functions[o]),this.callStatic[t]==null&&he(this.callStatic,t,this.callStatic[o]),this.populateTransaction[t]==null&&he(this.populateTransaction,t,this.populateTransaction[o]),this.estimateGas[t]==null&&he(this.estimateGas,t,this.estimateGas[o])})}static getContractAddress(e){return K4(e)}static getInterface(e){return G7.isInterface(e)?e:new G7(e)}deployed(){return this._deployed()}_deployed(e){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,e).then(a=>(a==="0x"&&La.throwError("contract not deployed",X.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(e){this.signer||La.throwError("sending a transactions require a signer",X.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});let a=ea(e||{});return["from","to"].forEach(function(f){a[f]!=null&&La.throwError("cannot override "+f,X.errors.UNSUPPORTED_OPERATION,{operation:f})}),a.to=this.resolvedAddress,this.deployed().then(()=>this.signer.sendTransaction(a))}connect(e){typeof e=="string"&&(e=new t8(e,this.provider));let a=new this.constructor(this.address,this.interface,e);return this.deployTransaction&&he(a,"deployTransaction",this.deployTransaction),a}attach(e){return new this.constructor(e,this.interface,this.signer||this.provider)}static isIndexed(e){return b8.isIndexed(e)}_normalizeRunningEvent(e){return this._runningEvents[e.tag]?this._runningEvents[e.tag]:e}_getRunningEvent(e){if(typeof e=="string"){if(e==="error")return this._normalizeRunningEvent(new JL);if(e==="event")return this._normalizeRunningEvent(new Y4("event",null));if(e==="*")return this._normalizeRunningEvent(new Dm(this.address,this.interface));let a=this.interface.getEvent(e);return this._normalizeRunningEvent(new Mm(this.address,this.interface,a))}if(e.topics&&e.topics.length>0){try{let f=e.topics[0];if(typeof f!="string")throw new Error("invalid topic");let d=this.interface.getEvent(f);return this._normalizeRunningEvent(new Mm(this.address,this.interface,d,e.topics))}catch{}let a={address:this.address,topics:e.topics};return this._normalizeRunningEvent(new Y4(Aee(a),a))}return this._normalizeRunningEvent(new Dm(this.address,this.interface))}_checkRunningEvents(e){if(e.listenerCount()===0){delete this._runningEvents[e.tag];let a=this._wrappedEmits[e.tag];a&&e.filter&&(this.provider.off(e.filter,a),delete this._wrappedEmits[e.tag])}}_wrapEvent(e,a,f){let d=Va(a);return d.removeListener=()=>{!f||(e.removeListener(f),this._checkRunningEvents(e))},d.getBlock=()=>this.provider.getBlock(a.blockHash),d.getTransaction=()=>this.provider.getTransaction(a.transactionHash),d.getTransactionReceipt=()=>this.provider.getTransactionReceipt(a.transactionHash),e.prepareEvent(d),d}_addEventListener(e,a,f){if(this.provider||La.throwError("events require a provider or a signer with a provider",X.errors.UNSUPPORTED_OPERATION,{operation:"once"}),e.addListener(a,f),this._runningEvents[e.tag]=e,!this._wrappedEmits[e.tag]){let d=b=>{let t=this._wrapEvent(e,b,a);if(t.decodeError==null)try{let r=e.getEmit(t);this.emit(e.filter,...r)}catch(r){t.decodeError=r.error}e.filter!=null&&this.emit("event",t),t.decodeError!=null&&this.emit("error",t.decodeError,t)};this._wrappedEmits[e.tag]=d,e.filter!=null&&this.provider.on(e.filter,d)}}queryFilter(e,a,f){let d=this._getRunningEvent(e),b=ea(d.filter);return typeof a=="string"&&n0(a,32)?(f!=null&&La.throwArgumentError("cannot specify toBlock with blockhash","toBlock",f),b.blockHash=a):(b.fromBlock=a??0,b.toBlock=f??"latest"),this.provider.getLogs(b).then(t=>t.map(r=>this._wrapEvent(d,r,null)))}on(e,a){return this._addEventListener(this._getRunningEvent(e),a,!1),this}once(e,a){return this._addEventListener(this._getRunningEvent(e),a,!0),this}emit(e,...a){if(!this.provider)return!1;let f=this._getRunningEvent(e),d=f.run(a)>0;return this._checkRunningEvents(f),d}listenerCount(e){return this.provider?e==null?Object.keys(this._runningEvents).reduce((a,f)=>a+this._runningEvents[f].listenerCount(),0):this._getRunningEvent(e).listenerCount():0}listeners(e){if(!this.provider)return[];if(e==null){let a=[];for(let f in this._runningEvents)this._runningEvents[f].listeners().forEach(d=>{a.push(d)});return a}return this._getRunningEvent(e).listeners()}removeAllListeners(e){if(!this.provider)return this;if(e==null){for(let f in this._runningEvents){let d=this._runningEvents[f];d.removeAllListeners(),this._checkRunningEvents(d)}return this}let a=this._getRunningEvent(e);return a.removeAllListeners(),this._checkRunningEvents(a),this}off(e,a){if(!this.provider)return this;let f=this._getRunningEvent(e);return f.removeListener(a),this._checkRunningEvents(f),this}removeListener(e,a){return this.off(e,a)}},X4=class extends Pt{},No=class{constructor(e,a,f){let d=null;typeof a=="string"?d=a:Q2(a)?d=Be(a):a&&typeof a.object=="string"?d=a.object:d="!",d.substring(0,2)!=="0x"&&(d="0x"+d),(!n0(d)||d.length%2)&&La.throwArgumentError("invalid bytecode","bytecode",a),f&&!fd.isSigner(f)&&La.throwArgumentError("invalid signer","signer",f),he(this,"bytecode",d),he(this,"interface",Ka(new.target,"getInterface")(e)),he(this,"signer",f||null)}getDeployTransaction(...e){let a={};if(e.length===this.interface.deploy.inputs.length+1&&typeof e[e.length-1]=="object"){a=ea(e.pop());for(let f in a)if(!vye[f])throw new Error("unknown transaction override "+f)}return["data","from","to"].forEach(f=>{a[f]!=null&&La.throwError("cannot override "+f,X.errors.UNSUPPORTED_OPERATION,{operation:f})}),a.value&&!Ee.from(a.value).isZero()&&!this.interface.deploy.payable&&La.throwError("non-payable constructor cannot override value",X.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:a.value}),La.checkArgumentCount(e.length,this.interface.deploy.inputs.length," in Contract constructor"),a.data=Be(O0([this.bytecode,this.interface.encodeDeploy(e)])),a}deploy(...e){return $7(this,void 0,void 0,function*(){let a={};e.length===this.interface.deploy.inputs.length+1&&(a=e.pop()),La.checkArgumentCount(e.length,this.interface.deploy.inputs.length," in Contract constructor");let f=yield Oo(this.signer,e,this.interface.deploy.inputs);f.push(a);let d=this.getDeployTransaction(...f),b=yield this.signer.sendTransaction(d),t=Ka(this.constructor,"getContractAddress")(b),r=Ka(this.constructor,"getContract")(t,this.interface,this.signer);return vee(r,b),he(r,"deployTransaction",b),r})}attach(e){return this.constructor.getContract(e,this.interface,this.signer)}connect(e){return new this.constructor(this.interface,this.bytecode,e)}static fromSolidity(e,a){e==null&&La.throwError("missing compiler output",X.errors.MISSING_ARGUMENT,{argument:"compilerOutput"}),typeof e=="string"&&(e=JSON.parse(e));let f=e.abi,d=null;return e.bytecode?d=e.bytecode:e.evm&&e.evm.bytecode&&(d=e.evm.bytecode),new this(f,d,a)}static getInterface(e){return X4.getInterface(e)}static getContractAddress(e){return K4(e)}static getContract(e,a,f){return new X4(e,a,f)}};s();x();s();x();s();x();var Um=class{constructor(e){he(this,"alphabet",e),he(this,"base",e.length),he(this,"_alphabetMap",{}),he(this,"_leader",e.charAt(0));for(let a=0;a<e.length;a++)this._alphabetMap[e.charAt(a)]=a}encode(e){let a=Se(e);if(a.length===0)return"";let f=[0];for(let b=0;b<a.length;++b){let t=a[b];for(let r=0;r<f.length;++r)t+=f[r]<<8,f[r]=t%this.base,t=t/this.base|0;for(;t>0;)f.push(t%this.base),t=t/this.base|0}let d="";for(let b=0;a[b]===0&&b<a.length-1;++b)d+=this._leader;for(let b=f.length-1;b>=0;--b)d+=this.alphabet[f[b]];return d}decode(e){if(typeof e!="string")throw new TypeError("Expected String");let a=[];if(e.length===0)return new Uint8Array(a);a.push(0);for(let f=0;f<e.length;f++){let d=this._alphabetMap[e[f]];if(d===void 0)throw new Error("Non-base"+this.base+" character");let b=d;for(let t=0;t<a.length;++t)b+=a[t]*this.base,a[t]=b&255,b>>=8;for(;b>0;)a.push(b&255),b>>=8}for(let f=0;e[f]===this._leader&&f<e.length-1;++f)a.push(0);return Se(new Uint8Array(a.reverse()))}},vF0=new Um("abcdefghijklmnopqrstuvwxyz234567"),o8=new Um("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");s();x();s();x();s();x();s();x();var Tt=Fe(UL());s();x();var Jb;(function(c){c.sha256="sha256",c.sha512="sha512"})(Jb||(Jb={}));s();x();var See="sha2/5.7.0";var Iye=new X(See);function Mo(c){return"0x"+Tt.default.ripemd160().update(Se(c)).digest("hex")}function Rd(c){return"0x"+Tt.default.sha256().update(Se(c)).digest("hex")}function ZL(c){return"0x"+Tt.default.sha512().update(Se(c)).digest("hex")}function s8(c,e,a){return Jb[c]||Iye.throwError("unsupported algorithm "+c,X.errors.UNSUPPORTED_OPERATION,{operation:"hmac",algorithm:c}),"0x"+Tt.default.hmac(Tt.default[c],Se(e)).update(Se(a)).digest("hex")}function e5(c,e,a,f,d){c=Se(c),e=Se(e);let b,t=1,r=new Uint8Array(f),o=new Uint8Array(e.length+4);o.set(e);let n,i;for(let l=1;l<=t;l++){o[e.length]=l>>24&255,o[e.length+1]=l>>16&255,o[e.length+2]=l>>8&255,o[e.length+3]=l&255;let h=Se(s8(d,c,o));b||(b=h.length,i=new Uint8Array(b),t=Math.ceil(f/b),n=f-(t-1)*b),i.set(h);for(let E=1;E<a;E++){h=Se(s8(d,c,h));for(let _=0;_<b;_++)i[_]^=h[_]}let u=(l-1)*b,g=l===t?n:b;r.set(Se(i).slice(0,g),u)}return Be(r)}s();x();s();x();s();x();var Iee="wordlists/5.7.0";var Lye=!1,Lee=new X(Iee),f1=class{constructor(e){Lee.checkAbstract(new.target,f1),he(this,"locale",e)}split(e){return e.toLowerCase().split(/ +/g)}join(e){return e.join(" ")}static check(e){let a=[];for(let f=0;f<2048;f++){let d=e.getWord(f);if(f!==e.getWordIndex(d))return"0x";a.push(d)}return n2(a.join(`
|
|
348
348
|
`)+`
|
|
349
|
-
`)}static register(e,a){if(a||(a=e.locale),Lye)try{let f=window;f._ethers&&f._ethers.wordlists&&(f._ethers.wordlists[a]||he(f._ethers.wordlists,a,e))}catch{}}};s();x();s();x();var Fye="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",Do=null;function Fee(c){if(Do==null&&(Do=Fye.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),f1.check(c)!=="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"))throw Do=null,new Error("BIP39 Wordlist for en (English) FAILED")}var YL=class extends f1{constructor(){super("en")}getWord(e){return Fee(this),Do[e]}getWordIndex(e){return Fee(this),Do.indexOf(e)}},XL=new YL;f1.register(XL);var a5={en:XL};s();x();var Cee="hdnode/5.7.0";var ko=new X(Cee),Cye=Ee.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Rye=J0("Bitcoin seed"),Nt=2147483648;function Bee(c){return(1<<c)-1<<8-c}function Bye(c){return(1<<c)-1}function qm(c){return q0(Be(c),32)}function Ree(c){return o8.encode(O0([c,ya(Rd(Rd(c)),0,4)]))}function eF(c){if(c==null)return a5.en;if(typeof c=="string"){let e=a5[c];return e==null&&ko.throwArgumentError("unknown locale","wordlist",c),e}return c}var Ot={},x8="m/44'/60'/0'/0/0",Kc=class{constructor(e,a,f,d,b,t,r,o){if(e!==Ot)throw new Error("HDNode constructor cannot be called directly");if(a){let n=new a1(a);he(this,"privateKey",n.privateKey),he(this,"publicKey",n.compressedPublicKey)}else he(this,"privateKey",null),he(this,"publicKey",Be(f));he(this,"parentFingerprint",d),he(this,"fingerprint",ya(Mo(Rd(this.publicKey)),0,4)),he(this,"address",c1(this.publicKey)),he(this,"chainCode",b),he(this,"index",t),he(this,"depth",r),o==null?(he(this,"mnemonic",null),he(this,"path",null)):typeof o=="string"?(he(this,"mnemonic",null),he(this,"path",o)):(he(this,"mnemonic",o),he(this,"path",o.path))}get extendedKey(){if(this.depth>=256)throw new Error("Depth too large!");return Ree(O0([this.privateKey!=null?"0x0488ADE4":"0x0488B21E",Be(this.depth),this.parentFingerprint,q0(Be(this.index),4),this.chainCode,this.privateKey!=null?O0(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new Kc(Ot,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(e){if(e>4294967295)throw new Error("invalid index - "+String(e));let a=this.path;a&&(a+="/"+(e&~Nt));let f=new Uint8Array(37);if(e&Nt){if(!this.privateKey)throw new Error("cannot derive child of neutered node");f.set(Se(this.privateKey),1),a&&(a+="'")}else f.set(Se(this.publicKey));for(let l=24;l>=0;l-=8)f[33+(l>>3)]=e>>24-l&255;let d=Se(s8(Jb.sha512,this.chainCode,f)),b=d.slice(0,32),t=d.slice(32),r=null,o=null;this.privateKey?r=qm(Ee.from(b).add(this.privateKey).mod(Cye)):o=new a1(Be(b))._addPoint(this.publicKey);let n=a,i=this.mnemonic;return i&&(n=Object.freeze({phrase:i.phrase,path:a,locale:i.locale||"en"})),new Kc(Ot,r,o,this.fingerprint,qm(t),e,this.depth+1,n)}derivePath(e){let a=e.split("/");if(a.length===0||a[0]==="m"&&this.depth!==0)throw new Error("invalid path - "+e);a[0]==="m"&&a.shift();let f=this;for(let d=0;d<a.length;d++){let b=a[d];if(b.match(/^[0-9]+'$/)){let t=parseInt(b.substring(0,b.length-1));if(t>=Nt)throw new Error("invalid path index - "+b);f=f._derive(Nt+t)}else if(b.match(/^[0-9]+$/)){let t=parseInt(b);if(t>=Nt)throw new Error("invalid path index - "+b);f=f._derive(t)}else throw new Error("invalid path component - "+b)}return f}static _fromSeed(e,a){let f=Se(e);if(f.length<16||f.length>64)throw new Error("invalid seed");let d=Se(s8(Jb.sha512,Rye,f));return new Kc(Ot,qm(d.slice(0,32)),null,"0x00000000",qm(d.slice(32)),0,0,a)}static fromMnemonic(e,a,f){return f=eF(f),e=c5(Mt(e,f),f),Kc._fromSeed(aF(e,a),{phrase:e,path:"m",locale:f.locale})}static fromSeed(e){return Kc._fromSeed(e,null)}static fromExtendedKey(e){let a=o8.decode(e);(a.length!==82||Ree(a.slice(0,78))!==e)&&ko.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let f=a[4],d=Be(a.slice(5,9)),b=parseInt(Be(a.slice(9,13)).substring(2),16),t=Be(a.slice(13,45)),r=a.slice(45,78);switch(Be(a.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new Kc(Ot,null,Be(r),d,t,b,f,null);case"0x0488ade4":case"0x04358394 ":if(r[0]!==0)break;return new Kc(Ot,Be(r.slice(1)),null,d,t,b,f,null)}return ko.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}};function aF(c,e){e||(e="");let a=J0("mnemonic"+e,cd.NFKD);return e5(J0(c,cd.NFKD),a,2048,64,"sha512")}function Mt(c,e){e=eF(e),ko.checkNormalize();let a=e.split(c);if(a.length%3!==0)throw new Error("invalid mnemonic");let f=Se(new Uint8Array(Math.ceil(11*a.length/8))),d=0;for(let n=0;n<a.length;n++){let i=e.getWordIndex(a[n].normalize("NFKD"));if(i===-1)throw new Error("invalid mnemonic");for(let l=0;l<11;l++)i&1<<10-l&&(f[d>>3]|=1<<7-d%8),d++}let b=32*a.length/3,t=a.length/3,r=Bee(t);if((Se(Rd(f.slice(0,b/8)))[0]&r)!==(f[f.length-1]&r))throw new Error("invalid checksum");return Be(f.slice(0,b/8))}function c5(c,e){if(e=eF(e),c=Se(c),c.length%4!==0||c.length<16||c.length>32)throw new Error("invalid entropy");let a=[0],f=11;for(let t=0;t<c.length;t++)f>8?(a[a.length-1]<<=8,a[a.length-1]|=c[t],f-=8):(a[a.length-1]<<=f,a[a.length-1]|=c[t]>>8-f,a.push(c[t]&Bye(8-f)),f+=3);let d=c.length/4,b=Se(Rd(c))[0]&Bee(d);return a[a.length-1]<<=d,a[a.length-1]|=b>>8-d,e.join(a.map(t=>e.getWord(t)))}function Pee(c,e){try{return Mt(c,e),!0}catch{}return!1}function Tee(c){return(typeof c!="number"||c<0||c>=Nt||c%1)&&ko.throwArgumentError("invalid account index","index",c),`m/44'/60'/${c}'/0/0`}s();x();s();x();s();x();var Oee="random/5.7.0";var cF=new X(Oee);function Pye(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof globalThis<"u")return globalThis;throw new Error("unable to locate global object")}var Nee=Pye(),Gm=Nee.crypto||Nee.msCrypto;(!Gm||!Gm.getRandomValues)&&(cF.warn("WARNING: Missing strong random number source"),Gm={getRandomValues:function(c){return cF.throwError("no secure random source avaialble",X.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});function Zb(c){(c<=0||c>1024||c%1||c!=c)&&cF.throwArgumentError("invalid length","length",c);let e=new Uint8Array(c);return Gm.getRandomValues(e),Se(e)}s();x();function Uo(c){c=c.slice();for(let e=c.length-1;e>0;e--){let a=Math.floor(Math.random()*(e+1)),f=c[e];c[e]=c[a],c[a]=f}return c}s();x();s();x();var bF=Fe(dF());s();x();var zm="json-wallets/5.7.0";s();x();function l8(c){return typeof c=="string"&&c.substring(0,2)!=="0x"&&(c="0x"+c),Se(c)}function Dt(c,e){for(c=String(c);c.length<e;)c="0"+c;return c}function qo(c){return typeof c=="string"?J0(c,cd.NFKC):Se(c)}function Za(c,e){let a=c,f=e.toLowerCase().split("/");for(let d=0;d<f.length;d++){let b=null;for(let t in a)if(t.toLowerCase()===f[d]){b=a[t];break}if(b===null)return null;a=b}return a}function Dee(c){let e=Se(c);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let a=Be(e);return[a.substring(2,10),a.substring(10,14),a.substring(14,18),a.substring(18,22),a.substring(22,34)].join("-")}var Tye=new X(zm),tF=class extends t2{isCrowdsaleAccount(e){return!!(e&&e._isCrowdsaleAccount)}};function rF(c,e){let a=JSON.parse(c);e=qo(e);let f=M0(Za(a,"ethaddr")),d=l8(Za(a,"encseed"));(!d||d.length%16!==0)&&Tye.throwArgumentError("invalid encseed","json",c);let b=Se(e5(e,e,2e3,32,"sha256")).slice(0,16),t=d.slice(0,16),r=d.slice(16),o=new bF.default.ModeOfOperation.cbc(b,t),n=bF.default.padding.pkcs7.strip(Se(o.decrypt(r))),i="";for(let u=0;u<n.length;u++)i+=String.fromCharCode(n[u]);let l=J0(i),h=N0(l);return new tF({_isCrowdsaleAccount:!0,address:f,privateKey:h})}s();x();function jm(c){let e=null;try{e=JSON.parse(c)}catch{return!1}return e.encseed&&e.ethaddr}function Hm(c){let e=null;try{e=JSON.parse(c)}catch{return!1}return!(!e.version||parseInt(e.version)!==e.version||parseInt(e.version)!==3)}function nF(c){if(jm(c))try{return M0(JSON.parse(c).ethaddr)}catch{return null}if(Hm(c))try{return M0(JSON.parse(c).address)}catch{return null}return null}s();x();var u8=Fe(dF()),$m=Fe(Uee());var Oye=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},oF=new X(zm);function qee(c){return c!=null&&c.mnemonic&&c.mnemonic.phrase}var sF=class extends t2{isKeystoreAccount(e){return!!(e&&e._isKeystoreAccount)}};function Nye(c,e,a){if(Za(c,"crypto/cipher")==="aes-128-ctr"){let d=l8(Za(c,"crypto/cipherparams/iv")),b=new u8.default.Counter(d),t=new u8.default.ModeOfOperation.ctr(e,b);return Se(t.decrypt(a))}return null}function Gee(c,e){let a=l8(Za(c,"crypto/ciphertext"));if(Be(N0(O0([e.slice(16,32),a]))).substring(2)!==Za(c,"crypto/mac").toLowerCase())throw new Error("invalid password");let d=Nye(c,e.slice(0,16),a);d||oF.throwError("unsupported cipher",X.errors.UNSUPPORTED_OPERATION,{operation:"decrypt"});let b=e.slice(32,64),t=c1(d);if(c.address){let o=c.address.toLowerCase();if(o.substring(0,2)!=="0x"&&(o="0x"+o),M0(o)!==t)throw new Error("address mismatch")}let r={_isKeystoreAccount:!0,address:t,privateKey:Be(d)};if(Za(c,"x-ethers/version")==="0.1"){let o=l8(Za(c,"x-ethers/mnemonicCiphertext")),n=l8(Za(c,"x-ethers/mnemonicCounter")),i=new u8.default.Counter(n),l=new u8.default.ModeOfOperation.ctr(b,i),h=Za(c,"x-ethers/path")||x8,u=Za(c,"x-ethers/locale")||"en",g=Se(l.decrypt(o));try{let E=c5(g,u),_=Kc.fromMnemonic(E,null,u).derivePath(h);if(_.privateKey!=r.privateKey)throw new Error("mnemonic mismatch");r.mnemonic=_.mnemonic}catch(E){if(E.code!==X.errors.INVALID_ARGUMENT||E.argument!=="wordlist")throw E}}return new sF(r)}function zee(c,e,a,f,d){return Se(e5(c,e,a,f,d))}function Mye(c,e,a,f,d){return Promise.resolve(zee(c,e,a,f,d))}function jee(c,e,a,f,d){let b=qo(e),t=Za(c,"crypto/kdf");if(t&&typeof t=="string"){let r=function(o,n){return oF.throwArgumentError("invalid key-derivation function parameters",o,n)};if(t.toLowerCase()==="scrypt"){let o=l8(Za(c,"crypto/kdfparams/salt")),n=parseInt(Za(c,"crypto/kdfparams/n")),i=parseInt(Za(c,"crypto/kdfparams/r")),l=parseInt(Za(c,"crypto/kdfparams/p"));(!n||!i||!l)&&r("kdf",t),(n&n-1)!==0&&r("N",n);let h=parseInt(Za(c,"crypto/kdfparams/dklen"));return h!==32&&r("dklen",h),f(b,o,n,i,l,64,d)}else if(t.toLowerCase()==="pbkdf2"){let o=l8(Za(c,"crypto/kdfparams/salt")),n=null,i=Za(c,"crypto/kdfparams/prf");i==="hmac-sha256"?n="sha256":i==="hmac-sha512"?n="sha512":r("prf",i);let l=parseInt(Za(c,"crypto/kdfparams/c")),h=parseInt(Za(c,"crypto/kdfparams/dklen"));return h!==32&&r("dklen",h),a(b,o,l,h,n)}}return oF.throwArgumentError("unsupported key-derivation function","kdf",t)}function Hee(c,e){let a=JSON.parse(c),f=jee(a,e,zee,$m.default.syncScrypt);return Gee(a,f)}function $ee(c,e,a){return Oye(this,void 0,void 0,function*(){let f=JSON.parse(c),d=yield jee(f,e,Mye,$m.default.scrypt,a);return Gee(f,d)})}function xF(c,e,a,f){try{if(M0(c.address)!==c1(c.privateKey))throw new Error("address/privateKey mismatch");if(qee(c)){let _=c.mnemonic;if(Kc.fromMnemonic(_.phrase,null,_.locale).derivePath(_.path||x8).privateKey!=c.privateKey)throw new Error("mnemonic mismatch")}}catch(_){return Promise.reject(_)}typeof a=="function"&&!f&&(f=a,a={}),a||(a={});let d=Se(c.privateKey),b=qo(e),t=null,r=null,o=null;if(qee(c)){let _=c.mnemonic;t=Se(Mt(_.phrase,_.locale||"en")),r=_.path||x8,o=_.locale||"en"}let n=a.client;n||(n="ethers.js");let i=null;a.salt?i=Se(a.salt):i=Zb(32);let l=null;if(a.iv){if(l=Se(a.iv),l.length!==16)throw new Error("invalid iv")}else l=Zb(16);let h=null;if(a.uuid){if(h=Se(a.uuid),h.length!==16)throw new Error("invalid uuid")}else h=Zb(16);let u=1<<17,g=8,E=1;return a.scrypt&&(a.scrypt.N&&(u=a.scrypt.N),a.scrypt.r&&(g=a.scrypt.r),a.scrypt.p&&(E=a.scrypt.p)),$m.default.scrypt(b,i,u,g,E,64,f).then(_=>{_=Se(_);let F=_.slice(0,16),L=_.slice(16,32),U=_.slice(32,64),O=new u8.default.Counter(l),H=new u8.default.ModeOfOperation.ctr(F,O),P=Se(H.encrypt(d)),A=N0(O0([L,P])),I={address:c.address.substring(2).toLowerCase(),id:Dee(h),version:3,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:Be(l).substring(2)},ciphertext:Be(P).substring(2),kdf:"scrypt",kdfparams:{salt:Be(i).substring(2),n:u,dklen:32,p:E,r:g},mac:A.substring(2)}};if(t){let K=Zb(16),j=new u8.default.Counter(K),J=new u8.default.ModeOfOperation.ctr(U,j),V=Se(J.encrypt(t)),S=new Date,y=S.getUTCFullYear()+"-"+Dt(S.getUTCMonth()+1,2)+"-"+Dt(S.getUTCDate(),2)+"T"+Dt(S.getUTCHours(),2)+"-"+Dt(S.getUTCMinutes(),2)+"-"+Dt(S.getUTCSeconds(),2)+".0Z";I["x-ethers"]={client:n,gethFilename:"UTC--"+y+"--"+I.address,mnemonicCounter:Be(K).substring(2),mnemonicCiphertext:Be(V).substring(2),path:r,locale:o,version:"0.1"}}return JSON.stringify(I)})}function Vee(c,e,a){if(jm(c)){a&&a(0);let f=rF(c,e);return a&&a(1),Promise.resolve(f)}return Hm(c)?$ee(c,e,a):Promise.reject(new Error("invalid JSON wallet"))}function Kee(c,e){if(jm(c))return rF(c,e);if(Hm(c))return Hee(c,e);throw new Error("invalid JSON wallet")}s();x();var Qee="wallet/5.7.0";var Wee=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},kt=new X(Qee);function Dye(c){return c!=null&&n0(c.privateKey,32)&&c.address!=null}function kye(c){let e=c.mnemonic;return e&&e.phrase}var V1=class extends fd{constructor(e,a){if(super(),Dye(e)){let f=new a1(e.privateKey);if(he(this,"_signingKey",()=>f),he(this,"address",c1(this.publicKey)),this.address!==M0(e.address)&&kt.throwArgumentError("privateKey/address mismatch","privateKey","[REDACTED]"),kye(e)){let d=e.mnemonic;he(this,"_mnemonic",()=>({phrase:d.phrase,path:d.path||x8,locale:d.locale||"en"}));let b=this.mnemonic,t=Kc.fromMnemonic(b.phrase,null,b.locale).derivePath(b.path);c1(t.privateKey)!==this.address&&kt.throwArgumentError("mnemonic/address mismatch","privateKey","[REDACTED]")}else he(this,"_mnemonic",()=>null)}else{if(a1.isSigningKey(e))e.curve!=="secp256k1"&&kt.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),he(this,"_signingKey",()=>e);else{typeof e=="string"&&e.match(/^[0-9a-f]*$/i)&&e.length===64&&(e="0x"+e);let f=new a1(e);he(this,"_signingKey",()=>f)}he(this,"_mnemonic",()=>null),he(this,"address",c1(this.publicKey))}a&&!Fd.isProvider(a)&&kt.throwArgumentError("invalid provider","provider",a),he(this,"provider",a||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(e){return new V1(this,e)}signTransaction(e){return wa(e).then(a=>{a.from!=null&&(M0(a.from)!==this.address&&kt.throwArgumentError("transaction from address mismatch","transaction.from",e.from),delete a.from);let f=this._signingKey().signDigest(N0(To(a)));return To(a,f)})}signMessage(e){return Wee(this,void 0,void 0,function*(){return mo(this._signingKey().signDigest(_t(e)))})}_signTypedData(e,a,f){return Wee(this,void 0,void 0,function*(){let d=yield Wa.resolveNames(e,a,f,b=>(this.provider==null&&kt.throwError("cannot resolve ENS names without a provider",X.errors.UNSUPPORTED_OPERATION,{operation:"resolveName",value:b}),this.provider.resolveName(b)));return mo(this._signingKey().signDigest(Wa.hash(d.domain,a,d.value)))})}encrypt(e,a,f){if(typeof a=="function"&&!f&&(f=a,a={}),f&&typeof f!="function")throw new Error("invalid callback");return a||(a={}),xF(this,e,a,f)}static createRandom(e){let a=Zb(16);e||(e={}),e.extraEntropy&&(a=Se(ya(N0(O0([a,e.extraEntropy])),0,16)));let f=c5(a,e.locale);return V1.fromMnemonic(f,e.path,e.locale)}static fromEncryptedJson(e,a,f){return Vee(e,a,f).then(d=>new V1(d))}static fromEncryptedJsonSync(e,a){return new V1(Kee(e,a))}static fromMnemonic(e,a,f){return a||(a=x8),new V1(Kc.fromMnemonic(e,null,f).derivePath(a))}};function Jee(c,e){return Z4(_t(c),e)}function Zee(c,e,a,f){return Z4(Wa.hash(c,e,a),f)}var ng={};v0(ng,{AlchemyProvider:()=>Ht,AlchemyWebSocketProvider:()=>Zo,AnkrProvider:()=>Yo,BaseProvider:()=>Xb,CloudflareProvider:()=>Xo,EtherscanProvider:()=>es,FallbackProvider:()=>cs,Formatter:()=>e0,InfuraProvider:()=>Vt,InfuraWebSocketProvider:()=>ds,IpcProvider:()=>SF,JsonRpcBatchProvider:()=>tg,JsonRpcProvider:()=>Bd,JsonRpcSigner:()=>zt,NodesmithProvider:()=>bs,PocketProvider:()=>ts,Provider:()=>Fd,Resolver:()=>Gt,StaticJsonRpcProvider:()=>Jo,UrlJsonRpcProvider:()=>Qc,Web3Provider:()=>rs,WebSocketProvider:()=>m8,getDefaultProvider:()=>rg,getNetwork:()=>Go,isCommunityResourcable:()=>hF,isCommunityResource:()=>Ho,showThrottleMessage:()=>Yb});s();x();s();x();s();x();var Yee="networks/5.7.1";var Xee=new X(Yee);function Uye(c){return c&&typeof c.renetwork=="function"}function h8(c){let e=function(a,f){f==null&&(f={});let d=[];if(a.InfuraProvider&&f.infura!=="-")try{d.push(new a.InfuraProvider(c,f.infura))}catch{}if(a.EtherscanProvider&&f.etherscan!=="-")try{d.push(new a.EtherscanProvider(c,f.etherscan))}catch{}if(a.AlchemyProvider&&f.alchemy!=="-")try{d.push(new a.AlchemyProvider(c,f.alchemy))}catch{}if(a.PocketProvider&&f.pocket!=="-"){let b=["goerli","ropsten","rinkeby","sepolia"];try{let t=new a.PocketProvider(c,f.pocket);t.network&&b.indexOf(t.network.name)===-1&&d.push(t)}catch{}}if(a.CloudflareProvider&&f.cloudflare!=="-")try{d.push(new a.CloudflareProvider(c))}catch{}if(a.AnkrProvider&&f.ankr!=="-")try{let b=["ropsten"],t=new a.AnkrProvider(c,f.ankr);t.network&&b.indexOf(t.network.name)===-1&&d.push(t)}catch{}if(d.length===0)return null;if(a.FallbackProvider){let b=1;return f.quorum!=null?b=f.quorum:c==="homestead"&&(b=2),new a.FallbackProvider(d,b)}return d[0]};return e.renetwork=function(a){return h8(a)},e}function Km(c,e){let a=function(f,d){return f.JsonRpcProvider?new f.JsonRpcProvider(c,e):null};return a.renetwork=function(f){return Km(c,f)},a}var e0e={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:h8("homestead")},a0e={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:h8("ropsten")},c0e={chainId:63,name:"classicMordor",_defaultProvider:Km("https://www.ethercluster.com/mordor","classicMordor")},Vm={unspecified:{chainId:0,name:"unspecified"},homestead:e0e,mainnet:e0e,morden:{chainId:2,name:"morden"},ropsten:a0e,testnet:a0e,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:h8("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:h8("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:h8("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:h8("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:Km("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:c0e,classicTestnet:c0e,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:Km("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:h8("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:h8("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function Go(c){if(c==null)return null;if(typeof c=="number"){for(let f in Vm){let d=Vm[f];if(d.chainId===c)return{name:d.name,chainId:d.chainId,ensAddress:d.ensAddress||null,_defaultProvider:d._defaultProvider||null}}return{chainId:c,name:"unknown"}}if(typeof c=="string"){let f=Vm[c];return f==null?null:{name:f.name,chainId:f.chainId,ensAddress:f.ensAddress,_defaultProvider:f._defaultProvider||null}}let e=Vm[c.name];if(!e)return typeof c.chainId!="number"&&Xee.throwArgumentError("invalid network chainId","network",c),c;c.chainId!==0&&c.chainId!==e.chainId&&Xee.throwArgumentError("network chainId mismatch","network",c);let a=c._defaultProvider||null;return a==null&&e._defaultProvider&&(Uye(e._defaultProvider)?a=e._defaultProvider.renetwork(c):a=e._defaultProvider),{name:c.name,chainId:e.chainId,ensAddress:c.ensAddress||e.ensAddress||null,_defaultProvider:a}}s();x();s();x();s();x();var f0e="web/5.7.1";s();x();var qye=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})};function d0e(c,e){return qye(this,void 0,void 0,function*(){e==null&&(e={});let a={method:e.method||"GET",headers:e.headers||{},body:e.body||void 0};if(e.skipFetchSetup!==!0&&(a.mode="cors",a.cache="no-cache",a.credentials="same-origin",a.redirect="follow",a.referrer="client"),e.fetchOptions!=null){let t=e.fetchOptions;t.mode&&(a.mode=t.mode),t.cache&&(a.cache=t.cache),t.credentials&&(a.credentials=t.credentials),t.redirect&&(a.redirect=t.redirect),t.referrer&&(a.referrer=t.referrer)}let f=yield fetch(c,a),d=yield f.arrayBuffer(),b={};return f.headers.forEach?f.headers.forEach((t,r)=>{b[r.toLowerCase()]=t}):f.headers.keys().forEach(t=>{b[t.toLowerCase()]=f.headers.get(t)}),{headers:b,statusCode:f.status,statusMessage:f.statusText,body:Se(new Uint8Array(d))}})}var Gye=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},K1=new X(f0e);function b0e(c){return new Promise(e=>{setTimeout(e,c)})}function V7(c,e){if(c==null)return null;if(typeof c=="string")return c;if(a8(c)){if(e&&(e.split("/")[0]==="text"||e.split(";")[0].trim()==="application/json"))try{return Ld(c)}catch{}return Be(c)}return c}function zye(c){return J0(c.replace(/%([0-9a-f][0-9a-f])/gi,(e,a)=>String.fromCharCode(parseInt(a,16))))}function lF(c,e,a){let f=typeof c=="object"&&c.throttleLimit!=null?c.throttleLimit:12;K1.assertArgument(f>0&&f%1===0,"invalid connection throttle limit","connection.throttleLimit",f);let d=typeof c=="object"?c.throttleCallback:null,b=typeof c=="object"&&typeof c.throttleSlotInterval=="number"?c.throttleSlotInterval:100;K1.assertArgument(b>0&&b%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",b);let t=typeof c=="object"?!!c.errorPassThrough:!1,r={},o=null,n={method:"GET"},i=!1,l=2*60*1e3;if(typeof c=="string")o=c;else if(typeof c=="object"){if((c==null||c.url==null)&&K1.throwArgumentError("missing URL","connection.url",c),o=c.url,typeof c.timeout=="number"&&c.timeout>0&&(l=c.timeout),c.headers)for(let F in c.headers)r[F.toLowerCase()]={key:F,value:String(c.headers[F])},["if-none-match","if-modified-since"].indexOf(F.toLowerCase())>=0&&(i=!0);if(n.allowGzip=!!c.allowGzip,c.user!=null&&c.password!=null){o.substring(0,6)!=="https:"&&c.allowInsecureAuthentication!==!0&&K1.throwError("basic authentication requires a secure https url",X.errors.INVALID_ARGUMENT,{argument:"url",url:o,user:c.user,password:"[REDACTED]"});let F=c.user+":"+c.password;r.authorization={key:"Authorization",value:"Basic "+wt(J0(F))}}c.skipFetchSetup!=null&&(n.skipFetchSetup=!!c.skipFetchSetup),c.fetchOptions!=null&&(n.fetchOptions=ea(c.fetchOptions))}let h=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),u=o?o.match(h):null;if(u)try{let F={statusCode:200,statusMessage:"OK",headers:{"content-type":u[1]||"text/plain"},body:u[2]?yt(u[3]):zye(u[3])},L=F.body;return a&&(L=a(F.body,F)),Promise.resolve(L)}catch(F){K1.throwError("processing response error",X.errors.SERVER_ERROR,{body:V7(u[1],u[2]),error:F,requestBody:null,requestMethod:"GET",url:o})}e&&(n.method="POST",n.body=e,r["content-type"]==null&&(r["content-type"]={key:"Content-Type",value:"application/octet-stream"}),r["content-length"]==null&&(r["content-length"]={key:"Content-Length",value:String(e.length)}));let g={};Object.keys(r).forEach(F=>{let L=r[F];g[L.key]=L.value}),n.headers=g;let E=function(){let F=null;return{promise:new Promise(function(O,H){l&&(F=setTimeout(()=>{F!=null&&(F=null,H(K1.makeError("timeout",X.errors.TIMEOUT,{requestBody:V7(n.body,g["content-type"]),requestMethod:n.method,timeout:l,url:o})))},l))}),cancel:function(){F!=null&&(clearTimeout(F),F=null)}}}(),_=function(){return Gye(this,void 0,void 0,function*(){for(let F=0;F<f;F++){let L=null;try{if(L=yield d0e(o,n),F<f){if(L.statusCode===301||L.statusCode===302){let O=L.headers.location||"";if(n.method==="GET"&&O.match(/^https:/)){o=L.headers.location;continue}}else if(L.statusCode===429){let O=!0;if(d&&(O=yield d(F,o)),O){let H=0,P=L.headers["retry-after"];typeof P=="string"&&P.match(/^[1-9][0-9]*$/)?H=parseInt(P)*1e3:H=b*parseInt(String(Math.random()*Math.pow(2,F))),yield b0e(H);continue}}}}catch(O){L=O.response,L==null&&(E.cancel(),K1.throwError("missing response",X.errors.SERVER_ERROR,{requestBody:V7(n.body,g["content-type"]),requestMethod:n.method,serverError:O,url:o}))}let U=L.body;if(i&&L.statusCode===304?U=null:!t&&(L.statusCode<200||L.statusCode>=300)&&(E.cancel(),K1.throwError("bad response",X.errors.SERVER_ERROR,{status:L.statusCode,headers:L.headers,body:V7(U,L.headers?L.headers["content-type"]:null),requestBody:V7(n.body,g["content-type"]),requestMethod:n.method,url:o})),a)try{let O=yield a(U,L);return E.cancel(),O}catch(O){if(O.throttleRetry&&F<f){let H=!0;if(d&&(H=yield d(F,o)),H){let P=b*parseInt(String(Math.random()*Math.pow(2,F)));yield b0e(P);continue}}E.cancel(),K1.throwError("processing response error",X.errors.SERVER_ERROR,{body:V7(U,L.headers?L.headers["content-type"]:null),error:O,requestBody:V7(n.body,g["content-type"]),requestMethod:n.method,url:o})}return E.cancel(),U}return K1.throwError("failed response",X.errors.SERVER_ERROR,{requestBody:V7(n.body,g["content-type"]),requestMethod:n.method,url:o})})}();return Promise.race([E.promise,_])}function Q1(c,e,a){let f=(b,t)=>{let r=null;if(b!=null)try{r=JSON.parse(Ld(b))}catch(o){K1.throwError("invalid JSON",X.errors.SERVER_ERROR,{body:b,error:o})}return a&&(r=a(r,t)),r},d=null;if(e!=null){d=J0(e);let b=typeof c=="string"?{url:c}:ea(c);b.headers?Object.keys(b.headers).filter(r=>r.toLowerCase()==="content-type").length!==0||(b.headers=ea(b.headers),b.headers["content-type"]="application/json"):b.headers={"content-type":"application/json"},c=b}return lF(c,d,f)}function W1(c,e){return e||(e={}),e=ea(e),e.floor==null&&(e.floor=0),e.ceiling==null&&(e.ceiling=1e4),e.interval==null&&(e.interval=250),new Promise(function(a,f){let d=null,b=!1,t=()=>b?!1:(b=!0,d&&clearTimeout(d),!0);e.timeout&&(d=setTimeout(()=>{t()&&f(new Error("timeout"))},e.timeout));let r=e.retryLimit,o=0;function n(){return c().then(function(i){if(i!==void 0)t()&&a(i);else if(e.oncePoll)e.oncePoll.once("poll",n);else if(e.onceBlock)e.onceBlock.once("block",n);else if(!b){if(o++,o>r){t()&&f(new Error("retry limit reached"));return}let l=e.interval*parseInt(String(Math.random()*Math.pow(2,o)));l<e.floor&&(l=e.floor),l>e.ceiling&&(l=e.ceiling),setTimeout(n,l)}return null},function(i){t()&&f(i)})}n()})}var yF=Fe(i0e());s();x();var ia="providers/5.7.2";s();x();var jo=new X(ia),e0=class{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){let e={},a=this.address.bind(this),f=this.bigNumber.bind(this),d=this.blockTag.bind(this),b=this.data.bind(this),t=this.hash.bind(this),r=this.hex.bind(this),o=this.number.bind(this),n=this.type.bind(this),i=l=>this.data(l,!0);return e.transaction={hash:t,type:n,accessList:e0.allowNull(this.accessList.bind(this),null),blockHash:e0.allowNull(t,null),blockNumber:e0.allowNull(o,null),transactionIndex:e0.allowNull(o,null),confirmations:e0.allowNull(o,null),from:a,gasPrice:e0.allowNull(f),maxPriorityFeePerGas:e0.allowNull(f),maxFeePerGas:e0.allowNull(f),gasLimit:f,to:e0.allowNull(a,null),value:f,nonce:o,data:b,r:e0.allowNull(this.uint256),s:e0.allowNull(this.uint256),v:e0.allowNull(o),creates:e0.allowNull(a,null),raw:e0.allowNull(b)},e.transactionRequest={from:e0.allowNull(a),nonce:e0.allowNull(o),gasLimit:e0.allowNull(f),gasPrice:e0.allowNull(f),maxPriorityFeePerGas:e0.allowNull(f),maxFeePerGas:e0.allowNull(f),to:e0.allowNull(a),value:e0.allowNull(f),data:e0.allowNull(i),type:e0.allowNull(o),accessList:e0.allowNull(this.accessList.bind(this),null)},e.receiptLog={transactionIndex:o,blockNumber:o,transactionHash:t,address:a,topics:e0.arrayOf(t),data:b,logIndex:o,blockHash:t},e.receipt={to:e0.allowNull(this.address,null),from:e0.allowNull(this.address,null),contractAddress:e0.allowNull(a,null),transactionIndex:o,root:e0.allowNull(r),gasUsed:f,logsBloom:e0.allowNull(b),blockHash:t,transactionHash:t,logs:e0.arrayOf(this.receiptLog.bind(this)),blockNumber:o,confirmations:e0.allowNull(o,null),cumulativeGasUsed:f,effectiveGasPrice:e0.allowNull(f),status:e0.allowNull(o),type:n},e.block={hash:e0.allowNull(t),parentHash:t,number:o,timestamp:o,nonce:e0.allowNull(r),difficulty:this.difficulty.bind(this),gasLimit:f,gasUsed:f,miner:e0.allowNull(a),extraData:b,transactions:e0.allowNull(e0.arrayOf(t)),baseFeePerGas:e0.allowNull(f)},e.blockWithTransactions=ea(e.block),e.blockWithTransactions.transactions=e0.allowNull(e0.arrayOf(this.transactionResponse.bind(this))),e.filter={fromBlock:e0.allowNull(d,void 0),toBlock:e0.allowNull(d,void 0),blockHash:e0.allowNull(t,void 0),address:e0.allowNull(a,void 0),topics:e0.allowNull(this.topics.bind(this),void 0)},e.filterLog={blockNumber:e0.allowNull(o),blockHash:e0.allowNull(t),transactionIndex:o,removed:e0.allowNull(this.boolean.bind(this)),address:a,data:e0.allowFalsish(b,"0x"),topics:e0.arrayOf(t),transactionHash:t,logIndex:o},e}accessList(e){return s2(e||[])}number(e){return e==="0x"?0:Ee.from(e).toNumber()}type(e){return e==="0x"||e==null?0:Ee.from(e).toNumber()}bigNumber(e){return Ee.from(e)}boolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){if(e=e.toLowerCase(),e==="true")return!0;if(e==="false")return!1}throw new Error("invalid boolean - "+e)}hex(e,a){return typeof e=="string"&&(!a&&e.substring(0,2)!=="0x"&&(e="0x"+e),n0(e))?e.toLowerCase():jo.throwArgumentError("invalid hash","value",e)}data(e,a){let f=this.hex(e,a);if(f.length%2!==0)throw new Error("invalid data; odd-length - "+e);return f}address(e){return M0(e)}callAddress(e){if(!n0(e,32))return null;let a=M0(ya(e,12));return a===sm?null:a}contractAddress(e){return K4(e)}blockTag(e){if(e==null)return"latest";if(e==="earliest")return"0x0";switch(e){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return e}if(typeof e=="number"||n0(e))return kb(e);throw new Error("invalid blockTag")}hash(e,a){let f=this.hex(e,a);return Cf(f)!==32?jo.throwArgumentError("invalid hash","value",e):f}difficulty(e){if(e==null)return null;let a=Ee.from(e);try{return a.toNumber()}catch{}return null}uint256(e){if(!n0(e))throw new Error("invalid uint256");return q0(e,32)}_block(e,a){e.author!=null&&e.miner==null&&(e.miner=e.author);let f=e._difficulty!=null?e._difficulty:e.difficulty,d=e0.check(a,e);return d._difficulty=f==null?null:Ee.from(f),d}block(e){return this._block(e,this.formats.block)}blockWithTransactions(e){return this._block(e,this.formats.blockWithTransactions)}transactionRequest(e){return e0.check(this.formats.transactionRequest,e)}transactionResponse(e){e.gas!=null&&e.gasLimit==null&&(e.gasLimit=e.gas),e.to&&Ee.from(e.to).isZero()&&(e.to="0x0000000000000000000000000000000000000000"),e.input!=null&&e.data==null&&(e.data=e.input),e.to==null&&e.creates==null&&(e.creates=this.contractAddress(e)),(e.type===1||e.type===2)&&e.accessList==null&&(e.accessList=[]);let a=e0.check(this.formats.transaction,e);if(e.chainId!=null){let f=e.chainId;n0(f)&&(f=Ee.from(f).toNumber()),a.chainId=f}else{let f=e.networkId;f==null&&a.v==null&&(f=e.chainId),n0(f)&&(f=Ee.from(f).toNumber()),typeof f!="number"&&a.v!=null&&(f=(a.v-35)/2,f<0&&(f=0),f=parseInt(f)),typeof f!="number"&&(f=0),a.chainId=f}return a.blockHash&&a.blockHash.replace(/0/g,"")==="x"&&(a.blockHash=null),a}transaction(e){return Om(e)}receiptLog(e){return e0.check(this.formats.receiptLog,e)}receipt(e){let a=e0.check(this.formats.receipt,e);if(a.root!=null)if(a.root.length<=4){let f=Ee.from(a.root).toNumber();f===0||f===1?(a.status!=null&&a.status!==f&&jo.throwArgumentError("alt-root-status/status mismatch","value",{root:a.root,status:a.status}),a.status=f,delete a.root):jo.throwArgumentError("invalid alt-root-status","value.root",a.root)}else a.root.length!==66&&jo.throwArgumentError("invalid root hash","value.root",a.root);return a.status!=null&&(a.byzantium=!0),a}topics(e){return Array.isArray(e)?e.map(a=>this.topics(a)):e!=null?this.hash(e,!0):null}filter(e){return e0.check(this.formats.filter,e)}filterLog(e){return e0.check(this.formats.filterLog,e)}static check(e,a){let f={};for(let d in e)try{let b=e[d](a[d]);b!==void 0&&(f[d]=b)}catch(b){throw b.checkKey=d,b.checkValue=a[d],b}return f}static allowNull(e,a){return function(f){return f==null?a:e(f)}}static allowFalsish(e,a){return function(f){return f?e(f):a}}static arrayOf(e){return function(a){if(!Array.isArray(a))throw new Error("not an array");let f=[];return a.forEach(function(d){f.push(e(d))}),f}}};function hF(c){return c&&typeof c.isCommunityResource=="function"}function Ho(c){return hF(c)&&c.isCommunityResource()}var o0e=!1;function Yb(){o0e||(o0e=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}var S0=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},G0=new X(ia),Jye=10;function s0e(c){return c==null?"null":(Cf(c)!==32&&G0.throwArgumentError("invalid topic","topic",c),c.toLowerCase())}function x0e(c){for(c=c.slice();c.length>0&&c[c.length-1]==null;)c.pop();return c.map(e=>{if(Array.isArray(e)){let a={};e.forEach(d=>{a[s0e(d)]=!0});let f=Object.keys(a);return f.sort(),f.join("|")}else return s0e(e)}).join("&")}function Zye(c){return c===""?[]:c.split(/&/g).map(e=>{if(e==="")return[];let a=e.split("|").map(f=>f==="null"?null:f);return a.length===1?a[0]:a})}function qt(c){if(typeof c=="string"){if(c=c.toLowerCase(),Cf(c)===32)return"tx:"+c;if(c.indexOf(":")===-1)return c}else{if(Array.isArray(c))return"filter:*:"+x0e(c);if(Em.isForkEvent(c))throw G0.warn("not implemented"),new Error("not implemented");if(c&&typeof c=="object")return"filter:"+(c.address||"*")+":"+x0e(c.topics||[])}throw new Error("invalid event - "+c)}function $o(){return new Date().getTime()}function l0e(c){return new Promise(e=>{setTimeout(e,c)})}var Yye=["block","network","pending","poll"],wF=class{constructor(e,a,f){he(this,"tag",e),he(this,"listener",a),he(this,"once",f),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){let e=this.tag.split(":");return e[0]!=="tx"?null:e[1]}get filter(){let e=this.tag.split(":");if(e[0]!=="filter")return null;let a=e[1],f=Zye(e[2]),d={};return f.length>0&&(d.topics=f),a&&a!=="*"&&(d.address=a),d}pollable(){return this.tag.indexOf(":")>=0||Yye.indexOf(this.tag)>=0}},Xye={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function pF(c){return q0(Ee.from(c).toHexString(),32)}function u0e(c){return o8.encode(O0([c,ya(Rd(Rd(c)),0,4)]))}var m0e=new RegExp("^(ipfs)://(.*)$","i"),h0e=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),m0e,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function Zm(c,e){try{return Ld(Vo(c,e))}catch{}return null}function Vo(c,e){if(c==="0x")return null;let a=Ee.from(ya(c,e,e+32)).toNumber(),f=Ee.from(ya(c,a,a+32)).toNumber();return ya(c,a+32,a+32+f)}function mF(c){return c.match(/^ipfs:\/\/ipfs\//i)?c=c.substring(12):c.match(/^ipfs:\/\//i)?c=c.substring(7):G0.throwArgumentError("unsupported IPFS format","link",c),`https://gateway.ipfs.io/ipfs/${c}`}function p0e(c){let e=Se(c);if(e.length>32)throw new Error("internal; should not happen");let a=new Uint8Array(32);return a.set(e,32-e.length),a}function ewe(c){if(c.length%32===0)return c;let e=new Uint8Array(Math.ceil(c.length/32)*32);return e.set(c),e}function g0e(c){let e=[],a=0;for(let f=0;f<c.length;f++)e.push(null),a+=32;for(let f=0;f<c.length;f++){let d=Se(c[f]);e[f]=p0e(a),e.push(p0e(d.length)),e.push(ewe(d)),a+=32+Math.ceil(d.length/32)*32}return Ec(e)}var Gt=class{constructor(e,a,f,d){he(this,"provider",e),he(this,"name",f),he(this,"address",e.formatter.address(a)),he(this,"_resolvedAddress",d)}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(e=>Ee.from(e).eq(1)).catch(e=>{if(e.code===X.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,e})),this._supportsEip2544}_fetch(e,a){return S0(this,void 0,void 0,function*(){let f={to:this.address,ccipReadEnabled:!0,data:Ec([e,q7(this.name),a||"0x"])},d=!1;(yield this.supportsWildcard())&&(d=!0,f.data=Ec(["0x9061b923",g0e([Co(this.name),f.data])]));try{let b=yield this.provider.call(f);return Se(b).length%32===4&&G0.throwError("resolver threw error",X.errors.CALL_EXCEPTION,{transaction:f,data:b}),d&&(b=Vo(b,0)),b}catch(b){if(b.code===X.errors.CALL_EXCEPTION)return null;throw b}})}_fetchBytes(e,a){return S0(this,void 0,void 0,function*(){let f=yield this._fetch(e,a);return f!=null?Vo(f,0):null})}_getAddress(e,a){let f=Xye[String(e)];if(f==null&&G0.throwError(`unsupported coin type: ${e}`,X.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`}),f.ilk==="eth")return this.provider.formatter.address(a);let d=Se(a);if(f.p2pkh!=null){let b=a.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(b){let t=parseInt(b[1],16);if(b[2].length===t*2&&t>=1&&t<=75)return u0e(O0([[f.p2pkh],"0x"+b[2]]))}}if(f.p2sh!=null){let b=a.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(b){let t=parseInt(b[1],16);if(b[2].length===t*2&&t>=1&&t<=75)return u0e(O0([[f.p2sh],"0x"+b[2]]))}}if(f.prefix!=null){let b=d[1],t=d[0];if(t===0?b!==20&&b!==32&&(t=-1):t=-1,t>=0&&d.length===2+b&&b>=1&&b<=75){let r=yF.default.toWords(d.slice(2));return r.unshift(t),yF.default.encode(f.prefix,r)}}return null}getAddress(e){return S0(this,void 0,void 0,function*(){if(e==null&&(e=60),e===60)try{let d=yield this._fetch("0x3b3b57de");return d==="0x"||d===mt?null:this.provider.formatter.callAddress(d)}catch(d){if(d.code===X.errors.CALL_EXCEPTION)return null;throw d}let a=yield this._fetchBytes("0xf1cb7e06",pF(e));if(a==null||a==="0x")return null;let f=this._getAddress(e,a);return f==null&&G0.throwError("invalid or unsupported coin data",X.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`,coinType:e,data:a}),f})}getAvatar(){return S0(this,void 0,void 0,function*(){let e=[{type:"name",content:this.name}];try{let a=yield this.getText("avatar");if(a==null)return null;for(let f=0;f<h0e.length;f++){let d=a.match(h0e[f]);if(d==null)continue;let b=d[1].toLowerCase();switch(b){case"https":return e.push({type:"url",content:a}),{linkage:e,url:a};case"data":return e.push({type:"data",content:a}),{linkage:e,url:a};case"ipfs":return e.push({type:"ipfs",content:a}),{linkage:e,url:mF(a)};case"erc721":case"erc1155":{let t=b==="erc721"?"0xc87b56dd":"0x0e89341c";e.push({type:b,content:a});let r=this._resolvedAddress||(yield this.getAddress()),o=(d[2]||"").split("/");if(o.length!==2)return null;let n=yield this.provider.formatter.address(o[0]),i=q0(Ee.from(o[1]).toHexString(),32);if(b==="erc721"){let E=this.provider.formatter.callAddress(yield this.provider.call({to:n,data:Ec(["0x6352211e",i])}));if(r!==E)return null;e.push({type:"owner",content:E})}else if(b==="erc1155"){let E=Ee.from(yield this.provider.call({to:n,data:Ec(["0x00fdd58e",q0(r,32),i])}));if(E.isZero())return null;e.push({type:"balance",content:E.toString()})}let l={to:this.provider.formatter.address(o[0]),data:Ec([t,i])},h=Zm(yield this.provider.call(l),0);if(h==null)return null;e.push({type:"metadata-url-base",content:h}),b==="erc1155"&&(h=h.replace("{id}",i.substring(2)),e.push({type:"metadata-url-expanded",content:h})),h.match(/^ipfs:/i)&&(h=mF(h)),e.push({type:"metadata-url",content:h});let u=yield Q1(h);if(!u)return null;e.push({type:"metadata",content:JSON.stringify(u)});let g=u.image;if(typeof g!="string")return null;if(!g.match(/^(https:\/\/|data:)/i)){if(g.match(m0e)==null)return null;e.push({type:"url-ipfs",content:g}),g=mF(g)}return e.push({type:"url",content:g}),{linkage:e,url:g}}}}}catch{}return null})}getContentHash(){return S0(this,void 0,void 0,function*(){let e=yield this._fetchBytes("0xbc1c58d1");if(e==null||e==="0x")return null;let a=e.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(a){let t=parseInt(a[3],16);if(a[4].length===t*2)return"ipfs://"+o8.encode("0x"+a[1])}let f=e.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(f){let t=parseInt(f[3],16);if(f[4].length===t*2)return"ipns://"+o8.encode("0x"+f[1])}let d=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(d&&d[1].length===32*2)return"bzz://"+d[1];let b=e.match(/^0x90b2c605([0-9a-f]*)$/);if(b&&b[1].length===34*2){let t={"=":"","+":"-","/":"_"};return"sia://"+wt("0x"+b[1]).replace(/[=+\/]/g,o=>t[o])}return G0.throwError("invalid or unsupported content hash data",X.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:e})})}getText(e){return S0(this,void 0,void 0,function*(){let a=J0(e);a=O0([pF(64),pF(a.length),a]),a.length%32!==0&&(a=O0([a,q0("0x",32-e.length%32)]));let f=yield this._fetchBytes("0x59d1d43c",Be(a));return f==null||f==="0x"?null:Ld(f)})}},gF=null,awe=1,Xb=class extends Fd{constructor(e){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),he(this,"anyNetwork",e==="any"),this.anyNetwork&&(e=this.detectNetwork()),e instanceof Promise)this._networkPromise=e,e.catch(a=>{}),this._ready().catch(a=>{});else{let a=Ka(new.target,"getNetwork")(e);a?(he(this,"_network",a),this.emit("network",a,null)):G0.throwArgumentError("invalid network","network",e)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return S0(this,void 0,void 0,function*(){if(this._network==null){let e=null;if(this._networkPromise)try{e=yield this._networkPromise}catch{}e==null&&(e=yield this.detectNetwork()),e||G0.throwError("no network detected",X.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=e:he(this,"_network",e),this.emit("network",e,null))}return this._network})}get ready(){return W1(()=>this._ready().then(e=>e,e=>{if(!(e.code===X.errors.NETWORK_ERROR&&e.event==="noNetwork"))throw e}))}static getFormatter(){return gF==null&&(gF=new e0),gF}static getNetwork(e){return Go(e??"homestead")}ccipReadFetch(e,a,f){return S0(this,void 0,void 0,function*(){if(this.disableCcipRead||f.length===0)return null;let d=e.to.toLowerCase(),b=a.toLowerCase(),t=[];for(let r=0;r<f.length;r++){let o=f[r],n=o.replace("{sender}",d).replace("{data}",b),i=o.indexOf("{data}")>=0?null:JSON.stringify({data:b,sender:d}),l=yield Q1({url:n,errorPassThrough:!0},i,(u,g)=>(u.status=g.statusCode,u));if(l.data)return l.data;let h=l.message||"unknown error";if(l.status>=400&&l.status<500)return G0.throwError(`response not found during CCIP fetch: ${h}`,X.errors.SERVER_ERROR,{url:o,errorMessage:h});t.push(h)}return G0.throwError(`error encountered during CCIP fetch: ${t.map(r=>JSON.stringify(r)).join(", ")}`,X.errors.SERVER_ERROR,{urls:f,errorMessages:t})})}_getInternalBlockNumber(e){return S0(this,void 0,void 0,function*(){if(yield this._ready(),e>0)for(;this._internalBlockNumber;){let d=this._internalBlockNumber;try{let b=yield d;if($o()-b.respTime<=e)return b.blockNumber;break}catch{if(this._internalBlockNumber===d)break}}let a=$o(),f=wa({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(d=>null,d=>d)}).then(({blockNumber:d,networkError:b})=>{if(b)throw this._internalBlockNumber===f&&(this._internalBlockNumber=null),b;let t=$o();return d=Ee.from(d).toNumber(),d<this._maxInternalBlockNumber&&(d=this._maxInternalBlockNumber),this._maxInternalBlockNumber=d,this._setFastBlockNumber(d),{blockNumber:d,reqTime:a,respTime:t}});return this._internalBlockNumber=f,f.catch(d=>{this._internalBlockNumber===f&&(this._internalBlockNumber=null)}),(yield f).blockNumber})}poll(){return S0(this,void 0,void 0,function*(){let e=awe++,a=[],f=null;try{f=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(d){this.emit("error",d);return}if(this._setFastBlockNumber(f),this.emit("poll",e,f),f===this._lastBlockNumber){this.emit("didPoll",e);return}if(this._emitted.block===-2&&(this._emitted.block=f-1),Math.abs(this._emitted.block-f)>1e3)G0.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${f})`),this.emit("error",G0.makeError("network block skew detected",X.errors.NETWORK_ERROR,{blockNumber:f,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",f);else for(let d=this._emitted.block+1;d<=f;d++)this.emit("block",d);this._emitted.block!==f&&(this._emitted.block=f,Object.keys(this._emitted).forEach(d=>{if(d==="block")return;let b=this._emitted[d];b!=="pending"&&f-b>12&&delete this._emitted[d]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=f-1),this._events.forEach(d=>{switch(d.type){case"tx":{let b=d.hash,t=this.getTransactionReceipt(b).then(r=>(!r||r.blockNumber==null||(this._emitted["t:"+b]=r.blockNumber,this.emit(b,r)),null)).catch(r=>{this.emit("error",r)});a.push(t);break}case"filter":{if(!d._inflight){d._inflight=!0,d._lastBlockNumber===-2&&(d._lastBlockNumber=f-1);let b=d.filter;b.fromBlock=d._lastBlockNumber+1,b.toBlock=f;let t=b.toBlock-this._maxFilterBlockRange;t>b.fromBlock&&(b.fromBlock=t),b.fromBlock<0&&(b.fromBlock=0);let r=this.getLogs(b).then(o=>{d._inflight=!1,o.length!==0&&o.forEach(n=>{n.blockNumber>d._lastBlockNumber&&(d._lastBlockNumber=n.blockNumber),this._emitted["b:"+n.blockHash]=n.blockNumber,this._emitted["t:"+n.transactionHash]=n.blockNumber,this.emit(b,n)})}).catch(o=>{this.emit("error",o),d._inflight=!1});a.push(r)}break}}}),this._lastBlockNumber=f,Promise.all(a).then(()=>{this.emit("didPoll",e)}).catch(d=>{this.emit("error",d)})})}resetEventsBlock(e){this._lastBlockNumber=e-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return S0(this,void 0,void 0,function*(){return G0.throwError("provider does not support network detection",X.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return S0(this,void 0,void 0,function*(){let e=yield this._ready(),a=yield this.detectNetwork();if(e.chainId!==a.chainId){if(this.anyNetwork)return this._network=a,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",a,e),yield l0e(0),this._network;let f=G0.makeError("underlying network changed",X.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:a});throw this.emit("error",f),f}return e})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(e=>{this._setFastBlockNumber(e)},e=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(e){e&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(e){if(typeof e!="number"||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){let e=$o();return e-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=e,this._fastBlockNumberPromise=this.getBlockNumber().then(a=>((this._fastBlockNumber==null||a>this._fastBlockNumber)&&(this._fastBlockNumber=a),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(e){this._fastBlockNumber!=null&&e<this._fastBlockNumber||(this._fastQueryDate=$o(),(this._fastBlockNumber==null||e>this._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))}waitForTransaction(e,a,f){return S0(this,void 0,void 0,function*(){return this._waitForTransaction(e,a??1,f||0,null)})}_waitForTransaction(e,a,f,d){return S0(this,void 0,void 0,function*(){let b=yield this.getTransactionReceipt(e);return(b?b.confirmations:0)>=a?b:new Promise((t,r)=>{let o=[],n=!1,i=function(){return n?!0:(n=!0,o.forEach(h=>{h()}),!1)},l=h=>{h.confirmations<a||i()||t(h)};if(this.on(e,l),o.push(()=>{this.removeListener(e,l)}),d){let h=d.startBlock,u=null,g=E=>S0(this,void 0,void 0,function*(){n||(yield l0e(1e3),this.getTransactionCount(d.from).then(_=>S0(this,void 0,void 0,function*(){if(!n){if(_<=d.nonce)h=E;else{{let F=yield this.getTransaction(e);if(F&&F.blockNumber!=null)return}for(u==null&&(u=h-3,u<d.startBlock&&(u=d.startBlock));u<=E;){if(n)return;let F=yield this.getBlockWithTransactions(u);for(let L=0;L<F.transactions.length;L++){let U=F.transactions[L];if(U.hash===e)return;if(U.from===d.from&&U.nonce===d.nonce){if(n)return;let O=yield this.waitForTransaction(U.hash,a);if(i())return;let H="replaced";U.data===d.data&&U.to===d.to&&U.value.eq(d.value)?H="repriced":U.data==="0x"&&U.from===U.to&&U.value.isZero()&&(H="cancelled"),r(G0.makeError("transaction was replaced",X.errors.TRANSACTION_REPLACED,{cancelled:H==="replaced"||H==="cancelled",reason:H,replacement:this._wrapTransaction(U),hash:e,receipt:O}));return}}u++}}n||this.once("block",g)}}),_=>{n||this.once("block",g)}))});if(n)return;this.once("block",g),o.push(()=>{this.removeListener("block",g)})}if(typeof f=="number"&&f>0){let h=setTimeout(()=>{i()||r(G0.makeError("timeout exceeded",X.errors.TIMEOUT,{timeout:f}))},f);h.unref&&h.unref(),o.push(()=>{clearTimeout(h)})}})})}getBlockNumber(){return S0(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let e=yield this.perform("getGasPrice",{});try{return Ee.from(e)}catch(a){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"getGasPrice",result:e,error:a})}})}getBalance(e,a){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let f=yield wa({address:this._getAddress(e),blockTag:this._getBlockTag(a)}),d=yield this.perform("getBalance",f);try{return Ee.from(d)}catch(b){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"getBalance",params:f,result:d,error:b})}})}getTransactionCount(e,a){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let f=yield wa({address:this._getAddress(e),blockTag:this._getBlockTag(a)}),d=yield this.perform("getTransactionCount",f);try{return Ee.from(d).toNumber()}catch(b){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"getTransactionCount",params:f,result:d,error:b})}})}getCode(e,a){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let f=yield wa({address:this._getAddress(e),blockTag:this._getBlockTag(a)}),d=yield this.perform("getCode",f);try{return Be(d)}catch(b){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"getCode",params:f,result:d,error:b})}})}getStorageAt(e,a,f){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let d=yield wa({address:this._getAddress(e),blockTag:this._getBlockTag(f),position:Promise.resolve(a).then(t=>kb(t))}),b=yield this.perform("getStorageAt",d);try{return Be(b)}catch(t){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"getStorageAt",params:d,result:b,error:t})}})}_wrapTransaction(e,a,f){if(a!=null&&Cf(a)!==32)throw new Error("invalid response - sendTransaction");let d=e;return a!=null&&e.hash!==a&&G0.throwError("Transaction hash mismatch from Provider.sendTransaction.",X.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:a}),d.wait=(b,t)=>S0(this,void 0,void 0,function*(){b==null&&(b=1),t==null&&(t=0);let r;b!==0&&f!=null&&(r={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:f});let o=yield this._waitForTransaction(e.hash,b,t,r);return o==null&&b===0?null:(this._emitted["t:"+e.hash]=o.blockNumber,o.status===0&&G0.throwError("transaction failed",X.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:o}),o)}),d}sendTransaction(e){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let a=yield Promise.resolve(e).then(b=>Be(b)),f=this.formatter.transaction(e);f.confirmations==null&&(f.confirmations=0);let d=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{let b=yield this.perform("sendTransaction",{signedTransaction:a});return this._wrapTransaction(f,b,d)}catch(b){throw b.transaction=f,b.transactionHash=f.hash,b}})}_getTransactionRequest(e){return S0(this,void 0,void 0,function*(){let a=yield e,f={};return["from","to"].forEach(d=>{a[d]!=null&&(f[d]=Promise.resolve(a[d]).then(b=>b?this._getAddress(b):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(d=>{a[d]!=null&&(f[d]=Promise.resolve(a[d]).then(b=>b?Ee.from(b):null))}),["type"].forEach(d=>{a[d]!=null&&(f[d]=Promise.resolve(a[d]).then(b=>b??null))}),a.accessList&&(f.accessList=this.formatter.accessList(a.accessList)),["data"].forEach(d=>{a[d]!=null&&(f[d]=Promise.resolve(a[d]).then(b=>b?Be(b):null))}),this.formatter.transactionRequest(yield wa(f))})}_getFilter(e){return S0(this,void 0,void 0,function*(){e=yield e;let a={};return e.address!=null&&(a.address=this._getAddress(e.address)),["blockHash","topics"].forEach(f=>{e[f]!=null&&(a[f]=e[f])}),["fromBlock","toBlock"].forEach(f=>{e[f]!=null&&(a[f]=this._getBlockTag(e[f]))}),this.formatter.filter(yield wa(a))})}_call(e,a,f){return S0(this,void 0,void 0,function*(){f>=Jye&&G0.throwError("CCIP read exceeded maximum redirections",X.errors.SERVER_ERROR,{redirects:f,transaction:e});let d=e.to,b=yield this.perform("call",{transaction:e,blockTag:a});if(f>=0&&a==="latest"&&d!=null&&b.substring(0,10)==="0x556f1830"&&Cf(b)%32===4)try{let t=ya(b,4),r=ya(t,0,32);Ee.from(r).eq(d)||G0.throwError("CCIP Read sender did not match",X.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:b});let o=[],n=Ee.from(ya(t,32,64)).toNumber(),i=Ee.from(ya(t,n,n+32)).toNumber(),l=ya(t,n+32);for(let F=0;F<i;F++){let L=Zm(l,F*32);L==null&&G0.throwError("CCIP Read contained corrupt URL string",X.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:b}),o.push(L)}let h=Vo(t,64);Ee.from(ya(t,100,128)).isZero()||G0.throwError("CCIP Read callback selector included junk",X.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:b});let u=ya(t,96,100),g=Vo(t,128),E=yield this.ccipReadFetch(e,h,o);E==null&&G0.throwError("CCIP Read disabled or provided no URLs",X.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:b});let _={to:d,data:Ec([u,g0e([E,g])])};return this._call(_,a,f+1)}catch(t){if(t.code===X.errors.SERVER_ERROR)throw t}try{return Be(b)}catch(t){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"call",params:{transaction:e,blockTag:a},result:b,error:t})}})}call(e,a){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let f=yield wa({transaction:this._getTransactionRequest(e),blockTag:this._getBlockTag(a),ccipReadEnabled:Promise.resolve(e.ccipReadEnabled)});return this._call(f.transaction,f.blockTag,f.ccipReadEnabled?0:-1)})}estimateGas(e){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let a=yield wa({transaction:this._getTransactionRequest(e)}),f=yield this.perform("estimateGas",a);try{return Ee.from(f)}catch(d){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"estimateGas",params:a,result:f,error:d})}})}_getAddress(e){return S0(this,void 0,void 0,function*(){e=yield e,typeof e!="string"&&G0.throwArgumentError("invalid address or ENS name","name",e);let a=yield this.resolveName(e);return a==null&&G0.throwError("ENS name not configured",X.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(e)})`}),a})}_getBlock(e,a){return S0(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;let f=-128,d={includeTransactions:!!a};if(n0(e,32))d.blockHash=e;else try{d.blockTag=yield this._getBlockTag(e),n0(d.blockTag)&&(f=parseInt(d.blockTag.substring(2),16))}catch{G0.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",e)}return W1(()=>S0(this,void 0,void 0,function*(){let b=yield this.perform("getBlock",d);if(b==null)return d.blockHash!=null&&this._emitted["b:"+d.blockHash]==null||d.blockTag!=null&&f>this._emitted.block?null:void 0;if(a){let t=null;for(let o=0;o<b.transactions.length;o++){let n=b.transactions[o];if(n.blockNumber==null)n.confirmations=0;else if(n.confirmations==null){t==null&&(t=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let i=t-n.blockNumber+1;i<=0&&(i=1),n.confirmations=i}}let r=this.formatter.blockWithTransactions(b);return r.transactions=r.transactions.map(o=>this._wrapTransaction(o)),r}return this.formatter.block(b)}),{oncePoll:this})})}getBlock(e){return this._getBlock(e,!1)}getBlockWithTransactions(e){return this._getBlock(e,!0)}getTransaction(e){return S0(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;let a={transactionHash:this.formatter.hash(e,!0)};return W1(()=>S0(this,void 0,void 0,function*(){let f=yield this.perform("getTransaction",a);if(f==null)return this._emitted["t:"+e]==null?null:void 0;let d=this.formatter.transactionResponse(f);if(d.blockNumber==null)d.confirmations=0;else if(d.confirmations==null){let t=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-d.blockNumber+1;t<=0&&(t=1),d.confirmations=t}return this._wrapTransaction(d)}),{oncePoll:this})})}getTransactionReceipt(e){return S0(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;let a={transactionHash:this.formatter.hash(e,!0)};return W1(()=>S0(this,void 0,void 0,function*(){let f=yield this.perform("getTransactionReceipt",a);if(f==null)return this._emitted["t:"+e]==null?null:void 0;if(f.blockHash==null)return;let d=this.formatter.receipt(f);if(d.blockNumber==null)d.confirmations=0;else if(d.confirmations==null){let t=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-d.blockNumber+1;t<=0&&(t=1),d.confirmations=t}return d}),{oncePoll:this})})}getLogs(e){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let a=yield wa({filter:this._getFilter(e)}),f=yield this.perform("getLogs",a);return f.forEach(d=>{d.removed==null&&(d.removed=!1)}),e0.arrayOf(this.formatter.filterLog.bind(this.formatter))(f)})}getEtherPrice(){return S0(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(e){return S0(this,void 0,void 0,function*(){if(e=yield e,typeof e=="number"&&e<0){e%1&&G0.throwArgumentError("invalid BlockTag","blockTag",e);let a=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return a+=e,a<0&&(a=0),this.formatter.blockTag(a)}return this.formatter.blockTag(e)})}getResolver(e){return S0(this,void 0,void 0,function*(){let a=e;for(;;){if(a===""||a==="."||e!=="eth"&&a==="eth")return null;let f=yield this._getResolver(a,"getResolver");if(f!=null){let d=new Gt(this,f,e);return a!==e&&!(yield d.supportsWildcard())?null:d}a=a.split(".").slice(1).join(".")}})}_getResolver(e,a){return S0(this,void 0,void 0,function*(){a==null&&(a="ENS");let f=yield this.getNetwork();f.ensAddress||G0.throwError("network does not support ENS",X.errors.UNSUPPORTED_OPERATION,{operation:a,network:f.name});try{let d=yield this.call({to:f.ensAddress,data:"0x0178b8bf"+q7(e).substring(2)});return this.formatter.callAddress(d)}catch{}return null})}resolveName(e){return S0(this,void 0,void 0,function*(){e=yield e;try{return Promise.resolve(this.formatter.address(e))}catch(f){if(n0(e))throw f}typeof e!="string"&&G0.throwArgumentError("invalid ENS name","name",e);let a=yield this.getResolver(e);return a?yield a.getAddress():null})}lookupAddress(e){return S0(this,void 0,void 0,function*(){e=yield e,e=this.formatter.address(e);let a=e.substring(2).toLowerCase()+".addr.reverse",f=yield this._getResolver(a,"lookupAddress");if(f==null)return null;let d=Zm(yield this.call({to:f,data:"0x691f3431"+q7(a).substring(2)}),0);return(yield this.resolveName(d))!=e?null:d})}getAvatar(e){return S0(this,void 0,void 0,function*(){let a=null;if(n0(e)){let b=this.formatter.address(e).substring(2).toLowerCase()+".addr.reverse",t=yield this._getResolver(b,"getAvatar");if(!t)return null;a=new Gt(this,t,b);try{let r=yield a.getAvatar();if(r)return r.url}catch(r){if(r.code!==X.errors.CALL_EXCEPTION)throw r}try{let r=Zm(yield this.call({to:t,data:"0x691f3431"+q7(b).substring(2)}),0);a=yield this.getResolver(r)}catch(r){if(r.code!==X.errors.CALL_EXCEPTION)throw r;return null}}else if(a=yield this.getResolver(e),!a)return null;let f=yield a.getAvatar();return f==null?null:f.url})}perform(e,a){return G0.throwError(e+" not implemented",X.errors.NOT_IMPLEMENTED,{operation:e})}_startEvent(e){this.polling=this._events.filter(a=>a.pollable()).length>0}_stopEvent(e){this.polling=this._events.filter(a=>a.pollable()).length>0}_addEventListener(e,a,f){let d=new wF(qt(e),a,f);return this._events.push(d),this._startEvent(d),this}on(e,a){return this._addEventListener(e,a,!1)}once(e,a){return this._addEventListener(e,a,!0)}emit(e,...a){let f=!1,d=[],b=qt(e);return this._events=this._events.filter(t=>t.tag!==b?!0:(setTimeout(()=>{t.listener.apply(this,a)},0),f=!0,t.once?(d.push(t),!1):!0)),d.forEach(t=>{this._stopEvent(t)}),f}listenerCount(e){if(!e)return this._events.length;let a=qt(e);return this._events.filter(f=>f.tag===a).length}listeners(e){if(e==null)return this._events.map(f=>f.listener);let a=qt(e);return this._events.filter(f=>f.tag===a).map(f=>f.listener)}off(e,a){if(a==null)return this.removeAllListeners(e);let f=[],d=!1,b=qt(e);return this._events=this._events.filter(t=>t.tag!==b||t.listener!=a||d?!0:(d=!0,f.push(t),!1)),f.forEach(t=>{this._stopEvent(t)}),this}removeAllListeners(e){let a=[];if(e==null)a=this._events,this._events=[];else{let f=qt(e);this._events=this._events.filter(d=>d.tag!==f?!0:(a.push(d),!1))}return a.forEach(f=>{this._stopEvent(f)}),this}};s();x();s();x();s();x();var p8=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Sc=new X(ia),cwe=["call","estimateGas"];function Qo(c,e){if(c==null)return null;if(typeof c.message=="string"&&c.message.match("reverted")){let a=n0(c.data)?c.data:null;if(!e||a)return{message:c.message,data:a}}if(typeof c=="object"){for(let a in c){let f=Qo(c[a],e);if(f)return f}return null}if(typeof c=="string")try{return Qo(JSON.parse(c),e)}catch{}return null}function w0e(c,e,a){let f=a.transaction||a.signedTransaction;if(c==="call"){let b=Qo(e,!0);if(b)return b.data;Sc.throwError("missing revert data in call exception; Transaction reverted without a reason string",X.errors.CALL_EXCEPTION,{data:"0x",transaction:f,error:e})}if(c==="estimateGas"){let b=Qo(e.body,!1);b==null&&(b=Qo(e,!1)),b&&Sc.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",X.errors.UNPREDICTABLE_GAS_LIMIT,{reason:b.message,method:c,transaction:f,error:e})}let d=e.message;throw e.code===X.errors.SERVER_ERROR&&e.error&&typeof e.error.message=="string"?d=e.error.message:typeof e.body=="string"?d=e.body:typeof e.responseText=="string"&&(d=e.responseText),d=(d||"").toLowerCase(),d.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&Sc.throwError("insufficient funds for intrinsic transaction cost",X.errors.INSUFFICIENT_FUNDS,{error:e,method:c,transaction:f}),d.match(/nonce (is )?too low/i)&&Sc.throwError("nonce has already been used",X.errors.NONCE_EXPIRED,{error:e,method:c,transaction:f}),d.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&Sc.throwError("replacement fee too low",X.errors.REPLACEMENT_UNDERPRICED,{error:e,method:c,transaction:f}),d.match(/only replay-protected/i)&&Sc.throwError("legacy pre-eip-155 transactions not supported",X.errors.UNSUPPORTED_OPERATION,{error:e,method:c,transaction:f}),cwe.indexOf(c)>=0&&d.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&Sc.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",X.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:c,transaction:f}),e}function y0e(c){return new Promise(function(e){setTimeout(e,c)})}function fwe(c){if(c.error){let e=new Error(c.error.message);throw e.code=c.error.code,e.data=c.error.data,e}return c.result}function Ko(c){return c&&c.toLowerCase()}var _F={},zt=class extends fd{constructor(e,a,f){if(super(),e!==_F)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");he(this,"provider",a),f==null&&(f=0),typeof f=="string"?(he(this,"_address",this.provider.formatter.address(f)),he(this,"_index",null)):typeof f=="number"?(he(this,"_index",f),he(this,"_address",null)):Sc.throwArgumentError("invalid address or index","addressOrIndex",f)}connect(e){return Sc.throwError("cannot alter JSON-RPC Signer connection",X.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new vF(_F,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(e=>(e.length<=this._index&&Sc.throwError("unknown account #"+this._index,X.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(e[this._index])))}sendUncheckedTransaction(e){e=ea(e);let a=this.getAddress().then(f=>(f&&(f=f.toLowerCase()),f));if(e.gasLimit==null){let f=ea(e);f.from=a,e.gasLimit=this.provider.estimateGas(f)}return e.to!=null&&(e.to=Promise.resolve(e.to).then(f=>p8(this,void 0,void 0,function*(){if(f==null)return null;let d=yield this.provider.resolveName(f);return d==null&&Sc.throwArgumentError("provided ENS name resolves to null","tx.to",f),d}))),wa({tx:wa(e),sender:a}).then(({tx:f,sender:d})=>{f.from!=null?f.from.toLowerCase()!==d&&Sc.throwArgumentError("from address mismatch","transaction",e):f.from=d;let b=this.provider.constructor.hexlifyTransaction(f,{from:!0});return this.provider.send("eth_sendTransaction",[b]).then(t=>t,t=>(typeof t.message=="string"&&t.message.match(/user denied/i)&&Sc.throwError("user rejected transaction",X.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:f}),w0e("sendTransaction",t,b)))})}signTransaction(e){return Sc.throwError("signing transactions is unsupported",X.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(e){return p8(this,void 0,void 0,function*(){let a=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),f=yield this.sendUncheckedTransaction(e);try{return yield W1(()=>p8(this,void 0,void 0,function*(){let d=yield this.provider.getTransaction(f);if(d!==null)return this.provider._wrapTransaction(d,f,a)}),{oncePoll:this.provider})}catch(d){throw d.transactionHash=f,d}})}signMessage(e){return p8(this,void 0,void 0,function*(){let a=typeof e=="string"?J0(e):e,f=yield this.getAddress();try{return yield this.provider.send("personal_sign",[Be(a),f.toLowerCase()])}catch(d){throw typeof d.message=="string"&&d.message.match(/user denied/i)&&Sc.throwError("user rejected signing",X.errors.ACTION_REJECTED,{action:"signMessage",from:f,messageData:e}),d}})}_legacySignMessage(e){return p8(this,void 0,void 0,function*(){let a=typeof e=="string"?J0(e):e,f=yield this.getAddress();try{return yield this.provider.send("eth_sign",[f.toLowerCase(),Be(a)])}catch(d){throw typeof d.message=="string"&&d.message.match(/user denied/i)&&Sc.throwError("user rejected signing",X.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:f,messageData:e}),d}})}_signTypedData(e,a,f){return p8(this,void 0,void 0,function*(){let d=yield Wa.resolveNames(e,a,f,t=>this.provider.resolveName(t)),b=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[b.toLowerCase(),JSON.stringify(Wa.getPayload(d.domain,a,d.value))])}catch(t){throw typeof t.message=="string"&&t.message.match(/user denied/i)&&Sc.throwError("user rejected signing",X.errors.ACTION_REJECTED,{action:"_signTypedData",from:b,messageData:{domain:d.domain,types:a,value:d.value}}),t}})}unlock(e){return p8(this,void 0,void 0,function*(){let a=this.provider,f=yield this.getAddress();return a.send("personal_unlockAccount",[f.toLowerCase(),e,null])})}},vF=class extends zt{sendTransaction(e){return this.sendUncheckedTransaction(e).then(a=>({hash:a,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:f=>this.provider.waitForTransaction(a,f)}))}},dwe={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0},Bd=class extends Xb{constructor(e,a){let f=a;f==null&&(f=new Promise((d,b)=>{setTimeout(()=>{this.detectNetwork().then(t=>{d(t)},t=>{b(t)})},0)})),super(f),e||(e=Ka(this.constructor,"defaultUrl")()),typeof e=="string"?he(this,"connection",Object.freeze({url:e})):he(this,"connection",Object.freeze(ea(e))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return p8(this,void 0,void 0,function*(){yield y0e(0);let e=null;try{e=yield this.send("eth_chainId",[])}catch{try{e=yield this.send("net_version",[])}catch{}}if(e!=null){let a=Ka(this.constructor,"getNetwork");try{return a(Ee.from(e).toNumber())}catch(f){return Sc.throwError("could not detect network",X.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:f})}}return Sc.throwError("could not detect network",X.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(e){return new zt(_F,this,e)}getUncheckedSigner(e){return this.getSigner(e).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(e=>e.map(a=>this.formatter.address(a)))}send(e,a){let f={method:e,params:a,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:Va(f),provider:this});let d=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(d&&this._cache[e])return this._cache[e];let b=Q1(this.connection,JSON.stringify(f),fwe).then(t=>(this.emit("debug",{action:"response",request:f,response:t,provider:this}),t),t=>{throw this.emit("debug",{action:"response",error:t,request:f,provider:this}),t});return d&&(this._cache[e]=b,setTimeout(()=>{this._cache[e]=null},0)),b}prepareRequest(e,a){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[Ko(a.address),a.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[Ko(a.address),a.blockTag]];case"getCode":return["eth_getCode",[Ko(a.address),a.blockTag]];case"getStorageAt":return["eth_getStorageAt",[Ko(a.address),q0(a.position,32),a.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[a.signedTransaction]];case"getBlock":return a.blockTag?["eth_getBlockByNumber",[a.blockTag,!!a.includeTransactions]]:a.blockHash?["eth_getBlockByHash",[a.blockHash,!!a.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[a.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[a.transactionHash]];case"call":return["eth_call",[Ka(this.constructor,"hexlifyTransaction")(a.transaction,{from:!0}),a.blockTag]];case"estimateGas":return["eth_estimateGas",[Ka(this.constructor,"hexlifyTransaction")(a.transaction,{from:!0})]];case"getLogs":return a.filter&&a.filter.address!=null&&(a.filter.address=Ko(a.filter.address)),["eth_getLogs",[a.filter]];default:break}return null}perform(e,a){return p8(this,void 0,void 0,function*(){if(e==="call"||e==="estimateGas"){let d=a.transaction;if(d&&d.type!=null&&Ee.from(d.type).isZero()&&d.maxFeePerGas==null&&d.maxPriorityFeePerGas==null){let b=yield this.getFeeData();b.maxFeePerGas==null&&b.maxPriorityFeePerGas==null&&(a=ea(a),a.transaction=ea(d),delete a.transaction.type)}}let f=this.prepareRequest(e,a);f==null&&Sc.throwError(e+" not implemented",X.errors.NOT_IMPLEMENTED,{operation:e});try{return yield this.send(f[0],f[1])}catch(d){return w0e(e,d,a)}})}_startEvent(e){e.tag==="pending"&&this._startPending(),super._startEvent(e)}_startPending(){if(this._pendingFilter!=null)return;let e=this,a=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=a,a.then(function(f){function d(){e.send("eth_getFilterChanges",[f]).then(function(b){if(e._pendingFilter!=a)return null;let t=Promise.resolve();return b.forEach(function(r){e._emitted["t:"+r.toLowerCase()]="pending",t=t.then(function(){return e.getTransaction(r).then(function(o){return e.emit("pending",o),null})})}),t.then(function(){return y0e(1e3)})}).then(function(){if(e._pendingFilter!=a){e.send("eth_uninstallFilter",[f]);return}return setTimeout(function(){d()},0),null}).catch(b=>{})}return d(),f}).catch(f=>{})}_stopEvent(e){e.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(e)}static hexlifyTransaction(e,a){let f=ea(dwe);if(a)for(let b in a)a[b]&&(f[b]=!0);xt(e,f);let d={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(b){if(e[b]==null)return;let t=kb(Ee.from(e[b]));b==="gasLimit"&&(b="gas"),d[b]=t}),["from","to","data"].forEach(function(b){e[b]!=null&&(d[b]=Be(e[b]))}),e.accessList&&(d.accessList=s2(e.accessList)),d}};s();x();var jt=null;try{if(jt=WebSocket,jt==null)throw new Error("inject please")}catch{let e=new X(ia);jt=function(){e.throwError("WebSockets not supported in this environment",X.errors.UNSUPPORTED_OPERATION,{operation:"new WebSocket()"})}}var EF=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Ym=new X(ia),bwe=1,m8=class extends Bd{constructor(e,a){a==="any"&&Ym.throwError("WebSocketProvider does not support 'any' network yet",X.errors.UNSUPPORTED_OPERATION,{operation:"network:any"}),typeof e=="string"?super(e,a):super("_websocket",a),this._pollingInterval=-1,this._wsReady=!1,typeof e=="string"?he(this,"_websocket",new jt(this.connection.url)):he(this,"_websocket",e),he(this,"_requests",{}),he(this,"_subs",{}),he(this,"_subIds",{}),he(this,"_detectNetwork",super.detectNetwork()),this.websocket.onopen=()=>{this._wsReady=!0,Object.keys(this._requests).forEach(d=>{this.websocket.send(this._requests[d].payload)})},this.websocket.onmessage=d=>{let b=d.data,t=JSON.parse(b);if(t.id!=null){let r=String(t.id),o=this._requests[r];if(delete this._requests[r],t.result!==void 0)o.callback(null,t.result),this.emit("debug",{action:"response",request:JSON.parse(o.payload),response:t.result,provider:this});else{let n=null;t.error?(n=new Error(t.error.message||"unknown error"),he(n,"code",t.error.code||null),he(n,"response",b)):n=new Error("unknown error"),o.callback(n,void 0),this.emit("debug",{action:"response",error:n,request:JSON.parse(o.payload),provider:this})}}else if(t.method==="eth_subscription"){let r=this._subs[t.params.subscription];r&&r.processFunc(t.params.result)}else console.warn("this should not happen")};let f=setInterval(()=>{this.emit("poll")},1e3);f.unref&&f.unref()}get websocket(){return this._websocket}detectNetwork(){return this._detectNetwork}get pollingInterval(){return 0}resetEventsBlock(e){Ym.throwError("cannot reset events block on WebSocketProvider",X.errors.UNSUPPORTED_OPERATION,{operation:"resetEventBlock"})}set pollingInterval(e){Ym.throwError("cannot set polling interval on WebSocketProvider",X.errors.UNSUPPORTED_OPERATION,{operation:"setPollingInterval"})}poll(){return EF(this,void 0,void 0,function*(){return null})}set polling(e){!e||Ym.throwError("cannot set polling on WebSocketProvider",X.errors.UNSUPPORTED_OPERATION,{operation:"setPolling"})}send(e,a){let f=bwe++;return new Promise((d,b)=>{function t(o,n){return o?b(o):d(n)}let r=JSON.stringify({method:e,params:a,id:f,jsonrpc:"2.0"});this.emit("debug",{action:"request",request:JSON.parse(r),provider:this}),this._requests[String(f)]={callback:t,payload:r},this._wsReady&&this.websocket.send(r)})}static defaultUrl(){return"ws://localhost:8546"}_subscribe(e,a,f){return EF(this,void 0,void 0,function*(){let d=this._subIds[e];d==null&&(d=Promise.all(a).then(t=>this.send("eth_subscribe",t)),this._subIds[e]=d);let b=yield d;this._subs[b]={tag:e,processFunc:f}})}_startEvent(e){switch(e.type){case"block":this._subscribe("block",["newHeads"],a=>{let f=Ee.from(a.number).toNumber();this._emitted.block=f,this.emit("block",f)});break;case"pending":this._subscribe("pending",["newPendingTransactions"],a=>{this.emit("pending",a)});break;case"filter":this._subscribe(e.tag,["logs",this._getFilter(e.filter)],a=>{a.removed==null&&(a.removed=!1),this.emit(e.filter,this.formatter.filterLog(a))});break;case"tx":{let a=f=>{let d=f.hash;this.getTransactionReceipt(d).then(b=>{!b||this.emit(d,b)})};a(e),this._subscribe("tx",["newHeads"],f=>{this._events.filter(d=>d.type==="tx").forEach(a)});break}case"debug":case"poll":case"willPoll":case"didPoll":case"error":break;default:console.log("unhandled:",e);break}}_stopEvent(e){let a=e.tag;if(e.type==="tx"){if(this._events.filter(d=>d.type==="tx").length)return;a="tx"}else if(this.listenerCount(e.event))return;let f=this._subIds[a];!f||(delete this._subIds[a],f.then(d=>{!this._subs[d]||(delete this._subs[d],this.send("eth_unsubscribe",[d]))}))}destroy(){return EF(this,void 0,void 0,function*(){this.websocket.readyState===jt.CONNECTING&&(yield new Promise(e=>{this.websocket.onopen=function(){e(!0)},this.websocket.onerror=function(){e(!1)}})),this.websocket.close(1e3)})}};s();x();var twe=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Wo=new X(ia),Jo=class extends Bd{detectNetwork(){let e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return twe(this,void 0,void 0,function*(){let a=this.network;return a==null&&(a=yield e.detectNetwork.call(this),a||Wo.throwError("no network detected",X.errors.UNKNOWN_ERROR,{}),this._network==null&&(he(this,"_network",a),this.emit("network",a,null))),a})}},Qc=class extends Jo{constructor(e,a){Wo.checkAbstract(new.target,Qc),e=Ka(new.target,"getNetwork")(e),a=Ka(new.target,"getApiKey")(a);let f=Ka(new.target,"getUrl")(e,a);super(f,e),typeof a=="string"?he(this,"apiKey",a):a!=null&&Object.keys(a).forEach(d=>{he(this,d,a[d])})}_startPending(){Wo.warn("WARNING: API provider does not support pending filters")}isCommunityResource(){return!1}getSigner(e){return Wo.throwError("API provider does not support signing",X.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"})}listAccounts(){return Promise.resolve([])}static getApiKey(e){return e}static getUrl(e,a){return Wo.throwError("not implemented; sub-classes must override getUrl",X.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}};var _0e=new X(ia),Xm="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC",Zo=class extends m8{constructor(e,a){let f=new Ht(e,a),d=f.connection.url.replace(/^http/i,"ws").replace(".alchemyapi.",".ws.alchemyapi.");super(d,f.network),he(this,"apiKey",f.apiKey)}isCommunityResource(){return this.apiKey===Xm}},Ht=class extends Qc{static getWebSocketProvider(e,a){return new Zo(e,a)}static getApiKey(e){return e==null?Xm:(e&&typeof e!="string"&&_0e.throwArgumentError("invalid apiKey","apiKey",e),e)}static getUrl(e,a){let f=null;switch(e.name){case"homestead":f="eth-mainnet.alchemyapi.io/v2/";break;case"goerli":f="eth-goerli.g.alchemy.com/v2/";break;case"matic":f="polygon-mainnet.g.alchemy.com/v2/";break;case"maticmum":f="polygon-mumbai.g.alchemy.com/v2/";break;case"arbitrum":f="arb-mainnet.g.alchemy.com/v2/";break;case"arbitrum-goerli":f="arb-goerli.g.alchemy.com/v2/";break;case"optimism":f="opt-mainnet.g.alchemy.com/v2/";break;case"optimism-goerli":f="opt-goerli.g.alchemy.com/v2/";break;default:_0e.throwArgumentError("unsupported network","network",arguments[0])}return{allowGzip:!0,url:"https://"+f+a,throttleCallback:(d,b)=>(a===Xm&&Yb(),Promise.resolve(!0))}}isCommunityResource(){return this.apiKey===Xm}};s();x();var rwe=new X(ia),eg="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function nwe(c){switch(c){case"homestead":return"rpc.ankr.com/eth/";case"ropsten":return"rpc.ankr.com/eth_ropsten/";case"rinkeby":return"rpc.ankr.com/eth_rinkeby/";case"goerli":return"rpc.ankr.com/eth_goerli/";case"matic":return"rpc.ankr.com/polygon/";case"arbitrum":return"rpc.ankr.com/arbitrum/"}return rwe.throwArgumentError("unsupported network","name",c)}var Yo=class extends Qc{isCommunityResource(){return this.apiKey===eg}static getApiKey(e){return e??eg}static getUrl(e,a){a==null&&(a=eg);let f={allowGzip:!0,url:"https://"+nwe(e.name)+a,throttleCallback:(d,b)=>(a.apiKey===eg&&Yb(),Promise.resolve(!0))};return a.projectSecret!=null&&(f.user="",f.password=a.projectSecret),f}};s();x();var iwe=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},v0e=new X(ia),Xo=class extends Qc{static getApiKey(e){return e!=null&&v0e.throwArgumentError("apiKey not supported for cloudflare","apiKey",e),null}static getUrl(e,a){let f=null;switch(e.name){case"homestead":f="https://cloudflare-eth.com/";break;default:v0e.throwArgumentError("unsupported network","network",arguments[0])}return f}perform(e,a){let f=Object.create(null,{perform:{get:()=>super.perform}});return iwe(this,void 0,void 0,function*(){return e==="getBlockNumber"?(yield f.perform.call(this,"getBlock",{blockTag:"latest"})).number:f.perform.call(this,e,a)})}};s();x();var ag=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},K7=new X(ia);function E0e(c){let e={};for(let a in c){if(c[a]==null)continue;let f=c[a];a==="type"&&f===0||({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[a]?f=kb(Be(f)):a==="accessList"?f="["+s2(f).map(d=>`{address:"${d.address}",storageKeys:["${d.storageKeys.join('","')}"]}`).join(",")+"]":f=Be(f),e[a]=f)}return e}function owe(c){if(c.status==0&&(c.message==="No records found"||c.message==="No transactions found"))return c.result;if(c.status!=1||typeof c.message!="string"||!c.message.match(/^OK/)){let e=new Error("invalid response");throw e.result=JSON.stringify(c),(c.result||"").toLowerCase().indexOf("rate limit")>=0&&(e.throttleRetry=!0),e}return c.result}function A0e(c){if(c&&c.status==0&&c.message=="NOTOK"&&(c.result||"").toLowerCase().indexOf("rate limit")>=0){let e=new Error("throttled response");throw e.result=JSON.stringify(c),e.throttleRetry=!0,e}if(c.jsonrpc!="2.0"){let e=new Error("invalid response");throw e.result=JSON.stringify(c),e}if(c.error){let e=new Error(c.error.message||"unknown error");throw c.error.code&&(e.code=c.error.code),c.error.data&&(e.data=c.error.data),e}return c.result}function S0e(c){if(c==="pending")throw new Error("pending not supported");return c==="latest"?c:parseInt(c.substring(2),16)}function AF(c,e,a){if(c==="call"&&e.code===X.errors.SERVER_ERROR){let d=e.error;if(d&&(d.message.match(/reverted/i)||d.message.match(/VM execution error/i))){let b=d.data;if(b&&(b="0x"+b.replace(/^.*0x/i,"")),n0(b))return b;K7.throwError("missing revert data in call exception",X.errors.CALL_EXCEPTION,{error:e,data:"0x"})}}let f=e.message;throw e.code===X.errors.SERVER_ERROR&&(e.error&&typeof e.error.message=="string"?f=e.error.message:typeof e.body=="string"?f=e.body:typeof e.responseText=="string"&&(f=e.responseText)),f=(f||"").toLowerCase(),f.match(/insufficient funds/)&&K7.throwError("insufficient funds for intrinsic transaction cost",X.errors.INSUFFICIENT_FUNDS,{error:e,method:c,transaction:a}),f.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&K7.throwError("nonce has already been used",X.errors.NONCE_EXPIRED,{error:e,method:c,transaction:a}),f.match(/another transaction with same nonce/)&&K7.throwError("replacement fee too low",X.errors.REPLACEMENT_UNDERPRICED,{error:e,method:c,transaction:a}),f.match(/execution failed due to an exception|execution reverted/)&&K7.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",X.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:c,transaction:a}),e}var es=class extends Xb{constructor(e,a){super(e),he(this,"baseUrl",this.getBaseUrl()),he(this,"apiKey",a||null)}getBaseUrl(){switch(this.network?this.network.name:"invalid"){case"homestead":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"matic":return"https://api.polygonscan.com";case"maticmum":return"https://api-testnet.polygonscan.com";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io";default:}return K7.throwArgumentError("unsupported network","network",this.network.name)}getUrl(e,a){let f=Object.keys(a).reduce((b,t)=>{let r=a[t];return r!=null&&(b+=`&${t}=${r}`),b},""),d=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.baseUrl}/api?module=${e}${f}${d}`}getPostUrl(){return`${this.baseUrl}/api`}getPostData(e,a){return a.module=e,a.apikey=this.apiKey,a}fetch(e,a,f){return ag(this,void 0,void 0,function*(){let d=f?this.getPostUrl():this.getUrl(e,a),b=f?this.getPostData(e,a):null,t=e==="proxy"?A0e:owe;this.emit("debug",{action:"request",request:d,provider:this});let r={url:d,throttleSlotInterval:1e3,throttleCallback:(i,l)=>(this.isCommunityResource()&&Yb(),Promise.resolve(!0))},o=null;b&&(r.headers={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},o=Object.keys(b).map(i=>`${i}=${b[i]}`).join("&"));let n=yield Q1(r,o,t||A0e);return this.emit("debug",{action:"response",request:d,response:Va(n),provider:this}),n})}detectNetwork(){return ag(this,void 0,void 0,function*(){return this.network})}perform(e,a){let f=Object.create(null,{perform:{get:()=>super.perform}});return ag(this,void 0,void 0,function*(){switch(e){case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getBalance":return this.fetch("account",{action:"balance",address:a.address,tag:a.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:a.address,tag:a.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:a.address,tag:a.blockTag});case"getStorageAt":return this.fetch("proxy",{action:"eth_getStorageAt",address:a.address,position:a.position,tag:a.blockTag});case"sendTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:a.signedTransaction},!0).catch(d=>AF("sendTransaction",d,a.signedTransaction));case"getBlock":if(a.blockTag)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:a.blockTag,boolean:a.includeTransactions?"true":"false"});throw new Error("getBlock by blockHash not implemented");case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:a.transactionHash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:a.transactionHash});case"call":{if(a.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");let d=E0e(a.transaction);d.module="proxy",d.action="eth_call";try{return yield this.fetch("proxy",d,!0)}catch(b){return AF("call",b,a.transaction)}}case"estimateGas":{let d=E0e(a.transaction);d.module="proxy",d.action="eth_estimateGas";try{return yield this.fetch("proxy",d,!0)}catch(b){return AF("estimateGas",b,a.transaction)}}case"getLogs":{let d={action:"getLogs"};if(a.filter.fromBlock&&(d.fromBlock=S0e(a.filter.fromBlock)),a.filter.toBlock&&(d.toBlock=S0e(a.filter.toBlock)),a.filter.address&&(d.address=a.filter.address),a.filter.topics&&a.filter.topics.length>0&&(a.filter.topics.length>1&&K7.throwError("unsupported topic count",X.errors.UNSUPPORTED_OPERATION,{topics:a.filter.topics}),a.filter.topics.length===1)){let r=a.filter.topics[0];(typeof r!="string"||r.length!==66)&&K7.throwError("unsupported topic format",X.errors.UNSUPPORTED_OPERATION,{topic0:r}),d.topic0=r}let b=yield this.fetch("logs",d),t={};for(let r=0;r<b.length;r++){let o=b[r];if(o.blockHash==null){if(t[o.blockNumber]==null){let n=yield this.getBlock(o.blockNumber);n&&(t[o.blockNumber]=n.hash)}o.blockHash=t[o.blockNumber]}}return b}case"getEtherPrice":return this.network.name!=="homestead"?0:parseFloat((yield this.fetch("stats",{action:"ethprice"})).ethusd);default:break}return f.perform.call(this,e,a)})}getHistory(e,a,f){return ag(this,void 0,void 0,function*(){let d={action:"txlist",address:yield this.resolveName(e),startblock:a??0,endblock:f??99999999,sort:"asc"};return(yield this.fetch("account",d)).map(t=>{["contractAddress","to"].forEach(function(o){t[o]==""&&delete t[o]}),t.creates==null&&t.contractAddress!=null&&(t.creates=t.contractAddress);let r=this.formatter.transactionResponse(t);return t.timeStamp&&(r.timestamp=parseInt(t.timeStamp)),r})})}isCommunityResource(){return this.apiKey==null}};s();x();var dg=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},f5=new X(ia);function cg(){return new Date().getTime()}function I0e(c){let e=null;for(let a=0;a<c.length;a++){let f=c[a];if(f==null)return null;e?e.name===f.name&&e.chainId===f.chainId&&(e.ensAddress===f.ensAddress||e.ensAddress==null&&f.ensAddress==null)||f5.throwArgumentError("provider mismatch","networks",c):e=f}return e}function L0e(c,e){c=c.slice().sort();let a=Math.floor(c.length/2);if(c.length%2)return c[a];let f=c[a-1],d=c[a];return e!=null&&Math.abs(f-d)>e?null:(f+d)/2}function $t(c){if(c===null)return"null";if(typeof c=="number"||typeof c=="boolean")return JSON.stringify(c);if(typeof c=="string")return c;if(Ee.isBigNumber(c))return c.toString();if(Array.isArray(c))return JSON.stringify(c.map(e=>$t(e)));if(typeof c=="object"){let e=Object.keys(c);return e.sort(),"{"+e.map(a=>{let f=c[a];return typeof f=="function"?f="[function]":f=$t(f),JSON.stringify(a)+":"+f}).join(",")+"}"}throw new Error("unknown value type: "+typeof c)}var swe=1;function F0e(c){let e=null,a=null,f=new Promise(t=>{e=function(){a&&(clearTimeout(a),a=null),t()},a=setTimeout(e,c)}),d=t=>(f=f.then(t),f);function b(){return f}return{cancel:e,getPromise:b,wait:d}}var xwe=[X.errors.CALL_EXCEPTION,X.errors.INSUFFICIENT_FUNDS,X.errors.NONCE_EXPIRED,X.errors.REPLACEMENT_UNDERPRICED,X.errors.UNPREDICTABLE_GAS_LIMIT],lwe=["address","args","errorArgs","errorSignature","method","transaction"];function fg(c,e){let a={weight:c.weight};return Object.defineProperty(a,"provider",{get:()=>c.provider}),c.start&&(a.start=c.start),e&&(a.duration=e-c.start),c.done&&(c.error?a.error=c.error:a.result=c.result||null),a}function uwe(c,e){return function(a){let f={};a.forEach(b=>{let t=c(b.result);f[t]||(f[t]={count:0,result:b.result}),f[t].count++});let d=Object.keys(f);for(let b=0;b<d.length;b++){let t=f[d[b]];if(t.count>=e)return t.result}}}function hwe(c,e,a){let f=$t;switch(e){case"getBlockNumber":return function(d){let b=d.map(r=>r.result),t=L0e(d.map(r=>r.result),2);if(t!=null)return t=Math.ceil(t),b.indexOf(t+1)>=0&&t++,t>=c._highestBlockNumber&&(c._highestBlockNumber=t),c._highestBlockNumber};case"getGasPrice":return function(d){let b=d.map(t=>t.result);return b.sort(),b[Math.floor(b.length/2)]};case"getEtherPrice":return function(d){return L0e(d.map(b=>b.result))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":f=function(d){return d==null?null:(d=ea(d),d.confirmations=-1,$t(d))};break;case"getBlock":a.includeTransactions?f=function(d){return d==null?null:(d=ea(d),d.transactions=d.transactions.map(b=>(b=ea(b),b.confirmations=-1,b)),$t(d))}:f=function(d){return d==null?null:$t(d)};break;default:throw new Error("unknown method: "+e)}return uwe(f,c.quorum)}function as(c,e){return dg(this,void 0,void 0,function*(){let a=c.provider;return a.blockNumber!=null&&a.blockNumber>=e||e===-1?a:W1(()=>new Promise((f,d)=>{setTimeout(function(){return a.blockNumber>=e?f(a):c.cancelled?f(null):f(void 0)},0)}),{oncePoll:a})})}function pwe(c,e,a,f){return dg(this,void 0,void 0,function*(){let d=c.provider;switch(a){case"getBlockNumber":case"getGasPrice":return d[a]();case"getEtherPrice":if(d.getEtherPrice)return d.getEtherPrice();break;case"getBalance":case"getTransactionCount":case"getCode":return f.blockTag&&n0(f.blockTag)&&(d=yield as(c,e)),d[a](f.address,f.blockTag||"latest");case"getStorageAt":return f.blockTag&&n0(f.blockTag)&&(d=yield as(c,e)),d.getStorageAt(f.address,f.position,f.blockTag||"latest");case"getBlock":return f.blockTag&&n0(f.blockTag)&&(d=yield as(c,e)),d[f.includeTransactions?"getBlockWithTransactions":"getBlock"](f.blockTag||f.blockHash);case"call":case"estimateGas":return f.blockTag&&n0(f.blockTag)&&(d=yield as(c,e)),a==="call"&&f.blockTag?d[a](f.transaction,f.blockTag):d[a](f.transaction);case"getTransaction":case"getTransactionReceipt":return d[a](f.transactionHash);case"getLogs":{let b=f.filter;return(b.fromBlock&&n0(b.fromBlock)||b.toBlock&&n0(b.toBlock))&&(d=yield as(c,e)),d.getLogs(b)}}return f5.throwError("unknown method error",X.errors.UNKNOWN_ERROR,{method:a,params:f})})}var cs=class extends Xb{constructor(e,a){e.length===0&&f5.throwArgumentError("missing providers","providers",e);let f=e.map((t,r)=>{if(Fd.isProvider(t)){let i=Ho(t)?2e3:750;return Object.freeze({provider:t,weight:1,stallTimeout:i,priority:1})}let o=ea(t);o.priority==null&&(o.priority=1),o.stallTimeout==null&&(o.stallTimeout=Ho(t)?2e3:750),o.weight==null&&(o.weight=1);let n=o.weight;return(n%1||n>512||n<1)&&f5.throwArgumentError("invalid weight; must be integer in [1, 512]",`providers[${r}].weight`,n),Object.freeze(o)}),d=f.reduce((t,r)=>t+r.weight,0);a==null?a=d/2:a>d&&f5.throwArgumentError("quorum will always fail; larger than total weight","quorum",a);let b=I0e(f.map(t=>t.provider.network));b==null&&(b=new Promise((t,r)=>{setTimeout(()=>{this.detectNetwork().then(t,r)},0)})),super(b),he(this,"providerConfigs",Object.freeze(f)),he(this,"quorum",a),this._highestBlockNumber=-1}detectNetwork(){return dg(this,void 0,void 0,function*(){let e=yield Promise.all(this.providerConfigs.map(a=>a.provider.getNetwork()));return I0e(e)})}perform(e,a){return dg(this,void 0,void 0,function*(){if(e==="sendTransaction"){let o=yield Promise.all(this.providerConfigs.map(n=>n.provider.sendTransaction(a.signedTransaction).then(i=>i.hash,i=>i)));for(let n=0;n<o.length;n++){let i=o[n];if(typeof i=="string")return i}throw o[0]}this._highestBlockNumber===-1&&e!=="getBlockNumber"&&(yield this.getBlockNumber());let f=hwe(this,e,a),d=Uo(this.providerConfigs.map(ea));d.sort((o,n)=>o.priority-n.priority);let b=this._highestBlockNumber,t=0,r=!0;for(;;){let o=cg(),n=d.filter(u=>u.runner&&o-u.start<u.stallTimeout).reduce((u,g)=>u+g.weight,0);for(;n<this.quorum&&t<d.length;){let u=d[t++],g=swe++;u.start=cg(),u.staller=F0e(u.stallTimeout),u.staller.wait(()=>{u.staller=null}),u.runner=pwe(u,b,e,a).then(E=>{u.done=!0,u.result=E,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:g,backend:fg(u,cg()),request:{method:e,params:Va(a)},provider:this})},E=>{u.done=!0,u.error=E,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:g,backend:fg(u,cg()),request:{method:e,params:Va(a)},provider:this})}),this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:g,backend:fg(u,null),request:{method:e,params:Va(a)},provider:this}),n+=u.weight}let i=[];d.forEach(u=>{u.done||!u.runner||(i.push(u.runner),u.staller&&i.push(u.staller.getPromise()))}),i.length&&(yield Promise.race(i));let l=d.filter(u=>u.done&&u.error==null);if(l.length>=this.quorum){let u=f(l);if(u!==void 0)return d.forEach(g=>{g.staller&&g.staller.cancel(),g.cancelled=!0}),u;r||(yield F0e(100).getPromise()),r=!1}let h=d.reduce((u,g)=>{if(!g.done||g.error==null)return u;let E=g.error.code;return xwe.indexOf(E)>=0&&(u[E]||(u[E]={error:g.error,weight:0}),u[E].weight+=g.weight),u},{});if(Object.keys(h).forEach(u=>{let g=h[u];if(g.weight<this.quorum)return;d.forEach(F=>{F.staller&&F.staller.cancel(),F.cancelled=!0});let E=g.error,_={};lwe.forEach(F=>{E[F]!=null&&(_[F]=E[F])}),f5.throwError(E.reason||E.message,u,_)}),d.filter(u=>!u.done).length===0)break}return d.forEach(o=>{o.staller&&o.staller.cancel(),o.cancelled=!0}),f5.throwError("failed to meet quorum",X.errors.SERVER_ERROR,{method:e,params:a,results:d.map(o=>fg(o)),provider:this})})}};s();x();var SF=null;s();x();var bg=new X(ia),fs="84842078b09946638c03157f83405213",ds=class extends m8{constructor(e,a){let f=new Vt(e,a),d=f.connection;d.password&&bg.throwError("INFURA WebSocket project secrets unsupported",X.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});let b=d.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(b,e),he(this,"apiKey",f.projectId),he(this,"projectId",f.projectId),he(this,"projectSecret",f.projectSecret)}isCommunityResource(){return this.projectId===fs}},Vt=class extends Qc{static getWebSocketProvider(e,a){return new ds(e,a)}static getApiKey(e){let a={apiKey:fs,projectId:fs,projectSecret:null};return e==null||(typeof e=="string"?a.projectId=e:e.projectSecret!=null?(bg.assertArgument(typeof e.projectId=="string","projectSecret requires a projectId","projectId",e.projectId),bg.assertArgument(typeof e.projectSecret=="string","invalid projectSecret","projectSecret","[REDACTED]"),a.projectId=e.projectId,a.projectSecret=e.projectSecret):e.projectId&&(a.projectId=e.projectId),a.apiKey=a.projectId),a}static getUrl(e,a){let f=null;switch(e?e.name:"unknown"){case"homestead":f="mainnet.infura.io";break;case"goerli":f="goerli.infura.io";break;case"sepolia":f="sepolia.infura.io";break;case"matic":f="polygon-mainnet.infura.io";break;case"maticmum":f="polygon-mumbai.infura.io";break;case"optimism":f="optimism-mainnet.infura.io";break;case"optimism-goerli":f="optimism-goerli.infura.io";break;case"arbitrum":f="arbitrum-mainnet.infura.io";break;case"arbitrum-goerli":f="arbitrum-goerli.infura.io";break;default:bg.throwError("unsupported network",X.errors.INVALID_ARGUMENT,{argument:"network",value:e})}let d={allowGzip:!0,url:"https://"+f+"/v3/"+a.projectId,throttleCallback:(b,t)=>(a.projectId===fs&&Yb(),Promise.resolve(!0))};return a.projectSecret!=null&&(d.user="",d.password=a.projectSecret),d}isCommunityResource(){return this.projectId===fs}};s();x();var tg=class extends Bd{send(e,a){let f={method:e,params:a,id:this._nextId++,jsonrpc:"2.0"};this._pendingBatch==null&&(this._pendingBatch=[]);let d={request:f,resolve:null,reject:null},b=new Promise((t,r)=>{d.resolve=t,d.reject=r});return this._pendingBatch.push(d),this._pendingBatchAggregator||(this._pendingBatchAggregator=setTimeout(()=>{let t=this._pendingBatch;this._pendingBatch=null,this._pendingBatchAggregator=null;let r=t.map(o=>o.request);return this.emit("debug",{action:"requestBatch",request:Va(r),provider:this}),Q1(this.connection,JSON.stringify(r)).then(o=>{this.emit("debug",{action:"response",request:r,response:o,provider:this}),t.forEach((n,i)=>{let l=o[i];if(l.error){let h=new Error(l.error.message);h.code=l.error.code,h.data=l.error.data,n.reject(h)}else n.resolve(l.result)})},o=>{this.emit("debug",{action:"response",error:o,request:r,provider:this}),t.forEach(n=>{n.reject(o)})})},10)),b}};s();x();var IF=new X(ia),mwe="ETHERS_JS_SHARED",bs=class extends Qc{static getApiKey(e){return e&&typeof e!="string"&&IF.throwArgumentError("invalid apiKey","apiKey",e),e||mwe}static getUrl(e,a){IF.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");let f=null;switch(e.name){case"homestead":f="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":f="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":f="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":f="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":f="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:IF.throwArgumentError("unsupported network","network",arguments[0])}return f+"?apiKey="+a}};s();x();var C0e=new X(ia),R0e="62e1ad51b37b8e00394bda3b",ts=class extends Qc{static getApiKey(e){let a={applicationId:null,loadBalancer:!0,applicationSecretKey:null};return e==null?a.applicationId=R0e:typeof e=="string"?a.applicationId=e:e.applicationSecretKey!=null?(a.applicationId=e.applicationId,a.applicationSecretKey=e.applicationSecretKey):e.applicationId?a.applicationId=e.applicationId:C0e.throwArgumentError("unsupported PocketProvider apiKey","apiKey",e),a}static getUrl(e,a){let f=null;switch(e?e.name:"unknown"){case"goerli":f="eth-goerli.gateway.pokt.network";break;case"homestead":f="eth-mainnet.gateway.pokt.network";break;case"kovan":f="poa-kovan.gateway.pokt.network";break;case"matic":f="poly-mainnet.gateway.pokt.network";break;case"maticmum":f="polygon-mumbai-rpc.gateway.pokt.network";break;case"rinkeby":f="eth-rinkeby.gateway.pokt.network";break;case"ropsten":f="eth-ropsten.gateway.pokt.network";break;default:C0e.throwError("unsupported network",X.errors.INVALID_ARGUMENT,{argument:"network",value:e})}let d=`https://${f}/v1/lb/${a.applicationId}`,b={headers:{},url:d};return a.applicationSecretKey!=null&&(b.user="",b.password=a.applicationSecretKey),b}isCommunityResource(){return this.applicationId===R0e}};s();x();var B0e=new X(ia),gwe=1;function P0e(c,e){let a="Web3LegacyFetcher";return function(f,d){let b={method:f,params:d,id:gwe++,jsonrpc:"2.0"};return new Promise((t,r)=>{this.emit("debug",{action:"request",fetcher:a,request:Va(b),provider:this}),e(b,(o,n)=>{if(o)return this.emit("debug",{action:"response",fetcher:a,error:o,request:b,provider:this}),r(o);if(this.emit("debug",{action:"response",fetcher:a,request:b,response:n,provider:this}),n.error){let i=new Error(n.error.message);return i.code=n.error.code,i.data=n.error.data,r(i)}t(n.result)})})}}function ywe(c){return function(e,a){a==null&&(a=[]);let f={method:e,params:a};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:Va(f),provider:this}),c.request(f).then(d=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:f,response:d,provider:this}),d),d=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:f,error:d,provider:this}),d})}}var rs=class extends Bd{constructor(e,a){e==null&&B0e.throwArgumentError("missing provider","provider",e);let f=null,d=null,b=null;typeof e=="function"?(f="unknown:",d=e):(f=e.host||e.path||"",!f&&e.isMetaMask&&(f="metamask"),b=e,e.request?(f===""&&(f="eip-1193:"),d=ywe(e)):e.sendAsync?d=P0e(e,e.sendAsync.bind(e)):e.send?d=P0e(e,e.send.bind(e)):B0e.throwArgumentError("unsupported provider","provider",e),f||(f="unknown:")),super(f,a),he(this,"jsonRpcFetchFunc",d),he(this,"provider",b)}send(e,a){return this.jsonRpcFetchFunc(e,a)}};var T0e=new X(ia);function rg(c,e){if(c==null&&(c="homestead"),typeof c=="string"){let f=c.match(/^(ws|http)s?:/i);if(f)switch(f[1].toLowerCase()){case"http":case"https":return new Bd(c);case"ws":case"wss":return new m8(c);default:T0e.throwArgumentError("unsupported URL scheme","network",c)}}let a=Go(c);return(!a||!a._defaultProvider)&&T0e.throwError("unsupported getDefaultProvider network",X.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:c}),a._defaultProvider({FallbackProvider:cs,AlchemyProvider:Ht,AnkrProvider:Yo,CloudflareProvider:Xo,EtherscanProvider:es,InfuraProvider:Vt,JsonRpcProvider:Bd,NodesmithProvider:bs,PocketProvider:ts,Web3Provider:rs,IpcProvider:null},e)}var og={};v0(og,{AbiCoder:()=>gt,ConstructorFragment:()=>Rf,ErrorFragment:()=>r2,EventFragment:()=>ed,FormatTypes:()=>Q0,Fragment:()=>ad,FunctionFragment:()=>Bf,HDNode:()=>Kc,Indexed:()=>b8,Interface:()=>G7,LogDescription:()=>vt,Logger:()=>X,ParamType:()=>Na,RLP:()=>fm,SigningKey:()=>a1,SupportedAlgorithm:()=>Jb,TransactionDescription:()=>Et,TransactionTypes:()=>Tm,UnicodeNormalizationForm:()=>cd,Utf8ErrorFuncs:()=>mm,Utf8ErrorReason:()=>Pf,_TypedDataEncoder:()=>Wa,_fetchData:()=>lF,_toEscapedUtf8String:()=>yL,accessListify:()=>s2,arrayify:()=>Se,base58:()=>o8,base64:()=>SL,checkProperties:()=>xt,checkResultErrors:()=>ut,commify:()=>G0e,computeAddress:()=>c1,computeHmac:()=>s8,computePublicKey:()=>Po,concat:()=>O0,deepCopy:()=>Va,defaultAbiCoder:()=>Lo,defaultPath:()=>x8,defineReadOnly:()=>he,dnsEncode:()=>Co,entropyToMnemonic:()=>c5,fetchJson:()=>Q1,formatBytes32String:()=>wL,formatEther:()=>z0e,formatUnits:()=>LF,getAccountPath:()=>Tee,getAddress:()=>M0,getContractAddress:()=>K4,getCreate2Address:()=>QY,getIcapAddress:()=>KY,getJsonWalletAddress:()=>nF,getStatic:()=>Ka,hashMessage:()=>_t,hexConcat:()=>Ec,hexDataLength:()=>Cf,hexDataSlice:()=>ya,hexStripZeros:()=>nL,hexValue:()=>kb,hexZeroPad:()=>q0,hexlify:()=>Be,id:()=>n2,isAddress:()=>VY,isBytes:()=>Q2,isBytesLike:()=>a8,isHexString:()=>n0,isValidMnemonic:()=>Pee,isValidName:()=>LL,joinSignature:()=>mo,keccak256:()=>N0,mnemonicToEntropy:()=>Mt,mnemonicToSeed:()=>aF,namehash:()=>q7,nameprep:()=>AL,parseBytes32String:()=>_L,parseEther:()=>j0e,parseTransaction:()=>Om,parseUnits:()=>FF,poll:()=>W1,randomBytes:()=>Zb,recoverAddress:()=>Z4,recoverPublicKey:()=>Pm,resolveProperties:()=>wa,ripemd160:()=>Mo,serializeTransaction:()=>To,sha256:()=>Rd,sha512:()=>ZL,shallowCopy:()=>ea,shuffled:()=>Uo,solidityKeccak256:()=>M0e,solidityPack:()=>ig,soliditySha256:()=>D0e,splitSignature:()=>Ub,stripZeros:()=>b2,toUtf8Bytes:()=>J0,toUtf8CodePoints:()=>U7,toUtf8String:()=>Ld,verifyMessage:()=>Jee,verifyTypedData:()=>Zee,zeroPad:()=>j4});s();x();s();x();s();x();var O0e="solidity/5.7.0";var wwe=new RegExp("^bytes([0-9]+)$"),_we=new RegExp("^(u?int)([0-9]*)$"),vwe=new RegExp("^(.*)\\[([0-9]*)\\]$"),Ewe="0000000000000000000000000000000000000000000000000000000000000000",Kt=new X(O0e);function N0e(c,e,a){switch(c){case"address":return a?j4(e,32):Se(e);case"string":return J0(e);case"bytes":return Se(e);case"bool":return e=e?"0x01":"0x00",a?j4(e,32):Se(e)}let f=c.match(_we);if(f){let d=parseInt(f[2]||"256");return(f[2]&&String(d)!==f[2]||d%8!==0||d===0||d>256)&&Kt.throwArgumentError("invalid number type","type",c),a&&(d=256),e=Ee.from(e).toTwos(d),j4(e,d/8)}if(f=c.match(wwe),f){let d=parseInt(f[1]);return(String(d)!==f[1]||d===0||d>32)&&Kt.throwArgumentError("invalid bytes type","type",c),Se(e).byteLength!==d&&Kt.throwArgumentError(`invalid value for ${c}`,"value",e),a?Se((e+Ewe).substring(0,66)):e}if(f=c.match(vwe),f&&Array.isArray(e)){let d=f[1];parseInt(f[2]||String(e.length))!=e.length&&Kt.throwArgumentError(`invalid array length for ${c}`,"value",e);let t=[];return e.forEach(function(r){t.push(N0e(d,r,!0))}),O0(t)}return Kt.throwArgumentError("invalid type","type",c)}function ig(c,e){c.length!=e.length&&Kt.throwArgumentError("wrong number of values; expected ${ types.length }","values",e);let a=[];return c.forEach(function(f,d){a.push(N0e(f,e[d]))}),Be(O0(a))}function M0e(c,e){return N0(ig(c,e))}function D0e(c,e){return Rd(ig(c,e))}s();x();s();x();var k0e="units/5.7.0";var U0e=new X(k0e),q0e=["wei","kwei","mwei","gwei","szabo","finney","ether"];function G0e(c){let e=String(c).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||c==="."||c==="-.")&&U0e.throwArgumentError("invalid value","value",c);let a=e[0],f="";for(a.substring(0,1)==="-"&&(f="-",a=a.substring(1));a.substring(0,1)==="0";)a=a.substring(1);a===""&&(a="0");let d="";for(e.length===2&&(d="."+(e[1]||"0"));d.length>2&&d[d.length-1]==="0";)d=d.substring(0,d.length-1);let b=[];for(;a.length;)if(a.length<=3){b.unshift(a);break}else{let t=a.length-3;b.unshift(a.substring(t)),a=a.substring(0,t)}return f+b.join(",")+d}function LF(c,e){if(typeof e=="string"){let a=q0e.indexOf(e);a!==-1&&(e=3*a)}return st(c,e??18)}function FF(c,e){if(typeof c!="string"&&U0e.throwArgumentError("value must be a string","value",c),typeof e=="string"){let a=q0e.indexOf(e);a!==-1&&(e=3*a)}return J2(c,e??18)}function z0e(c){return LF(c,18)}function j0e(c){return FF(c,18)}s();x();var sg="ethers/5.7.2";var H0e=new X(sg);try{let c=window;c._ethers==null&&(c._ethers=Qt)}catch{}var $0e=[{anonymous:!1,inputs:[{indexed:!1,internalType:"uint8",name:"version",type:"uint8"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"id",type:"uint256"},{indexed:!1,internalType:"uint256",name:"blockN",type:"uint256"},{indexed:!1,internalType:"uint256",name:"timestamp",type:"uint256"},{indexed:!1,internalType:"uint256",name:"state",type:"uint256"}],name:"StateUpdated",type:"event"},{inputs:[],name:"ID_HISTORY_RETURN_LIMIT",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"}],name:"getGISTProof",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"bool",name:"existence",type:"bool"},{internalType:"uint256[64]",name:"siblings",type:"uint256[64]"},{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"auxExistence",type:"bool"},{internalType:"uint256",name:"auxIndex",type:"uint256"},{internalType:"uint256",name:"auxValue",type:"uint256"}],internalType:"struct Smt.Proof",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getGISTProofByBlock",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"bool",name:"existence",type:"bool"},{internalType:"uint256[64]",name:"siblings",type:"uint256[64]"},{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"auxExistence",type:"bool"},{internalType:"uint256",name:"auxIndex",type:"uint256"},{internalType:"uint256",name:"auxValue",type:"uint256"}],internalType:"struct Smt.Proof",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"root",type:"uint256"}],name:"getGISTProofByRoot",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"bool",name:"existence",type:"bool"},{internalType:"uint256[64]",name:"siblings",type:"uint256[64]"},{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"auxExistence",type:"bool"},{internalType:"uint256",name:"auxIndex",type:"uint256"},{internalType:"uint256",name:"auxValue",type:"uint256"}],internalType:"struct Smt.Proof",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"timestamp",type:"uint256"}],name:"getGISTProofByTime",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"bool",name:"existence",type:"bool"},{internalType:"uint256[64]",name:"siblings",type:"uint256[64]"},{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"auxExistence",type:"bool"},{internalType:"uint256",name:"auxIndex",type:"uint256"},{internalType:"uint256",name:"auxValue",type:"uint256"}],internalType:"struct Smt.Proof",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getGISTRoot",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"start",type:"uint256"},{internalType:"uint256",name:"length",type:"uint256"}],name:"getGISTRootHistory",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"uint256",name:"replacedByRoot",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct Smt.RootInfo[]",name:"",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getGISTRootHistoryLength",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"root",type:"uint256"}],name:"getGISTRootInfo",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"uint256",name:"replacedByRoot",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct Smt.RootInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getGISTRootInfoByBlock",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"uint256",name:"replacedByRoot",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct Smt.RootInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],name:"getGISTRootInfoByTime",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"uint256",name:"replacedByRoot",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct Smt.RootInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"}],name:"getStateInfoById",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"state",type:"uint256"},{internalType:"uint256",name:"replacedByState",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct StateV2.StateInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"state",type:"uint256"}],name:"getStateInfoByState",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"state",type:"uint256"},{internalType:"uint256",name:"replacedByState",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct StateV2.StateInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"startIndex",type:"uint256"},{internalType:"uint256",name:"length",type:"uint256"}],name:"getStateInfoHistoryById",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"state",type:"uint256"},{internalType:"uint256",name:"replacedByState",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct StateV2.StateInfo[]",name:"",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"}],name:"getStateInfoHistoryLengthById",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVerifier",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"}],name:"idExists",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract IVerifier",name:"verifierContractAddr",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newVerifierAddr",type:"address"}],name:"setVerifier",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"state",type:"uint256"}],name:"stateExists",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"oldState",type:"uint256"},{internalType:"uint256",name:"newState",type:"uint256"},{internalType:"bool",name:"isOldStateGenesis",type:"bool"},{internalType:"uint256[2]",name:"a",type:"uint256[2]"},{internalType:"uint256[2][2]",name:"b",type:"uint256[2][2]"},{internalType:"uint256[2]",name:"c",type:"uint256[2]"}],name:"transitState",outputs:[],stateMutability:"nonpayable",type:"function"}];var V0e={url:"http://localhost:8545",defaultGasLimit:6e5,minGasPrice:"0",maxGasPrice:"100000000000",confirmationBlockCount:5,confirmationTimeout:6e5,contractAddress:"0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",receiptTimeout:6e5,rpcResponseTimeout:5e3,waitReceiptCycleTime:3e4,waitBlockCycleTime:3e3},CF=class{constructor(e=V0e){this.ethConfig=e;this.provider=new Qt.providers.JsonRpcProvider(this.ethConfig.url),this.stateContract=new Qt.Contract(this.ethConfig.contractAddress,$0e,this.provider)}stateContract;provider;async getLatestStateById(e){let a=await this.stateContract.getStateInfoById(e);return{id:Ee.from(a[0]).toBigInt(),state:Ee.from(a[1]).toBigInt(),replacedByState:Ee.from(a[2]).toBigInt(),createdAtTimestamp:Ee.from(a[3]).toBigInt(),replacedAtTimestamp:Ee.from(a[4]).toBigInt(),createdAtBlock:Ee.from(a[5]).toBigInt(),replacedAtBlock:Ee.from(a[6]).toBigInt()}}async publishState(e,a){let f=new TextEncoder,d=this.stateContract.connect(a),b=new po;b.pubSignalsUnmarshal(f.encode(JSON.stringify(e.pub_signals)));let{userId:t,oldUserState:r,newUserState:o,isOldStateGenesis:n}=b,i=[t.bigInt().toString(),r.bigInt().toString(),o.bigInt().toString(),n,e.proof.pi_a.slice(0,2),[[e.proof.pi_b[0][1].toString(),e.proof.pi_b[0][0].toString()],[e.proof.pi_b[1][1].toString(),e.proof.pi_b[1][0].toString()]],e.proof.pi_c.slice(0,2)];await d.estimateGas.transitState(...i);let h=await(await d.transitState(...i)).wait(),u=h.status,g=h.transactionHash;if(u===0)throw new Error(`transaction: ${g} failed to mined`);return g}async getGISTProof(e){let a=await this.stateContract.getGISTProof(e);return{root:BigInt(a.root.toString()),existence:a.existence,siblings:a.siblings?.map(f=>BigInt(f.toString())),index:BigInt(a.index.toString()),value:BigInt(a.value.toString()),auxExistence:a.auxExistence,auxIndex:BigInt(a.auxIndex.toString()),auxValue:BigInt(a.auxValue.toString())}}async getGISTRootInfo(e){let a=await this.stateContract.getGISTRootInfo(e);return{root:BigInt(a.root.toString()),replacedByRoot:BigInt(a.replacedByRoot.toString()),createdAtTimestamp:BigInt(a.createdAtTimestamp.toString()),replacedAtTimestamp:BigInt(a.replacedAtTimestamp.toString()),createdAtBlock:BigInt(a.createdAtBlock.toString()),replacedAtBlock:BigInt(a.replacedAtBlock.toString())}}};s();x();s();x();s();x();s();x();s();x();s();x();var K0e=(a=>(a.NotDefinedQueryKey="not defined query key",a.NotDefinedComparator="not defined comparator",a))(K0e||{}),Q7={$noop:()=>!0,$eq:(c,e)=>c===e,$in:(c,e)=>e.includes(c),$nin:(c,e)=>!e.includes(c),$gt:(c,e)=>c>e,$lt:(c,e)=>c<e,$ne:(c,e)=>c!==e},RF=(c,e,a=null)=>e.split(".").reduce((f,d)=>f?f[d]:a,c),Swe=(c,e,a,f=!1)=>{if(!e)throw new Error("not defined comparator");return d=>{let b=RF(d,c);return b?f?e(a,b):e(b,a):!1}},e3=class{constructor(e,a,f,d=!1){this.path=e;this.operatorFunc=a;this.value=f;this.isReverseParams=d}execute(e){if(!this.operatorFunc)throw new Error("not defined comparator");let a=RF(e,this.path);return a==null?!1:this.isReverseParams?this.operatorFunc(this.value,a):this.operatorFunc(a,this.value)}},BF=c=>Object.keys(c).reduce((e,a)=>{let f=c[a];switch(a){case"claimId":return e.concat(new e3("id",Q7.$eq,f));case"allowedIssuers":{let[d]=f||[];return d&&d==="*"?e:e.concat(new e3("issuer",Q7.$in,f))}case"type":return e.concat(new e3("type",Q7.$in,f,!0));case"context":return e.concat(new e3("@context",Q7.$in,f,!0));case"credentialSubjectId":return e.concat(new e3("credentialSubject.id",Q7.$eq,f));case"schema":return e.concat(new e3("credentialSchema.id",Q7.$eq,f));case"skipClaimRevocationCheck":return e;case"credentialSubject":{let d=Object.keys(f).reduce((b,t)=>{let r=f[t],o=Object.keys(r).map(n=>{let i=r[n],l=`credentialSubject.${t}`;return new e3(l,Q7[n],i)});return b.concat(o)},[]);return e.concat(d)}default:throw new Error("not defined query key")}},[]);s();x();s();x();var Iwe=[0,1,2],PF=class{_data;mtDepth;constructor(e){this.mtDepth=e,this._data={}}async createIdentityMerkleTrees(e){e||(e=`${If()}`),this._data[e]=[];let a=[];return Iwe.forEach(f=>{let d=e.concat("+"+f.toString()),b=new S2(new X5(yb(d)),!0,this.mtDepth),t={treeId:d,identifier:e,type:f};this._data[e].push({tree:b,metaInfo:t}),a.push(t)}),a}async getIdentityMerkleTreesInfo(e){return this._data[e].map(a=>a.metaInfo)}async getMerkleTreeByIdentifierAndType(e,a){let f=this._data[e].find(d=>d.metaInfo.type==a);if(!f)throw new Error(`Merkle tree not found for identifier ${e} and type ${a}`);return f.tree}async addToMerkleTree(e,a,f,d){for(let b=0;b<this._data[e].length;b++)this._data[e][b].metaInfo.type===a&&await this._data[e][b].tree.add(f,d)}async bindMerkleTreeToNewIdentifier(e,a){this._data[a]=[...this._data[e]],delete this._data[e],this._data[a].forEach(f=>{f.metaInfo.identifier=a})}};s();x();s();x();var TF=class{_data=[];async save(e,a,f="id"){let d=this._data.findIndex(b=>b[f]===e);d===-1?this._data.push(a):this._data[d]=a}async get(e,a="id"){return this._data.find(f=>f[a]===e)}async load(){return this._data}async delete(e,a="id"){let f=this._data.filter(d=>d[a]!==e);if(f.length===this._data.length)throw new Error(`${"item not found"} to delete: ${e}`);this._data=f}};s();x();s();x();var OF=class{constructor(e){this._localStorageKey=e;localStorage.getItem(this._localStorageKey)||localStorage.setItem(e,JSON.stringify([]))}async save(e,a,f="id"){if(localStorage){let d=localStorage.getItem(this._localStorageKey),b=JSON.parse(d),t=b.findIndex(r=>r[f]===e);t===-1?b.push(a):b[t]=a,localStorage.setItem(this._localStorageKey,JSON.stringify(b))}}async get(e,a="id"){let f=localStorage.getItem(this._localStorageKey);return(f&&JSON.parse(f)).find(b=>b[a]===e)}async load(){let e=localStorage.getItem(this._localStorageKey);return e&&JSON.parse(e)}async delete(e,a="id"){let f=localStorage.getItem(this._localStorageKey),d=JSON.parse(f),b=d.filter(t=>t[a]!==e);if(d.length===b.length)throw new Error(`${"item not found"} to delete: ${e}`);localStorage.setItem(this._localStorageKey,JSON.stringify(b))}};s();x();var W0e=[0,1,2],a3=class{constructor(e){this._mtDepth=e}async createIdentityMerkleTrees(e){e||(e=`${If()}`);let a=()=>{let b=[];for(let t=0;t<W0e.length;t++){let r=W0e[t],n={treeId:e.concat("+"+r.toString()),identifier:e,type:r};b.push(n)}return b},f=localStorage.getItem(a3.storageKeyMeta);if(f){let b=JSON.parse(f),t=b.filter(o=>o.identifier===e);if(t.length>0)return t;let r=a();localStorage.setItem(a3.storageKeyMeta,JSON.stringify([...b,...r]))}let d=a();return localStorage.setItem(a3.storageKeyMeta,JSON.stringify(d)),d}async getIdentityMerkleTreesInfo(e){let a=localStorage.getItem(a3.storageKeyMeta);if(a)return JSON.parse(a).filter(d=>d.identifier===e);throw new Error(`Merkle tree meta not found for identifier ${e}`)}async getMerkleTreeByIdentifierAndType(e,a){let f=localStorage.getItem(a3.storageKeyMeta),d=new Error(`Merkle tree not found for identifier ${e} and type ${a}`);if(!f)throw d;let t=JSON.parse(f).filter(r=>r.identifier===e&&r.type===a)[0];if(!t)throw d;return new S2(new hn(yb(t.treeId)),!0,this._mtDepth)}async addToMerkleTree(e,a,f,d){let b=localStorage.getItem(a3.storageKeyMeta);if(!b)throw new Error(`Merkle tree meta not found for identifier ${e}`);let r=JSON.parse(b).filter(n=>n.identifier===e&&n.type===a)[0];if(!r)throw new Error(`Merkle tree not found for identifier ${e} and type ${a}`);await new S2(new hn(yb(r.treeId)),!0,this._mtDepth).add(f,d)}async bindMerkleTreeToNewIdentifier(e,a){let f=localStorage.getItem(a3.storageKeyMeta);if(!f)throw new Error(`Merkle tree meta not found for identifier ${e}`);let d=JSON.parse(f),b=d.filter(r=>r.identifier===e).map(r=>({...r,identifier:a}));if(b.length===0)throw new Error(`Merkle tree meta not found for identifier ${e}`);let t=[...d.filter(r=>r.identifier!==e),...b];localStorage.setItem(a3.storageKeyMeta,JSON.stringify(t))}},xg=a3;Zc(xg,"storageKeyMeta","merkle-tree-meta");s();x();s();x();var NF=class{constructor(e){this._storageKey=e;this._store=I3(`${e}-db`,e)}_store;async save(e,a,f="id"){return gb(e,a,this._store)}async get(e,a="id"){return Md(e,this._store)}async load(){return EO(this._store)}async delete(e,a="id"){return xl(e,this._store)}};s();x();var J0e=[0,1,2],ug=class{constructor(e){this._mtDepth=e;this._merkleTreeMetaStore=I3(`${ug.storageKeyMeta}-db`,ug.storageKeyMeta)}_merkleTreeMetaStore;async createIdentityMerkleTrees(e){e||(e=`${If()}`);let a=()=>{let b=[];for(let t=0;t<J0e.length;t++){let r=J0e[t],n={treeId:e.concat("+"+r.toString()),identifier:e,type:r};b.push(n)}return b},f=await Md(e,this._merkleTreeMetaStore);if(f)return f;let d=a();return await gb(e,d,this._merkleTreeMetaStore),d}async getIdentityMerkleTreesInfo(e){let a=await Md(e,this._merkleTreeMetaStore);if(a)return a;throw new Error(`Merkle tree meta not found for identifier ${e}`)}async getMerkleTreeByIdentifierAndType(e,a){let f=await Md(e,this._merkleTreeMetaStore),d=new Error(`Merkle tree not found for identifier ${e} and type ${a}`);if(!f)throw d;let b=f.find(t=>t.identifier===e&&t.type===a);if(!b)throw d;return new S2(new B3(yb(b.treeId)),!0,this._mtDepth)}async addToMerkleTree(e,a,f,d){let b=await Md(e,this._merkleTreeMetaStore);if(!b)throw new Error(`Merkle tree meta not found for identifier ${e}`);let t=b.find(o=>o.identifier===e&&o.type===a);if(!t)throw new Error(`Merkle tree not found for identifier ${e} and type ${a}`);await new S2(new B3(yb(t.treeId)),!0,this._mtDepth).add(f,d)}async bindMerkleTreeToNewIdentifier(e,a){let f=await Md(e,this._merkleTreeMetaStore);if(!f||!f?.length)throw new Error(`Merkle tree meta not found for identifier ${e}`);let d=f.map(b=>({...b,identifier:a}));await gb(a,d,this._merkleTreeMetaStore),await xl(e,this._merkleTreeMetaStore)}},lg=ug;Zc(lg,"storageKeyMeta","merkle-tree-meta");s();x();s();x();var hg=class{constructor(e){this._dataSource=e}async loadCircuitData(e){let a=await this._dataSource.get(e.toString(),"circuitId");if(!a)throw new Error(`${"item not found"}: ${e}`);return a}async saveCircuitData(e,a){await this._dataSource.save(e.toString(),a,"circuitId")}};Zc(hg,"storageKey","circuits");s();x();var pg=class{constructor(e){this._dataSource=e}async listCredentials(){let e=await this._dataSource.load();return e=e.map(a=>a?Object.assign(new U2,a):void 0),e}async saveCredential(e){return this._dataSource.save(e.id,e)}async saveAllCredentials(e){for(let a of e)await this._dataSource.save(a.id,a)}async removeCredential(e){return this._dataSource.delete(e)}async findCredentialById(e){let a=await this._dataSource.get(e);return a?Object.assign(new U2,a):void 0}async findCredentialsByQuery(e){let a=BF(e),f=(await this._dataSource.load()).filter(d=>a.every(b=>b.execute(d)));return f=f.map(d=>d?Object.assign(new U2,d):void 0),f}};Zc(pg,"storageKey","credentials");s();x();var ns=class{constructor(e,a){this._identityDataSource=e;this._profileDataSource=a}async saveProfile(e){let f=(await this._profileDataSource.load()).filter(b=>b.genesisIdentifier===e.genesisIdentifier),d=f.length?[...f,e]:[e];for(let b=0;b<d.length;b++){let t=d[b];await this._profileDataSource.save(t.id,t)}}async getProfileByVerifier(e){let a=await this._profileDataSource.get(e,"verifier");if(!a)throw new Error("profile not found");return a}async getProfileById(e){let a=await this._profileDataSource.get(e);if(!a)throw new Error("profile not found");return a}async getProfilesByGenesisIdentifier(e){return(await this._profileDataSource.load()).filter(a=>a.genesisIdentifier===e)}async getAllIdentities(){return this._identityDataSource.load()}async saveIdentity(e){return this._identityDataSource.save(e.identifier,e,"identifier")}async getIdentity(e){return this._identityDataSource.get(e,"identifier")}};Zc(ns,"identitiesStorageKey","identities"),Zc(ns,"profilesStorageKey","profiles");s();x();s();x();s();x();var mg=c=>({proof:c.mtp,treeState:ZI(c.issuer.state,c.issuer.claimsTreeRoot,c.issuer.revocationTreeRoot,c.issuer.rootOfRoots)}),Lwe=(c,e,a)=>{let f=new Gd;f.existence=c,f.nodeAux=a,f.depth=e.length;let d=[];for(let b=0;b<e.length;b++){let t=e[b];t.bytes.every(r=>r===0)||(k6(f.notEmpties,b),d.push(t))}return f.siblings=d,f},MF=c=>{let e=!1,a;c.existence?e=!0:c.auxExistence&&(a={key:Y0(c.auxIndex),value:Y0(c.auxValue)});let f=c.siblings.map(t=>Y0(t)),d=Lwe(e,f,a);return{root:Y0(c.root),proof:d}};s();x();s();x();var e6={};v0(e6,{exportSolidityCallData:()=>IC,fullProve:()=>EC,prove:()=>ws,verify:()=>SC});s();x();s();x();s();x();s();x();s();x();s();x();Ah();async function kF(c,e,a,f){if(a=a||4096*64,typeof e!="number"&&["w+","wx+","r","ax+","a+"].indexOf(e)<0)throw new Error("Invalid open option");let d=await Eh.promises.open(c,e),b=await d.stat();return new DF(d,b,a,f,c)}var DF=class{constructor(e,a,f,d,b){for(this.fileName=b,this.fd=e,this.pos=0,this.pageSize=d||1<<8;this.pageSize<a.blksize;)this.pageSize*=2;this.totalSize=a.size,this.totalPages=Math.floor((a.size-1)/this.pageSize)+1,this.maxPagesLoaded=Math.floor(f/this.pageSize)+1,this.pages={},this.pendingLoads=[],this.writing=!1,this.reading=!1,this.avBuffs=[],this.history={}}_loadPage(e){let a=this,f=new Promise((d,b)=>{a.pendingLoads.push({page:e,resolve:d,reject:b})});return a.__statusPage("After Load request: ",e),f}__statusPage(e,a){let f=[],d=this;if(!d.logHistory)return;f.push("=="+e+" "+a);let b="";for(let t=0;t<d.pendingLoads.length;t++)d.pendingLoads[t].page==a&&(b=b+" "+t);if(b&&f.push("Pending loads:"+b),typeof d.pages[a]<"u"){let t=d.pages[a];f.push("Loaded"),f.push("pendingOps: "+t.pendingOps),t.loading&&f.push("loading: "+t.loading),t.writing&&f.push("writing"),t.dirty&&f.push("dirty")}f.push("=="),d.history[a]||(d.history[a]=[]),d.history[a].push(f)}__printHistory(e){let a=this;a.history[e]||console.log("Empty History ",e),console.log("History "+e);for(let f=0;f<a.history[e].length;f++)for(let d=0;d<a.history[e][f].length;d++)console.log("-> "+a.history[e][f][d])}_triggerLoad(){let e=this;if(e.reading||e.pendingLoads.length==0)return;let a=Object.keys(e.pages),f=[];for(let r=0;r<a.length;r++){let o=e.pages[parseInt(a[r])];o.dirty==!1&&o.pendingOps==0&&!o.writing&&!o.loading&&f.push(parseInt(a[r]))}let d=e.maxPagesLoaded-a.length,b=[];for(;e.pendingLoads.length>0&&(typeof e.pages[e.pendingLoads[0].page]<"u"||d>0||f.length>0);){let r=e.pendingLoads.shift();if(typeof e.pages[r.page]<"u"){e.pages[r.page].pendingOps++;let o=f.indexOf(r.page);o>=0&&f.splice(o,1),e.pages[r.page].loading?e.pages[r.page].loading.push(r):r.resolve(),e.__statusPage("After Load (cached): ",r.page)}else{if(d)d--;else{let o=f.shift();e.__statusPage("Before Unload: ",o),e.avBuffs.unshift(e.pages[o]),delete e.pages[o],e.__statusPage("After Unload: ",o)}r.page>=e.totalPages?(e.pages[r.page]=t(),r.resolve(),e.__statusPage("After Load (new): ",r.page)):(e.reading=!0,e.pages[r.page]=t(),e.pages[r.page].loading=[r],b.push(e.fd.read(e.pages[r.page].buff,0,e.pageSize,r.page*e.pageSize).then(o=>{e.pages[r.page].size=o.bytesRead;let n=e.pages[r.page].loading;delete e.pages[r.page].loading;for(let i=0;i<n.length;i++)n[i].resolve();return e.__statusPage("After Load (loaded): ",r.page),o},o=>{r.reject(o)})),e.__statusPage("After Load (loading): ",r.page))}}Promise.all(b).then(()=>{e.reading=!1,e.pendingLoads.length>0&&setImmediate(e._triggerLoad.bind(e)),e._tryClose()});function t(){if(e.avBuffs.length>0){let r=e.avBuffs.shift();return r.dirty=!1,r.pendingOps=1,r.size=0,r}else return{dirty:!1,buff:new Uint8Array(e.pageSize),pendingOps:1,size:0}}}_triggerWrite(){let e=this;if(e.writing)return;let a=Object.keys(e.pages),f=[];for(let d=0;d<a.length;d++){let b=e.pages[parseInt(a[d])];b.dirty&&(b.dirty=!1,b.writing=!0,e.writing=!0,f.push(e.fd.write(b.buff,0,b.size,parseInt(a[d])*e.pageSize).then(()=>{b.writing=!1},t=>{console.log("ERROR Writing: "+t),e.error=t,e._tryClose()})))}e.writing&&Promise.all(f).then(()=>{e.writing=!1,setImmediate(e._triggerWrite.bind(e)),e._tryClose(),e.pendingLoads.length>0&&setImmediate(e._triggerLoad.bind(e))})}_getDirtyPage(){for(let e in this.pages)if(this.pages[e].dirty)return e;return-1}async write(e,a){if(e.byteLength==0)return;let f=this;if(typeof a>"u"&&(a=f.pos),f.pos=a+e.byteLength,f.totalSize<a+e.byteLength&&(f.totalSize=a+e.byteLength),f.pendingClose)throw new Error("Writing a closing file");let d=Math.floor(a/f.pageSize),b=Math.floor((a+e.byteLength-1)/f.pageSize),t=[];for(let i=d;i<=b;i++)t.push(f._loadPage(i));f._triggerLoad();let r=d,o=a%f.pageSize,n=e.byteLength;for(;n>0;){await t[r-d];let i=o+n>f.pageSize?f.pageSize-o:n,l=e.slice(e.byteLength-n,e.byteLength-n+i);new Uint8Array(f.pages[r].buff.buffer,o,i).set(l),f.pages[r].dirty=!0,f.pages[r].pendingOps--,f.pages[r].size=Math.max(o+i,f.pages[r].size),r>=f.totalPages&&(f.totalPages=r+1),n=n-i,r++,o=0,f.writing||setImmediate(f._triggerWrite.bind(f))}}async read(e,a){let f=this,d=new Uint8Array(e);return await f.readToBuffer(d,0,e,a),d}async readToBuffer(e,a,f,d){if(f==0)return;let b=this;if(f>b.pageSize*b.maxPagesLoaded*.8){let h=Math.floor(f*1.1);this.maxPagesLoaded=Math.floor(h/b.pageSize)+1}if(typeof d>"u"&&(d=b.pos),b.pos=d+f,b.pendingClose)throw new Error("Reading a closing file");let t=Math.floor(d/b.pageSize),r=Math.floor((d+f-1)/b.pageSize),o=[];for(let h=t;h<=r;h++)o.push(b._loadPage(h));b._triggerLoad();let n=t,i=d%b.pageSize,l=d+f>b.totalSize?f-(d+f-b.totalSize):f;for(;l>0;){await o[n-t],b.__statusPage("After Await (read): ",n);let h=i+l>b.pageSize?b.pageSize-i:l,u=new Uint8Array(b.pages[n].buff.buffer,b.pages[n].buff.byteOffset+i,h);e.set(u,a+f-l),b.pages[n].pendingOps--,b.__statusPage("After Op done: ",n),l=l-h,n++,i=0,b.pendingLoads.length>0&&setImmediate(b._triggerLoad.bind(b))}this.pos=d+f}_tryClose(){let e=this;!e.pendingClose||(e.error&&e.pendingCloseReject(e.error),e._getDirtyPage()>=0||e.writing||e.reading||e.pendingLoads.length>0)||e.pendingClose()}close(){let e=this;if(e.pendingClose)throw new Error("Closing the file twice");return new Promise((a,f)=>{e.pendingClose=a,e.pendingCloseReject=f,e._tryClose()}).then(()=>{e.fd.close()},a=>{throw e.fd.close(),a})}async discard(){await this.close(),await Eh.promises.unlink(this.fileName)}async writeULE32(e,a){let f=this,d=new Uint8Array(4);new DataView(d.buffer).setUint32(0,e,!0),await f.write(d,a)}async writeUBE32(e,a){let f=this,d=new Uint8Array(4);new DataView(d.buffer).setUint32(0,e,!1),await f.write(d,a)}async writeULE64(e,a){let f=this,d=new Uint8Array(8),b=new DataView(d.buffer);b.setUint32(0,e&4294967295,!0),b.setUint32(4,Math.floor(e/4294967296),!0),await f.write(d,a)}async readULE32(e){let f=await this.read(4,e);return new Uint32Array(f.buffer)[0]}async readUBE32(e){let f=await this.read(4,e);return new DataView(f.buffer).getUint32(0,!1)}async readULE64(e){let f=await this.read(8,e),d=new Uint32Array(f.buffer);return d[1]*4294967296+d[0]}async readString(e){let a=this;if(a.pendingClose)throw new Error("Reading a closing file");let f=typeof e>"u"?a.pos:e,d=Math.floor(f/a.pageSize),b=!1,t="";for(;!b;){let r=a._loadPage(d);a._triggerLoad(),await r,a.__statusPage("After Await (read): ",d);let o=f%a.pageSize,n=new Uint8Array(a.pages[d].buff.buffer,a.pages[d].buff.byteOffset+o,a.pageSize-o),i=n.findIndex(l=>l===0);b=i!==-1,b?(t+=new TextDecoder().decode(n.slice(0,i)),a.pos=d*this.pageSize+o+i+1):(t+=new TextDecoder().decode(n),a.pos=d*this.pageSize+o+n.length),a.pages[d].pendingOps--,a.__statusPage("After Op done: ",d),f=a.pos,d++,a.pendingLoads.length>0&&setImmediate(a._triggerLoad.bind(a))}return t}};s();x();function X0e(c){let e=c.initialSize||1048576,a=new gg;return a.o=c,a.o.data=new Uint8Array(e),a.allocSize=e,a.totalSize=0,a.readOnly=!1,a.pos=0,a}function eae(c){let e=new gg;return e.o=c,e.allocSize=c.data.byteLength,e.totalSize=c.data.byteLength,e.readOnly=!0,e.pos=0,e}var UF=new Uint8Array(4),Z0e=new DataView(UF.buffer),aae=new Uint8Array(8),Y0e=new DataView(aae.buffer),gg=class{constructor(){this.pageSize=1<<14}_resizeIfNeeded(e){if(e>this.allocSize){let a=Math.max(this.allocSize+1048576,Math.floor(this.allocSize*1.1),e),f=new Uint8Array(a);f.set(this.o.data),this.o.data=f,this.allocSize=a}}async write(e,a){if(typeof a>"u"&&(a=this.pos),this.readOnly)throw new Error("Writing a read only file");this._resizeIfNeeded(a+e.byteLength),this.o.data.set(e.slice(),a),a+e.byteLength>this.totalSize&&(this.totalSize=a+e.byteLength),this.pos=a+e.byteLength}async readToBuffer(e,a,f,d){if(typeof d>"u"&&(d=this.pos),this.readOnly&&d+f>this.totalSize)throw new Error("Reading out of bounds");this._resizeIfNeeded(d+f);let t=new Uint8Array(this.o.data.buffer,this.o.data.byteOffset+d,f);e.set(t,a),this.pos=d+f}async read(e,a){let f=this,d=new Uint8Array(e);return await f.readToBuffer(d,0,e,a),d}close(){this.o.data.byteLength!=this.totalSize&&(this.o.data=this.o.data.slice(0,this.totalSize))}async discard(){}async writeULE32(e,a){let f=this;Z0e.setUint32(0,e,!0),await f.write(UF,a)}async writeUBE32(e,a){let f=this;Z0e.setUint32(0,e,!1),await f.write(UF,a)}async writeULE64(e,a){let f=this;Y0e.setUint32(0,e&4294967295,!0),Y0e.setUint32(4,Math.floor(e/4294967296),!0),await f.write(aae,a)}async readULE32(e){let f=await this.read(4,e);return new Uint32Array(f.buffer)[0]}async readUBE32(e){let f=await this.read(4,e);return new DataView(f.buffer).getUint32(0,!1)}async readULE64(e){let f=await this.read(8,e),d=new Uint32Array(f.buffer);return d[1]*4294967296+d[0]}async readString(e){let a=this,f=typeof e>"u"?a.pos:e;if(f>this.totalSize){if(this.readOnly)throw new Error("Reading out of bounds");this._resizeIfNeeded(e)}let d=new Uint8Array(a.o.data.buffer,f,this.totalSize-f),b=d.findIndex(o=>o===0),t=b!==-1,r="";return t?(r=new TextDecoder().decode(d.slice(0,b)),a.pos=f+b+1):a.pos=f,r}};s();x();function dae(c){let e=c.initialSize||0,a=new yg;a.o=c;let f=e?Math.floor((e-1)/4194304)+1:0;a.o.data=[];for(let d=0;d<f-1;d++)a.o.data.push(new Uint8Array(4194304));return f&&a.o.data.push(new Uint8Array(e-4194304*(f-1))),a.totalSize=0,a.readOnly=!1,a.pos=0,a}function bae(c){let e=new yg;return e.o=c,e.totalSize=(c.data.length-1)*4194304+c.data[c.data.length-1].byteLength,e.readOnly=!0,e.pos=0,e}var qF=new Uint8Array(4),cae=new DataView(qF.buffer),tae=new Uint8Array(8),fae=new DataView(tae.buffer),yg=class{constructor(){this.pageSize=1<<14}_resizeIfNeeded(e){if(e<=this.totalSize)return;if(this.readOnly)throw new Error("Reading out of file bounds");let a=Math.floor((e-1)/4194304)+1;for(let f=Math.max(this.o.data.length-1,0);f<a;f++){let d=f<a-1?4194304:e-(a-1)*4194304,b=new Uint8Array(d);f==this.o.data.length-1&&b.set(this.o.data[f]),this.o.data[f]=b}this.totalSize=e}async write(e,a){let f=this;if(typeof a>"u"&&(a=f.pos),this.readOnly)throw new Error("Writing a read only file");this._resizeIfNeeded(a+e.byteLength);let b=Math.floor(a/4194304),t=a%4194304,r=e.byteLength;for(;r>0;){let o=t+r>4194304?4194304-t:r,n=e.slice(e.byteLength-r,e.byteLength-r+o);new Uint8Array(f.o.data[b].buffer,t,o).set(n),r=r-o,b++,t=0}this.pos=a+e.byteLength}async readToBuffer(e,a,f,d){let b=this;if(typeof d>"u"&&(d=b.pos),this.readOnly&&d+f>this.totalSize)throw new Error("Reading out of bounds");this._resizeIfNeeded(d+f);let r=Math.floor(d/4194304),o=d%4194304,n=f;for(;n>0;){let i=o+n>4194304?4194304-o:n,l=new Uint8Array(b.o.data[r].buffer,o,i);e.set(l,a+f-n),n=n-i,r++,o=0}this.pos=d+f}async read(e,a){let f=this,d=new Uint8Array(e);return await f.readToBuffer(d,0,e,a),d}close(){}async discard(){}async writeULE32(e,a){let f=this;cae.setUint32(0,e,!0),await f.write(qF,a)}async writeUBE32(e,a){let f=this;cae.setUint32(0,e,!1),await f.write(qF,a)}async writeULE64(e,a){let f=this;fae.setUint32(0,e&4294967295,!0),fae.setUint32(4,Math.floor(e/4294967296),!0),await f.write(tae,a)}async readULE32(e){let f=await this.read(4,e);return new Uint32Array(f.buffer)[0]}async readUBE32(e){let f=await this.read(4,e);return new DataView(f.buffer).getUint32(0,!1)}async readULE64(e){let f=await this.read(8,e),d=new Uint32Array(f.buffer);return d[1]*4294967296+d[0]}async readString(e){let a=this,f=2048,d=typeof e>"u"?a.pos:e;if(d>this.totalSize){if(this.readOnly)throw new Error("Reading out of bounds");this._resizeIfNeeded(e)}let b=!1,t="";for(;!b;){let r=Math.floor(d/4194304),o=d%4194304;if(a.o.data[r]===void 0)throw new Error("ERROR");let n=Math.min(f,a.o.data[r].length-o),i=new Uint8Array(a.o.data[r].buffer,o,n),l=i.findIndex(h=>h===0);b=l!==-1,b?(t+=new TextDecoder().decode(i.slice(0,l)),a.pos=r*4194304+o+l+1):(t+=new TextDecoder().decode(i),a.pos=r*4194304+o+i.length),d=a.pos}return t}};s();x();var rae=0;var nae=2;var iae=512;var oae=1024;var sae=1<<16,xae=1<<13;async function W7(c,e,a){if(typeof c=="string"&&(c={type:"file",fileName:c,cacheSize:e||sae,pageSize:a||xae}),c.type=="file")return await kF(c.fileName,oae|iae|nae,c.cacheSize,c.pageSize);if(c.type=="mem")return X0e(c);if(c.type=="bigMem")return dae(c);throw new Error("Invalid FastFile type: "+c.type)}async function c3(c,e,a){if(c instanceof Uint8Array&&(c={type:"mem",data:c}),process.browser?typeof c=="string"&&(c={type:"mem",data:await fetch(c).then(function(d){return d.arrayBuffer()}).then(function(d){return new Uint8Array(d)})}):typeof c=="string"&&(c={type:"file",fileName:c,cacheSize:e||sae,pageSize:a||xae}),c.type=="file")return await kF(c.fileName,rae,c.cacheSize,c.pageSize);if(c.type=="mem")return await eae(c);if(c.type=="bigMem")return await bae(c);throw new Error("Invalid FastFile type: "+c.type)}async function Ga(c,e,a,f,d){let b=await c3(c,f,d),t=await b.read(4),r="";for(let l=0;l<4;l++)r+=String.fromCharCode(t[l]);if(r!=e)throw new Error(c+": Invalid File format");if(await b.readULE32()>a)throw new Error("Version not supported");let n=await b.readULE32(),i=[];for(let l=0;l<n;l++){let h=await b.readULE32(),u=await b.readULE64();typeof i[h]>"u"&&(i[h]=[]),i[h].push({p:b.pos,size:u}),b.pos+=u}return{fd:b,sections:i}}async function of(c,e,a,f,d,b){let t=await W7(c,d,b),r=new Uint8Array(4);for(let o=0;o<4;o++)r[o]=e.charCodeAt(o);return await t.write(r,0),await t.writeULE32(a),await t.writeULE32(f),t}async function dd(c,e){if(typeof c.writingSection<"u")throw new Error("Already writing a section");await c.writeULE32(e),c.writingSection={pSectionSize:c.pos},await c.writeULE64(0)}async function bd(c){if(typeof c.writingSection>"u")throw new Error("Not writing a section");let e=c.pos-c.writingSection.pSectionSize-8,a=c.pos;c.pos=c.writingSection.pSectionSize,await c.writeULE64(e),c.pos=a,delete c.writingSection}async function td(c,e,a){if(typeof c.readingSection<"u")throw new Error("Already reading a section");if(!e[a])throw new Error(c.fileName+": Missing section "+a);if(e[a].length>1)throw new Error(c.fileName+": Section Duplicated "+a);c.pos=e[a][0].p,c.readingSection=e[a][0]}async function rd(c,e){if(typeof c.readingSection>"u")throw new Error("Not reading a section");if(!e&&c.pos-c.readingSection.p!=c.readingSection.size)throw new Error("Invalid section size reading");delete c.readingSection}async function Wt(c,e,a,f){let d=new Uint8Array(a);E0.toRprLE(d,0,e,a),await c.write(d,f)}async function J7(c,e,a){let f=await c.read(e,a);return E0.fromRprLE(f,0,e)}async function x2(c,e,a,f,d){if(f=typeof f>"u"?0:f,d=typeof d>"u"?e[a][0].size-f:d,f+d>e[a][0].size)throw new Error("Reading out of the range of the section");let b;return d<1<<30?b=new Uint8Array(d):b=new ca(d),await c.readToBuffer(b,0,d,e[a][0].p+f),b}s();x();s();x();var sf={};v0(sf,{abs:()=>Dwe,add:()=>os,band:()=>vg,bitLength:()=>d5,bits:()=>hae,bor:()=>Gwe,bxor:()=>zwe,div:()=>gae,e:()=>_a,eq:()=>HF,exp:()=>Mwe,fromArray:()=>Bwe,fromRprBE:()=>wae,fromRprLE:()=>t5,fromString:()=>wg,geq:()=>$F,gt:()=>xs,isNegative:()=>GF,isOdd:()=>_g,isZero:()=>lae,land:()=>jwe,leq:()=>qwe,lnot:()=>$we,lor:()=>Hwe,lt:()=>Uwe,mod:()=>ss,mul:()=>jF,naf:()=>uae,neg:()=>zF,neq:()=>kwe,one:()=>Z7,pow:()=>mae,shiftLeft:()=>is,shiftRight:()=>b5,shl:()=>Pwe,shr:()=>Twe,square:()=>Nwe,sub:()=>Jt,toArray:()=>Owe,toLEBuff:()=>d3,toNumber:()=>pae,toRprBE:()=>yae,toRprLE:()=>Zt,toString:()=>Eg,zero:()=>VF});s();x();var Rwe=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function wg(c,e){if(!e||e==10)return BigInt(c);if(e==16)return c.slice(0,2)=="0x"?BigInt(c):BigInt("0x"+c)}var _a=wg;function Bwe(c,e){let a=BigInt(0);e=BigInt(e);for(let f=0;f<c.length;f++)a=a*e+BigInt(c[f]);return a}function d5(c){let e=c.toString(16);return(e.length-1)*4+Rwe[parseInt(e[0],16)]}function GF(c){return BigInt(c)<BigInt(0)}function lae(c){return!c}function is(c,e){return BigInt(c)<<BigInt(e)}function b5(c,e){return BigInt(c)>>BigInt(e)}var Pwe=is,Twe=b5;function _g(c){return(BigInt(c)&BigInt(1))==BigInt(1)}function uae(c){let e=BigInt(c),a=[];for(;e;){if(e&BigInt(1)){let f=2-Number(e%BigInt(4));a.push(f),e=e-BigInt(f)}else a.push(0);e=e>>BigInt(1)}return a}function hae(c){let e=BigInt(c),a=[];for(;e;)e&BigInt(1)?a.push(1):a.push(0),e=e>>BigInt(1);return a}function pae(c){if(c>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Number too big");return Number(c)}function Owe(c,e){let a=[],f=BigInt(c);for(e=BigInt(e);f;)a.unshift(Number(f%e)),f=f/e;return a}function os(c,e){return BigInt(c)+BigInt(e)}function Jt(c,e){return BigInt(c)-BigInt(e)}function zF(c){return-BigInt(c)}function jF(c,e){return BigInt(c)*BigInt(e)}function Nwe(c){return BigInt(c)*BigInt(c)}function mae(c,e){return BigInt(c)**BigInt(e)}function Mwe(c,e){return BigInt(c)**BigInt(e)}function Dwe(c){return BigInt(c)>=0?BigInt(c):-BigInt(c)}function gae(c,e){return BigInt(c)/BigInt(e)}function ss(c,e){return BigInt(c)%BigInt(e)}function HF(c,e){return BigInt(c)==BigInt(e)}function kwe(c,e){return BigInt(c)!=BigInt(e)}function Uwe(c,e){return BigInt(c)<BigInt(e)}function xs(c,e){return BigInt(c)>BigInt(e)}function qwe(c,e){return BigInt(c)<=BigInt(e)}function $F(c,e){return BigInt(c)>=BigInt(e)}function vg(c,e){return BigInt(c)&BigInt(e)}function Gwe(c,e){return BigInt(c)|BigInt(e)}function zwe(c,e){return BigInt(c)^BigInt(e)}function jwe(c,e){return BigInt(c)&&BigInt(e)}function Hwe(c,e){return BigInt(c)||BigInt(e)}function $we(c){return!BigInt(c)}function Zt(c,e,a,f){let d="0000000"+a.toString(16),b=new Uint32Array(c.buffer,e,f/4),t=((d.length-7)*4-1>>5)+1;for(let r=0;r<t;r++)b[r]=parseInt(d.substring(d.length-8*r-8,d.length-8*r),16);for(let r=t;r<b.length;r++)b[r]=0;for(let r=b.length*4;r<f;r++)c[r]=pae(vg(b5(a,r*8),255))}function yae(c,e,a,f){let d="0000000"+a.toString(16),b=new DataView(c.buffer,c.byteOffset+e,f),t=((d.length-7)*4-1>>5)+1;for(let r=0;r<t;r++)b.setUint32(f-r*4-4,parseInt(d.substring(d.length-8*r-8,d.length-8*r),16),!1);for(let r=0;r<f/4-t;r++)b[r]=0}function t5(c,e,a){a=a||c.byteLength,e=e||0;let f=new Uint32Array(c.buffer,e,a/4),d=new Array(a/4);return f.forEach((b,t)=>d[d.length-t-1]=b.toString(16).padStart(8,"0")),wg(d.join(""),16)}function wae(c,e,a){a=a||c.byteLength,e=e||0;let f=new DataView(c.buffer,c.byteOffset+e,a),d=new Array(a/4);for(let b=0;b<a/4;b++)d[b]=f.getUint32(b*4,!1).toString(16).padStart(8,"0");return wg(d.join(""),16)}function Eg(c,e){return c.toString(e)}function d3(c){let e=new Uint8Array(Math.floor((d5(c)-1)/8)+1);return Zt(e,0,c,e.byteLength),e}var VF=_a(0),Z7=_a(1);s();x();var Vwe=[];for(let c=0;c<256;c++)Vwe[c]=Kwe(c,8);function Kwe(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}s();x();s();x();s();x();s();x();s();x();function Y7(c,e,a,f,d){c[e]=c[e]+c[a]>>>0,c[d]=(c[d]^c[e])>>>0,c[d]=(c[d]<<16|c[d]>>>16&65535)>>>0,c[f]=c[f]+c[d]>>>0,c[a]=(c[a]^c[f])>>>0,c[a]=(c[a]<<12|c[a]>>>20&4095)>>>0,c[e]=c[e]+c[a]>>>0,c[d]=(c[d]^c[e])>>>0,c[d]=(c[d]<<8|c[d]>>>24&255)>>>0,c[f]=c[f]+c[d]>>>0,c[a]=(c[a]^c[f])>>>0,c[a]=(c[a]<<7|c[a]>>>25&127)>>>0}function Qwe(c){Y7(c,0,4,8,12),Y7(c,1,5,9,13),Y7(c,2,6,10,14),Y7(c,3,7,11,15),Y7(c,0,5,10,15),Y7(c,1,6,11,12),Y7(c,2,7,8,13),Y7(c,3,4,9,14)}var b3=class{constructor(e){e=e||[0,0,0,0,0,0,0,0],this.state=[1634760805,857760878,2036477234,1797285236,e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],0,0,0,0],this.idx=16,this.buff=new Array(16)}nextU32(){return this.idx==16&&this.update(),this.buff[this.idx++]}nextU64(){return os(jF(this.nextU32(),4294967296),this.nextU32())}nextBool(){return(this.nextU32()&1)==1}update(){for(let e=0;e<16;e++)this.buff[e]=this.state[e];for(let e=0;e<10;e++)Qwe(this.buff);for(let e=0;e<16;e++)this.buff[e]=this.buff[e]+this.state[e]>>>0;this.idx=0,this.state[12]=this.state[12]+1>>>0,this.state[12]==0&&(this.state[13]=this.state[13]+1>>>0,this.state[13]==0&&(this.state[14]=this.state[14]+1>>>0,this.state[14]==0&&(this.state[15]=this.state[15]+1>>>0)))}};_3();function _ae(c){let e=new Uint8Array(c);if(process.browser)if(typeof globalThis.crypto<"u")globalThis.crypto.getRandomValues(e);else for(let a=0;a<c;a++)e[a]=Math.random()*4294967296>>>0;else o1.randomFillSync(e);return e}function Wwe(){let c=_ae(32),e=new Uint32Array(c.buffer),a=[];for(let f=0;f<8;f++)a.push(e[f]);return a}var Sg=null;function Yt(){return Sg||(Sg=new b3(Wwe()),Sg)}s();x();s();x();s();x();s();x();s();x();var Lae=Fe(E3(),1);s();x();s();x();var Ig={};v0(Ig,{array2buffer:()=>us,beBuff2int:()=>Zwe,beInt2Buff:()=>Ywe,bitReverse:()=>Aae,buffReverseBits:()=>YF,buffer2array:()=>Xt,leBuff2int:()=>Xwe,leInt2Buff:()=>ZF,log2:()=>Mf,stringifyBigInts:()=>KF,stringifyFElements:()=>WF,unstringifyBigInts:()=>QF,unstringifyFElements:()=>JF});s();x();function KF(c){if(typeof c=="bigint"||c.eq!==void 0)return c.toString(10);if(c instanceof Uint8Array)return t5(c,0);if(Array.isArray(c))return c.map(KF);if(typeof c=="object"){let e={};return Object.keys(c).forEach(f=>{e[f]=KF(c[f])}),e}else return c}function QF(c){if(typeof c=="string"&&/^[0-9]+$/.test(c))return BigInt(c);if(typeof c=="string"&&/^0x[0-9a-fA-F]+$/.test(c))return BigInt(c);if(Array.isArray(c))return c.map(QF);if(typeof c=="object"){if(c===null)return null;let e={};return Object.keys(c).forEach(f=>{e[f]=QF(c[f])}),e}else return c}function Zwe(c){let e=BigInt(0),a=c.length,f=0,d=new DataView(c.buffer,c.byteOffset,c.byteLength);for(;a>0;)a>=4?(a-=4,e+=BigInt(d.getUint32(a))<<BigInt(f*8),f+=4):a>=2?(a-=2,e+=BigInt(d.getUint16(a))<<BigInt(f*8),f+=2):(a-=1,e+=BigInt(d.getUint8(a))<<BigInt(f*8),f+=1);return e}function Ywe(c,e){let a=c,f=new Uint8Array(e),d=new DataView(f.buffer),b=e;for(;b>0;)b-4>=0?(b-=4,d.setUint32(b,Number(a&BigInt(4294967295))),a=a>>BigInt(32)):b-2>=0?(b-=2,d.setUint16(b,Number(a&BigInt(65535))),a=a>>BigInt(16)):(b-=1,d.setUint8(b,Number(a&BigInt(255))),a=a>>BigInt(8));if(a)throw new Error("Number does not fit in this length");return f}function Xwe(c){let e=BigInt(0),a=0,f=new DataView(c.buffer,c.byteOffset,c.byteLength);for(;a<c.length;)a+4<=c.length?(e+=BigInt(f.getUint32(a,!0))<<BigInt(a*8),a+=4):a+4<=c.length?(e+=BigInt(f.getUint16(a,!0))<<BigInt(a*8),a+=2):(e+=BigInt(f.getUint8(a,!0))<<BigInt(a*8),a+=1);return e}function ZF(c,e){let a=c;typeof e>"u"&&(e=Math.floor((d5(c)-1)/8)+1,e==0&&(e=1));let f=new Uint8Array(e),d=new DataView(f.buffer),b=0;for(;b<e;)b+4<=e?(d.setUint32(b,Number(a&BigInt(4294967295)),!0),b+=4,a=a>>BigInt(32)):b+2<=e?(d.setUint16(Number(b,a&BigInt(65535)),!0),b+=2,a=a>>BigInt(16)):(d.setUint8(Number(b,a&BigInt(255)),!0),b+=1,a=a>>BigInt(8));if(a)throw new Error("Number does not fit in this length");return f}function WF(c,e){if(typeof e=="bigint"||e.eq!==void 0)return e.toString(10);if(e instanceof Uint8Array)return c.toString(c.e(e));if(Array.isArray(e))return e.map(WF.bind(this,c));if(typeof e=="object"){let a={};return Object.keys(e).forEach(d=>{a[d]=WF(c,e[d])}),a}else return e}function JF(c,e){if(typeof e=="string"&&/^[0-9]+$/.test(e))return c.e(e);if(typeof e=="string"&&/^0x[0-9a-fA-F]+$/.test(e))return c.e(e);if(Array.isArray(e))return e.map(JF.bind(this,c));if(typeof e=="object"){if(e===null)return null;let a={};return Object.keys(e).forEach(d=>{a[d]=JF(c,e[d])}),a}else return e}var ls=[];for(let c=0;c<256;c++)ls[c]=e_e(c,8);function e_e(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}function Aae(c,e){return(ls[c>>>24]|ls[c>>>16&255]<<8|ls[c>>>8&255]<<16|ls[c&255]<<24)>>>32-e}function Mf(c){return((c&4294901760)!==0?(c&=4294901760,16):0)|((c&4278255360)!==0?(c&=4278255360,8):0)|((c&4042322160)!==0?(c&=4042322160,4):0)|((c&3435973836)!==0?(c&=3435973836,2):0)|(c&2863311530)!==0}function YF(c,e){let a=c.byteLength/e,f=Mf(a);if(a!=1<<f)throw new Error("Invalid number of pointers");for(let d=0;d<a;d++){let b=Aae(d,f);if(d>b){let t=c.slice(d*e,(d+1)*e);c.set(c.slice(b*e,(b+1)*e),d*e),c.set(t,b*e)}}}function us(c,e){let a=new Uint8Array(e*c.length);for(let f=0;f<c.length;f++)a.set(c[f],f*e);return a}function Xt(c,e){let a=c.byteLength/e,f=new Array(a);for(let d=0;d<a;d++)f[d]=c.slice(d*e,d*e+e);return f}s();x();s();x();var I0=class{constructor(e){this.buffers=[],this.byteLength=e;for(let a=0;a<e;a+=1073741824){let f=Math.min(e-a,1073741824);this.buffers.push(new Uint8Array(f))}}slice(e,a){a===void 0&&(a=this.byteLength),e===void 0&&(e=0);let f=a-e,d=Math.floor(e/1073741824),b=Math.floor((e+f-1)/1073741824);if(d==b||f==0)return this.buffers[d].slice(e%1073741824,e%1073741824+f);let t,r=d,o=e%1073741824,n=f;for(;n>0;){let i=o+n>1073741824?1073741824-o:n,l=new Uint8Array(this.buffers[r].buffer,this.buffers[r].byteOffset+o,i);if(i==f)return l.slice();t||(f<=1073741824?t=new Uint8Array(f):t=new I0(f)),t.set(l,f-n),n=n-i,r++,o=0}return t}set(e,a){a===void 0&&(a=0);let f=e.byteLength;if(f==0)return;let d=Math.floor(a/1073741824),b=Math.floor((a+f-1)/1073741824);if(d==b)return e instanceof I0&&e.buffers.length==1?this.buffers[d].set(e.buffers[0],a%1073741824):this.buffers[d].set(e,a%1073741824);let t=d,r=a%1073741824,o=f;for(;o>0;){let n=r+o>1073741824?1073741824-r:o,i=e.slice(f-o,f-o+n);new Uint8Array(this.buffers[t].buffer,this.buffers[t].byteOffset+r,n).set(i),o=o-n,t++,r=0}}};function J1(c,e,a,f){return async function(b){let t=Math.floor(b.byteLength/a);if(t*a!==b.byteLength)throw new Error("Invalid buffer size");let r=Math.floor(t/c.concurrency),o=[];for(let h=0;h<c.concurrency;h++){let u;if(h<c.concurrency-1?u=r:u=t-h*r,u==0)continue;let E=[{cmd:"ALLOCSET",var:0,buff:b.slice(h*r*a,h*r*a+u*a)},{cmd:"ALLOC",var:1,len:f*u},{cmd:"CALL",fnName:e,params:[{var:0},{val:u},{var:1}]},{cmd:"GET",out:0,var:1,len:f*u}];o.push(c.queueAction(E))}let n=await Promise.all(o),i;b instanceof I0?i=new I0(t*f):i=new Uint8Array(t*f);let l=0;for(let h=0;h<n.length;h++)i.set(n[h][0],l),l+=n[h][0].byteLength;return i}}var er=class{constructor(e,a,f,d){if(this.tm=e,this.prefix=a,this.p=d,this.n8=f,this.type="F1",this.m=1,this.half=b5(d,Z7),this.bitLength=d5(d),this.mask=Jt(is(Z7,this.bitLength),Z7),this.pOp1=e.alloc(f),this.pOp2=e.alloc(f),this.pOp3=e.alloc(f),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,this.n8),this.tm.instance.exports[a+"_one"](this.pOp1),this.one=this.tm.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.n64=Math.floor(f/8),this.n32=Math.floor(f/4),this.n64*8!=this.n8)throw new Error("n8 must be a multiple of 8");this.half=b5(this.p,Z7),this.nqr=this.two;let b=this.exp(this.nqr,this.half);for(;!this.eq(b,this.negone);)this.nqr=this.add(this.nqr,this.one),b=this.exp(this.nqr,this.half);this.shift=this.mul(this.nqr,this.nqr),this.shiftInv=this.inv(this.shift),this.s=0;let t=Jt(this.p,Z7);for(;!_g(t);)this.s=this.s+1,t=b5(t,Z7);this.w=[],this.w[this.s]=this.exp(this.nqr,t);for(let r=this.s-1;r>=0;r--)this.w[r]=this.square(this.w[r+1]);if(!this.eq(this.w[0],this.one))throw new Error("Error calculating roots of unity");this.batchToMontgomery=J1(e,a+"_batchToMontgomery",this.n8,this.n8),this.batchFromMontgomery=J1(e,a+"_batchFromMontgomery",this.n8,this.n8)}op2(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2)}op1(e,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(e,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}add(e,a){return this.op2("_add",e,a)}eq(e,a){return this.op2Bool("_eq",e,a)}isZero(e){return this.op1Bool("_isZero",e)}sub(e,a){return this.op2("_sub",e,a)}neg(e){return this.op1("_neg",e)}inv(e){return this.op1("_inverse",e)}toMontgomery(e){return this.op1("_toMontgomery",e)}fromMontgomery(e){return this.op1("_fromMontgomery",e)}mul(e,a){return this.op2("_mul",e,a)}div(e,a){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(e){return this.op1("_square",e)}isSquare(e){return this.op1Bool("_isSquare",e)}sqrt(e){return this.op1("_sqrt",e)}exp(e,a){return a instanceof Uint8Array||(a=d3(_a(a))),this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}isNegative(e){return this.op1Bool("_isNegative",e)}e(e,a){if(e instanceof Uint8Array)return e;let f=_a(e,a);GF(f)?(f=zF(f),xs(f,this.p)&&(f=ss(f,this.p)),f=Jt(this.p,f)):xs(f,this.p)&&(f=ss(f,this.p));let d=ZF(f,this.n8);return this.toMontgomery(d)}toString(e,a){let f=this.fromMontgomery(e),d=t5(f,0);return Eg(d,a)}fromRng(e){let a,f=new Uint8Array(this.n8);do{a=VF;for(let d=0;d<this.n64;d++)a=os(a,is(e.nextU64(),64*d));a=vg(a,this.mask)}while($F(a,this.p));return Zt(f,0,a,this.n8),f}random(){return this.fromRng(Yt())}toObject(e){let a=this.fromMontgomery(e);return t5(a,0)}fromObject(e){let a=new Uint8Array(this.n8);return Zt(a,0,e,this.n8),this.toMontgomery(a)}toRprLE(e,a,f){e.set(this.fromMontgomery(f),a)}toRprBE(e,a,f){let d=this.fromMontgomery(f);for(let b=0;b<this.n8/2;b++){let t=d[b];d[b]=d[this.n8-1-b],d[this.n8-1-b]=t}e.set(d,a)}fromRprLE(e,a){a=a||0;let f=e.slice(a,a+this.n8);return this.toMontgomery(f)}async batchInverse(e){let a=!1,f=this.n8,d=this.n8;Array.isArray(e)?(e=us(e,f),a=!0):e=e.slice(0,e.byteLength);let b=Math.floor(e.byteLength/f);if(b*f!==e.byteLength)throw new Error("Invalid buffer size");let t=Math.floor(b/this.tm.concurrency),r=[];for(let l=0;l<this.tm.concurrency;l++){let h;if(l<this.tm.concurrency-1?h=t:h=b-l*t,h==0)continue;let g=[{cmd:"ALLOCSET",var:0,buff:e.slice(l*t*f,l*t*f+h*f)},{cmd:"ALLOC",var:1,len:d*h},{cmd:"CALL",fnName:this.prefix+"_batchInverse",params:[{var:0},{val:f},{val:h},{var:1},{val:d}]},{cmd:"GET",out:0,var:1,len:d*h}];r.push(this.tm.queueAction(g))}let o=await Promise.all(r),n;e instanceof I0?n=new I0(b*d):n=new Uint8Array(b*d);let i=0;for(let l=0;l<o.length;l++)n.set(o[l][0],i),i+=o[l][0].byteLength;return a?Xt(n,d):n}};s();x();var ar=class{constructor(e,a,f){this.tm=e,this.prefix=a,this.F=f,this.type="F2",this.m=f.m*2,this.n8=this.F.n8*2,this.n32=this.F.n32*2,this.n64=this.F.n64*2,this.pOp1=e.alloc(f.n8*2),this.pOp2=e.alloc(f.n8*2),this.pOp3=e.alloc(f.n8*2),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=e.getBuff(this.pOp1,this.n8),this.tm.instance.exports[a+"_one"](this.pOp1),this.one=e.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one)}op2(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2)}op1(e,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(e,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}add(e,a){return this.op2("_add",e,a)}eq(e,a){return this.op2Bool("_eq",e,a)}isZero(e){return this.op1Bool("_isZero",e)}sub(e,a){return this.op2("_sub",e,a)}neg(e){return this.op1("_neg",e)}inv(e){return this.op1("_inverse",e)}isNegative(e){return this.op1Bool("_isNegative",e)}toMontgomery(e){return this.op1("_toMontgomery",e)}fromMontgomery(e){return this.op1("_fromMontgomery",e)}mul(e,a){return this.op2("_mul",e,a)}mul1(e,a){return this.op2("_mul1",e,a)}div(e,a){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(e){return this.op1("_square",e)}isSquare(e){return this.op1Bool("_isSquare",e)}sqrt(e){return this.op1("_sqrt",e)}exp(e,a){return a instanceof Uint8Array||(a=d3(_a(a))),this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}e(e,a){if(e instanceof Uint8Array)return e;if(Array.isArray(e)&&e.length==2){let f=this.F.e(e[0],a),d=this.F.e(e[1],a),b=new Uint8Array(this.F.n8*2);return b.set(f),b.set(d,this.F.n8*2),b}else throw new Error("invalid F2")}toString(e,a){let f=this.F.toString(e.slice(0,this.F.n8),a),d=this.F.toString(e.slice(this.F.n8),a);return`[${f}, ${d}]`}fromRng(e){let a=this.F.fromRng(e),f=this.F.fromRng(e),d=new Uint8Array(this.F.n8*2);return d.set(a),d.set(f,this.F.n8),d}random(){return this.fromRng(Yt())}toObject(e){let a=this.F.toObject(e.slice(0,this.F.n8)),f=this.F.toObject(e.slice(this.F.n8,this.F.n8*2));return[a,f]}fromObject(e){let a=new Uint8Array(this.F.n8*2),f=this.F.fromObject(e[0]),d=this.F.fromObject(e[1]);return a.set(f),a.set(d,this.F.n8),a}c1(e){return e.slice(0,this.F.n8)}c2(e){return e.slice(this.F.n8)}};s();x();var hs=class{constructor(e,a,f){this.tm=e,this.prefix=a,this.F=f,this.type="F3",this.m=f.m*3,this.n8=this.F.n8*3,this.n32=this.F.n32*3,this.n64=this.F.n64*3,this.pOp1=e.alloc(f.n8*3),this.pOp2=e.alloc(f.n8*3),this.pOp3=e.alloc(f.n8*3),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=e.getBuff(this.pOp1,this.n8),this.tm.instance.exports[a+"_one"](this.pOp1),this.one=e.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one)}op2(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2)}op1(e,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(e,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}eq(e,a){return this.op2Bool("_eq",e,a)}isZero(e){return this.op1Bool("_isZero",e)}add(e,a){return this.op2("_add",e,a)}sub(e,a){return this.op2("_sub",e,a)}neg(e){return this.op1("_neg",e)}inv(e){return this.op1("_inverse",e)}isNegative(e){return this.op1Bool("_isNegative",e)}toMontgomery(e){return this.op1("_toMontgomery",e)}fromMontgomery(e){return this.op1("_fromMontgomery",e)}mul(e,a){return this.op2("_mul",e,a)}div(e,a){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(e){return this.op1("_square",e)}isSquare(e){return this.op1Bool("_isSquare",e)}sqrt(e){return this.op1("_sqrt",e)}exp(e,a){return a instanceof Uint8Array||(a=d3(_a(a))),this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.getBuff(this.pOp3,this.n8)}e(e,a){if(e instanceof Uint8Array)return e;if(Array.isArray(e)&&e.length==3){let f=this.F.e(e[0],a),d=this.F.e(e[1],a),b=this.F.e(e[2],a),t=new Uint8Array(this.F.n8*3);return t.set(f),t.set(d,this.F.n8),t.set(b,this.F.n8*2),t}else throw new Error("invalid F3")}toString(e,a){let f=this.F.toString(e.slice(0,this.F.n8),a),d=this.F.toString(e.slice(this.F.n8,this.F.n8*2),a),b=this.F.toString(e.slice(this.F.n8*2),a);return`[${f}, ${d}, ${b}]`}fromRng(e){let a=this.F.fromRng(e),f=this.F.fromRng(e),d=this.F.fromRng(e),b=new Uint8Array(this.F.n8*3);return b.set(a),b.set(f,this.F.n8),b.set(d,this.F.n8*2),b}random(){return this.fromRng(Yt())}toObject(e){let a=this.F.toObject(e.slice(0,this.F.n8)),f=this.F.toObject(e.slice(this.F.n8,this.F.n8*2)),d=this.F.toObject(e.slice(this.F.n8*2,this.F.n8*3));return[a,f,d]}fromObject(e){let a=new Uint8Array(this.F.n8*3),f=this.F.fromObject(e[0]),d=this.F.fromObject(e[1]),b=this.F.fromObject(e[2]);return a.set(f),a.set(d,this.F.n8),a.set(b,this.F.n8*2),a}c1(e){return e.slice(0,this.F.n8)}c2(e){return e.slice(this.F.n8,this.F.n8*2)}c3(e){return e.slice(this.F.n8*2)}};s();x();var cr=class{constructor(e,a,f,d,b,t){this.tm=e,this.prefix=a,this.F=f,this.pOp1=e.alloc(f.n8*3),this.pOp2=e.alloc(f.n8*3),this.pOp3=e.alloc(f.n8*3),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,f.n8*3),this.tm.instance.exports[a+"_zeroAffine"](this.pOp1),this.zeroAffine=this.tm.getBuff(this.pOp1,f.n8*2),this.one=this.tm.getBuff(d,f.n8*3),this.g=this.one,this.oneAffine=this.tm.getBuff(d,f.n8*2),this.gAffine=this.oneAffine,this.b=this.tm.getBuff(b,f.n8),t&&(this.cofactor=d3(t)),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.batchLEMtoC=J1(e,a+"_batchLEMtoC",f.n8*2,f.n8),this.batchLEMtoU=J1(e,a+"_batchLEMtoU",f.n8*2,f.n8*2),this.batchCtoLEM=J1(e,a+"_batchCtoLEM",f.n8,f.n8*2),this.batchUtoLEM=J1(e,a+"_batchUtoLEM",f.n8*2,f.n8*2),this.batchToJacobian=J1(e,a+"_batchToJacobian",f.n8*2,f.n8*3),this.batchToAffine=J1(e,a+"_batchToAffine",f.n8*3,f.n8*2)}op2(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}op2bool(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3)}op1(e,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}op1Affine(e,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*2)}op1Bool(e,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}add(e,a){if(e.byteLength==this.F.n8*3){if(a.byteLength==this.F.n8*3)return this.op2("_add",e,a);if(a.byteLength==this.F.n8*2)return this.op2("_addMixed",e,a);throw new Error("invalid point size")}else if(e.byteLength==this.F.n8*2){if(a.byteLength==this.F.n8*3)return this.op2("_addMixed",a,e);if(a.byteLength==this.F.n8*2)return this.op2("_addAffine",e,a);throw new Error("invalid point size")}else throw new Error("invalid point size")}sub(e,a){if(e.byteLength==this.F.n8*3){if(a.byteLength==this.F.n8*3)return this.op2("_sub",e,a);if(a.byteLength==this.F.n8*2)return this.op2("_subMixed",e,a);throw new Error("invalid point size")}else if(e.byteLength==this.F.n8*2){if(a.byteLength==this.F.n8*3)return this.op2("_subMixed",a,e);if(a.byteLength==this.F.n8*2)return this.op2("_subAffine",e,a);throw new Error("invalid point size")}else throw new Error("invalid point size")}neg(e){if(e.byteLength==this.F.n8*3)return this.op1("_neg",e);if(e.byteLength==this.F.n8*2)return this.op1Affine("_negAffine",e);throw new Error("invalid point size")}double(e){if(e.byteLength==this.F.n8*3)return this.op1("_double",e);if(e.byteLength==this.F.n8*2)return this.op1("_doubleAffine",e);throw new Error("invalid point size")}isZero(e){if(e.byteLength==this.F.n8*3)return this.op1Bool("_isZero",e);if(e.byteLength==this.F.n8*2)return this.op1Bool("_isZeroAffine",e);throw new Error("invalid point size")}timesScalar(e,a){a instanceof Uint8Array||(a=d3(_a(a)));let f;if(e.byteLength==this.F.n8*3)f=this.prefix+"_timesScalar";else if(e.byteLength==this.F.n8*2)f=this.prefix+"_timesScalarAffine";else throw new Error("invalid point size");return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[f](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}timesFr(e,a){let f;if(e.byteLength==this.F.n8*3)f=this.prefix+"_timesFr";else if(e.byteLength==this.F.n8*2)f=this.prefix+"_timesFrAffine";else throw new Error("invalid point size");return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[f](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}eq(e,a){if(e.byteLength==this.F.n8*3){if(a.byteLength==this.F.n8*3)return this.op2bool("_eq",e,a);if(a.byteLength==this.F.n8*2)return this.op2bool("_eqMixed",e,a);throw new Error("invalid point size")}else if(e.byteLength==this.F.n8*2){if(a.byteLength==this.F.n8*3)return this.op2bool("_eqMixed",a,e);if(a.byteLength==this.F.n8*2)return this.op2bool("_eqAffine",e,a);throw new Error("invalid point size")}else throw new Error("invalid point size")}toAffine(e){if(e.byteLength==this.F.n8*3)return this.op1Affine("_toAffine",e);if(e.byteLength==this.F.n8*2)return e;throw new Error("invalid point size")}toJacobian(e){if(e.byteLength==this.F.n8*3)return e;if(e.byteLength==this.F.n8*2)return this.op1("_toJacobian",e);throw new Error("invalid point size")}toRprUncompressed(e,a,f){if(this.tm.setBuff(this.pOp1,f),f.byteLength==this.F.n8*3)this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);else if(f.byteLength!=this.F.n8*2)throw new Error("invalid point size");this.tm.instance.exports[this.prefix+"_LEMtoU"](this.pOp1,this.pOp1);let d=this.tm.getBuff(this.pOp1,this.F.n8*2);e.set(d,a)}fromRprUncompressed(e,a){let f=e.slice(a,a+this.F.n8*2);return this.tm.setBuff(this.pOp1,f),this.tm.instance.exports[this.prefix+"_UtoLEM"](this.pOp1,this.pOp1),this.tm.getBuff(this.pOp1,this.F.n8*2)}toRprCompressed(e,a,f){if(this.tm.setBuff(this.pOp1,f),f.byteLength==this.F.n8*3)this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);else if(f.byteLength!=this.F.n8*2)throw new Error("invalid point size");this.tm.instance.exports[this.prefix+"_LEMtoC"](this.pOp1,this.pOp1);let d=this.tm.getBuff(this.pOp1,this.F.n8);e.set(d,a)}fromRprCompressed(e,a){let f=e.slice(a,a+this.F.n8);return this.tm.setBuff(this.pOp1,f),this.tm.instance.exports[this.prefix+"_CtoLEM"](this.pOp1,this.pOp2),this.tm.getBuff(this.pOp2,this.F.n8*2)}toUncompressed(e){let a=new Uint8Array(this.F.n8*2);return this.toRprUncompressed(a,0,e),a}toRprLEM(e,a,f){if(f.byteLength==this.F.n8*2){e.set(f,a);return}else if(f.byteLength==this.F.n8*3){this.tm.setBuff(this.pOp1,f),this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);let d=this.tm.getBuff(this.pOp1,this.F.n8*2);e.set(d,a)}else throw new Error("invalid point size")}fromRprLEM(e,a){return a=a||0,e.slice(a,a+this.F.n8*2)}toString(e,a){if(e.byteLength==this.F.n8*3){let f=this.F.toString(e.slice(0,this.F.n8),a),d=this.F.toString(e.slice(this.F.n8,this.F.n8*2),a),b=this.F.toString(e.slice(this.F.n8*2),a);return`[ ${f}, ${d}, ${b} ]`}else if(e.byteLength==this.F.n8*2){let f=this.F.toString(e.slice(0,this.F.n8),a),d=this.F.toString(e.slice(this.F.n8),a);return`[ ${f}, ${d} ]`}else throw new Error("invalid point size")}isValid(e){if(this.isZero(e))return!0;let a=this.F,f=this.toAffine(e),d=f.slice(0,this.F.n8),b=f.slice(this.F.n8,this.F.n8*2),t=a.add(a.mul(a.square(d),d),this.b),r=a.square(b);return a.eq(t,r)}fromRng(e){let a=this.F,f=[],d,b;do f[0]=a.fromRng(e),d=e.nextBool(),b=a.add(a.mul(a.square(f[0]),f[0]),this.b);while(!a.isSquare(b));f[1]=a.sqrt(b);let t=a.isNegative(f[1]);d^t&&(f[1]=a.neg(f[1]));let r=new Uint8Array(this.F.n8*2);return r.set(f[0]),r.set(f[1],this.F.n8),this.cofactor&&(r=this.timesScalar(r,this.cofactor)),r}toObject(e){if(this.isZero(e))return[this.F.toObject(this.F.zero),this.F.toObject(this.F.one),this.F.toObject(this.F.zero)];let a=this.F.toObject(e.slice(0,this.F.n8)),f=this.F.toObject(e.slice(this.F.n8,this.F.n8*2)),d;return e.byteLength==this.F.n8*3?d=this.F.toObject(e.slice(this.F.n8*2,this.F.n8*3)):d=this.F.toObject(this.F.one),[a,f,d]}fromObject(e){let a=this.F.fromObject(e[0]),f=this.F.fromObject(e[1]),d;if(e.length==3?d=this.F.fromObject(e[2]):d=this.F.one,this.F.isZero(d,this.F.one))return this.zeroAffine;if(this.F.eq(d,this.F.one)){let b=new Uint8Array(this.F.n8*2);return b.set(a),b.set(f,this.F.n8),b}else{let b=new Uint8Array(this.F.n8*3);return b.set(a),b.set(f,this.F.n8),b.set(d,this.F.n8*2),b}}e(e){return e instanceof Uint8Array?e:this.fromObject(e)}x(e){return this.toAffine(e).slice(0,this.F.n8)}y(e){return this.toAffine(e).slice(this.F.n8)}};s();x();s();x();function Lg(c){let a,f;c&&(c.onmessage=function(i){let l;if(i.data?l=i.data:l=i,l[0].cmd=="INIT")d(l[0]).then(function(){c.postMessage(l.result)});else if(l[0].cmd=="TERMINATE")c.close();else{let h=n(l);c.postMessage(h)}});async function d(i){let l=new Uint8Array(i.code),h=await WebAssembly.compile(l);f=new WebAssembly.Memory({initial:i.init,maximum:32767}),a=await WebAssembly.instantiate(h,{env:{memory:f}})}function b(i){let l=new Uint32Array(f.buffer,0,1);for(;l[0]&3;)l[0]++;let h=l[0];if(l[0]+=i,l[0]+i>f.buffer.byteLength){let u=f.buffer.byteLength/65536,g=Math.floor((l[0]+i)/65536)+1;g>32767&&(g=32767),f.grow(g-u)}return h}function t(i){let l=b(i.byteLength);return o(l,i),l}function r(i,l){let h=new Uint8Array(f.buffer);return new Uint8Array(h.buffer,h.byteOffset+i,l)}function o(i,l){new Uint8Array(f.buffer).set(new Uint8Array(l),i)}function n(i){if(i[0].cmd=="INIT")return d(i[0]);let l={vars:[],out:[]},u=new Uint32Array(f.buffer,0,1)[0];for(let E=0;E<i.length;E++)switch(i[E].cmd){case"ALLOCSET":l.vars[i[E].var]=t(i[E].buff);break;case"ALLOC":l.vars[i[E].var]=b(i[E].len);break;case"SET":o(l.vars[i[E].var],i[E].buff);break;case"CALL":{let _=[];for(let F=0;F<i[E].params.length;F++){let L=i[E].params[F];typeof L.var<"u"?_.push(l.vars[L.var]+(L.offset||0)):typeof L.val<"u"&&_.push(L.val)}a.exports[i[E].fnName](..._);break}case"GET":l.out[i[E].out]=r(l.vars[i[E].var],i[E].len).slice();break;default:throw new Error("Invalid cmd")}let g=new Uint32Array(f.buffer,0,1);return g[0]=u,l.out}return n}var Sae=Fe(Wr(),1),XF=25,Fg=class{constructor(){this.promise=new Promise((e,a)=>{this.reject=a,this.resolve=e})}};function a_e(c){return new Promise(e=>setTimeout(e,c))}function c_e(c){return process.browser?globalThis.btoa(c):Buffer.from(c).toString("base64")}var f_e=c_e("("+Lg.toString()+")(self)"),d_e="data:application/javascript;base64,"+f_e;async function aC(c,e){let a=new eC;a.memory=new WebAssembly.Memory({initial:XF}),a.u8=new Uint8Array(a.memory.buffer),a.u32=new Uint32Array(a.memory.buffer);let f=await WebAssembly.compile(c.code);if(a.instance=await WebAssembly.instantiate(f,{env:{memory:a.memory}}),a.singleThread=e,a.initalPFree=a.u32[0],a.pq=c.pq,a.pr=c.pr,a.pG1gen=c.pG1gen,a.pG1zero=c.pG1zero,a.pG2gen=c.pG2gen,a.pG2zero=c.pG2zero,a.pOneT=c.pOneT,e)a.code=c.code,a.taskManager=Lg(),await a.taskManager([{cmd:"INIT",init:XF,code:a.code.slice()}]),a.concurrency=1;else{a.workers=[],a.pendingDeferreds=[],a.working=[];let b;typeof navigator=="object"&&navigator.hardwareConcurrency?b=navigator.hardwareConcurrency:b=j5.cpus().length,b==0&&(b=2),b>64&&(b=64),a.concurrency=b;for(let r=0;r<b;r++)a.workers[r]=new Sae.default(d_e),a.workers[r].addEventListener("message",d(r)),a.working[r]=!1;let t=[];for(let r=0;r<a.workers.length;r++){let o=c.code.slice();t.push(a.postAction(r,[{cmd:"INIT",init:XF,code:o}],[o.buffer]))}await Promise.all(t)}return a;function d(b){return function(t){let r;t&&t.data?r=t.data:r=t,a.working[b]=!1,a.pendingDeferreds[b].resolve(r),a.processWorks()}}}var eC=class{constructor(){this.actionQueue=[],this.oldPFree=0}startSyncOp(){if(this.oldPFree!=0)throw new Error("Sync operation in progress");this.oldPFree=this.u32[0]}endSyncOp(){if(this.oldPFree==0)throw new Error("No sync operation in progress");this.u32[0]=this.oldPFree,this.oldPFree=0}postAction(e,a,f,d){if(this.working[e])throw new Error("Posting a job t a working worker");return this.working[e]=!0,this.pendingDeferreds[e]=d||new Fg,this.workers[e].postMessage(a,f),this.pendingDeferreds[e].promise}processWorks(){for(let e=0;e<this.workers.length&&this.actionQueue.length>0;e++)if(this.working[e]==!1){let a=this.actionQueue.shift();this.postAction(e,a.data,a.transfers,a.deferred)}}queueAction(e,a){let f=new Fg;if(this.singleThread){let d=this.taskManager(e);f.resolve(d)}else this.actionQueue.push({data:e,transfers:a,deferred:f}),this.processWorks();return f.promise}resetMemory(){this.u32[0]=this.initalPFree}allocBuff(e){let a=this.alloc(e.byteLength);return this.setBuff(a,e),a}getBuff(e,a){return this.u8.slice(e,e+a)}setBuff(e,a){this.u8.set(new Uint8Array(a),e)}alloc(e){for(;this.u32[0]&3;)this.u32[0]++;let a=this.u32[0];return this.u32[0]+=e,a}async terminate(){for(let e=0;e<this.workers.length;e++)this.workers[e].postMessage([{cmd:"TERMINATE"}]);await a_e(200)}};s();x();function ps(c,e){let a=c[e],f=c.Fr,d=c.tm;c[e].batchApplyKey=async function(b,t,r,o,n){o=o||"affine",n=n||"affine";let i,l,h,u,g;if(e=="G1")o=="jacobian"?(h=a.F.n8*3,i="g1m_batchApplyKey"):(h=a.F.n8*2,i="g1m_batchApplyKeyMixed"),u=a.F.n8*3,n=="jacobian"?g=a.F.n8*3:(l="g1m_batchToAffine",g=a.F.n8*2);else if(e=="G2")o=="jacobian"?(h=a.F.n8*3,i="g2m_batchApplyKey"):(h=a.F.n8*2,i="g2m_batchApplyKeyMixed"),u=a.F.n8*3,n=="jacobian"?g=a.F.n8*3:(l="g2m_batchToAffine",g=a.F.n8*2);else if(e=="Fr")i="frm_batchApplyKey",h=a.n8,u=a.n8,g=a.n8;else throw new Error("Invalid group: "+e);let E=Math.floor(b.byteLength/h),_=Math.floor(E/d.concurrency),F=[];r=f.e(r);let L=f.e(t);for(let P=0;P<d.concurrency;P++){let A;if(P<d.concurrency-1?A=_:A=E-P*_,A==0)continue;let I=[];I.push({cmd:"ALLOCSET",var:0,buff:b.slice(P*_*h,P*_*h+A*h)}),I.push({cmd:"ALLOCSET",var:1,buff:L}),I.push({cmd:"ALLOCSET",var:2,buff:r}),I.push({cmd:"ALLOC",var:3,len:A*Math.max(u,g)}),I.push({cmd:"CALL",fnName:i,params:[{var:0},{val:A},{var:1},{var:2},{var:3}]}),l&&I.push({cmd:"CALL",fnName:l,params:[{var:3},{val:A},{var:3}]}),I.push({cmd:"GET",out:0,var:3,len:A*g}),F.push(d.queueAction(I)),L=f.mul(L,f.exp(r,A))}let U=await Promise.all(F),O;b instanceof I0?O=new I0(E*g):O=new Uint8Array(E*g);let H=0;for(let P=0;P<U.length;P++)O.set(U[P][0],H),H+=U[P][0].byteLength;return O}}s();x();function cC(c){let e=c.tm;c.pairing=function(f,d){e.startSyncOp();let b=e.allocBuff(c.G1.toJacobian(f)),t=e.allocBuff(c.G2.toJacobian(d)),r=e.alloc(c.Gt.n8);e.instance.exports[c.name+"_pairing"](b,t,r);let o=e.getBuff(r,c.Gt.n8);return e.endSyncOp(),o},c.pairingEq=async function(){let f,d;arguments.length%2==1?(f=arguments[arguments.length-1],d=(arguments.length-1)/2):(f=c.Gt.one,d=arguments.length/2);let b=[];for(let i=0;i<d;i++){let l=[],h=c.G1.toJacobian(arguments[i*2]);l.push({cmd:"ALLOCSET",var:0,buff:h}),l.push({cmd:"ALLOC",var:1,len:c.prePSize});let u=c.G2.toJacobian(arguments[i*2+1]);l.push({cmd:"ALLOCSET",var:2,buff:u}),l.push({cmd:"ALLOC",var:3,len:c.preQSize}),l.push({cmd:"ALLOC",var:4,len:c.Gt.n8}),l.push({cmd:"CALL",fnName:c.name+"_prepareG1",params:[{var:0},{var:1}]}),l.push({cmd:"CALL",fnName:c.name+"_prepareG2",params:[{var:2},{var:3}]}),l.push({cmd:"CALL",fnName:c.name+"_millerLoop",params:[{var:1},{var:3},{var:4}]}),l.push({cmd:"GET",out:0,var:4,len:c.Gt.n8}),b.push(e.queueAction(l))}let t=await Promise.all(b);e.startSyncOp();let r=e.alloc(c.Gt.n8);e.instance.exports.ftm_one(r);for(let i=0;i<t.length;i++){let l=e.allocBuff(t[i][0]);e.instance.exports.ftm_mul(r,l,r)}e.instance.exports[c.name+"_finalExponentiation"](r,r);let o=e.allocBuff(f),n=!!e.instance.exports.ftm_eq(r,o);return e.endSyncOp(),n},c.prepareG1=function(a){this.tm.startSyncOp();let f=this.tm.allocBuff(a),d=this.tm.alloc(this.prePSize);this.tm.instance.exports[this.name+"_prepareG1"](f,d);let b=this.tm.getBuff(d,this.prePSize);return this.tm.endSyncOp(),b},c.prepareG2=function(a){this.tm.startSyncOp();let f=this.tm.allocBuff(a),d=this.tm.alloc(this.preQSize);this.tm.instance.exports[this.name+"_prepareG2"](f,d);let b=this.tm.getBuff(d,this.preQSize);return this.tm.endSyncOp(),b},c.millerLoop=function(a,f){this.tm.startSyncOp();let d=this.tm.allocBuff(a),b=this.tm.allocBuff(f),t=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+"_millerLoop"](d,b,t);let r=this.tm.getBuff(t,this.Gt.n8);return this.tm.endSyncOp(),r},c.finalExponentiation=function(a){this.tm.startSyncOp();let f=this.tm.allocBuff(a),d=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+"_finalExponentiation"](f,d);let b=this.tm.getBuff(d,this.Gt.n8);return this.tm.endSyncOp(),b}}s();x();var Iae=[1,1,1,1,2,3,4,5,6,7,7,8,9,10,11,12,13,13,14,15,16,16,17,17,17,17,17,17,17,17,17,17];function Cg(c,e){let a=c[e],f=a.tm;async function d(t,r,o,n,i){if(!(t instanceof Uint8Array))throw n&&n.error(`${i} _multiExpChunk buffBases is not Uint8Array`),new Error(`${i} _multiExpChunk buffBases is not Uint8Array`);if(!(r instanceof Uint8Array))throw n&&n.error(`${i} _multiExpChunk buffScalars is not Uint8Array`),new Error(`${i} _multiExpChunk buffScalars is not Uint8Array`);o=o||"affine";let l,h;if(e=="G1")o=="affine"?(h="g1m_multiexpAffine_chunk",l=a.F.n8*2):(h="g1m_multiexp_chunk",l=a.F.n8*3);else if(e=="G2")o=="affine"?(h="g2m_multiexpAffine_chunk",l=a.F.n8*2):(h="g2m_multiexp_chunk",l=a.F.n8*3);else throw new Error("Invalid group");let u=Math.floor(t.byteLength/l);if(u==0)return a.zero;let g=Math.floor(r.byteLength/u);if(g*u!=r.byteLength)throw new Error("Scalar size does not match");let E=Iae[Mf(u)],_=Math.floor((g*8-1)/E)+1,F=[];for(let O=0;O<_;O++){let H=[{cmd:"ALLOCSET",var:0,buff:t},{cmd:"ALLOCSET",var:1,buff:r},{cmd:"ALLOC",var:2,len:a.F.n8*3},{cmd:"CALL",fnName:h,params:[{var:0},{var:1},{val:g},{val:u},{val:O*E},{val:Math.min(g*8-O*E,E)},{var:2}]},{cmd:"GET",out:0,var:2,len:a.F.n8*3}];F.push(a.tm.queueAction(H))}let L=await Promise.all(F),U=a.zero;for(let O=L.length-1;O>=0;O--){if(!a.isZero(U))for(let H=0;H<E;H++)U=a.double(U);U=a.add(U,L[O][0])}return U}async function b(t,r,o,n,i){let u;if(e=="G1")o=="affine"?u=a.F.n8*2:u=a.F.n8*3;else if(e=="G2")o=="affine"?u=a.F.n8*2:u=a.F.n8*3;else throw new Error("Invalid group");let g=Math.floor(t.byteLength/u),E=Math.floor(r.byteLength/g);if(E*g!=r.byteLength)throw new Error("Scalar size does not match");let _=Iae[Mf(g)],F=Math.floor((E*8-1)/_)+1,L;L=Math.floor(g/(f.concurrency/F)),L>4194304&&(L=4194304),L<1024&&(L=1024);let U=[];for(let P=0;P<g;P+=L){n&&n.debug(`Multiexp start: ${i}: ${P}/${g}`);let A=Math.min(g-P,L),I=t.slice(P*u,(P+A)*u),K=r.slice(P*E,(P+A)*E);U.push(d(I,K,o,n,i).then(j=>(n&&n.debug(`Multiexp end: ${i}: ${P}/${g}`),j)))}let O=await Promise.all(U),H=a.zero;for(let P=O.length-1;P>=0;P--)H=a.add(H,O[P]);return H}a.multiExp=async function(r,o,n,i){return await b(r,o,"jacobian",n,i)},a.multiExpAffine=async function(r,o,n,i){return await b(r,o,"affine",n,i)}}s();x();function ms(c,e){let a=c[e],f=c.Fr,d=a.tm;async function b(n,i,l,h,u,g){l=l||"affine",h=h||"affine";let E=14,_,F,L,U,O,H,P,A;e=="G1"?(l=="affine"?(_=a.F.n8*2,U="g1m_batchToJacobian"):_=a.F.n8*3,F=a.F.n8*3,i&&(A="g1m_fftFinal"),P="g1m_fftJoin",H="g1m_fftMix",h=="affine"?(L=a.F.n8*2,O="g1m_batchToAffine"):L=a.F.n8*3):e=="G2"?(l=="affine"?(_=a.F.n8*2,U="g2m_batchToJacobian"):_=a.F.n8*3,F=a.F.n8*3,i&&(A="g2m_fftFinal"),P="g2m_fftJoin",H="g2m_fftMix",h=="affine"?(L=a.F.n8*2,O="g2m_batchToAffine"):L=a.F.n8*3):e=="Fr"&&(_=a.n8,F=a.n8,L=a.n8,i&&(A="frm_fftFinal"),H="frm_fftMix",P="frm_fftJoin");let I=!1;Array.isArray(n)?(n=us(n,_),I=!0):n=n.slice(0,n.byteLength);let K=n.byteLength/_,j=Mf(K);if(1<<j!=K)throw new Error("fft must be multiple of 2");if(j==f.s+1){let M;return i?M=await r(n,l,h,u,g):M=await t(n,l,h,u,g),I?Xt(M,L):M}let J;i&&(J=f.inv(f.e(K)));let V;YF(n,_);let S,y=Math.min(1<<E,K),R=K/y;for(;R<d.concurrency&&y>=16;)R*=2,y/=2;let k=Mf(y),D=[];for(let M=0;M<R;M++){u&&u.debug(`${g}: fft ${j} mix start: ${M}/${R}`);let N=[];N.push({cmd:"ALLOC",var:0,len:F*y});let q=n.slice(y*M*_,y*(M+1)*_);N.push({cmd:"SET",var:0,buff:q}),U&&N.push({cmd:"CALL",fnName:U,params:[{var:0},{val:y},{var:0}]});for(let G=1;G<=k;G++)N.push({cmd:"CALL",fnName:H,params:[{var:0},{val:y},{val:G}]});k==j?(A&&(N.push({cmd:"ALLOCSET",var:1,buff:J}),N.push({cmd:"CALL",fnName:A,params:[{var:0},{val:y},{var:1}]})),O&&N.push({cmd:"CALL",fnName:O,params:[{var:0},{val:y},{var:0}]}),N.push({cmd:"GET",out:0,var:0,len:y*L})):N.push({cmd:"GET",out:0,var:0,len:F*y}),D.push(d.queueAction(N).then(G=>(u&&u.debug(`${g}: fft ${j} mix end: ${M}/${R}`),G)))}S=await Promise.all(D);for(let M=0;M<R;M++)S[M]=S[M][0];for(let M=k+1;M<=j;M++){u&&u.debug(`${g}: fft ${j} join: ${M}/${j}`);let N=1<<j-M,q=R/N,G=[];for(let z=0;z<N;z++)for(let de=0;de<q/2;de++){let w=f.exp(f.w[M],de*y),p=f.w[M],T=z*q+de,v=z*q+de+q/2,W=[];W.push({cmd:"ALLOCSET",var:0,buff:S[T]}),W.push({cmd:"ALLOCSET",var:1,buff:S[v]}),W.push({cmd:"ALLOCSET",var:2,buff:w}),W.push({cmd:"ALLOCSET",var:3,buff:p}),W.push({cmd:"CALL",fnName:P,params:[{var:0},{var:1},{val:y},{var:2},{var:3}]}),M==j?(A&&(W.push({cmd:"ALLOCSET",var:4,buff:J}),W.push({cmd:"CALL",fnName:A,params:[{var:0},{val:y},{var:4}]}),W.push({cmd:"CALL",fnName:A,params:[{var:1},{val:y},{var:4}]})),O&&(W.push({cmd:"CALL",fnName:O,params:[{var:0},{val:y},{var:0}]}),W.push({cmd:"CALL",fnName:O,params:[{var:1},{val:y},{var:1}]})),W.push({cmd:"GET",out:0,var:0,len:y*L}),W.push({cmd:"GET",out:1,var:1,len:y*L})):(W.push({cmd:"GET",out:0,var:0,len:y*F}),W.push({cmd:"GET",out:1,var:1,len:y*F})),G.push(d.queueAction(W).then($=>(u&&u.debug(`${g}: fft ${j} join ${M}/${j} ${z+1}/${N} ${de}/${q/2}`),$)))}let C=await Promise.all(G);for(let z=0;z<N;z++)for(let de=0;de<q/2;de++){let w=z*q+de,p=z*q+de+q/2,T=C.shift();S[w]=T[0],S[p]=T[1]}}if(n instanceof I0?V=new I0(K*L):V=new Uint8Array(K*L),i){V.set(S[0].slice((y-1)*L));let M=L;for(let N=R-1;N>0;N--)V.set(S[N],M),M+=y*L,delete S[N];V.set(S[0].slice(0,(y-1)*L),M),delete S[0]}else for(let M=0;M<R;M++)V.set(S[M],y*L*M),delete S[M];return I?Xt(V,L):V}async function t(n,i,l,h,u){let g,E;g=n.slice(0,n.byteLength/2),E=n.slice(n.byteLength/2,n.byteLength);let _=[];[g,E]=await o(g,E,"fftJoinExt",f.one,f.shift,i,"jacobian",h,u),_.push(b(g,!1,"jacobian",l,h,u)),_.push(b(E,!1,"jacobian",l,h,u));let F=await Promise.all(_),L;return F[0].byteLength>1<<28?L=new I0(F[0].byteLength*2):L=new Uint8Array(F[0].byteLength*2),L.set(F[0]),L.set(F[1],F[0].byteLength),L}async function r(n,i,l,h,u){let g,E;g=n.slice(0,n.byteLength/2),E=n.slice(n.byteLength/2,n.byteLength);let _=[];_.push(b(g,!0,i,"jacobian",h,u)),_.push(b(E,!0,i,"jacobian",h,u)),[g,E]=await Promise.all(_);let F=await o(g,E,"fftJoinExtInv",f.one,f.shiftInv,"jacobian",l,h,u),L;return F[0].byteLength>1<<28?L=new I0(F[0].byteLength*2):L=new Uint8Array(F[0].byteLength*2),L.set(F[0]),L.set(F[1],F[0].byteLength),L}async function o(n,i,l,h,u,g,E,_,F){let O,H,P,A,I,K;if(e=="G1")g=="affine"?(I=a.F.n8*2,H="g1m_batchToJacobian"):I=a.F.n8*3,K=a.F.n8*3,O="g1m_"+l,E=="affine"?(P="g1m_batchToAffine",A=a.F.n8*2):A=a.F.n8*3;else if(e=="G2")g=="affine"?(I=a.F.n8*2,H="g2m_batchToJacobian"):I=a.F.n8*3,O="g2m_"+l,K=a.F.n8*3,E=="affine"?(P="g2m_batchToAffine",A=a.F.n8*2):A=a.F.n8*3;else if(e=="Fr")I=f.n8,A=f.n8,K=f.n8,O="frm_"+l;else throw new Error("Invalid group");if(n.byteLength!=i.byteLength)throw new Error("Invalid buffer size");let j=Math.floor(n.byteLength/I);if(j!=1<<Mf(j))throw new Error("Invalid number of points");let J=Math.floor(j/d.concurrency);J<16&&(J=16),J>65536&&(J=65536);let V=[];for(let D=0;D<j;D+=J){_&&_.debug(`${F}: fftJoinExt Start: ${D}/${j}`);let M=Math.min(j-D,J),N=f.mul(h,f.exp(u,D)),q=[],G=n.slice(D*I,(D+M)*I),C=i.slice(D*I,(D+M)*I);q.push({cmd:"ALLOC",var:0,len:K*M}),q.push({cmd:"SET",var:0,buff:G}),q.push({cmd:"ALLOC",var:1,len:K*M}),q.push({cmd:"SET",var:1,buff:C}),q.push({cmd:"ALLOCSET",var:2,buff:N}),q.push({cmd:"ALLOCSET",var:3,buff:u}),H&&(q.push({cmd:"CALL",fnName:H,params:[{var:0},{val:M},{var:0}]}),q.push({cmd:"CALL",fnName:H,params:[{var:1},{val:M},{var:1}]})),q.push({cmd:"CALL",fnName:O,params:[{var:0},{var:1},{val:M},{var:2},{var:3},{val:f.s}]}),P&&(q.push({cmd:"CALL",fnName:P,params:[{var:0},{val:M},{var:0}]}),q.push({cmd:"CALL",fnName:P,params:[{var:1},{val:M},{var:1}]})),q.push({cmd:"GET",out:0,var:0,len:M*A}),q.push({cmd:"GET",out:1,var:1,len:M*A}),V.push(d.queueAction(q).then(z=>(_&&_.debug(`${F}: fftJoinExt End: ${D}/${j}`),z)))}let S=await Promise.all(V),y,R;j*A>1<<28?(y=new I0(j*A),R=new I0(j*A)):(y=new Uint8Array(j*A),R=new Uint8Array(j*A));let k=0;for(let D=0;D<S.length;D++)y.set(S[D][0],k),R.set(S[D][1],k),k+=S[D][0].byteLength;return[y,R]}a.fft=async function(n,i,l,h,u){return await b(n,!1,i,l,h,u)},a.ifft=async function(n,i,l,h,u){return await b(n,!0,i,l,h,u)},a.lagrangeEvaluations=async function(n,i,l,h,u){i=i||"affine",l=l||"affine";let g;if(e=="G1")i=="affine"?g=a.F.n8*2:g=a.F.n8*3;else if(e=="G2")i=="affine"?g=a.F.n8*2:g=a.F.n8*3;else if(e=="Fr")g=f.n8;else throw new Error("Invalid group");let E=n.byteLength/g,_=Mf(E);if(2**_*g!=n.byteLength)throw h&&h.error("lagrangeEvaluations iinvalid input size"),new Error("lagrangeEvaluations invalid Input size");if(_<=f.s)return await a.ifft(n,i,l,h,u);if(_>f.s+1)throw h&&h.error("lagrangeEvaluations input too big"),new Error("lagrangeEvaluations input too big");let F=n.slice(0,n.byteLength/2),L=n.slice(n.byteLength/2,n.byteLength),U=f.exp(f.shift,E/2),O=f.inv(f.sub(f.one,U));[F,L]=await o(F,L,"prepareLagrangeEvaluation",O,f.shiftInv,i,"jacobian",h,u+" prep");let H=[];H.push(b(F,!0,"jacobian",l,h,u+" t0")),H.push(b(L,!0,"jacobian",l,h,u+" t1")),[F,L]=await Promise.all(H);let P;return F.byteLength>1<<28?P=new I0(F.byteLength*2):P=new Uint8Array(F.byteLength*2),P.set(F),P.set(L,F.byteLength),P},a.fftMix=async function(i){let l=a.F.n8*3,h,u;if(e=="G1")h="g1m_fftMix",u="g1m_fftJoin";else if(e=="G2")h="g2m_fftMix",u="g2m_fftJoin";else if(e=="Fr")h="frm_fftMix",u="frm_fftJoin";else throw new Error("Invalid group");let g=Math.floor(i.byteLength/l),E=Mf(g),_=1<<Mf(d.concurrency);g<=_*2&&(_=1);let F=g/_,L=Mf(F),U=[];for(let I=0;I<_;I++){let K=[],j=i.slice(I*F*l,(I+1)*F*l);K.push({cmd:"ALLOCSET",var:0,buff:j});for(let J=1;J<=L;J++)K.push({cmd:"CALL",fnName:h,params:[{var:0},{val:F},{val:J}]});K.push({cmd:"GET",out:0,var:0,len:F*l}),U.push(d.queueAction(K))}let O=await Promise.all(U),H=[];for(let I=0;I<O.length;I++)H[I]=O[I][0];for(let I=L+1;I<=E;I++){let K=1<<E-I,j=_/K,J=[];for(let S=0;S<K;S++)for(let y=0;y<j/2;y++){let R=f.exp(f.w[I],y*F),k=f.w[I],D=S*j+y,M=S*j+y+j/2,N=[];N.push({cmd:"ALLOCSET",var:0,buff:H[D]}),N.push({cmd:"ALLOCSET",var:1,buff:H[M]}),N.push({cmd:"ALLOCSET",var:2,buff:R}),N.push({cmd:"ALLOCSET",var:3,buff:k}),N.push({cmd:"CALL",fnName:u,params:[{var:0},{var:1},{val:F},{var:2},{var:3}]}),N.push({cmd:"GET",out:0,var:0,len:F*l}),N.push({cmd:"GET",out:1,var:1,len:F*l}),J.push(d.queueAction(N))}let V=await Promise.all(J);for(let S=0;S<K;S++)for(let y=0;y<j/2;y++){let R=S*j+y,k=S*j+y+j/2,D=V.shift();H[R]=D[0],H[k]=D[1]}}let P;i instanceof I0?P=new I0(g*l):P=new Uint8Array(g*l);let A=0;for(let I=0;I<_;I++)P.set(H[I],A),A+=H[I].byteLength;return P},a.fftJoin=async function(i,l,h,u){let g=a.F.n8*3,E;if(e=="G1")E="g1m_fftJoin";else if(e=="G2")E="g2m_fftJoin";else if(e=="Fr")E="frm_fftJoin";else throw new Error("Invalid group");if(i.byteLength!=l.byteLength)throw new Error("Invalid buffer size");let _=Math.floor(i.byteLength/g);if(_!=1<<Mf(_))throw new Error("Invalid number of points");let F=1<<Mf(d.concurrency);_<=F*2&&(F=1);let L=_/F,U=[];for(let I=0;I<F;I++){let K=[],j=f.mul(h,f.exp(u,I*L)),J=i.slice(I*L*g,(I+1)*L*g),V=l.slice(I*L*g,(I+1)*L*g);K.push({cmd:"ALLOCSET",var:0,buff:J}),K.push({cmd:"ALLOCSET",var:1,buff:V}),K.push({cmd:"ALLOCSET",var:2,buff:j}),K.push({cmd:"ALLOCSET",var:3,buff:u}),K.push({cmd:"CALL",fnName:E,params:[{var:0},{var:1},{val:L},{var:2},{var:3}]}),K.push({cmd:"GET",out:0,var:0,len:L*g}),K.push({cmd:"GET",out:1,var:1,len:L*g}),U.push(d.queueAction(K))}let O=await Promise.all(U),H,P;i instanceof I0?(H=new I0(_*g),P=new I0(_*g)):(H=new Uint8Array(_*g),P=new Uint8Array(_*g));let A=0;for(let I=0;I<O.length;I++)H.set(O[I][0],A),P.set(O[I][1],A),A+=O[I][0].byteLength;return[H,P]},a.fftFinal=async function(i,l){let h=a.F.n8*3,u=a.F.n8*2,g,E;if(e=="G1")g="g1m_fftFinal",E="g1m_batchToAffine";else if(e=="G2")g="g2m_fftFinal",E="g2m_batchToAffine";else throw new Error("Invalid group");let _=Math.floor(i.byteLength/h);if(_!=1<<Mf(_))throw new Error("Invalid number of points");let F=Math.floor(_/d.concurrency),L=[];for(let P=0;P<d.concurrency;P++){let A;if(P<d.concurrency-1?A=F:A=_-P*F,A==0)continue;let I=[],K=i.slice(P*F*h,(P*F+A)*h);I.push({cmd:"ALLOCSET",var:0,buff:K}),I.push({cmd:"ALLOCSET",var:1,buff:l}),I.push({cmd:"CALL",fnName:g,params:[{var:0},{val:A},{var:1}]}),I.push({cmd:"CALL",fnName:E,params:[{var:0},{val:A},{var:0}]}),I.push({cmd:"GET",out:0,var:0,len:A*u}),L.push(d.queueAction(I))}let U=await Promise.all(L),O;i instanceof I0?O=new I0(_*u):O=new Uint8Array(_*u);let H=0;for(let P=U.length-1;P>=0;P--)O.set(U[P][0],H),H+=U[P][0].byteLength;return O}}async function gs(c){let e=await aC(c.wasm,c.singleThread),a={};return a.q=_a(c.wasm.q.toString()),a.r=_a(c.wasm.r.toString()),a.name=c.name,a.tm=e,a.prePSize=c.wasm.prePSize,a.preQSize=c.wasm.preQSize,a.Fr=new er(e,"frm",c.n8r,c.r),a.F1=new er(e,"f1m",c.n8q,c.q),a.F2=new ar(e,"f2m",a.F1),a.G1=new cr(e,"g1m",a.F1,c.wasm.pG1gen,c.wasm.pG1b,c.cofactorG1),a.G2=new cr(e,"g2m",a.F2,c.wasm.pG2gen,c.wasm.pG2b,c.cofactorG2),a.F6=new hs(e,"f6m",a.F2),a.F12=new ar(e,"ftm",a.F6),a.Gt=a.F12,ps(a,"G1"),ps(a,"G2"),ps(a,"Fr"),Cg(a,"G1"),Cg(a,"G2"),ms(a,"G1"),ms(a,"G2"),ms(a,"Fr"),cC(a),a.array2buffer=function(f,d){let b=new Uint8Array(d*f.length);for(let t=0;t<f.length;t++)b.set(f[t],t*d);return b},a.buffer2array=function(f,d){let b=f.byteLength/d,t=new Array(b);for(let r=0;r<b;r++)t[r]=f.slice(r*d,r*d+d);return t},a}globalThis.curve_bn128=null;async function fr(c,e){let a=new gf;a.setMemory(25),(0,Lae.buildBn128)(a),e&&e(a);let f={};if(f.code=a.build(),f.pq=a.modules.f1m.pq,f.pr=a.modules.frm.pq,f.pG1gen=a.modules.bn128.pG1gen,f.pG1zero=a.modules.bn128.pG1zero,f.pG1b=a.modules.bn128.pG1b,f.pG2gen=a.modules.bn128.pG2gen,f.pG2zero=a.modules.bn128.pG2zero,f.pG2b=a.modules.bn128.pG2b,f.pOneT=a.modules.bn128.pOneT,f.prePSize=a.modules.bn128.prePSize,f.preQSize=a.modules.bn128.preQSize,f.n8q=32,f.n8r=32,f.q=a.modules.bn128.q,f.r=a.modules.bn128.r,!c&&globalThis.curve_bn128)return globalThis.curve_bn128;let d={name:"bn128",wasm:f,q:_a("21888242871839275222246405745257275088696311157297823662689037894645226208583"),r:_a("21888242871839275222246405745257275088548364400416034343698204186575808495617"),n8q:32,n8r:32,cofactorG2:_a("30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d",16),singleThread:!!c},b=await gs(d);return b.terminate=async function(){d.singleThread||(globalThis.curve_bn128=null,await this.tm.terminate())},c||(globalThis.curve_bn128=b),b}s();x();var Fae=Fe(E3(),1);globalThis.curve_bls12381=null;async function dr(c,e){let a=new gf;a.setMemory(25),(0,Fae.buildBls12381)(a),e&&e(a);let f={};if(f.code=a.build(),f.pq=a.modules.f1m.pq,f.pr=a.modules.frm.pq,f.pG1gen=a.modules.bls12381.pG1gen,f.pG1zero=a.modules.bls12381.pG1zero,f.pG1b=a.modules.bls12381.pG1b,f.pG2gen=a.modules.bls12381.pG2gen,f.pG2zero=a.modules.bls12381.pG2zero,f.pG2b=a.modules.bls12381.pG2b,f.pOneT=a.modules.bls12381.pOneT,f.prePSize=a.modules.bls12381.prePSize,f.preQSize=a.modules.bls12381.preQSize,f.n8q=48,f.n8r=32,f.q=a.modules.bls12381.q,f.r=a.modules.bls12381.r,!c&&globalThis.curve_bls12381)return globalThis.curve_bls12381;let d={name:"bls12381",wasm:f,q:_a("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),r:_a("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),n8q:48,n8r:32,cofactorG1:_a("0x396c8c005555e1568c00aaab0000aaab",16),cofactorG2:_a("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5",16),singleThread:!!c},b=await gs(d);return b.terminate=async function(){d.singleThread||(globalThis.curve_bls12381=null,await this.tm.terminate())},c||(globalThis.curve_bls12381=b),b}s();x();var eG0=_a("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),aG0=_a("21888242871839275222246405745257275088548364400416034343698204186575808495617"),cG0=_a("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),fG0=_a("21888242871839275222246405745257275088696311157297823662689037894645226208583");var Ma=sf,Ya=Ig;s();x();var CG0=Ma.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),RG0=Ma.e("21888242871839275222246405745257275088548364400416034343698204186575808495617"),b_e=Ma.e("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),t_e=Ma.e("21888242871839275222246405745257275088696311157297823662689037894645226208583");async function t3(c){let e;if(Ma.eq(c,t_e))e=await fr();else if(Ma.eq(c,b_e))e=await dr();else throw new Error(`Curve not supported: ${Ma.toString(c)}`);return e}async function Rg(c){let e,a=f(c);if(["BN128","BN254","ALTBN128"].indexOf(a)>=0)e=await fr();else if(["BLS12381"].indexOf(a)>=0)e=await dr();else throw new Error(`Curve not supported: ${c}`);return e;function f(d){return d.toUpperCase().match(/[A-Za-z0-9]+/g).join("")}}s();x();var fve=Fe(xf(),1);s();x();_3();var dve=[];for(let c=0;c<256;c++)dve[c]=bve(c,8);function bve(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}function i5(c){return((c&4294901760)!==0?(c&=4294901760,16):0)|((c&4278255360)!==0?(c&=4278255360,8):0)|((c&4042322160)!==0?(c&=4042322160,4):0)|((c&3435973836)!==0?(c&=3435973836,2):0)|(c&2863311530)!==0}async function Z1(c,e,a){let f=await c.read(e.G1.F.n8*2),d=e.G1.fromRprLEM(f,0);return a?e.G1.toObject(d):d}async function Og(c,e,a){let f=await c.read(e.G2.F.n8*2),d=e.G2.fromRprLEM(f,0);return a?e.G2.toObject(d):d}async function w8(c,e,a){await td(c,e,1);let f=await c.readULE32();if(await rd(c),f==1)return await tve(c,e,a);if(f==2)return await rve(c,e,a);throw new Error("Protocol not supported: ")}async function tve(c,e,a){let f={};f.protocol="groth16",await td(c,e,2);let d=await c.readULE32();f.n8q=d,f.q=await J7(c,d);let b=await c.readULE32();return f.n8r=b,f.r=await J7(c,b),f.curve=await t3(f.q),f.nVars=await c.readULE32(),f.nPublic=await c.readULE32(),f.domainSize=await c.readULE32(),f.power=i5(f.domainSize),f.vk_alpha_1=await Z1(c,f.curve,a),f.vk_beta_1=await Z1(c,f.curve,a),f.vk_beta_2=await Og(c,f.curve,a),f.vk_gamma_2=await Og(c,f.curve,a),f.vk_delta_1=await Z1(c,f.curve,a),f.vk_delta_2=await Og(c,f.curve,a),await rd(c),f}async function rve(c,e,a){let f={};f.protocol="plonk",await td(c,e,2);let d=await c.readULE32();f.n8q=d,f.q=await J7(c,d);let b=await c.readULE32();return f.n8r=b,f.r=await J7(c,b),f.curve=await t3(f.q),f.nVars=await c.readULE32(),f.nPublic=await c.readULE32(),f.domainSize=await c.readULE32(),f.power=i5(f.domainSize),f.nAdditions=await c.readULE32(),f.nConstrains=await c.readULE32(),f.k1=await c.read(b),f.k2=await c.read(b),f.Qm=await Z1(c,f.curve,a),f.Ql=await Z1(c,f.curve,a),f.Qr=await Z1(c,f.curve,a),f.Qo=await Z1(c,f.curve,a),f.Qc=await Z1(c,f.curve,a),f.S1=await Z1(c,f.curve,a),f.S2=await Z1(c,f.curve,a),f.S3=await Z1(c,f.curve,a),f.X_2=await Og(c,f.curve,a),await rd(c),f}s();x();async function ice(c,e,a){await dd(c,1);let f=(Math.floor((Ma.bitLength(a)-1)/64)+1)*8;if(await c.writeULE32(f),await Wt(c,a,f),e.byteLength%f!=0)throw new Error("Invalid witness length");await c.writeULE32(e.byteLength/f),await bd(c),await dd(c,2),await c.write(e),await bd(c)}async function nC(c,e){await td(c,e,1);let a=await c.readULE32(),f=await J7(c,a),d=await c.readULE32();return await rd(c),{n8:a,q:f,nWitness:d}}var{stringifyBigInts:oce}=Ya;async function ws(c,e,a){let{fd:f,sections:d}=await Ga(e,"wtns",2,33554432,8388608),b=await nC(f,d),{fd:t,sections:r}=await Ga(c,"zkey",2,1<<25,1<<23),o=await w8(t,r);if(o.protocol!="groth16")throw new Error("zkey file is not groth16");if(!Ma.eq(o.r,b.q))throw new Error("Curve of the witness does not match the curve of the proving key");if(b.nWitness!=o.nVars)throw new Error(`Invalid witness length. Circuit: ${o.nVars}, witness: ${b.nWitness}`);let n=o.curve,i=n.Fr,l=n.G1,h=n.G2,u=i5(o.domainSize);a&&a.debug("Reading Wtns");let g=await x2(f,d,2);a&&a.debug("Reading Coeffs");let E=await x2(t,r,4);a&&a.debug("Building ABC");let[_,F,L]=await nve(n,o,g,E,a),U=u==i.s?n.Fr.shift:n.Fr.w[u+1],O=await i.ifft(_,"","",a,"IFFT_A"),H=await i.batchApplyKey(O,i.e(1),U),P=await i.fft(H,"","",a,"FFT_A"),A=await i.ifft(F,"","",a,"IFFT_B"),I=await i.batchApplyKey(A,i.e(1),U),K=await i.fft(I,"","",a,"FFT_B"),j=await i.ifft(L,"","",a,"IFFT_C"),J=await i.batchApplyKey(j,i.e(1),U),V=await i.fft(J,"","",a,"FFT_C");a&&a.debug("Join ABC");let S=await ive(n,o,P,K,V,a),y={};a&&a.debug("Reading A Points");let R=await x2(t,r,5);y.pi_a=await n.G1.multiExpAffine(R,g,a,"multiexp A"),a&&a.debug("Reading B1 Points");let k=await x2(t,r,6),D=await n.G1.multiExpAffine(k,g,a,"multiexp B1");a&&a.debug("Reading B2 Points");let M=await x2(t,r,7);y.pi_b=await n.G2.multiExpAffine(M,g,a,"multiexp B2"),a&&a.debug("Reading C Points");let N=await x2(t,r,8);y.pi_c=await n.G1.multiExpAffine(N,g.slice((o.nPublic+1)*n.Fr.n8),a,"multiexp C"),a&&a.debug("Reading H Points");let q=await x2(t,r,9),G=await n.G1.multiExpAffine(q,S,a,"multiexp H"),C=n.Fr.random(),z=n.Fr.random();y.pi_a=l.add(y.pi_a,o.vk_alpha_1),y.pi_a=l.add(y.pi_a,l.timesFr(o.vk_delta_1,C)),y.pi_b=h.add(y.pi_b,o.vk_beta_2),y.pi_b=h.add(y.pi_b,h.timesFr(o.vk_delta_2,z)),D=l.add(D,o.vk_beta_1),D=l.add(D,l.timesFr(o.vk_delta_1,z)),y.pi_c=l.add(y.pi_c,G),y.pi_c=l.add(y.pi_c,l.timesFr(y.pi_a,z)),y.pi_c=l.add(y.pi_c,l.timesFr(D,C)),y.pi_c=l.add(y.pi_c,l.timesFr(o.vk_delta_1,i.neg(i.mul(C,z))));let de=[];for(let w=1;w<=o.nPublic;w++){let p=g.slice(w*i.n8,w*i.n8+i.n8);de.push(Ma.fromRprLE(p))}return y.pi_a=l.toObject(l.toAffine(y.pi_a)),y.pi_b=h.toObject(h.toAffine(y.pi_b)),y.pi_c=l.toObject(l.toAffine(y.pi_c)),y.protocol="groth16",y.curve=n.name,await t.close(),await f.close(),y=oce(y),de=oce(de),{proof:y,publicSignals:de}}async function nve(c,e,a,f,d){let b=c.Fr.n8,t=4*3+e.n8r,r=(f.byteLength-4)/t,o=new I0(e.domainSize*b),n=new I0(e.domainSize*b),i=new I0(e.domainSize*b),l=[o,n];for(let h=0;h<r;h++){d&&h%1e6==0&&d.debug(`QAP AB: ${h}/${r}`);let u=f.slice(4+h*t,4+h*t+t),g=new DataView(u.buffer),E=g.getUint32(0,!0),_=g.getUint32(4,!0),F=g.getUint32(8,!0),L=u.slice(12,12+b);l[E].set(c.Fr.add(l[E].slice(_*b,_*b+b),c.Fr.mul(L,a.slice(F*b,F*b+b))),_*b)}for(let h=0;h<e.domainSize;h++)d&&h%1e6==0&&d.debug(`QAP C: ${h}/${e.domainSize}`),i.set(c.Fr.mul(o.slice(h*b,h*b+b),n.slice(h*b,h*b+b)),h*b);return[o,n,i]}async function ive(c,e,a,f,d,b){let r=c.Fr.n8,o=Math.floor(a.byteLength/c.Fr.n8),n=[];for(let u=0;u<o;u+=4194304){b&&b.debug(`JoinABC: ${u}/${o}`);let g=Math.min(o-u,4194304),E=[],_=a.slice(u*r,(u+g)*r),F=f.slice(u*r,(u+g)*r),L=d.slice(u*r,(u+g)*r);E.push({cmd:"ALLOCSET",var:0,buff:_}),E.push({cmd:"ALLOCSET",var:1,buff:F}),E.push({cmd:"ALLOCSET",var:2,buff:L}),E.push({cmd:"ALLOC",var:3,len:g*r}),E.push({cmd:"CALL",fnName:"qap_joinABC",params:[{var:0},{var:1},{var:2},{val:g},{var:3}]}),E.push({cmd:"CALL",fnName:"frm_batchFromMontgomery",params:[{var:3},{val:g},{var:3}]}),E.push({cmd:"GET",out:0,var:3,len:g*r}),n.push(c.tm.queueAction(E))}let i=await Promise.all(n),l;a instanceof I0?l=new I0(a.byteLength):l=new Uint8Array(a.byteLength);let h=0;for(let u=0;u<i.length;u++)l.set(i[u][0],h),h+=i[u][0].byteLength;return l}s();x();s();x();s();x();s();x();function iC(c){var e=[];return a(e,c),e;function a(f,d){if(Array.isArray(d))for(let b=0;b<d.length;b++)a(f,d[b]);else f.push(d)}}function oC(c){let e=BigInt(2)**BigInt(64),a=BigInt("0xCBF29CE484222325");for(var f=0;f<c.length;f++)a^=BigInt(c[f].charCodeAt()),a*=BigInt(1099511628211),a%=e;let d=a.toString(16),b=16-d.length;return d="0".repeat(b).concat(d),d}function sce(c,e){let a=[],f=BigInt(c),d=BigInt(4294967296);for(;f;)a.unshift(Number(f%d)),f=f/d;if(e)for(var b=e-a.length;b>0;)a.unshift(0),b--;return a}s();x();var lf={};v0(lf,{abs:()=>mve,add:()=>uC,band:()=>pC,bitLength:()=>tr,bits:()=>lC,bor:()=>_ve,bxor:()=>vve,div:()=>o5,e:()=>id,eq:()=>_8,exp:()=>pve,fromArray:()=>sve,fromRprBE:()=>gC,fromRprLE:()=>vs,fromString:()=>Mg,geq:()=>mce,gt:()=>hC,isNegative:()=>xce,isOdd:()=>kg,isZero:()=>sC,land:()=>Eve,leq:()=>wve,lnot:()=>Sve,lor:()=>Ave,lt:()=>yve,mod:()=>n3,mul:()=>pce,naf:()=>lce,neg:()=>hce,neq:()=>gve,one:()=>yce,pow:()=>rr,shiftLeft:()=>xC,shiftRight:()=>Dg,shl:()=>xve,shr:()=>lve,square:()=>hve,sub:()=>X7,toArray:()=>uve,toLEBuff:()=>Es,toNumber:()=>uce,toRprBE:()=>mC,toRprLE:()=>_s,toString:()=>yC,zero:()=>gce});s();x();var ove=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function Mg(c,e){if(!e||e==10)return BigInt(c);if(e==16)return c.slice(0,2)=="0x"?BigInt(c):BigInt("0x"+c)}var id=Mg;function sve(c,e){let a=BigInt(0);e=BigInt(e);for(let f=0;f<c.length;f++)a=a*e+BigInt(c[f]);return a}function tr(c){let e=c.toString(16);return(e.length-1)*4+ove[parseInt(e[0],16)]}function xce(c){return BigInt(c)<BigInt(0)}function sC(c){return!c}function xC(c,e){return BigInt(c)<<BigInt(e)}function Dg(c,e){return BigInt(c)>>BigInt(e)}var xve=xC,lve=Dg;function kg(c){return(BigInt(c)&BigInt(1))==BigInt(1)}function lce(c){let e=BigInt(c),a=[];for(;e;){if(e&BigInt(1)){let f=2-Number(e%BigInt(4));a.push(f),e=e-BigInt(f)}else a.push(0);e=e>>BigInt(1)}return a}function lC(c){let e=BigInt(c),a=[];for(;e;)e&BigInt(1)?a.push(1):a.push(0),e=e>>BigInt(1);return a}function uce(c){if(c>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Number too big");return Number(c)}function uve(c,e){let a=[],f=BigInt(c);for(e=BigInt(e);f;)a.unshift(Number(f%e)),f=f/e;return a}function uC(c,e){return BigInt(c)+BigInt(e)}function X7(c,e){return BigInt(c)-BigInt(e)}function hce(c){return-BigInt(c)}function pce(c,e){return BigInt(c)*BigInt(e)}function hve(c){return BigInt(c)*BigInt(c)}function rr(c,e){return BigInt(c)**BigInt(e)}function pve(c,e){return BigInt(c)**BigInt(e)}function mve(c){return BigInt(c)>=0?BigInt(c):-BigInt(c)}function o5(c,e){return BigInt(c)/BigInt(e)}function n3(c,e){return BigInt(c)%BigInt(e)}function _8(c,e){return BigInt(c)==BigInt(e)}function gve(c,e){return BigInt(c)!=BigInt(e)}function yve(c,e){return BigInt(c)<BigInt(e)}function hC(c,e){return BigInt(c)>BigInt(e)}function wve(c,e){return BigInt(c)<=BigInt(e)}function mce(c,e){return BigInt(c)>=BigInt(e)}function pC(c,e){return BigInt(c)&BigInt(e)}function _ve(c,e){return BigInt(c)|BigInt(e)}function vve(c,e){return BigInt(c)^BigInt(e)}function Eve(c,e){return BigInt(c)&&BigInt(e)}function Ave(c,e){return BigInt(c)||BigInt(e)}function Sve(c){return!BigInt(c)}function _s(c,e,a,f){let d="0000000"+a.toString(16),b=new Uint32Array(c.buffer,e,f/4),t=((d.length-7)*4-1>>5)+1;for(let r=0;r<t;r++)b[r]=parseInt(d.substring(d.length-8*r-8,d.length-8*r),16);for(let r=t;r<b.length;r++)b[r]=0;for(let r=b.length*4;r<f;r++)c[r]=uce(pC(Dg(a,r*8),255))}function mC(c,e,a,f){let d="0000000"+a.toString(16),b=new DataView(c.buffer,c.byteOffset+e,f),t=((d.length-7)*4-1>>5)+1;for(let r=0;r<t;r++)b.setUint32(f-r*4-4,parseInt(d.substring(d.length-8*r-8,d.length-8*r),16),!1);for(let r=0;r<f/4-t;r++)b[r]=0}function vs(c,e,a){a=a||c.byteLength,e=e||0;let f=new Uint32Array(c.buffer,e,a/4),d=new Array(a/4);return f.forEach((b,t)=>d[d.length-t-1]=b.toString(16).padStart(8,"0")),Mg(d.join(""),16)}function gC(c,e,a){a=a||c.byteLength,e=e||0;let f=new DataView(c.buffer,c.byteOffset+e,a),d=new Array(a/4);for(let b=0;b<a/4;b++)d[b]=f.getUint32(b*4,!1).toString(16).padStart(8,"0");return Mg(d.join(""),16)}function yC(c,e){return c.toString(e)}function Es(c){let e=new Uint8Array(Math.floor((tr(c)-1)/8)+1);return _s(e,0,c,e.byteLength),e}var gce=id(0),yce=id(1);s();x();var Ive=[];for(let c=0;c<256;c++)Ive[c]=Lve(c,8);function Lve(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}s();x();s();x();function As(c,e,a){if(sC(a))return c.one;let f=lC(a);if(f.length==0)return c.one;let d=e;for(let b=f.length-2;b>=0;b--)d=c.square(d),f[b]&&(d=c.mul(d,e));return d}s();x();function qg(c){if(c.m%2==1)if(_8(n3(c.p,4),1))if(_8(n3(c.p,8),1))if(_8(n3(c.p,16),1))Fve(c);else if(_8(n3(c.p,16),9))Cve(c);else throw new Error("Field withot sqrt");else if(_8(n3(c.p,8),5))Rve(c);else throw new Error("Field withot sqrt");else _8(n3(c.p,4),3)&&Bve(c);else{let e=n3(rr(c.p,c.m/2),4);e==1?Pve(c):e==3?Tve(c):Ove(c)}}function Fve(c){for(c.sqrt_q=rr(c.p,c.m),c.sqrt_s=0,c.sqrt_t=X7(c.sqrt_q,1);!kg(c.sqrt_t);)c.sqrt_s=c.sqrt_s+1,c.sqrt_t=o5(c.sqrt_t,2);let e=c.one;for(;c.eq(e,c.one);){let a=c.random();c.sqrt_z=c.pow(a,c.sqrt_t),e=c.pow(c.sqrt_z,2**(c.sqrt_s-1))}c.sqrt_tm1d2=o5(X7(c.sqrt_t,1),2),c.sqrt=function(a){let f=this;if(f.isZero(a))return f.zero;let d=f.pow(a,f.sqrt_tm1d2),b=f.pow(f.mul(f.square(d),a),2**(f.sqrt_s-1));if(f.eq(b,f.negone))return null;let t=f.sqrt_s,r=f.mul(a,d),o=f.mul(r,d),n=f.sqrt_z;for(;!f.eq(o,f.one);){let i=f.square(o),l=1;for(;!f.eq(i,f.one);)i=f.square(i),l++;d=n;for(let h=0;h<t-l-1;h++)d=f.square(d);n=f.square(d),o=f.mul(o,n),r=f.mul(r,d),t=l}return f.geq(r,f.zero)?r:f.neg(r)}}function Cve(c){c.sqrt=function(){throw new Error("Sqrt alg 4 not implemented")}}function Rve(c){c.sqrt=function(){throw new Error("Sqrt alg 3 not implemented")}}function Bve(c){c.sqrt_q=rr(c.p,c.m),c.sqrt_e1=o5(X7(c.sqrt_q,3),4),c.sqrt=function(e){if(this.isZero(e))return this.zero;let a=this.pow(e,this.sqrt_e1),f=this.mul(this.square(a),e);if(this.eq(f,this.negone))return null;let d=this.mul(a,e);return c.geq(d,c.zero)?d:c.neg(d)}}function Pve(c){c.sqrt=function(){throw new Error("Sqrt alg 10 not implemented")}}function Tve(c){c.sqrt_q=rr(c.p,c.m/2),c.sqrt_e34=o5(X7(c.sqrt_q,3),4),c.sqrt_e12=o5(X7(c.sqrt_q,1),2),c.frobenius=function(e,a){return e%2==1?c.conjugate(a):a},c.sqrt=function(e){let a=this,f=a.pow(e,a.sqrt_e34),d=a.mul(a.square(f),e),b=a.mul(a.frobenius(1,d),d);if(a.eq(b,a.negone))return null;let t=a.mul(f,e),r;if(a.eq(d,a.negone))r=a.mul(t,[a.F.zero,a.F.one]);else{let o=a.pow(a.add(a.one,d),a.sqrt_e12);r=a.mul(o,t)}return a.geq(r,a.zero)?r:a.neg(r)}}function Ove(c){c.sqrt=function(){throw new Error("Sqrt alg 8 not implemented")}}s();x();s();x();_3();function wce(c){let e=new Uint8Array(c);if(process.browser)if(typeof globalThis.crypto<"u")globalThis.crypto.getRandomValues(e);else for(let a=0;a<c;a++)e[a]=Math.random()*4294967296>>>0;else o1.randomFillSync(e);return e}s();x();var Ss=class{constructor(e,a,f){this.F=a,this.G=e,this.opMulGF=f;let d=a.sqrt_t||a.t,b=a.sqrt_s||a.s,t=a.one;for(;a.eq(a.pow(t,a.half),a.one);)t=a.add(t,a.one);this.w=new Array(b+1),this.wi=new Array(b+1),this.w[b]=this.F.pow(t,d),this.wi[b]=this.F.inv(this.w[b]);let r=b-1;for(;r>=0;)this.w[r]=this.F.square(this.w[r+1]),this.wi[r]=this.F.square(this.wi[r+1]),r--;this.roots=[],this._setRoots(Math.min(b,15))}_setRoots(e){for(let a=e;a>=0&&!this.roots[a];a--){let f=this.F.one,d=1<<a,b=new Array(d);for(let t=0;t<d;t++)b[t]=f,f=this.F.mul(f,this.w[a]);this.roots[a]=b}}fft(e){if(e.length<=1)return e;let a=_ce(e.length-1)+1;this._setRoots(a);let f=1<<a;if(e.length!=f)throw new Error("Size must be multiple of 2");return Gg(this,e,a,0,1)}ifft(e){if(e.length<=1)return e;let a=_ce(e.length-1)+1;this._setRoots(a);let f=1<<a;if(e.length!=f)throw new Error("Size must be multiple of 2");let d=Gg(this,e,a,0,1),b=this.F.inv(this.F.mulScalar(this.F.one,f)),t=new Array(f);for(let r=0;r<f;r++)t[r]=this.opMulGF(d[(f-r)%f],b);return t}};function _ce(c){return((c&4294901760)!==0?(c&=4294901760,16):0)|((c&4278255360)!==0?(c&=4278255360,8):0)|((c&4042322160)!==0?(c&=4042322160,4):0)|((c&3435973836)!==0?(c&=3435973836,2):0)|(c&2863311530)!==0}function Gg(c,e,a,f,d){let b=1<<a;if(b==1)return[e[f]];if(b==2)return[c.G.add(e[f],e[f+d]),c.G.sub(e[f],e[f+d])];let t=b>>1,r=Gg(c,e,a-1,f,d*2),o=Gg(c,e,a-1,f+d,d*2),n=new Array(b);for(let i=0;i<t;i++)n[i]=c.G.add(r[i],c.opMulGF(o[i],c.roots[a][i])),n[i+t]=c.G.sub(r[i],c.opMulGF(o[i],c.roots[a][i]));return n}var s5=class{constructor(e){this.type="F1",this.one=BigInt(1),this.zero=BigInt(0),this.p=BigInt(e),this.m=1,this.negone=this.p-this.one,this.two=BigInt(2),this.half=this.p>>this.one,this.bitLength=tr(this.p),this.mask=(this.one<<BigInt(this.bitLength))-this.one,this.n64=Math.floor((this.bitLength-1)/64)+1,this.n32=this.n64*2,this.n8=this.n64*8,this.R=this.e(this.one<<BigInt(this.n64*64)),this.Ri=this.inv(this.R);let a=this.negone>>this.one;this.nqr=this.two;let f=this.pow(this.nqr,a);for(;!this.eq(f,this.negone);)this.nqr=this.nqr+this.one,f=this.pow(this.nqr,a);for(this.s=0,this.t=this.negone;(this.t&this.one)==this.zero;)this.s=this.s+1,this.t=this.t>>this.one;this.nqr_to_t=this.pow(this.nqr,this.t),qg(this),this.FFT=new Ss(this,this,this.mul.bind(this)),this.fft=this.FFT.fft.bind(this.FFT),this.ifft=this.FFT.ifft.bind(this.FFT),this.w=this.FFT.w,this.wi=this.FFT.wi,this.shift=this.square(this.nqr),this.k=this.exp(this.nqr,2**this.s)}e(e,a){let f;if(a?a==16&&(f=BigInt("0x"+e)):f=BigInt(e),f<0){let d=-f;return d>=this.p&&(d=d%this.p),this.p-d}else return f>=this.p?f%this.p:f}add(e,a){let f=e+a;return f>=this.p?f-this.p:f}sub(e,a){return e>=a?e-a:this.p-a+e}neg(e){return e&&this.p-e}mul(e,a){return e*a%this.p}mulScalar(e,a){return e*this.e(a)%this.p}square(e){return e*e%this.p}eq(e,a){return e==a}neq(e,a){return e!=a}lt(e,a){let f=e>this.half?e-this.p:e,d=a>this.half?a-this.p:a;return f<d}gt(e,a){let f=e>this.half?e-this.p:e,d=a>this.half?a-this.p:a;return f>d}leq(e,a){let f=e>this.half?e-this.p:e,d=a>this.half?a-this.p:a;return f<=d}geq(e,a){let f=e>this.half?e-this.p:e,d=a>this.half?a-this.p:a;return f>=d}div(e,a){return this.mul(e,this.inv(a))}idiv(e,a){if(!a)throw new Error("Division by zero");return e/a}inv(e){if(!e)throw new Error("Division by zero");let a=this.zero,f=this.p,d=this.one,b=e%this.p;for(;b;){let t=f/b;[a,d]=[d,a-t*d],[f,b]=[b,f-t*b]}return a<this.zero&&(a+=this.p),a}mod(e,a){return e%a}pow(e,a){return As(this,e,a)}exp(e,a){return As(this,e,a)}band(e,a){let f=e&a&this.mask;return f>=this.p?f-this.p:f}bor(e,a){let f=(e|a)&this.mask;return f>=this.p?f-this.p:f}bxor(e,a){let f=(e^a)&this.mask;return f>=this.p?f-this.p:f}bnot(e){let a=e^this.mask;return a>=this.p?a-this.p:a}shl(e,a){if(Number(a)<this.bitLength){let f=e<<a&this.mask;return f>=this.p?f-this.p:f}else{let f=this.p-a;return Number(f)<this.bitLength?e>>f:this.zero}}shr(e,a){if(Number(a)<this.bitLength)return e>>a;{let f=this.p-a;if(Number(f)<this.bitLength){let d=e<<f&this.mask;return d>=this.p?d-this.p:d}else return 0}}land(e,a){return e&&a?this.one:this.zero}lor(e,a){return e||a?this.one:this.zero}lnot(e){return e?this.zero:this.one}sqrt_old(e){if(e==this.zero)return this.zero;if(this.pow(e,this.negone>>this.one)!=this.one)return null;let f=this.s,d=this.nqr_to_t,b=this.pow(e,this.t),t=this.pow(e,this.add(this.t,this.one)>>this.one);for(;b!=this.one;){let r=this.square(b),o=1;for(;r!=this.one;)o++,r=this.square(r);let n=d;for(let i=0;i<f-o-1;i++)n=this.square(n);f=o,d=this.square(n),b=this.mul(b,d),t=this.mul(t,n)}return t>this.p>>this.one&&(t=this.neg(t)),t}normalize(e,a){if(e=BigInt(e,a),e<0){let f=-e;return f>=this.p&&(f=f%this.p),this.p-f}else return e>=this.p?e%this.p:e}random(){let e=this.bitLength*2/8,a=this.zero;for(let f=0;f<e;f++)a=(a<<BigInt(8))+BigInt(wce(1)[0]);return a%this.p}toString(e,a){a=a||10;let f;return e>this.half&&a==10?f="-"+(this.p-e).toString(a):f=e.toString(a),f}isZero(e){return e==this.zero}fromRng(e){let a;do{a=this.zero;for(let f=0;f<this.n64;f++)a+=e.nextU64()<<BigInt(64*f);a&=this.mask}while(a>=this.p);return a=a*this.Ri%this.p,a}fft(e){return this.FFT.fft(e)}ifft(e){return this.FFT.ifft(e)}toRprLE(e,a,f){_s(e,a,f,this.n64*8)}toRprBE(e,a,f){mC(e,a,f,this.n64*8)}toRprBEM(e,a,f){return this.toRprBE(e,a,this.mul(this.R,f))}toRprLEM(e,a,f){return this.toRprLE(e,a,this.mul(this.R,f))}fromRprLE(e,a){return vs(e,a,this.n8)}fromRprBE(e,a){return gC(e,a,this.n8)}fromRprLEM(e,a){return this.mul(this.fromRprLE(e,a),this.Ri)}fromRprBEM(e,a){return this.mul(this.fromRprBE(e,a),this.Ri)}toObject(e){return e}};s();x();s();x();s();x();s();x();var Vve=Fe(E3(),1);s();x();s();x();s();x();var Mve=[];for(let c=0;c<256;c++)Mve[c]=Dve(c,8);function Dve(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}s();x();s();x();s();x();s();x();s();x();s();x();s();x();function wC(c){let a,f;c&&(c.onmessage=function(i){let l;if(i.data?l=i.data:l=i,l[0].cmd=="INIT")d(l[0]).then(function(){c.postMessage(l.result)});else if(l[0].cmd=="TERMINATE")c.close();else{let h=n(l);c.postMessage(h)}});async function d(i){let l=new Uint8Array(i.code),h=await WebAssembly.compile(l);f=new WebAssembly.Memory({initial:i.init,maximum:32767}),a=await WebAssembly.instantiate(h,{env:{memory:f}})}function b(i){let l=new Uint32Array(f.buffer,0,1);for(;l[0]&3;)l[0]++;let h=l[0];if(l[0]+=i,l[0]+i>f.buffer.byteLength){let u=f.buffer.byteLength/65536,g=Math.floor((l[0]+i)/65536)+1;g>32767&&(g=32767),f.grow(g-u)}return h}function t(i){let l=b(i.byteLength);return o(l,i),l}function r(i,l){let h=new Uint8Array(f.buffer);return new Uint8Array(h.buffer,h.byteOffset+i,l)}function o(i,l){new Uint8Array(f.buffer).set(new Uint8Array(l),i)}function n(i){if(i[0].cmd=="INIT")return d(i[0]);let l={vars:[],out:[]},u=new Uint32Array(f.buffer,0,1)[0];for(let E=0;E<i.length;E++)switch(i[E].cmd){case"ALLOCSET":l.vars[i[E].var]=t(i[E].buff);break;case"ALLOC":l.vars[i[E].var]=b(i[E].len);break;case"SET":o(l.vars[i[E].var],i[E].buff);break;case"CALL":{let _=[];for(let F=0;F<i[E].params.length;F++){let L=i[E].params[F];typeof L.var<"u"?_.push(l.vars[L.var]+(L.offset||0)):typeof L.val<"u"&&_.push(L.val)}a.exports[i[E].fnName](..._);break}case"GET":l.out[i[E].out]=r(l.vars[i[E].var],i[E].len).slice();break;default:throw new Error("Invalid cmd")}let g=new Uint32Array(f.buffer,0,1);return g[0]=u,l.out}return n}var Gve=Fe(Wr(),1);function zve(c){return process.browser?globalThis.btoa(c):Buffer.from(c).toString("base64")}var jve=zve("("+wC.toString()+")(self)"),Jj0="data:application/javascript;base64,"+jve;s();x();s();x();s();x();s();x();globalThis.curve_bn128=null;s();x();var Kve=Fe(E3(),1);globalThis.curve_bls12381=null;s();x();var JH0=id("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),ZH0=id("21888242871839275222246405745257275088548364400416034343698204186575808495617"),YH0=id("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),XH0=id("21888242871839275222246405745257275088696311157297823662689037894645226208583");var d1=lf;async function Is(c,e){e=e||{};let a=32767,f,d=!1;for(;!d;)try{f=new WebAssembly.Memory({initial:a}),d=!0}catch(_){if(a===1)throw _;console.warn("Could not allocate "+a*1024*64+" bytes. This may cause severe instability. Trying with "+a*1024*64/2+" bytes"),a=Math.floor(a/2)}let b=await WebAssembly.compile(c),t,r="",o="",n=1,i=0,l=0,h=await WebAssembly.instantiate(b,{env:{memory:f},runtime:{exceptionHandler:function(_){let F;throw _==1?F="Signal not found. ":_==2?F="Too many signals set. ":_==3?F="Signal already set. ":_==4?F="Assert Failed. ":_==5?F="Not enough memory. ":_==6?F="Input signal array access exceeds the size. ":F="Unknown error. ",console.error("ERROR: ",_,r),new Error(F+r)},printErrorMessage:function(){r+=g()+`
|
|
349
|
+
`)}static register(e,a){if(a||(a=e.locale),Lye)try{let f=window;f._ethers&&f._ethers.wordlists&&(f._ethers.wordlists[a]||he(f._ethers.wordlists,a,e))}catch{}}};s();x();s();x();var Fye="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",Do=null;function Fee(c){if(Do==null&&(Do=Fye.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),f1.check(c)!=="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"))throw Do=null,new Error("BIP39 Wordlist for en (English) FAILED")}var YL=class extends f1{constructor(){super("en")}getWord(e){return Fee(this),Do[e]}getWordIndex(e){return Fee(this),Do.indexOf(e)}},XL=new YL;f1.register(XL);var a5={en:XL};s();x();var Cee="hdnode/5.7.0";var ko=new X(Cee),Cye=Ee.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Rye=J0("Bitcoin seed"),Nt=2147483648;function Bee(c){return(1<<c)-1<<8-c}function Bye(c){return(1<<c)-1}function qm(c){return q0(Be(c),32)}function Ree(c){return o8.encode(O0([c,ya(Rd(Rd(c)),0,4)]))}function eF(c){if(c==null)return a5.en;if(typeof c=="string"){let e=a5[c];return e==null&&ko.throwArgumentError("unknown locale","wordlist",c),e}return c}var Ot={},x8="m/44'/60'/0'/0/0",Kc=class{constructor(e,a,f,d,b,t,r,o){if(e!==Ot)throw new Error("HDNode constructor cannot be called directly");if(a){let n=new a1(a);he(this,"privateKey",n.privateKey),he(this,"publicKey",n.compressedPublicKey)}else he(this,"privateKey",null),he(this,"publicKey",Be(f));he(this,"parentFingerprint",d),he(this,"fingerprint",ya(Mo(Rd(this.publicKey)),0,4)),he(this,"address",c1(this.publicKey)),he(this,"chainCode",b),he(this,"index",t),he(this,"depth",r),o==null?(he(this,"mnemonic",null),he(this,"path",null)):typeof o=="string"?(he(this,"mnemonic",null),he(this,"path",o)):(he(this,"mnemonic",o),he(this,"path",o.path))}get extendedKey(){if(this.depth>=256)throw new Error("Depth too large!");return Ree(O0([this.privateKey!=null?"0x0488ADE4":"0x0488B21E",Be(this.depth),this.parentFingerprint,q0(Be(this.index),4),this.chainCode,this.privateKey!=null?O0(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new Kc(Ot,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(e){if(e>4294967295)throw new Error("invalid index - "+String(e));let a=this.path;a&&(a+="/"+(e&~Nt));let f=new Uint8Array(37);if(e&Nt){if(!this.privateKey)throw new Error("cannot derive child of neutered node");f.set(Se(this.privateKey),1),a&&(a+="'")}else f.set(Se(this.publicKey));for(let l=24;l>=0;l-=8)f[33+(l>>3)]=e>>24-l&255;let d=Se(s8(Jb.sha512,this.chainCode,f)),b=d.slice(0,32),t=d.slice(32),r=null,o=null;this.privateKey?r=qm(Ee.from(b).add(this.privateKey).mod(Cye)):o=new a1(Be(b))._addPoint(this.publicKey);let n=a,i=this.mnemonic;return i&&(n=Object.freeze({phrase:i.phrase,path:a,locale:i.locale||"en"})),new Kc(Ot,r,o,this.fingerprint,qm(t),e,this.depth+1,n)}derivePath(e){let a=e.split("/");if(a.length===0||a[0]==="m"&&this.depth!==0)throw new Error("invalid path - "+e);a[0]==="m"&&a.shift();let f=this;for(let d=0;d<a.length;d++){let b=a[d];if(b.match(/^[0-9]+'$/)){let t=parseInt(b.substring(0,b.length-1));if(t>=Nt)throw new Error("invalid path index - "+b);f=f._derive(Nt+t)}else if(b.match(/^[0-9]+$/)){let t=parseInt(b);if(t>=Nt)throw new Error("invalid path index - "+b);f=f._derive(t)}else throw new Error("invalid path component - "+b)}return f}static _fromSeed(e,a){let f=Se(e);if(f.length<16||f.length>64)throw new Error("invalid seed");let d=Se(s8(Jb.sha512,Rye,f));return new Kc(Ot,qm(d.slice(0,32)),null,"0x00000000",qm(d.slice(32)),0,0,a)}static fromMnemonic(e,a,f){return f=eF(f),e=c5(Mt(e,f),f),Kc._fromSeed(aF(e,a),{phrase:e,path:"m",locale:f.locale})}static fromSeed(e){return Kc._fromSeed(e,null)}static fromExtendedKey(e){let a=o8.decode(e);(a.length!==82||Ree(a.slice(0,78))!==e)&&ko.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let f=a[4],d=Be(a.slice(5,9)),b=parseInt(Be(a.slice(9,13)).substring(2),16),t=Be(a.slice(13,45)),r=a.slice(45,78);switch(Be(a.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new Kc(Ot,null,Be(r),d,t,b,f,null);case"0x0488ade4":case"0x04358394 ":if(r[0]!==0)break;return new Kc(Ot,Be(r.slice(1)),null,d,t,b,f,null)}return ko.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}};function aF(c,e){e||(e="");let a=J0("mnemonic"+e,cd.NFKD);return e5(J0(c,cd.NFKD),a,2048,64,"sha512")}function Mt(c,e){e=eF(e),ko.checkNormalize();let a=e.split(c);if(a.length%3!==0)throw new Error("invalid mnemonic");let f=Se(new Uint8Array(Math.ceil(11*a.length/8))),d=0;for(let n=0;n<a.length;n++){let i=e.getWordIndex(a[n].normalize("NFKD"));if(i===-1)throw new Error("invalid mnemonic");for(let l=0;l<11;l++)i&1<<10-l&&(f[d>>3]|=1<<7-d%8),d++}let b=32*a.length/3,t=a.length/3,r=Bee(t);if((Se(Rd(f.slice(0,b/8)))[0]&r)!==(f[f.length-1]&r))throw new Error("invalid checksum");return Be(f.slice(0,b/8))}function c5(c,e){if(e=eF(e),c=Se(c),c.length%4!==0||c.length<16||c.length>32)throw new Error("invalid entropy");let a=[0],f=11;for(let t=0;t<c.length;t++)f>8?(a[a.length-1]<<=8,a[a.length-1]|=c[t],f-=8):(a[a.length-1]<<=f,a[a.length-1]|=c[t]>>8-f,a.push(c[t]&Bye(8-f)),f+=3);let d=c.length/4,b=Se(Rd(c))[0]&Bee(d);return a[a.length-1]<<=d,a[a.length-1]|=b>>8-d,e.join(a.map(t=>e.getWord(t)))}function Pee(c,e){try{return Mt(c,e),!0}catch{}return!1}function Tee(c){return(typeof c!="number"||c<0||c>=Nt||c%1)&&ko.throwArgumentError("invalid account index","index",c),`m/44'/60'/${c}'/0/0`}s();x();s();x();s();x();var Oee="random/5.7.0";var cF=new X(Oee);function Pye(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof globalThis<"u")return globalThis;throw new Error("unable to locate global object")}var Nee=Pye(),Gm=Nee.crypto||Nee.msCrypto;(!Gm||!Gm.getRandomValues)&&(cF.warn("WARNING: Missing strong random number source"),Gm={getRandomValues:function(c){return cF.throwError("no secure random source avaialble",X.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});function Zb(c){(c<=0||c>1024||c%1||c!=c)&&cF.throwArgumentError("invalid length","length",c);let e=new Uint8Array(c);return Gm.getRandomValues(e),Se(e)}s();x();function Uo(c){c=c.slice();for(let e=c.length-1;e>0;e--){let a=Math.floor(Math.random()*(e+1)),f=c[e];c[e]=c[a],c[a]=f}return c}s();x();s();x();var bF=Fe(dF());s();x();var zm="json-wallets/5.7.0";s();x();function l8(c){return typeof c=="string"&&c.substring(0,2)!=="0x"&&(c="0x"+c),Se(c)}function Dt(c,e){for(c=String(c);c.length<e;)c="0"+c;return c}function qo(c){return typeof c=="string"?J0(c,cd.NFKC):Se(c)}function Za(c,e){let a=c,f=e.toLowerCase().split("/");for(let d=0;d<f.length;d++){let b=null;for(let t in a)if(t.toLowerCase()===f[d]){b=a[t];break}if(b===null)return null;a=b}return a}function Dee(c){let e=Se(c);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let a=Be(e);return[a.substring(2,10),a.substring(10,14),a.substring(14,18),a.substring(18,22),a.substring(22,34)].join("-")}var Tye=new X(zm),tF=class extends t2{isCrowdsaleAccount(e){return!!(e&&e._isCrowdsaleAccount)}};function rF(c,e){let a=JSON.parse(c);e=qo(e);let f=M0(Za(a,"ethaddr")),d=l8(Za(a,"encseed"));(!d||d.length%16!==0)&&Tye.throwArgumentError("invalid encseed","json",c);let b=Se(e5(e,e,2e3,32,"sha256")).slice(0,16),t=d.slice(0,16),r=d.slice(16),o=new bF.default.ModeOfOperation.cbc(b,t),n=bF.default.padding.pkcs7.strip(Se(o.decrypt(r))),i="";for(let u=0;u<n.length;u++)i+=String.fromCharCode(n[u]);let l=J0(i),h=N0(l);return new tF({_isCrowdsaleAccount:!0,address:f,privateKey:h})}s();x();function jm(c){let e=null;try{e=JSON.parse(c)}catch{return!1}return e.encseed&&e.ethaddr}function Hm(c){let e=null;try{e=JSON.parse(c)}catch{return!1}return!(!e.version||parseInt(e.version)!==e.version||parseInt(e.version)!==3)}function nF(c){if(jm(c))try{return M0(JSON.parse(c).ethaddr)}catch{return null}if(Hm(c))try{return M0(JSON.parse(c).address)}catch{return null}return null}s();x();var u8=Fe(dF()),$m=Fe(Uee());var Oye=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},oF=new X(zm);function qee(c){return c!=null&&c.mnemonic&&c.mnemonic.phrase}var sF=class extends t2{isKeystoreAccount(e){return!!(e&&e._isKeystoreAccount)}};function Nye(c,e,a){if(Za(c,"crypto/cipher")==="aes-128-ctr"){let d=l8(Za(c,"crypto/cipherparams/iv")),b=new u8.default.Counter(d),t=new u8.default.ModeOfOperation.ctr(e,b);return Se(t.decrypt(a))}return null}function Gee(c,e){let a=l8(Za(c,"crypto/ciphertext"));if(Be(N0(O0([e.slice(16,32),a]))).substring(2)!==Za(c,"crypto/mac").toLowerCase())throw new Error("invalid password");let d=Nye(c,e.slice(0,16),a);d||oF.throwError("unsupported cipher",X.errors.UNSUPPORTED_OPERATION,{operation:"decrypt"});let b=e.slice(32,64),t=c1(d);if(c.address){let o=c.address.toLowerCase();if(o.substring(0,2)!=="0x"&&(o="0x"+o),M0(o)!==t)throw new Error("address mismatch")}let r={_isKeystoreAccount:!0,address:t,privateKey:Be(d)};if(Za(c,"x-ethers/version")==="0.1"){let o=l8(Za(c,"x-ethers/mnemonicCiphertext")),n=l8(Za(c,"x-ethers/mnemonicCounter")),i=new u8.default.Counter(n),l=new u8.default.ModeOfOperation.ctr(b,i),h=Za(c,"x-ethers/path")||x8,u=Za(c,"x-ethers/locale")||"en",g=Se(l.decrypt(o));try{let E=c5(g,u),_=Kc.fromMnemonic(E,null,u).derivePath(h);if(_.privateKey!=r.privateKey)throw new Error("mnemonic mismatch");r.mnemonic=_.mnemonic}catch(E){if(E.code!==X.errors.INVALID_ARGUMENT||E.argument!=="wordlist")throw E}}return new sF(r)}function zee(c,e,a,f,d){return Se(e5(c,e,a,f,d))}function Mye(c,e,a,f,d){return Promise.resolve(zee(c,e,a,f,d))}function jee(c,e,a,f,d){let b=qo(e),t=Za(c,"crypto/kdf");if(t&&typeof t=="string"){let r=function(o,n){return oF.throwArgumentError("invalid key-derivation function parameters",o,n)};if(t.toLowerCase()==="scrypt"){let o=l8(Za(c,"crypto/kdfparams/salt")),n=parseInt(Za(c,"crypto/kdfparams/n")),i=parseInt(Za(c,"crypto/kdfparams/r")),l=parseInt(Za(c,"crypto/kdfparams/p"));(!n||!i||!l)&&r("kdf",t),(n&n-1)!==0&&r("N",n);let h=parseInt(Za(c,"crypto/kdfparams/dklen"));return h!==32&&r("dklen",h),f(b,o,n,i,l,64,d)}else if(t.toLowerCase()==="pbkdf2"){let o=l8(Za(c,"crypto/kdfparams/salt")),n=null,i=Za(c,"crypto/kdfparams/prf");i==="hmac-sha256"?n="sha256":i==="hmac-sha512"?n="sha512":r("prf",i);let l=parseInt(Za(c,"crypto/kdfparams/c")),h=parseInt(Za(c,"crypto/kdfparams/dklen"));return h!==32&&r("dklen",h),a(b,o,l,h,n)}}return oF.throwArgumentError("unsupported key-derivation function","kdf",t)}function Hee(c,e){let a=JSON.parse(c),f=jee(a,e,zee,$m.default.syncScrypt);return Gee(a,f)}function $ee(c,e,a){return Oye(this,void 0,void 0,function*(){let f=JSON.parse(c),d=yield jee(f,e,Mye,$m.default.scrypt,a);return Gee(f,d)})}function xF(c,e,a,f){try{if(M0(c.address)!==c1(c.privateKey))throw new Error("address/privateKey mismatch");if(qee(c)){let _=c.mnemonic;if(Kc.fromMnemonic(_.phrase,null,_.locale).derivePath(_.path||x8).privateKey!=c.privateKey)throw new Error("mnemonic mismatch")}}catch(_){return Promise.reject(_)}typeof a=="function"&&!f&&(f=a,a={}),a||(a={});let d=Se(c.privateKey),b=qo(e),t=null,r=null,o=null;if(qee(c)){let _=c.mnemonic;t=Se(Mt(_.phrase,_.locale||"en")),r=_.path||x8,o=_.locale||"en"}let n=a.client;n||(n="ethers.js");let i=null;a.salt?i=Se(a.salt):i=Zb(32);let l=null;if(a.iv){if(l=Se(a.iv),l.length!==16)throw new Error("invalid iv")}else l=Zb(16);let h=null;if(a.uuid){if(h=Se(a.uuid),h.length!==16)throw new Error("invalid uuid")}else h=Zb(16);let u=1<<17,g=8,E=1;return a.scrypt&&(a.scrypt.N&&(u=a.scrypt.N),a.scrypt.r&&(g=a.scrypt.r),a.scrypt.p&&(E=a.scrypt.p)),$m.default.scrypt(b,i,u,g,E,64,f).then(_=>{_=Se(_);let F=_.slice(0,16),L=_.slice(16,32),U=_.slice(32,64),O=new u8.default.Counter(l),H=new u8.default.ModeOfOperation.ctr(F,O),P=Se(H.encrypt(d)),A=N0(O0([L,P])),I={address:c.address.substring(2).toLowerCase(),id:Dee(h),version:3,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:Be(l).substring(2)},ciphertext:Be(P).substring(2),kdf:"scrypt",kdfparams:{salt:Be(i).substring(2),n:u,dklen:32,p:E,r:g},mac:A.substring(2)}};if(t){let K=Zb(16),j=new u8.default.Counter(K),J=new u8.default.ModeOfOperation.ctr(U,j),V=Se(J.encrypt(t)),S=new Date,y=S.getUTCFullYear()+"-"+Dt(S.getUTCMonth()+1,2)+"-"+Dt(S.getUTCDate(),2)+"T"+Dt(S.getUTCHours(),2)+"-"+Dt(S.getUTCMinutes(),2)+"-"+Dt(S.getUTCSeconds(),2)+".0Z";I["x-ethers"]={client:n,gethFilename:"UTC--"+y+"--"+I.address,mnemonicCounter:Be(K).substring(2),mnemonicCiphertext:Be(V).substring(2),path:r,locale:o,version:"0.1"}}return JSON.stringify(I)})}function Vee(c,e,a){if(jm(c)){a&&a(0);let f=rF(c,e);return a&&a(1),Promise.resolve(f)}return Hm(c)?$ee(c,e,a):Promise.reject(new Error("invalid JSON wallet"))}function Kee(c,e){if(jm(c))return rF(c,e);if(Hm(c))return Hee(c,e);throw new Error("invalid JSON wallet")}s();x();var Qee="wallet/5.7.0";var Wee=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},kt=new X(Qee);function Dye(c){return c!=null&&n0(c.privateKey,32)&&c.address!=null}function kye(c){let e=c.mnemonic;return e&&e.phrase}var V1=class extends fd{constructor(e,a){if(super(),Dye(e)){let f=new a1(e.privateKey);if(he(this,"_signingKey",()=>f),he(this,"address",c1(this.publicKey)),this.address!==M0(e.address)&&kt.throwArgumentError("privateKey/address mismatch","privateKey","[REDACTED]"),kye(e)){let d=e.mnemonic;he(this,"_mnemonic",()=>({phrase:d.phrase,path:d.path||x8,locale:d.locale||"en"}));let b=this.mnemonic,t=Kc.fromMnemonic(b.phrase,null,b.locale).derivePath(b.path);c1(t.privateKey)!==this.address&&kt.throwArgumentError("mnemonic/address mismatch","privateKey","[REDACTED]")}else he(this,"_mnemonic",()=>null)}else{if(a1.isSigningKey(e))e.curve!=="secp256k1"&&kt.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),he(this,"_signingKey",()=>e);else{typeof e=="string"&&e.match(/^[0-9a-f]*$/i)&&e.length===64&&(e="0x"+e);let f=new a1(e);he(this,"_signingKey",()=>f)}he(this,"_mnemonic",()=>null),he(this,"address",c1(this.publicKey))}a&&!Fd.isProvider(a)&&kt.throwArgumentError("invalid provider","provider",a),he(this,"provider",a||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(e){return new V1(this,e)}signTransaction(e){return wa(e).then(a=>{a.from!=null&&(M0(a.from)!==this.address&&kt.throwArgumentError("transaction from address mismatch","transaction.from",e.from),delete a.from);let f=this._signingKey().signDigest(N0(To(a)));return To(a,f)})}signMessage(e){return Wee(this,void 0,void 0,function*(){return mo(this._signingKey().signDigest(_t(e)))})}_signTypedData(e,a,f){return Wee(this,void 0,void 0,function*(){let d=yield Wa.resolveNames(e,a,f,b=>(this.provider==null&&kt.throwError("cannot resolve ENS names without a provider",X.errors.UNSUPPORTED_OPERATION,{operation:"resolveName",value:b}),this.provider.resolveName(b)));return mo(this._signingKey().signDigest(Wa.hash(d.domain,a,d.value)))})}encrypt(e,a,f){if(typeof a=="function"&&!f&&(f=a,a={}),f&&typeof f!="function")throw new Error("invalid callback");return a||(a={}),xF(this,e,a,f)}static createRandom(e){let a=Zb(16);e||(e={}),e.extraEntropy&&(a=Se(ya(N0(O0([a,e.extraEntropy])),0,16)));let f=c5(a,e.locale);return V1.fromMnemonic(f,e.path,e.locale)}static fromEncryptedJson(e,a,f){return Vee(e,a,f).then(d=>new V1(d))}static fromEncryptedJsonSync(e,a){return new V1(Kee(e,a))}static fromMnemonic(e,a,f){return a||(a=x8),new V1(Kc.fromMnemonic(e,null,f).derivePath(a))}};function Jee(c,e){return Z4(_t(c),e)}function Zee(c,e,a,f){return Z4(Wa.hash(c,e,a),f)}var ng={};v0(ng,{AlchemyProvider:()=>Ht,AlchemyWebSocketProvider:()=>Zo,AnkrProvider:()=>Yo,BaseProvider:()=>Xb,CloudflareProvider:()=>Xo,EtherscanProvider:()=>es,FallbackProvider:()=>cs,Formatter:()=>e0,InfuraProvider:()=>Vt,InfuraWebSocketProvider:()=>ds,IpcProvider:()=>SF,JsonRpcBatchProvider:()=>tg,JsonRpcProvider:()=>Bd,JsonRpcSigner:()=>zt,NodesmithProvider:()=>bs,PocketProvider:()=>ts,Provider:()=>Fd,Resolver:()=>Gt,StaticJsonRpcProvider:()=>Jo,UrlJsonRpcProvider:()=>Qc,Web3Provider:()=>rs,WebSocketProvider:()=>m8,getDefaultProvider:()=>rg,getNetwork:()=>Go,isCommunityResourcable:()=>hF,isCommunityResource:()=>Ho,showThrottleMessage:()=>Yb});s();x();s();x();s();x();var Yee="networks/5.7.1";var Xee=new X(Yee);function Uye(c){return c&&typeof c.renetwork=="function"}function h8(c){let e=function(a,f){f==null&&(f={});let d=[];if(a.InfuraProvider&&f.infura!=="-")try{d.push(new a.InfuraProvider(c,f.infura))}catch{}if(a.EtherscanProvider&&f.etherscan!=="-")try{d.push(new a.EtherscanProvider(c,f.etherscan))}catch{}if(a.AlchemyProvider&&f.alchemy!=="-")try{d.push(new a.AlchemyProvider(c,f.alchemy))}catch{}if(a.PocketProvider&&f.pocket!=="-"){let b=["goerli","ropsten","rinkeby","sepolia"];try{let t=new a.PocketProvider(c,f.pocket);t.network&&b.indexOf(t.network.name)===-1&&d.push(t)}catch{}}if(a.CloudflareProvider&&f.cloudflare!=="-")try{d.push(new a.CloudflareProvider(c))}catch{}if(a.AnkrProvider&&f.ankr!=="-")try{let b=["ropsten"],t=new a.AnkrProvider(c,f.ankr);t.network&&b.indexOf(t.network.name)===-1&&d.push(t)}catch{}if(d.length===0)return null;if(a.FallbackProvider){let b=1;return f.quorum!=null?b=f.quorum:c==="homestead"&&(b=2),new a.FallbackProvider(d,b)}return d[0]};return e.renetwork=function(a){return h8(a)},e}function Km(c,e){let a=function(f,d){return f.JsonRpcProvider?new f.JsonRpcProvider(c,e):null};return a.renetwork=function(f){return Km(c,f)},a}var e0e={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:h8("homestead")},a0e={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:h8("ropsten")},c0e={chainId:63,name:"classicMordor",_defaultProvider:Km("https://www.ethercluster.com/mordor","classicMordor")},Vm={unspecified:{chainId:0,name:"unspecified"},homestead:e0e,mainnet:e0e,morden:{chainId:2,name:"morden"},ropsten:a0e,testnet:a0e,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:h8("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:h8("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:h8("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:h8("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:Km("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:c0e,classicTestnet:c0e,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:Km("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:h8("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:h8("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function Go(c){if(c==null)return null;if(typeof c=="number"){for(let f in Vm){let d=Vm[f];if(d.chainId===c)return{name:d.name,chainId:d.chainId,ensAddress:d.ensAddress||null,_defaultProvider:d._defaultProvider||null}}return{chainId:c,name:"unknown"}}if(typeof c=="string"){let f=Vm[c];return f==null?null:{name:f.name,chainId:f.chainId,ensAddress:f.ensAddress,_defaultProvider:f._defaultProvider||null}}let e=Vm[c.name];if(!e)return typeof c.chainId!="number"&&Xee.throwArgumentError("invalid network chainId","network",c),c;c.chainId!==0&&c.chainId!==e.chainId&&Xee.throwArgumentError("network chainId mismatch","network",c);let a=c._defaultProvider||null;return a==null&&e._defaultProvider&&(Uye(e._defaultProvider)?a=e._defaultProvider.renetwork(c):a=e._defaultProvider),{name:c.name,chainId:e.chainId,ensAddress:c.ensAddress||e.ensAddress||null,_defaultProvider:a}}s();x();s();x();s();x();var f0e="web/5.7.1";s();x();var qye=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})};function d0e(c,e){return qye(this,void 0,void 0,function*(){e==null&&(e={});let a={method:e.method||"GET",headers:e.headers||{},body:e.body||void 0};if(e.skipFetchSetup!==!0&&(a.mode="cors",a.cache="no-cache",a.credentials="same-origin",a.redirect="follow",a.referrer="client"),e.fetchOptions!=null){let t=e.fetchOptions;t.mode&&(a.mode=t.mode),t.cache&&(a.cache=t.cache),t.credentials&&(a.credentials=t.credentials),t.redirect&&(a.redirect=t.redirect),t.referrer&&(a.referrer=t.referrer)}let f=yield fetch(c,a),d=yield f.arrayBuffer(),b={};return f.headers.forEach?f.headers.forEach((t,r)=>{b[r.toLowerCase()]=t}):f.headers.keys().forEach(t=>{b[t.toLowerCase()]=f.headers.get(t)}),{headers:b,statusCode:f.status,statusMessage:f.statusText,body:Se(new Uint8Array(d))}})}var Gye=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},K1=new X(f0e);function b0e(c){return new Promise(e=>{setTimeout(e,c)})}function V7(c,e){if(c==null)return null;if(typeof c=="string")return c;if(a8(c)){if(e&&(e.split("/")[0]==="text"||e.split(";")[0].trim()==="application/json"))try{return Ld(c)}catch{}return Be(c)}return c}function zye(c){return J0(c.replace(/%([0-9a-f][0-9a-f])/gi,(e,a)=>String.fromCharCode(parseInt(a,16))))}function lF(c,e,a){let f=typeof c=="object"&&c.throttleLimit!=null?c.throttleLimit:12;K1.assertArgument(f>0&&f%1===0,"invalid connection throttle limit","connection.throttleLimit",f);let d=typeof c=="object"?c.throttleCallback:null,b=typeof c=="object"&&typeof c.throttleSlotInterval=="number"?c.throttleSlotInterval:100;K1.assertArgument(b>0&&b%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",b);let t=typeof c=="object"?!!c.errorPassThrough:!1,r={},o=null,n={method:"GET"},i=!1,l=2*60*1e3;if(typeof c=="string")o=c;else if(typeof c=="object"){if((c==null||c.url==null)&&K1.throwArgumentError("missing URL","connection.url",c),o=c.url,typeof c.timeout=="number"&&c.timeout>0&&(l=c.timeout),c.headers)for(let F in c.headers)r[F.toLowerCase()]={key:F,value:String(c.headers[F])},["if-none-match","if-modified-since"].indexOf(F.toLowerCase())>=0&&(i=!0);if(n.allowGzip=!!c.allowGzip,c.user!=null&&c.password!=null){o.substring(0,6)!=="https:"&&c.allowInsecureAuthentication!==!0&&K1.throwError("basic authentication requires a secure https url",X.errors.INVALID_ARGUMENT,{argument:"url",url:o,user:c.user,password:"[REDACTED]"});let F=c.user+":"+c.password;r.authorization={key:"Authorization",value:"Basic "+wt(J0(F))}}c.skipFetchSetup!=null&&(n.skipFetchSetup=!!c.skipFetchSetup),c.fetchOptions!=null&&(n.fetchOptions=ea(c.fetchOptions))}let h=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),u=o?o.match(h):null;if(u)try{let F={statusCode:200,statusMessage:"OK",headers:{"content-type":u[1]||"text/plain"},body:u[2]?yt(u[3]):zye(u[3])},L=F.body;return a&&(L=a(F.body,F)),Promise.resolve(L)}catch(F){K1.throwError("processing response error",X.errors.SERVER_ERROR,{body:V7(u[1],u[2]),error:F,requestBody:null,requestMethod:"GET",url:o})}e&&(n.method="POST",n.body=e,r["content-type"]==null&&(r["content-type"]={key:"Content-Type",value:"application/octet-stream"}),r["content-length"]==null&&(r["content-length"]={key:"Content-Length",value:String(e.length)}));let g={};Object.keys(r).forEach(F=>{let L=r[F];g[L.key]=L.value}),n.headers=g;let E=function(){let F=null;return{promise:new Promise(function(O,H){l&&(F=setTimeout(()=>{F!=null&&(F=null,H(K1.makeError("timeout",X.errors.TIMEOUT,{requestBody:V7(n.body,g["content-type"]),requestMethod:n.method,timeout:l,url:o})))},l))}),cancel:function(){F!=null&&(clearTimeout(F),F=null)}}}(),_=function(){return Gye(this,void 0,void 0,function*(){for(let F=0;F<f;F++){let L=null;try{if(L=yield d0e(o,n),F<f){if(L.statusCode===301||L.statusCode===302){let O=L.headers.location||"";if(n.method==="GET"&&O.match(/^https:/)){o=L.headers.location;continue}}else if(L.statusCode===429){let O=!0;if(d&&(O=yield d(F,o)),O){let H=0,P=L.headers["retry-after"];typeof P=="string"&&P.match(/^[1-9][0-9]*$/)?H=parseInt(P)*1e3:H=b*parseInt(String(Math.random()*Math.pow(2,F))),yield b0e(H);continue}}}}catch(O){L=O.response,L==null&&(E.cancel(),K1.throwError("missing response",X.errors.SERVER_ERROR,{requestBody:V7(n.body,g["content-type"]),requestMethod:n.method,serverError:O,url:o}))}let U=L.body;if(i&&L.statusCode===304?U=null:!t&&(L.statusCode<200||L.statusCode>=300)&&(E.cancel(),K1.throwError("bad response",X.errors.SERVER_ERROR,{status:L.statusCode,headers:L.headers,body:V7(U,L.headers?L.headers["content-type"]:null),requestBody:V7(n.body,g["content-type"]),requestMethod:n.method,url:o})),a)try{let O=yield a(U,L);return E.cancel(),O}catch(O){if(O.throttleRetry&&F<f){let H=!0;if(d&&(H=yield d(F,o)),H){let P=b*parseInt(String(Math.random()*Math.pow(2,F)));yield b0e(P);continue}}E.cancel(),K1.throwError("processing response error",X.errors.SERVER_ERROR,{body:V7(U,L.headers?L.headers["content-type"]:null),error:O,requestBody:V7(n.body,g["content-type"]),requestMethod:n.method,url:o})}return E.cancel(),U}return K1.throwError("failed response",X.errors.SERVER_ERROR,{requestBody:V7(n.body,g["content-type"]),requestMethod:n.method,url:o})})}();return Promise.race([E.promise,_])}function Q1(c,e,a){let f=(b,t)=>{let r=null;if(b!=null)try{r=JSON.parse(Ld(b))}catch(o){K1.throwError("invalid JSON",X.errors.SERVER_ERROR,{body:b,error:o})}return a&&(r=a(r,t)),r},d=null;if(e!=null){d=J0(e);let b=typeof c=="string"?{url:c}:ea(c);b.headers?Object.keys(b.headers).filter(r=>r.toLowerCase()==="content-type").length!==0||(b.headers=ea(b.headers),b.headers["content-type"]="application/json"):b.headers={"content-type":"application/json"},c=b}return lF(c,d,f)}function W1(c,e){return e||(e={}),e=ea(e),e.floor==null&&(e.floor=0),e.ceiling==null&&(e.ceiling=1e4),e.interval==null&&(e.interval=250),new Promise(function(a,f){let d=null,b=!1,t=()=>b?!1:(b=!0,d&&clearTimeout(d),!0);e.timeout&&(d=setTimeout(()=>{t()&&f(new Error("timeout"))},e.timeout));let r=e.retryLimit,o=0;function n(){return c().then(function(i){if(i!==void 0)t()&&a(i);else if(e.oncePoll)e.oncePoll.once("poll",n);else if(e.onceBlock)e.onceBlock.once("block",n);else if(!b){if(o++,o>r){t()&&f(new Error("retry limit reached"));return}let l=e.interval*parseInt(String(Math.random()*Math.pow(2,o)));l<e.floor&&(l=e.floor),l>e.ceiling&&(l=e.ceiling),setTimeout(n,l)}return null},function(i){t()&&f(i)})}n()})}var yF=Fe(i0e());s();x();var ia="providers/5.7.2";s();x();var jo=new X(ia),e0=class{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){let e={},a=this.address.bind(this),f=this.bigNumber.bind(this),d=this.blockTag.bind(this),b=this.data.bind(this),t=this.hash.bind(this),r=this.hex.bind(this),o=this.number.bind(this),n=this.type.bind(this),i=l=>this.data(l,!0);return e.transaction={hash:t,type:n,accessList:e0.allowNull(this.accessList.bind(this),null),blockHash:e0.allowNull(t,null),blockNumber:e0.allowNull(o,null),transactionIndex:e0.allowNull(o,null),confirmations:e0.allowNull(o,null),from:a,gasPrice:e0.allowNull(f),maxPriorityFeePerGas:e0.allowNull(f),maxFeePerGas:e0.allowNull(f),gasLimit:f,to:e0.allowNull(a,null),value:f,nonce:o,data:b,r:e0.allowNull(this.uint256),s:e0.allowNull(this.uint256),v:e0.allowNull(o),creates:e0.allowNull(a,null),raw:e0.allowNull(b)},e.transactionRequest={from:e0.allowNull(a),nonce:e0.allowNull(o),gasLimit:e0.allowNull(f),gasPrice:e0.allowNull(f),maxPriorityFeePerGas:e0.allowNull(f),maxFeePerGas:e0.allowNull(f),to:e0.allowNull(a),value:e0.allowNull(f),data:e0.allowNull(i),type:e0.allowNull(o),accessList:e0.allowNull(this.accessList.bind(this),null)},e.receiptLog={transactionIndex:o,blockNumber:o,transactionHash:t,address:a,topics:e0.arrayOf(t),data:b,logIndex:o,blockHash:t},e.receipt={to:e0.allowNull(this.address,null),from:e0.allowNull(this.address,null),contractAddress:e0.allowNull(a,null),transactionIndex:o,root:e0.allowNull(r),gasUsed:f,logsBloom:e0.allowNull(b),blockHash:t,transactionHash:t,logs:e0.arrayOf(this.receiptLog.bind(this)),blockNumber:o,confirmations:e0.allowNull(o,null),cumulativeGasUsed:f,effectiveGasPrice:e0.allowNull(f),status:e0.allowNull(o),type:n},e.block={hash:e0.allowNull(t),parentHash:t,number:o,timestamp:o,nonce:e0.allowNull(r),difficulty:this.difficulty.bind(this),gasLimit:f,gasUsed:f,miner:e0.allowNull(a),extraData:b,transactions:e0.allowNull(e0.arrayOf(t)),baseFeePerGas:e0.allowNull(f)},e.blockWithTransactions=ea(e.block),e.blockWithTransactions.transactions=e0.allowNull(e0.arrayOf(this.transactionResponse.bind(this))),e.filter={fromBlock:e0.allowNull(d,void 0),toBlock:e0.allowNull(d,void 0),blockHash:e0.allowNull(t,void 0),address:e0.allowNull(a,void 0),topics:e0.allowNull(this.topics.bind(this),void 0)},e.filterLog={blockNumber:e0.allowNull(o),blockHash:e0.allowNull(t),transactionIndex:o,removed:e0.allowNull(this.boolean.bind(this)),address:a,data:e0.allowFalsish(b,"0x"),topics:e0.arrayOf(t),transactionHash:t,logIndex:o},e}accessList(e){return s2(e||[])}number(e){return e==="0x"?0:Ee.from(e).toNumber()}type(e){return e==="0x"||e==null?0:Ee.from(e).toNumber()}bigNumber(e){return Ee.from(e)}boolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){if(e=e.toLowerCase(),e==="true")return!0;if(e==="false")return!1}throw new Error("invalid boolean - "+e)}hex(e,a){return typeof e=="string"&&(!a&&e.substring(0,2)!=="0x"&&(e="0x"+e),n0(e))?e.toLowerCase():jo.throwArgumentError("invalid hash","value",e)}data(e,a){let f=this.hex(e,a);if(f.length%2!==0)throw new Error("invalid data; odd-length - "+e);return f}address(e){return M0(e)}callAddress(e){if(!n0(e,32))return null;let a=M0(ya(e,12));return a===sm?null:a}contractAddress(e){return K4(e)}blockTag(e){if(e==null)return"latest";if(e==="earliest")return"0x0";switch(e){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return e}if(typeof e=="number"||n0(e))return kb(e);throw new Error("invalid blockTag")}hash(e,a){let f=this.hex(e,a);return Cf(f)!==32?jo.throwArgumentError("invalid hash","value",e):f}difficulty(e){if(e==null)return null;let a=Ee.from(e);try{return a.toNumber()}catch{}return null}uint256(e){if(!n0(e))throw new Error("invalid uint256");return q0(e,32)}_block(e,a){e.author!=null&&e.miner==null&&(e.miner=e.author);let f=e._difficulty!=null?e._difficulty:e.difficulty,d=e0.check(a,e);return d._difficulty=f==null?null:Ee.from(f),d}block(e){return this._block(e,this.formats.block)}blockWithTransactions(e){return this._block(e,this.formats.blockWithTransactions)}transactionRequest(e){return e0.check(this.formats.transactionRequest,e)}transactionResponse(e){e.gas!=null&&e.gasLimit==null&&(e.gasLimit=e.gas),e.to&&Ee.from(e.to).isZero()&&(e.to="0x0000000000000000000000000000000000000000"),e.input!=null&&e.data==null&&(e.data=e.input),e.to==null&&e.creates==null&&(e.creates=this.contractAddress(e)),(e.type===1||e.type===2)&&e.accessList==null&&(e.accessList=[]);let a=e0.check(this.formats.transaction,e);if(e.chainId!=null){let f=e.chainId;n0(f)&&(f=Ee.from(f).toNumber()),a.chainId=f}else{let f=e.networkId;f==null&&a.v==null&&(f=e.chainId),n0(f)&&(f=Ee.from(f).toNumber()),typeof f!="number"&&a.v!=null&&(f=(a.v-35)/2,f<0&&(f=0),f=parseInt(f)),typeof f!="number"&&(f=0),a.chainId=f}return a.blockHash&&a.blockHash.replace(/0/g,"")==="x"&&(a.blockHash=null),a}transaction(e){return Om(e)}receiptLog(e){return e0.check(this.formats.receiptLog,e)}receipt(e){let a=e0.check(this.formats.receipt,e);if(a.root!=null)if(a.root.length<=4){let f=Ee.from(a.root).toNumber();f===0||f===1?(a.status!=null&&a.status!==f&&jo.throwArgumentError("alt-root-status/status mismatch","value",{root:a.root,status:a.status}),a.status=f,delete a.root):jo.throwArgumentError("invalid alt-root-status","value.root",a.root)}else a.root.length!==66&&jo.throwArgumentError("invalid root hash","value.root",a.root);return a.status!=null&&(a.byzantium=!0),a}topics(e){return Array.isArray(e)?e.map(a=>this.topics(a)):e!=null?this.hash(e,!0):null}filter(e){return e0.check(this.formats.filter,e)}filterLog(e){return e0.check(this.formats.filterLog,e)}static check(e,a){let f={};for(let d in e)try{let b=e[d](a[d]);b!==void 0&&(f[d]=b)}catch(b){throw b.checkKey=d,b.checkValue=a[d],b}return f}static allowNull(e,a){return function(f){return f==null?a:e(f)}}static allowFalsish(e,a){return function(f){return f?e(f):a}}static arrayOf(e){return function(a){if(!Array.isArray(a))throw new Error("not an array");let f=[];return a.forEach(function(d){f.push(e(d))}),f}}};function hF(c){return c&&typeof c.isCommunityResource=="function"}function Ho(c){return hF(c)&&c.isCommunityResource()}var o0e=!1;function Yb(){o0e||(o0e=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}var S0=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},G0=new X(ia),Jye=10;function s0e(c){return c==null?"null":(Cf(c)!==32&&G0.throwArgumentError("invalid topic","topic",c),c.toLowerCase())}function x0e(c){for(c=c.slice();c.length>0&&c[c.length-1]==null;)c.pop();return c.map(e=>{if(Array.isArray(e)){let a={};e.forEach(d=>{a[s0e(d)]=!0});let f=Object.keys(a);return f.sort(),f.join("|")}else return s0e(e)}).join("&")}function Zye(c){return c===""?[]:c.split(/&/g).map(e=>{if(e==="")return[];let a=e.split("|").map(f=>f==="null"?null:f);return a.length===1?a[0]:a})}function qt(c){if(typeof c=="string"){if(c=c.toLowerCase(),Cf(c)===32)return"tx:"+c;if(c.indexOf(":")===-1)return c}else{if(Array.isArray(c))return"filter:*:"+x0e(c);if(Em.isForkEvent(c))throw G0.warn("not implemented"),new Error("not implemented");if(c&&typeof c=="object")return"filter:"+(c.address||"*")+":"+x0e(c.topics||[])}throw new Error("invalid event - "+c)}function $o(){return new Date().getTime()}function l0e(c){return new Promise(e=>{setTimeout(e,c)})}var Yye=["block","network","pending","poll"],wF=class{constructor(e,a,f){he(this,"tag",e),he(this,"listener",a),he(this,"once",f),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){let e=this.tag.split(":");return e[0]!=="tx"?null:e[1]}get filter(){let e=this.tag.split(":");if(e[0]!=="filter")return null;let a=e[1],f=Zye(e[2]),d={};return f.length>0&&(d.topics=f),a&&a!=="*"&&(d.address=a),d}pollable(){return this.tag.indexOf(":")>=0||Yye.indexOf(this.tag)>=0}},Xye={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function pF(c){return q0(Ee.from(c).toHexString(),32)}function u0e(c){return o8.encode(O0([c,ya(Rd(Rd(c)),0,4)]))}var m0e=new RegExp("^(ipfs)://(.*)$","i"),h0e=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),m0e,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function Zm(c,e){try{return Ld(Vo(c,e))}catch{}return null}function Vo(c,e){if(c==="0x")return null;let a=Ee.from(ya(c,e,e+32)).toNumber(),f=Ee.from(ya(c,a,a+32)).toNumber();return ya(c,a+32,a+32+f)}function mF(c){return c.match(/^ipfs:\/\/ipfs\//i)?c=c.substring(12):c.match(/^ipfs:\/\//i)?c=c.substring(7):G0.throwArgumentError("unsupported IPFS format","link",c),`https://gateway.ipfs.io/ipfs/${c}`}function p0e(c){let e=Se(c);if(e.length>32)throw new Error("internal; should not happen");let a=new Uint8Array(32);return a.set(e,32-e.length),a}function ewe(c){if(c.length%32===0)return c;let e=new Uint8Array(Math.ceil(c.length/32)*32);return e.set(c),e}function g0e(c){let e=[],a=0;for(let f=0;f<c.length;f++)e.push(null),a+=32;for(let f=0;f<c.length;f++){let d=Se(c[f]);e[f]=p0e(a),e.push(p0e(d.length)),e.push(ewe(d)),a+=32+Math.ceil(d.length/32)*32}return Ec(e)}var Gt=class{constructor(e,a,f,d){he(this,"provider",e),he(this,"name",f),he(this,"address",e.formatter.address(a)),he(this,"_resolvedAddress",d)}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(e=>Ee.from(e).eq(1)).catch(e=>{if(e.code===X.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,e})),this._supportsEip2544}_fetch(e,a){return S0(this,void 0,void 0,function*(){let f={to:this.address,ccipReadEnabled:!0,data:Ec([e,q7(this.name),a||"0x"])},d=!1;(yield this.supportsWildcard())&&(d=!0,f.data=Ec(["0x9061b923",g0e([Co(this.name),f.data])]));try{let b=yield this.provider.call(f);return Se(b).length%32===4&&G0.throwError("resolver threw error",X.errors.CALL_EXCEPTION,{transaction:f,data:b}),d&&(b=Vo(b,0)),b}catch(b){if(b.code===X.errors.CALL_EXCEPTION)return null;throw b}})}_fetchBytes(e,a){return S0(this,void 0,void 0,function*(){let f=yield this._fetch(e,a);return f!=null?Vo(f,0):null})}_getAddress(e,a){let f=Xye[String(e)];if(f==null&&G0.throwError(`unsupported coin type: ${e}`,X.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`}),f.ilk==="eth")return this.provider.formatter.address(a);let d=Se(a);if(f.p2pkh!=null){let b=a.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(b){let t=parseInt(b[1],16);if(b[2].length===t*2&&t>=1&&t<=75)return u0e(O0([[f.p2pkh],"0x"+b[2]]))}}if(f.p2sh!=null){let b=a.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(b){let t=parseInt(b[1],16);if(b[2].length===t*2&&t>=1&&t<=75)return u0e(O0([[f.p2sh],"0x"+b[2]]))}}if(f.prefix!=null){let b=d[1],t=d[0];if(t===0?b!==20&&b!==32&&(t=-1):t=-1,t>=0&&d.length===2+b&&b>=1&&b<=75){let r=yF.default.toWords(d.slice(2));return r.unshift(t),yF.default.encode(f.prefix,r)}}return null}getAddress(e){return S0(this,void 0,void 0,function*(){if(e==null&&(e=60),e===60)try{let d=yield this._fetch("0x3b3b57de");return d==="0x"||d===mt?null:this.provider.formatter.callAddress(d)}catch(d){if(d.code===X.errors.CALL_EXCEPTION)return null;throw d}let a=yield this._fetchBytes("0xf1cb7e06",pF(e));if(a==null||a==="0x")return null;let f=this._getAddress(e,a);return f==null&&G0.throwError("invalid or unsupported coin data",X.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`,coinType:e,data:a}),f})}getAvatar(){return S0(this,void 0,void 0,function*(){let e=[{type:"name",content:this.name}];try{let a=yield this.getText("avatar");if(a==null)return null;for(let f=0;f<h0e.length;f++){let d=a.match(h0e[f]);if(d==null)continue;let b=d[1].toLowerCase();switch(b){case"https":return e.push({type:"url",content:a}),{linkage:e,url:a};case"data":return e.push({type:"data",content:a}),{linkage:e,url:a};case"ipfs":return e.push({type:"ipfs",content:a}),{linkage:e,url:mF(a)};case"erc721":case"erc1155":{let t=b==="erc721"?"0xc87b56dd":"0x0e89341c";e.push({type:b,content:a});let r=this._resolvedAddress||(yield this.getAddress()),o=(d[2]||"").split("/");if(o.length!==2)return null;let n=yield this.provider.formatter.address(o[0]),i=q0(Ee.from(o[1]).toHexString(),32);if(b==="erc721"){let E=this.provider.formatter.callAddress(yield this.provider.call({to:n,data:Ec(["0x6352211e",i])}));if(r!==E)return null;e.push({type:"owner",content:E})}else if(b==="erc1155"){let E=Ee.from(yield this.provider.call({to:n,data:Ec(["0x00fdd58e",q0(r,32),i])}));if(E.isZero())return null;e.push({type:"balance",content:E.toString()})}let l={to:this.provider.formatter.address(o[0]),data:Ec([t,i])},h=Zm(yield this.provider.call(l),0);if(h==null)return null;e.push({type:"metadata-url-base",content:h}),b==="erc1155"&&(h=h.replace("{id}",i.substring(2)),e.push({type:"metadata-url-expanded",content:h})),h.match(/^ipfs:/i)&&(h=mF(h)),e.push({type:"metadata-url",content:h});let u=yield Q1(h);if(!u)return null;e.push({type:"metadata",content:JSON.stringify(u)});let g=u.image;if(typeof g!="string")return null;if(!g.match(/^(https:\/\/|data:)/i)){if(g.match(m0e)==null)return null;e.push({type:"url-ipfs",content:g}),g=mF(g)}return e.push({type:"url",content:g}),{linkage:e,url:g}}}}}catch{}return null})}getContentHash(){return S0(this,void 0,void 0,function*(){let e=yield this._fetchBytes("0xbc1c58d1");if(e==null||e==="0x")return null;let a=e.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(a){let t=parseInt(a[3],16);if(a[4].length===t*2)return"ipfs://"+o8.encode("0x"+a[1])}let f=e.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(f){let t=parseInt(f[3],16);if(f[4].length===t*2)return"ipns://"+o8.encode("0x"+f[1])}let d=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(d&&d[1].length===32*2)return"bzz://"+d[1];let b=e.match(/^0x90b2c605([0-9a-f]*)$/);if(b&&b[1].length===34*2){let t={"=":"","+":"-","/":"_"};return"sia://"+wt("0x"+b[1]).replace(/[=+\/]/g,o=>t[o])}return G0.throwError("invalid or unsupported content hash data",X.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:e})})}getText(e){return S0(this,void 0,void 0,function*(){let a=J0(e);a=O0([pF(64),pF(a.length),a]),a.length%32!==0&&(a=O0([a,q0("0x",32-e.length%32)]));let f=yield this._fetchBytes("0x59d1d43c",Be(a));return f==null||f==="0x"?null:Ld(f)})}},gF=null,awe=1,Xb=class extends Fd{constructor(e){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),he(this,"anyNetwork",e==="any"),this.anyNetwork&&(e=this.detectNetwork()),e instanceof Promise)this._networkPromise=e,e.catch(a=>{}),this._ready().catch(a=>{});else{let a=Ka(new.target,"getNetwork")(e);a?(he(this,"_network",a),this.emit("network",a,null)):G0.throwArgumentError("invalid network","network",e)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return S0(this,void 0,void 0,function*(){if(this._network==null){let e=null;if(this._networkPromise)try{e=yield this._networkPromise}catch{}e==null&&(e=yield this.detectNetwork()),e||G0.throwError("no network detected",X.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=e:he(this,"_network",e),this.emit("network",e,null))}return this._network})}get ready(){return W1(()=>this._ready().then(e=>e,e=>{if(!(e.code===X.errors.NETWORK_ERROR&&e.event==="noNetwork"))throw e}))}static getFormatter(){return gF==null&&(gF=new e0),gF}static getNetwork(e){return Go(e??"homestead")}ccipReadFetch(e,a,f){return S0(this,void 0,void 0,function*(){if(this.disableCcipRead||f.length===0)return null;let d=e.to.toLowerCase(),b=a.toLowerCase(),t=[];for(let r=0;r<f.length;r++){let o=f[r],n=o.replace("{sender}",d).replace("{data}",b),i=o.indexOf("{data}")>=0?null:JSON.stringify({data:b,sender:d}),l=yield Q1({url:n,errorPassThrough:!0},i,(u,g)=>(u.status=g.statusCode,u));if(l.data)return l.data;let h=l.message||"unknown error";if(l.status>=400&&l.status<500)return G0.throwError(`response not found during CCIP fetch: ${h}`,X.errors.SERVER_ERROR,{url:o,errorMessage:h});t.push(h)}return G0.throwError(`error encountered during CCIP fetch: ${t.map(r=>JSON.stringify(r)).join(", ")}`,X.errors.SERVER_ERROR,{urls:f,errorMessages:t})})}_getInternalBlockNumber(e){return S0(this,void 0,void 0,function*(){if(yield this._ready(),e>0)for(;this._internalBlockNumber;){let d=this._internalBlockNumber;try{let b=yield d;if($o()-b.respTime<=e)return b.blockNumber;break}catch{if(this._internalBlockNumber===d)break}}let a=$o(),f=wa({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(d=>null,d=>d)}).then(({blockNumber:d,networkError:b})=>{if(b)throw this._internalBlockNumber===f&&(this._internalBlockNumber=null),b;let t=$o();return d=Ee.from(d).toNumber(),d<this._maxInternalBlockNumber&&(d=this._maxInternalBlockNumber),this._maxInternalBlockNumber=d,this._setFastBlockNumber(d),{blockNumber:d,reqTime:a,respTime:t}});return this._internalBlockNumber=f,f.catch(d=>{this._internalBlockNumber===f&&(this._internalBlockNumber=null)}),(yield f).blockNumber})}poll(){return S0(this,void 0,void 0,function*(){let e=awe++,a=[],f=null;try{f=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(d){this.emit("error",d);return}if(this._setFastBlockNumber(f),this.emit("poll",e,f),f===this._lastBlockNumber){this.emit("didPoll",e);return}if(this._emitted.block===-2&&(this._emitted.block=f-1),Math.abs(this._emitted.block-f)>1e3)G0.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${f})`),this.emit("error",G0.makeError("network block skew detected",X.errors.NETWORK_ERROR,{blockNumber:f,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",f);else for(let d=this._emitted.block+1;d<=f;d++)this.emit("block",d);this._emitted.block!==f&&(this._emitted.block=f,Object.keys(this._emitted).forEach(d=>{if(d==="block")return;let b=this._emitted[d];b!=="pending"&&f-b>12&&delete this._emitted[d]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=f-1),this._events.forEach(d=>{switch(d.type){case"tx":{let b=d.hash,t=this.getTransactionReceipt(b).then(r=>(!r||r.blockNumber==null||(this._emitted["t:"+b]=r.blockNumber,this.emit(b,r)),null)).catch(r=>{this.emit("error",r)});a.push(t);break}case"filter":{if(!d._inflight){d._inflight=!0,d._lastBlockNumber===-2&&(d._lastBlockNumber=f-1);let b=d.filter;b.fromBlock=d._lastBlockNumber+1,b.toBlock=f;let t=b.toBlock-this._maxFilterBlockRange;t>b.fromBlock&&(b.fromBlock=t),b.fromBlock<0&&(b.fromBlock=0);let r=this.getLogs(b).then(o=>{d._inflight=!1,o.length!==0&&o.forEach(n=>{n.blockNumber>d._lastBlockNumber&&(d._lastBlockNumber=n.blockNumber),this._emitted["b:"+n.blockHash]=n.blockNumber,this._emitted["t:"+n.transactionHash]=n.blockNumber,this.emit(b,n)})}).catch(o=>{this.emit("error",o),d._inflight=!1});a.push(r)}break}}}),this._lastBlockNumber=f,Promise.all(a).then(()=>{this.emit("didPoll",e)}).catch(d=>{this.emit("error",d)})})}resetEventsBlock(e){this._lastBlockNumber=e-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return S0(this,void 0,void 0,function*(){return G0.throwError("provider does not support network detection",X.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return S0(this,void 0,void 0,function*(){let e=yield this._ready(),a=yield this.detectNetwork();if(e.chainId!==a.chainId){if(this.anyNetwork)return this._network=a,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",a,e),yield l0e(0),this._network;let f=G0.makeError("underlying network changed",X.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:a});throw this.emit("error",f),f}return e})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(e=>{this._setFastBlockNumber(e)},e=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(e){e&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(e){if(typeof e!="number"||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){let e=$o();return e-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=e,this._fastBlockNumberPromise=this.getBlockNumber().then(a=>((this._fastBlockNumber==null||a>this._fastBlockNumber)&&(this._fastBlockNumber=a),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(e){this._fastBlockNumber!=null&&e<this._fastBlockNumber||(this._fastQueryDate=$o(),(this._fastBlockNumber==null||e>this._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))}waitForTransaction(e,a,f){return S0(this,void 0,void 0,function*(){return this._waitForTransaction(e,a??1,f||0,null)})}_waitForTransaction(e,a,f,d){return S0(this,void 0,void 0,function*(){let b=yield this.getTransactionReceipt(e);return(b?b.confirmations:0)>=a?b:new Promise((t,r)=>{let o=[],n=!1,i=function(){return n?!0:(n=!0,o.forEach(h=>{h()}),!1)},l=h=>{h.confirmations<a||i()||t(h)};if(this.on(e,l),o.push(()=>{this.removeListener(e,l)}),d){let h=d.startBlock,u=null,g=E=>S0(this,void 0,void 0,function*(){n||(yield l0e(1e3),this.getTransactionCount(d.from).then(_=>S0(this,void 0,void 0,function*(){if(!n){if(_<=d.nonce)h=E;else{{let F=yield this.getTransaction(e);if(F&&F.blockNumber!=null)return}for(u==null&&(u=h-3,u<d.startBlock&&(u=d.startBlock));u<=E;){if(n)return;let F=yield this.getBlockWithTransactions(u);for(let L=0;L<F.transactions.length;L++){let U=F.transactions[L];if(U.hash===e)return;if(U.from===d.from&&U.nonce===d.nonce){if(n)return;let O=yield this.waitForTransaction(U.hash,a);if(i())return;let H="replaced";U.data===d.data&&U.to===d.to&&U.value.eq(d.value)?H="repriced":U.data==="0x"&&U.from===U.to&&U.value.isZero()&&(H="cancelled"),r(G0.makeError("transaction was replaced",X.errors.TRANSACTION_REPLACED,{cancelled:H==="replaced"||H==="cancelled",reason:H,replacement:this._wrapTransaction(U),hash:e,receipt:O}));return}}u++}}n||this.once("block",g)}}),_=>{n||this.once("block",g)}))});if(n)return;this.once("block",g),o.push(()=>{this.removeListener("block",g)})}if(typeof f=="number"&&f>0){let h=setTimeout(()=>{i()||r(G0.makeError("timeout exceeded",X.errors.TIMEOUT,{timeout:f}))},f);h.unref&&h.unref(),o.push(()=>{clearTimeout(h)})}})})}getBlockNumber(){return S0(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let e=yield this.perform("getGasPrice",{});try{return Ee.from(e)}catch(a){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"getGasPrice",result:e,error:a})}})}getBalance(e,a){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let f=yield wa({address:this._getAddress(e),blockTag:this._getBlockTag(a)}),d=yield this.perform("getBalance",f);try{return Ee.from(d)}catch(b){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"getBalance",params:f,result:d,error:b})}})}getTransactionCount(e,a){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let f=yield wa({address:this._getAddress(e),blockTag:this._getBlockTag(a)}),d=yield this.perform("getTransactionCount",f);try{return Ee.from(d).toNumber()}catch(b){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"getTransactionCount",params:f,result:d,error:b})}})}getCode(e,a){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let f=yield wa({address:this._getAddress(e),blockTag:this._getBlockTag(a)}),d=yield this.perform("getCode",f);try{return Be(d)}catch(b){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"getCode",params:f,result:d,error:b})}})}getStorageAt(e,a,f){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let d=yield wa({address:this._getAddress(e),blockTag:this._getBlockTag(f),position:Promise.resolve(a).then(t=>kb(t))}),b=yield this.perform("getStorageAt",d);try{return Be(b)}catch(t){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"getStorageAt",params:d,result:b,error:t})}})}_wrapTransaction(e,a,f){if(a!=null&&Cf(a)!==32)throw new Error("invalid response - sendTransaction");let d=e;return a!=null&&e.hash!==a&&G0.throwError("Transaction hash mismatch from Provider.sendTransaction.",X.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:a}),d.wait=(b,t)=>S0(this,void 0,void 0,function*(){b==null&&(b=1),t==null&&(t=0);let r;b!==0&&f!=null&&(r={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:f});let o=yield this._waitForTransaction(e.hash,b,t,r);return o==null&&b===0?null:(this._emitted["t:"+e.hash]=o.blockNumber,o.status===0&&G0.throwError("transaction failed",X.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:o}),o)}),d}sendTransaction(e){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let a=yield Promise.resolve(e).then(b=>Be(b)),f=this.formatter.transaction(e);f.confirmations==null&&(f.confirmations=0);let d=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{let b=yield this.perform("sendTransaction",{signedTransaction:a});return this._wrapTransaction(f,b,d)}catch(b){throw b.transaction=f,b.transactionHash=f.hash,b}})}_getTransactionRequest(e){return S0(this,void 0,void 0,function*(){let a=yield e,f={};return["from","to"].forEach(d=>{a[d]!=null&&(f[d]=Promise.resolve(a[d]).then(b=>b?this._getAddress(b):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(d=>{a[d]!=null&&(f[d]=Promise.resolve(a[d]).then(b=>b?Ee.from(b):null))}),["type"].forEach(d=>{a[d]!=null&&(f[d]=Promise.resolve(a[d]).then(b=>b??null))}),a.accessList&&(f.accessList=this.formatter.accessList(a.accessList)),["data"].forEach(d=>{a[d]!=null&&(f[d]=Promise.resolve(a[d]).then(b=>b?Be(b):null))}),this.formatter.transactionRequest(yield wa(f))})}_getFilter(e){return S0(this,void 0,void 0,function*(){e=yield e;let a={};return e.address!=null&&(a.address=this._getAddress(e.address)),["blockHash","topics"].forEach(f=>{e[f]!=null&&(a[f]=e[f])}),["fromBlock","toBlock"].forEach(f=>{e[f]!=null&&(a[f]=this._getBlockTag(e[f]))}),this.formatter.filter(yield wa(a))})}_call(e,a,f){return S0(this,void 0,void 0,function*(){f>=Jye&&G0.throwError("CCIP read exceeded maximum redirections",X.errors.SERVER_ERROR,{redirects:f,transaction:e});let d=e.to,b=yield this.perform("call",{transaction:e,blockTag:a});if(f>=0&&a==="latest"&&d!=null&&b.substring(0,10)==="0x556f1830"&&Cf(b)%32===4)try{let t=ya(b,4),r=ya(t,0,32);Ee.from(r).eq(d)||G0.throwError("CCIP Read sender did not match",X.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:b});let o=[],n=Ee.from(ya(t,32,64)).toNumber(),i=Ee.from(ya(t,n,n+32)).toNumber(),l=ya(t,n+32);for(let F=0;F<i;F++){let L=Zm(l,F*32);L==null&&G0.throwError("CCIP Read contained corrupt URL string",X.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:b}),o.push(L)}let h=Vo(t,64);Ee.from(ya(t,100,128)).isZero()||G0.throwError("CCIP Read callback selector included junk",X.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:b});let u=ya(t,96,100),g=Vo(t,128),E=yield this.ccipReadFetch(e,h,o);E==null&&G0.throwError("CCIP Read disabled or provided no URLs",X.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:b});let _={to:d,data:Ec([u,g0e([E,g])])};return this._call(_,a,f+1)}catch(t){if(t.code===X.errors.SERVER_ERROR)throw t}try{return Be(b)}catch(t){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"call",params:{transaction:e,blockTag:a},result:b,error:t})}})}call(e,a){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let f=yield wa({transaction:this._getTransactionRequest(e),blockTag:this._getBlockTag(a),ccipReadEnabled:Promise.resolve(e.ccipReadEnabled)});return this._call(f.transaction,f.blockTag,f.ccipReadEnabled?0:-1)})}estimateGas(e){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let a=yield wa({transaction:this._getTransactionRequest(e)}),f=yield this.perform("estimateGas",a);try{return Ee.from(f)}catch(d){return G0.throwError("bad result from backend",X.errors.SERVER_ERROR,{method:"estimateGas",params:a,result:f,error:d})}})}_getAddress(e){return S0(this,void 0,void 0,function*(){e=yield e,typeof e!="string"&&G0.throwArgumentError("invalid address or ENS name","name",e);let a=yield this.resolveName(e);return a==null&&G0.throwError("ENS name not configured",X.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(e)})`}),a})}_getBlock(e,a){return S0(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;let f=-128,d={includeTransactions:!!a};if(n0(e,32))d.blockHash=e;else try{d.blockTag=yield this._getBlockTag(e),n0(d.blockTag)&&(f=parseInt(d.blockTag.substring(2),16))}catch{G0.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",e)}return W1(()=>S0(this,void 0,void 0,function*(){let b=yield this.perform("getBlock",d);if(b==null)return d.blockHash!=null&&this._emitted["b:"+d.blockHash]==null||d.blockTag!=null&&f>this._emitted.block?null:void 0;if(a){let t=null;for(let o=0;o<b.transactions.length;o++){let n=b.transactions[o];if(n.blockNumber==null)n.confirmations=0;else if(n.confirmations==null){t==null&&(t=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let i=t-n.blockNumber+1;i<=0&&(i=1),n.confirmations=i}}let r=this.formatter.blockWithTransactions(b);return r.transactions=r.transactions.map(o=>this._wrapTransaction(o)),r}return this.formatter.block(b)}),{oncePoll:this})})}getBlock(e){return this._getBlock(e,!1)}getBlockWithTransactions(e){return this._getBlock(e,!0)}getTransaction(e){return S0(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;let a={transactionHash:this.formatter.hash(e,!0)};return W1(()=>S0(this,void 0,void 0,function*(){let f=yield this.perform("getTransaction",a);if(f==null)return this._emitted["t:"+e]==null?null:void 0;let d=this.formatter.transactionResponse(f);if(d.blockNumber==null)d.confirmations=0;else if(d.confirmations==null){let t=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-d.blockNumber+1;t<=0&&(t=1),d.confirmations=t}return this._wrapTransaction(d)}),{oncePoll:this})})}getTransactionReceipt(e){return S0(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;let a={transactionHash:this.formatter.hash(e,!0)};return W1(()=>S0(this,void 0,void 0,function*(){let f=yield this.perform("getTransactionReceipt",a);if(f==null)return this._emitted["t:"+e]==null?null:void 0;if(f.blockHash==null)return;let d=this.formatter.receipt(f);if(d.blockNumber==null)d.confirmations=0;else if(d.confirmations==null){let t=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-d.blockNumber+1;t<=0&&(t=1),d.confirmations=t}return d}),{oncePoll:this})})}getLogs(e){return S0(this,void 0,void 0,function*(){yield this.getNetwork();let a=yield wa({filter:this._getFilter(e)}),f=yield this.perform("getLogs",a);return f.forEach(d=>{d.removed==null&&(d.removed=!1)}),e0.arrayOf(this.formatter.filterLog.bind(this.formatter))(f)})}getEtherPrice(){return S0(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(e){return S0(this,void 0,void 0,function*(){if(e=yield e,typeof e=="number"&&e<0){e%1&&G0.throwArgumentError("invalid BlockTag","blockTag",e);let a=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return a+=e,a<0&&(a=0),this.formatter.blockTag(a)}return this.formatter.blockTag(e)})}getResolver(e){return S0(this,void 0,void 0,function*(){let a=e;for(;;){if(a===""||a==="."||e!=="eth"&&a==="eth")return null;let f=yield this._getResolver(a,"getResolver");if(f!=null){let d=new Gt(this,f,e);return a!==e&&!(yield d.supportsWildcard())?null:d}a=a.split(".").slice(1).join(".")}})}_getResolver(e,a){return S0(this,void 0,void 0,function*(){a==null&&(a="ENS");let f=yield this.getNetwork();f.ensAddress||G0.throwError("network does not support ENS",X.errors.UNSUPPORTED_OPERATION,{operation:a,network:f.name});try{let d=yield this.call({to:f.ensAddress,data:"0x0178b8bf"+q7(e).substring(2)});return this.formatter.callAddress(d)}catch{}return null})}resolveName(e){return S0(this,void 0,void 0,function*(){e=yield e;try{return Promise.resolve(this.formatter.address(e))}catch(f){if(n0(e))throw f}typeof e!="string"&&G0.throwArgumentError("invalid ENS name","name",e);let a=yield this.getResolver(e);return a?yield a.getAddress():null})}lookupAddress(e){return S0(this,void 0,void 0,function*(){e=yield e,e=this.formatter.address(e);let a=e.substring(2).toLowerCase()+".addr.reverse",f=yield this._getResolver(a,"lookupAddress");if(f==null)return null;let d=Zm(yield this.call({to:f,data:"0x691f3431"+q7(a).substring(2)}),0);return(yield this.resolveName(d))!=e?null:d})}getAvatar(e){return S0(this,void 0,void 0,function*(){let a=null;if(n0(e)){let b=this.formatter.address(e).substring(2).toLowerCase()+".addr.reverse",t=yield this._getResolver(b,"getAvatar");if(!t)return null;a=new Gt(this,t,b);try{let r=yield a.getAvatar();if(r)return r.url}catch(r){if(r.code!==X.errors.CALL_EXCEPTION)throw r}try{let r=Zm(yield this.call({to:t,data:"0x691f3431"+q7(b).substring(2)}),0);a=yield this.getResolver(r)}catch(r){if(r.code!==X.errors.CALL_EXCEPTION)throw r;return null}}else if(a=yield this.getResolver(e),!a)return null;let f=yield a.getAvatar();return f==null?null:f.url})}perform(e,a){return G0.throwError(e+" not implemented",X.errors.NOT_IMPLEMENTED,{operation:e})}_startEvent(e){this.polling=this._events.filter(a=>a.pollable()).length>0}_stopEvent(e){this.polling=this._events.filter(a=>a.pollable()).length>0}_addEventListener(e,a,f){let d=new wF(qt(e),a,f);return this._events.push(d),this._startEvent(d),this}on(e,a){return this._addEventListener(e,a,!1)}once(e,a){return this._addEventListener(e,a,!0)}emit(e,...a){let f=!1,d=[],b=qt(e);return this._events=this._events.filter(t=>t.tag!==b?!0:(setTimeout(()=>{t.listener.apply(this,a)},0),f=!0,t.once?(d.push(t),!1):!0)),d.forEach(t=>{this._stopEvent(t)}),f}listenerCount(e){if(!e)return this._events.length;let a=qt(e);return this._events.filter(f=>f.tag===a).length}listeners(e){if(e==null)return this._events.map(f=>f.listener);let a=qt(e);return this._events.filter(f=>f.tag===a).map(f=>f.listener)}off(e,a){if(a==null)return this.removeAllListeners(e);let f=[],d=!1,b=qt(e);return this._events=this._events.filter(t=>t.tag!==b||t.listener!=a||d?!0:(d=!0,f.push(t),!1)),f.forEach(t=>{this._stopEvent(t)}),this}removeAllListeners(e){let a=[];if(e==null)a=this._events,this._events=[];else{let f=qt(e);this._events=this._events.filter(d=>d.tag!==f?!0:(a.push(d),!1))}return a.forEach(f=>{this._stopEvent(f)}),this}};s();x();s();x();s();x();var p8=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Sc=new X(ia),cwe=["call","estimateGas"];function Qo(c,e){if(c==null)return null;if(typeof c.message=="string"&&c.message.match("reverted")){let a=n0(c.data)?c.data:null;if(!e||a)return{message:c.message,data:a}}if(typeof c=="object"){for(let a in c){let f=Qo(c[a],e);if(f)return f}return null}if(typeof c=="string")try{return Qo(JSON.parse(c),e)}catch{}return null}function w0e(c,e,a){let f=a.transaction||a.signedTransaction;if(c==="call"){let b=Qo(e,!0);if(b)return b.data;Sc.throwError("missing revert data in call exception; Transaction reverted without a reason string",X.errors.CALL_EXCEPTION,{data:"0x",transaction:f,error:e})}if(c==="estimateGas"){let b=Qo(e.body,!1);b==null&&(b=Qo(e,!1)),b&&Sc.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",X.errors.UNPREDICTABLE_GAS_LIMIT,{reason:b.message,method:c,transaction:f,error:e})}let d=e.message;throw e.code===X.errors.SERVER_ERROR&&e.error&&typeof e.error.message=="string"?d=e.error.message:typeof e.body=="string"?d=e.body:typeof e.responseText=="string"&&(d=e.responseText),d=(d||"").toLowerCase(),d.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&Sc.throwError("insufficient funds for intrinsic transaction cost",X.errors.INSUFFICIENT_FUNDS,{error:e,method:c,transaction:f}),d.match(/nonce (is )?too low/i)&&Sc.throwError("nonce has already been used",X.errors.NONCE_EXPIRED,{error:e,method:c,transaction:f}),d.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&Sc.throwError("replacement fee too low",X.errors.REPLACEMENT_UNDERPRICED,{error:e,method:c,transaction:f}),d.match(/only replay-protected/i)&&Sc.throwError("legacy pre-eip-155 transactions not supported",X.errors.UNSUPPORTED_OPERATION,{error:e,method:c,transaction:f}),cwe.indexOf(c)>=0&&d.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&Sc.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",X.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:c,transaction:f}),e}function y0e(c){return new Promise(function(e){setTimeout(e,c)})}function fwe(c){if(c.error){let e=new Error(c.error.message);throw e.code=c.error.code,e.data=c.error.data,e}return c.result}function Ko(c){return c&&c.toLowerCase()}var _F={},zt=class extends fd{constructor(e,a,f){if(super(),e!==_F)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");he(this,"provider",a),f==null&&(f=0),typeof f=="string"?(he(this,"_address",this.provider.formatter.address(f)),he(this,"_index",null)):typeof f=="number"?(he(this,"_index",f),he(this,"_address",null)):Sc.throwArgumentError("invalid address or index","addressOrIndex",f)}connect(e){return Sc.throwError("cannot alter JSON-RPC Signer connection",X.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new vF(_F,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(e=>(e.length<=this._index&&Sc.throwError("unknown account #"+this._index,X.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(e[this._index])))}sendUncheckedTransaction(e){e=ea(e);let a=this.getAddress().then(f=>(f&&(f=f.toLowerCase()),f));if(e.gasLimit==null){let f=ea(e);f.from=a,e.gasLimit=this.provider.estimateGas(f)}return e.to!=null&&(e.to=Promise.resolve(e.to).then(f=>p8(this,void 0,void 0,function*(){if(f==null)return null;let d=yield this.provider.resolveName(f);return d==null&&Sc.throwArgumentError("provided ENS name resolves to null","tx.to",f),d}))),wa({tx:wa(e),sender:a}).then(({tx:f,sender:d})=>{f.from!=null?f.from.toLowerCase()!==d&&Sc.throwArgumentError("from address mismatch","transaction",e):f.from=d;let b=this.provider.constructor.hexlifyTransaction(f,{from:!0});return this.provider.send("eth_sendTransaction",[b]).then(t=>t,t=>(typeof t.message=="string"&&t.message.match(/user denied/i)&&Sc.throwError("user rejected transaction",X.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:f}),w0e("sendTransaction",t,b)))})}signTransaction(e){return Sc.throwError("signing transactions is unsupported",X.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(e){return p8(this,void 0,void 0,function*(){let a=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),f=yield this.sendUncheckedTransaction(e);try{return yield W1(()=>p8(this,void 0,void 0,function*(){let d=yield this.provider.getTransaction(f);if(d!==null)return this.provider._wrapTransaction(d,f,a)}),{oncePoll:this.provider})}catch(d){throw d.transactionHash=f,d}})}signMessage(e){return p8(this,void 0,void 0,function*(){let a=typeof e=="string"?J0(e):e,f=yield this.getAddress();try{return yield this.provider.send("personal_sign",[Be(a),f.toLowerCase()])}catch(d){throw typeof d.message=="string"&&d.message.match(/user denied/i)&&Sc.throwError("user rejected signing",X.errors.ACTION_REJECTED,{action:"signMessage",from:f,messageData:e}),d}})}_legacySignMessage(e){return p8(this,void 0,void 0,function*(){let a=typeof e=="string"?J0(e):e,f=yield this.getAddress();try{return yield this.provider.send("eth_sign",[f.toLowerCase(),Be(a)])}catch(d){throw typeof d.message=="string"&&d.message.match(/user denied/i)&&Sc.throwError("user rejected signing",X.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:f,messageData:e}),d}})}_signTypedData(e,a,f){return p8(this,void 0,void 0,function*(){let d=yield Wa.resolveNames(e,a,f,t=>this.provider.resolveName(t)),b=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[b.toLowerCase(),JSON.stringify(Wa.getPayload(d.domain,a,d.value))])}catch(t){throw typeof t.message=="string"&&t.message.match(/user denied/i)&&Sc.throwError("user rejected signing",X.errors.ACTION_REJECTED,{action:"_signTypedData",from:b,messageData:{domain:d.domain,types:a,value:d.value}}),t}})}unlock(e){return p8(this,void 0,void 0,function*(){let a=this.provider,f=yield this.getAddress();return a.send("personal_unlockAccount",[f.toLowerCase(),e,null])})}},vF=class extends zt{sendTransaction(e){return this.sendUncheckedTransaction(e).then(a=>({hash:a,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:f=>this.provider.waitForTransaction(a,f)}))}},dwe={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0},Bd=class extends Xb{constructor(e,a){let f=a;f==null&&(f=new Promise((d,b)=>{setTimeout(()=>{this.detectNetwork().then(t=>{d(t)},t=>{b(t)})},0)})),super(f),e||(e=Ka(this.constructor,"defaultUrl")()),typeof e=="string"?he(this,"connection",Object.freeze({url:e})):he(this,"connection",Object.freeze(ea(e))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return p8(this,void 0,void 0,function*(){yield y0e(0);let e=null;try{e=yield this.send("eth_chainId",[])}catch{try{e=yield this.send("net_version",[])}catch{}}if(e!=null){let a=Ka(this.constructor,"getNetwork");try{return a(Ee.from(e).toNumber())}catch(f){return Sc.throwError("could not detect network",X.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:f})}}return Sc.throwError("could not detect network",X.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(e){return new zt(_F,this,e)}getUncheckedSigner(e){return this.getSigner(e).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(e=>e.map(a=>this.formatter.address(a)))}send(e,a){let f={method:e,params:a,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:Va(f),provider:this});let d=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(d&&this._cache[e])return this._cache[e];let b=Q1(this.connection,JSON.stringify(f),fwe).then(t=>(this.emit("debug",{action:"response",request:f,response:t,provider:this}),t),t=>{throw this.emit("debug",{action:"response",error:t,request:f,provider:this}),t});return d&&(this._cache[e]=b,setTimeout(()=>{this._cache[e]=null},0)),b}prepareRequest(e,a){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[Ko(a.address),a.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[Ko(a.address),a.blockTag]];case"getCode":return["eth_getCode",[Ko(a.address),a.blockTag]];case"getStorageAt":return["eth_getStorageAt",[Ko(a.address),q0(a.position,32),a.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[a.signedTransaction]];case"getBlock":return a.blockTag?["eth_getBlockByNumber",[a.blockTag,!!a.includeTransactions]]:a.blockHash?["eth_getBlockByHash",[a.blockHash,!!a.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[a.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[a.transactionHash]];case"call":return["eth_call",[Ka(this.constructor,"hexlifyTransaction")(a.transaction,{from:!0}),a.blockTag]];case"estimateGas":return["eth_estimateGas",[Ka(this.constructor,"hexlifyTransaction")(a.transaction,{from:!0})]];case"getLogs":return a.filter&&a.filter.address!=null&&(a.filter.address=Ko(a.filter.address)),["eth_getLogs",[a.filter]];default:break}return null}perform(e,a){return p8(this,void 0,void 0,function*(){if(e==="call"||e==="estimateGas"){let d=a.transaction;if(d&&d.type!=null&&Ee.from(d.type).isZero()&&d.maxFeePerGas==null&&d.maxPriorityFeePerGas==null){let b=yield this.getFeeData();b.maxFeePerGas==null&&b.maxPriorityFeePerGas==null&&(a=ea(a),a.transaction=ea(d),delete a.transaction.type)}}let f=this.prepareRequest(e,a);f==null&&Sc.throwError(e+" not implemented",X.errors.NOT_IMPLEMENTED,{operation:e});try{return yield this.send(f[0],f[1])}catch(d){return w0e(e,d,a)}})}_startEvent(e){e.tag==="pending"&&this._startPending(),super._startEvent(e)}_startPending(){if(this._pendingFilter!=null)return;let e=this,a=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=a,a.then(function(f){function d(){e.send("eth_getFilterChanges",[f]).then(function(b){if(e._pendingFilter!=a)return null;let t=Promise.resolve();return b.forEach(function(r){e._emitted["t:"+r.toLowerCase()]="pending",t=t.then(function(){return e.getTransaction(r).then(function(o){return e.emit("pending",o),null})})}),t.then(function(){return y0e(1e3)})}).then(function(){if(e._pendingFilter!=a){e.send("eth_uninstallFilter",[f]);return}return setTimeout(function(){d()},0),null}).catch(b=>{})}return d(),f}).catch(f=>{})}_stopEvent(e){e.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(e)}static hexlifyTransaction(e,a){let f=ea(dwe);if(a)for(let b in a)a[b]&&(f[b]=!0);xt(e,f);let d={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(b){if(e[b]==null)return;let t=kb(Ee.from(e[b]));b==="gasLimit"&&(b="gas"),d[b]=t}),["from","to","data"].forEach(function(b){e[b]!=null&&(d[b]=Be(e[b]))}),e.accessList&&(d.accessList=s2(e.accessList)),d}};s();x();var jt=null;try{if(jt=WebSocket,jt==null)throw new Error("inject please")}catch{let e=new X(ia);jt=function(){e.throwError("WebSockets not supported in this environment",X.errors.UNSUPPORTED_OPERATION,{operation:"new WebSocket()"})}}var EF=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Ym=new X(ia),bwe=1,m8=class extends Bd{constructor(e,a){a==="any"&&Ym.throwError("WebSocketProvider does not support 'any' network yet",X.errors.UNSUPPORTED_OPERATION,{operation:"network:any"}),typeof e=="string"?super(e,a):super("_websocket",a),this._pollingInterval=-1,this._wsReady=!1,typeof e=="string"?he(this,"_websocket",new jt(this.connection.url)):he(this,"_websocket",e),he(this,"_requests",{}),he(this,"_subs",{}),he(this,"_subIds",{}),he(this,"_detectNetwork",super.detectNetwork()),this.websocket.onopen=()=>{this._wsReady=!0,Object.keys(this._requests).forEach(d=>{this.websocket.send(this._requests[d].payload)})},this.websocket.onmessage=d=>{let b=d.data,t=JSON.parse(b);if(t.id!=null){let r=String(t.id),o=this._requests[r];if(delete this._requests[r],t.result!==void 0)o.callback(null,t.result),this.emit("debug",{action:"response",request:JSON.parse(o.payload),response:t.result,provider:this});else{let n=null;t.error?(n=new Error(t.error.message||"unknown error"),he(n,"code",t.error.code||null),he(n,"response",b)):n=new Error("unknown error"),o.callback(n,void 0),this.emit("debug",{action:"response",error:n,request:JSON.parse(o.payload),provider:this})}}else if(t.method==="eth_subscription"){let r=this._subs[t.params.subscription];r&&r.processFunc(t.params.result)}else console.warn("this should not happen")};let f=setInterval(()=>{this.emit("poll")},1e3);f.unref&&f.unref()}get websocket(){return this._websocket}detectNetwork(){return this._detectNetwork}get pollingInterval(){return 0}resetEventsBlock(e){Ym.throwError("cannot reset events block on WebSocketProvider",X.errors.UNSUPPORTED_OPERATION,{operation:"resetEventBlock"})}set pollingInterval(e){Ym.throwError("cannot set polling interval on WebSocketProvider",X.errors.UNSUPPORTED_OPERATION,{operation:"setPollingInterval"})}poll(){return EF(this,void 0,void 0,function*(){return null})}set polling(e){!e||Ym.throwError("cannot set polling on WebSocketProvider",X.errors.UNSUPPORTED_OPERATION,{operation:"setPolling"})}send(e,a){let f=bwe++;return new Promise((d,b)=>{function t(o,n){return o?b(o):d(n)}let r=JSON.stringify({method:e,params:a,id:f,jsonrpc:"2.0"});this.emit("debug",{action:"request",request:JSON.parse(r),provider:this}),this._requests[String(f)]={callback:t,payload:r},this._wsReady&&this.websocket.send(r)})}static defaultUrl(){return"ws://localhost:8546"}_subscribe(e,a,f){return EF(this,void 0,void 0,function*(){let d=this._subIds[e];d==null&&(d=Promise.all(a).then(t=>this.send("eth_subscribe",t)),this._subIds[e]=d);let b=yield d;this._subs[b]={tag:e,processFunc:f}})}_startEvent(e){switch(e.type){case"block":this._subscribe("block",["newHeads"],a=>{let f=Ee.from(a.number).toNumber();this._emitted.block=f,this.emit("block",f)});break;case"pending":this._subscribe("pending",["newPendingTransactions"],a=>{this.emit("pending",a)});break;case"filter":this._subscribe(e.tag,["logs",this._getFilter(e.filter)],a=>{a.removed==null&&(a.removed=!1),this.emit(e.filter,this.formatter.filterLog(a))});break;case"tx":{let a=f=>{let d=f.hash;this.getTransactionReceipt(d).then(b=>{!b||this.emit(d,b)})};a(e),this._subscribe("tx",["newHeads"],f=>{this._events.filter(d=>d.type==="tx").forEach(a)});break}case"debug":case"poll":case"willPoll":case"didPoll":case"error":break;default:console.log("unhandled:",e);break}}_stopEvent(e){let a=e.tag;if(e.type==="tx"){if(this._events.filter(d=>d.type==="tx").length)return;a="tx"}else if(this.listenerCount(e.event))return;let f=this._subIds[a];!f||(delete this._subIds[a],f.then(d=>{!this._subs[d]||(delete this._subs[d],this.send("eth_unsubscribe",[d]))}))}destroy(){return EF(this,void 0,void 0,function*(){this.websocket.readyState===jt.CONNECTING&&(yield new Promise(e=>{this.websocket.onopen=function(){e(!0)},this.websocket.onerror=function(){e(!1)}})),this.websocket.close(1e3)})}};s();x();var twe=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},Wo=new X(ia),Jo=class extends Bd{detectNetwork(){let e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return twe(this,void 0,void 0,function*(){let a=this.network;return a==null&&(a=yield e.detectNetwork.call(this),a||Wo.throwError("no network detected",X.errors.UNKNOWN_ERROR,{}),this._network==null&&(he(this,"_network",a),this.emit("network",a,null))),a})}},Qc=class extends Jo{constructor(e,a){Wo.checkAbstract(new.target,Qc),e=Ka(new.target,"getNetwork")(e),a=Ka(new.target,"getApiKey")(a);let f=Ka(new.target,"getUrl")(e,a);super(f,e),typeof a=="string"?he(this,"apiKey",a):a!=null&&Object.keys(a).forEach(d=>{he(this,d,a[d])})}_startPending(){Wo.warn("WARNING: API provider does not support pending filters")}isCommunityResource(){return!1}getSigner(e){return Wo.throwError("API provider does not support signing",X.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"})}listAccounts(){return Promise.resolve([])}static getApiKey(e){return e}static getUrl(e,a){return Wo.throwError("not implemented; sub-classes must override getUrl",X.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}};var _0e=new X(ia),Xm="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC",Zo=class extends m8{constructor(e,a){let f=new Ht(e,a),d=f.connection.url.replace(/^http/i,"ws").replace(".alchemyapi.",".ws.alchemyapi.");super(d,f.network),he(this,"apiKey",f.apiKey)}isCommunityResource(){return this.apiKey===Xm}},Ht=class extends Qc{static getWebSocketProvider(e,a){return new Zo(e,a)}static getApiKey(e){return e==null?Xm:(e&&typeof e!="string"&&_0e.throwArgumentError("invalid apiKey","apiKey",e),e)}static getUrl(e,a){let f=null;switch(e.name){case"homestead":f="eth-mainnet.alchemyapi.io/v2/";break;case"goerli":f="eth-goerli.g.alchemy.com/v2/";break;case"matic":f="polygon-mainnet.g.alchemy.com/v2/";break;case"maticmum":f="polygon-mumbai.g.alchemy.com/v2/";break;case"arbitrum":f="arb-mainnet.g.alchemy.com/v2/";break;case"arbitrum-goerli":f="arb-goerli.g.alchemy.com/v2/";break;case"optimism":f="opt-mainnet.g.alchemy.com/v2/";break;case"optimism-goerli":f="opt-goerli.g.alchemy.com/v2/";break;default:_0e.throwArgumentError("unsupported network","network",arguments[0])}return{allowGzip:!0,url:"https://"+f+a,throttleCallback:(d,b)=>(a===Xm&&Yb(),Promise.resolve(!0))}}isCommunityResource(){return this.apiKey===Xm}};s();x();var rwe=new X(ia),eg="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function nwe(c){switch(c){case"homestead":return"rpc.ankr.com/eth/";case"ropsten":return"rpc.ankr.com/eth_ropsten/";case"rinkeby":return"rpc.ankr.com/eth_rinkeby/";case"goerli":return"rpc.ankr.com/eth_goerli/";case"matic":return"rpc.ankr.com/polygon/";case"arbitrum":return"rpc.ankr.com/arbitrum/"}return rwe.throwArgumentError("unsupported network","name",c)}var Yo=class extends Qc{isCommunityResource(){return this.apiKey===eg}static getApiKey(e){return e??eg}static getUrl(e,a){a==null&&(a=eg);let f={allowGzip:!0,url:"https://"+nwe(e.name)+a,throttleCallback:(d,b)=>(a.apiKey===eg&&Yb(),Promise.resolve(!0))};return a.projectSecret!=null&&(f.user="",f.password=a.projectSecret),f}};s();x();var iwe=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},v0e=new X(ia),Xo=class extends Qc{static getApiKey(e){return e!=null&&v0e.throwArgumentError("apiKey not supported for cloudflare","apiKey",e),null}static getUrl(e,a){let f=null;switch(e.name){case"homestead":f="https://cloudflare-eth.com/";break;default:v0e.throwArgumentError("unsupported network","network",arguments[0])}return f}perform(e,a){let f=Object.create(null,{perform:{get:()=>super.perform}});return iwe(this,void 0,void 0,function*(){return e==="getBlockNumber"?(yield f.perform.call(this,"getBlock",{blockTag:"latest"})).number:f.perform.call(this,e,a)})}};s();x();var ag=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},K7=new X(ia);function E0e(c){let e={};for(let a in c){if(c[a]==null)continue;let f=c[a];a==="type"&&f===0||({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[a]?f=kb(Be(f)):a==="accessList"?f="["+s2(f).map(d=>`{address:"${d.address}",storageKeys:["${d.storageKeys.join('","')}"]}`).join(",")+"]":f=Be(f),e[a]=f)}return e}function owe(c){if(c.status==0&&(c.message==="No records found"||c.message==="No transactions found"))return c.result;if(c.status!=1||typeof c.message!="string"||!c.message.match(/^OK/)){let e=new Error("invalid response");throw e.result=JSON.stringify(c),(c.result||"").toLowerCase().indexOf("rate limit")>=0&&(e.throttleRetry=!0),e}return c.result}function A0e(c){if(c&&c.status==0&&c.message=="NOTOK"&&(c.result||"").toLowerCase().indexOf("rate limit")>=0){let e=new Error("throttled response");throw e.result=JSON.stringify(c),e.throttleRetry=!0,e}if(c.jsonrpc!="2.0"){let e=new Error("invalid response");throw e.result=JSON.stringify(c),e}if(c.error){let e=new Error(c.error.message||"unknown error");throw c.error.code&&(e.code=c.error.code),c.error.data&&(e.data=c.error.data),e}return c.result}function S0e(c){if(c==="pending")throw new Error("pending not supported");return c==="latest"?c:parseInt(c.substring(2),16)}function AF(c,e,a){if(c==="call"&&e.code===X.errors.SERVER_ERROR){let d=e.error;if(d&&(d.message.match(/reverted/i)||d.message.match(/VM execution error/i))){let b=d.data;if(b&&(b="0x"+b.replace(/^.*0x/i,"")),n0(b))return b;K7.throwError("missing revert data in call exception",X.errors.CALL_EXCEPTION,{error:e,data:"0x"})}}let f=e.message;throw e.code===X.errors.SERVER_ERROR&&(e.error&&typeof e.error.message=="string"?f=e.error.message:typeof e.body=="string"?f=e.body:typeof e.responseText=="string"&&(f=e.responseText)),f=(f||"").toLowerCase(),f.match(/insufficient funds/)&&K7.throwError("insufficient funds for intrinsic transaction cost",X.errors.INSUFFICIENT_FUNDS,{error:e,method:c,transaction:a}),f.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&K7.throwError("nonce has already been used",X.errors.NONCE_EXPIRED,{error:e,method:c,transaction:a}),f.match(/another transaction with same nonce/)&&K7.throwError("replacement fee too low",X.errors.REPLACEMENT_UNDERPRICED,{error:e,method:c,transaction:a}),f.match(/execution failed due to an exception|execution reverted/)&&K7.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",X.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:c,transaction:a}),e}var es=class extends Xb{constructor(e,a){super(e),he(this,"baseUrl",this.getBaseUrl()),he(this,"apiKey",a||null)}getBaseUrl(){switch(this.network?this.network.name:"invalid"){case"homestead":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"matic":return"https://api.polygonscan.com";case"maticmum":return"https://api-testnet.polygonscan.com";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io";default:}return K7.throwArgumentError("unsupported network","network",this.network.name)}getUrl(e,a){let f=Object.keys(a).reduce((b,t)=>{let r=a[t];return r!=null&&(b+=`&${t}=${r}`),b},""),d=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.baseUrl}/api?module=${e}${f}${d}`}getPostUrl(){return`${this.baseUrl}/api`}getPostData(e,a){return a.module=e,a.apikey=this.apiKey,a}fetch(e,a,f){return ag(this,void 0,void 0,function*(){let d=f?this.getPostUrl():this.getUrl(e,a),b=f?this.getPostData(e,a):null,t=e==="proxy"?A0e:owe;this.emit("debug",{action:"request",request:d,provider:this});let r={url:d,throttleSlotInterval:1e3,throttleCallback:(i,l)=>(this.isCommunityResource()&&Yb(),Promise.resolve(!0))},o=null;b&&(r.headers={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},o=Object.keys(b).map(i=>`${i}=${b[i]}`).join("&"));let n=yield Q1(r,o,t||A0e);return this.emit("debug",{action:"response",request:d,response:Va(n),provider:this}),n})}detectNetwork(){return ag(this,void 0,void 0,function*(){return this.network})}perform(e,a){let f=Object.create(null,{perform:{get:()=>super.perform}});return ag(this,void 0,void 0,function*(){switch(e){case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getBalance":return this.fetch("account",{action:"balance",address:a.address,tag:a.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:a.address,tag:a.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:a.address,tag:a.blockTag});case"getStorageAt":return this.fetch("proxy",{action:"eth_getStorageAt",address:a.address,position:a.position,tag:a.blockTag});case"sendTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:a.signedTransaction},!0).catch(d=>AF("sendTransaction",d,a.signedTransaction));case"getBlock":if(a.blockTag)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:a.blockTag,boolean:a.includeTransactions?"true":"false"});throw new Error("getBlock by blockHash not implemented");case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:a.transactionHash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:a.transactionHash});case"call":{if(a.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");let d=E0e(a.transaction);d.module="proxy",d.action="eth_call";try{return yield this.fetch("proxy",d,!0)}catch(b){return AF("call",b,a.transaction)}}case"estimateGas":{let d=E0e(a.transaction);d.module="proxy",d.action="eth_estimateGas";try{return yield this.fetch("proxy",d,!0)}catch(b){return AF("estimateGas",b,a.transaction)}}case"getLogs":{let d={action:"getLogs"};if(a.filter.fromBlock&&(d.fromBlock=S0e(a.filter.fromBlock)),a.filter.toBlock&&(d.toBlock=S0e(a.filter.toBlock)),a.filter.address&&(d.address=a.filter.address),a.filter.topics&&a.filter.topics.length>0&&(a.filter.topics.length>1&&K7.throwError("unsupported topic count",X.errors.UNSUPPORTED_OPERATION,{topics:a.filter.topics}),a.filter.topics.length===1)){let r=a.filter.topics[0];(typeof r!="string"||r.length!==66)&&K7.throwError("unsupported topic format",X.errors.UNSUPPORTED_OPERATION,{topic0:r}),d.topic0=r}let b=yield this.fetch("logs",d),t={};for(let r=0;r<b.length;r++){let o=b[r];if(o.blockHash==null){if(t[o.blockNumber]==null){let n=yield this.getBlock(o.blockNumber);n&&(t[o.blockNumber]=n.hash)}o.blockHash=t[o.blockNumber]}}return b}case"getEtherPrice":return this.network.name!=="homestead"?0:parseFloat((yield this.fetch("stats",{action:"ethprice"})).ethusd);default:break}return f.perform.call(this,e,a)})}getHistory(e,a,f){return ag(this,void 0,void 0,function*(){let d={action:"txlist",address:yield this.resolveName(e),startblock:a??0,endblock:f??99999999,sort:"asc"};return(yield this.fetch("account",d)).map(t=>{["contractAddress","to"].forEach(function(o){t[o]==""&&delete t[o]}),t.creates==null&&t.contractAddress!=null&&(t.creates=t.contractAddress);let r=this.formatter.transactionResponse(t);return t.timeStamp&&(r.timestamp=parseInt(t.timeStamp)),r})})}isCommunityResource(){return this.apiKey==null}};s();x();var dg=function(c,e,a,f){function d(b){return b instanceof a?b:new a(function(t){t(b)})}return new(a||(a=Promise))(function(b,t){function r(i){try{n(f.next(i))}catch(l){t(l)}}function o(i){try{n(f.throw(i))}catch(l){t(l)}}function n(i){i.done?b(i.value):d(i.value).then(r,o)}n((f=f.apply(c,e||[])).next())})},f5=new X(ia);function cg(){return new Date().getTime()}function I0e(c){let e=null;for(let a=0;a<c.length;a++){let f=c[a];if(f==null)return null;e?e.name===f.name&&e.chainId===f.chainId&&(e.ensAddress===f.ensAddress||e.ensAddress==null&&f.ensAddress==null)||f5.throwArgumentError("provider mismatch","networks",c):e=f}return e}function L0e(c,e){c=c.slice().sort();let a=Math.floor(c.length/2);if(c.length%2)return c[a];let f=c[a-1],d=c[a];return e!=null&&Math.abs(f-d)>e?null:(f+d)/2}function $t(c){if(c===null)return"null";if(typeof c=="number"||typeof c=="boolean")return JSON.stringify(c);if(typeof c=="string")return c;if(Ee.isBigNumber(c))return c.toString();if(Array.isArray(c))return JSON.stringify(c.map(e=>$t(e)));if(typeof c=="object"){let e=Object.keys(c);return e.sort(),"{"+e.map(a=>{let f=c[a];return typeof f=="function"?f="[function]":f=$t(f),JSON.stringify(a)+":"+f}).join(",")+"}"}throw new Error("unknown value type: "+typeof c)}var swe=1;function F0e(c){let e=null,a=null,f=new Promise(t=>{e=function(){a&&(clearTimeout(a),a=null),t()},a=setTimeout(e,c)}),d=t=>(f=f.then(t),f);function b(){return f}return{cancel:e,getPromise:b,wait:d}}var xwe=[X.errors.CALL_EXCEPTION,X.errors.INSUFFICIENT_FUNDS,X.errors.NONCE_EXPIRED,X.errors.REPLACEMENT_UNDERPRICED,X.errors.UNPREDICTABLE_GAS_LIMIT],lwe=["address","args","errorArgs","errorSignature","method","transaction"];function fg(c,e){let a={weight:c.weight};return Object.defineProperty(a,"provider",{get:()=>c.provider}),c.start&&(a.start=c.start),e&&(a.duration=e-c.start),c.done&&(c.error?a.error=c.error:a.result=c.result||null),a}function uwe(c,e){return function(a){let f={};a.forEach(b=>{let t=c(b.result);f[t]||(f[t]={count:0,result:b.result}),f[t].count++});let d=Object.keys(f);for(let b=0;b<d.length;b++){let t=f[d[b]];if(t.count>=e)return t.result}}}function hwe(c,e,a){let f=$t;switch(e){case"getBlockNumber":return function(d){let b=d.map(r=>r.result),t=L0e(d.map(r=>r.result),2);if(t!=null)return t=Math.ceil(t),b.indexOf(t+1)>=0&&t++,t>=c._highestBlockNumber&&(c._highestBlockNumber=t),c._highestBlockNumber};case"getGasPrice":return function(d){let b=d.map(t=>t.result);return b.sort(),b[Math.floor(b.length/2)]};case"getEtherPrice":return function(d){return L0e(d.map(b=>b.result))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":f=function(d){return d==null?null:(d=ea(d),d.confirmations=-1,$t(d))};break;case"getBlock":a.includeTransactions?f=function(d){return d==null?null:(d=ea(d),d.transactions=d.transactions.map(b=>(b=ea(b),b.confirmations=-1,b)),$t(d))}:f=function(d){return d==null?null:$t(d)};break;default:throw new Error("unknown method: "+e)}return uwe(f,c.quorum)}function as(c,e){return dg(this,void 0,void 0,function*(){let a=c.provider;return a.blockNumber!=null&&a.blockNumber>=e||e===-1?a:W1(()=>new Promise((f,d)=>{setTimeout(function(){return a.blockNumber>=e?f(a):c.cancelled?f(null):f(void 0)},0)}),{oncePoll:a})})}function pwe(c,e,a,f){return dg(this,void 0,void 0,function*(){let d=c.provider;switch(a){case"getBlockNumber":case"getGasPrice":return d[a]();case"getEtherPrice":if(d.getEtherPrice)return d.getEtherPrice();break;case"getBalance":case"getTransactionCount":case"getCode":return f.blockTag&&n0(f.blockTag)&&(d=yield as(c,e)),d[a](f.address,f.blockTag||"latest");case"getStorageAt":return f.blockTag&&n0(f.blockTag)&&(d=yield as(c,e)),d.getStorageAt(f.address,f.position,f.blockTag||"latest");case"getBlock":return f.blockTag&&n0(f.blockTag)&&(d=yield as(c,e)),d[f.includeTransactions?"getBlockWithTransactions":"getBlock"](f.blockTag||f.blockHash);case"call":case"estimateGas":return f.blockTag&&n0(f.blockTag)&&(d=yield as(c,e)),a==="call"&&f.blockTag?d[a](f.transaction,f.blockTag):d[a](f.transaction);case"getTransaction":case"getTransactionReceipt":return d[a](f.transactionHash);case"getLogs":{let b=f.filter;return(b.fromBlock&&n0(b.fromBlock)||b.toBlock&&n0(b.toBlock))&&(d=yield as(c,e)),d.getLogs(b)}}return f5.throwError("unknown method error",X.errors.UNKNOWN_ERROR,{method:a,params:f})})}var cs=class extends Xb{constructor(e,a){e.length===0&&f5.throwArgumentError("missing providers","providers",e);let f=e.map((t,r)=>{if(Fd.isProvider(t)){let i=Ho(t)?2e3:750;return Object.freeze({provider:t,weight:1,stallTimeout:i,priority:1})}let o=ea(t);o.priority==null&&(o.priority=1),o.stallTimeout==null&&(o.stallTimeout=Ho(t)?2e3:750),o.weight==null&&(o.weight=1);let n=o.weight;return(n%1||n>512||n<1)&&f5.throwArgumentError("invalid weight; must be integer in [1, 512]",`providers[${r}].weight`,n),Object.freeze(o)}),d=f.reduce((t,r)=>t+r.weight,0);a==null?a=d/2:a>d&&f5.throwArgumentError("quorum will always fail; larger than total weight","quorum",a);let b=I0e(f.map(t=>t.provider.network));b==null&&(b=new Promise((t,r)=>{setTimeout(()=>{this.detectNetwork().then(t,r)},0)})),super(b),he(this,"providerConfigs",Object.freeze(f)),he(this,"quorum",a),this._highestBlockNumber=-1}detectNetwork(){return dg(this,void 0,void 0,function*(){let e=yield Promise.all(this.providerConfigs.map(a=>a.provider.getNetwork()));return I0e(e)})}perform(e,a){return dg(this,void 0,void 0,function*(){if(e==="sendTransaction"){let o=yield Promise.all(this.providerConfigs.map(n=>n.provider.sendTransaction(a.signedTransaction).then(i=>i.hash,i=>i)));for(let n=0;n<o.length;n++){let i=o[n];if(typeof i=="string")return i}throw o[0]}this._highestBlockNumber===-1&&e!=="getBlockNumber"&&(yield this.getBlockNumber());let f=hwe(this,e,a),d=Uo(this.providerConfigs.map(ea));d.sort((o,n)=>o.priority-n.priority);let b=this._highestBlockNumber,t=0,r=!0;for(;;){let o=cg(),n=d.filter(u=>u.runner&&o-u.start<u.stallTimeout).reduce((u,g)=>u+g.weight,0);for(;n<this.quorum&&t<d.length;){let u=d[t++],g=swe++;u.start=cg(),u.staller=F0e(u.stallTimeout),u.staller.wait(()=>{u.staller=null}),u.runner=pwe(u,b,e,a).then(E=>{u.done=!0,u.result=E,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:g,backend:fg(u,cg()),request:{method:e,params:Va(a)},provider:this})},E=>{u.done=!0,u.error=E,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:g,backend:fg(u,cg()),request:{method:e,params:Va(a)},provider:this})}),this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:g,backend:fg(u,null),request:{method:e,params:Va(a)},provider:this}),n+=u.weight}let i=[];d.forEach(u=>{u.done||!u.runner||(i.push(u.runner),u.staller&&i.push(u.staller.getPromise()))}),i.length&&(yield Promise.race(i));let l=d.filter(u=>u.done&&u.error==null);if(l.length>=this.quorum){let u=f(l);if(u!==void 0)return d.forEach(g=>{g.staller&&g.staller.cancel(),g.cancelled=!0}),u;r||(yield F0e(100).getPromise()),r=!1}let h=d.reduce((u,g)=>{if(!g.done||g.error==null)return u;let E=g.error.code;return xwe.indexOf(E)>=0&&(u[E]||(u[E]={error:g.error,weight:0}),u[E].weight+=g.weight),u},{});if(Object.keys(h).forEach(u=>{let g=h[u];if(g.weight<this.quorum)return;d.forEach(F=>{F.staller&&F.staller.cancel(),F.cancelled=!0});let E=g.error,_={};lwe.forEach(F=>{E[F]!=null&&(_[F]=E[F])}),f5.throwError(E.reason||E.message,u,_)}),d.filter(u=>!u.done).length===0)break}return d.forEach(o=>{o.staller&&o.staller.cancel(),o.cancelled=!0}),f5.throwError("failed to meet quorum",X.errors.SERVER_ERROR,{method:e,params:a,results:d.map(o=>fg(o)),provider:this})})}};s();x();var SF=null;s();x();var bg=new X(ia),fs="84842078b09946638c03157f83405213",ds=class extends m8{constructor(e,a){let f=new Vt(e,a),d=f.connection;d.password&&bg.throwError("INFURA WebSocket project secrets unsupported",X.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});let b=d.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(b,e),he(this,"apiKey",f.projectId),he(this,"projectId",f.projectId),he(this,"projectSecret",f.projectSecret)}isCommunityResource(){return this.projectId===fs}},Vt=class extends Qc{static getWebSocketProvider(e,a){return new ds(e,a)}static getApiKey(e){let a={apiKey:fs,projectId:fs,projectSecret:null};return e==null||(typeof e=="string"?a.projectId=e:e.projectSecret!=null?(bg.assertArgument(typeof e.projectId=="string","projectSecret requires a projectId","projectId",e.projectId),bg.assertArgument(typeof e.projectSecret=="string","invalid projectSecret","projectSecret","[REDACTED]"),a.projectId=e.projectId,a.projectSecret=e.projectSecret):e.projectId&&(a.projectId=e.projectId),a.apiKey=a.projectId),a}static getUrl(e,a){let f=null;switch(e?e.name:"unknown"){case"homestead":f="mainnet.infura.io";break;case"goerli":f="goerli.infura.io";break;case"sepolia":f="sepolia.infura.io";break;case"matic":f="polygon-mainnet.infura.io";break;case"maticmum":f="polygon-mumbai.infura.io";break;case"optimism":f="optimism-mainnet.infura.io";break;case"optimism-goerli":f="optimism-goerli.infura.io";break;case"arbitrum":f="arbitrum-mainnet.infura.io";break;case"arbitrum-goerli":f="arbitrum-goerli.infura.io";break;default:bg.throwError("unsupported network",X.errors.INVALID_ARGUMENT,{argument:"network",value:e})}let d={allowGzip:!0,url:"https://"+f+"/v3/"+a.projectId,throttleCallback:(b,t)=>(a.projectId===fs&&Yb(),Promise.resolve(!0))};return a.projectSecret!=null&&(d.user="",d.password=a.projectSecret),d}isCommunityResource(){return this.projectId===fs}};s();x();var tg=class extends Bd{send(e,a){let f={method:e,params:a,id:this._nextId++,jsonrpc:"2.0"};this._pendingBatch==null&&(this._pendingBatch=[]);let d={request:f,resolve:null,reject:null},b=new Promise((t,r)=>{d.resolve=t,d.reject=r});return this._pendingBatch.push(d),this._pendingBatchAggregator||(this._pendingBatchAggregator=setTimeout(()=>{let t=this._pendingBatch;this._pendingBatch=null,this._pendingBatchAggregator=null;let r=t.map(o=>o.request);return this.emit("debug",{action:"requestBatch",request:Va(r),provider:this}),Q1(this.connection,JSON.stringify(r)).then(o=>{this.emit("debug",{action:"response",request:r,response:o,provider:this}),t.forEach((n,i)=>{let l=o[i];if(l.error){let h=new Error(l.error.message);h.code=l.error.code,h.data=l.error.data,n.reject(h)}else n.resolve(l.result)})},o=>{this.emit("debug",{action:"response",error:o,request:r,provider:this}),t.forEach(n=>{n.reject(o)})})},10)),b}};s();x();var IF=new X(ia),mwe="ETHERS_JS_SHARED",bs=class extends Qc{static getApiKey(e){return e&&typeof e!="string"&&IF.throwArgumentError("invalid apiKey","apiKey",e),e||mwe}static getUrl(e,a){IF.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");let f=null;switch(e.name){case"homestead":f="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":f="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":f="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":f="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":f="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:IF.throwArgumentError("unsupported network","network",arguments[0])}return f+"?apiKey="+a}};s();x();var C0e=new X(ia),R0e="62e1ad51b37b8e00394bda3b",ts=class extends Qc{static getApiKey(e){let a={applicationId:null,loadBalancer:!0,applicationSecretKey:null};return e==null?a.applicationId=R0e:typeof e=="string"?a.applicationId=e:e.applicationSecretKey!=null?(a.applicationId=e.applicationId,a.applicationSecretKey=e.applicationSecretKey):e.applicationId?a.applicationId=e.applicationId:C0e.throwArgumentError("unsupported PocketProvider apiKey","apiKey",e),a}static getUrl(e,a){let f=null;switch(e?e.name:"unknown"){case"goerli":f="eth-goerli.gateway.pokt.network";break;case"homestead":f="eth-mainnet.gateway.pokt.network";break;case"kovan":f="poa-kovan.gateway.pokt.network";break;case"matic":f="poly-mainnet.gateway.pokt.network";break;case"maticmum":f="polygon-mumbai-rpc.gateway.pokt.network";break;case"rinkeby":f="eth-rinkeby.gateway.pokt.network";break;case"ropsten":f="eth-ropsten.gateway.pokt.network";break;default:C0e.throwError("unsupported network",X.errors.INVALID_ARGUMENT,{argument:"network",value:e})}let d=`https://${f}/v1/lb/${a.applicationId}`,b={headers:{},url:d};return a.applicationSecretKey!=null&&(b.user="",b.password=a.applicationSecretKey),b}isCommunityResource(){return this.applicationId===R0e}};s();x();var B0e=new X(ia),gwe=1;function P0e(c,e){let a="Web3LegacyFetcher";return function(f,d){let b={method:f,params:d,id:gwe++,jsonrpc:"2.0"};return new Promise((t,r)=>{this.emit("debug",{action:"request",fetcher:a,request:Va(b),provider:this}),e(b,(o,n)=>{if(o)return this.emit("debug",{action:"response",fetcher:a,error:o,request:b,provider:this}),r(o);if(this.emit("debug",{action:"response",fetcher:a,request:b,response:n,provider:this}),n.error){let i=new Error(n.error.message);return i.code=n.error.code,i.data=n.error.data,r(i)}t(n.result)})})}}function ywe(c){return function(e,a){a==null&&(a=[]);let f={method:e,params:a};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:Va(f),provider:this}),c.request(f).then(d=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:f,response:d,provider:this}),d),d=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:f,error:d,provider:this}),d})}}var rs=class extends Bd{constructor(e,a){e==null&&B0e.throwArgumentError("missing provider","provider",e);let f=null,d=null,b=null;typeof e=="function"?(f="unknown:",d=e):(f=e.host||e.path||"",!f&&e.isMetaMask&&(f="metamask"),b=e,e.request?(f===""&&(f="eip-1193:"),d=ywe(e)):e.sendAsync?d=P0e(e,e.sendAsync.bind(e)):e.send?d=P0e(e,e.send.bind(e)):B0e.throwArgumentError("unsupported provider","provider",e),f||(f="unknown:")),super(f,a),he(this,"jsonRpcFetchFunc",d),he(this,"provider",b)}send(e,a){return this.jsonRpcFetchFunc(e,a)}};var T0e=new X(ia);function rg(c,e){if(c==null&&(c="homestead"),typeof c=="string"){let f=c.match(/^(ws|http)s?:/i);if(f)switch(f[1].toLowerCase()){case"http":case"https":return new Bd(c);case"ws":case"wss":return new m8(c);default:T0e.throwArgumentError("unsupported URL scheme","network",c)}}let a=Go(c);return(!a||!a._defaultProvider)&&T0e.throwError("unsupported getDefaultProvider network",X.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:c}),a._defaultProvider({FallbackProvider:cs,AlchemyProvider:Ht,AnkrProvider:Yo,CloudflareProvider:Xo,EtherscanProvider:es,InfuraProvider:Vt,JsonRpcProvider:Bd,NodesmithProvider:bs,PocketProvider:ts,Web3Provider:rs,IpcProvider:null},e)}var og={};v0(og,{AbiCoder:()=>gt,ConstructorFragment:()=>Rf,ErrorFragment:()=>r2,EventFragment:()=>ed,FormatTypes:()=>Q0,Fragment:()=>ad,FunctionFragment:()=>Bf,HDNode:()=>Kc,Indexed:()=>b8,Interface:()=>G7,LogDescription:()=>vt,Logger:()=>X,ParamType:()=>Na,RLP:()=>fm,SigningKey:()=>a1,SupportedAlgorithm:()=>Jb,TransactionDescription:()=>Et,TransactionTypes:()=>Tm,UnicodeNormalizationForm:()=>cd,Utf8ErrorFuncs:()=>mm,Utf8ErrorReason:()=>Pf,_TypedDataEncoder:()=>Wa,_fetchData:()=>lF,_toEscapedUtf8String:()=>yL,accessListify:()=>s2,arrayify:()=>Se,base58:()=>o8,base64:()=>SL,checkProperties:()=>xt,checkResultErrors:()=>ut,commify:()=>G0e,computeAddress:()=>c1,computeHmac:()=>s8,computePublicKey:()=>Po,concat:()=>O0,deepCopy:()=>Va,defaultAbiCoder:()=>Lo,defaultPath:()=>x8,defineReadOnly:()=>he,dnsEncode:()=>Co,entropyToMnemonic:()=>c5,fetchJson:()=>Q1,formatBytes32String:()=>wL,formatEther:()=>z0e,formatUnits:()=>LF,getAccountPath:()=>Tee,getAddress:()=>M0,getContractAddress:()=>K4,getCreate2Address:()=>QY,getIcapAddress:()=>KY,getJsonWalletAddress:()=>nF,getStatic:()=>Ka,hashMessage:()=>_t,hexConcat:()=>Ec,hexDataLength:()=>Cf,hexDataSlice:()=>ya,hexStripZeros:()=>nL,hexValue:()=>kb,hexZeroPad:()=>q0,hexlify:()=>Be,id:()=>n2,isAddress:()=>VY,isBytes:()=>Q2,isBytesLike:()=>a8,isHexString:()=>n0,isValidMnemonic:()=>Pee,isValidName:()=>LL,joinSignature:()=>mo,keccak256:()=>N0,mnemonicToEntropy:()=>Mt,mnemonicToSeed:()=>aF,namehash:()=>q7,nameprep:()=>AL,parseBytes32String:()=>_L,parseEther:()=>j0e,parseTransaction:()=>Om,parseUnits:()=>FF,poll:()=>W1,randomBytes:()=>Zb,recoverAddress:()=>Z4,recoverPublicKey:()=>Pm,resolveProperties:()=>wa,ripemd160:()=>Mo,serializeTransaction:()=>To,sha256:()=>Rd,sha512:()=>ZL,shallowCopy:()=>ea,shuffled:()=>Uo,solidityKeccak256:()=>M0e,solidityPack:()=>ig,soliditySha256:()=>D0e,splitSignature:()=>Ub,stripZeros:()=>b2,toUtf8Bytes:()=>J0,toUtf8CodePoints:()=>U7,toUtf8String:()=>Ld,verifyMessage:()=>Jee,verifyTypedData:()=>Zee,zeroPad:()=>j4});s();x();s();x();s();x();var O0e="solidity/5.7.0";var wwe=new RegExp("^bytes([0-9]+)$"),_we=new RegExp("^(u?int)([0-9]*)$"),vwe=new RegExp("^(.*)\\[([0-9]*)\\]$"),Ewe="0000000000000000000000000000000000000000000000000000000000000000",Kt=new X(O0e);function N0e(c,e,a){switch(c){case"address":return a?j4(e,32):Se(e);case"string":return J0(e);case"bytes":return Se(e);case"bool":return e=e?"0x01":"0x00",a?j4(e,32):Se(e)}let f=c.match(_we);if(f){let d=parseInt(f[2]||"256");return(f[2]&&String(d)!==f[2]||d%8!==0||d===0||d>256)&&Kt.throwArgumentError("invalid number type","type",c),a&&(d=256),e=Ee.from(e).toTwos(d),j4(e,d/8)}if(f=c.match(wwe),f){let d=parseInt(f[1]);return(String(d)!==f[1]||d===0||d>32)&&Kt.throwArgumentError("invalid bytes type","type",c),Se(e).byteLength!==d&&Kt.throwArgumentError(`invalid value for ${c}`,"value",e),a?Se((e+Ewe).substring(0,66)):e}if(f=c.match(vwe),f&&Array.isArray(e)){let d=f[1];parseInt(f[2]||String(e.length))!=e.length&&Kt.throwArgumentError(`invalid array length for ${c}`,"value",e);let t=[];return e.forEach(function(r){t.push(N0e(d,r,!0))}),O0(t)}return Kt.throwArgumentError("invalid type","type",c)}function ig(c,e){c.length!=e.length&&Kt.throwArgumentError("wrong number of values; expected ${ types.length }","values",e);let a=[];return c.forEach(function(f,d){a.push(N0e(f,e[d]))}),Be(O0(a))}function M0e(c,e){return N0(ig(c,e))}function D0e(c,e){return Rd(ig(c,e))}s();x();s();x();var k0e="units/5.7.0";var U0e=new X(k0e),q0e=["wei","kwei","mwei","gwei","szabo","finney","ether"];function G0e(c){let e=String(c).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||c==="."||c==="-.")&&U0e.throwArgumentError("invalid value","value",c);let a=e[0],f="";for(a.substring(0,1)==="-"&&(f="-",a=a.substring(1));a.substring(0,1)==="0";)a=a.substring(1);a===""&&(a="0");let d="";for(e.length===2&&(d="."+(e[1]||"0"));d.length>2&&d[d.length-1]==="0";)d=d.substring(0,d.length-1);let b=[];for(;a.length;)if(a.length<=3){b.unshift(a);break}else{let t=a.length-3;b.unshift(a.substring(t)),a=a.substring(0,t)}return f+b.join(",")+d}function LF(c,e){if(typeof e=="string"){let a=q0e.indexOf(e);a!==-1&&(e=3*a)}return st(c,e??18)}function FF(c,e){if(typeof c!="string"&&U0e.throwArgumentError("value must be a string","value",c),typeof e=="string"){let a=q0e.indexOf(e);a!==-1&&(e=3*a)}return J2(c,e??18)}function z0e(c){return LF(c,18)}function j0e(c){return FF(c,18)}s();x();var sg="ethers/5.7.2";var H0e=new X(sg);try{let c=window;c._ethers==null&&(c._ethers=Qt)}catch{}var $0e=[{anonymous:!1,inputs:[{indexed:!1,internalType:"uint8",name:"version",type:"uint8"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"id",type:"uint256"},{indexed:!1,internalType:"uint256",name:"blockN",type:"uint256"},{indexed:!1,internalType:"uint256",name:"timestamp",type:"uint256"},{indexed:!1,internalType:"uint256",name:"state",type:"uint256"}],name:"StateUpdated",type:"event"},{inputs:[],name:"VERSION",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"acceptOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"}],name:"getGISTProof",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"bool",name:"existence",type:"bool"},{internalType:"uint256[64]",name:"siblings",type:"uint256[64]"},{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"auxExistence",type:"bool"},{internalType:"uint256",name:"auxIndex",type:"uint256"},{internalType:"uint256",name:"auxValue",type:"uint256"}],internalType:"struct IState.GistProof",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getGISTProofByBlock",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"bool",name:"existence",type:"bool"},{internalType:"uint256[64]",name:"siblings",type:"uint256[64]"},{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"auxExistence",type:"bool"},{internalType:"uint256",name:"auxIndex",type:"uint256"},{internalType:"uint256",name:"auxValue",type:"uint256"}],internalType:"struct IState.GistProof",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"root",type:"uint256"}],name:"getGISTProofByRoot",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"bool",name:"existence",type:"bool"},{internalType:"uint256[64]",name:"siblings",type:"uint256[64]"},{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"auxExistence",type:"bool"},{internalType:"uint256",name:"auxIndex",type:"uint256"},{internalType:"uint256",name:"auxValue",type:"uint256"}],internalType:"struct IState.GistProof",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"timestamp",type:"uint256"}],name:"getGISTProofByTime",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"bool",name:"existence",type:"bool"},{internalType:"uint256[64]",name:"siblings",type:"uint256[64]"},{internalType:"uint256",name:"index",type:"uint256"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"bool",name:"auxExistence",type:"bool"},{internalType:"uint256",name:"auxIndex",type:"uint256"},{internalType:"uint256",name:"auxValue",type:"uint256"}],internalType:"struct IState.GistProof",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getGISTRoot",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"start",type:"uint256"},{internalType:"uint256",name:"length",type:"uint256"}],name:"getGISTRootHistory",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"uint256",name:"replacedByRoot",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct IState.GistRootInfo[]",name:"",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getGISTRootHistoryLength",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"root",type:"uint256"}],name:"getGISTRootInfo",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"uint256",name:"replacedByRoot",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct IState.GistRootInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"blockNumber",type:"uint256"}],name:"getGISTRootInfoByBlock",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"uint256",name:"replacedByRoot",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct IState.GistRootInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],name:"getGISTRootInfoByTime",outputs:[{components:[{internalType:"uint256",name:"root",type:"uint256"},{internalType:"uint256",name:"replacedByRoot",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct IState.GistRootInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"}],name:"getStateInfoById",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"state",type:"uint256"},{internalType:"uint256",name:"replacedByState",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct IState.StateInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"state",type:"uint256"}],name:"getStateInfoByIdAndState",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"state",type:"uint256"},{internalType:"uint256",name:"replacedByState",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct IState.StateInfo",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"startIndex",type:"uint256"},{internalType:"uint256",name:"length",type:"uint256"}],name:"getStateInfoHistoryById",outputs:[{components:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"state",type:"uint256"},{internalType:"uint256",name:"replacedByState",type:"uint256"},{internalType:"uint256",name:"createdAtTimestamp",type:"uint256"},{internalType:"uint256",name:"replacedAtTimestamp",type:"uint256"},{internalType:"uint256",name:"createdAtBlock",type:"uint256"},{internalType:"uint256",name:"replacedAtBlock",type:"uint256"}],internalType:"struct IState.StateInfo[]",name:"",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"}],name:"getStateInfoHistoryLengthById",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getVerifier",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"}],name:"idExists",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract IStateTransitionVerifier",name:"verifierContractAddr",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pendingOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newVerifierAddr",type:"address"}],name:"setVerifier",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"state",type:"uint256"}],name:"stateExists",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"id",type:"uint256"},{internalType:"uint256",name:"oldState",type:"uint256"},{internalType:"uint256",name:"newState",type:"uint256"},{internalType:"bool",name:"isOldStateGenesis",type:"bool"},{internalType:"uint256[2]",name:"a",type:"uint256[2]"},{internalType:"uint256[2][2]",name:"b",type:"uint256[2][2]"},{internalType:"uint256[2]",name:"c",type:"uint256[2]"}],name:"transitState",outputs:[],stateMutability:"nonpayable",type:"function"}];var V0e={url:"http://localhost:8545",defaultGasLimit:6e5,minGasPrice:"0",maxGasPrice:"100000000000",confirmationBlockCount:5,confirmationTimeout:6e5,contractAddress:"0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",receiptTimeout:6e5,rpcResponseTimeout:5e3,waitReceiptCycleTime:3e4,waitBlockCycleTime:3e3},CF=class{constructor(e=V0e){this.ethConfig=e;this.provider=new Qt.providers.JsonRpcProvider(this.ethConfig.url),this.stateContract=new Qt.Contract(this.ethConfig.contractAddress,$0e,this.provider)}stateContract;provider;async getLatestStateById(e){let a=await this.stateContract.getStateInfoById(e);return{id:Ee.from(a[0]).toBigInt(),state:Ee.from(a[1]).toBigInt(),replacedByState:Ee.from(a[2]).toBigInt(),createdAtTimestamp:Ee.from(a[3]).toBigInt(),replacedAtTimestamp:Ee.from(a[4]).toBigInt(),createdAtBlock:Ee.from(a[5]).toBigInt(),replacedAtBlock:Ee.from(a[6]).toBigInt()}}async publishState(e,a){let f=new TextEncoder,d=this.stateContract.connect(a),b=new po;b.pubSignalsUnmarshal(f.encode(JSON.stringify(e.pub_signals)));let{userId:t,oldUserState:r,newUserState:o,isOldStateGenesis:n}=b,i=[t.bigInt().toString(),r.bigInt().toString(),o.bigInt().toString(),n,e.proof.pi_a.slice(0,2),[[e.proof.pi_b[0][1].toString(),e.proof.pi_b[0][0].toString()],[e.proof.pi_b[1][1].toString(),e.proof.pi_b[1][0].toString()]],e.proof.pi_c.slice(0,2)];await d.estimateGas.transitState(...i);let h=await(await d.transitState(...i)).wait(),u=h.status,g=h.transactionHash;if(u===0)throw new Error(`transaction: ${g} failed to mined`);return g}async getGISTProof(e){let a=await this.stateContract.getGISTProof(e);return{root:BigInt(a.root.toString()),existence:a.existence,siblings:a.siblings?.map(f=>BigInt(f.toString())),index:BigInt(a.index.toString()),value:BigInt(a.value.toString()),auxExistence:a.auxExistence,auxIndex:BigInt(a.auxIndex.toString()),auxValue:BigInt(a.auxValue.toString())}}async getGISTRootInfo(e){let a=await this.stateContract.getGISTRootInfo(e);return{root:BigInt(a.root.toString()),replacedByRoot:BigInt(a.replacedByRoot.toString()),createdAtTimestamp:BigInt(a.createdAtTimestamp.toString()),replacedAtTimestamp:BigInt(a.replacedAtTimestamp.toString()),createdAtBlock:BigInt(a.createdAtBlock.toString()),replacedAtBlock:BigInt(a.replacedAtBlock.toString())}}};s();x();s();x();s();x();s();x();s();x();s();x();var K0e=(a=>(a.NotDefinedQueryKey="not defined query key",a.NotDefinedComparator="not defined comparator",a))(K0e||{}),Q7={$noop:()=>!0,$eq:(c,e)=>c===e,$in:(c,e)=>e.includes(c),$nin:(c,e)=>!e.includes(c),$gt:(c,e)=>c>e,$lt:(c,e)=>c<e,$ne:(c,e)=>c!==e},RF=(c,e,a=null)=>e.split(".").reduce((f,d)=>f?f[d]:a,c),Swe=(c,e,a,f=!1)=>{if(!e)throw new Error("not defined comparator");return d=>{let b=RF(d,c);return b?f?e(a,b):e(b,a):!1}},e3=class{constructor(e,a,f,d=!1){this.path=e;this.operatorFunc=a;this.value=f;this.isReverseParams=d}execute(e){if(!this.operatorFunc)throw new Error("not defined comparator");let a=RF(e,this.path);return a==null?!1:this.isReverseParams?this.operatorFunc(this.value,a):this.operatorFunc(a,this.value)}},BF=c=>Object.keys(c).reduce((e,a)=>{let f=c[a];switch(a){case"claimId":return e.concat(new e3("id",Q7.$eq,f));case"allowedIssuers":{let[d]=f||[];return d&&d==="*"?e:e.concat(new e3("issuer",Q7.$in,f))}case"type":return e.concat(new e3("type",Q7.$in,f,!0));case"context":return e.concat(new e3("@context",Q7.$in,f,!0));case"credentialSubjectId":return e.concat(new e3("credentialSubject.id",Q7.$eq,f));case"schema":return e.concat(new e3("credentialSchema.id",Q7.$eq,f));case"skipClaimRevocationCheck":return e;case"credentialSubject":{let d=Object.keys(f).reduce((b,t)=>{let r=f[t],o=Object.keys(r).map(n=>{let i=r[n],l=`credentialSubject.${t}`;return new e3(l,Q7[n],i)});return b.concat(o)},[]);return e.concat(d)}default:throw new Error("not defined query key")}},[]);s();x();s();x();var Iwe=[0,1,2],PF=class{_data;mtDepth;constructor(e){this.mtDepth=e,this._data={}}async createIdentityMerkleTrees(e){e||(e=`${If()}`),this._data[e]=[];let a=[];return Iwe.forEach(f=>{let d=e.concat("+"+f.toString()),b=new S2(new X5(yb(d)),!0,this.mtDepth),t={treeId:d,identifier:e,type:f};this._data[e].push({tree:b,metaInfo:t}),a.push(t)}),a}async getIdentityMerkleTreesInfo(e){return this._data[e].map(a=>a.metaInfo)}async getMerkleTreeByIdentifierAndType(e,a){let f=this._data[e].find(d=>d.metaInfo.type==a);if(!f)throw new Error(`Merkle tree not found for identifier ${e} and type ${a}`);return f.tree}async addToMerkleTree(e,a,f,d){for(let b=0;b<this._data[e].length;b++)this._data[e][b].metaInfo.type===a&&await this._data[e][b].tree.add(f,d)}async bindMerkleTreeToNewIdentifier(e,a){this._data[a]=[...this._data[e]],delete this._data[e],this._data[a].forEach(f=>{f.metaInfo.identifier=a})}};s();x();s();x();var TF=class{_data=[];async save(e,a,f="id"){let d=this._data.findIndex(b=>b[f]===e);d===-1?this._data.push(a):this._data[d]=a}async get(e,a="id"){return this._data.find(f=>f[a]===e)}async load(){return this._data}async delete(e,a="id"){let f=this._data.filter(d=>d[a]!==e);if(f.length===this._data.length)throw new Error(`${"item not found"} to delete: ${e}`);this._data=f}};s();x();s();x();var OF=class{constructor(e){this._localStorageKey=e;localStorage.getItem(this._localStorageKey)||localStorage.setItem(e,JSON.stringify([]))}async save(e,a,f="id"){if(localStorage){let d=localStorage.getItem(this._localStorageKey),b=JSON.parse(d),t=b.findIndex(r=>r[f]===e);t===-1?b.push(a):b[t]=a,localStorage.setItem(this._localStorageKey,JSON.stringify(b))}}async get(e,a="id"){let f=localStorage.getItem(this._localStorageKey);return(f&&JSON.parse(f)).find(b=>b[a]===e)}async load(){let e=localStorage.getItem(this._localStorageKey);return e&&JSON.parse(e)}async delete(e,a="id"){let f=localStorage.getItem(this._localStorageKey),d=JSON.parse(f),b=d.filter(t=>t[a]!==e);if(d.length===b.length)throw new Error(`${"item not found"} to delete: ${e}`);localStorage.setItem(this._localStorageKey,JSON.stringify(b))}};s();x();var W0e=[0,1,2],a3=class{constructor(e){this._mtDepth=e}async createIdentityMerkleTrees(e){e||(e=`${If()}`);let a=()=>{let b=[];for(let t=0;t<W0e.length;t++){let r=W0e[t],n={treeId:e.concat("+"+r.toString()),identifier:e,type:r};b.push(n)}return b},f=localStorage.getItem(a3.storageKeyMeta);if(f){let b=JSON.parse(f),t=b.filter(o=>o.identifier===e);if(t.length>0)return t;let r=a();localStorage.setItem(a3.storageKeyMeta,JSON.stringify([...b,...r]))}let d=a();return localStorage.setItem(a3.storageKeyMeta,JSON.stringify(d)),d}async getIdentityMerkleTreesInfo(e){let a=localStorage.getItem(a3.storageKeyMeta);if(a)return JSON.parse(a).filter(d=>d.identifier===e);throw new Error(`Merkle tree meta not found for identifier ${e}`)}async getMerkleTreeByIdentifierAndType(e,a){let f=localStorage.getItem(a3.storageKeyMeta),d=new Error(`Merkle tree not found for identifier ${e} and type ${a}`);if(!f)throw d;let t=JSON.parse(f).filter(r=>r.identifier===e&&r.type===a)[0];if(!t)throw d;return new S2(new hn(yb(t.treeId)),!0,this._mtDepth)}async addToMerkleTree(e,a,f,d){let b=localStorage.getItem(a3.storageKeyMeta);if(!b)throw new Error(`Merkle tree meta not found for identifier ${e}`);let r=JSON.parse(b).filter(n=>n.identifier===e&&n.type===a)[0];if(!r)throw new Error(`Merkle tree not found for identifier ${e} and type ${a}`);await new S2(new hn(yb(r.treeId)),!0,this._mtDepth).add(f,d)}async bindMerkleTreeToNewIdentifier(e,a){let f=localStorage.getItem(a3.storageKeyMeta);if(!f)throw new Error(`Merkle tree meta not found for identifier ${e}`);let d=JSON.parse(f),b=d.filter(r=>r.identifier===e).map(r=>({...r,identifier:a}));if(b.length===0)throw new Error(`Merkle tree meta not found for identifier ${e}`);let t=[...d.filter(r=>r.identifier!==e),...b];localStorage.setItem(a3.storageKeyMeta,JSON.stringify(t))}},xg=a3;Zc(xg,"storageKeyMeta","merkle-tree-meta");s();x();s();x();var NF=class{constructor(e){this._storageKey=e;this._store=I3(`${e}-db`,e)}_store;async save(e,a,f="id"){return gb(e,a,this._store)}async get(e,a="id"){return Md(e,this._store)}async load(){return EO(this._store)}async delete(e,a="id"){return xl(e,this._store)}};s();x();var J0e=[0,1,2],ug=class{constructor(e){this._mtDepth=e;this._merkleTreeMetaStore=I3(`${ug.storageKeyMeta}-db`,ug.storageKeyMeta)}_merkleTreeMetaStore;async createIdentityMerkleTrees(e){e||(e=`${If()}`);let a=()=>{let b=[];for(let t=0;t<J0e.length;t++){let r=J0e[t],n={treeId:e.concat("+"+r.toString()),identifier:e,type:r};b.push(n)}return b},f=await Md(e,this._merkleTreeMetaStore);if(f)return f;let d=a();return await gb(e,d,this._merkleTreeMetaStore),d}async getIdentityMerkleTreesInfo(e){let a=await Md(e,this._merkleTreeMetaStore);if(a)return a;throw new Error(`Merkle tree meta not found for identifier ${e}`)}async getMerkleTreeByIdentifierAndType(e,a){let f=await Md(e,this._merkleTreeMetaStore),d=new Error(`Merkle tree not found for identifier ${e} and type ${a}`);if(!f)throw d;let b=f.find(t=>t.identifier===e&&t.type===a);if(!b)throw d;return new S2(new B3(yb(b.treeId)),!0,this._mtDepth)}async addToMerkleTree(e,a,f,d){let b=await Md(e,this._merkleTreeMetaStore);if(!b)throw new Error(`Merkle tree meta not found for identifier ${e}`);let t=b.find(o=>o.identifier===e&&o.type===a);if(!t)throw new Error(`Merkle tree not found for identifier ${e} and type ${a}`);await new S2(new B3(yb(t.treeId)),!0,this._mtDepth).add(f,d)}async bindMerkleTreeToNewIdentifier(e,a){let f=await Md(e,this._merkleTreeMetaStore);if(!f||!f?.length)throw new Error(`Merkle tree meta not found for identifier ${e}`);let d=f.map(b=>({...b,identifier:a}));await gb(a,d,this._merkleTreeMetaStore),await xl(e,this._merkleTreeMetaStore)}},lg=ug;Zc(lg,"storageKeyMeta","merkle-tree-meta");s();x();s();x();var hg=class{constructor(e){this._dataSource=e}async loadCircuitData(e){let a=await this._dataSource.get(e.toString(),"circuitId");if(!a)throw new Error(`${"item not found"}: ${e}`);return a}async saveCircuitData(e,a){await this._dataSource.save(e.toString(),a,"circuitId")}};Zc(hg,"storageKey","circuits");s();x();var pg=class{constructor(e){this._dataSource=e}async listCredentials(){let e=await this._dataSource.load();return e=e.map(a=>a?Object.assign(new U2,a):void 0),e}async saveCredential(e){return this._dataSource.save(e.id,e)}async saveAllCredentials(e){for(let a of e)await this._dataSource.save(a.id,a)}async removeCredential(e){return this._dataSource.delete(e)}async findCredentialById(e){let a=await this._dataSource.get(e);return a?Object.assign(new U2,a):void 0}async findCredentialsByQuery(e){let a=BF(e),f=(await this._dataSource.load()).filter(d=>a.every(b=>b.execute(d)));return f=f.map(d=>d?Object.assign(new U2,d):void 0),f}};Zc(pg,"storageKey","credentials");s();x();var ns=class{constructor(e,a){this._identityDataSource=e;this._profileDataSource=a}async saveProfile(e){let f=(await this._profileDataSource.load()).filter(b=>b.genesisIdentifier===e.genesisIdentifier),d=f.length?[...f,e]:[e];for(let b=0;b<d.length;b++){let t=d[b];await this._profileDataSource.save(t.id,t)}}async getProfileByVerifier(e){let a=await this._profileDataSource.get(e,"verifier");if(!a)throw new Error("profile not found");return a}async getProfileById(e){let a=await this._profileDataSource.get(e);if(!a)throw new Error("profile not found");return a}async getProfilesByGenesisIdentifier(e){return(await this._profileDataSource.load()).filter(a=>a.genesisIdentifier===e)}async getAllIdentities(){return this._identityDataSource.load()}async saveIdentity(e){return this._identityDataSource.save(e.identifier,e,"identifier")}async getIdentity(e){return this._identityDataSource.get(e,"identifier")}};Zc(ns,"identitiesStorageKey","identities"),Zc(ns,"profilesStorageKey","profiles");s();x();s();x();s();x();var mg=c=>({proof:c.mtp,treeState:ZI(c.issuer.state,c.issuer.claimsTreeRoot,c.issuer.revocationTreeRoot,c.issuer.rootOfRoots)}),Lwe=(c,e,a)=>{let f=new Gd;f.existence=c,f.nodeAux=a,f.depth=e.length;let d=[];for(let b=0;b<e.length;b++){let t=e[b];t.bytes.every(r=>r===0)||(k6(f.notEmpties,b),d.push(t))}return f.siblings=d,f},MF=c=>{let e=!1,a;c.existence?e=!0:c.auxExistence&&(a={key:Y0(c.auxIndex),value:Y0(c.auxValue)});let f=c.siblings.map(t=>Y0(t)),d=Lwe(e,f,a);return{root:Y0(c.root),proof:d}};s();x();s();x();var e6={};v0(e6,{exportSolidityCallData:()=>IC,fullProve:()=>EC,prove:()=>ws,verify:()=>SC});s();x();s();x();s();x();s();x();s();x();s();x();Ah();async function kF(c,e,a,f){if(a=a||4096*64,typeof e!="number"&&["w+","wx+","r","ax+","a+"].indexOf(e)<0)throw new Error("Invalid open option");let d=await Eh.promises.open(c,e),b=await d.stat();return new DF(d,b,a,f,c)}var DF=class{constructor(e,a,f,d,b){for(this.fileName=b,this.fd=e,this.pos=0,this.pageSize=d||1<<8;this.pageSize<a.blksize;)this.pageSize*=2;this.totalSize=a.size,this.totalPages=Math.floor((a.size-1)/this.pageSize)+1,this.maxPagesLoaded=Math.floor(f/this.pageSize)+1,this.pages={},this.pendingLoads=[],this.writing=!1,this.reading=!1,this.avBuffs=[],this.history={}}_loadPage(e){let a=this,f=new Promise((d,b)=>{a.pendingLoads.push({page:e,resolve:d,reject:b})});return a.__statusPage("After Load request: ",e),f}__statusPage(e,a){let f=[],d=this;if(!d.logHistory)return;f.push("=="+e+" "+a);let b="";for(let t=0;t<d.pendingLoads.length;t++)d.pendingLoads[t].page==a&&(b=b+" "+t);if(b&&f.push("Pending loads:"+b),typeof d.pages[a]<"u"){let t=d.pages[a];f.push("Loaded"),f.push("pendingOps: "+t.pendingOps),t.loading&&f.push("loading: "+t.loading),t.writing&&f.push("writing"),t.dirty&&f.push("dirty")}f.push("=="),d.history[a]||(d.history[a]=[]),d.history[a].push(f)}__printHistory(e){let a=this;a.history[e]||console.log("Empty History ",e),console.log("History "+e);for(let f=0;f<a.history[e].length;f++)for(let d=0;d<a.history[e][f].length;d++)console.log("-> "+a.history[e][f][d])}_triggerLoad(){let e=this;if(e.reading||e.pendingLoads.length==0)return;let a=Object.keys(e.pages),f=[];for(let r=0;r<a.length;r++){let o=e.pages[parseInt(a[r])];o.dirty==!1&&o.pendingOps==0&&!o.writing&&!o.loading&&f.push(parseInt(a[r]))}let d=e.maxPagesLoaded-a.length,b=[];for(;e.pendingLoads.length>0&&(typeof e.pages[e.pendingLoads[0].page]<"u"||d>0||f.length>0);){let r=e.pendingLoads.shift();if(typeof e.pages[r.page]<"u"){e.pages[r.page].pendingOps++;let o=f.indexOf(r.page);o>=0&&f.splice(o,1),e.pages[r.page].loading?e.pages[r.page].loading.push(r):r.resolve(),e.__statusPage("After Load (cached): ",r.page)}else{if(d)d--;else{let o=f.shift();e.__statusPage("Before Unload: ",o),e.avBuffs.unshift(e.pages[o]),delete e.pages[o],e.__statusPage("After Unload: ",o)}r.page>=e.totalPages?(e.pages[r.page]=t(),r.resolve(),e.__statusPage("After Load (new): ",r.page)):(e.reading=!0,e.pages[r.page]=t(),e.pages[r.page].loading=[r],b.push(e.fd.read(e.pages[r.page].buff,0,e.pageSize,r.page*e.pageSize).then(o=>{e.pages[r.page].size=o.bytesRead;let n=e.pages[r.page].loading;delete e.pages[r.page].loading;for(let i=0;i<n.length;i++)n[i].resolve();return e.__statusPage("After Load (loaded): ",r.page),o},o=>{r.reject(o)})),e.__statusPage("After Load (loading): ",r.page))}}Promise.all(b).then(()=>{e.reading=!1,e.pendingLoads.length>0&&setImmediate(e._triggerLoad.bind(e)),e._tryClose()});function t(){if(e.avBuffs.length>0){let r=e.avBuffs.shift();return r.dirty=!1,r.pendingOps=1,r.size=0,r}else return{dirty:!1,buff:new Uint8Array(e.pageSize),pendingOps:1,size:0}}}_triggerWrite(){let e=this;if(e.writing)return;let a=Object.keys(e.pages),f=[];for(let d=0;d<a.length;d++){let b=e.pages[parseInt(a[d])];b.dirty&&(b.dirty=!1,b.writing=!0,e.writing=!0,f.push(e.fd.write(b.buff,0,b.size,parseInt(a[d])*e.pageSize).then(()=>{b.writing=!1},t=>{console.log("ERROR Writing: "+t),e.error=t,e._tryClose()})))}e.writing&&Promise.all(f).then(()=>{e.writing=!1,setImmediate(e._triggerWrite.bind(e)),e._tryClose(),e.pendingLoads.length>0&&setImmediate(e._triggerLoad.bind(e))})}_getDirtyPage(){for(let e in this.pages)if(this.pages[e].dirty)return e;return-1}async write(e,a){if(e.byteLength==0)return;let f=this;if(typeof a>"u"&&(a=f.pos),f.pos=a+e.byteLength,f.totalSize<a+e.byteLength&&(f.totalSize=a+e.byteLength),f.pendingClose)throw new Error("Writing a closing file");let d=Math.floor(a/f.pageSize),b=Math.floor((a+e.byteLength-1)/f.pageSize),t=[];for(let i=d;i<=b;i++)t.push(f._loadPage(i));f._triggerLoad();let r=d,o=a%f.pageSize,n=e.byteLength;for(;n>0;){await t[r-d];let i=o+n>f.pageSize?f.pageSize-o:n,l=e.slice(e.byteLength-n,e.byteLength-n+i);new Uint8Array(f.pages[r].buff.buffer,o,i).set(l),f.pages[r].dirty=!0,f.pages[r].pendingOps--,f.pages[r].size=Math.max(o+i,f.pages[r].size),r>=f.totalPages&&(f.totalPages=r+1),n=n-i,r++,o=0,f.writing||setImmediate(f._triggerWrite.bind(f))}}async read(e,a){let f=this,d=new Uint8Array(e);return await f.readToBuffer(d,0,e,a),d}async readToBuffer(e,a,f,d){if(f==0)return;let b=this;if(f>b.pageSize*b.maxPagesLoaded*.8){let h=Math.floor(f*1.1);this.maxPagesLoaded=Math.floor(h/b.pageSize)+1}if(typeof d>"u"&&(d=b.pos),b.pos=d+f,b.pendingClose)throw new Error("Reading a closing file");let t=Math.floor(d/b.pageSize),r=Math.floor((d+f-1)/b.pageSize),o=[];for(let h=t;h<=r;h++)o.push(b._loadPage(h));b._triggerLoad();let n=t,i=d%b.pageSize,l=d+f>b.totalSize?f-(d+f-b.totalSize):f;for(;l>0;){await o[n-t],b.__statusPage("After Await (read): ",n);let h=i+l>b.pageSize?b.pageSize-i:l,u=new Uint8Array(b.pages[n].buff.buffer,b.pages[n].buff.byteOffset+i,h);e.set(u,a+f-l),b.pages[n].pendingOps--,b.__statusPage("After Op done: ",n),l=l-h,n++,i=0,b.pendingLoads.length>0&&setImmediate(b._triggerLoad.bind(b))}this.pos=d+f}_tryClose(){let e=this;!e.pendingClose||(e.error&&e.pendingCloseReject(e.error),e._getDirtyPage()>=0||e.writing||e.reading||e.pendingLoads.length>0)||e.pendingClose()}close(){let e=this;if(e.pendingClose)throw new Error("Closing the file twice");return new Promise((a,f)=>{e.pendingClose=a,e.pendingCloseReject=f,e._tryClose()}).then(()=>{e.fd.close()},a=>{throw e.fd.close(),a})}async discard(){await this.close(),await Eh.promises.unlink(this.fileName)}async writeULE32(e,a){let f=this,d=new Uint8Array(4);new DataView(d.buffer).setUint32(0,e,!0),await f.write(d,a)}async writeUBE32(e,a){let f=this,d=new Uint8Array(4);new DataView(d.buffer).setUint32(0,e,!1),await f.write(d,a)}async writeULE64(e,a){let f=this,d=new Uint8Array(8),b=new DataView(d.buffer);b.setUint32(0,e&4294967295,!0),b.setUint32(4,Math.floor(e/4294967296),!0),await f.write(d,a)}async readULE32(e){let f=await this.read(4,e);return new Uint32Array(f.buffer)[0]}async readUBE32(e){let f=await this.read(4,e);return new DataView(f.buffer).getUint32(0,!1)}async readULE64(e){let f=await this.read(8,e),d=new Uint32Array(f.buffer);return d[1]*4294967296+d[0]}async readString(e){let a=this;if(a.pendingClose)throw new Error("Reading a closing file");let f=typeof e>"u"?a.pos:e,d=Math.floor(f/a.pageSize),b=!1,t="";for(;!b;){let r=a._loadPage(d);a._triggerLoad(),await r,a.__statusPage("After Await (read): ",d);let o=f%a.pageSize,n=new Uint8Array(a.pages[d].buff.buffer,a.pages[d].buff.byteOffset+o,a.pageSize-o),i=n.findIndex(l=>l===0);b=i!==-1,b?(t+=new TextDecoder().decode(n.slice(0,i)),a.pos=d*this.pageSize+o+i+1):(t+=new TextDecoder().decode(n),a.pos=d*this.pageSize+o+n.length),a.pages[d].pendingOps--,a.__statusPage("After Op done: ",d),f=a.pos,d++,a.pendingLoads.length>0&&setImmediate(a._triggerLoad.bind(a))}return t}};s();x();function X0e(c){let e=c.initialSize||1048576,a=new gg;return a.o=c,a.o.data=new Uint8Array(e),a.allocSize=e,a.totalSize=0,a.readOnly=!1,a.pos=0,a}function eae(c){let e=new gg;return e.o=c,e.allocSize=c.data.byteLength,e.totalSize=c.data.byteLength,e.readOnly=!0,e.pos=0,e}var UF=new Uint8Array(4),Z0e=new DataView(UF.buffer),aae=new Uint8Array(8),Y0e=new DataView(aae.buffer),gg=class{constructor(){this.pageSize=1<<14}_resizeIfNeeded(e){if(e>this.allocSize){let a=Math.max(this.allocSize+1048576,Math.floor(this.allocSize*1.1),e),f=new Uint8Array(a);f.set(this.o.data),this.o.data=f,this.allocSize=a}}async write(e,a){if(typeof a>"u"&&(a=this.pos),this.readOnly)throw new Error("Writing a read only file");this._resizeIfNeeded(a+e.byteLength),this.o.data.set(e.slice(),a),a+e.byteLength>this.totalSize&&(this.totalSize=a+e.byteLength),this.pos=a+e.byteLength}async readToBuffer(e,a,f,d){if(typeof d>"u"&&(d=this.pos),this.readOnly&&d+f>this.totalSize)throw new Error("Reading out of bounds");this._resizeIfNeeded(d+f);let t=new Uint8Array(this.o.data.buffer,this.o.data.byteOffset+d,f);e.set(t,a),this.pos=d+f}async read(e,a){let f=this,d=new Uint8Array(e);return await f.readToBuffer(d,0,e,a),d}close(){this.o.data.byteLength!=this.totalSize&&(this.o.data=this.o.data.slice(0,this.totalSize))}async discard(){}async writeULE32(e,a){let f=this;Z0e.setUint32(0,e,!0),await f.write(UF,a)}async writeUBE32(e,a){let f=this;Z0e.setUint32(0,e,!1),await f.write(UF,a)}async writeULE64(e,a){let f=this;Y0e.setUint32(0,e&4294967295,!0),Y0e.setUint32(4,Math.floor(e/4294967296),!0),await f.write(aae,a)}async readULE32(e){let f=await this.read(4,e);return new Uint32Array(f.buffer)[0]}async readUBE32(e){let f=await this.read(4,e);return new DataView(f.buffer).getUint32(0,!1)}async readULE64(e){let f=await this.read(8,e),d=new Uint32Array(f.buffer);return d[1]*4294967296+d[0]}async readString(e){let a=this,f=typeof e>"u"?a.pos:e;if(f>this.totalSize){if(this.readOnly)throw new Error("Reading out of bounds");this._resizeIfNeeded(e)}let d=new Uint8Array(a.o.data.buffer,f,this.totalSize-f),b=d.findIndex(o=>o===0),t=b!==-1,r="";return t?(r=new TextDecoder().decode(d.slice(0,b)),a.pos=f+b+1):a.pos=f,r}};s();x();function dae(c){let e=c.initialSize||0,a=new yg;a.o=c;let f=e?Math.floor((e-1)/4194304)+1:0;a.o.data=[];for(let d=0;d<f-1;d++)a.o.data.push(new Uint8Array(4194304));return f&&a.o.data.push(new Uint8Array(e-4194304*(f-1))),a.totalSize=0,a.readOnly=!1,a.pos=0,a}function bae(c){let e=new yg;return e.o=c,e.totalSize=(c.data.length-1)*4194304+c.data[c.data.length-1].byteLength,e.readOnly=!0,e.pos=0,e}var qF=new Uint8Array(4),cae=new DataView(qF.buffer),tae=new Uint8Array(8),fae=new DataView(tae.buffer),yg=class{constructor(){this.pageSize=1<<14}_resizeIfNeeded(e){if(e<=this.totalSize)return;if(this.readOnly)throw new Error("Reading out of file bounds");let a=Math.floor((e-1)/4194304)+1;for(let f=Math.max(this.o.data.length-1,0);f<a;f++){let d=f<a-1?4194304:e-(a-1)*4194304,b=new Uint8Array(d);f==this.o.data.length-1&&b.set(this.o.data[f]),this.o.data[f]=b}this.totalSize=e}async write(e,a){let f=this;if(typeof a>"u"&&(a=f.pos),this.readOnly)throw new Error("Writing a read only file");this._resizeIfNeeded(a+e.byteLength);let b=Math.floor(a/4194304),t=a%4194304,r=e.byteLength;for(;r>0;){let o=t+r>4194304?4194304-t:r,n=e.slice(e.byteLength-r,e.byteLength-r+o);new Uint8Array(f.o.data[b].buffer,t,o).set(n),r=r-o,b++,t=0}this.pos=a+e.byteLength}async readToBuffer(e,a,f,d){let b=this;if(typeof d>"u"&&(d=b.pos),this.readOnly&&d+f>this.totalSize)throw new Error("Reading out of bounds");this._resizeIfNeeded(d+f);let r=Math.floor(d/4194304),o=d%4194304,n=f;for(;n>0;){let i=o+n>4194304?4194304-o:n,l=new Uint8Array(b.o.data[r].buffer,o,i);e.set(l,a+f-n),n=n-i,r++,o=0}this.pos=d+f}async read(e,a){let f=this,d=new Uint8Array(e);return await f.readToBuffer(d,0,e,a),d}close(){}async discard(){}async writeULE32(e,a){let f=this;cae.setUint32(0,e,!0),await f.write(qF,a)}async writeUBE32(e,a){let f=this;cae.setUint32(0,e,!1),await f.write(qF,a)}async writeULE64(e,a){let f=this;fae.setUint32(0,e&4294967295,!0),fae.setUint32(4,Math.floor(e/4294967296),!0),await f.write(tae,a)}async readULE32(e){let f=await this.read(4,e);return new Uint32Array(f.buffer)[0]}async readUBE32(e){let f=await this.read(4,e);return new DataView(f.buffer).getUint32(0,!1)}async readULE64(e){let f=await this.read(8,e),d=new Uint32Array(f.buffer);return d[1]*4294967296+d[0]}async readString(e){let a=this,f=2048,d=typeof e>"u"?a.pos:e;if(d>this.totalSize){if(this.readOnly)throw new Error("Reading out of bounds");this._resizeIfNeeded(e)}let b=!1,t="";for(;!b;){let r=Math.floor(d/4194304),o=d%4194304;if(a.o.data[r]===void 0)throw new Error("ERROR");let n=Math.min(f,a.o.data[r].length-o),i=new Uint8Array(a.o.data[r].buffer,o,n),l=i.findIndex(h=>h===0);b=l!==-1,b?(t+=new TextDecoder().decode(i.slice(0,l)),a.pos=r*4194304+o+l+1):(t+=new TextDecoder().decode(i),a.pos=r*4194304+o+i.length),d=a.pos}return t}};s();x();var rae=0;var nae=2;var iae=512;var oae=1024;var sae=1<<16,xae=1<<13;async function W7(c,e,a){if(typeof c=="string"&&(c={type:"file",fileName:c,cacheSize:e||sae,pageSize:a||xae}),c.type=="file")return await kF(c.fileName,oae|iae|nae,c.cacheSize,c.pageSize);if(c.type=="mem")return X0e(c);if(c.type=="bigMem")return dae(c);throw new Error("Invalid FastFile type: "+c.type)}async function c3(c,e,a){if(c instanceof Uint8Array&&(c={type:"mem",data:c}),process.browser?typeof c=="string"&&(c={type:"mem",data:await fetch(c).then(function(d){return d.arrayBuffer()}).then(function(d){return new Uint8Array(d)})}):typeof c=="string"&&(c={type:"file",fileName:c,cacheSize:e||sae,pageSize:a||xae}),c.type=="file")return await kF(c.fileName,rae,c.cacheSize,c.pageSize);if(c.type=="mem")return await eae(c);if(c.type=="bigMem")return await bae(c);throw new Error("Invalid FastFile type: "+c.type)}async function Ga(c,e,a,f,d){let b=await c3(c,f,d),t=await b.read(4),r="";for(let l=0;l<4;l++)r+=String.fromCharCode(t[l]);if(r!=e)throw new Error(c+": Invalid File format");if(await b.readULE32()>a)throw new Error("Version not supported");let n=await b.readULE32(),i=[];for(let l=0;l<n;l++){let h=await b.readULE32(),u=await b.readULE64();typeof i[h]>"u"&&(i[h]=[]),i[h].push({p:b.pos,size:u}),b.pos+=u}return{fd:b,sections:i}}async function of(c,e,a,f,d,b){let t=await W7(c,d,b),r=new Uint8Array(4);for(let o=0;o<4;o++)r[o]=e.charCodeAt(o);return await t.write(r,0),await t.writeULE32(a),await t.writeULE32(f),t}async function dd(c,e){if(typeof c.writingSection<"u")throw new Error("Already writing a section");await c.writeULE32(e),c.writingSection={pSectionSize:c.pos},await c.writeULE64(0)}async function bd(c){if(typeof c.writingSection>"u")throw new Error("Not writing a section");let e=c.pos-c.writingSection.pSectionSize-8,a=c.pos;c.pos=c.writingSection.pSectionSize,await c.writeULE64(e),c.pos=a,delete c.writingSection}async function td(c,e,a){if(typeof c.readingSection<"u")throw new Error("Already reading a section");if(!e[a])throw new Error(c.fileName+": Missing section "+a);if(e[a].length>1)throw new Error(c.fileName+": Section Duplicated "+a);c.pos=e[a][0].p,c.readingSection=e[a][0]}async function rd(c,e){if(typeof c.readingSection>"u")throw new Error("Not reading a section");if(!e&&c.pos-c.readingSection.p!=c.readingSection.size)throw new Error("Invalid section size reading");delete c.readingSection}async function Wt(c,e,a,f){let d=new Uint8Array(a);E0.toRprLE(d,0,e,a),await c.write(d,f)}async function J7(c,e,a){let f=await c.read(e,a);return E0.fromRprLE(f,0,e)}async function x2(c,e,a,f,d){if(f=typeof f>"u"?0:f,d=typeof d>"u"?e[a][0].size-f:d,f+d>e[a][0].size)throw new Error("Reading out of the range of the section");let b;return d<1<<30?b=new Uint8Array(d):b=new ca(d),await c.readToBuffer(b,0,d,e[a][0].p+f),b}s();x();s();x();var sf={};v0(sf,{abs:()=>Dwe,add:()=>os,band:()=>vg,bitLength:()=>d5,bits:()=>hae,bor:()=>Gwe,bxor:()=>zwe,div:()=>gae,e:()=>_a,eq:()=>HF,exp:()=>Mwe,fromArray:()=>Bwe,fromRprBE:()=>wae,fromRprLE:()=>t5,fromString:()=>wg,geq:()=>$F,gt:()=>xs,isNegative:()=>GF,isOdd:()=>_g,isZero:()=>lae,land:()=>jwe,leq:()=>qwe,lnot:()=>$we,lor:()=>Hwe,lt:()=>Uwe,mod:()=>ss,mul:()=>jF,naf:()=>uae,neg:()=>zF,neq:()=>kwe,one:()=>Z7,pow:()=>mae,shiftLeft:()=>is,shiftRight:()=>b5,shl:()=>Pwe,shr:()=>Twe,square:()=>Nwe,sub:()=>Jt,toArray:()=>Owe,toLEBuff:()=>d3,toNumber:()=>pae,toRprBE:()=>yae,toRprLE:()=>Zt,toString:()=>Eg,zero:()=>VF});s();x();var Rwe=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function wg(c,e){if(!e||e==10)return BigInt(c);if(e==16)return c.slice(0,2)=="0x"?BigInt(c):BigInt("0x"+c)}var _a=wg;function Bwe(c,e){let a=BigInt(0);e=BigInt(e);for(let f=0;f<c.length;f++)a=a*e+BigInt(c[f]);return a}function d5(c){let e=c.toString(16);return(e.length-1)*4+Rwe[parseInt(e[0],16)]}function GF(c){return BigInt(c)<BigInt(0)}function lae(c){return!c}function is(c,e){return BigInt(c)<<BigInt(e)}function b5(c,e){return BigInt(c)>>BigInt(e)}var Pwe=is,Twe=b5;function _g(c){return(BigInt(c)&BigInt(1))==BigInt(1)}function uae(c){let e=BigInt(c),a=[];for(;e;){if(e&BigInt(1)){let f=2-Number(e%BigInt(4));a.push(f),e=e-BigInt(f)}else a.push(0);e=e>>BigInt(1)}return a}function hae(c){let e=BigInt(c),a=[];for(;e;)e&BigInt(1)?a.push(1):a.push(0),e=e>>BigInt(1);return a}function pae(c){if(c>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Number too big");return Number(c)}function Owe(c,e){let a=[],f=BigInt(c);for(e=BigInt(e);f;)a.unshift(Number(f%e)),f=f/e;return a}function os(c,e){return BigInt(c)+BigInt(e)}function Jt(c,e){return BigInt(c)-BigInt(e)}function zF(c){return-BigInt(c)}function jF(c,e){return BigInt(c)*BigInt(e)}function Nwe(c){return BigInt(c)*BigInt(c)}function mae(c,e){return BigInt(c)**BigInt(e)}function Mwe(c,e){return BigInt(c)**BigInt(e)}function Dwe(c){return BigInt(c)>=0?BigInt(c):-BigInt(c)}function gae(c,e){return BigInt(c)/BigInt(e)}function ss(c,e){return BigInt(c)%BigInt(e)}function HF(c,e){return BigInt(c)==BigInt(e)}function kwe(c,e){return BigInt(c)!=BigInt(e)}function Uwe(c,e){return BigInt(c)<BigInt(e)}function xs(c,e){return BigInt(c)>BigInt(e)}function qwe(c,e){return BigInt(c)<=BigInt(e)}function $F(c,e){return BigInt(c)>=BigInt(e)}function vg(c,e){return BigInt(c)&BigInt(e)}function Gwe(c,e){return BigInt(c)|BigInt(e)}function zwe(c,e){return BigInt(c)^BigInt(e)}function jwe(c,e){return BigInt(c)&&BigInt(e)}function Hwe(c,e){return BigInt(c)||BigInt(e)}function $we(c){return!BigInt(c)}function Zt(c,e,a,f){let d="0000000"+a.toString(16),b=new Uint32Array(c.buffer,e,f/4),t=((d.length-7)*4-1>>5)+1;for(let r=0;r<t;r++)b[r]=parseInt(d.substring(d.length-8*r-8,d.length-8*r),16);for(let r=t;r<b.length;r++)b[r]=0;for(let r=b.length*4;r<f;r++)c[r]=pae(vg(b5(a,r*8),255))}function yae(c,e,a,f){let d="0000000"+a.toString(16),b=new DataView(c.buffer,c.byteOffset+e,f),t=((d.length-7)*4-1>>5)+1;for(let r=0;r<t;r++)b.setUint32(f-r*4-4,parseInt(d.substring(d.length-8*r-8,d.length-8*r),16),!1);for(let r=0;r<f/4-t;r++)b[r]=0}function t5(c,e,a){a=a||c.byteLength,e=e||0;let f=new Uint32Array(c.buffer,e,a/4),d=new Array(a/4);return f.forEach((b,t)=>d[d.length-t-1]=b.toString(16).padStart(8,"0")),wg(d.join(""),16)}function wae(c,e,a){a=a||c.byteLength,e=e||0;let f=new DataView(c.buffer,c.byteOffset+e,a),d=new Array(a/4);for(let b=0;b<a/4;b++)d[b]=f.getUint32(b*4,!1).toString(16).padStart(8,"0");return wg(d.join(""),16)}function Eg(c,e){return c.toString(e)}function d3(c){let e=new Uint8Array(Math.floor((d5(c)-1)/8)+1);return Zt(e,0,c,e.byteLength),e}var VF=_a(0),Z7=_a(1);s();x();var Vwe=[];for(let c=0;c<256;c++)Vwe[c]=Kwe(c,8);function Kwe(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}s();x();s();x();s();x();s();x();s();x();function Y7(c,e,a,f,d){c[e]=c[e]+c[a]>>>0,c[d]=(c[d]^c[e])>>>0,c[d]=(c[d]<<16|c[d]>>>16&65535)>>>0,c[f]=c[f]+c[d]>>>0,c[a]=(c[a]^c[f])>>>0,c[a]=(c[a]<<12|c[a]>>>20&4095)>>>0,c[e]=c[e]+c[a]>>>0,c[d]=(c[d]^c[e])>>>0,c[d]=(c[d]<<8|c[d]>>>24&255)>>>0,c[f]=c[f]+c[d]>>>0,c[a]=(c[a]^c[f])>>>0,c[a]=(c[a]<<7|c[a]>>>25&127)>>>0}function Qwe(c){Y7(c,0,4,8,12),Y7(c,1,5,9,13),Y7(c,2,6,10,14),Y7(c,3,7,11,15),Y7(c,0,5,10,15),Y7(c,1,6,11,12),Y7(c,2,7,8,13),Y7(c,3,4,9,14)}var b3=class{constructor(e){e=e||[0,0,0,0,0,0,0,0],this.state=[1634760805,857760878,2036477234,1797285236,e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],0,0,0,0],this.idx=16,this.buff=new Array(16)}nextU32(){return this.idx==16&&this.update(),this.buff[this.idx++]}nextU64(){return os(jF(this.nextU32(),4294967296),this.nextU32())}nextBool(){return(this.nextU32()&1)==1}update(){for(let e=0;e<16;e++)this.buff[e]=this.state[e];for(let e=0;e<10;e++)Qwe(this.buff);for(let e=0;e<16;e++)this.buff[e]=this.buff[e]+this.state[e]>>>0;this.idx=0,this.state[12]=this.state[12]+1>>>0,this.state[12]==0&&(this.state[13]=this.state[13]+1>>>0,this.state[13]==0&&(this.state[14]=this.state[14]+1>>>0,this.state[14]==0&&(this.state[15]=this.state[15]+1>>>0)))}};_3();function _ae(c){let e=new Uint8Array(c);if(process.browser)if(typeof globalThis.crypto<"u")globalThis.crypto.getRandomValues(e);else for(let a=0;a<c;a++)e[a]=Math.random()*4294967296>>>0;else o1.randomFillSync(e);return e}function Wwe(){let c=_ae(32),e=new Uint32Array(c.buffer),a=[];for(let f=0;f<8;f++)a.push(e[f]);return a}var Sg=null;function Yt(){return Sg||(Sg=new b3(Wwe()),Sg)}s();x();s();x();s();x();s();x();s();x();var Lae=Fe(E3(),1);s();x();s();x();var Ig={};v0(Ig,{array2buffer:()=>us,beBuff2int:()=>Zwe,beInt2Buff:()=>Ywe,bitReverse:()=>Aae,buffReverseBits:()=>YF,buffer2array:()=>Xt,leBuff2int:()=>Xwe,leInt2Buff:()=>ZF,log2:()=>Mf,stringifyBigInts:()=>KF,stringifyFElements:()=>WF,unstringifyBigInts:()=>QF,unstringifyFElements:()=>JF});s();x();function KF(c){if(typeof c=="bigint"||c.eq!==void 0)return c.toString(10);if(c instanceof Uint8Array)return t5(c,0);if(Array.isArray(c))return c.map(KF);if(typeof c=="object"){let e={};return Object.keys(c).forEach(f=>{e[f]=KF(c[f])}),e}else return c}function QF(c){if(typeof c=="string"&&/^[0-9]+$/.test(c))return BigInt(c);if(typeof c=="string"&&/^0x[0-9a-fA-F]+$/.test(c))return BigInt(c);if(Array.isArray(c))return c.map(QF);if(typeof c=="object"){if(c===null)return null;let e={};return Object.keys(c).forEach(f=>{e[f]=QF(c[f])}),e}else return c}function Zwe(c){let e=BigInt(0),a=c.length,f=0,d=new DataView(c.buffer,c.byteOffset,c.byteLength);for(;a>0;)a>=4?(a-=4,e+=BigInt(d.getUint32(a))<<BigInt(f*8),f+=4):a>=2?(a-=2,e+=BigInt(d.getUint16(a))<<BigInt(f*8),f+=2):(a-=1,e+=BigInt(d.getUint8(a))<<BigInt(f*8),f+=1);return e}function Ywe(c,e){let a=c,f=new Uint8Array(e),d=new DataView(f.buffer),b=e;for(;b>0;)b-4>=0?(b-=4,d.setUint32(b,Number(a&BigInt(4294967295))),a=a>>BigInt(32)):b-2>=0?(b-=2,d.setUint16(b,Number(a&BigInt(65535))),a=a>>BigInt(16)):(b-=1,d.setUint8(b,Number(a&BigInt(255))),a=a>>BigInt(8));if(a)throw new Error("Number does not fit in this length");return f}function Xwe(c){let e=BigInt(0),a=0,f=new DataView(c.buffer,c.byteOffset,c.byteLength);for(;a<c.length;)a+4<=c.length?(e+=BigInt(f.getUint32(a,!0))<<BigInt(a*8),a+=4):a+4<=c.length?(e+=BigInt(f.getUint16(a,!0))<<BigInt(a*8),a+=2):(e+=BigInt(f.getUint8(a,!0))<<BigInt(a*8),a+=1);return e}function ZF(c,e){let a=c;typeof e>"u"&&(e=Math.floor((d5(c)-1)/8)+1,e==0&&(e=1));let f=new Uint8Array(e),d=new DataView(f.buffer),b=0;for(;b<e;)b+4<=e?(d.setUint32(b,Number(a&BigInt(4294967295)),!0),b+=4,a=a>>BigInt(32)):b+2<=e?(d.setUint16(Number(b,a&BigInt(65535)),!0),b+=2,a=a>>BigInt(16)):(d.setUint8(Number(b,a&BigInt(255)),!0),b+=1,a=a>>BigInt(8));if(a)throw new Error("Number does not fit in this length");return f}function WF(c,e){if(typeof e=="bigint"||e.eq!==void 0)return e.toString(10);if(e instanceof Uint8Array)return c.toString(c.e(e));if(Array.isArray(e))return e.map(WF.bind(this,c));if(typeof e=="object"){let a={};return Object.keys(e).forEach(d=>{a[d]=WF(c,e[d])}),a}else return e}function JF(c,e){if(typeof e=="string"&&/^[0-9]+$/.test(e))return c.e(e);if(typeof e=="string"&&/^0x[0-9a-fA-F]+$/.test(e))return c.e(e);if(Array.isArray(e))return e.map(JF.bind(this,c));if(typeof e=="object"){if(e===null)return null;let a={};return Object.keys(e).forEach(d=>{a[d]=JF(c,e[d])}),a}else return e}var ls=[];for(let c=0;c<256;c++)ls[c]=e_e(c,8);function e_e(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}function Aae(c,e){return(ls[c>>>24]|ls[c>>>16&255]<<8|ls[c>>>8&255]<<16|ls[c&255]<<24)>>>32-e}function Mf(c){return((c&4294901760)!==0?(c&=4294901760,16):0)|((c&4278255360)!==0?(c&=4278255360,8):0)|((c&4042322160)!==0?(c&=4042322160,4):0)|((c&3435973836)!==0?(c&=3435973836,2):0)|(c&2863311530)!==0}function YF(c,e){let a=c.byteLength/e,f=Mf(a);if(a!=1<<f)throw new Error("Invalid number of pointers");for(let d=0;d<a;d++){let b=Aae(d,f);if(d>b){let t=c.slice(d*e,(d+1)*e);c.set(c.slice(b*e,(b+1)*e),d*e),c.set(t,b*e)}}}function us(c,e){let a=new Uint8Array(e*c.length);for(let f=0;f<c.length;f++)a.set(c[f],f*e);return a}function Xt(c,e){let a=c.byteLength/e,f=new Array(a);for(let d=0;d<a;d++)f[d]=c.slice(d*e,d*e+e);return f}s();x();s();x();var I0=class{constructor(e){this.buffers=[],this.byteLength=e;for(let a=0;a<e;a+=1073741824){let f=Math.min(e-a,1073741824);this.buffers.push(new Uint8Array(f))}}slice(e,a){a===void 0&&(a=this.byteLength),e===void 0&&(e=0);let f=a-e,d=Math.floor(e/1073741824),b=Math.floor((e+f-1)/1073741824);if(d==b||f==0)return this.buffers[d].slice(e%1073741824,e%1073741824+f);let t,r=d,o=e%1073741824,n=f;for(;n>0;){let i=o+n>1073741824?1073741824-o:n,l=new Uint8Array(this.buffers[r].buffer,this.buffers[r].byteOffset+o,i);if(i==f)return l.slice();t||(f<=1073741824?t=new Uint8Array(f):t=new I0(f)),t.set(l,f-n),n=n-i,r++,o=0}return t}set(e,a){a===void 0&&(a=0);let f=e.byteLength;if(f==0)return;let d=Math.floor(a/1073741824),b=Math.floor((a+f-1)/1073741824);if(d==b)return e instanceof I0&&e.buffers.length==1?this.buffers[d].set(e.buffers[0],a%1073741824):this.buffers[d].set(e,a%1073741824);let t=d,r=a%1073741824,o=f;for(;o>0;){let n=r+o>1073741824?1073741824-r:o,i=e.slice(f-o,f-o+n);new Uint8Array(this.buffers[t].buffer,this.buffers[t].byteOffset+r,n).set(i),o=o-n,t++,r=0}}};function J1(c,e,a,f){return async function(b){let t=Math.floor(b.byteLength/a);if(t*a!==b.byteLength)throw new Error("Invalid buffer size");let r=Math.floor(t/c.concurrency),o=[];for(let h=0;h<c.concurrency;h++){let u;if(h<c.concurrency-1?u=r:u=t-h*r,u==0)continue;let E=[{cmd:"ALLOCSET",var:0,buff:b.slice(h*r*a,h*r*a+u*a)},{cmd:"ALLOC",var:1,len:f*u},{cmd:"CALL",fnName:e,params:[{var:0},{val:u},{var:1}]},{cmd:"GET",out:0,var:1,len:f*u}];o.push(c.queueAction(E))}let n=await Promise.all(o),i;b instanceof I0?i=new I0(t*f):i=new Uint8Array(t*f);let l=0;for(let h=0;h<n.length;h++)i.set(n[h][0],l),l+=n[h][0].byteLength;return i}}var er=class{constructor(e,a,f,d){if(this.tm=e,this.prefix=a,this.p=d,this.n8=f,this.type="F1",this.m=1,this.half=b5(d,Z7),this.bitLength=d5(d),this.mask=Jt(is(Z7,this.bitLength),Z7),this.pOp1=e.alloc(f),this.pOp2=e.alloc(f),this.pOp3=e.alloc(f),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,this.n8),this.tm.instance.exports[a+"_one"](this.pOp1),this.one=this.tm.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.n64=Math.floor(f/8),this.n32=Math.floor(f/4),this.n64*8!=this.n8)throw new Error("n8 must be a multiple of 8");this.half=b5(this.p,Z7),this.nqr=this.two;let b=this.exp(this.nqr,this.half);for(;!this.eq(b,this.negone);)this.nqr=this.add(this.nqr,this.one),b=this.exp(this.nqr,this.half);this.shift=this.mul(this.nqr,this.nqr),this.shiftInv=this.inv(this.shift),this.s=0;let t=Jt(this.p,Z7);for(;!_g(t);)this.s=this.s+1,t=b5(t,Z7);this.w=[],this.w[this.s]=this.exp(this.nqr,t);for(let r=this.s-1;r>=0;r--)this.w[r]=this.square(this.w[r+1]);if(!this.eq(this.w[0],this.one))throw new Error("Error calculating roots of unity");this.batchToMontgomery=J1(e,a+"_batchToMontgomery",this.n8,this.n8),this.batchFromMontgomery=J1(e,a+"_batchFromMontgomery",this.n8,this.n8)}op2(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2)}op1(e,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(e,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}add(e,a){return this.op2("_add",e,a)}eq(e,a){return this.op2Bool("_eq",e,a)}isZero(e){return this.op1Bool("_isZero",e)}sub(e,a){return this.op2("_sub",e,a)}neg(e){return this.op1("_neg",e)}inv(e){return this.op1("_inverse",e)}toMontgomery(e){return this.op1("_toMontgomery",e)}fromMontgomery(e){return this.op1("_fromMontgomery",e)}mul(e,a){return this.op2("_mul",e,a)}div(e,a){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(e){return this.op1("_square",e)}isSquare(e){return this.op1Bool("_isSquare",e)}sqrt(e){return this.op1("_sqrt",e)}exp(e,a){return a instanceof Uint8Array||(a=d3(_a(a))),this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}isNegative(e){return this.op1Bool("_isNegative",e)}e(e,a){if(e instanceof Uint8Array)return e;let f=_a(e,a);GF(f)?(f=zF(f),xs(f,this.p)&&(f=ss(f,this.p)),f=Jt(this.p,f)):xs(f,this.p)&&(f=ss(f,this.p));let d=ZF(f,this.n8);return this.toMontgomery(d)}toString(e,a){let f=this.fromMontgomery(e),d=t5(f,0);return Eg(d,a)}fromRng(e){let a,f=new Uint8Array(this.n8);do{a=VF;for(let d=0;d<this.n64;d++)a=os(a,is(e.nextU64(),64*d));a=vg(a,this.mask)}while($F(a,this.p));return Zt(f,0,a,this.n8),f}random(){return this.fromRng(Yt())}toObject(e){let a=this.fromMontgomery(e);return t5(a,0)}fromObject(e){let a=new Uint8Array(this.n8);return Zt(a,0,e,this.n8),this.toMontgomery(a)}toRprLE(e,a,f){e.set(this.fromMontgomery(f),a)}toRprBE(e,a,f){let d=this.fromMontgomery(f);for(let b=0;b<this.n8/2;b++){let t=d[b];d[b]=d[this.n8-1-b],d[this.n8-1-b]=t}e.set(d,a)}fromRprLE(e,a){a=a||0;let f=e.slice(a,a+this.n8);return this.toMontgomery(f)}async batchInverse(e){let a=!1,f=this.n8,d=this.n8;Array.isArray(e)?(e=us(e,f),a=!0):e=e.slice(0,e.byteLength);let b=Math.floor(e.byteLength/f);if(b*f!==e.byteLength)throw new Error("Invalid buffer size");let t=Math.floor(b/this.tm.concurrency),r=[];for(let l=0;l<this.tm.concurrency;l++){let h;if(l<this.tm.concurrency-1?h=t:h=b-l*t,h==0)continue;let g=[{cmd:"ALLOCSET",var:0,buff:e.slice(l*t*f,l*t*f+h*f)},{cmd:"ALLOC",var:1,len:d*h},{cmd:"CALL",fnName:this.prefix+"_batchInverse",params:[{var:0},{val:f},{val:h},{var:1},{val:d}]},{cmd:"GET",out:0,var:1,len:d*h}];r.push(this.tm.queueAction(g))}let o=await Promise.all(r),n;e instanceof I0?n=new I0(b*d):n=new Uint8Array(b*d);let i=0;for(let l=0;l<o.length;l++)n.set(o[l][0],i),i+=o[l][0].byteLength;return a?Xt(n,d):n}};s();x();var ar=class{constructor(e,a,f){this.tm=e,this.prefix=a,this.F=f,this.type="F2",this.m=f.m*2,this.n8=this.F.n8*2,this.n32=this.F.n32*2,this.n64=this.F.n64*2,this.pOp1=e.alloc(f.n8*2),this.pOp2=e.alloc(f.n8*2),this.pOp3=e.alloc(f.n8*2),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=e.getBuff(this.pOp1,this.n8),this.tm.instance.exports[a+"_one"](this.pOp1),this.one=e.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one)}op2(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2)}op1(e,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(e,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}add(e,a){return this.op2("_add",e,a)}eq(e,a){return this.op2Bool("_eq",e,a)}isZero(e){return this.op1Bool("_isZero",e)}sub(e,a){return this.op2("_sub",e,a)}neg(e){return this.op1("_neg",e)}inv(e){return this.op1("_inverse",e)}isNegative(e){return this.op1Bool("_isNegative",e)}toMontgomery(e){return this.op1("_toMontgomery",e)}fromMontgomery(e){return this.op1("_fromMontgomery",e)}mul(e,a){return this.op2("_mul",e,a)}mul1(e,a){return this.op2("_mul1",e,a)}div(e,a){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(e){return this.op1("_square",e)}isSquare(e){return this.op1Bool("_isSquare",e)}sqrt(e){return this.op1("_sqrt",e)}exp(e,a){return a instanceof Uint8Array||(a=d3(_a(a))),this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}e(e,a){if(e instanceof Uint8Array)return e;if(Array.isArray(e)&&e.length==2){let f=this.F.e(e[0],a),d=this.F.e(e[1],a),b=new Uint8Array(this.F.n8*2);return b.set(f),b.set(d,this.F.n8*2),b}else throw new Error("invalid F2")}toString(e,a){let f=this.F.toString(e.slice(0,this.F.n8),a),d=this.F.toString(e.slice(this.F.n8),a);return`[${f}, ${d}]`}fromRng(e){let a=this.F.fromRng(e),f=this.F.fromRng(e),d=new Uint8Array(this.F.n8*2);return d.set(a),d.set(f,this.F.n8),d}random(){return this.fromRng(Yt())}toObject(e){let a=this.F.toObject(e.slice(0,this.F.n8)),f=this.F.toObject(e.slice(this.F.n8,this.F.n8*2));return[a,f]}fromObject(e){let a=new Uint8Array(this.F.n8*2),f=this.F.fromObject(e[0]),d=this.F.fromObject(e[1]);return a.set(f),a.set(d,this.F.n8),a}c1(e){return e.slice(0,this.F.n8)}c2(e){return e.slice(this.F.n8)}};s();x();var hs=class{constructor(e,a,f){this.tm=e,this.prefix=a,this.F=f,this.type="F3",this.m=f.m*3,this.n8=this.F.n8*3,this.n32=this.F.n32*3,this.n64=this.F.n64*3,this.pOp1=e.alloc(f.n8*3),this.pOp2=e.alloc(f.n8*3),this.pOp3=e.alloc(f.n8*3),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=e.getBuff(this.pOp1,this.n8),this.tm.instance.exports[a+"_one"](this.pOp1),this.one=e.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one)}op2(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2)}op1(e,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(e,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}eq(e,a){return this.op2Bool("_eq",e,a)}isZero(e){return this.op1Bool("_isZero",e)}add(e,a){return this.op2("_add",e,a)}sub(e,a){return this.op2("_sub",e,a)}neg(e){return this.op1("_neg",e)}inv(e){return this.op1("_inverse",e)}isNegative(e){return this.op1Bool("_isNegative",e)}toMontgomery(e){return this.op1("_toMontgomery",e)}fromMontgomery(e){return this.op1("_fromMontgomery",e)}mul(e,a){return this.op2("_mul",e,a)}div(e,a){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(e){return this.op1("_square",e)}isSquare(e){return this.op1Bool("_isSquare",e)}sqrt(e){return this.op1("_sqrt",e)}exp(e,a){return a instanceof Uint8Array||(a=d3(_a(a))),this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.getBuff(this.pOp3,this.n8)}e(e,a){if(e instanceof Uint8Array)return e;if(Array.isArray(e)&&e.length==3){let f=this.F.e(e[0],a),d=this.F.e(e[1],a),b=this.F.e(e[2],a),t=new Uint8Array(this.F.n8*3);return t.set(f),t.set(d,this.F.n8),t.set(b,this.F.n8*2),t}else throw new Error("invalid F3")}toString(e,a){let f=this.F.toString(e.slice(0,this.F.n8),a),d=this.F.toString(e.slice(this.F.n8,this.F.n8*2),a),b=this.F.toString(e.slice(this.F.n8*2),a);return`[${f}, ${d}, ${b}]`}fromRng(e){let a=this.F.fromRng(e),f=this.F.fromRng(e),d=this.F.fromRng(e),b=new Uint8Array(this.F.n8*3);return b.set(a),b.set(f,this.F.n8),b.set(d,this.F.n8*2),b}random(){return this.fromRng(Yt())}toObject(e){let a=this.F.toObject(e.slice(0,this.F.n8)),f=this.F.toObject(e.slice(this.F.n8,this.F.n8*2)),d=this.F.toObject(e.slice(this.F.n8*2,this.F.n8*3));return[a,f,d]}fromObject(e){let a=new Uint8Array(this.F.n8*3),f=this.F.fromObject(e[0]),d=this.F.fromObject(e[1]),b=this.F.fromObject(e[2]);return a.set(f),a.set(d,this.F.n8),a.set(b,this.F.n8*2),a}c1(e){return e.slice(0,this.F.n8)}c2(e){return e.slice(this.F.n8,this.F.n8*2)}c3(e){return e.slice(this.F.n8*2)}};s();x();var cr=class{constructor(e,a,f,d,b,t){this.tm=e,this.prefix=a,this.F=f,this.pOp1=e.alloc(f.n8*3),this.pOp2=e.alloc(f.n8*3),this.pOp3=e.alloc(f.n8*3),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,f.n8*3),this.tm.instance.exports[a+"_zeroAffine"](this.pOp1),this.zeroAffine=this.tm.getBuff(this.pOp1,f.n8*2),this.one=this.tm.getBuff(d,f.n8*3),this.g=this.one,this.oneAffine=this.tm.getBuff(d,f.n8*2),this.gAffine=this.oneAffine,this.b=this.tm.getBuff(b,f.n8),t&&(this.cofactor=d3(t)),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.batchLEMtoC=J1(e,a+"_batchLEMtoC",f.n8*2,f.n8),this.batchLEMtoU=J1(e,a+"_batchLEMtoU",f.n8*2,f.n8*2),this.batchCtoLEM=J1(e,a+"_batchCtoLEM",f.n8,f.n8*2),this.batchUtoLEM=J1(e,a+"_batchUtoLEM",f.n8*2,f.n8*2),this.batchToJacobian=J1(e,a+"_batchToJacobian",f.n8*2,f.n8*3),this.batchToAffine=J1(e,a+"_batchToAffine",f.n8*3,f.n8*2)}op2(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}op2bool(e,a,f){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,f),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3)}op1(e,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}op1Affine(e,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*2)}op1Bool(e,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}add(e,a){if(e.byteLength==this.F.n8*3){if(a.byteLength==this.F.n8*3)return this.op2("_add",e,a);if(a.byteLength==this.F.n8*2)return this.op2("_addMixed",e,a);throw new Error("invalid point size")}else if(e.byteLength==this.F.n8*2){if(a.byteLength==this.F.n8*3)return this.op2("_addMixed",a,e);if(a.byteLength==this.F.n8*2)return this.op2("_addAffine",e,a);throw new Error("invalid point size")}else throw new Error("invalid point size")}sub(e,a){if(e.byteLength==this.F.n8*3){if(a.byteLength==this.F.n8*3)return this.op2("_sub",e,a);if(a.byteLength==this.F.n8*2)return this.op2("_subMixed",e,a);throw new Error("invalid point size")}else if(e.byteLength==this.F.n8*2){if(a.byteLength==this.F.n8*3)return this.op2("_subMixed",a,e);if(a.byteLength==this.F.n8*2)return this.op2("_subAffine",e,a);throw new Error("invalid point size")}else throw new Error("invalid point size")}neg(e){if(e.byteLength==this.F.n8*3)return this.op1("_neg",e);if(e.byteLength==this.F.n8*2)return this.op1Affine("_negAffine",e);throw new Error("invalid point size")}double(e){if(e.byteLength==this.F.n8*3)return this.op1("_double",e);if(e.byteLength==this.F.n8*2)return this.op1("_doubleAffine",e);throw new Error("invalid point size")}isZero(e){if(e.byteLength==this.F.n8*3)return this.op1Bool("_isZero",e);if(e.byteLength==this.F.n8*2)return this.op1Bool("_isZeroAffine",e);throw new Error("invalid point size")}timesScalar(e,a){a instanceof Uint8Array||(a=d3(_a(a)));let f;if(e.byteLength==this.F.n8*3)f=this.prefix+"_timesScalar";else if(e.byteLength==this.F.n8*2)f=this.prefix+"_timesScalarAffine";else throw new Error("invalid point size");return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[f](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}timesFr(e,a){let f;if(e.byteLength==this.F.n8*3)f=this.prefix+"_timesFr";else if(e.byteLength==this.F.n8*2)f=this.prefix+"_timesFrAffine";else throw new Error("invalid point size");return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[f](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}eq(e,a){if(e.byteLength==this.F.n8*3){if(a.byteLength==this.F.n8*3)return this.op2bool("_eq",e,a);if(a.byteLength==this.F.n8*2)return this.op2bool("_eqMixed",e,a);throw new Error("invalid point size")}else if(e.byteLength==this.F.n8*2){if(a.byteLength==this.F.n8*3)return this.op2bool("_eqMixed",a,e);if(a.byteLength==this.F.n8*2)return this.op2bool("_eqAffine",e,a);throw new Error("invalid point size")}else throw new Error("invalid point size")}toAffine(e){if(e.byteLength==this.F.n8*3)return this.op1Affine("_toAffine",e);if(e.byteLength==this.F.n8*2)return e;throw new Error("invalid point size")}toJacobian(e){if(e.byteLength==this.F.n8*3)return e;if(e.byteLength==this.F.n8*2)return this.op1("_toJacobian",e);throw new Error("invalid point size")}toRprUncompressed(e,a,f){if(this.tm.setBuff(this.pOp1,f),f.byteLength==this.F.n8*3)this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);else if(f.byteLength!=this.F.n8*2)throw new Error("invalid point size");this.tm.instance.exports[this.prefix+"_LEMtoU"](this.pOp1,this.pOp1);let d=this.tm.getBuff(this.pOp1,this.F.n8*2);e.set(d,a)}fromRprUncompressed(e,a){let f=e.slice(a,a+this.F.n8*2);return this.tm.setBuff(this.pOp1,f),this.tm.instance.exports[this.prefix+"_UtoLEM"](this.pOp1,this.pOp1),this.tm.getBuff(this.pOp1,this.F.n8*2)}toRprCompressed(e,a,f){if(this.tm.setBuff(this.pOp1,f),f.byteLength==this.F.n8*3)this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);else if(f.byteLength!=this.F.n8*2)throw new Error("invalid point size");this.tm.instance.exports[this.prefix+"_LEMtoC"](this.pOp1,this.pOp1);let d=this.tm.getBuff(this.pOp1,this.F.n8);e.set(d,a)}fromRprCompressed(e,a){let f=e.slice(a,a+this.F.n8);return this.tm.setBuff(this.pOp1,f),this.tm.instance.exports[this.prefix+"_CtoLEM"](this.pOp1,this.pOp2),this.tm.getBuff(this.pOp2,this.F.n8*2)}toUncompressed(e){let a=new Uint8Array(this.F.n8*2);return this.toRprUncompressed(a,0,e),a}toRprLEM(e,a,f){if(f.byteLength==this.F.n8*2){e.set(f,a);return}else if(f.byteLength==this.F.n8*3){this.tm.setBuff(this.pOp1,f),this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);let d=this.tm.getBuff(this.pOp1,this.F.n8*2);e.set(d,a)}else throw new Error("invalid point size")}fromRprLEM(e,a){return a=a||0,e.slice(a,a+this.F.n8*2)}toString(e,a){if(e.byteLength==this.F.n8*3){let f=this.F.toString(e.slice(0,this.F.n8),a),d=this.F.toString(e.slice(this.F.n8,this.F.n8*2),a),b=this.F.toString(e.slice(this.F.n8*2),a);return`[ ${f}, ${d}, ${b} ]`}else if(e.byteLength==this.F.n8*2){let f=this.F.toString(e.slice(0,this.F.n8),a),d=this.F.toString(e.slice(this.F.n8),a);return`[ ${f}, ${d} ]`}else throw new Error("invalid point size")}isValid(e){if(this.isZero(e))return!0;let a=this.F,f=this.toAffine(e),d=f.slice(0,this.F.n8),b=f.slice(this.F.n8,this.F.n8*2),t=a.add(a.mul(a.square(d),d),this.b),r=a.square(b);return a.eq(t,r)}fromRng(e){let a=this.F,f=[],d,b;do f[0]=a.fromRng(e),d=e.nextBool(),b=a.add(a.mul(a.square(f[0]),f[0]),this.b);while(!a.isSquare(b));f[1]=a.sqrt(b);let t=a.isNegative(f[1]);d^t&&(f[1]=a.neg(f[1]));let r=new Uint8Array(this.F.n8*2);return r.set(f[0]),r.set(f[1],this.F.n8),this.cofactor&&(r=this.timesScalar(r,this.cofactor)),r}toObject(e){if(this.isZero(e))return[this.F.toObject(this.F.zero),this.F.toObject(this.F.one),this.F.toObject(this.F.zero)];let a=this.F.toObject(e.slice(0,this.F.n8)),f=this.F.toObject(e.slice(this.F.n8,this.F.n8*2)),d;return e.byteLength==this.F.n8*3?d=this.F.toObject(e.slice(this.F.n8*2,this.F.n8*3)):d=this.F.toObject(this.F.one),[a,f,d]}fromObject(e){let a=this.F.fromObject(e[0]),f=this.F.fromObject(e[1]),d;if(e.length==3?d=this.F.fromObject(e[2]):d=this.F.one,this.F.isZero(d,this.F.one))return this.zeroAffine;if(this.F.eq(d,this.F.one)){let b=new Uint8Array(this.F.n8*2);return b.set(a),b.set(f,this.F.n8),b}else{let b=new Uint8Array(this.F.n8*3);return b.set(a),b.set(f,this.F.n8),b.set(d,this.F.n8*2),b}}e(e){return e instanceof Uint8Array?e:this.fromObject(e)}x(e){return this.toAffine(e).slice(0,this.F.n8)}y(e){return this.toAffine(e).slice(this.F.n8)}};s();x();s();x();function Lg(c){let a,f;c&&(c.onmessage=function(i){let l;if(i.data?l=i.data:l=i,l[0].cmd=="INIT")d(l[0]).then(function(){c.postMessage(l.result)});else if(l[0].cmd=="TERMINATE")c.close();else{let h=n(l);c.postMessage(h)}});async function d(i){let l=new Uint8Array(i.code),h=await WebAssembly.compile(l);f=new WebAssembly.Memory({initial:i.init,maximum:32767}),a=await WebAssembly.instantiate(h,{env:{memory:f}})}function b(i){let l=new Uint32Array(f.buffer,0,1);for(;l[0]&3;)l[0]++;let h=l[0];if(l[0]+=i,l[0]+i>f.buffer.byteLength){let u=f.buffer.byteLength/65536,g=Math.floor((l[0]+i)/65536)+1;g>32767&&(g=32767),f.grow(g-u)}return h}function t(i){let l=b(i.byteLength);return o(l,i),l}function r(i,l){let h=new Uint8Array(f.buffer);return new Uint8Array(h.buffer,h.byteOffset+i,l)}function o(i,l){new Uint8Array(f.buffer).set(new Uint8Array(l),i)}function n(i){if(i[0].cmd=="INIT")return d(i[0]);let l={vars:[],out:[]},u=new Uint32Array(f.buffer,0,1)[0];for(let E=0;E<i.length;E++)switch(i[E].cmd){case"ALLOCSET":l.vars[i[E].var]=t(i[E].buff);break;case"ALLOC":l.vars[i[E].var]=b(i[E].len);break;case"SET":o(l.vars[i[E].var],i[E].buff);break;case"CALL":{let _=[];for(let F=0;F<i[E].params.length;F++){let L=i[E].params[F];typeof L.var<"u"?_.push(l.vars[L.var]+(L.offset||0)):typeof L.val<"u"&&_.push(L.val)}a.exports[i[E].fnName](..._);break}case"GET":l.out[i[E].out]=r(l.vars[i[E].var],i[E].len).slice();break;default:throw new Error("Invalid cmd")}let g=new Uint32Array(f.buffer,0,1);return g[0]=u,l.out}return n}var Sae=Fe(Wr(),1),XF=25,Fg=class{constructor(){this.promise=new Promise((e,a)=>{this.reject=a,this.resolve=e})}};function a_e(c){return new Promise(e=>setTimeout(e,c))}function c_e(c){return process.browser?globalThis.btoa(c):Buffer.from(c).toString("base64")}var f_e=c_e("("+Lg.toString()+")(self)"),d_e="data:application/javascript;base64,"+f_e;async function aC(c,e){let a=new eC;a.memory=new WebAssembly.Memory({initial:XF}),a.u8=new Uint8Array(a.memory.buffer),a.u32=new Uint32Array(a.memory.buffer);let f=await WebAssembly.compile(c.code);if(a.instance=await WebAssembly.instantiate(f,{env:{memory:a.memory}}),a.singleThread=e,a.initalPFree=a.u32[0],a.pq=c.pq,a.pr=c.pr,a.pG1gen=c.pG1gen,a.pG1zero=c.pG1zero,a.pG2gen=c.pG2gen,a.pG2zero=c.pG2zero,a.pOneT=c.pOneT,e)a.code=c.code,a.taskManager=Lg(),await a.taskManager([{cmd:"INIT",init:XF,code:a.code.slice()}]),a.concurrency=1;else{a.workers=[],a.pendingDeferreds=[],a.working=[];let b;typeof navigator=="object"&&navigator.hardwareConcurrency?b=navigator.hardwareConcurrency:b=j5.cpus().length,b==0&&(b=2),b>64&&(b=64),a.concurrency=b;for(let r=0;r<b;r++)a.workers[r]=new Sae.default(d_e),a.workers[r].addEventListener("message",d(r)),a.working[r]=!1;let t=[];for(let r=0;r<a.workers.length;r++){let o=c.code.slice();t.push(a.postAction(r,[{cmd:"INIT",init:XF,code:o}],[o.buffer]))}await Promise.all(t)}return a;function d(b){return function(t){let r;t&&t.data?r=t.data:r=t,a.working[b]=!1,a.pendingDeferreds[b].resolve(r),a.processWorks()}}}var eC=class{constructor(){this.actionQueue=[],this.oldPFree=0}startSyncOp(){if(this.oldPFree!=0)throw new Error("Sync operation in progress");this.oldPFree=this.u32[0]}endSyncOp(){if(this.oldPFree==0)throw new Error("No sync operation in progress");this.u32[0]=this.oldPFree,this.oldPFree=0}postAction(e,a,f,d){if(this.working[e])throw new Error("Posting a job t a working worker");return this.working[e]=!0,this.pendingDeferreds[e]=d||new Fg,this.workers[e].postMessage(a,f),this.pendingDeferreds[e].promise}processWorks(){for(let e=0;e<this.workers.length&&this.actionQueue.length>0;e++)if(this.working[e]==!1){let a=this.actionQueue.shift();this.postAction(e,a.data,a.transfers,a.deferred)}}queueAction(e,a){let f=new Fg;if(this.singleThread){let d=this.taskManager(e);f.resolve(d)}else this.actionQueue.push({data:e,transfers:a,deferred:f}),this.processWorks();return f.promise}resetMemory(){this.u32[0]=this.initalPFree}allocBuff(e){let a=this.alloc(e.byteLength);return this.setBuff(a,e),a}getBuff(e,a){return this.u8.slice(e,e+a)}setBuff(e,a){this.u8.set(new Uint8Array(a),e)}alloc(e){for(;this.u32[0]&3;)this.u32[0]++;let a=this.u32[0];return this.u32[0]+=e,a}async terminate(){for(let e=0;e<this.workers.length;e++)this.workers[e].postMessage([{cmd:"TERMINATE"}]);await a_e(200)}};s();x();function ps(c,e){let a=c[e],f=c.Fr,d=c.tm;c[e].batchApplyKey=async function(b,t,r,o,n){o=o||"affine",n=n||"affine";let i,l,h,u,g;if(e=="G1")o=="jacobian"?(h=a.F.n8*3,i="g1m_batchApplyKey"):(h=a.F.n8*2,i="g1m_batchApplyKeyMixed"),u=a.F.n8*3,n=="jacobian"?g=a.F.n8*3:(l="g1m_batchToAffine",g=a.F.n8*2);else if(e=="G2")o=="jacobian"?(h=a.F.n8*3,i="g2m_batchApplyKey"):(h=a.F.n8*2,i="g2m_batchApplyKeyMixed"),u=a.F.n8*3,n=="jacobian"?g=a.F.n8*3:(l="g2m_batchToAffine",g=a.F.n8*2);else if(e=="Fr")i="frm_batchApplyKey",h=a.n8,u=a.n8,g=a.n8;else throw new Error("Invalid group: "+e);let E=Math.floor(b.byteLength/h),_=Math.floor(E/d.concurrency),F=[];r=f.e(r);let L=f.e(t);for(let P=0;P<d.concurrency;P++){let A;if(P<d.concurrency-1?A=_:A=E-P*_,A==0)continue;let I=[];I.push({cmd:"ALLOCSET",var:0,buff:b.slice(P*_*h,P*_*h+A*h)}),I.push({cmd:"ALLOCSET",var:1,buff:L}),I.push({cmd:"ALLOCSET",var:2,buff:r}),I.push({cmd:"ALLOC",var:3,len:A*Math.max(u,g)}),I.push({cmd:"CALL",fnName:i,params:[{var:0},{val:A},{var:1},{var:2},{var:3}]}),l&&I.push({cmd:"CALL",fnName:l,params:[{var:3},{val:A},{var:3}]}),I.push({cmd:"GET",out:0,var:3,len:A*g}),F.push(d.queueAction(I)),L=f.mul(L,f.exp(r,A))}let U=await Promise.all(F),O;b instanceof I0?O=new I0(E*g):O=new Uint8Array(E*g);let H=0;for(let P=0;P<U.length;P++)O.set(U[P][0],H),H+=U[P][0].byteLength;return O}}s();x();function cC(c){let e=c.tm;c.pairing=function(f,d){e.startSyncOp();let b=e.allocBuff(c.G1.toJacobian(f)),t=e.allocBuff(c.G2.toJacobian(d)),r=e.alloc(c.Gt.n8);e.instance.exports[c.name+"_pairing"](b,t,r);let o=e.getBuff(r,c.Gt.n8);return e.endSyncOp(),o},c.pairingEq=async function(){let f,d;arguments.length%2==1?(f=arguments[arguments.length-1],d=(arguments.length-1)/2):(f=c.Gt.one,d=arguments.length/2);let b=[];for(let i=0;i<d;i++){let l=[],h=c.G1.toJacobian(arguments[i*2]);l.push({cmd:"ALLOCSET",var:0,buff:h}),l.push({cmd:"ALLOC",var:1,len:c.prePSize});let u=c.G2.toJacobian(arguments[i*2+1]);l.push({cmd:"ALLOCSET",var:2,buff:u}),l.push({cmd:"ALLOC",var:3,len:c.preQSize}),l.push({cmd:"ALLOC",var:4,len:c.Gt.n8}),l.push({cmd:"CALL",fnName:c.name+"_prepareG1",params:[{var:0},{var:1}]}),l.push({cmd:"CALL",fnName:c.name+"_prepareG2",params:[{var:2},{var:3}]}),l.push({cmd:"CALL",fnName:c.name+"_millerLoop",params:[{var:1},{var:3},{var:4}]}),l.push({cmd:"GET",out:0,var:4,len:c.Gt.n8}),b.push(e.queueAction(l))}let t=await Promise.all(b);e.startSyncOp();let r=e.alloc(c.Gt.n8);e.instance.exports.ftm_one(r);for(let i=0;i<t.length;i++){let l=e.allocBuff(t[i][0]);e.instance.exports.ftm_mul(r,l,r)}e.instance.exports[c.name+"_finalExponentiation"](r,r);let o=e.allocBuff(f),n=!!e.instance.exports.ftm_eq(r,o);return e.endSyncOp(),n},c.prepareG1=function(a){this.tm.startSyncOp();let f=this.tm.allocBuff(a),d=this.tm.alloc(this.prePSize);this.tm.instance.exports[this.name+"_prepareG1"](f,d);let b=this.tm.getBuff(d,this.prePSize);return this.tm.endSyncOp(),b},c.prepareG2=function(a){this.tm.startSyncOp();let f=this.tm.allocBuff(a),d=this.tm.alloc(this.preQSize);this.tm.instance.exports[this.name+"_prepareG2"](f,d);let b=this.tm.getBuff(d,this.preQSize);return this.tm.endSyncOp(),b},c.millerLoop=function(a,f){this.tm.startSyncOp();let d=this.tm.allocBuff(a),b=this.tm.allocBuff(f),t=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+"_millerLoop"](d,b,t);let r=this.tm.getBuff(t,this.Gt.n8);return this.tm.endSyncOp(),r},c.finalExponentiation=function(a){this.tm.startSyncOp();let f=this.tm.allocBuff(a),d=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+"_finalExponentiation"](f,d);let b=this.tm.getBuff(d,this.Gt.n8);return this.tm.endSyncOp(),b}}s();x();var Iae=[1,1,1,1,2,3,4,5,6,7,7,8,9,10,11,12,13,13,14,15,16,16,17,17,17,17,17,17,17,17,17,17];function Cg(c,e){let a=c[e],f=a.tm;async function d(t,r,o,n,i){if(!(t instanceof Uint8Array))throw n&&n.error(`${i} _multiExpChunk buffBases is not Uint8Array`),new Error(`${i} _multiExpChunk buffBases is not Uint8Array`);if(!(r instanceof Uint8Array))throw n&&n.error(`${i} _multiExpChunk buffScalars is not Uint8Array`),new Error(`${i} _multiExpChunk buffScalars is not Uint8Array`);o=o||"affine";let l,h;if(e=="G1")o=="affine"?(h="g1m_multiexpAffine_chunk",l=a.F.n8*2):(h="g1m_multiexp_chunk",l=a.F.n8*3);else if(e=="G2")o=="affine"?(h="g2m_multiexpAffine_chunk",l=a.F.n8*2):(h="g2m_multiexp_chunk",l=a.F.n8*3);else throw new Error("Invalid group");let u=Math.floor(t.byteLength/l);if(u==0)return a.zero;let g=Math.floor(r.byteLength/u);if(g*u!=r.byteLength)throw new Error("Scalar size does not match");let E=Iae[Mf(u)],_=Math.floor((g*8-1)/E)+1,F=[];for(let O=0;O<_;O++){let H=[{cmd:"ALLOCSET",var:0,buff:t},{cmd:"ALLOCSET",var:1,buff:r},{cmd:"ALLOC",var:2,len:a.F.n8*3},{cmd:"CALL",fnName:h,params:[{var:0},{var:1},{val:g},{val:u},{val:O*E},{val:Math.min(g*8-O*E,E)},{var:2}]},{cmd:"GET",out:0,var:2,len:a.F.n8*3}];F.push(a.tm.queueAction(H))}let L=await Promise.all(F),U=a.zero;for(let O=L.length-1;O>=0;O--){if(!a.isZero(U))for(let H=0;H<E;H++)U=a.double(U);U=a.add(U,L[O][0])}return U}async function b(t,r,o,n,i){let u;if(e=="G1")o=="affine"?u=a.F.n8*2:u=a.F.n8*3;else if(e=="G2")o=="affine"?u=a.F.n8*2:u=a.F.n8*3;else throw new Error("Invalid group");let g=Math.floor(t.byteLength/u),E=Math.floor(r.byteLength/g);if(E*g!=r.byteLength)throw new Error("Scalar size does not match");let _=Iae[Mf(g)],F=Math.floor((E*8-1)/_)+1,L;L=Math.floor(g/(f.concurrency/F)),L>4194304&&(L=4194304),L<1024&&(L=1024);let U=[];for(let P=0;P<g;P+=L){n&&n.debug(`Multiexp start: ${i}: ${P}/${g}`);let A=Math.min(g-P,L),I=t.slice(P*u,(P+A)*u),K=r.slice(P*E,(P+A)*E);U.push(d(I,K,o,n,i).then(j=>(n&&n.debug(`Multiexp end: ${i}: ${P}/${g}`),j)))}let O=await Promise.all(U),H=a.zero;for(let P=O.length-1;P>=0;P--)H=a.add(H,O[P]);return H}a.multiExp=async function(r,o,n,i){return await b(r,o,"jacobian",n,i)},a.multiExpAffine=async function(r,o,n,i){return await b(r,o,"affine",n,i)}}s();x();function ms(c,e){let a=c[e],f=c.Fr,d=a.tm;async function b(n,i,l,h,u,g){l=l||"affine",h=h||"affine";let E=14,_,F,L,U,O,H,P,A;e=="G1"?(l=="affine"?(_=a.F.n8*2,U="g1m_batchToJacobian"):_=a.F.n8*3,F=a.F.n8*3,i&&(A="g1m_fftFinal"),P="g1m_fftJoin",H="g1m_fftMix",h=="affine"?(L=a.F.n8*2,O="g1m_batchToAffine"):L=a.F.n8*3):e=="G2"?(l=="affine"?(_=a.F.n8*2,U="g2m_batchToJacobian"):_=a.F.n8*3,F=a.F.n8*3,i&&(A="g2m_fftFinal"),P="g2m_fftJoin",H="g2m_fftMix",h=="affine"?(L=a.F.n8*2,O="g2m_batchToAffine"):L=a.F.n8*3):e=="Fr"&&(_=a.n8,F=a.n8,L=a.n8,i&&(A="frm_fftFinal"),H="frm_fftMix",P="frm_fftJoin");let I=!1;Array.isArray(n)?(n=us(n,_),I=!0):n=n.slice(0,n.byteLength);let K=n.byteLength/_,j=Mf(K);if(1<<j!=K)throw new Error("fft must be multiple of 2");if(j==f.s+1){let M;return i?M=await r(n,l,h,u,g):M=await t(n,l,h,u,g),I?Xt(M,L):M}let J;i&&(J=f.inv(f.e(K)));let V;YF(n,_);let S,y=Math.min(1<<E,K),R=K/y;for(;R<d.concurrency&&y>=16;)R*=2,y/=2;let k=Mf(y),D=[];for(let M=0;M<R;M++){u&&u.debug(`${g}: fft ${j} mix start: ${M}/${R}`);let N=[];N.push({cmd:"ALLOC",var:0,len:F*y});let q=n.slice(y*M*_,y*(M+1)*_);N.push({cmd:"SET",var:0,buff:q}),U&&N.push({cmd:"CALL",fnName:U,params:[{var:0},{val:y},{var:0}]});for(let G=1;G<=k;G++)N.push({cmd:"CALL",fnName:H,params:[{var:0},{val:y},{val:G}]});k==j?(A&&(N.push({cmd:"ALLOCSET",var:1,buff:J}),N.push({cmd:"CALL",fnName:A,params:[{var:0},{val:y},{var:1}]})),O&&N.push({cmd:"CALL",fnName:O,params:[{var:0},{val:y},{var:0}]}),N.push({cmd:"GET",out:0,var:0,len:y*L})):N.push({cmd:"GET",out:0,var:0,len:F*y}),D.push(d.queueAction(N).then(G=>(u&&u.debug(`${g}: fft ${j} mix end: ${M}/${R}`),G)))}S=await Promise.all(D);for(let M=0;M<R;M++)S[M]=S[M][0];for(let M=k+1;M<=j;M++){u&&u.debug(`${g}: fft ${j} join: ${M}/${j}`);let N=1<<j-M,q=R/N,G=[];for(let z=0;z<N;z++)for(let de=0;de<q/2;de++){let w=f.exp(f.w[M],de*y),p=f.w[M],T=z*q+de,v=z*q+de+q/2,W=[];W.push({cmd:"ALLOCSET",var:0,buff:S[T]}),W.push({cmd:"ALLOCSET",var:1,buff:S[v]}),W.push({cmd:"ALLOCSET",var:2,buff:w}),W.push({cmd:"ALLOCSET",var:3,buff:p}),W.push({cmd:"CALL",fnName:P,params:[{var:0},{var:1},{val:y},{var:2},{var:3}]}),M==j?(A&&(W.push({cmd:"ALLOCSET",var:4,buff:J}),W.push({cmd:"CALL",fnName:A,params:[{var:0},{val:y},{var:4}]}),W.push({cmd:"CALL",fnName:A,params:[{var:1},{val:y},{var:4}]})),O&&(W.push({cmd:"CALL",fnName:O,params:[{var:0},{val:y},{var:0}]}),W.push({cmd:"CALL",fnName:O,params:[{var:1},{val:y},{var:1}]})),W.push({cmd:"GET",out:0,var:0,len:y*L}),W.push({cmd:"GET",out:1,var:1,len:y*L})):(W.push({cmd:"GET",out:0,var:0,len:y*F}),W.push({cmd:"GET",out:1,var:1,len:y*F})),G.push(d.queueAction(W).then($=>(u&&u.debug(`${g}: fft ${j} join ${M}/${j} ${z+1}/${N} ${de}/${q/2}`),$)))}let C=await Promise.all(G);for(let z=0;z<N;z++)for(let de=0;de<q/2;de++){let w=z*q+de,p=z*q+de+q/2,T=C.shift();S[w]=T[0],S[p]=T[1]}}if(n instanceof I0?V=new I0(K*L):V=new Uint8Array(K*L),i){V.set(S[0].slice((y-1)*L));let M=L;for(let N=R-1;N>0;N--)V.set(S[N],M),M+=y*L,delete S[N];V.set(S[0].slice(0,(y-1)*L),M),delete S[0]}else for(let M=0;M<R;M++)V.set(S[M],y*L*M),delete S[M];return I?Xt(V,L):V}async function t(n,i,l,h,u){let g,E;g=n.slice(0,n.byteLength/2),E=n.slice(n.byteLength/2,n.byteLength);let _=[];[g,E]=await o(g,E,"fftJoinExt",f.one,f.shift,i,"jacobian",h,u),_.push(b(g,!1,"jacobian",l,h,u)),_.push(b(E,!1,"jacobian",l,h,u));let F=await Promise.all(_),L;return F[0].byteLength>1<<28?L=new I0(F[0].byteLength*2):L=new Uint8Array(F[0].byteLength*2),L.set(F[0]),L.set(F[1],F[0].byteLength),L}async function r(n,i,l,h,u){let g,E;g=n.slice(0,n.byteLength/2),E=n.slice(n.byteLength/2,n.byteLength);let _=[];_.push(b(g,!0,i,"jacobian",h,u)),_.push(b(E,!0,i,"jacobian",h,u)),[g,E]=await Promise.all(_);let F=await o(g,E,"fftJoinExtInv",f.one,f.shiftInv,"jacobian",l,h,u),L;return F[0].byteLength>1<<28?L=new I0(F[0].byteLength*2):L=new Uint8Array(F[0].byteLength*2),L.set(F[0]),L.set(F[1],F[0].byteLength),L}async function o(n,i,l,h,u,g,E,_,F){let O,H,P,A,I,K;if(e=="G1")g=="affine"?(I=a.F.n8*2,H="g1m_batchToJacobian"):I=a.F.n8*3,K=a.F.n8*3,O="g1m_"+l,E=="affine"?(P="g1m_batchToAffine",A=a.F.n8*2):A=a.F.n8*3;else if(e=="G2")g=="affine"?(I=a.F.n8*2,H="g2m_batchToJacobian"):I=a.F.n8*3,O="g2m_"+l,K=a.F.n8*3,E=="affine"?(P="g2m_batchToAffine",A=a.F.n8*2):A=a.F.n8*3;else if(e=="Fr")I=f.n8,A=f.n8,K=f.n8,O="frm_"+l;else throw new Error("Invalid group");if(n.byteLength!=i.byteLength)throw new Error("Invalid buffer size");let j=Math.floor(n.byteLength/I);if(j!=1<<Mf(j))throw new Error("Invalid number of points");let J=Math.floor(j/d.concurrency);J<16&&(J=16),J>65536&&(J=65536);let V=[];for(let D=0;D<j;D+=J){_&&_.debug(`${F}: fftJoinExt Start: ${D}/${j}`);let M=Math.min(j-D,J),N=f.mul(h,f.exp(u,D)),q=[],G=n.slice(D*I,(D+M)*I),C=i.slice(D*I,(D+M)*I);q.push({cmd:"ALLOC",var:0,len:K*M}),q.push({cmd:"SET",var:0,buff:G}),q.push({cmd:"ALLOC",var:1,len:K*M}),q.push({cmd:"SET",var:1,buff:C}),q.push({cmd:"ALLOCSET",var:2,buff:N}),q.push({cmd:"ALLOCSET",var:3,buff:u}),H&&(q.push({cmd:"CALL",fnName:H,params:[{var:0},{val:M},{var:0}]}),q.push({cmd:"CALL",fnName:H,params:[{var:1},{val:M},{var:1}]})),q.push({cmd:"CALL",fnName:O,params:[{var:0},{var:1},{val:M},{var:2},{var:3},{val:f.s}]}),P&&(q.push({cmd:"CALL",fnName:P,params:[{var:0},{val:M},{var:0}]}),q.push({cmd:"CALL",fnName:P,params:[{var:1},{val:M},{var:1}]})),q.push({cmd:"GET",out:0,var:0,len:M*A}),q.push({cmd:"GET",out:1,var:1,len:M*A}),V.push(d.queueAction(q).then(z=>(_&&_.debug(`${F}: fftJoinExt End: ${D}/${j}`),z)))}let S=await Promise.all(V),y,R;j*A>1<<28?(y=new I0(j*A),R=new I0(j*A)):(y=new Uint8Array(j*A),R=new Uint8Array(j*A));let k=0;for(let D=0;D<S.length;D++)y.set(S[D][0],k),R.set(S[D][1],k),k+=S[D][0].byteLength;return[y,R]}a.fft=async function(n,i,l,h,u){return await b(n,!1,i,l,h,u)},a.ifft=async function(n,i,l,h,u){return await b(n,!0,i,l,h,u)},a.lagrangeEvaluations=async function(n,i,l,h,u){i=i||"affine",l=l||"affine";let g;if(e=="G1")i=="affine"?g=a.F.n8*2:g=a.F.n8*3;else if(e=="G2")i=="affine"?g=a.F.n8*2:g=a.F.n8*3;else if(e=="Fr")g=f.n8;else throw new Error("Invalid group");let E=n.byteLength/g,_=Mf(E);if(2**_*g!=n.byteLength)throw h&&h.error("lagrangeEvaluations iinvalid input size"),new Error("lagrangeEvaluations invalid Input size");if(_<=f.s)return await a.ifft(n,i,l,h,u);if(_>f.s+1)throw h&&h.error("lagrangeEvaluations input too big"),new Error("lagrangeEvaluations input too big");let F=n.slice(0,n.byteLength/2),L=n.slice(n.byteLength/2,n.byteLength),U=f.exp(f.shift,E/2),O=f.inv(f.sub(f.one,U));[F,L]=await o(F,L,"prepareLagrangeEvaluation",O,f.shiftInv,i,"jacobian",h,u+" prep");let H=[];H.push(b(F,!0,"jacobian",l,h,u+" t0")),H.push(b(L,!0,"jacobian",l,h,u+" t1")),[F,L]=await Promise.all(H);let P;return F.byteLength>1<<28?P=new I0(F.byteLength*2):P=new Uint8Array(F.byteLength*2),P.set(F),P.set(L,F.byteLength),P},a.fftMix=async function(i){let l=a.F.n8*3,h,u;if(e=="G1")h="g1m_fftMix",u="g1m_fftJoin";else if(e=="G2")h="g2m_fftMix",u="g2m_fftJoin";else if(e=="Fr")h="frm_fftMix",u="frm_fftJoin";else throw new Error("Invalid group");let g=Math.floor(i.byteLength/l),E=Mf(g),_=1<<Mf(d.concurrency);g<=_*2&&(_=1);let F=g/_,L=Mf(F),U=[];for(let I=0;I<_;I++){let K=[],j=i.slice(I*F*l,(I+1)*F*l);K.push({cmd:"ALLOCSET",var:0,buff:j});for(let J=1;J<=L;J++)K.push({cmd:"CALL",fnName:h,params:[{var:0},{val:F},{val:J}]});K.push({cmd:"GET",out:0,var:0,len:F*l}),U.push(d.queueAction(K))}let O=await Promise.all(U),H=[];for(let I=0;I<O.length;I++)H[I]=O[I][0];for(let I=L+1;I<=E;I++){let K=1<<E-I,j=_/K,J=[];for(let S=0;S<K;S++)for(let y=0;y<j/2;y++){let R=f.exp(f.w[I],y*F),k=f.w[I],D=S*j+y,M=S*j+y+j/2,N=[];N.push({cmd:"ALLOCSET",var:0,buff:H[D]}),N.push({cmd:"ALLOCSET",var:1,buff:H[M]}),N.push({cmd:"ALLOCSET",var:2,buff:R}),N.push({cmd:"ALLOCSET",var:3,buff:k}),N.push({cmd:"CALL",fnName:u,params:[{var:0},{var:1},{val:F},{var:2},{var:3}]}),N.push({cmd:"GET",out:0,var:0,len:F*l}),N.push({cmd:"GET",out:1,var:1,len:F*l}),J.push(d.queueAction(N))}let V=await Promise.all(J);for(let S=0;S<K;S++)for(let y=0;y<j/2;y++){let R=S*j+y,k=S*j+y+j/2,D=V.shift();H[R]=D[0],H[k]=D[1]}}let P;i instanceof I0?P=new I0(g*l):P=new Uint8Array(g*l);let A=0;for(let I=0;I<_;I++)P.set(H[I],A),A+=H[I].byteLength;return P},a.fftJoin=async function(i,l,h,u){let g=a.F.n8*3,E;if(e=="G1")E="g1m_fftJoin";else if(e=="G2")E="g2m_fftJoin";else if(e=="Fr")E="frm_fftJoin";else throw new Error("Invalid group");if(i.byteLength!=l.byteLength)throw new Error("Invalid buffer size");let _=Math.floor(i.byteLength/g);if(_!=1<<Mf(_))throw new Error("Invalid number of points");let F=1<<Mf(d.concurrency);_<=F*2&&(F=1);let L=_/F,U=[];for(let I=0;I<F;I++){let K=[],j=f.mul(h,f.exp(u,I*L)),J=i.slice(I*L*g,(I+1)*L*g),V=l.slice(I*L*g,(I+1)*L*g);K.push({cmd:"ALLOCSET",var:0,buff:J}),K.push({cmd:"ALLOCSET",var:1,buff:V}),K.push({cmd:"ALLOCSET",var:2,buff:j}),K.push({cmd:"ALLOCSET",var:3,buff:u}),K.push({cmd:"CALL",fnName:E,params:[{var:0},{var:1},{val:L},{var:2},{var:3}]}),K.push({cmd:"GET",out:0,var:0,len:L*g}),K.push({cmd:"GET",out:1,var:1,len:L*g}),U.push(d.queueAction(K))}let O=await Promise.all(U),H,P;i instanceof I0?(H=new I0(_*g),P=new I0(_*g)):(H=new Uint8Array(_*g),P=new Uint8Array(_*g));let A=0;for(let I=0;I<O.length;I++)H.set(O[I][0],A),P.set(O[I][1],A),A+=O[I][0].byteLength;return[H,P]},a.fftFinal=async function(i,l){let h=a.F.n8*3,u=a.F.n8*2,g,E;if(e=="G1")g="g1m_fftFinal",E="g1m_batchToAffine";else if(e=="G2")g="g2m_fftFinal",E="g2m_batchToAffine";else throw new Error("Invalid group");let _=Math.floor(i.byteLength/h);if(_!=1<<Mf(_))throw new Error("Invalid number of points");let F=Math.floor(_/d.concurrency),L=[];for(let P=0;P<d.concurrency;P++){let A;if(P<d.concurrency-1?A=F:A=_-P*F,A==0)continue;let I=[],K=i.slice(P*F*h,(P*F+A)*h);I.push({cmd:"ALLOCSET",var:0,buff:K}),I.push({cmd:"ALLOCSET",var:1,buff:l}),I.push({cmd:"CALL",fnName:g,params:[{var:0},{val:A},{var:1}]}),I.push({cmd:"CALL",fnName:E,params:[{var:0},{val:A},{var:0}]}),I.push({cmd:"GET",out:0,var:0,len:A*u}),L.push(d.queueAction(I))}let U=await Promise.all(L),O;i instanceof I0?O=new I0(_*u):O=new Uint8Array(_*u);let H=0;for(let P=U.length-1;P>=0;P--)O.set(U[P][0],H),H+=U[P][0].byteLength;return O}}async function gs(c){let e=await aC(c.wasm,c.singleThread),a={};return a.q=_a(c.wasm.q.toString()),a.r=_a(c.wasm.r.toString()),a.name=c.name,a.tm=e,a.prePSize=c.wasm.prePSize,a.preQSize=c.wasm.preQSize,a.Fr=new er(e,"frm",c.n8r,c.r),a.F1=new er(e,"f1m",c.n8q,c.q),a.F2=new ar(e,"f2m",a.F1),a.G1=new cr(e,"g1m",a.F1,c.wasm.pG1gen,c.wasm.pG1b,c.cofactorG1),a.G2=new cr(e,"g2m",a.F2,c.wasm.pG2gen,c.wasm.pG2b,c.cofactorG2),a.F6=new hs(e,"f6m",a.F2),a.F12=new ar(e,"ftm",a.F6),a.Gt=a.F12,ps(a,"G1"),ps(a,"G2"),ps(a,"Fr"),Cg(a,"G1"),Cg(a,"G2"),ms(a,"G1"),ms(a,"G2"),ms(a,"Fr"),cC(a),a.array2buffer=function(f,d){let b=new Uint8Array(d*f.length);for(let t=0;t<f.length;t++)b.set(f[t],t*d);return b},a.buffer2array=function(f,d){let b=f.byteLength/d,t=new Array(b);for(let r=0;r<b;r++)t[r]=f.slice(r*d,r*d+d);return t},a}globalThis.curve_bn128=null;async function fr(c,e){let a=new gf;a.setMemory(25),(0,Lae.buildBn128)(a),e&&e(a);let f={};if(f.code=a.build(),f.pq=a.modules.f1m.pq,f.pr=a.modules.frm.pq,f.pG1gen=a.modules.bn128.pG1gen,f.pG1zero=a.modules.bn128.pG1zero,f.pG1b=a.modules.bn128.pG1b,f.pG2gen=a.modules.bn128.pG2gen,f.pG2zero=a.modules.bn128.pG2zero,f.pG2b=a.modules.bn128.pG2b,f.pOneT=a.modules.bn128.pOneT,f.prePSize=a.modules.bn128.prePSize,f.preQSize=a.modules.bn128.preQSize,f.n8q=32,f.n8r=32,f.q=a.modules.bn128.q,f.r=a.modules.bn128.r,!c&&globalThis.curve_bn128)return globalThis.curve_bn128;let d={name:"bn128",wasm:f,q:_a("21888242871839275222246405745257275088696311157297823662689037894645226208583"),r:_a("21888242871839275222246405745257275088548364400416034343698204186575808495617"),n8q:32,n8r:32,cofactorG2:_a("30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d",16),singleThread:!!c},b=await gs(d);return b.terminate=async function(){d.singleThread||(globalThis.curve_bn128=null,await this.tm.terminate())},c||(globalThis.curve_bn128=b),b}s();x();var Fae=Fe(E3(),1);globalThis.curve_bls12381=null;async function dr(c,e){let a=new gf;a.setMemory(25),(0,Fae.buildBls12381)(a),e&&e(a);let f={};if(f.code=a.build(),f.pq=a.modules.f1m.pq,f.pr=a.modules.frm.pq,f.pG1gen=a.modules.bls12381.pG1gen,f.pG1zero=a.modules.bls12381.pG1zero,f.pG1b=a.modules.bls12381.pG1b,f.pG2gen=a.modules.bls12381.pG2gen,f.pG2zero=a.modules.bls12381.pG2zero,f.pG2b=a.modules.bls12381.pG2b,f.pOneT=a.modules.bls12381.pOneT,f.prePSize=a.modules.bls12381.prePSize,f.preQSize=a.modules.bls12381.preQSize,f.n8q=48,f.n8r=32,f.q=a.modules.bls12381.q,f.r=a.modules.bls12381.r,!c&&globalThis.curve_bls12381)return globalThis.curve_bls12381;let d={name:"bls12381",wasm:f,q:_a("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),r:_a("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),n8q:48,n8r:32,cofactorG1:_a("0x396c8c005555e1568c00aaab0000aaab",16),cofactorG2:_a("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5",16),singleThread:!!c},b=await gs(d);return b.terminate=async function(){d.singleThread||(globalThis.curve_bls12381=null,await this.tm.terminate())},c||(globalThis.curve_bls12381=b),b}s();x();var eG0=_a("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),aG0=_a("21888242871839275222246405745257275088548364400416034343698204186575808495617"),cG0=_a("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),fG0=_a("21888242871839275222246405745257275088696311157297823662689037894645226208583");var Ma=sf,Ya=Ig;s();x();var CG0=Ma.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),RG0=Ma.e("21888242871839275222246405745257275088548364400416034343698204186575808495617"),b_e=Ma.e("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),t_e=Ma.e("21888242871839275222246405745257275088696311157297823662689037894645226208583");async function t3(c){let e;if(Ma.eq(c,t_e))e=await fr();else if(Ma.eq(c,b_e))e=await dr();else throw new Error(`Curve not supported: ${Ma.toString(c)}`);return e}async function Rg(c){let e,a=f(c);if(["BN128","BN254","ALTBN128"].indexOf(a)>=0)e=await fr();else if(["BLS12381"].indexOf(a)>=0)e=await dr();else throw new Error(`Curve not supported: ${c}`);return e;function f(d){return d.toUpperCase().match(/[A-Za-z0-9]+/g).join("")}}s();x();var fve=Fe(xf(),1);s();x();_3();var dve=[];for(let c=0;c<256;c++)dve[c]=bve(c,8);function bve(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}function i5(c){return((c&4294901760)!==0?(c&=4294901760,16):0)|((c&4278255360)!==0?(c&=4278255360,8):0)|((c&4042322160)!==0?(c&=4042322160,4):0)|((c&3435973836)!==0?(c&=3435973836,2):0)|(c&2863311530)!==0}async function Z1(c,e,a){let f=await c.read(e.G1.F.n8*2),d=e.G1.fromRprLEM(f,0);return a?e.G1.toObject(d):d}async function Og(c,e,a){let f=await c.read(e.G2.F.n8*2),d=e.G2.fromRprLEM(f,0);return a?e.G2.toObject(d):d}async function w8(c,e,a){await td(c,e,1);let f=await c.readULE32();if(await rd(c),f==1)return await tve(c,e,a);if(f==2)return await rve(c,e,a);throw new Error("Protocol not supported: ")}async function tve(c,e,a){let f={};f.protocol="groth16",await td(c,e,2);let d=await c.readULE32();f.n8q=d,f.q=await J7(c,d);let b=await c.readULE32();return f.n8r=b,f.r=await J7(c,b),f.curve=await t3(f.q),f.nVars=await c.readULE32(),f.nPublic=await c.readULE32(),f.domainSize=await c.readULE32(),f.power=i5(f.domainSize),f.vk_alpha_1=await Z1(c,f.curve,a),f.vk_beta_1=await Z1(c,f.curve,a),f.vk_beta_2=await Og(c,f.curve,a),f.vk_gamma_2=await Og(c,f.curve,a),f.vk_delta_1=await Z1(c,f.curve,a),f.vk_delta_2=await Og(c,f.curve,a),await rd(c),f}async function rve(c,e,a){let f={};f.protocol="plonk",await td(c,e,2);let d=await c.readULE32();f.n8q=d,f.q=await J7(c,d);let b=await c.readULE32();return f.n8r=b,f.r=await J7(c,b),f.curve=await t3(f.q),f.nVars=await c.readULE32(),f.nPublic=await c.readULE32(),f.domainSize=await c.readULE32(),f.power=i5(f.domainSize),f.nAdditions=await c.readULE32(),f.nConstrains=await c.readULE32(),f.k1=await c.read(b),f.k2=await c.read(b),f.Qm=await Z1(c,f.curve,a),f.Ql=await Z1(c,f.curve,a),f.Qr=await Z1(c,f.curve,a),f.Qo=await Z1(c,f.curve,a),f.Qc=await Z1(c,f.curve,a),f.S1=await Z1(c,f.curve,a),f.S2=await Z1(c,f.curve,a),f.S3=await Z1(c,f.curve,a),f.X_2=await Og(c,f.curve,a),await rd(c),f}s();x();async function ice(c,e,a){await dd(c,1);let f=(Math.floor((Ma.bitLength(a)-1)/64)+1)*8;if(await c.writeULE32(f),await Wt(c,a,f),e.byteLength%f!=0)throw new Error("Invalid witness length");await c.writeULE32(e.byteLength/f),await bd(c),await dd(c,2),await c.write(e),await bd(c)}async function nC(c,e){await td(c,e,1);let a=await c.readULE32(),f=await J7(c,a),d=await c.readULE32();return await rd(c),{n8:a,q:f,nWitness:d}}var{stringifyBigInts:oce}=Ya;async function ws(c,e,a){let{fd:f,sections:d}=await Ga(e,"wtns",2,33554432,8388608),b=await nC(f,d),{fd:t,sections:r}=await Ga(c,"zkey",2,1<<25,1<<23),o=await w8(t,r);if(o.protocol!="groth16")throw new Error("zkey file is not groth16");if(!Ma.eq(o.r,b.q))throw new Error("Curve of the witness does not match the curve of the proving key");if(b.nWitness!=o.nVars)throw new Error(`Invalid witness length. Circuit: ${o.nVars}, witness: ${b.nWitness}`);let n=o.curve,i=n.Fr,l=n.G1,h=n.G2,u=i5(o.domainSize);a&&a.debug("Reading Wtns");let g=await x2(f,d,2);a&&a.debug("Reading Coeffs");let E=await x2(t,r,4);a&&a.debug("Building ABC");let[_,F,L]=await nve(n,o,g,E,a),U=u==i.s?n.Fr.shift:n.Fr.w[u+1],O=await i.ifft(_,"","",a,"IFFT_A"),H=await i.batchApplyKey(O,i.e(1),U),P=await i.fft(H,"","",a,"FFT_A"),A=await i.ifft(F,"","",a,"IFFT_B"),I=await i.batchApplyKey(A,i.e(1),U),K=await i.fft(I,"","",a,"FFT_B"),j=await i.ifft(L,"","",a,"IFFT_C"),J=await i.batchApplyKey(j,i.e(1),U),V=await i.fft(J,"","",a,"FFT_C");a&&a.debug("Join ABC");let S=await ive(n,o,P,K,V,a),y={};a&&a.debug("Reading A Points");let R=await x2(t,r,5);y.pi_a=await n.G1.multiExpAffine(R,g,a,"multiexp A"),a&&a.debug("Reading B1 Points");let k=await x2(t,r,6),D=await n.G1.multiExpAffine(k,g,a,"multiexp B1");a&&a.debug("Reading B2 Points");let M=await x2(t,r,7);y.pi_b=await n.G2.multiExpAffine(M,g,a,"multiexp B2"),a&&a.debug("Reading C Points");let N=await x2(t,r,8);y.pi_c=await n.G1.multiExpAffine(N,g.slice((o.nPublic+1)*n.Fr.n8),a,"multiexp C"),a&&a.debug("Reading H Points");let q=await x2(t,r,9),G=await n.G1.multiExpAffine(q,S,a,"multiexp H"),C=n.Fr.random(),z=n.Fr.random();y.pi_a=l.add(y.pi_a,o.vk_alpha_1),y.pi_a=l.add(y.pi_a,l.timesFr(o.vk_delta_1,C)),y.pi_b=h.add(y.pi_b,o.vk_beta_2),y.pi_b=h.add(y.pi_b,h.timesFr(o.vk_delta_2,z)),D=l.add(D,o.vk_beta_1),D=l.add(D,l.timesFr(o.vk_delta_1,z)),y.pi_c=l.add(y.pi_c,G),y.pi_c=l.add(y.pi_c,l.timesFr(y.pi_a,z)),y.pi_c=l.add(y.pi_c,l.timesFr(D,C)),y.pi_c=l.add(y.pi_c,l.timesFr(o.vk_delta_1,i.neg(i.mul(C,z))));let de=[];for(let w=1;w<=o.nPublic;w++){let p=g.slice(w*i.n8,w*i.n8+i.n8);de.push(Ma.fromRprLE(p))}return y.pi_a=l.toObject(l.toAffine(y.pi_a)),y.pi_b=h.toObject(h.toAffine(y.pi_b)),y.pi_c=l.toObject(l.toAffine(y.pi_c)),y.protocol="groth16",y.curve=n.name,await t.close(),await f.close(),y=oce(y),de=oce(de),{proof:y,publicSignals:de}}async function nve(c,e,a,f,d){let b=c.Fr.n8,t=4*3+e.n8r,r=(f.byteLength-4)/t,o=new I0(e.domainSize*b),n=new I0(e.domainSize*b),i=new I0(e.domainSize*b),l=[o,n];for(let h=0;h<r;h++){d&&h%1e6==0&&d.debug(`QAP AB: ${h}/${r}`);let u=f.slice(4+h*t,4+h*t+t),g=new DataView(u.buffer),E=g.getUint32(0,!0),_=g.getUint32(4,!0),F=g.getUint32(8,!0),L=u.slice(12,12+b);l[E].set(c.Fr.add(l[E].slice(_*b,_*b+b),c.Fr.mul(L,a.slice(F*b,F*b+b))),_*b)}for(let h=0;h<e.domainSize;h++)d&&h%1e6==0&&d.debug(`QAP C: ${h}/${e.domainSize}`),i.set(c.Fr.mul(o.slice(h*b,h*b+b),n.slice(h*b,h*b+b)),h*b);return[o,n,i]}async function ive(c,e,a,f,d,b){let r=c.Fr.n8,o=Math.floor(a.byteLength/c.Fr.n8),n=[];for(let u=0;u<o;u+=4194304){b&&b.debug(`JoinABC: ${u}/${o}`);let g=Math.min(o-u,4194304),E=[],_=a.slice(u*r,(u+g)*r),F=f.slice(u*r,(u+g)*r),L=d.slice(u*r,(u+g)*r);E.push({cmd:"ALLOCSET",var:0,buff:_}),E.push({cmd:"ALLOCSET",var:1,buff:F}),E.push({cmd:"ALLOCSET",var:2,buff:L}),E.push({cmd:"ALLOC",var:3,len:g*r}),E.push({cmd:"CALL",fnName:"qap_joinABC",params:[{var:0},{var:1},{var:2},{val:g},{var:3}]}),E.push({cmd:"CALL",fnName:"frm_batchFromMontgomery",params:[{var:3},{val:g},{var:3}]}),E.push({cmd:"GET",out:0,var:3,len:g*r}),n.push(c.tm.queueAction(E))}let i=await Promise.all(n),l;a instanceof I0?l=new I0(a.byteLength):l=new Uint8Array(a.byteLength);let h=0;for(let u=0;u<i.length;u++)l.set(i[u][0],h),h+=i[u][0].byteLength;return l}s();x();s();x();s();x();s();x();function iC(c){var e=[];return a(e,c),e;function a(f,d){if(Array.isArray(d))for(let b=0;b<d.length;b++)a(f,d[b]);else f.push(d)}}function oC(c){let e=BigInt(2)**BigInt(64),a=BigInt("0xCBF29CE484222325");for(var f=0;f<c.length;f++)a^=BigInt(c[f].charCodeAt()),a*=BigInt(1099511628211),a%=e;let d=a.toString(16),b=16-d.length;return d="0".repeat(b).concat(d),d}function sce(c,e){let a=[],f=BigInt(c),d=BigInt(4294967296);for(;f;)a.unshift(Number(f%d)),f=f/d;if(e)for(var b=e-a.length;b>0;)a.unshift(0),b--;return a}s();x();var lf={};v0(lf,{abs:()=>mve,add:()=>uC,band:()=>pC,bitLength:()=>tr,bits:()=>lC,bor:()=>_ve,bxor:()=>vve,div:()=>o5,e:()=>id,eq:()=>_8,exp:()=>pve,fromArray:()=>sve,fromRprBE:()=>gC,fromRprLE:()=>vs,fromString:()=>Mg,geq:()=>mce,gt:()=>hC,isNegative:()=>xce,isOdd:()=>kg,isZero:()=>sC,land:()=>Eve,leq:()=>wve,lnot:()=>Sve,lor:()=>Ave,lt:()=>yve,mod:()=>n3,mul:()=>pce,naf:()=>lce,neg:()=>hce,neq:()=>gve,one:()=>yce,pow:()=>rr,shiftLeft:()=>xC,shiftRight:()=>Dg,shl:()=>xve,shr:()=>lve,square:()=>hve,sub:()=>X7,toArray:()=>uve,toLEBuff:()=>Es,toNumber:()=>uce,toRprBE:()=>mC,toRprLE:()=>_s,toString:()=>yC,zero:()=>gce});s();x();var ove=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function Mg(c,e){if(!e||e==10)return BigInt(c);if(e==16)return c.slice(0,2)=="0x"?BigInt(c):BigInt("0x"+c)}var id=Mg;function sve(c,e){let a=BigInt(0);e=BigInt(e);for(let f=0;f<c.length;f++)a=a*e+BigInt(c[f]);return a}function tr(c){let e=c.toString(16);return(e.length-1)*4+ove[parseInt(e[0],16)]}function xce(c){return BigInt(c)<BigInt(0)}function sC(c){return!c}function xC(c,e){return BigInt(c)<<BigInt(e)}function Dg(c,e){return BigInt(c)>>BigInt(e)}var xve=xC,lve=Dg;function kg(c){return(BigInt(c)&BigInt(1))==BigInt(1)}function lce(c){let e=BigInt(c),a=[];for(;e;){if(e&BigInt(1)){let f=2-Number(e%BigInt(4));a.push(f),e=e-BigInt(f)}else a.push(0);e=e>>BigInt(1)}return a}function lC(c){let e=BigInt(c),a=[];for(;e;)e&BigInt(1)?a.push(1):a.push(0),e=e>>BigInt(1);return a}function uce(c){if(c>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Number too big");return Number(c)}function uve(c,e){let a=[],f=BigInt(c);for(e=BigInt(e);f;)a.unshift(Number(f%e)),f=f/e;return a}function uC(c,e){return BigInt(c)+BigInt(e)}function X7(c,e){return BigInt(c)-BigInt(e)}function hce(c){return-BigInt(c)}function pce(c,e){return BigInt(c)*BigInt(e)}function hve(c){return BigInt(c)*BigInt(c)}function rr(c,e){return BigInt(c)**BigInt(e)}function pve(c,e){return BigInt(c)**BigInt(e)}function mve(c){return BigInt(c)>=0?BigInt(c):-BigInt(c)}function o5(c,e){return BigInt(c)/BigInt(e)}function n3(c,e){return BigInt(c)%BigInt(e)}function _8(c,e){return BigInt(c)==BigInt(e)}function gve(c,e){return BigInt(c)!=BigInt(e)}function yve(c,e){return BigInt(c)<BigInt(e)}function hC(c,e){return BigInt(c)>BigInt(e)}function wve(c,e){return BigInt(c)<=BigInt(e)}function mce(c,e){return BigInt(c)>=BigInt(e)}function pC(c,e){return BigInt(c)&BigInt(e)}function _ve(c,e){return BigInt(c)|BigInt(e)}function vve(c,e){return BigInt(c)^BigInt(e)}function Eve(c,e){return BigInt(c)&&BigInt(e)}function Ave(c,e){return BigInt(c)||BigInt(e)}function Sve(c){return!BigInt(c)}function _s(c,e,a,f){let d="0000000"+a.toString(16),b=new Uint32Array(c.buffer,e,f/4),t=((d.length-7)*4-1>>5)+1;for(let r=0;r<t;r++)b[r]=parseInt(d.substring(d.length-8*r-8,d.length-8*r),16);for(let r=t;r<b.length;r++)b[r]=0;for(let r=b.length*4;r<f;r++)c[r]=uce(pC(Dg(a,r*8),255))}function mC(c,e,a,f){let d="0000000"+a.toString(16),b=new DataView(c.buffer,c.byteOffset+e,f),t=((d.length-7)*4-1>>5)+1;for(let r=0;r<t;r++)b.setUint32(f-r*4-4,parseInt(d.substring(d.length-8*r-8,d.length-8*r),16),!1);for(let r=0;r<f/4-t;r++)b[r]=0}function vs(c,e,a){a=a||c.byteLength,e=e||0;let f=new Uint32Array(c.buffer,e,a/4),d=new Array(a/4);return f.forEach((b,t)=>d[d.length-t-1]=b.toString(16).padStart(8,"0")),Mg(d.join(""),16)}function gC(c,e,a){a=a||c.byteLength,e=e||0;let f=new DataView(c.buffer,c.byteOffset+e,a),d=new Array(a/4);for(let b=0;b<a/4;b++)d[b]=f.getUint32(b*4,!1).toString(16).padStart(8,"0");return Mg(d.join(""),16)}function yC(c,e){return c.toString(e)}function Es(c){let e=new Uint8Array(Math.floor((tr(c)-1)/8)+1);return _s(e,0,c,e.byteLength),e}var gce=id(0),yce=id(1);s();x();var Ive=[];for(let c=0;c<256;c++)Ive[c]=Lve(c,8);function Lve(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}s();x();s();x();function As(c,e,a){if(sC(a))return c.one;let f=lC(a);if(f.length==0)return c.one;let d=e;for(let b=f.length-2;b>=0;b--)d=c.square(d),f[b]&&(d=c.mul(d,e));return d}s();x();function qg(c){if(c.m%2==1)if(_8(n3(c.p,4),1))if(_8(n3(c.p,8),1))if(_8(n3(c.p,16),1))Fve(c);else if(_8(n3(c.p,16),9))Cve(c);else throw new Error("Field withot sqrt");else if(_8(n3(c.p,8),5))Rve(c);else throw new Error("Field withot sqrt");else _8(n3(c.p,4),3)&&Bve(c);else{let e=n3(rr(c.p,c.m/2),4);e==1?Pve(c):e==3?Tve(c):Ove(c)}}function Fve(c){for(c.sqrt_q=rr(c.p,c.m),c.sqrt_s=0,c.sqrt_t=X7(c.sqrt_q,1);!kg(c.sqrt_t);)c.sqrt_s=c.sqrt_s+1,c.sqrt_t=o5(c.sqrt_t,2);let e=c.one;for(;c.eq(e,c.one);){let a=c.random();c.sqrt_z=c.pow(a,c.sqrt_t),e=c.pow(c.sqrt_z,2**(c.sqrt_s-1))}c.sqrt_tm1d2=o5(X7(c.sqrt_t,1),2),c.sqrt=function(a){let f=this;if(f.isZero(a))return f.zero;let d=f.pow(a,f.sqrt_tm1d2),b=f.pow(f.mul(f.square(d),a),2**(f.sqrt_s-1));if(f.eq(b,f.negone))return null;let t=f.sqrt_s,r=f.mul(a,d),o=f.mul(r,d),n=f.sqrt_z;for(;!f.eq(o,f.one);){let i=f.square(o),l=1;for(;!f.eq(i,f.one);)i=f.square(i),l++;d=n;for(let h=0;h<t-l-1;h++)d=f.square(d);n=f.square(d),o=f.mul(o,n),r=f.mul(r,d),t=l}return f.geq(r,f.zero)?r:f.neg(r)}}function Cve(c){c.sqrt=function(){throw new Error("Sqrt alg 4 not implemented")}}function Rve(c){c.sqrt=function(){throw new Error("Sqrt alg 3 not implemented")}}function Bve(c){c.sqrt_q=rr(c.p,c.m),c.sqrt_e1=o5(X7(c.sqrt_q,3),4),c.sqrt=function(e){if(this.isZero(e))return this.zero;let a=this.pow(e,this.sqrt_e1),f=this.mul(this.square(a),e);if(this.eq(f,this.negone))return null;let d=this.mul(a,e);return c.geq(d,c.zero)?d:c.neg(d)}}function Pve(c){c.sqrt=function(){throw new Error("Sqrt alg 10 not implemented")}}function Tve(c){c.sqrt_q=rr(c.p,c.m/2),c.sqrt_e34=o5(X7(c.sqrt_q,3),4),c.sqrt_e12=o5(X7(c.sqrt_q,1),2),c.frobenius=function(e,a){return e%2==1?c.conjugate(a):a},c.sqrt=function(e){let a=this,f=a.pow(e,a.sqrt_e34),d=a.mul(a.square(f),e),b=a.mul(a.frobenius(1,d),d);if(a.eq(b,a.negone))return null;let t=a.mul(f,e),r;if(a.eq(d,a.negone))r=a.mul(t,[a.F.zero,a.F.one]);else{let o=a.pow(a.add(a.one,d),a.sqrt_e12);r=a.mul(o,t)}return a.geq(r,a.zero)?r:a.neg(r)}}function Ove(c){c.sqrt=function(){throw new Error("Sqrt alg 8 not implemented")}}s();x();s();x();_3();function wce(c){let e=new Uint8Array(c);if(process.browser)if(typeof globalThis.crypto<"u")globalThis.crypto.getRandomValues(e);else for(let a=0;a<c;a++)e[a]=Math.random()*4294967296>>>0;else o1.randomFillSync(e);return e}s();x();var Ss=class{constructor(e,a,f){this.F=a,this.G=e,this.opMulGF=f;let d=a.sqrt_t||a.t,b=a.sqrt_s||a.s,t=a.one;for(;a.eq(a.pow(t,a.half),a.one);)t=a.add(t,a.one);this.w=new Array(b+1),this.wi=new Array(b+1),this.w[b]=this.F.pow(t,d),this.wi[b]=this.F.inv(this.w[b]);let r=b-1;for(;r>=0;)this.w[r]=this.F.square(this.w[r+1]),this.wi[r]=this.F.square(this.wi[r+1]),r--;this.roots=[],this._setRoots(Math.min(b,15))}_setRoots(e){for(let a=e;a>=0&&!this.roots[a];a--){let f=this.F.one,d=1<<a,b=new Array(d);for(let t=0;t<d;t++)b[t]=f,f=this.F.mul(f,this.w[a]);this.roots[a]=b}}fft(e){if(e.length<=1)return e;let a=_ce(e.length-1)+1;this._setRoots(a);let f=1<<a;if(e.length!=f)throw new Error("Size must be multiple of 2");return Gg(this,e,a,0,1)}ifft(e){if(e.length<=1)return e;let a=_ce(e.length-1)+1;this._setRoots(a);let f=1<<a;if(e.length!=f)throw new Error("Size must be multiple of 2");let d=Gg(this,e,a,0,1),b=this.F.inv(this.F.mulScalar(this.F.one,f)),t=new Array(f);for(let r=0;r<f;r++)t[r]=this.opMulGF(d[(f-r)%f],b);return t}};function _ce(c){return((c&4294901760)!==0?(c&=4294901760,16):0)|((c&4278255360)!==0?(c&=4278255360,8):0)|((c&4042322160)!==0?(c&=4042322160,4):0)|((c&3435973836)!==0?(c&=3435973836,2):0)|(c&2863311530)!==0}function Gg(c,e,a,f,d){let b=1<<a;if(b==1)return[e[f]];if(b==2)return[c.G.add(e[f],e[f+d]),c.G.sub(e[f],e[f+d])];let t=b>>1,r=Gg(c,e,a-1,f,d*2),o=Gg(c,e,a-1,f+d,d*2),n=new Array(b);for(let i=0;i<t;i++)n[i]=c.G.add(r[i],c.opMulGF(o[i],c.roots[a][i])),n[i+t]=c.G.sub(r[i],c.opMulGF(o[i],c.roots[a][i]));return n}var s5=class{constructor(e){this.type="F1",this.one=BigInt(1),this.zero=BigInt(0),this.p=BigInt(e),this.m=1,this.negone=this.p-this.one,this.two=BigInt(2),this.half=this.p>>this.one,this.bitLength=tr(this.p),this.mask=(this.one<<BigInt(this.bitLength))-this.one,this.n64=Math.floor((this.bitLength-1)/64)+1,this.n32=this.n64*2,this.n8=this.n64*8,this.R=this.e(this.one<<BigInt(this.n64*64)),this.Ri=this.inv(this.R);let a=this.negone>>this.one;this.nqr=this.two;let f=this.pow(this.nqr,a);for(;!this.eq(f,this.negone);)this.nqr=this.nqr+this.one,f=this.pow(this.nqr,a);for(this.s=0,this.t=this.negone;(this.t&this.one)==this.zero;)this.s=this.s+1,this.t=this.t>>this.one;this.nqr_to_t=this.pow(this.nqr,this.t),qg(this),this.FFT=new Ss(this,this,this.mul.bind(this)),this.fft=this.FFT.fft.bind(this.FFT),this.ifft=this.FFT.ifft.bind(this.FFT),this.w=this.FFT.w,this.wi=this.FFT.wi,this.shift=this.square(this.nqr),this.k=this.exp(this.nqr,2**this.s)}e(e,a){let f;if(a?a==16&&(f=BigInt("0x"+e)):f=BigInt(e),f<0){let d=-f;return d>=this.p&&(d=d%this.p),this.p-d}else return f>=this.p?f%this.p:f}add(e,a){let f=e+a;return f>=this.p?f-this.p:f}sub(e,a){return e>=a?e-a:this.p-a+e}neg(e){return e&&this.p-e}mul(e,a){return e*a%this.p}mulScalar(e,a){return e*this.e(a)%this.p}square(e){return e*e%this.p}eq(e,a){return e==a}neq(e,a){return e!=a}lt(e,a){let f=e>this.half?e-this.p:e,d=a>this.half?a-this.p:a;return f<d}gt(e,a){let f=e>this.half?e-this.p:e,d=a>this.half?a-this.p:a;return f>d}leq(e,a){let f=e>this.half?e-this.p:e,d=a>this.half?a-this.p:a;return f<=d}geq(e,a){let f=e>this.half?e-this.p:e,d=a>this.half?a-this.p:a;return f>=d}div(e,a){return this.mul(e,this.inv(a))}idiv(e,a){if(!a)throw new Error("Division by zero");return e/a}inv(e){if(!e)throw new Error("Division by zero");let a=this.zero,f=this.p,d=this.one,b=e%this.p;for(;b;){let t=f/b;[a,d]=[d,a-t*d],[f,b]=[b,f-t*b]}return a<this.zero&&(a+=this.p),a}mod(e,a){return e%a}pow(e,a){return As(this,e,a)}exp(e,a){return As(this,e,a)}band(e,a){let f=e&a&this.mask;return f>=this.p?f-this.p:f}bor(e,a){let f=(e|a)&this.mask;return f>=this.p?f-this.p:f}bxor(e,a){let f=(e^a)&this.mask;return f>=this.p?f-this.p:f}bnot(e){let a=e^this.mask;return a>=this.p?a-this.p:a}shl(e,a){if(Number(a)<this.bitLength){let f=e<<a&this.mask;return f>=this.p?f-this.p:f}else{let f=this.p-a;return Number(f)<this.bitLength?e>>f:this.zero}}shr(e,a){if(Number(a)<this.bitLength)return e>>a;{let f=this.p-a;if(Number(f)<this.bitLength){let d=e<<f&this.mask;return d>=this.p?d-this.p:d}else return 0}}land(e,a){return e&&a?this.one:this.zero}lor(e,a){return e||a?this.one:this.zero}lnot(e){return e?this.zero:this.one}sqrt_old(e){if(e==this.zero)return this.zero;if(this.pow(e,this.negone>>this.one)!=this.one)return null;let f=this.s,d=this.nqr_to_t,b=this.pow(e,this.t),t=this.pow(e,this.add(this.t,this.one)>>this.one);for(;b!=this.one;){let r=this.square(b),o=1;for(;r!=this.one;)o++,r=this.square(r);let n=d;for(let i=0;i<f-o-1;i++)n=this.square(n);f=o,d=this.square(n),b=this.mul(b,d),t=this.mul(t,n)}return t>this.p>>this.one&&(t=this.neg(t)),t}normalize(e,a){if(e=BigInt(e,a),e<0){let f=-e;return f>=this.p&&(f=f%this.p),this.p-f}else return e>=this.p?e%this.p:e}random(){let e=this.bitLength*2/8,a=this.zero;for(let f=0;f<e;f++)a=(a<<BigInt(8))+BigInt(wce(1)[0]);return a%this.p}toString(e,a){a=a||10;let f;return e>this.half&&a==10?f="-"+(this.p-e).toString(a):f=e.toString(a),f}isZero(e){return e==this.zero}fromRng(e){let a;do{a=this.zero;for(let f=0;f<this.n64;f++)a+=e.nextU64()<<BigInt(64*f);a&=this.mask}while(a>=this.p);return a=a*this.Ri%this.p,a}fft(e){return this.FFT.fft(e)}ifft(e){return this.FFT.ifft(e)}toRprLE(e,a,f){_s(e,a,f,this.n64*8)}toRprBE(e,a,f){mC(e,a,f,this.n64*8)}toRprBEM(e,a,f){return this.toRprBE(e,a,this.mul(this.R,f))}toRprLEM(e,a,f){return this.toRprLE(e,a,this.mul(this.R,f))}fromRprLE(e,a){return vs(e,a,this.n8)}fromRprBE(e,a){return gC(e,a,this.n8)}fromRprLEM(e,a){return this.mul(this.fromRprLE(e,a),this.Ri)}fromRprBEM(e,a){return this.mul(this.fromRprBE(e,a),this.Ri)}toObject(e){return e}};s();x();s();x();s();x();s();x();var Vve=Fe(E3(),1);s();x();s();x();s();x();var Mve=[];for(let c=0;c<256;c++)Mve[c]=Dve(c,8);function Dve(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}s();x();s();x();s();x();s();x();s();x();s();x();s();x();function wC(c){let a,f;c&&(c.onmessage=function(i){let l;if(i.data?l=i.data:l=i,l[0].cmd=="INIT")d(l[0]).then(function(){c.postMessage(l.result)});else if(l[0].cmd=="TERMINATE")c.close();else{let h=n(l);c.postMessage(h)}});async function d(i){let l=new Uint8Array(i.code),h=await WebAssembly.compile(l);f=new WebAssembly.Memory({initial:i.init,maximum:32767}),a=await WebAssembly.instantiate(h,{env:{memory:f}})}function b(i){let l=new Uint32Array(f.buffer,0,1);for(;l[0]&3;)l[0]++;let h=l[0];if(l[0]+=i,l[0]+i>f.buffer.byteLength){let u=f.buffer.byteLength/65536,g=Math.floor((l[0]+i)/65536)+1;g>32767&&(g=32767),f.grow(g-u)}return h}function t(i){let l=b(i.byteLength);return o(l,i),l}function r(i,l){let h=new Uint8Array(f.buffer);return new Uint8Array(h.buffer,h.byteOffset+i,l)}function o(i,l){new Uint8Array(f.buffer).set(new Uint8Array(l),i)}function n(i){if(i[0].cmd=="INIT")return d(i[0]);let l={vars:[],out:[]},u=new Uint32Array(f.buffer,0,1)[0];for(let E=0;E<i.length;E++)switch(i[E].cmd){case"ALLOCSET":l.vars[i[E].var]=t(i[E].buff);break;case"ALLOC":l.vars[i[E].var]=b(i[E].len);break;case"SET":o(l.vars[i[E].var],i[E].buff);break;case"CALL":{let _=[];for(let F=0;F<i[E].params.length;F++){let L=i[E].params[F];typeof L.var<"u"?_.push(l.vars[L.var]+(L.offset||0)):typeof L.val<"u"&&_.push(L.val)}a.exports[i[E].fnName](..._);break}case"GET":l.out[i[E].out]=r(l.vars[i[E].var],i[E].len).slice();break;default:throw new Error("Invalid cmd")}let g=new Uint32Array(f.buffer,0,1);return g[0]=u,l.out}return n}var Gve=Fe(Wr(),1);function zve(c){return process.browser?globalThis.btoa(c):Buffer.from(c).toString("base64")}var jve=zve("("+wC.toString()+")(self)"),Jj0="data:application/javascript;base64,"+jve;s();x();s();x();s();x();s();x();globalThis.curve_bn128=null;s();x();var Kve=Fe(E3(),1);globalThis.curve_bls12381=null;s();x();var JH0=id("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),ZH0=id("21888242871839275222246405745257275088548364400416034343698204186575808495617"),YH0=id("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),XH0=id("21888242871839275222246405745257275088696311157297823662689037894645226208583");var d1=lf;async function Is(c,e){e=e||{};let a=32767,f,d=!1;for(;!d;)try{f=new WebAssembly.Memory({initial:a}),d=!0}catch(_){if(a===1)throw _;console.warn("Could not allocate "+a*1024*64+" bytes. This may cause severe instability. Trying with "+a*1024*64/2+" bytes"),a=Math.floor(a/2)}let b=await WebAssembly.compile(c),t,r="",o="",n=1,i=0,l=0,h=await WebAssembly.instantiate(b,{env:{memory:f},runtime:{exceptionHandler:function(_){let F;throw _==1?F="Signal not found. ":_==2?F="Too many signals set. ":_==3?F="Signal already set. ":_==4?F="Assert Failed. ":_==5?F="Not enough memory. ":_==6?F="Input signal array access exceeds the size. ":F="Unknown error. ",console.error("ERROR: ",_,r),new Error(F+r)},printErrorMessage:function(){r+=g()+`
|
|
350
350
|
`},writeBufferMessage:function(){let _=g();_===`
|
|
351
351
|
`?(console.log(o),o=""):(o!==""&&(o+=" "),o+=_)},showSharedRWMemory:function(){let _=h.exports.getFieldNumLen32(),F=new Uint32Array(_);for(let L=0;L<_;L++)F[_-1-L]=h.exports.readSharedRWMemory(L);if(n>=2&&(i>=1||l>=7)){o!==""&&(o+=" ");let L=d1.fromArray(F,4294967296).toString();o+=L}else console.log(d1.fromArray(F,4294967296))},error:function(_,F,L,U,O,H){let P;throw _==7?P=E(F)+" "+t.getFr(U).toString()+" != "+t.getFr(O).toString()+" "+E(H):_==9?P=E(F)+" "+t.getFr(U).toString()+" "+E(O):_==5&&e.sym?P=E(F)+" "+e.sym.labelIdx2Name[O]:P=E(F)+" "+L+" "+U+" "+O+" "+H,console.log("ERROR: ",_,P),new Error(P)},log:function(_){console.log(t.getFr(_).toString())},logGetSignal:function(_,F){e.logGetSignal&&e.logGetSignal(_,t.getFr(F))},logSetSignal:function(_,F){e.logSetSignal&&e.logSetSignal(_,t.getFr(F))},logStartComponent:function(_){e.logStartComponent&&e.logStartComponent(_)},logFinishComponent:function(_){e.logFinishComponent&&e.logFinishComponent(_)}}});typeof h.exports.getVersion=="function"&&(n=h.exports.getVersion()),typeof h.exports.getMinorVersion=="function"&&(i=h.exports.getMinorVersion()),typeof h.exports.getPatchVersion=="function"&&(l=h.exports.getPatchVersion());let u=e&&(e.sanityCheck||e.logGetSignal||e.logSetSignal||e.logStartComponent||e.logFinishComponent);return n===2?t=new vC(h,u):t=new _C(f,h,u),t;function g(){for(var _="",F=h.exports.getMessageChar();F!=0;)_+=String.fromCharCode(F),F=h.exports.getMessageChar();return _}function E(_){let F=new Uint8Array(f.buffer),L=[];for(let U=0;F[_+U]>0;U++)L.push(F[_+U]);return String.fromCharCode.apply(null,L)}}var _C=class{constructor(e,a,f){this.memory=e,this.i32=new Uint32Array(e.buffer),this.instance=a,this.n32=(this.instance.exports.getFrLen()>>2)-2;let d=this.instance.exports.getPRawPrime(),b=new Array(this.n32);for(let t=0;t<this.n32;t++)b[this.n32-1-t]=this.i32[(d>>2)+t];this.prime=d1.fromArray(b,4294967296),this.Fr=new s5(this.prime),this.mask32=d1.fromString("FFFFFFFF",16),this.NVars=this.instance.exports.getNVars(),this.n64=Math.floor((this.Fr.bitLength-1)/64)+1,this.R=this.Fr.e(d1.shiftLeft(1,this.n64*64)),this.RInv=this.Fr.inv(this.R),this.sanityCheck=f}circom_version(){return 1}async _doCalculateWitness(e,a){this.instance.exports.init(this.sanityCheck||a?1:0);let f=this.allocInt(),d=this.allocFr();Object.keys(e).forEach(t=>{let r=oC(t),o=parseInt(r.slice(0,8),16),n=parseInt(r.slice(8,16),16);try{this.instance.exports.getSignalOffset32(f,0,o,n)}catch{throw new Error(`Signal ${t} is not an input of the circuit.`)}let i=this.getInt(f),l=iC(e[t]);for(let h=0;h<l.length;h++)this.setFr(d,l[h]),this.instance.exports.setSignal(0,0,i+h,d)})}async calculateWitness(e,a){let f=this,d=f.i32[0],b=[];await f._doCalculateWitness(e,a);for(let t=0;t<f.NVars;t++){let r=f.instance.exports.getPWitness(t);b.push(f.getFr(r))}return f.i32[0]=d,b}async calculateBinWitness(e,a){let f=this,d=f.i32[0];await f._doCalculateWitness(e,a);let b=f.instance.exports.getWitnessBuffer();f.i32[0]=d;let t=f.memory.buffer.slice(b,b+f.NVars*f.n64*8);return new Uint8Array(t)}allocInt(){let e=this.i32[0];return this.i32[0]=e+8,e}allocFr(){let e=this.i32[0];return this.i32[0]=e+this.n32*4+8,e}getInt(e){return this.i32[e>>2]}setInt(e,a){this.i32[e>>2]=a}getFr(e){let a=this,f=e>>2;if(a.i32[f+1]&2147483648){let b=new Array(a.n32);for(let r=0;r<a.n32;r++)b[a.n32-1-r]=a.i32[f+2+r];let t=a.Fr.e(d1.fromArray(b,4294967296));return a.i32[f+1]&1073741824?d(t):t}else return a.i32[f]&2147483648?a.Fr.e(a.i32[f]-4294967296):a.Fr.e(a.i32[f]);function d(b){return a.Fr.mul(a.RInv,b)}}setFr(e,a){let f=this;a=f.Fr.e(a);let d=f.Fr.neg(f.Fr.e("80000000",16)),b=f.Fr.e("7FFFFFFF",16);if(f.Fr.geq(a,d)&&f.Fr.leq(a,b)){let r;f.Fr.geq(a,f.Fr.zero)?r=d1.toNumber(a):(r=d1.toNumber(f.Fr.sub(a,d)),r=r-2147483648,r=4294967296+r),f.i32[e>>2]=r,f.i32[(e>>2)+1]=0;return}f.i32[e>>2]=0,f.i32[(e>>2)+1]=2147483648;let t=d1.toArray(a,4294967296);for(let r=0;r<f.n32;r++){let o=t.length-1-r;o>=0?f.i32[(e>>2)+2+r]=t[o]:f.i32[(e>>2)+2+r]=0}}},vC=class{constructor(e,a){this.instance=e,this.version=this.instance.exports.getVersion(),this.n32=this.instance.exports.getFieldNumLen32(),this.instance.exports.getRawPrime();let f=new Array(this.n32);for(let d=0;d<this.n32;d++)f[this.n32-1-d]=this.instance.exports.readSharedRWMemory(d);this.prime=d1.fromArray(f,4294967296),this.witnessSize=this.instance.exports.getWitnessSize(),this.sanityCheck=a}circom_version(){return this.instance.exports.getVersion()}async _doCalculateWitness(e,a){this.instance.exports.init(this.sanityCheck||a?1:0);let f=Object.keys(e);var d=0;if(f.forEach(b=>{let t=oC(b),r=parseInt(t.slice(0,8),16),o=parseInt(t.slice(8,16),16),n=iC(e[b]);for(let i=0;i<n.length;i++){let l=sce(n[i],this.n32);for(let h=0;h<this.n32;h++)this.instance.exports.writeSharedRWMemory(h,l[this.n32-1-h]);try{this.instance.exports.setInputSignal(r,o,i),d++}catch(h){throw new Error(h)}}}),d<this.instance.exports.getInputSize())throw new Error(`Not all inputs have been set. Only ${d} out of ${this.instance.exports.getInputSize()}`)}async calculateWitness(e,a){let f=[];await this._doCalculateWitness(e,a);for(let d=0;d<this.witnessSize;d++){this.instance.exports.getWitness(d);let b=new Uint32Array(this.n32);for(let t=0;t<this.n32;t++)b[this.n32-1-t]=this.instance.exports.readSharedRWMemory(t);f.push(d1.fromArray(b,4294967296))}return f}async calculateWTNSBin(e,a){let f=new Uint32Array(this.witnessSize*this.n32+this.n32+11),d=new Uint8Array(f.buffer);await this._doCalculateWitness(e,a),d[0]="w".charCodeAt(0),d[1]="t".charCodeAt(0),d[2]="n".charCodeAt(0),d[3]="s".charCodeAt(0),f[1]=2,f[2]=2,f[3]=1;let b=this.n32*4,r=(8+b).toString(16);f[4]=parseInt(r.slice(0,8),16),f[5]=parseInt(r.slice(8,16),16),f[6]=b,this.instance.exports.getRawPrime();var o=7;for(let l=0;l<this.n32;l++)f[o+l]=this.instance.exports.readSharedRWMemory(l);o+=this.n32,f[o]=this.witnessSize,o++,f[o]=2,o++;let i=(b*this.witnessSize).toString(16);f[o]=parseInt(i.slice(0,8),16),f[o+1]=parseInt(i.slice(8,16),16),o+=2;for(let l=0;l<this.witnessSize;l++){this.instance.exports.getWitness(l);for(let h=0;h<this.n32;h++)f[o+h]=this.instance.exports.readSharedRWMemory(h);o+=this.n32}return d}};var{unstringifyBigInts:Jve}=Ya;async function Ls(c,e,a,f){let d=Jve(c),b=await c3(e),t=await b.read(b.totalSize);await b.close();let r=await Is(t);if(r.circom_version()==1){let o=await r.calculateBinWitness(d),n=await of(a,"wtns",2,2);await ice(n,o,r.prime),await n.close()}else{let o=await W7(a),n=await r.calculateWTNSBin(d);await o.write(n),await o.close()}}var{unstringifyBigInts:Zve}=Ya;async function EC(c,e,a,f){let d=Zve(c),b={type:"mem"};return await Ls(d,e,b),await ws(a,b,f)}s();x();var{unstringifyBigInts:AC}=Ya;async function SC(c,e,a,f){let d=AC(c),b=AC(a),t=AC(e),r=await Rg(d.curve),o=r.G1.fromObject(d.IC[0]),n=new Uint8Array(r.G1.F.n8*2*t.length),i=new Uint8Array(r.Fr.n8*t.length);for(let O=0;O<t.length;O++){let H=r.G1.fromObject(d.IC[O+1]);n.set(H,O*r.G1.F.n8*2),Ma.toRprLE(i,r.Fr.n8*O,t[O],r.Fr.n8)}let l=await r.G1.multiExpAffine(n,i);l=r.G1.add(l,o);let h=r.G1.fromObject(b.pi_a),u=r.G2.fromObject(b.pi_b),g=r.G1.fromObject(b.pi_c),E=r.G2.fromObject(d.vk_gamma_2),_=r.G2.fromObject(d.vk_delta_2),F=r.G1.fromObject(d.vk_alpha_1),L=r.G2.fromObject(d.vk_beta_2);return await r.pairingEq(r.G1.neg(h),u,l,E,g,_,F,L)?(f&&f.info("OK!"),!0):(f&&f.error("Invalid proof"),!1)}s();x();var{unstringifyBigInts:Sce}=Ya;function v8(c){let e=c.toString(16);for(;e.length<64;)e="0"+e;return e=`"0x${e}"`,e}async function IC(c,e){let a=Sce(c),f=Sce(e),d="";for(let t=0;t<f.length;t++)d!=""&&(d=d+","),d=d+v8(f[t]);let b;return b=`[${v8(a.pi_a[0])}, ${v8(a.pi_a[1])}],[[${v8(a.pi_b[0][1])}, ${v8(a.pi_b[0][0])}],[${v8(a.pi_b[1][1])}, ${v8(a.pi_b[1][0])}]],[${v8(a.pi_c[0])}, ${v8(a.pi_c[1])}],[${d}]`,b}s();x();s();x();s();x();var Xve=Fe(xf(),1);s();x();var Yve=Fe(xf(),1);var eEe=Fe(xf(),1);s();x();var aEe=Fe(xf(),1);s();x();var cEe=Fe(xf(),1);s();x();var tEe=Fe(xf(),1);_3();s();x();var nEe=Fe(xf(),1);s();x();s();x();var oEe=Fe(xf(),1);s();x();var sEe=Fe(xf(),1);s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();s();x();function uEe(c,e){if(!e||e==10)return BigInt(c);if(e==16)return c.slice(0,2)=="0x"?BigInt(c):BigInt("0x"+c)}var Pd=uEe;var hEe=Pd(0),pEe=Pd(1);s();x();var mEe=[];for(let c=0;c<256;c++)mEe[c]=gEe(c,8);function gEe(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}s();x();s();x();s();x();s();x();s();x();_3();s();x();s();x();s();x();s();x();s();x();var UEe=Fe(E3(),1);s();x();s();x();s();x();var FEe=[];for(let c=0;c<256;c++)FEe[c]=CEe(c,8);function CEe(c,e){let a=0,f=c;for(let d=0;d<e;d++)a<<=1,a=a|f&1,f>>=1;return a}s();x();s();x();s();x();s();x();s();x();s();x();s();x();function RC(c){let a,f;c&&(c.onmessage=function(i){let l;if(i.data?l=i.data:l=i,l[0].cmd=="INIT")d(l[0]).then(function(){c.postMessage(l.result)});else if(l[0].cmd=="TERMINATE")c.close();else{let h=n(l);c.postMessage(h)}});async function d(i){let l=new Uint8Array(i.code),h=await WebAssembly.compile(l);f=new WebAssembly.Memory({initial:i.init,maximum:32767}),a=await WebAssembly.instantiate(h,{env:{memory:f}})}function b(i){let l=new Uint32Array(f.buffer,0,1);for(;l[0]&3;)l[0]++;let h=l[0];if(l[0]+=i,l[0]+i>f.buffer.byteLength){let u=f.buffer.byteLength/65536,g=Math.floor((l[0]+i)/65536)+1;g>32767&&(g=32767),f.grow(g-u)}return h}function t(i){let l=b(i.byteLength);return o(l,i),l}function r(i,l){let h=new Uint8Array(f.buffer);return new Uint8Array(h.buffer,h.byteOffset+i,l)}function o(i,l){new Uint8Array(f.buffer).set(new Uint8Array(l),i)}function n(i){if(i[0].cmd=="INIT")return d(i[0]);let l={vars:[],out:[]},u=new Uint32Array(f.buffer,0,1)[0];for(let E=0;E<i.length;E++)switch(i[E].cmd){case"ALLOCSET":l.vars[i[E].var]=t(i[E].buff);break;case"ALLOC":l.vars[i[E].var]=b(i[E].len);break;case"SET":o(l.vars[i[E].var],i[E].buff);break;case"CALL":{let _=[];for(let F=0;F<i[E].params.length;F++){let L=i[E].params[F];typeof L.var<"u"?_.push(l.vars[L.var]+(L.offset||0)):typeof L.val<"u"&&_.push(L.val)}a.exports[i[E].fnName](..._);break}case"GET":l.out[i[E].out]=r(l.vars[i[E].var],i[E].len).slice();break;default:throw new Error("Invalid cmd")}let g=new Uint32Array(f.buffer,0,1);return g[0]=u,l.out}return n}var OEe=Fe(Wr(),1);function NEe(c){return process.browser?globalThis.btoa(c):Buffer.from(c).toString("base64")}var MEe=NEe("("+RC.toString()+")(self)"),nW0="data:application/javascript;base64,"+MEe;s();x();s();x();s();x();s();x();globalThis.curve_bn128=null;s();x();var qEe=Fe(E3(),1);globalThis.curve_bls12381=null;s();x();var nJ0=Pd("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),iJ0=Pd("21888242871839275222246405745257275088548364400416034343698204186575808495617"),oJ0=Pd("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),sJ0=Pd("21888242871839275222246405745257275088696311157297823662689037894645226208583");s();x();var VJ0=Ma.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),KJ0=Ma.e("21888242871839275222246405745257275088548364400416034343698204186575808495617");s();x();s();x();s();x();s();x();var{unstringifyBigInts:gZ0}=Ya;s();x();s();x();s();x();var QEe=Fe(xf(),1);s();x();s();x();s();x();s();x();s();x();var WEe=Fe(xf(),1);_3();s();x();var XEe=Fe(xf(),1);s();x();var eAe=Fe(xf(),1);s();x();s();x();var aAe=Fe(xf(),1);s();x();var{stringifyBigInts:GY0}=Ya;s();x();var EAe=Fe(nfe(),1);s();x();s();x();var SAe=Fe(xf(),1);s();x();s();x();var ife=Fe(cm(),1),{stringifyBigInts:HX0}=Ya,{keccak256:$X0}=ife.default;var{unstringifyBigInts:YX0}=Ya;s();x();var ofe=Fe(cm(),1),{unstringifyBigInts:dea}=Ya,{keccak256:bea}=ofe.default;s();x();var{unstringifyBigInts:sea}=Ya;s();x();async function xfe(c,e){e=e||{};let a;try{a=await WebAssembly.compile(c)}catch(i){throw new Error(i)}let f="",d="",b=await WebAssembly.instantiate(a,{runtime:{exceptionHandler:function(i){let l;throw i==1?l=`Signal not found.
|
|
352
352
|
`:i==2?l=`Too many signals set.
|