@snapshot-labs/snapshot.js 0.12.0-beta.1 → 0.12.0-beta.3
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/snapshot.cjs.js +3 -3
- package/dist/snapshot.esm.js +3 -3
- package/dist/snapshot.min.js +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/utils.spec.js +5 -5
- package/src/utils.ts +3 -3
package/dist/snapshot.min.js
CHANGED
|
@@ -29,4 +29,4 @@ function Gg(t){const{Fp:e,mds:r,reversePartialPowIdx:n,roundConstants:i}=t,{roun
|
|
|
29
29
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:Wg,hexToBytes:Xg}=Hm,ty={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=ty;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Wg(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=ty,r="string"==typeof t?Xg(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:o}=ty._parseInt(r.subarray(2)),{d:s,l:a}=ty._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:s}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),h=r(s);return`30${r(s+o+4)}02${h}${i}02${a}${n}`}},ey=BigInt(0),ry=BigInt(1),ny=BigInt(2),iy=BigInt(3),oy=BigInt(4);function sy(t){const e=function(t){const e=Yg(t);Vm(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return Fm(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function o(t){const{a:n,b:i}=e,o=r.sqr(t),s=r.mul(o,t);return r.add(r.add(s,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(t){return"bigint"==typeof t&&ey<t&&t<e.n}function a(t){if(!s(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function h(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:o}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=Nm(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let s;try{s="bigint"==typeof t?t:Pm(Dm("private key",t,n))}catch(e){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(s=$g(s,o)),a(s),s}const u=new Map;function l(t){if(!(t instanceof c))throw new Error("ProjectivePoint expected")}class c{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof c)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?c.ZERO:new c(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(c.fromAffine)}static fromHex(t){const e=c.fromAffine(i(Dm("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return c.BASE.multiply(h(t))}_setWindowSize(t){this._WINDOW_SIZE=t,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),s=o(t);if(!r.eql(i,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){l(t);const{px:e,py:n,pz:i}=this,{px:o,py:s,pz:a}=t,h=r.eql(r.mul(e,a),r.mul(o,i)),u=r.eql(r.mul(n,a),r.mul(s,i));return h&&u}negate(){return new c(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,iy),{px:o,py:s,pz:a}=this;let h=r.ZERO,u=r.ZERO,l=r.ZERO,f=r.mul(o,o),d=r.mul(s,s),p=r.mul(a,a),m=r.mul(o,s);return m=r.add(m,m),l=r.mul(o,a),l=r.add(l,l),h=r.mul(t,l),u=r.mul(i,p),u=r.add(h,u),h=r.sub(d,u),u=r.add(d,u),u=r.mul(h,u),h=r.mul(m,h),l=r.mul(i,l),p=r.mul(t,p),m=r.sub(f,p),m=r.mul(t,m),m=r.add(m,l),l=r.add(f,f),f=r.add(l,f),f=r.add(f,p),f=r.mul(f,m),u=r.add(u,f),p=r.mul(s,a),p=r.add(p,p),f=r.mul(p,m),h=r.sub(h,f),l=r.mul(p,d),l=r.add(l,l),l=r.add(l,l),new c(h,u,l)}add(t){l(t);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:h}=t;let u=r.ZERO,f=r.ZERO,d=r.ZERO;const p=e.a,m=r.mul(e.b,iy);let g=r.mul(n,s),y=r.mul(i,a),v=r.mul(o,h),w=r.add(n,i),b=r.add(s,a);w=r.mul(w,b),b=r.add(g,y),w=r.sub(w,b),b=r.add(n,o);let _=r.add(s,h);return b=r.mul(b,_),_=r.add(g,v),b=r.sub(b,_),_=r.add(i,o),u=r.add(a,h),_=r.mul(_,u),u=r.add(y,v),_=r.sub(_,u),d=r.mul(p,b),u=r.mul(m,v),d=r.add(u,d),u=r.sub(y,d),d=r.add(y,d),f=r.mul(u,d),y=r.add(g,g),y=r.add(y,g),v=r.mul(p,v),b=r.mul(m,b),y=r.add(y,v),v=r.sub(g,v),v=r.mul(p,v),b=r.add(b,v),g=r.mul(y,b),f=r.add(f,g),g=r.mul(_,b),u=r.mul(w,u),u=r.sub(u,g),g=r.mul(w,y),d=r.mul(_,d),d=r.add(d,g),new c(u,f,d)}subtract(t){return this.add(t.negate())}is0(){return this.equals(c.ZERO)}wNAF(t){return d.wNAFCached(this,u,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(c.fromAffine)}))}multiplyUnsafe(t){const n=c.ZERO;if(t===ey)return n;if(a(t),t===ry)return this;const{endo:i}=e;if(!i)return d.unsafeLadder(this,t);let{k1neg:o,k1:s,k2neg:h,k2:u}=i.splitScalar(t),l=n,f=n,p=this;for(;s>ey||u>ey;)s&ry&&(l=l.add(p)),u&ry&&(f=f.add(p)),p=p.double(),s>>=ry,u>>=ry;return o&&(l=l.negate()),h&&(f=f.negate()),f=new c(r.mul(f.px,i.beta),f.py,f.pz),l.add(f)}multiply(t){a(t);let n,i,o=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:h}=s.splitScalar(o);let{p:u,f:l}=this.wNAF(e),{p:f,f:p}=this.wNAF(h);u=d.constTimeNegate(t,u),f=d.constTimeNegate(a,f),f=new c(r.mul(f.px,s.beta),f.py,f.pz),n=u.add(f),i=l.add(p)}else{const{p:t,f:e}=this.wNAF(o);n=t,i=e}return c.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=c.BASE,i=(t,e)=>e!==ey&&e!==ry&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,r));return o.is0()?void 0:o}toAffine(t){const{px:e,py:n,pz:i}=this,o=this.is0();null==t&&(t=o?r.ONE:r.inv(i));const s=r.mul(e,t),a=r.mul(n,t),h=r.mul(i,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(h,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===ry)return!0;if(r)return r(c,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===ry?this:r?r(c,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(c,this,t)}toHex(t=!0){return Nm(this.toRawBytes(t))}}c.BASE=new c(e.Gx,e.Gy,r.ONE),c.ZERO=new c(r.ZERO,r.ONE,r.ZERO);const f=e.nBitLength,d=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,i=e;for(;r>Jg;)r&Qg&&(n=n.add(i)),i=i.double(),r>>=Qg;return n},precomputeWindow(t,e){const{windows:r,windowSize:i}=n(e),o=[];let s=t,a=s;for(let t=0;t<r;t++){a=s,o.push(a);for(let t=1;t<i;t++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(e,i,o){const{windows:s,windowSize:a}=n(e);let h=t.ZERO,u=t.BASE;const l=BigInt(2**e-1),c=2**e,f=BigInt(e);for(let t=0;t<s;t++){const e=t*a;let n=Number(o&l);o>>=f,n>a&&(n-=c,o+=Qg);const s=e,d=e+Math.abs(n)-1,p=t%2!=0,m=n<0;0===n?u=u.add(r(p,i[s])):h=h.add(r(m,i[d]))}return{p:h,f:u}},wNAFCached(t,e,r,n){const i=t._WINDOW_SIZE||1;let o=e.get(t);return o||(o=this.precomputeWindow(t,i),1!==i&&e.set(t,n(o))),this.wNAF(i,o,r)}}}(c,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:c,normPrivateKeyToScalar:h,weierstrassEquation:o,isWithinCurveOrder:s}}function ay(t){const e=function(t){const e=Yg(t);return Vm(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:r,n:n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(t){return $g(t,n)}function a(t){return Dg(t,n)}const{ProjectivePoint:h,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:c}=sy({...e,toBytes(t,e,n){const i=e.toAffine(),o=r.toBytes(i.x),s=Fm;return n?s(Uint8Array.from([e.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],s=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===o&&4===n){return{x:r.fromBytes(s.subarray(0,r.BYTES)),y:r.fromBytes(s.subarray(r.BYTES,2*r.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const t=Pm(s);if(!(ey<(a=t)&&a<r.ORDER))throw new Error("Point is not on curve");const e=l(t);let i=r.sqrt(e);return 1==(1&n)!==((i&ry)===ry)&&(i=r.neg(i)),{x:t,y:i}}var a}}),f=t=>Nm(Om(t,e.nByteLength));function d(t){return t>n>>ry}const p=(t,e,r)=>Pm(t.slice(e,r));class m{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=Dm("compactSignature",t,2*r),new m(p(t,0,r),p(t,r,2*r))}static fromDER(t){const{r:e,s:r}=ty.toSig(Dm("DER",t));return new m(e,r)}assertValidity(){if(!c(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!c(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new m(this.r,this.s,t)}recoverPublicKey(t){const{r:n,s:i,recovery:o}=this,u=w(Dm("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const l=2===o||3===o?n+e.n:n;if(l>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=0==(1&o)?"02":"03",d=h.fromHex(c+f(l)),p=a(l),m=s(-u*p),g=s(i*p),y=h.BASE.multiplyAndAddUnsafe(d,m,g);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Tm(this.toDERHex())}toDERHex(){return ty.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Tm(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const g={isValidPrivateKey(t){try{return u(t),!0}catch(t){return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const t=Hg(e.n);return function(t,e,r=!1){const n=t.length,i=Vg(e),o=Hg(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=$g(r?Pm(t):Rm(t),e-Ig)+Ig;return r?$m(s,i):Om(s,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=h.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function y(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===o:r?n===2*i||n===2*o:t instanceof h}const v=e.bits2int||function(t){const r=Pm(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},w=e.bits2int_modN||function(t){return s(v(t))},b=Um(e.nBitLength);function _(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(ey<=t&&t<b))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Om(t,e.nByteLength)}function E(t,n,i=A){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:l}=e;let{lowS:f,prehash:p,extraEntropy:g}=i;null==f&&(f=!0),t=Dm("msgHash",t),p&&(t=Dm("prehashed msgHash",o(t)));const y=w(t),b=u(n),E=[_(b),_(y)];if(null!=g){const t=!0===g?l(r.BYTES):g;E.push(Dm("extraEntropy",t))}const k=Fm(...E),M=y;return{seed:k,k2sig:function(t){const e=v(t);if(!c(e))return;const r=a(e),n=h.BASE.multiply(e).toAffine(),i=s(n.x);if(i===ey)return;const o=s(r*s(M+i*b));if(o===ey)return;let u=(n.x===i?0:2)|Number(n.y&ry),l=o;return f&&d(o)&&(l=function(t){return d(t)?s(-t):t}(o),u^=1),new m(i,l,u)}}}const A={lowS:e.lowS,prehash:!1},k={lowS:e.lowS,prehash:!1};return h.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return h.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(y(t))throw new Error("first arg must be private key");if(!y(e))throw new Error("second arg must be public key");return h.fromHex(e).multiply(u(t)).toRawBytes(r)},sign:function(t,r,n=A){const{seed:i,k2sig:o}=E(t,r,n),s=e;return zm(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(t,r,n,i=k){const o=t;if(r=Dm("msgHash",r),n=Dm("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:l}=i;let c,f;try{if("string"==typeof o||o instanceof Uint8Array)try{c=m.fromDER(o)}catch(t){if(!(t instanceof ty.Err))throw t;c=m.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:t,s:e}=o;c=new m(t,e)}}f=h.fromHex(n)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&c.hasHighS())return!1;l&&(r=e.hash(r));const{r:d,s:p}=c,g=w(r),y=a(p),v=s(g*y),b=s(d*y),_=h.BASE.multiplyAndAddUnsafe(f,v,b)?.toAffine();return!!_&&s(_.x)===d},ProjectivePoint:h,Signature:m,utils:g}}function hy(t,e){const r=t.ORDER;let n=ey;for(let t=r-ry;t%ny===ey;t/=ny)n+=ry;const i=n,o=ny<<i-ry-ry,s=o*ny,a=(r-ry)/s,h=(a-ry)/ny,u=s-ry,l=o,c=t.pow(e,a),f=t.pow(e,(a+ry)/ny);let d=(e,r)=>{let n=c,o=t.pow(r,u),s=t.sqr(o);s=t.mul(s,r);let a=t.mul(e,s);a=t.pow(a,h),a=t.mul(a,o),o=t.mul(a,r),s=t.mul(a,e);let d=t.mul(s,o);a=t.pow(d,l);let p=t.eql(a,t.ONE);o=t.mul(s,f),a=t.mul(d,n),s=t.cmov(o,s,p),d=t.cmov(a,d,p);for(let e=i;e>ry;e--){let r=e-ny;r=ny<<r-ry;let i=t.pow(d,r);const a=t.eql(i,t.ONE);o=t.mul(s,n),n=t.mul(n,n),i=t.mul(d,n),s=t.cmov(o,s,a),d=t.cmov(i,d,a)}return{isValid:p,value:s}};if(t.ORDER%oy===iy){const r=(t.ORDER-iy)/oy,n=t.sqrt(t.neg(e));d=(e,i)=>{let o=t.sqr(i);const s=t.mul(e,i);o=t.mul(o,s);let a=t.pow(o,r);a=t.mul(a,s);const h=t.mul(a,n),u=t.mul(t.sqr(a),i),l=t.eql(u,e);return{isValid:l,value:t.cmov(h,a,l)}}}return d}var uy=Object.freeze({__proto__:null,DER:ty,weierstrassPoints:sy,weierstrass:ay,SWUFpSqrtRatio:hy,mapToCurveSimpleSWU:function(t,e){if(jg(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=hy(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,o,s,a,h,u,l,c;i=t.sqr(n),i=t.mul(i,e.Z),o=t.sqr(i),o=t.add(o,i),s=t.add(o,t.ONE),s=t.mul(s,e.B),a=t.cmov(e.Z,t.neg(o),!t.eql(o,t.ZERO)),a=t.mul(a,e.A),o=t.sqr(s),u=t.sqr(a),h=t.mul(u,e.A),o=t.add(o,h),o=t.mul(o,s),u=t.mul(u,a),h=t.mul(u,e.B),o=t.add(o,h),l=t.mul(i,s);const{isValid:f,value:d}=r(o,u);c=t.mul(i,n),c=t.mul(c,d),l=t.cmov(l,s,f),c=t.cmov(c,d,f);const p=t.isOdd(n)===t.isOdd(c);return c=t.cmov(t.neg(c),c,p),l=t.div(l,a),{x:l,y:c}}}});function ly(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function cy(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}const fy="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,dy=t=>t instanceof Uint8Array;
|
|
30
30
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function py(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!dy(t))throw new Error("expected Uint8Array, got "+typeof t);return t}function my(t=32){if(fy&&"function"==typeof fy.getRandomValues)return fy.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class gy extends class{clone(){return this._cloneInto()}}{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");ly(t.outputLen),ly(t.blockLen)}(t);const r=py(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return cy(this),this.iHash.update(t),this}digestInto(t){cy(this),function(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const yy=(t,e,r)=>new gy(t,e).update(r).digest();yy.create=(t,e)=>new gy(t,e)
|
|
31
31
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const vy=BigInt("3618502788666131213697322783095070105526743751716087489154079457884512865583"),wy=BigInt("0x800000000000000000000000000000000000000000000000000000000000000");function by(t){for(;0===t[0];)t=t.subarray(1);const e=8*t.length-252,r=Pm(t);return e>0?r>>BigInt(e):r}function _y(t){return"string"==typeof t&&1&(t=Oy(t)).length&&(t="0"+t),Tm(t)}const Ey=ay({a:BigInt(1),b:BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),Fp:qg(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),n:vy,nBitLength:252,Gx:BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),Gy:BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),h:BigInt(1),lowS:!1,...function(t){return{hash:t,hmac:(e,...r)=>yy(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!dy(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}(...r)),randomBytes:my}}(Sg),bits2int:by,bits2int_modN:t=>{const e=Pm(t).toString(16);return 63===e.length&&(t=_y(e+"0")),$g(by(t),vy)}}),Ay=Ey;function ky(t){return Dm("","string"==typeof t?_y(t):t)}function My(t){return Nm(ky(t)).padStart(64,"0")}function xy(t,e=!1){return Ey.getPublicKey(My(t),e)}function Sy(t){const{r:e,s:r}=t;if(e<0n||e>=wy)throw new Error(`Signature.r should be [1, ${wy})`);const n=Dg(r,vy);if(n<0n||n>=wy)throw new Error(`inv(Signature.s) should be [1, ${wy})`)}function Ny(t){const e=ky(t);if(Pm(e)>=wy)throw new Error(`msgHash should be [0, ${wy})`);return e}const{CURVE:Iy,ProjectivePoint:Cy,Signature:Ty,utils:Py}=Ey;function Ry(t){return`0x${Nm(t.subarray(1)).replace(/^0+/gm,"")}`}function Oy(t){return t.replace(/^0x/i,"")}function $y(t){const e=ky(t),r=2n**256n,n=r-$g(r,vy);for(let t=0;;t++){const r=Ky(Fm(e,Bm(BigInt(t))));if(r<n)return $g(r,vy).toString(16);if(1e5===t)throw new Error("grindKey is broken: tried 100k vals")}}function By(t){return Ry(xy(t,!0))}const Dy=2n**31n-1n,Fy=t=>Number(t&Dy);const Uy=[new Cy(2089986280348253421170679821480865132823066470938446095505822317253594081284n,1713931329540660377023406109199410414810705867260802078187082345529207694986n,1n),new Cy(996781205833008774514500082376783249102396023663454813447423147977397232763n,1668503676786377725805489344771023921079126552019160156920634619255970485781n,1n),new Cy(2251563274489750535117886426533222435294046428347329203627021249169616184184n,1798716007562728905295480679789526322175868328062420237419143593021674992973n,1n),new Cy(2138414695194151160943305727036575959195309218611738193261179310511854807447n,113410276730064486255102093846540133784865286929052426931474106396135072156n,1n),new Cy(2379962749567351885752724891227938183011949129833673362440656643086021394946n,776496453633298175483985398648758586525933812536653089401905292063708816422n,1n)];function jy(t,e){const r=[];let n=t;for(let t=0;t<248;t++)r.push(n),n=n.double();n=e;for(let t=0;t<4;t++)r.push(n),n=n.double();return r}const Ly=jy(Uy[1],Uy[2]),zy=jy(Uy[3],Uy[4]);function qy(t,e,r){let n=function(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t){if(!Number.isSafeInteger(t))throw new Error(`Invalid pedersenArg: ${t}`);e=BigInt(t)}else e=Pm(ky(t));if(!(0n<=e&&e<Ey.CURVE.Fp.ORDER))throw new Error(`PedersenArg should be 0 <= value < CURVE.P: ${e}`);return e}(e);for(let e=0;e<252;e++){const i=r[e];if(i.equals(t))throw new Error("Same point");0n!==(1n&n)&&(t=t.add(i)),n>>=1n}return t}function Vy(t,e){let r=Uy[0];return r=qy(r,t,Ly),r=qy(r,e,zy),Ry(r.toRawBytes(!0))}const Hy=Um(250),Gy=t=>Pm(bg(t))&Hy,Ky=t=>Pm(Sg(t)),Zy=qg(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481"));function Jy(t,e,r){const n=t.fromBytes(Sg(rg(`${e}${r}`)));return t.create(n)}function Qy(t,e,r,n=0){const i=[],o=[];for(let s=0;s<r;s++)i.push(Jy(t,`${e}x`,n*r+s)),o.push(Jy(t,`${e}y`,n*r+s));if(new Set([...i,...o]).size!==2*r)throw new Error("X and Y values are not distinct");return i.map((e=>o.map((r=>t.inv(t.sub(e,r))))))}function Yy(t,e){if(jg(t.Fp),!Number.isSafeInteger(t.rate)||!Number.isSafeInteger(t.capacity))throw new Error(`Wrong poseidon opts: ${t}`);const r=t.rate+t.capacity,n=t.roundsFull+t.roundsPartial,i=[];for(let e=0;e<n;e++){const n=[];for(let i=0;i<r;i++)n.push(Jy(t.Fp,"Hades",r*e+i));i.push(n)}const o=Kg({...t,t:r,sboxPower:3,reversePartialPowIdx:!0,mds:e,roundConstants:i});return o.m=r,o.rate=t.rate,o.capacity=t.capacity,o}const Wy=Yy({Fp:Zy,rate:2,capacity:1,roundsFull:8,roundsPartial:83},[[3,1,1],[1,-1,1],[1,1,-2]].map((t=>t.map(BigInt))));function Xy(t,e,r=Wy){return r([t,e,2n])[0]}function tv(t,e=Wy){const{m:r,rate:n}=e;if(!Array.isArray(t))throw new Error("bigint array expected in values");const i=Array.from(t);for(i.push(1n);i.length%n!=0;)i.push(0n);let o=new Array(r).fill(0n);for(let t=0;t<i.length;t+=n){for(let e=0;e<n;e++)o[e]+=i[t+e];o=e(o)}return o[0]}var ev=Object.freeze({__proto__:null,MAX_VALUE:wy,_starkCurve:Ay,getPublicKey:xy,getSharedSecret:function(t,e){return Ey.getSharedSecret(My(t),e)},sign:function(t,e,r){const n=Ey.sign(Ny(t),My(e),r);return Sy(n),n},verify:function(t,e,r){if(!(t instanceof Ty)){const e=ky(t);try{t=Ty.fromDER(e)}catch(r){if(!(r instanceof ty.Err))throw r;t=Ty.fromCompact(e)}}return Sy(t),Ey.verify(t,Ny(e),ky(r))},CURVE:Iy,ProjectivePoint:Cy,Signature:Ty,utils:Py,grindKey:$y,getStarkKey:By,ethSigToPrivate:function(t){if(130!==(t=Oy(t)).length)throw new Error("Wrong ethereum signature");return $y(t.substring(0,64))},getAccountPath:function(t,e,r,n){const i=Fy(Ky(t)),o=Fy(Ky(e)),s=Cm(Oy(r));return`m/2645'/${i}'/${o}'/${Fy(s)}'/${Fy(s>>31n)}'/${n}`},pedersen:Vy,computeHashOnElements:(t,e=Vy)=>[0,...t,t.length].reduce(((t,r)=>e(t,r))),keccak:Gy,Fp251:Zy,_poseidonMDS:Qy,poseidonBasic:Yy,poseidonCreate:function(t,e=0){const r=t.rate+t.capacity;if(!Number.isSafeInteger(e))throw new Error(`Wrong mdsAttempt=${e}`);return Yy(t,Qy(t.Fp,"HadesMDS",r,e))},poseidonSmall:Wy,poseidonHash:Xy,poseidonHashFunc:function(t,e,r=Wy){return Bm(Xy(Pm(t),Pm(e),r))},poseidonHashSingle:function(t,e=Wy){return e([t,0n,1n])[0]},poseidonHashMany:tv});function rv(t){return nv.test(t)}var nv=/^-?[0-9]+$/;function iv(t){return ov.test(t)}var ov=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;var sv=function(t){return t.underflow="underflow",t.overflow="overflow",t.truncate_integer="truncate_integer",t.truncate_float="truncate_float",t}({});function av(t){if(!function(t,e){var r=parseFloat(t),n=String(r),i=hv(t),o=hv(n);if(i===o)return!0;if(!0===(null==e?void 0:e.approx)&&!rv(t)&&o.length>=14&&i.startsWith(o.substring(0,14)))return!0;return!1}(t,{approx:!1})){if(rv(t))return sv.truncate_integer;var e=parseFloat(t);return isFinite(e)?0===e?sv.underflow:sv.truncate_float:sv.overflow}}function hv(t){return t.replace(uv,"").replace(cv,"").replace(fv,"").replace(lv,"")}var uv=/[eE][+-]?\d+$/,lv=/^-?(0*)?/,cv=/\./,fv=/0+$/;function dv(t){return dv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dv(t)}function pv(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,mv(n.key),n)}}function mv(t){var e=function(t,e){if("object"!==dv(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==dv(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===dv(e)?e:String(e)}var gv=function(){function t(e){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=mv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(this,"isLosslessNumber",!0),!iv(e))throw new Error('Invalid number (value: "'+e+'")');this.value=e}var e,r,n;return e=t,(r=[{key:"valueOf",value:function(){var t=av(this.value);if(void 0===t||t===sv.truncate_float)return parseFloat(this.value);if(rv(this.value))return BigInt(this.value);throw new Error("Cannot safely convert to number: "+"the value '".concat(this.value,"' would ").concat(t," and become ").concat(parseFloat(this.value)))}},{key:"toString",value:function(){return this.value}}])&&pv(e.prototype,r),n&&pv(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function yv(t){return new gv(t)}function vv(t){return rv(t)?BigInt(t):parseFloat(t)}function wv(t){return wv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wv(t)}function bv(t,e){return _v({"":t},"",t,e)}function _v(t,e,r,n){return Array.isArray(r)?n.call(t,e,function(t,e){for(var r=0;r<t.length;r++)t[r]=_v(t,r+"",t[r],e);return t}(r,n)):r&&"object"===wv(r)&&!function(t){return t&&"object"===dv(t)&&!0===t.isLosslessNumber||!1}(r)?n.call(t,e,function(t,e){return Object.keys(t).forEach((function(r){var n=_v(t,r,t[r],e);void 0!==n?t[r]=n:delete t[r]})),t}(r,n)):n.call(t,e,r)}function Ev(t){return Ev="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ev(t)}function Av(t){return function(t){if(Array.isArray(t))return kv(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return kv(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return kv(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function kv(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Mv(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:yv,n=0,i=a();return p(i),g(),e?bv(i,e):i;function o(){if(t.charCodeAt(n)===$v){n++,u();for(var e={},r=!0;n<t.length&&t.charCodeAt(n)!==Bv;){r?r=!1:(f(),u());var i=n,o=l();void 0===o&&w(),u(),d();var s=a();void 0===s&&M(),Object.prototype.hasOwnProperty.call(e,o)&&!Tv(s,e[o])&&b(o,i+1),e[o]=s}return t.charCodeAt(n)!==Bv&&_(),n++,e}}function s(){if(t.charCodeAt(n)===Dv){n++,u();for(var e=[],r=!0;n<t.length&&t.charCodeAt(n)!==Fv;){r?r=!1:f();var i=a();m(i),e.push(i)}return t.charCodeAt(n)!==Fv&&E(),n++,e}}function a(){var t,e,r,n,i,a;u();var f=null!==(t=null!==(e=null!==(r=null!==(n=null!==(i=null!==(a=l())&&void 0!==a?a:c())&&void 0!==i?i:o())&&void 0!==n?n:s())&&void 0!==r?r:h("true",!0))&&void 0!==e?e:h("false",!1))&&void 0!==t?t:h("null",null);return u(),f}function h(e,r){if(t.slice(n,n+e.length)===e)return n+=e.length,r}function u(){for(;xv(t.charCodeAt(n));)n++}function l(){if(t.charCodeAt(n)===qv){n++;for(var e="";n<t.length&&t.charCodeAt(n)!==qv;){if(t.charCodeAt(n)===Ov){var r=t[n+1],i=Rv[r];void 0!==i?(e+=i,n++):"u"===r?Sv(t.charCodeAt(n+2))&&Sv(t.charCodeAt(n+3))&&Sv(t.charCodeAt(n+4))&&Sv(t.charCodeAt(n+5))?(e+=String.fromCharCode(parseInt(t.slice(n+2,n+6),16)),n+=5):x(n):k(n)}else Cv(t.charCodeAt(n))?e+=t[n]:A(t[n]);n++}return v(),n++,e}}function c(){var e=n;if(t.charCodeAt(n)===Hv&&(n++,y(e)),t.charCodeAt(n)===Gv)n++;else if(Iv(t.charCodeAt(n)))for(n++;Nv(t.charCodeAt(n));)n++;if(t.charCodeAt(n)===Qv)for(n++,y(e);Nv(t.charCodeAt(n));)n++;if(t.charCodeAt(n)===ew||t.charCodeAt(n)===tw)for(n++,t.charCodeAt(n)!==Hv&&t.charCodeAt(n)!==Vv||n++,y(e);Nv(t.charCodeAt(n));)n++;if(n>e)return r(t.slice(e,n))}function f(){if(t.charCodeAt(n)!==Jv)throw new SyntaxError("Comma ',' expected after value ".concat(I()));n++}function d(){if(t.charCodeAt(n)!==Yv)throw new SyntaxError("Colon ':' expected after property name ".concat(I()));n++}function p(t){if(void 0===t)throw new SyntaxError("JSON value expected ".concat(I()))}function m(t){if(void 0===t)throw new SyntaxError("Array item expected ".concat(I()))}function g(){if(n<t.length)throw new SyntaxError("Expected end of input ".concat(I()))}function y(e){if(!Nv(t.charCodeAt(n))){var r=t.slice(e,n);throw new SyntaxError("Invalid number '".concat(r,"', expecting a digit ").concat(I()))}}function v(){if(t.charCodeAt(n)!==qv)throw new SyntaxError("End of string '\"' expected ".concat(I()))}function w(){throw new SyntaxError("Quoted object key expected ".concat(I()))}function b(t,e){throw new SyntaxError("Duplicate key '".concat(t,"' encountered at position ").concat(e))}function _(){throw new SyntaxError("Quoted object key or end of object '}' expected ".concat(I()))}function E(){throw new SyntaxError("Array item or end of array ']' expected ".concat(I()))}function A(t){throw new SyntaxError("Invalid character '".concat(t,"' ").concat(S()))}function k(e){var r=t.slice(e,e+2);throw new SyntaxError("Invalid escape character '".concat(r,"' ").concat(S()))}function M(){throw new SyntaxError("Object value expected after ':' ".concat(S()))}function x(e){for(var r=e+2;/\w/.test(t[r]);)r++;var n=t.slice(e,r);throw new SyntaxError("Invalid unicode character '".concat(n,"' ").concat(S()))}function S(){return"at position ".concat(n)}function N(){return n<t.length?"but got '".concat(t[n],"'"):"but reached end of input"}function I(){return N()+" "+S()}}function xv(t){return t===Uv||t===jv||t===Lv||t===zv}function Sv(t){return t>=Gv&&t<=Zv||t>=Wv&&t<=rw||t>=Xv&&t<=nw}function Nv(t){return t>=Gv&&t<=Zv}function Iv(t){return t>=Kv&&t<=Zv}function Cv(t){return t>=32&&t<=1114111}function Tv(t,e){return t===e||(Array.isArray(t)&&Array.isArray(e)?t.length===e.length&&t.every((function(t,r){return Tv(t,e[r])})):!(!Pv(t)||!Pv(e))&&Av(new Set([].concat(Av(Object.keys(t)),Av(Object.keys(e))))).every((function(r){return Tv(t[r],e[r])})))}function Pv(t){return"object"===Ev(t)&&null!==t}var Rv={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},Ov=92,$v=123,Bv=125,Dv=91,Fv=93,Uv=32,jv=10,Lv=9,zv=13,qv=34,Vv=43,Hv=45,Gv=48,Kv=49,Zv=57,Jv=44,Qv=46,Yv=58,Wv=65,Xv=97,tw=69,ew=101,rw=70,nw=102;function iw(t){return iw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},iw(t)}function ow(t,e,r,n){var i=function(t){if("number"==typeof t)return" ".repeat(t);if("string"==typeof t&&""!==t)return t;return}
|
|
32
|
-
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */(r);return o("function"==typeof e?e.call({"":t},"",t):t,"");function o(t,s){if(Array.isArray(n)){var a=n.find((function(e){return e.test(t)}));if(a){var h=a.stringify(t);if("string"!=typeof h||!iv(h))throw new Error("Invalid JSON number: output of a number stringifier must be a string containing a JSON number "+"(output: ".concat(h,")"));return h}}return"boolean"==typeof t||"number"==typeof t||"string"==typeof t||null===t||t instanceof Date||t instanceof Boolean||t instanceof Number||t instanceof String?JSON.stringify(t):t&&t.isLosslessNumber||"bigint"==typeof t?t.toString():Array.isArray(t)?function(t,r){if(0===t.length)return"[]";for(var n=i?r+i:void 0,s=i?"[\n":"[",a=0;a<t.length;a++){var h="function"==typeof e?e.call(t,String(a),t[a]):t[a];i&&(s+=n),s+=void 0!==h&&"function"!=typeof h?o(h,n):"null",a<t.length-1&&(s+=i?",\n":",")}return s+=i?"\n"+r+"]":"]"}(t,s):t&&"object"===iw(t)?function(t,n){if("function"==typeof t.toJSON)return ow(t.toJSON(),e,r,void 0);var s=Array.isArray(e)?e.map(String):Object.keys(t);if(0===s.length)return"{}";var a=i?n+i:void 0,h=!0,u=i?"{\n":"{";return s.forEach((function(r){var n="function"==typeof e?e.call(t,r,t[r]):t[r];if(function(t,e){return void 0!==e&&"function"!=typeof e&&"symbol"!==iw(e)}(0,n)){h?h=!1:u+=i?",\n":",";var s=JSON.stringify(r);u+=i?a+s+": ":s+":",u+=o(n,a)}})),u+=i?"\n"+n+"}":"}"}(t,s):void 0}}function sw(t){let e=t.length;for(;--e>=0;)t[e]=0}const aw=256,hw=286,uw=30,lw=15,cw=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),fw=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),dw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),pw=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mw=new Array(576);sw(mw);const gw=new Array(60);sw(gw);const yw=new Array(512);sw(yw);const vw=new Array(256);sw(vw);const ww=new Array(29);sw(ww);const bw=new Array(uw);function _w(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let Ew,Aw,kw;function Mw(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}sw(bw);const xw=t=>t<256?yw[t]:yw[256+(t>>>7)],Sw=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},Nw=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,Sw(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},Iw=(t,e,r)=>{Nw(t,r[2*e],r[2*e+1])},Cw=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},Tw=(t,e,r)=>{const n=new Array(16);let i,o,s=0;for(i=1;i<=lw;i++)s=s+r[i-1]<<1,n[i]=s;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=Cw(n[e]++,e))}},Pw=t=>{let e;for(e=0;e<hw;e++)t.dyn_ltree[2*e]=0;for(e=0;e<uw;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},Rw=t=>{t.bi_valid>8?Sw(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},Ow=(t,e,r,n)=>{const i=2*e,o=2*r;return t[i]<t[o]||t[i]===t[o]&&n[e]<=n[r]},$w=(t,e,r)=>{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i<t.heap_len&&Ow(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!Ow(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n},Bw=(t,e,r)=>{let n,i,o,s,a=0;if(0!==t.sym_next)do{n=255&t.pending_buf[t.sym_buf+a++],n+=(255&t.pending_buf[t.sym_buf+a++])<<8,i=t.pending_buf[t.sym_buf+a++],0===n?Iw(t,i,e):(o=vw[i],Iw(t,o+aw+1,e),s=cw[o],0!==s&&(i-=ww[o],Nw(t,i,s)),n--,o=xw(n),Iw(t,o,r),s=fw[o],0!==s&&(n-=bw[o],Nw(t,n,s)))}while(a<t.sym_next);Iw(t,256,e)},Dw=(t,e)=>{const r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,o=e.stat_desc.elems;let s,a,h,u=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<o;s++)0!==r[2*s]?(t.heap[++t.heap_len]=u=s,t.depth[s]=0):r[2*s+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=u<2?++u:0,r[2*h]=1,t.depth[h]=0,t.opt_len--,i&&(t.static_len-=n[2*h+1]);for(e.max_code=u,s=t.heap_len>>1;s>=1;s--)$w(t,r,s);h=o;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],$w(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,r[2*h]=r[2*s]+r[2*a],t.depth[h]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,r[2*s+1]=r[2*a+1]=h,t.heap[1]=h++,$w(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,h=e.stat_desc.max_length;let u,l,c,f,d,p,m=0;for(f=0;f<=lw;f++)t.bl_count[f]=0;for(r[2*t.heap[t.heap_max]+1]=0,u=t.heap_max+1;u<573;u++)l=t.heap[u],f=r[2*r[2*l+1]+1]+1,f>h&&(f=h,m++),r[2*l+1]=f,l>n||(t.bl_count[f]++,d=0,l>=a&&(d=s[l-a]),p=r[2*l],t.opt_len+=p*(f+d),o&&(t.static_len+=p*(i[2*l+1]+d)));if(0!==m){do{for(f=h-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[h]--,m-=2}while(m>0);for(f=h;0!==f;f--)for(l=t.bl_count[f];0!==l;)c=t.heap[--u],c>n||(r[2*c+1]!==f&&(t.opt_len+=(f-r[2*c+1])*r[2*c],r[2*c+1]=f),l--)}})(t,e),Tw(r,u,t.bl_count)},Fw=(t,e,r)=>{let n,i,o=-1,s=e[1],a=0,h=7,u=4;for(0===s&&(h=138,u=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=e[2*(n+1)+1],++a<h&&i===s||(a<u?t.bl_tree[2*i]+=a:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,o=i,0===s?(h=138,u=3):i===s?(h=6,u=3):(h=7,u=4))},Uw=(t,e,r)=>{let n,i,o=-1,s=e[1],a=0,h=7,u=4;for(0===s&&(h=138,u=3),n=0;n<=r;n++)if(i=s,s=e[2*(n+1)+1],!(++a<h&&i===s)){if(a<u)do{Iw(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==o&&(Iw(t,i,t.bl_tree),a--),Iw(t,16,t.bl_tree),Nw(t,a-3,2)):a<=10?(Iw(t,17,t.bl_tree),Nw(t,a-3,3)):(Iw(t,18,t.bl_tree),Nw(t,a-11,7));a=0,o=i,0===s?(h=138,u=3):i===s?(h=6,u=3):(h=7,u=4)}};let jw=!1;const Lw=(t,e,r,n)=>{Nw(t,0+(n?1:0),3),Rw(t),Sw(t,r),Sw(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r};var zw=t=>{jw||((()=>{let t,e,r,n,i;const o=new Array(16);for(r=0,n=0;n<28;n++)for(ww[n]=r,t=0;t<1<<cw[n];t++)vw[r++]=n;for(vw[r-1]=n,i=0,n=0;n<16;n++)for(bw[n]=i,t=0;t<1<<fw[n];t++)yw[i++]=n;for(i>>=7;n<uw;n++)for(bw[n]=i<<7,t=0;t<1<<fw[n]-7;t++)yw[256+i++]=n;for(e=0;e<=lw;e++)o[e]=0;for(t=0;t<=143;)mw[2*t+1]=8,t++,o[8]++;for(;t<=255;)mw[2*t+1]=9,t++,o[9]++;for(;t<=279;)mw[2*t+1]=7,t++,o[7]++;for(;t<=287;)mw[2*t+1]=8,t++,o[8]++;for(Tw(mw,287,o),t=0;t<uw;t++)gw[2*t+1]=5,gw[2*t]=Cw(t,5);Ew=new _w(mw,cw,257,hw,lw),Aw=new _w(gw,fw,0,uw,lw),kw=new _w(new Array(0),dw,0,19,7)})(),jw=!0),t.l_desc=new Mw(t.dyn_ltree,Ew),t.d_desc=new Mw(t.dyn_dtree,Aw),t.bl_desc=new Mw(t.bl_tree,kw),t.bi_buf=0,t.bi_valid=0,Pw(t)},qw=(t,e,r,n)=>{let i,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<aw;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Dw(t,t.l_desc),Dw(t,t.d_desc),s=(t=>{let e;for(Fw(t,t.dyn_ltree,t.l_desc.max_code),Fw(t,t.dyn_dtree,t.d_desc.max_code),Dw(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*pw[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==e?Lw(t,e,r,n):4===t.strategy||o===i?(Nw(t,2+(n?1:0),3),Bw(t,mw,gw)):(Nw(t,4+(n?1:0),3),((t,e,r,n)=>{let i;for(Nw(t,e-257,5),Nw(t,r-1,5),Nw(t,n-4,4),i=0;i<n;i++)Nw(t,t.bl_tree[2*pw[i]+1],3);Uw(t,t.dyn_ltree,e-1),Uw(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),Bw(t,t.dyn_ltree,t.dyn_dtree)),Pw(t),n&&Rw(t)},Vw=(t,e,r)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(vw[r]+aw+1)]++,t.dyn_dtree[2*xw(e)]++),t.sym_next===t.sym_end),Hw=t=>{Nw(t,2,3),Iw(t,256,mw),(t=>{16===t.bi_valid?(Sw(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)},Gw={_tr_init:zw,_tr_stored_block:Lw,_tr_flush_block:qw,_tr_tally:Vw,_tr_align:Hw};var Kw=(t,e,r,n)=>{let i=65535&t|0,o=t>>>16&65535|0,s=0;for(;0!==r;){s=r>2e3?2e3:r,r-=s;do{i=i+e[n++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const Zw=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var Jw=(t,e,r,n)=>{const i=Zw,o=n+r;t^=-1;for(let r=n;r<o;r++)t=t>>>8^i[255&(t^e[r])];return-1^t},Qw={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Yw={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ww,_tr_stored_block:Xw,_tr_flush_block:tb,_tr_tally:eb,_tr_align:rb}=Gw,{Z_NO_FLUSH:nb,Z_PARTIAL_FLUSH:ib,Z_FULL_FLUSH:ob,Z_FINISH:sb,Z_BLOCK:ab,Z_OK:hb,Z_STREAM_END:ub,Z_STREAM_ERROR:lb,Z_DATA_ERROR:cb,Z_BUF_ERROR:fb,Z_DEFAULT_COMPRESSION:db,Z_FILTERED:pb,Z_HUFFMAN_ONLY:mb,Z_RLE:gb,Z_FIXED:yb,Z_DEFAULT_STRATEGY:vb,Z_UNKNOWN:wb,Z_DEFLATED:bb}=Yw,_b=258,Eb=262,Ab=42,kb=113,Mb=666,xb=(t,e)=>(t.msg=Qw[e],e),Sb=t=>2*t-(t>4?9:0),Nb=t=>{let e=t.length;for(;--e>=0;)t[e]=0},Ib=t=>{let e,r,n,i=t.w_size;e=t.hash_size,n=e;do{r=t.head[--n],t.head[n]=r>=i?r-i:0}while(--e);e=i,n=e;do{r=t.prev[--n],t.prev[n]=r>=i?r-i:0}while(--e)};let Cb=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const Tb=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},Pb=(t,e)=>{tb(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Tb(t.strm)},Rb=(t,e)=>{t.pending_buf[t.pending++]=e},Ob=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},$b=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=Kw(t.adler,e,i,r):2===t.state.wrap&&(t.adler=Jw(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},Bb=(t,e)=>{let r,n,i=t.max_chain_length,o=t.strstart,s=t.prev_length,a=t.nice_match;const h=t.strstart>t.w_size-Eb?t.strstart-(t.w_size-Eb):0,u=t.window,l=t.w_mask,c=t.prev,f=t.strstart+_b;let d=u[o+s-1],p=u[o+s];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(r=e,u[r+s]===p&&u[r+s-1]===d&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<f);if(n=_b-(f-o),o=f-_b,n>s){if(t.match_start=e,s=n,n>=a)break;d=u[o+s-1],p=u[o+s]}}}while((e=c[e&l])>h&&0!=--i);return s<=t.lookahead?s:t.lookahead},Db=t=>{const e=t.w_size;let r,n,i;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-Eb)&&(t.window.set(t.window.subarray(e,e+e-n),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),Ib(t),n+=e),0===t.strm.avail_in)break;if(r=$b(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=r,t.lookahead+t.insert>=3)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=Cb(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=Cb(t,t.ins_h,t.window[i+3-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<Eb&&0!==t.strm.avail_in)},Fb=(t,e)=>{let r,n,i,o=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,s=0,a=t.strm.avail_in;do{if(r=65535,i=t.bi_valid+42>>3,t.strm.avail_out<i)break;if(i=t.strm.avail_out-i,n=t.strstart-t.block_start,r>n+t.strm.avail_in&&(r=n+t.strm.avail_in),r>i&&(r=i),r<o&&(0===r&&e!==sb||e===nb||r!==n+t.strm.avail_in))break;s=e===sb&&r===n+t.strm.avail_in?1:0,Xw(t,0,0,s),t.pending_buf[t.pending-4]=r,t.pending_buf[t.pending-3]=r>>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,Tb(t.strm),n&&(n>r&&(n=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,r-=n),r&&($b(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===s);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),s?4:e!==nb&&e!==sb&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(i=t.window_size-t.strstart,t.strm.avail_in>i&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,i+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),i>t.strm.avail_in&&(i=t.strm.avail_in),i&&($b(t.strm,t.window,t.strstart,i),t.strstart+=i,t.insert+=i>t.w_size-t.insert?t.w_size-t.insert:i),t.high_water<t.strstart&&(t.high_water=t.strstart),i=t.bi_valid+42>>3,i=t.pending_buf_size-i>65535?65535:t.pending_buf_size-i,o=i>t.w_size?t.w_size:i,n=t.strstart-t.block_start,(n>=o||(n||e===sb)&&e!==nb&&0===t.strm.avail_in&&n<=i)&&(r=n>i?i:n,s=e===sb&&0===t.strm.avail_in&&r===n?1:0,Xw(t,t.block_start,r,s),t.block_start+=r,Tb(t.strm)),s?3:1)},Ub=(t,e)=>{let r,n;for(;;){if(t.lookahead<Eb){if(Db(t),t.lookahead<Eb&&e===nb)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=Cb(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-Eb&&(t.match_length=Bb(t,r)),t.match_length>=3)if(n=eb(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=Cb(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=Cb(t,t.ins_h,t.window[t.strstart+1]);else n=eb(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Pb(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===sb?(Pb(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Pb(t,!1),0===t.strm.avail_out)?1:2},jb=(t,e)=>{let r,n,i;for(;;){if(t.lookahead<Eb){if(Db(t),t.lookahead<Eb&&e===nb)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=Cb(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-Eb&&(t.match_length=Bb(t,r),t.match_length<=5&&(t.strategy===pb||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=eb(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=Cb(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(Pb(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=eb(t,0,t.window[t.strstart-1]),n&&Pb(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=eb(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===sb?(Pb(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Pb(t,!1),0===t.strm.avail_out)?1:2};function Lb(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}const zb=[new Lb(0,0,0,0,Fb),new Lb(4,4,8,4,Ub),new Lb(4,5,16,8,Ub),new Lb(4,6,32,32,Ub),new Lb(4,4,16,16,jb),new Lb(8,16,32,32,jb),new Lb(8,16,128,128,jb),new Lb(8,32,128,256,jb),new Lb(32,128,258,1024,jb),new Lb(32,258,258,4096,jb)];function qb(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=bb,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Nb(this.dyn_ltree),Nb(this.dyn_dtree),Nb(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Nb(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Nb(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Vb=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==Ab&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==kb&&e.status!==Mb?1:0},Hb=t=>{if(Vb(t))return xb(t,lb);t.total_in=t.total_out=0,t.data_type=wb;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?Ab:kb,t.adler=2===e.wrap?0:1,e.last_flush=-2,Ww(e),hb},Gb=t=>{const e=Hb(t);return e===hb&&(t=>{t.window_size=2*t.w_size,Nb(t.head),t.max_lazy_match=zb[t.level].max_lazy,t.good_match=zb[t.level].good_length,t.nice_match=zb[t.level].nice_length,t.max_chain_length=zb[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0})(t.state),e},Kb=(t,e,r,n,i,o)=>{if(!t)return lb;let s=1;if(e===db&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>9||r!==bb||n<8||n>15||e<0||e>9||o<0||o>yb||8===n&&1!==s)return xb(t,lb);8===n&&(n=9);const a=new qb;return t.state=a,a.strm=t,a.status=Ab,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=o,a.method=r,Gb(t)};var Zb=(t,e)=>{if(Vb(t)||e>ab||e<0)return t?xb(t,lb):lb;const r=t.state;if(!t.output||0!==t.avail_in&&!t.input||r.status===Mb&&e!==sb)return xb(t,0===t.avail_out?fb:lb);const n=r.last_flush;if(r.last_flush=e,0!==r.pending){if(Tb(t),0===t.avail_out)return r.last_flush=-1,hb}else if(0===t.avail_in&&Sb(e)<=Sb(n)&&e!==sb)return xb(t,fb);if(r.status===Mb&&0!==t.avail_in)return xb(t,fb);if(r.status===Ab&&0===r.wrap&&(r.status=kb),r.status===Ab){let e=bb+(r.w_bits-8<<4)<<8,n=-1;if(n=r.strategy>=mb||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=n<<6,0!==r.strstart&&(e|=32),e+=31-e%31,Ob(r,e),0!==r.strstart&&(Ob(r,t.adler>>>16),Ob(r,65535&t.adler)),t.adler=1,r.status=kb,Tb(t),0!==r.pending)return r.last_flush=-1,hb}if(57===r.status)if(t.adler=0,Rb(r,31),Rb(r,139),Rb(r,8),r.gzhead)Rb(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Rb(r,255&r.gzhead.time),Rb(r,r.gzhead.time>>8&255),Rb(r,r.gzhead.time>>16&255),Rb(r,r.gzhead.time>>24&255),Rb(r,9===r.level?2:r.strategy>=mb||r.level<2?4:0),Rb(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Rb(r,255&r.gzhead.extra.length),Rb(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=Jw(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(Rb(r,0),Rb(r,0),Rb(r,0),Rb(r,0),Rb(r,0),Rb(r,9===r.level?2:r.strategy>=mb||r.level<2?4:0),Rb(r,3),r.status=kb,Tb(t),0!==r.pending)return r.last_flush=-1,hb;if(69===r.status){if(r.gzhead.extra){let e=r.pending,n=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+n>r.pending_buf_size;){let i=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>e&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex+=i,Tb(t),0!==r.pending)return r.last_flush=-1,hb;e=0,n-=i}let i=new Uint8Array(r.gzhead.extra);r.pending_buf.set(i.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending+=n,r.gzhead.hcrc&&r.pending>e&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let e,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-n,n)),Tb(t),0!==r.pending)return r.last_flush=-1,hb;n=0}e=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,Rb(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>n&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let e,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-n,n)),Tb(t),0!==r.pending)return r.last_flush=-1,hb;n=0}e=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,Rb(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>n&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-n,n))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(Tb(t),0!==r.pending))return r.last_flush=-1,hb;Rb(r,255&t.adler),Rb(r,t.adler>>8&255),t.adler=0}if(r.status=kb,Tb(t),0!==r.pending)return r.last_flush=-1,hb}if(0!==t.avail_in||0!==r.lookahead||e!==nb&&r.status!==Mb){let n=0===r.level?Fb(r,e):r.strategy===mb?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(Db(t),0===t.lookahead)){if(e===nb)return 1;break}if(t.match_length=0,r=eb(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(Pb(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===sb?(Pb(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Pb(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===gb?((t,e)=>{let r,n,i,o;const s=t.window;for(;;){if(t.lookahead<=_b){if(Db(t),t.lookahead<=_b&&e===nb)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){o=t.strstart+_b;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<o);t.match_length=_b-(o-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=eb(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=eb(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(Pb(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===sb?(Pb(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Pb(t,!1),0===t.strm.avail_out)?1:2})(r,e):zb[r.level].func(r,e);if(3!==n&&4!==n||(r.status=Mb),1===n||3===n)return 0===t.avail_out&&(r.last_flush=-1),hb;if(2===n&&(e===ib?rb(r):e!==ab&&(Xw(r,0,0,!1),e===ob&&(Nb(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),Tb(t),0===t.avail_out))return r.last_flush=-1,hb}return e!==sb?hb:r.wrap<=0?ub:(2===r.wrap?(Rb(r,255&t.adler),Rb(r,t.adler>>8&255),Rb(r,t.adler>>16&255),Rb(r,t.adler>>24&255),Rb(r,255&t.total_in),Rb(r,t.total_in>>8&255),Rb(r,t.total_in>>16&255),Rb(r,t.total_in>>24&255)):(Ob(r,t.adler>>>16),Ob(r,65535&t.adler)),Tb(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?hb:ub)},Jb=(t,e)=>{let r=e.length;if(Vb(t))return lb;const n=t.state,i=n.wrap;if(2===i||1===i&&n.status!==Ab||n.lookahead)return lb;if(1===i&&(t.adler=Kw(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(Nb(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const o=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,Db(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=Cb(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,Db(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=s,t.input=a,t.avail_in=o,n.wrap=i,hb},Qb={deflateInit:(t,e)=>Kb(t,e,bb,15,8,vb),deflateInit2:Kb,deflateReset:Gb,deflateResetKeep:Hb,deflateSetHeader:(t,e)=>Vb(t)||2!==t.state.wrap?lb:(t.state.gzhead=e,hb),deflate:Zb,deflateEnd:t=>{if(Vb(t))return lb;const e=t.state.status;return t.state=null,e===kb?xb(t,cb):hb},deflateSetDictionary:Jb,deflateInfo:"pako deflate (from Nodeca project)"};const Yb=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Wb=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)Yb(r,e)&&(t[e]=r[e])}}return t},Xb=t=>{let e=0;for(let r=0,n=t.length;r<n;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,n=0,i=t.length;e<i;e++){let i=t[e];r.set(i,n),n+=i.length}return r};let t_=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){t_=!1}const e_=new Uint8Array(256);for(let t=0;t<256;t++)e_[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;e_[254]=e_[254]=1;var r_=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,i,o,s=t.length,a=0;for(i=0;i<s;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<s&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),o=0,i=0;o<a;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<s&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[o++]=r:r<2048?(e[o++]=192|r>>>6,e[o++]=128|63&r):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|63&r):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|63&r);return e},n_=(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,i;const o=new Array(2*r);for(i=0,n=0;n<r;){let e=t[n++];if(e<128){o[i++]=e;continue}let s=e_[e];if(s>4)o[i++]=65533,n+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&n<r;)e=e<<6|63&t[n++],s--;s>1?o[i++]=65533:e<65536?o[i++]=e:(e-=65536,o[i++]=55296|e>>10&1023,o[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&t_)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r})(o,i)},i_=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+e_[t[r]]>e?r:e};var o_=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const s_=Object.prototype.toString,{Z_NO_FLUSH:a_,Z_SYNC_FLUSH:h_,Z_FULL_FLUSH:u_,Z_FINISH:l_,Z_OK:c_,Z_STREAM_END:f_,Z_DEFAULT_COMPRESSION:d_,Z_DEFAULT_STRATEGY:p_,Z_DEFLATED:m_}=Yw;function g_(t){this.options=Wb({level:d_,method:m_,chunkSize:16384,windowBits:15,memLevel:8,strategy:p_},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o_,this.strm.avail_out=0;let r=Qb.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==c_)throw new Error(Qw[r]);if(e.header&&Qb.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?r_(e.dictionary):"[object ArrayBuffer]"===s_.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=Qb.deflateSetDictionary(this.strm,t),r!==c_)throw new Error(Qw[r]);this._dict_set=!0}}function y_(t,e){const r=new g_(e);if(r.push(t,!0),r.err)throw r.msg||Qw[r.err];return r.result}g_.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=e===~~e?e:!0===e?l_:a_,"string"==typeof t?r.input=r_(t):"[object ArrayBuffer]"===s_.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(o===h_||o===u_)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(i=Qb.deflate(r,o),i===f_)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Qb.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===c_;if(0!==r.avail_out){if(o>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},g_.prototype.onData=function(t){this.chunks.push(t)},g_.prototype.onEnd=function(t){t===c_&&(this.result=Xb(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var v_={Deflate:g_,deflate:y_,deflateRaw:function(t,e){return(e=e||{}).raw=!0,y_(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,y_(t,e)},constants:Yw};const w_=16209;var b_=function(t,e){let r,n,i,o,s,a,h,u,l,c,f,d,p,m,g,y,v,w,b,_,E,A,k,M;const x=t.state;r=t.next_in,k=t.input,n=r+(t.avail_in-5),i=t.next_out,M=t.output,o=i-(e-t.avail_out),s=i+(t.avail_out-257),a=x.dmax,h=x.wsize,u=x.whave,l=x.wnext,c=x.window,f=x.hold,d=x.bits,p=x.lencode,m=x.distcode,g=(1<<x.lenbits)-1,y=(1<<x.distbits)-1;t:do{d<15&&(f+=k[r++]<<d,d+=8,f+=k[r++]<<d,d+=8),v=p[f&g];e:for(;;){if(w=v>>>24,f>>>=w,d-=w,w=v>>>16&255,0===w)M[i++]=65535&v;else{if(!(16&w)){if(0==(64&w)){v=p[(65535&v)+(f&(1<<w)-1)];continue e}if(32&w){x.mode=16191;break t}t.msg="invalid literal/length code",x.mode=w_;break t}b=65535&v,w&=15,w&&(d<w&&(f+=k[r++]<<d,d+=8),b+=f&(1<<w)-1,f>>>=w,d-=w),d<15&&(f+=k[r++]<<d,d+=8,f+=k[r++]<<d,d+=8),v=m[f&y];r:for(;;){if(w=v>>>24,f>>>=w,d-=w,w=v>>>16&255,!(16&w)){if(0==(64&w)){v=m[(65535&v)+(f&(1<<w)-1)];continue r}t.msg="invalid distance code",x.mode=w_;break t}if(_=65535&v,w&=15,d<w&&(f+=k[r++]<<d,d+=8,d<w&&(f+=k[r++]<<d,d+=8)),_+=f&(1<<w)-1,_>a){t.msg="invalid distance too far back",x.mode=w_;break t}if(f>>>=w,d-=w,w=i-o,_>w){if(w=_-w,w>u&&x.sane){t.msg="invalid distance too far back",x.mode=w_;break t}if(E=0,A=c,0===l){if(E+=h-w,w<b){b-=w;do{M[i++]=c[E++]}while(--w);E=i-_,A=M}}else if(l<w){if(E+=h+l-w,w-=l,w<b){b-=w;do{M[i++]=c[E++]}while(--w);if(E=0,l<b){w=l,b-=w;do{M[i++]=c[E++]}while(--w);E=i-_,A=M}}}else if(E+=l-w,w<b){b-=w;do{M[i++]=c[E++]}while(--w);E=i-_,A=M}for(;b>2;)M[i++]=A[E++],M[i++]=A[E++],M[i++]=A[E++],b-=3;b&&(M[i++]=A[E++],b>1&&(M[i++]=A[E++]))}else{E=i-_;do{M[i++]=M[E++],M[i++]=M[E++],M[i++]=M[E++],b-=3}while(b>2);b&&(M[i++]=M[E++],b>1&&(M[i++]=M[E++]))}break}}break}}while(r<n&&i<s);b=d>>3,r-=b,d-=b<<3,f&=(1<<d)-1,t.next_in=r,t.next_out=i,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=i<s?s-i+257:257-(i-s),x.hold=f,x.bits=d};const __=15,E_=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),A_=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),k_=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),M_=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var x_=(t,e,r,n,i,o,s,a)=>{const h=a.bits;let u,l,c,f,d,p,m=0,g=0,y=0,v=0,w=0,b=0,_=0,E=0,A=0,k=0,M=null;const x=new Uint16Array(16),S=new Uint16Array(16);let N,I,C,T=null;for(m=0;m<=__;m++)x[m]=0;for(g=0;g<n;g++)x[e[r+g]]++;for(w=h,v=__;v>=1&&0===x[v];v--);if(w>v&&(w=v),0===v)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(y=1;y<v&&0===x[y];y++);for(w<y&&(w=y),E=1,m=1;m<=__;m++)if(E<<=1,E-=x[m],E<0)return-1;if(E>0&&(0===t||1!==v))return-1;for(S[1]=0,m=1;m<__;m++)S[m+1]=S[m]+x[m];for(g=0;g<n;g++)0!==e[r+g]&&(s[S[e[r+g]]++]=g);if(0===t?(M=T=s,p=20):1===t?(M=E_,T=A_,p=257):(M=k_,T=M_,p=0),k=0,g=0,m=y,d=o,b=w,_=0,c=-1,A=1<<w,f=A-1,1===t&&A>852||2===t&&A>592)return 1;for(;;){N=m-_,s[g]+1<p?(I=0,C=s[g]):s[g]>=p?(I=T[s[g]-p],C=M[s[g]-p]):(I=96,C=0),u=1<<m-_,l=1<<b,y=l;do{l-=u,i[d+(k>>_)+l]=N<<24|I<<16|C|0}while(0!==l);for(u=1<<m-1;k&u;)u>>=1;if(0!==u?(k&=u-1,k+=u):k=0,g++,0==--x[m]){if(m===v)break;m=e[r+s[g]]}if(m>w&&(k&f)!==c){for(0===_&&(_=w),d+=y,b=m-_,E=1<<b;b+_<v&&(E-=x[b+_],!(E<=0));)b++,E<<=1;if(A+=1<<b,1===t&&A>852||2===t&&A>592)return 1;c=k&f,i[c]=w<<24|b<<16|d-o|0}}return 0!==k&&(i[d+k]=m-_<<24|64<<16|0),a.bits=w,0};const{Z_FINISH:S_,Z_BLOCK:N_,Z_TREES:I_,Z_OK:C_,Z_STREAM_END:T_,Z_NEED_DICT:P_,Z_STREAM_ERROR:R_,Z_DATA_ERROR:O_,Z_MEM_ERROR:$_,Z_BUF_ERROR:B_,Z_DEFLATED:D_}=Yw,F_=16180,U_=16190,j_=16191,L_=16192,z_=16194,q_=16199,V_=16200,H_=16206,G_=16209,K_=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Z_(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const J_=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<F_||e.mode>16211?1:0},Q_=t=>{if(J_(t))return R_;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=F_,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,C_},Y_=t=>{if(J_(t))return R_;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Q_(t)},W_=(t,e)=>{let r;if(J_(t))return R_;const n=t.state;return e<0?(r=0,e=-e):(r=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?R_:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,Y_(t))},X_=(t,e)=>{if(!t)return R_;const r=new Z_;t.state=r,r.strm=t,r.window=null,r.mode=F_;const n=W_(t,e);return n!==C_&&(t.state=null),n};let tE,eE,rE=!0;const nE=t=>{if(rE){tE=new Int32Array(512),eE=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(x_(1,t.lens,0,288,tE,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;x_(2,t.lens,0,32,eE,0,t.work,{bits:5}),rE=!1}t.lencode=tE,t.lenbits=9,t.distcode=eE,t.distbits=5},iE=(t,e,r,n)=>{let i;const o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),n>=o.wsize?(o.window.set(e.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(e.subarray(r-n,r-n+i),o.wnext),(n-=i)?(o.window.set(e.subarray(r-n,r),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0};var oE=(t,e)=>{let r,n,i,o,s,a,h,u,l,c,f,d,p,m,g,y,v,w,b,_,E,A,k=0;const M=new Uint8Array(4);let x,S;const N=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(J_(t)||!t.output||!t.input&&0!==t.avail_in)return R_;r=t.state,r.mode===j_&&(r.mode=L_),s=t.next_out,i=t.output,h=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,u=r.hold,l=r.bits,c=a,f=h,A=C_;t:for(;;)switch(r.mode){case F_:if(0===r.wrap){r.mode=L_;break}for(;l<16;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(2&r.wrap&&35615===u){0===r.wbits&&(r.wbits=15),r.check=0,M[0]=255&u,M[1]=u>>>8&255,r.check=Jw(r.check,M,2,0),u=0,l=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",r.mode=G_;break}if((15&u)!==D_){t.msg="unknown compression method",r.mode=G_;break}if(u>>>=4,l-=4,E=8+(15&u),0===r.wbits&&(r.wbits=E),E>15||E>r.wbits){t.msg="invalid window size",r.mode=G_;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=512&u?16189:j_,u=0,l=0;break;case 16181:for(;l<16;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(r.flags=u,(255&r.flags)!==D_){t.msg="unknown compression method",r.mode=G_;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=G_;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&4&r.wrap&&(M[0]=255&u,M[1]=u>>>8&255,r.check=Jw(r.check,M,2,0)),u=0,l=0,r.mode=16182;case 16182:for(;l<32;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&4&r.wrap&&(M[0]=255&u,M[1]=u>>>8&255,M[2]=u>>>16&255,M[3]=u>>>24&255,r.check=Jw(r.check,M,4,0)),u=0,l=0,r.mode=16183;case 16183:for(;l<16;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&4&r.wrap&&(M[0]=255&u,M[1]=u>>>8&255,r.check=Jw(r.check,M,2,0)),u=0,l=0,r.mode=16184;case 16184:if(1024&r.flags){for(;l<16;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&4&r.wrap&&(M[0]=255&u,M[1]=u>>>8&255,r.check=Jw(r.check,M,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(d=r.length,d>a&&(d=a),d&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(o,o+d),E)),512&r.flags&&4&r.wrap&&(r.check=Jw(r.check,n,d,o)),a-=d,o+=d,r.length-=d),r.length))break t;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===a)break t;d=0;do{E=n[o+d++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&d<a);if(512&r.flags&&4&r.wrap&&(r.check=Jw(r.check,n,d,o)),a-=d,o+=d,E)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===a)break t;d=0;do{E=n[o+d++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&d<a);if(512&r.flags&&4&r.wrap&&(r.check=Jw(r.check,n,d,o)),a-=d,o+=d,E)break t}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;l<16;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(4&r.wrap&&u!==(65535&r.check)){t.msg="header crc mismatch",r.mode=G_;break}u=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=j_;break;case 16189:for(;l<32;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}t.adler=r.check=K_(u),u=0,l=0,r.mode=U_;case U_:if(0===r.havedict)return t.next_out=s,t.avail_out=h,t.next_in=o,t.avail_in=a,r.hold=u,r.bits=l,P_;t.adler=r.check=1,r.mode=j_;case j_:if(e===N_||e===I_)break t;case L_:if(r.last){u>>>=7&l,l-=7&l,r.mode=H_;break}for(;l<3;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}switch(r.last=1&u,u>>>=1,l-=1,3&u){case 0:r.mode=16193;break;case 1:if(nE(r),r.mode=q_,e===I_){u>>>=2,l-=2;break t}break;case 2:r.mode=16196;break;case 3:t.msg="invalid block type",r.mode=G_}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){t.msg="invalid stored block lengths",r.mode=G_;break}if(r.length=65535&u,u=0,l=0,r.mode=z_,e===I_)break t;case z_:r.mode=16195;case 16195:if(d=r.length,d){if(d>a&&(d=a),d>h&&(d=h),0===d)break t;i.set(n.subarray(o,o+d),s),a-=d,o+=d,h-=d,s+=d,r.length-=d;break}r.mode=j_;break;case 16196:for(;l<14;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=G_;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;l<3;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.lens[N[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[N[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,x={bits:r.lenbits},A=x_(0,r.lens,0,19,r.lencode,0,r.work,x),r.lenbits=x.bits,A){t.msg="invalid code lengths set",r.mode=G_;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;k=r.lencode[u&(1<<r.lenbits)-1],g=k>>>24,y=k>>>16&255,v=65535&k,!(g<=l);){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(v<16)u>>>=g,l-=g,r.lens[r.have++]=v;else{if(16===v){for(S=g+2;l<S;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(u>>>=g,l-=g,0===r.have){t.msg="invalid bit length repeat",r.mode=G_;break}E=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===v){for(S=g+3;l<S;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}u>>>=g,l-=g,E=0,d=3+(7&u),u>>>=3,l-=3}else{for(S=g+7;l<S;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}u>>>=g,l-=g,E=0,d=11+(127&u),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=G_;break}for(;d--;)r.lens[r.have++]=E}}if(r.mode===G_)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=G_;break}if(r.lenbits=9,x={bits:r.lenbits},A=x_(1,r.lens,0,r.nlen,r.lencode,0,r.work,x),r.lenbits=x.bits,A){t.msg="invalid literal/lengths set",r.mode=G_;break}if(r.distbits=6,r.distcode=r.distdyn,x={bits:r.distbits},A=x_(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,x),r.distbits=x.bits,A){t.msg="invalid distances set",r.mode=G_;break}if(r.mode=q_,e===I_)break t;case q_:r.mode=V_;case V_:if(a>=6&&h>=258){t.next_out=s,t.avail_out=h,t.next_in=o,t.avail_in=a,r.hold=u,r.bits=l,b_(t,f),s=t.next_out,i=t.output,h=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,u=r.hold,l=r.bits,r.mode===j_&&(r.back=-1);break}for(r.back=0;k=r.lencode[u&(1<<r.lenbits)-1],g=k>>>24,y=k>>>16&255,v=65535&k,!(g<=l);){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(y&&0==(240&y)){for(w=g,b=y,_=v;k=r.lencode[_+((u&(1<<w+b)-1)>>w)],g=k>>>24,y=k>>>16&255,v=65535&k,!(w+g<=l);){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}u>>>=w,l-=w,r.back+=w}if(u>>>=g,l-=g,r.back+=g,r.length=v,0===y){r.mode=16205;break}if(32&y){r.back=-1,r.mode=j_;break}if(64&y){t.msg="invalid literal/length code",r.mode=G_;break}r.extra=15&y,r.mode=16201;case 16201:if(r.extra){for(S=r.extra;l<S;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;k=r.distcode[u&(1<<r.distbits)-1],g=k>>>24,y=k>>>16&255,v=65535&k,!(g<=l);){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(0==(240&y)){for(w=g,b=y,_=v;k=r.distcode[_+((u&(1<<w+b)-1)>>w)],g=k>>>24,y=k>>>16&255,v=65535&k,!(w+g<=l);){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}u>>>=w,l-=w,r.back+=w}if(u>>>=g,l-=g,r.back+=g,64&y){t.msg="invalid distance code",r.mode=G_;break}r.offset=v,r.extra=15&y,r.mode=16203;case 16203:if(r.extra){for(S=r.extra;l<S;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=G_;break}r.mode=16204;case 16204:if(0===h)break t;if(d=f-h,r.offset>d){if(d=r.offset-d,d>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=G_;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=s-r.offset,d=r.length;d>h&&(d=h),h-=d,r.length-=d;do{i[s++]=m[p++]}while(--d);0===r.length&&(r.mode=V_);break;case 16205:if(0===h)break t;i[s++]=r.length,h--,r.mode=V_;break;case H_:if(r.wrap){for(;l<32;){if(0===a)break t;a--,u|=n[o++]<<l,l+=8}if(f-=h,t.total_out+=f,r.total+=f,4&r.wrap&&f&&(t.adler=r.check=r.flags?Jw(r.check,i,f,s-f):Kw(r.check,i,f,s-f)),f=h,4&r.wrap&&(r.flags?u:K_(u))!==r.check){t.msg="incorrect data check",r.mode=G_;break}u=0,l=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;l<32;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(4&r.wrap&&u!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=G_;break}u=0,l=0}r.mode=16208;case 16208:A=T_;break t;case G_:A=O_;break t;case 16210:return $_;default:return R_}return t.next_out=s,t.avail_out=h,t.next_in=o,t.avail_in=a,r.hold=u,r.bits=l,(r.wsize||f!==t.avail_out&&r.mode<G_&&(r.mode<H_||e!==S_))&&iE(t,t.output,t.next_out,f-t.avail_out),c-=t.avail_in,f-=t.avail_out,t.total_in+=c,t.total_out+=f,r.total+=f,4&r.wrap&&f&&(t.adler=r.check=r.flags?Jw(r.check,i,f,t.next_out-f):Kw(r.check,i,f,t.next_out-f)),t.data_type=r.bits+(r.last?64:0)+(r.mode===j_?128:0)+(r.mode===q_||r.mode===z_?256:0),(0===c&&0===f||e===S_)&&A===C_&&(A=B_),A},sE={inflateReset:Y_,inflateReset2:W_,inflateResetKeep:Q_,inflateInit:t=>X_(t,15),inflateInit2:X_,inflate:oE,inflateEnd:t=>{if(J_(t))return R_;let e=t.state;return e.window&&(e.window=null),t.state=null,C_},inflateGetHeader:(t,e)=>{if(J_(t))return R_;const r=t.state;return 0==(2&r.wrap)?R_:(r.head=e,e.done=!1,C_)},inflateSetDictionary:(t,e)=>{const r=e.length;let n,i,o;return J_(t)?R_:(n=t.state,0!==n.wrap&&n.mode!==U_?R_:n.mode===U_&&(i=1,i=Kw(i,e,r,0),i!==n.check)?O_:(o=iE(t,e,r,r),o?(n.mode=16210,$_):(n.havedict=1,C_)))},inflateInfo:"pako inflate (from Nodeca project)"};var aE=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const hE=Object.prototype.toString,{Z_NO_FLUSH:uE,Z_FINISH:lE,Z_OK:cE,Z_STREAM_END:fE,Z_NEED_DICT:dE,Z_STREAM_ERROR:pE,Z_DATA_ERROR:mE,Z_MEM_ERROR:gE}=Yw;function yE(t){this.options=Wb({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o_,this.strm.avail_out=0;let r=sE.inflateInit2(this.strm,e.windowBits);if(r!==cE)throw new Error(Qw[r]);if(this.header=new aE,sE.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=r_(e.dictionary):"[object ArrayBuffer]"===hE.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=sE.inflateSetDictionary(this.strm,e.dictionary),r!==cE)))throw new Error(Qw[r])}function vE(t,e){const r=new yE(e);if(r.push(t),r.err)throw r.msg||Qw[r.err];return r.result}yE.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=e===~~e?e:!0===e?lE:uE,"[object ArrayBuffer]"===hE.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),o=sE.inflate(r,s),o===dE&&i&&(o=sE.inflateSetDictionary(r,i),o===cE?o=sE.inflate(r,s):o===mE&&(o=dE));r.avail_in>0&&o===fE&&r.state.wrap>0&&0!==t[r.next_in];)sE.inflateReset(r),o=sE.inflate(r,s);switch(o){case pE:case mE:case dE:case gE:return this.onEnd(o),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||o===fE))if("string"===this.options.to){let t=i_(r.output,r.next_out),e=r.next_out-t,i=n_(r.output,t);r.next_out=e,r.avail_out=n-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(o!==cE||0!==a){if(o===fE)return o=sE.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},yE.prototype.onData=function(t){this.chunks.push(t)},yE.prototype.onEnd=function(t){t===cE&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Xb(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var wE={Inflate:yE,inflate:vE,inflateRaw:function(t,e){return(e=e||{}).raw=!0,vE(t,e)},ungzip:vE,constants:Yw};const{Deflate:bE,deflate:_E,deflateRaw:EE,gzip:AE}=v_,{Inflate:kE,inflate:ME,inflateRaw:xE,ungzip:SE}=wE;var NE=AE,IE=SE,CE="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==B&&B||{},TE="URLSearchParams"in CE,PE="Symbol"in CE&&"iterator"in Symbol,RE="FileReader"in CE&&"Blob"in CE&&function(){try{return new Blob,!0}catch(t){return!1}}(),OE="FormData"in CE,$E="ArrayBuffer"in CE;if($E)var BE=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],DE=ArrayBuffer.isView||function(t){return t&&BE.indexOf(Object.prototype.toString.call(t))>-1};function FE(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function UE(t){return"string"!=typeof t&&(t=String(t)),t}function jE(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return PE&&(e[Symbol.iterator]=function(){return e}),e}function LE(t){this.map={},t instanceof LE?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function zE(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function qE(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function VE(t){var e=new FileReader,r=qE(e);return e.readAsArrayBuffer(t),r}function HE(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function GE(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:RE&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:OE&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:TE&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():$E&&RE&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=HE(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):$E&&(ArrayBuffer.prototype.isPrototypeOf(t)||DE(t))?this._bodyArrayBuffer=HE(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):TE&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},RE&&(this.blob=function(){var t=zE(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=zE(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(RE)return this.blob().then(VE);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,n,i,o=zE(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=qE(e),n=/charset=([A-Za-z0-9_-]+)/.exec(t.type),i=n?n[1]:"utf-8",e.readAsText(t,i),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},OE&&(this.formData=function(){return this.text().then(JE)}),this.json=function(){return this.text().then(JSON.parse)},this}LE.prototype.append=function(t,e){t=FE(t),e=UE(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},LE.prototype.delete=function(t){delete this.map[FE(t)]},LE.prototype.get=function(t){return t=FE(t),this.has(t)?this.map[t]:null},LE.prototype.has=function(t){return this.map.hasOwnProperty(FE(t))},LE.prototype.set=function(t,e){this.map[FE(t)]=UE(e)},LE.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},LE.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),jE(t)},LE.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),jE(t)},LE.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),jE(t)},PE&&(LE.prototype[Symbol.iterator]=LE.prototype.entries);var KE=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function ZE(t,e){if(!(this instanceof ZE))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,n,i=(e=e||{}).body;if(t instanceof ZE){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new LE(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new LE(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),KE.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in CE)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function JE(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function QE(t,e){if(!(this instanceof QE))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new LE(e.headers),this.url=e.url||"",this._initBody(t)}ZE.prototype.clone=function(){return new ZE(this,{body:this._bodyInit})},GE.call(ZE.prototype),GE.call(QE.prototype),QE.prototype.clone=function(){return new QE(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new LE(this.headers),url:this.url})},QE.error=function(){var t=new QE(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var YE=[301,302,303,307,308];QE.redirect=function(t,e){if(-1===YE.indexOf(e))throw new RangeError("Invalid status code");return new QE(null,{status:e,headers:{location:t}})};var WE=CE.DOMException;try{new WE}catch(xb){WE=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},WE.prototype=Object.create(Error.prototype),WE.prototype.constructor=WE}function XE(t,e){return new Promise((function(r,n){var i=new ZE(t,e);if(i.signal&&i.signal.aborted)return n(new WE("Aborted","AbortError"));var o=new XMLHttpRequest;function s(){o.abort()}if(o.onload=function(){var t,e,n={statusText:o.statusText,headers:(t=o.getAllResponseHeaders()||"",e=new LE,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();try{e.append(n,i)}catch(t){console.warn("Response "+t.message)}}})),e)};0===i.url.indexOf("file://")&&(o.status<200||o.status>599)?n.status=200:n.status=o.status,n.url="responseURL"in o?o.responseURL:n.headers.get("X-Request-URL");var s="response"in o?o.response:o.responseText;setTimeout((function(){r(new QE(s,n))}),0)},o.onerror=function(){setTimeout((function(){n(new TypeError("Network request failed"))}),0)},o.ontimeout=function(){setTimeout((function(){n(new TypeError("Network request timed out"))}),0)},o.onabort=function(){setTimeout((function(){n(new WE("Aborted","AbortError"))}),0)},o.open(i.method,function(t){try{return""===t&&CE.location.href?CE.location.href:t}catch(e){return t}}(i.url),!0),"include"===i.credentials?o.withCredentials=!0:"omit"===i.credentials&&(o.withCredentials=!1),"responseType"in o&&(RE?o.responseType="blob":$E&&(o.responseType="arraybuffer")),e&&"object"==typeof e.headers&&!(e.headers instanceof LE||CE.Headers&&e.headers instanceof CE.Headers)){var a=[];Object.getOwnPropertyNames(e.headers).forEach((function(t){a.push(FE(t)),o.setRequestHeader(t,UE(e.headers[t]))})),i.headers.forEach((function(t,e){-1===a.indexOf(e)&&o.setRequestHeader(e,t)}))}else i.headers.forEach((function(t,e){o.setRequestHeader(e,t)}));i.signal&&(i.signal.addEventListener("abort",s),o.onreadystatechange=function(){4===o.readyState&&i.signal.removeEventListener("abort",s)}),o.send(void 0===i._bodyInit?null:i._bodyInit)}))}XE.polyfill=!0,CE.fetch||(CE.fetch=XE,CE.Headers=LE,CE.Request=ZE,CE.Response=QE);var tA=self.fetch.bind(self),eA=o((function(t){var e,n;e=r,n=function(){function t(t){var e=[];if(0===t.length)return"";if("string"!=typeof t[0])throw new TypeError("Url must be a string. Received "+t[0]);if(t[0].match(/^[^/:]+:\/*$/)&&t.length>1){var r=t.shift();t[0]=r+t[0]}t[0].match(/^file:\/\/\//)?t[0]=t[0].replace(/^([^/:]+):\/*/,"$1:///"):t[0]=t[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<t.length;n++){var i=t[n];if("string"!=typeof i)throw new TypeError("Url must be a string. Received "+i);""!==i&&(n>0&&(i=i.replace(/^[\/]+/,"")),i=n<t.length-1?i.replace(/[\/]+$/,""):i.replace(/[\/]+$/,"/"),e.push(i))}var o=e.join("/"),s=(o=o.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return o=s.shift()+(s.length>0?"?":"")+s.join("&")}return function(){return t("object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments))}},t.exports?t.exports=n():e.urljoin=n()})),rA=Object.defineProperty,nA=(t,e)=>{for(var r in e)rA(t,r,{get:e[r],enumerable:!0})};nA({},{API_VERSION:()=>NA,BN_FEE_TRANSACTION_VERSION_1:()=>AA,BN_FEE_TRANSACTION_VERSION_2:()=>kA,BN_TRANSACTION_VERSION_1:()=>_A,BN_TRANSACTION_VERSION_2:()=>EA,BaseUrl:()=>IA,HEX_STR_TRANSACTION_VERSION_1:()=>wA,HEX_STR_TRANSACTION_VERSION_2:()=>bA,IS_BROWSER:()=>iA,MASK_250:()=>xA,MASK_251:()=>SA,NetworkName:()=>CA,RPC_GOERLI_NODES:()=>OA,RPC_MAINNET_NODES:()=>$A,StarknetChainId:()=>TA,TEXT_TO_FELT_MAX_LEN:()=>vA,TransactionHashPrefix:()=>PA,UDC:()=>RA,ZERO:()=>MA});nA({},{IS_BROWSER:()=>iA,addHexPrefix:()=>fA,arrayBufferToString:()=>oA,atobUniversal:()=>hA,btoaUniversal:()=>uA,buf2hex:()=>lA,calcByteLength:()=>pA,padLeft:()=>dA,pascalToSnake:()=>yA,removeHexPrefix:()=>cA,sanitizeBytes:()=>mA,sanitizeHex:()=>gA,stringToArrayBuffer:()=>aA,utf8ToArray:()=>sA});var iA="undefined"!=typeof window;function oA(t){return new Uint8Array(t).reduce(((t,e)=>t+String.fromCharCode(e)),"")}function sA(t){return(new TextEncoder).encode(t)}function aA(t){return sA(t)}function hA(t){return Em.decode(t)}function uA(t){return Em.encode(new Uint8Array(t))}function lA(t){return t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"")}function cA(t){return t.replace(/^0x/i,"")}function fA(t){return`0x${cA(t)}`}function dA(t,e,r="0"){return function(t,e,r,n="0"){const i=e-t.length;let o=t;if(i>0){const e=n.repeat(i);o=r?e+t:t+e}return o}(t,e,!0,r)}function pA(t,e=8){const{length:r}=t,n=r%e;return n?(r-n)/e*e+e:r}function mA(t,e=8,r="0"){return dA(t,pA(t,e),r)}function gA(t){return(t=mA(t=cA(t),2))&&(t=fA(t)),t}var yA=t=>/[a-z]/.test(t)?t.split(/(?=[A-Z])/).join("_").toUpperCase():t,vA=31,wA="0x1",bA="0x2",_A=1n,EA=2n,AA=2n**128n+_A,kA=2n**128n+EA,MA=0n,xA=2n**250n-1n,SA=2n**251n,NA=MA,IA=(t=>(t.SN_MAIN="https://alpha-mainnet.starknet.io",t.SN_GOERLI="https://alpha4.starknet.io",t))(IA||{}),CA=(t=>(t.SN_MAIN="SN_MAIN",t.SN_GOERLI="SN_GOERLI",t))(CA||{}),TA=(t=>(t.SN_MAIN="0x534e5f4d41494e",t.SN_GOERLI="0x534e5f474f45524c49",t))(TA||{}),PA=(t=>(t.DECLARE="0x6465636c617265",t.DEPLOY="0x6465706c6f79",t.DEPLOY_ACCOUNT="0x6465706c6f795f6163636f756e74",t.INVOKE="0x696e766f6b65",t.L1_HANDLER="0x6c315f68616e646c6572",t))(PA||{}),RA={ADDRESS:"0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",ENTRYPOINT:"deployContract"},OA=["https://starknet-testnet.public.blastapi.io/rpc/v0.5","https://limited-rpc.nethermind.io/goerli-juno/v0_5"],$A=["https://starknet-mainnet.public.blastapi.io/rpc/v0.5","https://limited-rpc.nethermind.io/mainnet-juno/v0_5"];nA({},{BlockStatus:()=>HA,BlockTag:()=>GA,EntryPointType:()=>jA,Litteral:()=>UA,RPC:()=>KA,SIMULATION_FLAG:()=>BA,Sequencer:()=>ik,TransactionExecutionStatus:()=>VA,TransactionFinalityStatus:()=>qA,TransactionStatus:()=>zA,TransactionType:()=>LA,Uint:()=>FA,ValidateType:()=>DA});var BA=(t=>(t.SKIP_VALIDATE="SKIP_VALIDATE",t.SKIP_EXECUTE="SKIP_EXECUTE",t))(BA||{}),DA=(t=>(t.DEPLOY="DEPLOY",t.CALL="CALL",t.INVOKE="INVOKE",t))(DA||{}),FA=(t=>(t.u8="core::integer::u8",t.u16="core::integer::u16",t.u32="core::integer::u32",t.u64="core::integer::u64",t.u128="core::integer::u128",t.u256="core::integer::u256",t))(FA||{}),UA=(t=>(t.ClassHash="core::starknet::class_hash::ClassHash",t.ContractAddress="core::starknet::contract_address::ContractAddress",t))(UA||{}),jA=(t=>(t.EXTERNAL="EXTERNAL",t.L1_HANDLER="L1_HANDLER",t.CONSTRUCTOR="CONSTRUCTOR",t))(jA||{}),LA=(t=>(t.DECLARE="DECLARE",t.DEPLOY="DEPLOY",t.DEPLOY_ACCOUNT="DEPLOY_ACCOUNT",t.INVOKE="INVOKE_FUNCTION",t))(LA||{}),zA=(t=>(t.NOT_RECEIVED="NOT_RECEIVED",t.RECEIVED="RECEIVED",t.ACCEPTED_ON_L2="ACCEPTED_ON_L2",t.ACCEPTED_ON_L1="ACCEPTED_ON_L1",t.REJECTED="REJECTED",t.REVERTED="REVERTED",t))(zA||{}),qA=(t=>(t.NOT_RECEIVED="NOT_RECEIVED",t.RECEIVED="RECEIVED",t.ACCEPTED_ON_L2="ACCEPTED_ON_L2",t.ACCEPTED_ON_L1="ACCEPTED_ON_L1",t))(qA||{}),VA=(t=>(t.REJECTED="REJECTED",t.REVERTED="REVERTED",t.SUCCEEDED="SUCCEEDED",t))(VA||{}),HA=(t=>(t.PENDING="PENDING",t.ACCEPTED_ON_L1="ACCEPTED_ON_L1",t.ACCEPTED_ON_L2="ACCEPTED_ON_L2",t.REJECTED="REJECTED",t))(HA||{}),GA=(t=>(t.pending="pending",t.latest="latest",t))(GA||{}),KA={};nA(KA,{EBlockTag:()=>rk,EDataAvailabilityMode:()=>nk,ESimulationFlag:()=>WA,ETransactionExecutionStatus:()=>ek,ETransactionFinalityStatus:()=>tk,ETransactionStatus:()=>XA,ETransactionType:()=>YA,Errors:()=>JA,JRPC:()=>ZA,SPEC:()=>QA});var ZA={},JA={},QA={},YA=(t=>(t.DECLARE="DECLARE",t.DEPLOY="DEPLOY",t.DEPLOY_ACCOUNT="DEPLOY_ACCOUNT",t.INVOKE="INVOKE",t.L1_HANDLER="L1_HANDLER",t))(YA||{}),WA=(t=>(t.SKIP_VALIDATE="SKIP_VALIDATE",t.SKIP_FEE_CHARGE="SKIP_FEE_CHARGE",t))(WA||{}),XA=(t=>(t.RECEIVED="RECEIVED",t.REJECTED="REJECTED",t.ACCEPTED_ON_L2="ACCEPTED_ON_L2",t.ACCEPTED_ON_L1="ACCEPTED_ON_L1",t))(XA||{}),tk=(t=>(t.ACCEPTED_ON_L2="ACCEPTED_ON_L2",t.ACCEPTED_ON_L1="ACCEPTED_ON_L1",t))(tk||{}),ek=(t=>(t.SUCCEEDED="SUCCEEDED",t.REVERTED="REVERTED",t))(ek||{}),rk=(t=>(t.LATEST="latest",t.PENDING="pending",t))(rk||{}),nk=(t=>(t.L1="L1",t.L2="L2",t))(nk||{}),ik={};function ok(t,e){if(!t)throw new Error(e||"Assertion failure")}function sk(t){return/^0x[0-9a-f]*$/i.test(t)}function ak(t){return BigInt(t)}function hk(t){return"bigint"==typeof t}function uk(t){return fA(ak(t).toString(16))}nA({},{assertInRange:()=>pk,bigNumberishArrayToDecimalStringArray:()=>mk,bigNumberishArrayToHexadecimalStringArray:()=>gk,cleanHex:()=>dk,getDecimalString:()=>vk,getHexString:()=>wk,getHexStringArray:()=>bk,hexToBytes:()=>Ek,hexToDecimalString:()=>fk,isBigInt:()=>hk,isHex:()=>sk,isStringWholeNumber:()=>yk,toBigInt:()=>ak,toCairoBool:()=>_k,toHex:()=>uk,toHexString:()=>lk,toStorageKey:()=>ck});var lk=uk;function ck(t){return fA(ak(t).toString(16).padStart(64,"0"))}function fk(t){return BigInt(fA(t)).toString(10)}var dk=t=>t.toLowerCase().replace(/^(0x)0+/,"$1");function pk(t,e,r,n=""){const i=""===n?"invalid length":`invalid ${n} length`,o=BigInt(t),s=BigInt(e),a=BigInt(r);ok(o>=s&&o<=a,`Message not signable, ${i}.`)}function mk(t){return t.map((t=>ak(t).toString(10)))}function gk(t){return t.map((t=>uk(t)))}var yk=t=>/^\d+$/.test(t);function vk(t){if(sk(t))return fk(t);if(yk(t))return t;throw new Error(`${t} need to be hex-string or whole-number-string`)}function wk(t){if(sk(t))return t;if(yk(t))return lk(t);throw new Error(`${t} need to be hex-string or whole-number-string`)}function bk(t){return t.map((t=>wk(t)))}var _k=t=>(+t).toString();function Ek(t){if(!sk(t))throw new Error(`${t} need to be a hex-string`);let e=cA(t);return e.length%2!=0&&(e=`0${e}`),Tm(e)}function Ak(t){const e=cA(uk(BigInt(t))),r=e.length%2==0?e:`0${e}`;return fA(Gy(Ek(fA(r))).toString(16))}function kk(t){const e=BigInt(function(t){return fA(Gy(sA(t)).toString(16))}(t));return e&xA}function Mk(t){return uk(kk(t))}function xk(t){return sk(t)?t:yk(t)?lk(t):Mk(t)}nA({},{getSelector:()=>xk,getSelectorFromName:()=>Mk,keccakBn:()=>Ak,starknetKeccak:()=>kk});function Sk(t){return/^[\x00-\x7F]*$/.test(t)}function Nk(t){return t.length<=vA}function Ik(t){return/^[0-9]*$/i.test(t)}function Ck(t){return"string"==typeof t&&!sk(t)&&!yk(t)}nA({},{decodeShortString:()=>$k,encodeShortString:()=>Ok,isASCII:()=>Sk,isDecimalString:()=>Ik,isLongText:()=>Pk,isShortString:()=>Nk,isShortText:()=>Tk,isText:()=>Ck,splitLongString:()=>Rk});var Tk=t=>Ck(t)&&Nk(t),Pk=t=>Ck(t)&&!Nk(t);function Rk(t){const e=RegExp(`[^]{1,${vA}}`,"g");return t.match(e)||[]}function Ok(t){if(!Sk(t))throw new Error(`${t} is not an ASCII string`);if(!Nk(t))throw new Error(`${t} is too long`);return fA(t.replace(/./g,(t=>t.charCodeAt(0).toString(16))))}function $k(t){if(!Sk(t))throw new Error(`${t} is not an ASCII string`);if(sk(t))return cA(t).replace(/.{2}/g,(t=>String.fromCharCode(parseInt(t,16))));if(Ik(t))return $k("0X".concat(BigInt(t).toString(16)));throw new Error(`${t} is not Hex or decimal`)}var Bk={};nA(Bk,{felt:()=>uM,getAbiContractVersion:()=>sM,getArrayType:()=>iM,isCairo1Abi:()=>oM,isCairo1Type:()=>nM,isLen:()=>zk,isTypeArray:()=>Vk,isTypeBool:()=>tM,isTypeContractAddress:()=>eM,isTypeEnum:()=>Zk,isTypeEthAddress:()=>rM,isTypeFelt:()=>qk,isTypeLitteral:()=>Wk,isTypeNamedTuple:()=>Gk,isTypeOption:()=>Jk,isTypeResult:()=>Qk,isTypeStruct:()=>Kk,isTypeTuple:()=>Hk,isTypeUint:()=>Yk,isTypeUint256:()=>Xk,tuple:()=>hM,uint256:()=>aM});nA({},{UINT_128_MAX:()=>Dk,UINT_256_MAX:()=>Fk,bnToUint256:()=>Lk,isUint256:()=>jk,uint256ToBN:()=>Uk});var Dk=(1n<<128n)-1n,Fk=(1n<<256n)-1n;function Uk(t){return(ak(t.high)<<128n)+ak(t.low)}function jk(t){return ak(t)<=Fk}function Lk(t){const e=ak(t);if(!jk(e))throw new Error("Number is too large");return{low:fA((e&Dk).toString(16)),high:fA((e>>128n).toString(16))}}var zk=t=>/_len$/.test(t),qk=t=>"felt"===t||"core::felt252"===t,Vk=t=>/\*/.test(t)||t.startsWith("core::array::Array::")||t.startsWith("core::array::Span::"),Hk=t=>/^\(.*\)$/i.test(t),Gk=t=>/\(.*\)/i.test(t)&&t.includes(":"),Kk=(t,e)=>t in e,Zk=(t,e)=>t in e,Jk=t=>t.startsWith("core::option::Option::"),Qk=t=>t.startsWith("core::result::Result::"),Yk=t=>Object.values(FA).includes(t),Wk=t=>Object.values(UA).includes(t),Xk=t=>"core::integer::u256"===t,tM=t=>"core::bool"===t,eM=t=>"core::starknet::contract_address::ContractAddress"===t,rM=t=>"core::starknet::eth_address::EthAddress"===t,nM=t=>t.includes("::"),iM=t=>nM(t)?t.substring(t.indexOf("<")+1,t.lastIndexOf(">")):t.replace("*","");function oM(t){const{cairo:e}=sM(t);if(void 0===e)throw Error("Unable to determine Cairo version");return"1"===e}function sM(t){if(t.find((t=>"interface"===t.type)))return{cairo:"1",compiler:"2"};const e=t.find((t=>"function"===t.type&&(t.inputs.length||t.outputs.length)));if(!e)return{cairo:void 0,compiler:void 0};const r=e.inputs.length?e.inputs:e.outputs;return nM(r[0].type)?{cairo:"1",compiler:"1"}:{cairo:"0",compiler:"0"}}var aM=t=>{const e=BigInt(t);if(!jk(e))throw new Error("Number is too large");return{low:(e&Dk).toString(10),high:(e>>128n).toString(10)}},hM=(...t)=>({...t});function uM(t){if(hk(t)||"number"==typeof t&&Number.isInteger(t))return t.toString();if(Ck(t)){if(!Nk(t))throw new Error(`${t} is a long string > 31 chars, felt can store short strings, split it to array of short strings`);const e=Ok(t);return BigInt(e).toString()}if("string"==typeof t&&sk(t))return BigInt(t).toString();if("string"==typeof t&&yk(t))return t;if("boolean"==typeof t)return""+ +t;throw new Error(`${t} can't be computed by felt()`)}var lM=class{constructor(t){const e=Object.values(t);if(0===e.length)throw new Error("This Enum must have a least 1 variant");if(1!==e.filter((t=>void 0!==t)).length)throw new Error("This Enum must have exactly one active variant");this.variant=t}unwrap(){const t=Object.entries(this.variant).find((t=>void 0!==t[1]));if(void 0!==t)return t[1]}activeVariant(){const t=Object.entries(this.variant).find((t=>void 0!==t[1]));return void 0===t?"":t[0]}},cM=(t=>(t[t.Some=0]="Some",t[t.None=1]="None",t))(cM||{}),fM=class{constructor(t,e){if(!(t in cM))throw new Error("Wrong variant : should be CairoOptionVariant.Some or .None.");if(0===t){if(void 0===e)throw new Error('The creation of a Cairo Option with "Some" variant needs a content as input.');this.Some=e,this.None=void 0}else this.Some=void 0,this.None=!0}unwrap(){if(!this.None)return this.Some}isSome(){return!(void 0===this.Some)}isNone(){return!0===this.None}},dM=(t=>(t[t.Ok=0]="Ok",t[t.Err=1]="Err",t))(dM||{}),pM=class{constructor(t,e){if(!(t in dM))throw new Error("Wrong variant : should be CairoResultVariant.Ok or .Err.");0===t?(this.Ok=e,this.Err=void 0):(this.Ok=void 0,this.Err=e)}unwrap(){if(void 0!==this.Ok)return this.Ok;if(void 0!==this.Err)return this.Err;throw new Error("Both Result.Ok and .Err are undefined. Not authorized.")}isOk(){return!(void 0===this.Ok)}isErr(){return!(void 0===this.Err)}},mM=(t,e,r)=>{if(!hk(t[r]))throw new Error(`Data and formatter mismatch on ${r}:${e[r]}, expected response data ${r}:${t[r]} to be BN instead it is ${typeof t[r]}`)},gM=(t,e,r)=>{throw new Error(`Unhandled formatter type on ${r}:${e[r]} for data ${r}:${t[r]}`)};function yM(t,e,r){return Object.entries(t).reduce(((n,[i,o])=>{const s=r??e[i];if(!(i in e)&&!r)return n[i]=o,n;if("string"===s){if(Array.isArray(t[i])){const e=yM(t[i],t[i].map((t=>s)));return n[i]=Object.values(e).join(""),n}return mM(t,e,i),n[i]=$k(o),n}if("number"===s)return mM(t,e,i),n[i]=Number(o),n;if("function"==typeof s)return n[i]=s(o),n;if(Array.isArray(s)){const e=yM(t[i],s,s[0]);return n[i]=Object.values(e),n}return"object"==typeof s?(n[i]=yM(t[i],s),n):(gM(t,e,i),n)}),{})}function vM(t){const e=function(t){return t.find((t=>"interface"===t.type))?2:oM(t)?1:0}(t);if(0===e||1===e)return new class{constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.reduce(((t,e)=>zk(e.name)?t:t+1),0)}getMethod(t){return this.abi.find((e=>e.name===t))}getLegacyFormat(){return this.abi}}(t);if(2===e)return new class{constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.length}getMethod(t){return this.abi.find((t=>"interface"===t.type)).items.find((e=>e.name===t))}getLegacyFormat(){return this.abi.flatMap((t=>"interface"===t.type?t.items:t))}}(t);throw Error(`Unsupported ABI version ${e}`)}function wM(t,e,r){return"constructor"===t&&!r&&!e.length}function bM(t){if(!t.includes("("))return{subTuple:[],result:t};const e=[];let r="",n=0;for(;n<t.length;){if("("===t[n]){let i=1;const o=n;for(n++;i;)")"===t[n]&&i--,"("===t[n]&&i++,n++;e.push(t.substring(o,n)),r+=" ",n--}else r+=t[n];n++}return{subTuple:e,result:r}}function _M(t){return nM(t)?function(t){const e=t.replace(/\s/g,"").slice(1,-1),{subTuple:r,result:n}=bM(e);return n.split(",").map((t=>r.length?t.replace(" ",r.shift()):t))}(t):function(t){const e=t.replace(/\s/g,"").slice(1,-1),{subTuple:r,result:n}=bM(e);let i=n.split(",").map((t=>r.length?t.replace(" ",r.shift()):t));return Gk(t)&&(i=i.reduce(((t,e)=>t.concat(function(t){const e=t.substring(0,t.indexOf(":"));return{name:e,type:t.substring(e.length+":".length)}}(e))),[])),i}(t)}function EM(t,e,r,n){const i=(t,e)=>{if(Vk(e))return function(t,e){const r=iM(e);if("string"==typeof t)return t;return t.map((t=>i(t,r)))}(t,e);if(Zk(e,n)){const r=n[e];return s(t,r)}if(Hk(e))return function(t,e){const r=_M(e).reduce(((e,r,n)=>{const o=Object.keys(t),s=r=>Object.defineProperty(e,n.toString(),{enumerable:!0,value:r??t[o[n]]}),a=r?.type?r.type:r;return s(i(t[o[n]],a)),e}),{});return r}(t,e);if(rM(e))return t;if(Xk(e)){const r=t;if("object"!=typeof r)return r;if(!("low"in r)||!("high"in r))throw function(t){return Error(`Your object includes the property : ${t}, containing an Uint256 object without the 'low' and 'high' keys.`)}(e);return{low:r.low,high:r.high}}if(Kk(e,r)){const n=r[e].members;return o(t,n)}return t},o=(t,e)=>e.reduce(((e,r)=>{if("undefined"===t[r.name]&&(nM(r.type)||!zk(r.name)))throw Error(`Your object needs a property with key : ${r.name} .`);var n;return n=i(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:n??t[r.name]}),e}),{});const s=(t,e)=>{if(Qk(e.name)){const r=t,n=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(",")),o=e.name.substring(e.name.indexOf(",")+1,e.name.lastIndexOf(">"));return r.isOk()?new pM(0,i(t.unwrap(),n)):new pM(1,i(t.unwrap(),o))}if(Jk(e.name)){const r=t,n=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(">"));return r.isSome()?new fM(0,i(r.unwrap(),n)):new fM(1,{})}const r=t,n=Object.entries(r.variant).map((t=>{if(void 0===t[1])return t;const n=e.type.substring(e.type.lastIndexOf("<")+1,e.type.lastIndexOf(">"));return"()"===n?t:[t[0],i(r.unwrap(),n)]}));return new lM(Object.fromEntries(n))};return e.reduce(((e,r)=>{return zk(r.name)&&!nM(r.type)||(n=i(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:n})),e;var n}),{})}function AM(t,e){if(!0===Xk(t)){const t=aM(e);return[uM(t.low),uM(t.high)]}return uM(e)}function kM(t){if("object"==typeof t){const{low:e,high:r}=t;return[uM(e),uM(r)]}const e=aM(t);return[uM(e.low),uM(e.high)]}function MM(t,e,r,n){if(void 0===t)throw Error(`Missing parameter for type ${e}`);if(Array.isArray(t)){const i=[];i.push(uM(t.length));const o=iM(e);return t.reduce(((t,e)=>t.concat(MM(e,o,r,n))),i)}if(r[e]&&r[e].members.length){if(Xk(e))return kM(t);if("core::starknet::eth_address::EthAddress"===e)return AM(e,t);const{members:i}=r[e],o=t;return i.reduce(((t,e)=>t.concat(MM(o[e.name],e.type,r,n))),[])}if(Hk(e)){const i=function(t,e){const r=_M(e),n=Object.values(t);if(n.length!==r.length)throw Error(`ParseTuple: provided and expected abi tuple size do not match.\n provided: ${n} \n expected: ${r}`);return r.map(((t,e)=>({element:n[e],type:t.type??t})))}(t,e);return i.reduce(((t,e)=>{const i=MM(e.element,e.type,r,n);return t.concat(i)}),[])}if(Xk(e))return kM(t);if(Zk(e,n)){const{variants:i}=n[e];if(Jk(e)){const e=t;if(e.isSome()){const t=i.find((t=>"Some"===t.name));if(void 0===t)throw Error("Error in abi : Option has no 'Some' variant.");const o=t.type;if("()"===o)return(0).toString();const s=MM(e.unwrap(),o,r,n);return Array.isArray(s)?[(0).toString(),...s]:[(0).toString(),s]}return 1..toString()}if(Qk(e)){const e=t;if(e.isOk()){const t=i.find((t=>"Ok"===t.name));if(void 0===t)throw Error("Error in abi : Result has no 'Ok' variant.");const o=t.type;if("()"===o)return(0).toString();const s=MM(e.unwrap(),o,r,n);return Array.isArray(s)?[(0).toString(),...s]:[(0).toString(),s]}const o=i.find((t=>"Err"===t.name));if(void 0===o)throw Error("Error in abi : Result has no 'Err' variant.");const s=o.type;if("()"===s)return 1..toString();const a=MM(e.unwrap(),s,r,n);return Array.isArray(a)?[1..toString(),...a]:[1..toString(),a]}const o=t,s=o.activeVariant(),a=i.find((t=>t.name===s));if(void 0===a)throw Error(`Not find in abi : Enum has no '${s}' variant.`);const h=a.type,u=i.findIndex((t=>t.name===s));if("()"===h)return u.toString();const l=MM(o.unwrap(),h,r,n);return Array.isArray(l)?[u.toString(),...l]:[u.toString(),l]}if("object"==typeof t)throw Error(`Parameter ${t} do not align with abi parameter ${e}`);return AM(e,t)}function xM(t,e){let r;switch(!0){case tM(t):return r=e.next().value,Boolean(BigInt(r));case Xk(t):return Uk({low:e.next().value,high:e.next().value});default:return r=e.next().value,BigInt(r)}}function SM(t,e,r,n){if("()"===e.type)return{};if(Xk(e.type)){return Uk({low:t.next().value,high:t.next().value})}if(Vk(e.type)){const i=[],o={name:"",type:iM(e.type)},s=BigInt(t.next().value);for(;i.length<s;)i.push(SM(t,o,r,n));return i}if(r&&e.type in r&&r[e.type])return"core::starknet::eth_address::EthAddress"===e.type?xM(e.type,t):r[e.type].members.reduce(((e,i)=>(e[i.name]=SM(t,i,r,n),e)),{});if(n&&e.type in n&&n[e.type]){const i=Number(t.next().value),o=n[e.type].variants.reduce(((e,o,s)=>s===i?(e[o.name]=SM(t,{name:"",type:o.type},r,n),e):(e[o.name]=void 0,e)),{});if(e.type.startsWith("core::option::Option")){const t=0===i?o.Some:void 0;return new fM(i,t)}if(e.type.startsWith("core::result::Result")){let t;return t=0===i?o.Ok:o.Err,new pM(i,t)}return new lM(o)}if(Hk(e.type)){return _M(e.type).reduce(((e,i,o)=>{const s=i?.name?i.name:o,a={name:s,type:i?.type?i.type:i};return e[s]=SM(t,a,r,n),e}),{})}if(Vk(e.type)){const i=[],o={name:"",type:iM(e.type)},s=BigInt(t.next().value);for(;i.length<s;)i.push(SM(t,o,r,n));return i}return xM(e.type,t)}function NM(t,e,r,n,i){const{name:o,type:s}=e;let a;switch(!0){case zk(o):return a=t.next().value,BigInt(a);case r&&s in r||Hk(s):case n&&Zk(s,n):return SM(t,e,r,n);case Vk(s):if(nM(s))return SM(t,e,r,n);const h=[];if(i&&i[`${o}_len`]){const s=i[`${o}_len`];for(;h.length<s;)h.push(SM(t,{name:o,type:e.type.replace("*","")},r,n))}return h;default:return xM(s,t)}}var IM=(t,e)=>{if(ok("string"==typeof t||"number"==typeof t||"bigint"==typeof t,`Validate: arg ${e.name} should be a felt typed as (String, Number or BigInt)`),"string"==typeof t&&!sk(t))return;const r=BigInt(t.toString(10));ok(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`)},CM=(t,e)=>{"number"==typeof t&&ok(t<=Number.MAX_SAFE_INTEGER,"Validation: Parameter is to large to be typed as Number use (BigInt or String)"),ok("string"==typeof t||"number"==typeof t||"bigint"==typeof t||"object"==typeof t&&"low"in t&&"high"in t,`Validate: arg ${e.name} of cairo type ${e.type} should be type (String, Number or BigInt), but is ${typeof t} ${t}.`);const r="object"==typeof t?Uk(t):ak(t);switch(e.type){case"core::integer::u8":ok(r>=0n&&r<=255n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0 - 255]`);break;case"core::integer::u16":ok(r>=0n&&r<=65535n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 65535]`);break;case"core::integer::u32":ok(r>=0n&&r<=4294967295n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 4294967295]`);break;case"core::integer::u64":ok(r>=0n&&r<=2n**64n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^64-1]`);break;case"core::integer::u128":ok(r>=0n&&r<=2n**128n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^128-1]`);break;case"core::integer::u256":ok(r>=0n&&r<=2n**256n-1n,`Validate: arg ${e.name} is ${e.type} 0 - 2^256-1`);break;case"core::starknet::class_hash::ClassHash":case"core::starknet::contract_address::ContractAddress":ok(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`)}},TM=(t,e)=>{ok("boolean"==typeof t,`Validate: arg ${e.name} of cairo type ${e.type} should be type (Boolean)`)},PM=(t,e,r)=>{if("core::integer::u256"!==e.type)if("core::starknet::eth_address::EthAddress"!==e.type)ok("object"==typeof t&&!Array.isArray(t),`Validate: arg ${e.name} is cairo type struct (${e.type}), and should be defined as js object (not array)`),r[e.type].members.forEach((({name:r})=>{ok(Object.keys(t).includes(r),`Validate: arg ${e.name} should have a property ${r}`)}));else{ok("object"!=typeof t,`EthAdress type is waiting a BigNumberish. Got ${t}`);const r=BigInt(t.toString(10));ok(r>=0n&&r<=2n**160n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^160-1]`)}else CM(t,e)},RM=(t,e)=>{ok("object"==typeof t&&!Array.isArray(t),`Validate: arg ${e.name} is cairo type Enum (${e.type}), and should be defined as js object (not array)`);const r=Object.getOwnPropertyNames(Object.getPrototypeOf(t)),n=[...Object.getOwnPropertyNames(t),...r];if(!(Jk(e.type)&&n.includes("isSome")&&n.includes("isNone")||Qk(e.type)&&n.includes("isOk")&&n.includes("isErr")||n.includes("variant")&&n.includes("activeVariant")))throw new Error(`Validate Enum: argument ${e.name}, type ${e.type}, value received ${t}, is not an Enum.`)},OM=(t,e)=>{ok("object"==typeof t&&!Array.isArray(t),`Validate: arg ${e.name} should be a tuple (defined as object)`)},$M=(t,e,r,n)=>{const i=iM(e.type);if(!qk(i)||!Pk(t))switch(ok(Array.isArray(t),`Validate: arg ${e.name} should be an Array`),!0){case qk(i):t.forEach((t=>IM(t,e)));break;case Hk(i):t.forEach((t=>OM(t,{name:e.name,type:i})));break;case Vk(i):t.forEach((t=>$M(t,{name:"",type:i},r,n)));break;case Kk(i,r):t.forEach((t=>PM(t,{name:e.name,type:i},r)));break;case Zk(i,n):t.forEach((t=>RM(t,{name:e.name,type:i})));break;case Yk(i)||Wk(i):t.forEach((t=>CM(t,e)));break;case tM(i):t.forEach((t=>TM(t,e)));break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value ${t}`)}};function BM(t,e,r,n){t.inputs.reduce(((t,i)=>{const o=e[t];switch(!0){case zk(i.name):return t;case qk(i.type):IM(o,i);break;case Yk(i.type)||Wk(i.type):CM(o,i);break;case tM(i.type):TM(o,i);break;case Vk(i.type):$M(o,i,r,n);break;case Kk(i.type,r):PM(o,i,r);break;case Zk(i.type,n):RM(o,i);break;case Hk(i.type):OM(o,i);break;default:throw new Error(`Validate Unhandled: argument ${i.name}, type ${i.type}, value ${o}`)}return t+1}),0)}var DM=class{constructor(t){this.structs=DM.getAbiStruct(t),this.enums=DM.getAbiEnum(t),this.parser=vM(t),this.abi=this.parser.getLegacyFormat()}validate(t,e,r=[]){if("DEPLOY"!==t){ok(this.abi.filter((e=>{if("function"!==e.type)return!1;const r="view"===e.stateMutability||"view"===e.state_mutability;return"INVOKE"===t?!r:r})).map((t=>t.name)).includes(e),("INVOKE"===t?"invocable":"viewable")+" method not found in abi")}const n=this.abi.find((r=>"DEPLOY"===t?r.name===e&&"constructor"===r.type:r.name===e&&"function"===r.type));if(wM(e,r,n))return;const i=this.parser.methodInputsLength(n);if(r.length!==i)throw Error(`Invalid number of arguments, expected ${i} arguments, but got ${r.length}`);BM(n,r,this.structs,this.enums)}compile(t,e){const r=this.abi.find((e=>e.name===t));if(wM(t,e,r))return[];let n;if(Array.isArray(e))n=e;else{const t=EM(e,r.inputs,this.structs,this.enums);n=Object.values(t),BM(r,n,this.structs,this.enums)}const i=n[Symbol.iterator](),o=r.inputs.reduce(((t,e)=>zk(e.name)&&!nM(e.type)?t:t.concat(function(t,e,r,n){const{name:i,type:o}=e;let{value:s}=t.next();switch(!0){case Vk(o):if(!Array.isArray(s)&&!Ck(s))throw Error(`ABI expected parameter ${i} to be array or long string, got ${s}`);return"string"==typeof s&&(s=Rk(s)),MM(s,e.type,r,n);case"core::starknet::eth_address::EthAddress"===o:return AM(o,s);case Kk(o,r)||Hk(o)||Xk(o):case Zk(o,n):return MM(s,o,r,n);default:return AM(o,s)}}(i,e,this.structs,this.enums))),[]);return Object.defineProperty(o,"__compiled__",{enumerable:!1,writable:!1,value:!0}),o}static compile(t){const e=t=>{const e=(t,r=".")=>{const n=Array.isArray(t)?[t.length.toString(),...t]:t;return Object.entries(n).flatMap((([t,i])=>{let o=i;Pk(o)&&(o=Rk(o)),"entrypoint"===t&&(o=Mk(o));const s=Array.isArray(n)&&"0"===t?"$$len":t;if(hk(o))return[[`${r}${s}`,uM(o)]];if(Object(o)===o){const t=Object.getOwnPropertyNames(Object.getPrototypeOf(o)),n=[...Object.getOwnPropertyNames(o),...t];if(n.includes("isSome")&&n.includes("isNone")){const t=o,n=t.isSome()?0:1;return t.isSome()?e({0:n,1:t.unwrap()},`${r}${s}.`):[[`${r}${s}`,uM(n)]]}if(n.includes("isOk")&&n.includes("isErr")){const t=o,n=t.isOk()?0:1;return e({0:n,1:t.unwrap()},`${r}${s}.`)}if(n.includes("variant")&&n.includes("activeVariant")){const t=o,n=t.activeVariant(),i=Object.keys(t.variant).findIndex((t=>t===n));return"object"==typeof t.unwrap()&&0===Object.keys(t.unwrap()).length?[[`${r}${s}`,uM(i)]]:e({0:i,1:t.unwrap()},`${r}${s}.`)}return e(o,`${r}${s}.`)}return[[`${r}${s}`,uM(o)]]}))};return Object.fromEntries(e(t))};let r;if(Array.isArray(t)){const n=e({...t});r=Object.values(n)}else{const n=e(t);r=Object.values(n)}return Object.defineProperty(r,"__compiled__",{enumerable:!1,writable:!1,value:!0}),r}parse(t,e){const{outputs:r}=this.abi.find((e=>e.name===t)),n=e.flat()[Symbol.iterator](),i=r.flat().reduce(((t,e,r)=>{const i=e.name??r;return t[i]=NM(n,e,this.structs,this.enums,t),t[i]&&t[`${i}_len`]&&delete t[`${i}_len`],t}),{});return 1===Object.keys(i).length&&0 in i?i[0]:i}format(t,e,r){return yM(this.parse(t,e),r)}static getAbiStruct(t){return t.filter((t=>"struct"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{})}static getAbiEnum(t){const e=t.filter((t=>"enum"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{});return delete e["core::bool"],e}static toCalldata(t=[]){return DM.compile(t)}static toHex(t=[]){return DM.compile(t).map((t=>uk(t)))}};nA({},{calculateContractAddressFromHash:()=>tx,calculateDeclareTransactionHash:()=>YM,calculateDeployAccountTransactionHash:()=>WM,calculateDeployTransactionHash:()=>QM,calculateTransactionHash:()=>XM,calculateTransactionHashCommon:()=>JM,computeCompiledClassHash:()=>sx,computeContractClassHash:()=>ux,computeHashOnElements:()=>ZM,computeLegacyContractClassHash:()=>ix,computeSierraContractClassHash:()=>hx,default:()=>nx,feeTransactionVersion:()=>HM,feeTransactionVersion_2:()=>GM,formatSpaces:()=>rx,getSelector:()=>xk,getSelectorFromName:()=>Mk,getVersionsByType:()=>KM,keccakBn:()=>Ak,poseidon:()=>Zg,starknetKeccak:()=>kk,transactionVersion:()=>qM,transactionVersion_2:()=>VM});nA({},{starkCurve:()=>ev,weierstrass:()=>uy});nA({},{parse:()=>UM,parseAlwaysAsBig:()=>jM,stringify:()=>LM,stringifyAlwaysAsBig:()=>zM});var FM=t=>{if(!rv(t))return parseFloat(t);const e=parseInt(t,10);return Number.isSafeInteger(e)?e:BigInt(t)},UM=t=>Mv(String(t),void 0,FM),jM=t=>Mv(String(t),void 0,vv),LM=(t,e,r,n)=>ow(t,e,r,n),zM=LM,qM=_A,VM=EA,HM=AA,GM=kA;function KM(t){return"fee"===t?{v1:HM,v2:GM}:{v1:qM,v2:VM}}function ZM(t){return[...t,t.length].reduce(((t,e)=>Vy(ak(t),ak(e))),0).toString()}function JM(t,e,r,n,i,o,s,a=[]){const h=ZM(i);return ZM([t,e,r,n,h,o,s,...a])}function QM(t,e,r,n,i="constructor"){return JM("0x6465706c6f79",r,t,Mk(i),e,0,n)}function YM(t,e,r,n,i,o,s){return JM("0x6465636c617265",r,e,0,[t],n,i,[o,...s?[s]:[]])}function WM(t,e,r,n,i,o,s,a){return JM("0x6465706c6f795f6163636f756e74",i,t,0,[e,n,...r],o,s,[a])}function XM(t,e,r,n,i,o){return JM("0x696e766f6b65",e,t,0,r,n,i,[o])}function tx(t,e,r,n){const i=ZM(DM.compile(r));return ZM([uM("0x535441524b4e45545f434f4e54524143545f41444452455353"),n,t,e,i])}function ex(t,e){return"attributes"===t||"accessible_scopes"===t?Array.isArray(e)&&0===e.length?void 0:e:"debug_info"===t?null:null===e?void 0:e}function rx(t){let e=!1;const r=[];for(const n of t)'"'===n&&!1==(r.length>0&&"\\"===r.slice(-1)[0])&&(e=!e),e?r.push(n):r.push(":"===n?": ":","===n?", ":n);return r.join("")}function nx(t){const{abi:e,program:r}=t,n=rx(LM({abi:e,program:r},ex));return fA(Gy(sA(n)).toString(16))}function ix(t){const e="string"==typeof t?UM(t):t,r=uk(NA),n=ZM(e.entry_points_by_type.EXTERNAL.flatMap((t=>[t.selector,t.offset]))),i=ZM(e.entry_points_by_type.L1_HANDLER.flatMap((t=>[t.selector,t.offset]))),o=ZM(e.entry_points_by_type.CONSTRUCTOR.flatMap((t=>[t.selector,t.offset]))),s=ZM(e.program.builtins.map((t=>Ok(t)))),a=nx(e),h=ZM(e.program.data);return ZM([r,n,i,o,s,a,h])}function ox(t){const e=t.flatMap((t=>{return[BigInt(t.selector),BigInt(t.offset),(e=t.builtins,tv(e.flatMap((t=>BigInt(Ok(t))))))];var e}));return tv(e)}function sx(t){const e=BigInt(Ok("COMPILED_CLASS_V1")),r=ox(t.entry_points_by_type.EXTERNAL),n=ox(t.entry_points_by_type.L1_HANDLER),i=ox(t.entry_points_by_type.CONSTRUCTOR),o=tv(t.bytecode.map((t=>BigInt(t))));return uk(tv([e,r,n,i,o]))}function ax(t){return tv(t.flatMap((t=>[BigInt(t.selector),BigInt(t.function_idx)])))}function hx(t){const e=BigInt(Ok("CONTRACT_CLASS_V0.1.0")),r=ax(t.entry_points_by_type.EXTERNAL),n=ax(t.entry_points_by_type.L1_HANDLER),i=ax(t.entry_points_by_type.CONSTRUCTOR),o=function(t){const e=rx(LM(t.abi,null));return BigInt(fA(Gy(sA(e)).toString(16)))}(t),s=tv(t.sierra_program.map((t=>BigInt(t))));return uk(tv([e,r,n,i,o,s]))}function ux(t){const e="string"==typeof t?UM(t):t;return"sierra_program"in e?hx(e):ix(e)}function lx(t){const e="string"==typeof t?t:LM(t);return uA(NE(e))}function cx(t){if(Array.isArray(t))return t;const e=oA(IE(hA(t)));return UM(e)}function fx(){return By(Py.randomPrivateKey())}function dx(t){return fA(t).toLowerCase()}function px(t){if(!t)throw Error("formatSignature: provided signature is undefined");if(Array.isArray(t))return t.map((t=>uk(t)));try{const{r:e,s:r}=t;return[uk(e),uk(r)]}catch(t){throw new Error("Signature need to be weierstrass.SignatureType or an array for custom")}}function mx(t){return mk(px(t))}function gx(t){return gk(px(t))}function yx(t,e=.5){const r=Math.round(100*(1+e));return ak(t)*ak(r)/100n}function vx(t){return"sierra_program"in("string"==typeof t?UM(t):t)}nA({},{compressProgram:()=>lx,decompressProgram:()=>cx,estimatedFeeToMaxFee:()=>yx,formatSignature:()=>px,makeAddress:()=>dx,randomAddress:()=>fx,signatureToDecimalArray:()=>mx,signatureToHexArray:()=>gx});var wx="undefined"!=typeof window&&window.fetch||"undefined"!=typeof global&&global.fetch||tA;function bx(t){return new Promise((e=>{setTimeout(e,t)}))}function _x(t){const e={...t};return delete e.sierra_program_debug_info,e.abi=rx(LM(t.abi)),e.sierra_program=rx(LM(t.sierra_program)),e.sierra_program=lx(e.sierra_program),e}function Ex(t){const e="string"==typeof t?UM(t):t;return vx(t)?_x(e):{...e,..."program"in e&&{program:lx(e.program)}}}nA({},{createSierraContractClass:()=>_x,parseContract:()=>Ex,wait:()=>bx});var Ax=class extends Error{constructor(t){super(t),Object.defineProperty(this,"name",{value:new.target.name,enumerable:!1,configurable:!0}),function(t,e){const{setPrototypeOf:r}=Object;r?r(t,e):t.__proto__=e}(this,new.target.prototype),function(t,e=t.constructor){const{captureStackTrace:r}=Error;r&&r(t,e)}(this)}},kx=class extends Ax{},Mx=class extends kx{constructor(t,e){super(t),this.errorCode=e}},xx=class extends kx{constructor(t,e){super(t),this.errorCode=e}};nA({},{StarknetIdContract:()=>Bx,getStarknetIdContract:()=>Dx,useDecoded:()=>Ox,useEncoded:()=>$x});var Sx="abcdefghijklmnopqrstuvwxyz0123456789-",Nx=BigInt(Sx.length+1),Ix="这来",Cx=BigInt(Sx.length),Tx=BigInt(Ix.length),Px=BigInt(Ix.length+1);function Rx(t){let e=0;for(;t.endsWith(Ix[Ix.length-1]);)t=t.substring(0,t.length-1),e+=1;return[t,e]}function Ox(t){let e="";return t.forEach((t=>{for(;t!==MA;){const r=t%Nx;if(t/=Nx,r===BigInt(Sx.length)){const r=t/Px;if(r===MA){const n=t%Px;t=r,e+=n===MA?Sx[0]:Ix[Number(n)-1]}else{e+=Ix[Number(t%Tx)],t/=Tx}}else e+=Sx[Number(r)]}const[r,n]=Rx(e);n&&(e=r+(n%2==0?Ix[Ix.length-1].repeat(n/2-1)+Ix[0]+Sx[1]:Ix[Ix.length-1].repeat((n-1)/2+1))),e+="."})),e?e.concat("stark"):e}function $x(t){let e=BigInt(0),r=BigInt(1);if(t.endsWith(Ix[0]+Sx[1])){const[e,r]=Rx(t.substring(0,t.length-2));t=e+Ix[Ix.length-1].repeat(2*(r+1))}else{const[e,r]=Rx(t);r&&(t=e+Ix[Ix.length-1].repeat(1+2*(r-1)))}for(let n=0;n<t.length;n+=1){const i=t[n],o=Sx.indexOf(i),s=BigInt(Sx.indexOf(i));if(-1!==o)n===t.length-1&&t[n]===Sx[0]?(e+=r*Cx,r*=Nx,r*=Nx):(e+=r*s,r*=Nx);else if(-1!==Ix.indexOf(i)){e+=r*Cx,r*=Nx;const o=(n===t.length-1?1:0)+Ix.indexOf(i);e+=r*BigInt(o),r*=Tx}}return e}var Bx=(t=>(t.MAINNET="0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678",t.TESTNET="0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce",t))(Bx||{});function Dx(t){switch(t){case"0x534e5f4d41494e":return"0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678";case"0x534e5f474f45524c49":return"0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce";default:throw new Error("Starknet.id is not yet deployed on this network")}}async function Fx(t,e,r){const n=await t.getChainId(),i=r??Dx(n);try{const r=await t.callContract({contractAddress:i,entrypoint:"address_to_domain",calldata:DM.compile({address:e})}),n=Ox(r.result.map((t=>BigInt(t))).slice(1));if(!n)throw Error("Starkname not found");return n}catch(t){if(t instanceof Error&&"Starkname not found"===t.message)throw t;throw Error("Could not get stark name")}}async function Ux(t,e,r){const n=await t.getChainId(),i=r??Dx(n);try{return(await t.callContract({contractAddress:i,entrypoint:"domain_to_address",calldata:DM.compile({domain:[$x(e.replace(".stark","")).toString(10)]})})).result[0]}catch{throw Error("Could not get address from stark name")}}var jx=Object.values(GA),Lx=class{constructor(t){this.hash=null,this.number=null,this.tag=null,this.valueOf=()=>this.number,this.toString=()=>this.hash,this.setIdentifier(t)}setIdentifier(t){"string"==typeof t&&sk(t)?this.hash=t:"bigint"==typeof t?this.hash=uk(t):"number"==typeof t?this.number=t:"string"==typeof t&&jx.includes(t)?this.tag=t:this.tag="pending"}get queryIdentifier(){return null!==this.number?`blockNumber=${this.number}`:null!==this.hash?`blockHash=${this.hash}`:`blockNumber=${this.tag}`}get identifier(){return null!==this.number?{block_number:this.number}:null!==this.hash?{block_hash:this.hash}:this.tag}set identifier(t){this.setIdentifier(t)}get sequencerIdentifier(){return null!==this.hash?{blockHash:this.hash}:{blockNumber:this.number??this.tag}}},zx=(t,e=!1)=>{e||console.warn("Using default public node url, please provide nodeUrl in provider options!");const r="SN_MAIN"===t?$A:OA;return r[Math.floor(Math.random()*r.length)]},qx={"Content-Type":"application/json"},Vx="pending",Hx=200,Gx=class{constructor(t){this.responseParser=new class{parseGetBlockResponse(t){return{timestamp:t.timestamp,block_hash:"block_hash"in t?t.block_hash:"",block_number:"block_number"in t?t.block_number:-1,new_root:"new_root"in t?t.new_root:"",parent_hash:t.parent_hash,status:"status"in t?t.status:"PENDING",transactions:t.transactions}}parseGetTransactionResponse(t){return{calldata:"calldata"in t?t.calldata:[],contract_address:"contract_address"in t?t.contract_address:"",sender_address:"sender_address"in t?t.sender_address:"",max_fee:"max_fee"in t?t.max_fee:"",nonce:"nonce"in t?t.nonce:"",signature:"signature"in t?t.signature:[],transaction_hash:t.transaction_hash,version:t.version}}parseFeeEstimateResponse(t){return{overall_fee:ak(t[0].overall_fee),gas_consumed:ak(t[0].gas_consumed),gas_price:ak(t[0].gas_price)}}parseFeeEstimateBulkResponse(t){return t.map((t=>({overall_fee:ak(t.overall_fee),gas_consumed:ak(t.gas_consumed),gas_price:ak(t.gas_price)})))}parseCallContractResponse(t){return{result:t}}parseSimulateTransactionResponse(t){return t.map((t=>({...t,suggestedMaxFee:yx(BigInt(t.fee_estimation.overall_fee))})))}parseContractClassResponse(t){return{...t,abi:"string"==typeof t.abi?JSON.parse(t.abi):t.abi}}},this.getBlockHashAndNumber=this.getBlockLatestAccepted,this.getStateUpdate=this.getBlockStateUpdate,this.traceBlockTransactions=this.getBlockTransactionsTraces,this.getTransactionCount=this.getBlockTransactionCount,this.traceTransaction=this.getTransactionTrace,this.getSimulateTransaction=this.simulateTransaction;const{nodeUrl:e,retries:r,headers:n,blockIdentifier:i,chainId:o}=t||{};Object.values(CA).includes(e)?this.nodeUrl=zx(e,t?.default):this.nodeUrl=e||zx(void 0,t?.default),this.retries=r||Hx,this.headers={...qx,...n},this.blockIdentifier=i||Vx,this.chainId=o}fetch(t,e,r=0){const n={id:r,jsonrpc:"2.0",method:t,...e&&{params:e}};return wx(this.nodeUrl,{method:"POST",body:LM(n),headers:this.headers})}errorHandler(t,e,r,n){if(r){const{code:n,message:i,data:o}=r;throw new kx(`RPC: ${t} with params ${LM(e)}\n ${n}: ${i}: ${LM(o)}`)}if(n instanceof kx)throw n;if(n)throw Error(n.message)}async fetchEndpoint(t,e){try{const r=await this.fetch(t,e),{error:n,result:i}=await r.json();return this.errorHandler(t,e,n),i}catch(r){throw this.errorHandler(t,e,r?.response?.data,r),r}}async getChainId(){return this.chainId??(this.chainId=await this.fetchEndpoint("starknet_chainId")),this.chainId}async getSpecVersion(){return this.fetchEndpoint("starknet_specVersion")}async getNonceForAddress(t,e=this.blockIdentifier){const r=uk(t),n=new Lx(e).identifier;return this.fetchEndpoint("starknet_getNonce",{contract_address:r,block_id:n})}async getBlock(t=this.blockIdentifier){return this.getBlockWithTxHashes(t).then(this.responseParser.parseGetBlockResponse)}async getBlockLatestAccepted(){return this.fetchEndpoint("starknet_blockHashAndNumber")}async getBlockNumber(){return this.fetchEndpoint("starknet_blockNumber")}async getBlockWithTxHashes(t=this.blockIdentifier){const e=new Lx(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxHashes",{block_id:e})}async getBlockWithTxs(t=this.blockIdentifier){const e=new Lx(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxs",{block_id:e})}async getBlockStateUpdate(t=this.blockIdentifier){const e=new Lx(t).identifier;return this.fetchEndpoint("starknet_getStateUpdate",{block_id:e})}async getBlockTransactionsTraces(t=this.blockIdentifier){const e=new Lx(t).identifier;return this.fetchEndpoint("starknet_traceBlockTransactions",{block_id:e})}async getBlockTransactionCount(t=this.blockIdentifier){const e=new Lx(t).identifier;return this.fetchEndpoint("starknet_getBlockTransactionCount",{block_id:e})}async getPendingTransactions(){const{transactions:t}=await this.getBlock("pending");return Promise.all(t.map((t=>this.getTransactionByHash(t))))}async getTransaction(t){return this.getTransactionByHash(t).then(this.responseParser.parseGetTransactionResponse)}async getTransactionByHash(t){const e=uk(t);return this.fetchEndpoint("starknet_getTransactionByHash",{transaction_hash:e})}async getTransactionByBlockIdAndIndex(t,e){const r=new Lx(t).identifier;return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex",{block_id:r,index:e})}async getTransactionReceipt(t){const e=uk(t);return this.fetchEndpoint("starknet_getTransactionReceipt",{transaction_hash:e})}async getTransactionTrace(t){const e=uk(t);return this.fetchEndpoint("starknet_traceTransaction",{transaction_hash:e})}async getTransactionStatus(t){const e=uk(t);return this.fetchEndpoint("starknet_getTransactionStatus",{transaction_hash:e})}async simulateTransaction(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!1,skipFeeCharge:n=!0}){const i=new Lx(e).identifier,o=[];return r&&o.push(KA.ESimulationFlag.SKIP_VALIDATE),n&&o.push(KA.ESimulationFlag.SKIP_FEE_CHARGE),this.fetchEndpoint("starknet_simulateTransactions",{block_id:i,transactions:t.map((t=>this.buildTransaction(t))),simulation_flags:o}).then(this.responseParser.parseSimulateTransactionResponse)}async waitForTransaction(t,e){const r=uk(t);let{retries:n}=this,i=!1,o=!1;const s=e?.retryInterval??5e3,a=e?.errorStates??[KA.ETransactionStatus.REJECTED,KA.ETransactionExecutionStatus.REVERTED],h=e?.successStates??[KA.ETransactionExecutionStatus.SUCCEEDED,KA.ETransactionStatus.ACCEPTED_ON_L2,KA.ETransactionStatus.ACCEPTED_ON_L1];let u;for(;!i;){await bx(s);try{u=await this.getTransactionStatus(r);const t=u.execution_status,e=u.finality_status;if(!e){throw new Error("waiting for transaction status")}if(h.includes(t)||h.includes(e))i=!0;else if(a.includes(t)||a.includes(e)){const r=`${t}: ${e}`,n=new Error(r);throw n.response=u,o=!0,n}}catch(t){if(t instanceof Error&&o)throw t;if(n<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}n-=1}let l=null;for(;null===l;){try{l=await this.getTransactionReceipt(r)}catch(t){if(n<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}n-=1,await bx(s)}return l}async getStorageAt(t,e,r=this.blockIdentifier){const n=uk(t),i=ck(e),o=new Lx(r).identifier;return this.fetchEndpoint("starknet_getStorageAt",{contract_address:n,key:i,block_id:o})}async getClassHashAt(t,e=this.blockIdentifier){const r=uk(t),n=new Lx(e).identifier;return this.fetchEndpoint("starknet_getClassHashAt",{block_id:n,contract_address:r})}async getClassByHash(t){return this.getClass(t)}async getClass(t,e=this.blockIdentifier){const r=uk(t),n=new Lx(e).identifier;return this.fetchEndpoint("starknet_getClass",{class_hash:r,block_id:n}).then(this.responseParser.parseContractClassResponse)}async getClassAt(t,e=this.blockIdentifier){const r=uk(t),n=new Lx(e).identifier;return this.fetchEndpoint("starknet_getClassAt",{block_id:n,contract_address:r}).then(this.responseParser.parseContractClassResponse)}async getCode(t,e){throw new Error("RPC does not implement getCode function")}async getContractVersion(t,e,{blockIdentifier:r=this.blockIdentifier,compiler:n=!0}={}){let i;if(t)i=await this.getClassAt(t,r);else{if(!e)throw Error("getContractVersion require contractAddress or classHash");i=await this.getClass(e,r)}if(vx(i)){if(n){return{cairo:"1",compiler:sM(i.abi).compiler}}return{cairo:"1",compiler:void 0}}return{cairo:"0",compiler:"0"}}async getEstimateFee(t,e,r=this.blockIdentifier){return this.getInvokeEstimateFee(t,e,r)}async getInvokeEstimateFee(t,e,r=this.blockIdentifier){const n=new Lx(r).identifier,i=this.buildTransaction({type:"INVOKE_FUNCTION",...t,...e},"fee");return this.fetchEndpoint("starknet_estimateFee",{request:[i],block_id:n}).then(this.responseParser.parseFeeEstimateResponse)}async getDeclareEstimateFee(t,e,r=this.blockIdentifier){const n=new Lx(r).identifier,i=this.buildTransaction({type:"DECLARE",...t,...e},"fee");return this.fetchEndpoint("starknet_estimateFee",{request:[i],block_id:n}).then(this.responseParser.parseFeeEstimateResponse)}async getDeployAccountEstimateFee(t,e,r=this.blockIdentifier){const n=new Lx(r).identifier,i=this.buildTransaction({type:"DEPLOY_ACCOUNT",...t,...e},"fee");return this.fetchEndpoint("starknet_estimateFee",{request:[i],block_id:n}).then(this.responseParser.parseFeeEstimateResponse)}async getEstimateFeeBulk(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!1}){r&&console.warn("getEstimateFeeBulk RPC does not support skipValidate");const n=new Lx(e).identifier;return this.fetchEndpoint("starknet_estimateFee",{request:t.map((t=>this.buildTransaction(t,"fee"))),block_id:n}).then(this.responseParser.parseFeeEstimateBulkResponse)}async invokeFunction(t,e){return this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{sender_address:t.contractAddress,calldata:DM.toHex(t.calldata),type:KA.ETransactionType.INVOKE,max_fee:uk(e.maxFee||0),version:"0x1",signature:gx(t.signature),nonce:uk(e.nonce)}})}async declareContract({contract:t,signature:e,senderAddress:r,compiledClassHash:n},i){return vx(t)?this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:KA.ETransactionType.DECLARE,contract_class:{sierra_program:cx(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},compiled_class_hash:n||"",version:bA,max_fee:uk(i.maxFee||0),signature:gx(e),sender_address:r,nonce:uk(i.nonce)}}):this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:KA.ETransactionType.DECLARE,contract_class:{program:t.program,entry_points_by_type:t.entry_points_by_type,abi:t.abi},version:wA,max_fee:uk(i.maxFee||0),signature:gx(e),sender_address:r,nonce:uk(i.nonce)}})}async deployAccountContract({classHash:t,constructorCalldata:e,addressSalt:r,signature:n},i){return this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{constructor_calldata:DM.toHex(e||[]),class_hash:uk(t),contract_address_salt:uk(r||0),type:KA.ETransactionType.DEPLOY_ACCOUNT,max_fee:uk(i.maxFee||0),version:uk(i.version||0),signature:gx(n),nonce:uk(i.nonce)}})}async callContract(t,e=this.blockIdentifier){const r=new Lx(e).identifier,n=await this.fetchEndpoint("starknet_call",{request:{contract_address:t.contractAddress,entry_point_selector:Mk(t.entrypoint),calldata:DM.toHex(t.calldata)},block_id:r});return this.responseParser.parseCallContractResponse(n)}async estimateMessageFee(t,e=this.blockIdentifier){const{from_address:r,to_address:n,entry_point_selector:i,payload:o}=t,s={from_address:uk(r),to_address:uk(n),entry_point_selector:xk(i),payload:bk(o)},a=new Lx(e).identifier;return this.fetchEndpoint("starknet_estimateMessageFee",{message:s,block_id:a})}async getSyncingStats(){return this.fetchEndpoint("starknet_syncing")}async getEvents(t){return this.fetchEndpoint("starknet_getEvents",{filter:t})}async getStarkName(t,e){return Fx(this,t,e)}async getAddressFromStarkName(t,e){return Ux(this,t,e)}buildTransaction(t,e){const r=KM(e),n={signature:gx(t.signature),nonce:uk(t.nonce),max_fee:uk(t.maxFee||0)};if("INVOKE_FUNCTION"===t.type)return{type:KA.ETransactionType.INVOKE,sender_address:t.contractAddress,calldata:DM.toHex(t.calldata),version:uk(t.version||r.v1),...n};if("DECLARE"===t.type)return vx(t.contract)?{type:t.type,contract_class:{...t.contract,sierra_program:cx(t.contract.sierra_program)},compiled_class_hash:t.compiledClassHash||"",sender_address:t.senderAddress,version:uk(t.version||r.v2),...n}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:uk(t.version||r.v1),...n};if("DEPLOY_ACCOUNT"===t.type)return{type:t.type,constructor_calldata:DM.toHex(t.constructorCalldata||[]),class_hash:uk(t.classHash),contract_address_salt:uk(t.addressSalt||0),version:uk(t.version||r.v1),...n};throw Error("RPC buildTransaction received unknown TransactionType")}},Kx=/^(?:\w+:)?\/\/(\S+)$/,Zx=/^localhost[:?\d]*(?:[^:?\d]\S*)?$/,Jx=/^[^\s.]+\.\S{2,}$/;function Qx(t,e,r){return function(t){if(!t)return!1;if("string"!=typeof t)return!1;const e=t.match(Kx);if(!e)return!1;const r=e[1];return!(!r||!Zx.test(r)&&!Jx.test(r))}(r)?r:eA(t,r??e)}var Yx={network:"SN_GOERLI",blockIdentifier:"pending"},Wx=class{constructor(t=Yx){this.responseParser=new class extends class{}{parseGetBlockResponse(t){return{...t,new_root:t.state_root,parent_hash:t.parent_block_hash,transactions:Object.values(t.transactions).map((t=>"transaction_hash"in t&&t.transaction_hash)).filter(Boolean)}}parseGetTransactionResponse(t){if("NOT_RECEIVED"===t.status&&"NOT_RECEIVED"===t.finality_status)throw new kx;return{...t,calldata:"calldata"in t.transaction?t.transaction.calldata:[],contract_class:"contract_class"in t.transaction?t.transaction.contract_class:void 0,entry_point_selector:"entry_point_selector"in t.transaction?t.transaction.entry_point_selector:void 0,max_fee:"max_fee"in t.transaction?t.transaction.max_fee:void 0,nonce:t.transaction.nonce,sender_address:"sender_address"in t.transaction?t.transaction.sender_address:void 0,signature:"signature"in t.transaction?t.transaction.signature:void 0,transaction_hash:"transaction_hash"in t.transaction?t.transaction.transaction_hash:void 0,version:"version"in t.transaction?t.transaction.version:void 0}}parseGetTransactionReceiptResponse(t){return{...t,messages_sent:t.l2_to_l1_messages,..."revert_error"in t&&{revert_reason:t.revert_error}}}parseFeeEstimateResponse(t){if("overall_fee"in t){let e={};try{e={gas_consumed:ak(t.gas_usage),gas_price:ak(t.gas_price)}}catch{}return{overall_fee:ak(t.overall_fee),...e}}return{overall_fee:ak(t.amount)}}parseFeeEstimateBulkResponse(t){return[].concat(t).map((t=>{if("overall_fee"in t){let e={};try{e={gas_consumed:ak(t.gas_usage),gas_price:ak(t.gas_price)}}catch{}return{overall_fee:ak(t.overall_fee),...e}}return{overall_fee:ak(t.amount)}}))}parseSimulateTransactionResponse(t){const e="overall_fee"in t.fee_estimation?t.fee_estimation.overall_fee:t.fee_estimation.amount;return[{transaction_trace:t.trace,fee_estimation:t.fee_estimation,suggestedMaxFee:yx(BigInt(e))}]}parseCallContractResponse(t){return{result:t.result}}parseInvokeFunctionResponse(t){return{transaction_hash:t.transaction_hash}}parseDeployContractResponse(t){return{transaction_hash:t.transaction_hash,contract_address:t.address}}parseDeclareContractResponse(t){return{transaction_hash:t.transaction_hash,class_hash:t.class_hash}}parseGetStateUpdateResponse(t){const e=Object.entries(t.state_diff.nonces).map((([t,e])=>({contract_address:t,nonce:e}))),r=Object.entries(t.state_diff.storage_diffs).map((([t,e])=>({address:t,storage_entries:e})));return{...t,state_diff:{...t.state_diff,storage_diffs:r,nonces:e}}}parseContractClassResponse(t){const e=vx(t)?t:Ex(t);return{...e,abi:"string"==typeof e.abi?JSON.parse(e.abi):e.abi}}},"network"in t?(this.baseUrl=Wx.getNetworkFromName(t.network),this.feederGatewayUrl=Qx(this.baseUrl,"feeder_gateway"),this.gatewayUrl=Qx(this.baseUrl,"gateway")):(this.baseUrl=t.baseUrl,this.feederGatewayUrl=Qx(this.baseUrl,"feeder_gateway",t.feederGatewayUrl),this.gatewayUrl=Qx(this.baseUrl,"gateway",t.gatewayUrl)),this.chainId=t?.chainId??Wx.getChainIdFromBaseUrl(this.baseUrl),this.headers=t.headers,this.blockIdentifier=t?.blockIdentifier||Yx.blockIdentifier}static getNetworkFromName(t){switch(t){case"SN_MAIN":case"0x534e5f4d41494e":return"https://alpha-mainnet.starknet.io";case"SN_GOERLI":case"0x534e5f474f45524c49":return"https://alpha4.starknet.io";default:throw new Error("Could not detect base url from NetworkName")}}static getChainIdFromBaseUrl(t){try{return new URL(t).host.includes("mainnet.starknet.io")?"0x534e5f4d41494e":"0x534e5f474f45524c49"}catch{return console.error(`Could not parse baseUrl: ${t}`),"0x534e5f474f45524c49"}}getFetchUrl(t){return["add_transaction"].includes(t)?this.gatewayUrl:this.feederGatewayUrl}getFetchMethod(t){return["add_transaction","call_contract","estimate_fee","estimate_message_fee","estimate_fee_bulk","simulate_transaction"].includes(t)?"POST":"GET"}getQueryString(t){if(void 0===(e=t)||0===Object.keys(e).length||1===Object.keys(e).length&&Object.entries(e).every((([t,e])=>"blockIdentifier"===t&&null===e)))return"";var e;const r=Object.entries(t).map((([t,e])=>{if("blockIdentifier"===t){return`${new Lx(e).queryIdentifier}`}return`${t}=${e}`})).join("&");return`?${r}`}getHeaders(t){return"POST"===t?{"Content-Type":"application/json",...this.headers}:this.headers}async fetchEndpoint(t,...[e,r]){const n=this.getFetchUrl(t),i=this.getFetchMethod(t),o=this.getQueryString(e),s=eA(n,t,o);return this.fetch(s,{method:i,body:r})}async fetch(t,e){const r=Qx(this.baseUrl,"",t),n=e?.method??"GET",i=this.getHeaders(n),o=LM(e?.body);try{const t=await wx(r,{method:n,body:o,headers:i}),s=await t.text();if(!t.ok){let e;try{e=UM(s)}catch{throw new xx(t.statusText,t.status)}throw new Mx(e.message,e.code)}return(e?.parseAlwaysAsBigInt?jM:UM)(s)}catch(t){if(t instanceof Error&&!(t instanceof kx))throw Error(`Could not ${n} from endpoint \`${r}\`: ${t.message}`);throw t}}async getChainId(){return Promise.resolve(this.chainId)}async callContract({contractAddress:t,entrypoint:e,calldata:r=[]},n=this.blockIdentifier){return this.fetchEndpoint("call_contract",{blockIdentifier:n},{contract_address:t,entry_point_selector:Mk(e),calldata:DM.compile(r)}).then(this.responseParser.parseCallContractResponse)}async getBlock(t=this.blockIdentifier){return this.fetchEndpoint("get_block",{blockIdentifier:t}).then(this.responseParser.parseGetBlockResponse)}async getNonceForAddress(t,e=this.blockIdentifier){return this.fetchEndpoint("get_nonce",{contractAddress:t,blockIdentifier:e})}async getStorageAt(t,e,r=this.blockIdentifier){const n=ak(e).toString(10);return this.fetchEndpoint("get_storage_at",{blockIdentifier:r,contractAddress:t,key:n})}async getTransaction(t){const e=uk(t);return this.fetchEndpoint("get_transaction",{transactionHash:e}).then((t=>{if(1===Object.values(t).length)throw new kx(t.status);return this.responseParser.parseGetTransactionResponse(t)}))}async getTransactionReceipt(t){const e=uk(t);return this.fetchEndpoint("get_transaction_receipt",{transactionHash:e}).then(this.responseParser.parseGetTransactionReceiptResponse)}async getClassAt(t,e=this.blockIdentifier){return this.fetchEndpoint("get_full_contract",{blockIdentifier:e,contractAddress:t}).then(this.responseParser.parseContractClassResponse)}async getClassHashAt(t,e=this.blockIdentifier){return this.fetchEndpoint("get_class_hash_at",{blockIdentifier:e,contractAddress:t})}async getClassByHash(t,e=this.blockIdentifier){return this.fetchEndpoint("get_class_by_hash",{classHash:t,blockIdentifier:e}).then(this.responseParser.parseContractClassResponse)}async getCompiledClassByClassHash(t,e=this.blockIdentifier){return this.fetchEndpoint("get_compiled_class_by_class_hash",{classHash:t,blockIdentifier:e})}async getContractVersion(t,e,{blockIdentifier:r=this.blockIdentifier,compiler:n=!0}={}){let i;if(t)i=await this.getClassAt(t,r);else{if(!e)throw Error("getContractVersion require contractAddress or classHash");i=await this.getClassByHash(e,r)}if(vx(i)){if(n){return{cairo:"1",compiler:sM(i.abi).compiler}}return{cairo:"1",compiler:void 0}}return{cairo:"0",compiler:"0"}}async invokeFunction(t,e){return this.fetchEndpoint("add_transaction",void 0,{type:"INVOKE_FUNCTION",sender_address:t.contractAddress,calldata:DM.compile(t.calldata??[]),signature:mx(t.signature),nonce:uk(e.nonce),max_fee:uk(e.maxFee||0),version:"0x1"}).then(this.responseParser.parseInvokeFunctionResponse)}async deployAccountContract({classHash:t,constructorCalldata:e,addressSalt:r,signature:n},i){return this.fetchEndpoint("add_transaction",void 0,{type:"DEPLOY_ACCOUNT",contract_address_salt:r??fx(),constructor_calldata:DM.compile(e??[]),class_hash:uk(t),max_fee:uk(i.maxFee||0),version:uk(i.version||0),nonce:uk(i.nonce),signature:mx(n)}).then(this.responseParser.parseDeployContractResponse)}async declareContract({senderAddress:t,contract:e,signature:r,compiledClassHash:n},i){return vx(e)?this.fetchEndpoint("add_transaction",void 0,{type:"DECLARE",sender_address:t,compiled_class_hash:n,contract_class:e,nonce:uk(i.nonce),signature:mx(r),max_fee:uk(i.maxFee||0),version:uk(VM)}).then(this.responseParser.parseDeclareContractResponse):this.fetchEndpoint("add_transaction",void 0,{type:"DECLARE",contract_class:e,nonce:uk(i.nonce),signature:mx(r),sender_address:t,max_fee:uk(i.maxFee||0),version:uk(qM)}).then(this.responseParser.parseDeclareContractResponse)}async getEstimateFee(t,e,r=this.blockIdentifier,n=!1){return this.getInvokeEstimateFee(t,e,r,n)}async getInvokeEstimateFee(t,e,r=this.blockIdentifier,n=!1){const i=this.buildTransaction({type:"INVOKE_FUNCTION",...t,...e},"fee");return this.fetchEndpoint("estimate_fee",{blockIdentifier:r,skipValidate:n},i).then(this.responseParser.parseFeeEstimateResponse)}async getDeclareEstimateFee(t,e,r=this.blockIdentifier,n=!1){const i=this.buildTransaction({type:"DECLARE",...t,...e},"fee");return this.fetchEndpoint("estimate_fee",{blockIdentifier:r,skipValidate:n},i).then(this.responseParser.parseFeeEstimateResponse)}async getDeployAccountEstimateFee(t,e,r=this.blockIdentifier,n=!1){const i=this.buildTransaction({type:"DEPLOY_ACCOUNT",...t,...e},"fee");return this.fetchEndpoint("estimate_fee",{blockIdentifier:r,skipValidate:n},i).then(this.responseParser.parseFeeEstimateResponse)}async getEstimateFeeBulk(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!1}){const n=t.map((t=>this.buildTransaction(t,"fee")));return this.fetchEndpoint("estimate_fee_bulk",{blockIdentifier:e,skipValidate:r},n).then(this.responseParser.parseFeeEstimateBulkResponse)}async getCode(t,e=this.blockIdentifier){return this.fetchEndpoint("get_code",{contractAddress:t,blockIdentifier:e})}async waitForTransaction(t,e){let r,n=!1,i=0;const o=e?.retryInterval??5e3,s=e?.errorStates??["REJECTED","NOT_RECEIVED","REVERTED"],a=e?.successStates??["SUCCEEDED","ACCEPTED_ON_L1","ACCEPTED_ON_L2"];for(;!n;)if(await bx(o),r=await this.getTransactionStatus(t),"NOT_RECEIVED"===r.finality_status&&i<3)i+=1;else if(a.includes(r.finality_status)||a.includes(r.execution_status))n=!0;else if(s.includes(r.finality_status)||s.includes(r.execution_status)){let t;t=r.tx_failure_reason?`${r.tx_status}: ${r.tx_failure_reason.code}\n${r.tx_failure_reason.error_message}`:r.tx_revert_reason?`${r.tx_status}: ${r.tx_revert_reason}`:r.tx_status;const e=new Error(t);throw e.response=r,e}return await this.getTransactionReceipt(t)}async getTransactionStatus(t){const e=uk(t);return this.fetchEndpoint("get_transaction_status",{transactionHash:e})}async getContractAddresses(){return this.fetchEndpoint("get_contract_addresses")}async getTransactionTrace(t){const e=uk(t);return this.fetchEndpoint("get_transaction_trace",{transactionHash:e})}async estimateMessageFee({from_address:t,to_address:e,entry_point_selector:r,payload:n},i=this.blockIdentifier){const o={from_address:vk(t),to_address:wk(e),entry_point_selector:xk(r),payload:bk(n)};return this.fetchEndpoint("estimate_message_fee",{blockIdentifier:i},o)}async getSimulateTransaction(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!1,skipExecute:n=!1}){t.length>1&&console.warn("Sequencer simulate process only first element from invocations list"),n&&console.warn("Sequencer can't skip account __execute__");const i=this.buildTransaction(t[0]);return this.fetchEndpoint("simulate_transaction",{blockIdentifier:e,skipValidate:r??!1},i).then(this.responseParser.parseSimulateTransactionResponse)}async getStateUpdate(t=this.blockIdentifier){const e=new Lx(t).sequencerIdentifier;return this.fetchEndpoint("get_state_update",{...e}).then(this.responseParser.parseGetStateUpdateResponse)}async getBlockTraces(t=this.blockIdentifier){const e=new Lx(t).sequencerIdentifier;return this.fetchEndpoint("get_block_traces",{...e})}async getStarkName(t,e){return Fx(this,t,e)}async getAddressFromStarkName(t,e){return Ux(this,t,e)}buildTransaction(t,e){const r=KM(e),n={signature:mx(t.signature),nonce:uk(t.nonce)};if("INVOKE_FUNCTION"===t.type)return{type:t.type,sender_address:t.contractAddress,calldata:DM.compile(t.calldata??[]),version:uk(t.version||r.v1),...n};if("DECLARE"===t.type)return vx(t.contract)?{type:t.type,contract_class:t.contract,compiled_class_hash:t.compiledClassHash,sender_address:t.senderAddress,version:uk(t.version||r.v2),...n}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:uk(t.version||r.v1),...n};if("DEPLOY_ACCOUNT"===t.type)return{type:t.type,constructor_calldata:DM.compile(t.constructorCalldata||[]),class_hash:uk(t.classHash),contract_address_salt:uk(t.addressSalt||0),version:uk(t.version||r.v1),...n};throw Error("Sequencer buildTransaction received unknown TransactionType")}},Xx=class{constructor(t){this.provider=t instanceof Xx?t.provider:t instanceof Gx||t instanceof Wx?t:t&&"rpc"in t?new Gx(t.rpc):t&&"sequencer"in t?new Wx(t.sequencer):new Gx}async getChainId(){return this.provider.getChainId()}async getBlock(t){return this.provider.getBlock(t)}async getClassAt(t,e){return this.provider.getClassAt(t,e)}async getClassHashAt(t,e){return this.provider.getClassHashAt(t,e)}getClassByHash(t){return this.provider.getClassByHash(t)}async getEstimateFee(t,e,r){return this.provider.getEstimateFee(t,e,r)}async getInvokeEstimateFee(t,e,r,n){return this.provider.getInvokeEstimateFee(t,e,r,n)}async getEstimateFeeBulk(t,e){return this.provider.getEstimateFeeBulk(t,e)}async getNonceForAddress(t,e){return this.provider.getNonceForAddress(t,e)}async getStorageAt(t,e,r){return this.provider.getStorageAt(t,e,r)}async getTransaction(t){return this.provider.getTransaction(t)}async getTransactionReceipt(t){return this.provider.getTransactionReceipt(t)}async callContract(t,e){return this.provider.callContract(t,e)}async invokeFunction(t,e){return this.provider.invokeFunction(t,e)}async deployAccountContract(t,e){return this.provider.deployAccountContract(t,e)}async declareContract(t,e){return this.provider.declareContract(t,e)}async getDeclareEstimateFee(t,e,r,n){return this.provider.getDeclareEstimateFee(t,e,r,n)}getDeployAccountEstimateFee(t,e,r,n){return this.provider.getDeployAccountEstimateFee(t,e,r,n)}async getCode(t,e){return this.provider.getCode(t,e)}async waitForTransaction(t,e){return this.provider.waitForTransaction(t,e)}async getSimulateTransaction(t,e){return this.provider.getSimulateTransaction(t,e)}async getStateUpdate(t){return this.provider.getStateUpdate(t)}async getStarkName(t,e){return Fx(this,t,e)}async getAddressFromStarkName(t,e){return Ux(this,t,e)}async getContractVersion(t,e,r){return this.provider.getContractVersion(t,e,r)}};nA({},{fromCallsToExecuteCalldata:()=>eS,fromCallsToExecuteCalldataWithNonce:()=>rS,fromCallsToExecuteCalldata_cairo1:()=>iS,getExecuteCalldata:()=>oS,transformCallsToMulticallArrays:()=>tS,transformCallsToMulticallArrays_cairo1:()=>nS});var tS=t=>{const e=[],r=[];return t.forEach((t=>{const n=DM.compile(t.calldata||[]);e.push({to:ak(t.contractAddress).toString(10),selector:ak(Mk(t.entrypoint)).toString(10),data_offset:r.length.toString(),data_len:n.length.toString()}),r.push(...n)})),{callArray:e,calldata:DM.compile({calldata:r})}},eS=t=>{const{callArray:e,calldata:r}=tS(t);return[...DM.compile({callArray:e}),...r]},rS=(t,e)=>[...eS(t),ak(e).toString()],nS=t=>{const e=t.map((t=>({to:ak(t.contractAddress).toString(10),selector:ak(Mk(t.entrypoint)).toString(10),calldata:DM.compile(t.calldata||[])})));return e},iS=t=>{const e=t.map((t=>({contractAddress:t.contractAddress,entrypoint:t.entrypoint,calldata:Array.isArray(t.calldata)&&"__compiled__"in t.calldata?t.calldata:DM.compile(t.calldata)})));return DM.compile({orderCalls:e})},oS=(t,e="0")=>"1"===e?iS(t):eS(t),sS={};nA(sS,{encodeData:()=>gS,encodeType:()=>dS,encodeValue:()=>mS,getDependencies:()=>fS,getMessageHash:()=>vS,getStructHash:()=>yS,getTypeHash:()=>pS,isMerkleTreeType:()=>cS,prepareSelector:()=>lS});nA({},{MerkleTree:()=>aS,proofMerklePath:()=>hS});var aS=class{constructor(t){this.branches=[],this.leaves=t,this.root=this.build(t)}build(t){if(1===t.length)return t[0];t.length!==this.leaves.length&&this.branches.push(t);const e=[];for(let r=0;r<t.length;r+=2)r+1===t.length?e.push(aS.hash(t[r],"0x0")):e.push(aS.hash(t[r],t[r+1]));return this.build(e)}static hash(t,e){const[r,n]=[ak(t),ak(e)].sort(((t,e)=>t>=e?1:-1));return Vy(r,n)}getProof(t,e=this.leaves,r=[]){const n=e.indexOf(t);if(-1===n)throw new Error("leaf not found");if(1===e.length)return r;const i=n%2==0,o=(i?e[n+1]:e[n-1])??"0x0",s=[...r,o],a=this.leaves.length===e.length?-1:this.branches.findIndex((t=>t.length===e.length)),h=this.branches[a+1]??[this.root];return this.getProof(aS.hash(i?t:o,i?o:t),h,s)}};function hS(t,e,r){if(0===r.length)return t===e;const[n,...i]=r;return hS(t,aS.hash(e,n),i)}function uS(t){try{return uk(t)}catch(e){if("string"==typeof t)return uk(Ok(t));throw new Error(`Invalid BigNumberish: ${t}`)}}function lS(t){return sk(t)?t:Mk(t)}function cS(t){return"merkletree"===t.type}var fS=(t,e,r=[])=>("*"===e[e.length-1]&&(e=e.slice(0,-1)),r.includes(e)?r:t[e]?[e,...t[e].reduce(((e,r)=>[...e,...fS(t,r.type,e).filter((t=>!e.includes(t)))]),[])]:r);var dS=(t,e)=>{const[r,...n]=fS(t,e);return(r?[r,...n.sort()]:[]).map((e=>`${e}(${t[e].map((t=>`${t.name}:${t.type}`))})`)).join("")},pS=(t,e)=>Mk(dS(t,e)),mS=(t,e,r,n={})=>{if(t[e])return[e,yS(t,e,r)];if(Object.keys(t).map((t=>`${t}*`)).includes(e)){const n=r.map((r=>yS(t,e.slice(0,-1),r)));return[e,ZM(n)]}if("merkletree"===e){const e=function(t,e){if(e.parent&&e.key){const r=t[e.parent].find((t=>t.name===e.key));if(!cS(r))throw new Error(`${e.key} is not a merkle tree`);if(r.contains.endsWith("*"))throw new Error(`Merkle tree contain property must not be an array but was given ${e.key}`);return r.contains}return"raw"}(t,n),i=r.map((r=>mS(t,e,r)[1])),{root:o}=new aS(i);return["felt",o]}return"felt*"===e?["felt*",ZM(r)]:"selector"===e?["felt",lS(r)]:[e,uS(r)]},gS=(t,e,r)=>{const[n,i]=t[e].reduce((([n,i],o)=>{if(void 0===r[o.name]||null===r[o.name])throw new Error(`Cannot encode data: missing data for '${o.name}'`);const s=r[o.name],[a,h]=mS(t,o.type,s,{parent:e,key:o.name});return[[...n,a],[...i,h]]}),[["felt"],[pS(t,e)]]);return[n,i]},yS=(t,e,r)=>ZM(gS(t,e,r)[1]),vS=(t,e)=>{if(!(t=>{const e=t;return Boolean(e.types&&e.primaryType&&e.message)})(t))throw new Error("Typed data does not match JSON schema");return ZM([Ok("StarkNet Message"),yS(t.types,"StarkNetDomain",t.domain),e,yS(t.types,t.primaryType,t.message)])},wS=new Xx({rpc:{default:!0}});function bS(t){return t.filter((t=>"event"===t.type&&(t.size||"enum"!==t.kind))).reduce(((t,e)=>{const r=e.name.slice(e.name.lastIndexOf(":")+1),n={...e};return n.name=r,{...t,[fA(Gy(sA(r)).toString(16))]:n}}),{})}function _S(t,e,r,n){const i=t.flat().reduce(((t,i)=>{const o=e[i.keys[0]];if(!o)return t;const s={};s[o.name]={},i.keys.shift();const a=i.keys[Symbol.iterator](),h=i.data[Symbol.iterator](),u=o.members?.filter((t=>"key"===t.kind))||o.keys,l=o.members?.filter((t=>"data"===t.kind))||o.data;return u.forEach((t=>{s[o.name][t.name]=NM(a,t,r,n,s[o.name])})),l.forEach((t=>{s[o.name][t.name]=NM(h,t,r,n,s[o.name])})),t.push(s),t}),[]);return i}nA({},{getAbiEvents:()=>bS,parseEvents:()=>_S});var ES=t=>{const e=t[t.length-1];return"object"==typeof e&&["blockIdentifier","parseRequest","parseResponse","formatResponse","maxFee","nonce","signature","addressSalt"].some((t=>t in e))?{args:t,options:t.pop()}:{args:t}};function AS(t,e){return async function(...r){const n=ES(r);return t.call(e.name,n.args,{parseRequest:!0,parseResponse:!0,...n.options})}}function kS(t,e){return"view"===e.stateMutability||"view"===e.state_mutability?AS(t,e):function(t,e){return async function(...r){const n=ES(r);return t.invoke(e.name,n.args,{parseRequest:!0,...n.options})}}(t,e)}function MS(t,e){return function(...r){return t.estimate(e.name,r)}}function xS(t,e){return Array.isArray(t)&&"__compiled__"in t?t:Array.isArray(t)&&Array.isArray(t[0])&&"__compiled__"in t[0]?t[0]:e()}var SS=class{constructor(t,e,r=wS){this.address=e&&e.toLowerCase(),this.providerOrAccount=r,this.callData=new DM(t),this.structs=DM.getAbiStruct(t),this.events=bS(t);const n=vM(t);this.abi=n.getLegacyFormat();const i={enumerable:!0,value:{},writable:!1};Object.defineProperties(this,{functions:{enumerable:!0,value:{},writable:!1},callStatic:{enumerable:!0,value:{},writable:!1},populateTransaction:{enumerable:!0,value:{},writable:!1},estimateFee:{enumerable:!0,value:{},writable:!1}}),this.abi.forEach((t=>{if("function"!==t.type)return;const e=t.name;var r,n;this[e]||Object.defineProperty(this,e,{...i,value:kS(this,t)}),this.functions[e]||Object.defineProperty(this.functions,e,{...i,value:kS(this,t)}),this.callStatic[e]||Object.defineProperty(this.callStatic,e,{...i,value:AS(this,t)}),this.populateTransaction[e]||Object.defineProperty(this.populateTransaction,e,{...i,value:(r=this,n=t,function(...t){return r.populate(n.name,t)})}),this.estimateFee[e]||Object.defineProperty(this.estimateFee,e,{...i,value:MS(this,t)})}))}attach(t){this.address=t}connect(t){this.providerOrAccount=t}async deployed(){return this.deployTransactionHash&&(await this.providerOrAccount.waitForTransaction(this.deployTransactionHash),this.deployTransactionHash=void 0),this}async call(t,e=[],{parseRequest:r=!0,parseResponse:n=!0,formatResponse:i,blockIdentifier:o}={}){ok(null!==this.address,"contract is not connected to an address");const s=xS(e,(()=>r?(this.callData.validate("CALL",t,e),this.callData.compile(t,e)):(console.warn("Call skipped parsing but provided rawArgs, possible malfunction request"),e)));return this.providerOrAccount.callContract({contractAddress:this.address,calldata:s,entrypoint:t},o).then((e=>n?i?this.callData.format(t,e.result,i):this.callData.parse(t,e.result):e.result))}invoke(t,e=[],{parseRequest:r=!0,maxFee:n,nonce:i,signature:o}={}){ok(null!==this.address,"contract is not connected to an address");const s=xS(e,(()=>r?(this.callData.validate("INVOKE",t,e),this.callData.compile(t,e)):(console.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request"),e))),a={contractAddress:this.address,calldata:s,entrypoint:t};if("execute"in this.providerOrAccount)return this.providerOrAccount.execute(a,void 0,{maxFee:n,nonce:i});if(!i)throw new Error("Nonce is required when invoking a function without an account");return console.warn(`Invoking ${t} without an account. This will not work on a public node.`),this.providerOrAccount.invokeFunction({...a,signature:o},{nonce:i})}async estimate(t,e=[]){ok(null!==this.address,"contract is not connected to an address"),xS(e,(()=>!1))||this.callData.validate("INVOKE",t,e);const r=this.populate(t,e);if("estimateInvokeFee"in this.providerOrAccount)return this.providerOrAccount.estimateInvokeFee(r);throw Error("Contract must be connected to the account contract to estimate")}populate(t,e=[]){const r=xS(e,(()=>this.callData.compile(t,e)));return{contractAddress:this.address,entrypoint:t,calldata:r}}parseEvents(t){return _S(t.events?.filter((t=>dk(t.from_address)===dk(this.address)),[])||[],this.events,this.structs,DM.getAbiEnum(this.abi))}isCairo1(){return Bk.isCairo1Abi(this.abi)}async getVersion(){return this.providerOrAccount.getContractVersion(this.address)}typed(t){return this}};function NS(t){pk(t,MA,SA,"Starknet Address");const e=function(t){return fA(cA(uk(t)).padStart(64,"0"))}(t);if(!e.match(/^(0x)?[0-9a-fA-F]{64}$/))throw new Error("Invalid Address Format");return e}const IS={SN_MAIN:"https://starknet-mainnet.public.blastapi.io",SN_SEPOLIA:"https://starknet-sepolia.public.blastapi.io"},CS=[{name:"argent::account::interface::IDeprecatedArgentAccount",type:"interface",items:[{name:"isValidSignature",type:"function",inputs:[{name:"hash",type:"core::felt252"},{name:"signatures",type:"core::array::Array::<core::felt252>"}],outputs:[{type:"core::felt252"}],state_mutability:"view"}]}];function TS(t,e){var r;if(!IS[t])throw new Error("Invalid network");return new Gx({nodeUrl:null!==(r=null==e?void 0:e.broviderUrl)&&void 0!==r?r:IS[t]})}function PS(t){return!!t.primaryType&&!!t.types.StarkNetDomain}function RS(t,e){const{domain:r,types:n,primaryType:i,message:o}=t;return sS.getMessageHash({types:n,primaryType:i,domain:r,message:o},e)}var OS=Object.freeze({__proto__:null,isStarknetMessage:PS,getHash:RS,default:function(t,r,n){return e(this,arguments,void 0,(function*(t,e,r,n="SN_MAIN",i={}){const o=new SS(CS,t,TS(n,i));return yield o.isValidSignature(RS(r,t),[e[0],e[1]]),!0}))}});function $S(t){return we(En(t))}var BS=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const DS=new y("hash/5.6.1"),FS=new Uint8Array(32);FS.fill(0);const US=qt.from(-1),jS=qt.from(0),LS=qt.from(1),zS=qt.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const qS=O(LS.toHexString(),32),VS=O(jS.toHexString(),32),HS={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},GS=["name","version","chainId","verifyingContract","salt"];function KS(t){return function(e){return"string"!=typeof e&&DS.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const ZS={name:KS("name"),version:KS("version"),chainId:function(t){try{return qt.from(t).toString()}catch(t){}return DS.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return Pe(t).toLowerCase()}catch(t){}return DS.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=k(t);if(32!==e.length)throw new Error("bad length");return I(e)}catch(t){}return DS.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function JS(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],n=parseInt(e[2]||"256");(n%8!=0||n>256||e[2]&&e[2]!==String(n))&&DS.throwArgumentError("invalid numeric width","type",t);const i=zS.mask(r?n-1:n),o=r?i.add(LS).mul(US):jS;return function(e){const r=qt.from(e);return(r.lt(o)||r.gt(i))&&DS.throwArgumentError(`value out-of-bounds for ${t}`,"value",e),O(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&DS.throwArgumentError("invalid bytes width","type",t),function(e){return k(e).length!==r&&DS.throwArgumentError(`invalid length for ${t}`,"value",e),function(t){const e=k(t),r=e.length%32;return r?P([e,FS.slice(r)]):I(e)}(e)}}}switch(t){case"address":return function(t){return O(Pe(t),32)};case"bool":return function(t){return t?qS:VS};case"bytes":return function(t){return we(t)};case"string":return function(t){return $S(t)}}return null}function QS(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class YS{constructor(t){gr(this,"types",Object.freeze(Ar(t))),gr(this,"_encoderCache",{}),gr(this,"_types",{});const e={},r={},n={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],n[t]={}}));for(const n in t){const i={};t[n].forEach((o=>{i[o.name]&&DS.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",t),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&DS.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",t);JS(s)||(r[s]||DS.throwArgumentError(`unknown type ${JSON.stringify(s)}`,"types",t),r[s].push(n),e[n][s]=!0)}))}const i=Object.keys(r).filter((t=>0===r[t].length));0===i.length?DS.throwArgumentError("missing primary type","types",t):i.length>1&&DS.throwArgumentError(`ambiguous primary types or unused types: ${i.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),gr(this,"primaryType",i[0]),function i(o,s){s[o]&&DS.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",t),s[o]=!0,Object.keys(e[o]).forEach((t=>{r[t]&&(i(t,s),Object.keys(s).forEach((e=>{n[e][t]=!0})))})),delete s[o]}(this.primaryType,{});for(const e in n){const r=Object.keys(n[e]);r.sort(),this._types[e]=QS(e,t[e])+r.map((e=>QS(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=JS(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),n=parseInt(e[3]);return e=>{n>=0&&e.length!==n&&DS.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let i=e.map(r);return this._types[t]&&(i=i.map(we)),we(P(i))}}const r=this.types[t];if(r){const e=$S(this._types[t]);return t=>{const n=r.map((({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return this._types[r]?we(n):n}));return n.unshift(e),P(n)}}return DS.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||DS.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return we(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(JS(t))return r(t,e);const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],i=parseInt(n[3]);return i>=0&&e.length!==i&&DS.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const i=this.types[t];return i?i.reduce(((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t)),{}):DS.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new YS(t)}static getPrimaryType(t){return YS.from(t).primaryType}static hashStruct(t,e,r){return YS.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const n=HS[r];n||DS.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:n})}return e.sort(((t,e)=>GS.indexOf(t.name)-GS.indexOf(e.name))),YS.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return P(["0x1901",YS.hashDomain(t),YS.from(e).hash(r)])}static hash(t,e,r){return we(YS.encode(t,e,r))}static resolveNames(t,e,r,n){return BS(this,void 0,void 0,(function*(){t=wr(t);const i={};t.verifyingContract&&!S(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const o=YS.from(e);o.visit(r,((t,e)=>("address"!==t||S(e,20)||(i[e]="0x"),e)));for(const t in i)i[t]=yield n(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),r=o.visit(r,((t,e)=>"address"===t&&i[e]?i[e]:e)),{domain:t,value:r}}))}static getPayload(t,e,r){YS.hashDomain(t);const n={},i=[];GS.forEach((e=>{const r=t[e];null!=r&&(n[e]=ZS[e](r),i.push({name:e,type:HS[e]}))}));const o=YS.from(e),s=wr(e);return s.EIP712Domain?DS.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):s.EIP712Domain=i,o.encode(r),{types:s,domain:n,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return I(k(e));if(t.match(/^u?int/))return qt.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&DS.throwArgumentError("invalid string","value",e),e}return DS.throwArgumentError("unsupported type","type",t)}))}}}window&&window.__awaiter;new y("wallet/5.6.2");function WS(t,e,r,n){return Fs(YS.hash(t,e,r),n)}function XS(t,e){return t.toLowerCase()===e.toLowerCase()}function tN(t){const{domain:e,types:r,message:n}=t;return Lu.hash(e,r,n)}function eN(t,r,n,i){return e(this,void 0,void 0,(function*(){let e;try{e=yield ON(i,["function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[k(n),r]])}catch(t){if(t.message.startsWith("missing revert data in call exception"))return!1;throw t}return XS(e,"0x1626ba7e")}))}function rN(t,r,n,i){return e(this,void 0,void 0,(function*(){return XS(yield ON(i,["function isValidSignature(bytes _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[k(n),r]]),"0x20c13b0b")}))}var nN=Object.freeze({__proto__:null,getHash:tN,default:function(t,r,n){return e(this,arguments,void 0,(function*(t,e,r,n="1",i={}){const{domain:o,types:s,message:a}=r;try{if(XS(t,WS(o,s,a,e)))return!0}catch(t){}const h=cm(n,i),u=tN(r);return!!(yield eN(t,e,u,h))||(yield rN(t,e,u,h))}))}});var iN=["snapshot.4everland.link","ipfs.io","ipfs.fleek.co","gateway.pinata.cloud","dweb.link","ipfs.infura.io"],oN={1:{key:"1",name:"Ethereum",chainId:1,network:"homestead",multicall:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",ensResolvers:["0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63","0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"],ensNameWrapper:"0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401",ensSubgraph:"https://subgrapher.snapshot.org/subgraph/arbitrum/5XqPmWe6gjyrJtFn9cLy237i4cWw2j9HcUJEXsP5qGtH",rpc:["https://rpc.ankr.com/eth",{url:"https://api-geth-archive.ankr.com",user:"balancer_user",password:"balancerAnkr20201015"},"https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/eth/mainnet/archive","https://apis.ankr.com/e62bc219f9c9462b8749defe472d2dc5/6106d4a3ec1d1bcc87ec72158f8fd089/eth/archive/main","https://eth-archival.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://eth-mainnet.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],light:["https://cloudflare-eth.com"],ws:["wss://eth-mainnet.ws.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],explorer:{url:"https://etherscan.io",apiUrl:"https://api.etherscan.io"},start:7929876,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},8:{key:"8",name:"Ubiq",chainId:8,network:"Ubiq",multicall:"0x6668750957e4083725926B71C41bDF1434C73262",rpc:["https://rpc.octano.dev"],ws:["wss://ws.octano.dev"],explorer:{url:"https://ubiqscan.io"},start:1,logo:"ipfs://Qmec3HLoN4QhwZAhw4XTi2aN8Wwmcko5hHN22sHARzb9tw"},10:{key:"10",name:"Optimism",chainId:10,network:"Optimism mainnet",multicall:"0x35A6Cdb2C9AD4a45112df4a04147EB07dFA01aB7",rpc:["https://opt-mainnet.g.alchemy.com/v2/JzmIL4Q3jBj7it2duxLFeuCa9Wobmm7D"],explorer:{url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io"},start:657806,logo:"ipfs://QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb"},19:{key:"19",name:"Songbird Canary-Network",shortName:"Songbird",chainId:19,network:"songbird",multicall:"0x17032Ea9c3a13Ed337665145364c0d2aD1108c91",rpc:["https://songbird-api.flare.network/ext/C/rpc"],explorer:{url:"https://songbird-explorer.flare.network"},start:21807126,logo:"ipfs://QmXyvnrZY8FUxSULfnKKA99sAEkjAHtvhRx5WeHixgaEdu"},24:{key:"24",name:"KardiaChain Mainnet",shortName:"KAI",chainId:24,network:"mainnet",multicall:"0xd9c92F2287B7802A37eC9BEce96Aa65fb5f31E1b",rpc:["https://kai-internal.kardiachain.io"],explorer:{url:"https://explorer.kardiachain.io"},start:8260245,logo:"ipfs://bafkreig73yfyqzbxydv6e3dbj5nks3f57px2iez7tywayey4rilfhhrr34"},25:{key:"25",name:"Cronos",shortName:"Cronos",chainId:25,network:"mainnet",multicall:"0x6F522a3982e8F9A50A2EDc9E46ed1A3aE2B3FD3a",rpc:["https://evm-cronos.crypto.org"],explorer:{url:"https://cronos.crypto.org/explorer"},start:4067,logo:"ipfs://QmfSJbtirJoa3Pt7o5Fdm85wbyw9V1hpzqLr5PQbdnfsAj"},30:{key:"30",name:"RSK",chainId:30,network:"rsk mainnet",multicall:"0x4eeebb5580769ba6d26bfd07be636300076d1831",rpc:["https://public-node.rsk.co"],explorer:{url:"https://explorer.rsk.co"},start:2516442,logo:"ipfs://QmXTwpE1SqoNZmyY4c3fYWy6qUgQELsyWKbgJo2Pg6K6V9"},46:{key:"46",name:"Darwinia Network",shortName:"Darwinia",chainId:46,network:"mainnet",multicall:"0x67f9ae42EaA9a8aBf065D60ec6Ab3C1A11370607",rpc:["https://rpc.darwinia.network"],explorer:{url:"https://darwinia.subscan.io"},start:141853,logo:"ipfs://bafkreicf55maidhx46pyu3mwsshlr43xbewr6tkckkonh4nesbkp7krwkm"},56:{key:"56",name:"Binance Smart Chain",shortName:"BSC",chainId:56,network:"mainnet",multicall:"0x1ee38d535d541c55c9dae27b12edf090c608e6fb",rpc:["https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/bsc/mainnet/archive","https://rpc.ankr.com/bsc","https://bsc.getblock.io/mainnet/?api_key=91f8195f-bf46-488f-846a-73d6853790e7","https://bsc-private-dataseed1.nariox.org","https://bsc-dataseed1.ninicoin.io","https://bsc-dataseed1.binance.org"],explorer:{url:"https://bscscan.com"},start:461230,logo:"ipfs://QmWQaQ4Tv28DwA4DRKjSDJFWY9mZboGvuu77J8nh7kucxv"},61:{key:"61",name:"Ethereum Classic",shortName:"Ethereum Classic",chainId:61,network:"mainnet",multicall:"0x51be3a92C56ae7E207C5b5Fd87F7798Ce82C1AC2",rpc:["https://www.ethercluster.com/etc"],explorer:{url:"https://blockscout.com/etc/mainnet"},start:13307544,logo:"ipfs://QmVegc28DvA7LjKUFysab81c9BSuN4wQVDQkRXyAtuEBis"},66:{key:"66",name:"OKExChain",shortName:"OEC Mainnet",chainId:66,network:"oec mainnet",multicall:"0x6EB187d8197Ac265c945b69f3c3064A6f3831866",rpc:["https://exchainrpc.okex.org"],ws:["wss://exchainws.okex.org:8443"],explorer:{url:"https://www.oklink.com/okexchain"},start:5076543,logo:"ipfs://Qmd7dKnNwHRZ4HRCbCXUbkNV7gP28fGqPdjbHtjRtT9sQF"},75:{key:"75",name:"Decimal",shortName:"mainnet",chainId:75,network:"mainnet",multicall:"0x949d1A0757803C51F2EfFFEb5472C861A898B8E8",rpc:[],explorer:{url:"https://explorer.decimalchain.com"},start:16031065,logo:"ipfs://bafkreihkdhbce5rkogl63xegaarlirjrvbfarxbtbf5mqme3s5grvbjyxm"},81:{key:"81",name:"Shibuya Network",shortName:"Shibuya",chainId:81,network:"testnet",testnet:!0,multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shibuya.astar.network:8545"],explorer:{url:"https://blockscout.com/shibuya"},start:856303,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},82:{key:"82",name:"Meter",shortName:"Meter",chainId:82,network:"mainnet",multicall:"0x579De77CAEd0614e3b158cb738fcD5131B9719Ae",rpc:["https://rpc.meter.io"],explorer:{url:"https://scan.meter.io"},start:4992871,logo:"ipfs://QmSZvT9w9eUDvV1YVaq3BKKEbubtNVqu1Rin44FuN4wz11"},97:{key:"97",name:"Binance Smart Chain Testnet",shortName:"BSC Testnet",chainId:97,network:"testnet",testnet:!0,multicall:"0x8b54247c6BAe96A6ccAFa468ebae96c4D7445e46",rpc:["https://data-seed-prebsc-1-s1.binance.org:8545","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/bsc/testnet/archive"],explorer:{url:"https://testnet.bscscan.com"},start:3599656,logo:"ipfs://QmWQaQ4Tv28DwA4DRKjSDJFWY9mZboGvuu77J8nh7kucxv"},100:{key:"100",name:"Gnosis Chain",shortName:"xDAI",chainId:100,network:"mainnet",multicall:"0xb5b692a88bdfc81ca69dcb1d924f59f0413a602a",rpc:["https://gno.getblock.io/mainnet/6c1d1e6e-75d9-452f-a863-a694bff93d5c/","https://xdai-archive.blockscout.com","https://poa-xdai.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://rpc.gnosischain.com"],light:["https://rpc.gnosischain.com"],ws:["wss://rpc.xdaichain.com/wss"],explorer:{url:"https://gnosis.blockscout.com"},start:4108192,logo:"ipfs://QmZeiy8Ax4133wzxUQM9ky8z5XFVf6YLFjJMmTWbWVniZR"},108:{key:"108",name:"Thundercore",chainId:108,network:"mainnet",multicall:"0x3017086deef56679e267f67f66c4415109b7a97f",rpc:["https://mainnet-rpc.thundercore.com/archived/SNAPSHOTEuR82a75fLYA"],explorer:{url:"https://viewblock.io/thundercore"},start:94425385,logo:"ipfs://bafkreifc5z5vtvqx2luzgateyvoocwpd2ifv2hwufxdnyl2a767wa6icli"},122:{key:"122",name:"Fuse",shortName:"Fuse",chainId:122,network:"mainnet",multicall:"0x7a59441fb06666F6d2D766393d876945D06a169c",rpc:["https://explorer-node.fuse.io/","https://oefusefull1.liquify.info/"],explorer:{url:"https://explorer.fuse.io"},start:11923459,logo:"ipfs://QmXjWb64nako7voaVEifgdjAbDbswpTY8bghsiHpv8yWtb"},137:{key:"137",name:"Polygon PoS",shortName:"Polygon",chainId:137,network:"mainnet",multicall:"0xCBca837161be50EfA5925bB9Cc77406468e76751",rpc:["https://rpc.ankr.com/polygon","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/polygon/mainnet/archive","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mainnet/archive","https://rpc-mainnet.maticvigil.com/v1/1cfd7598e5ba6dcf0b4db58e8be484badc6ea08e"],ws:["wss://ws-mainnet.matic.network"],explorer:{url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com"},start:9834491,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},144:{key:"144",name:"PHI Network",shortName:"PHI",chainId:144,network:"mainnet",multicall:"0xc2f41B404a6757863AAeF49ff93039421acCd630",rpc:["https://connect.phi.network"],explorer:{url:"https://phiscan.com"},start:360030,logo:"ipfs://bafkreid6pm3mic7izp3a6zlfwhhe7etd276bjfsq2xash6a4s2vmcdf65a"},148:{key:"148",name:"ShimmerEVM",shortName:"ShimmerEVM",chainId:148,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.evm.shimmer.network/"},start:1290,logo:"ipfs://bafkreib4xhbgbhrwkmizp4d4nz3wzbpyhdm6wpz2v2pbkk7jxsgg3hdt74"},169:{key:"169",name:"Manta Pacific",shortName:"Manta",chainId:169,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://www.oklink.com/manta"},start:332890,logo:"ipfs://bafkreibbrwgwdcfh755dqh4ndta6tja77qbaa36bfv4pstub6prhhore7a"},204:{key:"204",name:"opBNB",shortName:"mainnet",chainId:204,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"http://opbnbscan.com/"},start:512881,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},246:{key:"246",name:"Energy Web Chain",shortName:"EWC",chainId:246,network:"mainnet",multicall:"0x0767F26d0D568aB61A98b279C0b28a4164A6f05e",rpc:["https://voting-rpc.carbonswap.exchange"],explorer:{url:"https://explorer.energyweb.org"},start:12086501,logo:"ipfs://Qmai7AGHgs8NpeGeXgbMZz7pS2i4kw44qubCJYGrZW2f3a"},250:{key:"250",name:"Fantom Opera",shortName:"fantom",chainId:250,network:"Mainnet",multicall:"0x7f6A10218264a22B4309F3896745687E712962a0",rpc:["https://rpc.ankr.com/fantom","https://rpc.ftm.tools","https://rpcapi.fantom.network"],explorer:{url:"https://ftmscan.com"},start:2497732,logo:"ipfs://QmVEgNeQDKnXygeGxfY9FywZpNGQu98ktZtRJ9bToYF6g7"},269:{key:"269",name:"High Performance Blockchain",shortName:"HPB",chainId:269,network:"mainnet",multicall:"0x67D0f263aef2F6167FA77353695D75b582Ff4Bca",rpc:["https://hpbnode.com"],ws:["wss://ws.hpbnode.com"],explorer:{url:"https://hscan.org"},start:13960096,logo:"ipfs://QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"},300:{key:"300",name:"zkSync Sepolia Testnet",shortName:"testnet",chainId:300,network:"testnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:[],explorer:{url:"https://sepolia.explorer.zksync.dev/"},start:2292,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy",testnet:!0},314:{key:"314",name:"Filecoin",shortName:"mainnet",chainId:314,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://filfox.io"},start:3328594,logo:"ipfs://bafybeibyvjfmk6aqlfdrczvth55jkmnoadtrch7ht3rdmvqmy2bfxynecm"},321:{key:"321",name:"KCC",shortName:"KCC",chainId:321,network:"mainnet",multicall:"0xa64D6AFb48225BDA3259246cfb418c0b91de6D7a",rpc:["https://rpc-mainnet.kcc.network"],ws:["wss://rpc-ws-mainnet.kcc.network"],explorer:{url:"https://explorer.kcc.io"},start:1487453,logo:"ipfs://QmRdzYGhFRG8QLzMJahHrw3vETE2YZ9sywQbEkenSjKEvb"},324:{key:"324",name:"zkSync Era",shortName:"zkSync-era",chainId:324,network:"zkSync Era Mainnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:["https://mainnet.era.zksync.io"],explorer:{url:"https://explorer.zksync.io/"},start:3908235,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy"},336:{key:"336",name:"Shiden Network",shortName:"Shiden",chainId:336,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shiden.astar.network:8545","https://shiden.api.onfinality.io/public"],explorer:{url:"https://blockscout.com/shiden"},start:1170016,logo:"ipfs://QmcqGQE4Sk73zXc3e91TUFFefKBVeaNgbxV141XkSNE4xj"},369:{key:"369",name:"Pulsechain",shortName:"Pulsechain",chainId:369,network:"mainnet",multicall:"0xdbdd0FD8B16F0092f306392b699D7fbddaA9011B",rpc:["https://rpc.pulsechain.com"],explorer:{url:"https://scan.pulsechain.com/"},start:17657774,logo:"ipfs://QmWUsiEWdejtHZ9B9981TYXn7Ds8C7fkB1S4h5rP3kCCZR"},416:{key:"416",name:"SX Network",shortName:"SX",chainId:416,network:"mainnet",multicall:"0x834a005DDCF990Ba1a79f259e840e58F2D14F49a",rpc:["https://rpc.sx.technology"],ws:["wss://rpc.sx.technology/ws"],explorer:{url:"https://explorer.sx.technology"},start:2680605,logo:"ipfs://QmSXLXqyr2H6Ja5XrmznXbWTEvF2gFaL8RXNXgyLmDHjAF"},592:{key:"592",name:"Astar Network",shortName:"Astar",chainId:592,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://astar.api.onfinality.io/public","https://rpc.astar.network:8545"],explorer:{url:"https://blockscout.com/astar"},start:366482,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},813:{key:"813",name:"Qitmeer",shortName:"MEER",chainId:813,network:"mainnet",multicall:"0x55034b2cF530ae3A8fC1e2e4523F58496796610F",rpc:["https://evm-dataseed1.meerscan.io","https://evm-dataseed.meerscan.com","https://evm-dataseed2.meerscan.io","https://evm-dataseed3.meerscan.io"],explorer:{url:"https://evm.meerscan.io"},start:43317,logo:"ipfs://QmXvum7SNVaAqAc2jNzR1NpNZN1GGvNaKWydg8a1GEDQ7y"},841:{key:"841",name:"Taraxa",shortName:"841",chainId:841,network:"mainnet",multicall:"0xFCe7a3121B42664AaD145712e1c2Bf2e38f60AA1",rpc:["https://rpc.mainnet.taraxa.io"],ws:["wss://ws.mainnet.taraxa.io"],explorer:{url:"https://mainnet.explorer.taraxa.io"},start:1515906,logo:"ipfs://Qmcc6ZCAGESMzZzoj5LsTVcCo2E35x3Ydk71uPJyov6Mwx"},888:{key:"888",name:"Wanchain",chainId:888,network:"mainnet",multicall:"0xba5934ab3056fca1fa458d30fbb3810c3eb5145f",rpc:["https://gwan-ssl.wandevs.org:56891"],ws:["wss://api.wanchain.org:8443/ws/v3/ddd16770c68f30350a21114802d5418eafe039b722de52b488e7eee1ee2cd73f"],explorer:{url:"https://www.wanscan.org"},start:11302663,logo:"ipfs://QmewFFN44rkxESFsHG8edaLt1znr62hjvZhGynfXqruzX3"},1001:{key:"1001",name:"Klaytn Baobab Testnet",shortName:"Boabab",chainId:1001,network:"testnet",testnet:!0,multicall:"0x40643B8Aeaaca0b87Ea1A1E596e64a0e14B1d244",rpc:["https://archive-en.baobab.klaytn.net"],ws:["wss://archive-en.baobab.klaytn.net/ws"],explorer:{url:"https://baobab.scope.klaytn.com"},start:87232478,logo:"ipfs://QmYACyZcidcFtMo4Uf9H6ZKUxTP2TQPjGzNjcUjqYa64dt"},1072:{key:"1072",name:"Shimmer EVM Testnet",shortName:"ShimmerEVM",chainId:1072,network:"testnet",testnet:!0,multicall:"0x751d21047C116413895c259f3f305e38C10B7cF6",rpc:["https://archive.evm.testnet.shimmer.network/v1/chains/rms1pr75wa5xuepg2hew44vnr28wz5h6n6x99zptk2g68sp2wuu2karywgrztx3/evm"],explorer:{url:"https://explorer.evm.testnet.shimmer.network/"},start:10614,logo:"ipfs://bafkreihtwfwrue7klzedwx4rqlk6agklz4lbbk7owsyw6xzn6c2m4t5tgy"},1088:{key:"1088",name:"Metis",shortName:"metis",chainId:1088,network:"mainnet",multicall:"0xc39aBB6c4451089dE48Cffb013c39d3110530e5C",rpc:["https://andromeda.metis.io/?owner=1088"],explorer:{url:"https://andromeda-explorer.metis.io"},start:451,logo:"ipfs://bafkreiaqr4atnjpdnk3c4vu4377ai7bzqpgaefefbl5j5imfsvr4puimtu"},1101:{key:"1101",name:"Polygon zkEVM",shortName:"mainnet",chainId:1101,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://zkevm.polygonscan.com"},start:57746,logo:"ipfs://bafkreibfiyvhqnme2vbxxfcku7qkxgjpkg6ywdkplxh4oxlkqsbznyorfm"},1116:{key:"1116",name:"Core Chain",shortName:"Core",chainId:1116,network:"mainnet",multicall:"0x024f0041b76B598c2A0a75004F8447FaF67BD004",rpc:["https://rpcar.coredao.org/"],explorer:{url:"https://scan.coredao.org"},start:853908,logo:"ipfs://bafkreigjv5yb7uhlrryzib7j2f73nnwqan2tmfnwjdu26vkk365fyesoiu"},1284:{key:"1284",name:"Moonbeam",shortName:"GLMR",chainId:1284,network:"mainnet",multicall:"0x83e3b61886770de2F64AAcaD2724ED4f08F7f36B",rpc:["https://rpc.api.moonbeam.network"],explorer:{url:"https://moonscan.io/"},start:171135,logo:"ipfs://QmWKTEK2pj5sBBbHnMHQbWgw6euVdBrk2Ligpi2chrWASk"},1285:{key:"1285",name:"Moonriver (Kusama)",shortName:"Moonriver",chainId:1285,network:"mainnet",multicall:"0x537004440ffFE1D4AE9F009031Fc2b0385FCA9F1",rpc:["https://rpc.api.moonriver.moonbeam.network"],explorer:{url:"https://blockscout.moonriver.moonbeam.network"},start:413539,logo:"ipfs://QmXtgPesL87Ejhq2Y7yxsaPYpf4RcnoTYPJWPcv6iiYhoi"},1287:{key:"1287",name:"Moonbase Alpha TestNet",shortName:"Moonbase",chainId:1287,network:"testnet",testnet:!0,multicall:"0xf09FD6B6FF3f41614b9d6be2166A0D07045A3A97",rpc:["https://rpc.testnet.moonbeam.network"],explorer:{url:"https://moonbase-blockscout.testnet.moonbeam.network"},start:859041,logo:"ipfs://QmeGbNTU2Jqwg8qLTMGW8n8HSi2VdgCncAaeGzLx6gYnD7"},1328:{key:"1328",name:"Sei atlantic testnet",shortName:"testnet",chainId:1328,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://seitrace.com"},start:96978658,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},1329:{key:"1329",name:"Sei",shortName:"mainnet",chainId:1329,network:"mainnet",multicall:"0xe033Bed7cae4114Af84Be1e9F1CA7DEa07Dfe1Cf",rpc:[],explorer:{url:"https://seitrace.com/"},start:79164574,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq"},1559:{key:"1559",name:"Tenet",shortName:"tenet",chainId:1559,network:"mainnet",multicall:"0xcCB3F00bE353950E4C08501ac8Af48765EAAa738",rpc:[],explorer:{url:"https://tenetscan.io"},start:944415,logo:"ipfs://Qmc1gqjWTzNo4pyFSGtQuCu7kRSZZBUVybtTjHn2nNEEPA"},1663:{key:"1663",name:"Horizen Gobi Testnet",shortName:"Gobi",chainId:1663,network:"testnet",testnet:!0,multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:["https://gobi-testnet.horizenlabs.io/ethv1"],explorer:{url:"https://gobi-explorer.horizen.io"},start:1,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},2e3:{key:"2000",name:"Doge Chain",shortName:"dogechain",chainId:2e3,network:"mainnet",multicall:"0x6f9D3f3932B417bd4957585D236Cbc32b32C0BDc",rpc:["https://rpc.dogechain.dog"],explorer:{url:"https://explorer.dogechain.dog"},start:877115,logo:"ipfs://bafkreigovfh3pinsdih777issfgaflwu2yjzroljs2642gbvwikcd3nm4i"},2109:{key:"2109",name:"Exosama Network",shortName:"EXN",chainId:2109,network:"mainnet",multicall:"0x2feFC828e2fEfdE0C9f7740919c6A9139F886067",rpc:["https://rpc.exosama.com"],explorer:{url:"https://explorer.exosama.com"},start:94085,logo:"ipfs://QmaQxfwpXYTomUd24PMx5tKjosupXcm99z1jL1XLq9LWBS"},2152:{key:"2152",name:"Findora",shortName:"Findora",chainId:2152,network:"mainnet",multicall:"0xCF7D1e21CBe9bdEF235aef06C5d8051B3d4DF0f5",rpc:["https://archive.prod.findora.org:8545/"],explorer:{url:"https://evm.findorascan.io"},start:4219343,logo:"ipfs://QmXkneyRB6HbHTHRLCZpZqSsawiyJY7b2kZ2V8ydvKYAgv"},2221:{key:"2221",name:"Kava Testnet",shortName:"testnet",chainId:2221,network:"testnet",multicall:"0xc7193EFE367DF0C9349a1149F4E95A2A35604262",rpc:[],explorer:{url:"https://testnet.kavascan.com"},start:6193104,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4",testnet:!0},2222:{key:"2222",name:"Kava",shortName:"mainnet",chainId:2222,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://kavascan.com/"},start:3661165,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4"},2400:{key:"2400",name:"TCG Verse",shortName:"TCGV",chainId:2400,network:"mainnet",multicall:"0xceC65DEE0b5012F1b7321b2647681F997c7204FC",rpc:["https://rpc.tcgverse.xyz"],explorer:{url:"https://explorer.tcgverse.xyz"},start:57500,logo:"ipfs://bafkreidg4wpewve5mdxrofneqblydkrjl3oevtgpdf3fk3z3vjqam6ocoe"},4200:{key:"4200",name:"Merlin",shortName:"merlin",chainId:4200,network:"mainnet",multicall:"0x830E7E548F4D80947a40A7Cf3a2a53166a0C3980",rpc:[],explorer:{url:"https://scan.merlinchain.io"},start:589494,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe"},4337:{key:"4337",name:"Beam",shortName:"Beam",chainId:4337,network:"mainnet",multicall:"0x4956F15eFdc3dC16645e90Cc356eAFA65fFC65Ec",rpc:[],explorer:{url:"https://subnets.avax.network/beam/"},start:1,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF"},4689:{key:"4689",name:"IoTeX",shortName:"IoTeX",chainId:4689,network:"mainnet",multicall:"0x9c8B105c94282CDB0F3ecF27e3cfA96A35c07be6",rpc:["https://babel-api.mainnet.iotex.io"],explorer:{url:"https://iotexscan.io"},start:11533283,logo:"ipfs://QmNkr1UPcBYbvLp7d7Pk4eF3YCsHpaNkfusKZNtykL2EQC"},5e3:{key:"5000",name:"Mantle",chainId:5e3,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.mantle.xyz"],explorer:{url:"https://explorer.mantle.xyz"},start:304717,logo:"ipfs://bafkreidkucwfn4mzo2gtydrt2wogk3je5xpugom67vhi4h4comaxxjzoz4"},5555:{key:"5555",name:"Chain Verse",shortName:"ChainVerse",chainId:5555,network:"ChainVerse",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.chainverse.info"],explorer:{url:"https://explorer.chainverse.info"},start:6334180,logo:"ipfs://QmQyJt28h4wN3QHPXUQJQYQqGiFUD77han3zibZPzHbitk"},6102:{key:"6102",name:"Cascadia Testnet",shortName:"Cascadia",chainId:6102,network:"testnet",multicall:"0x728989819bAD588F193563008E0a03E8cD6a3e4a",rpc:["https://testnet.cascadia.foundation"],explorer:{url:"https://explorer.cascadia.foundation"},testnet:!0,start:370457,logo:"ipfs://QmWkhZYhReYyaa5pQXj32hEGxoRcBqarFMcfQScELmjYQj"},7332:{key:"7332",name:"Horizen EON",shortName:"EON",chainId:7332,network:"mainnet",multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:[],explorer:{url:"https://eon-explorer.horizenlabs.io"},start:85108,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},7341:{key:"7341",name:"Shyft",shortName:"Shyft",chainId:7341,network:"mainnet",multicall:"0xceb10e9133D771cA93c8002Be527A465E85381a2",rpc:["https://rpc.shyft.network"],explorer:{url:"https://bx.shyft.network"},start:3673983,logo:"ipfs://bafkreifwxnnfk6koabzmxgcxcwlrwt6b5gijdain2gyqee77q4ajfb7fu4"},7560:{key:"7560",name:"Cyber",shortName:"mainnet",chainId:7560,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://cyberscan.co"},start:1731707,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm"},8217:{key:"8217",name:"Klaytn Cypress",shortName:"Cypress",chainId:8217,network:"mainnet",multicall:"0x5f5f0d1b9ff8b3dcace308e39b13b203354906e9",rpc:["https://archive-en.cypress.klaytn.net"],ws:["wss://archive-en.cypress.klaytn.net/ws"],explorer:{url:"https://scope.klaytn.com"},start:91582357,logo:"ipfs://QmYACyZcidcFtMo4Uf9H6ZKUxTP2TQPjGzNjcUjqYa64dt"},8453:{key:"8453",name:"Base",shortName:"mainnet",chainId:8453,network:"mainnet",multicall:"0xca11bde05977b3631167028862be2a173976ca11",rpc:[],explorer:{url:"https://basescan.org/"},start:5022,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv"},9001:{key:"9001",name:"Evmos Network",shortName:"Evmos",chainId:9001,network:"mainnet",multicall:"0x37763d16f8dBf6F185368E0f256350cAb7E24b26",rpc:["https://eth.bd.evmos.org:8545"],ws:["wss://eth.bd.evmos.org:8546"],explorer:{url:"https://escan.live"},start:13959539,logo:"ipfs://bafkreif4obrdoiretpozdd56seziywc6clha7wwkbldng3ovry2bpzly34"},1e4:{key:"10000",name:"smartBCH",shortName:"BCH",chainId:1e4,network:"mainnet",multicall:"0x1b38EBAd553f218e2962Cb1C0539Abb5d6A37774",rpc:["https://smartbch.greyh.at/"],explorer:{url:"https://smartbch-explorer.web.app"},start:268248,logo:"ipfs://QmWG1p7om4hZ4Yi4uQvDpxg4si7qVYhtppGbcDGrhVFvMd"},10243:{key:"10243",name:"Arthera Testnet",shortName:"Arthera_",chainId:10243,network:"testnet",testnet:!0,multicall:"0x27c7FC597aD2E81C4c1cA1769972f79DaF042Da7",rpc:["https://rpc-test.arthera.net"],explorer:{url:"https://explorer-test.arthera.net"},start:10523,logo:"ipfs://QmYQp3e52KjkT4bYdAvB6ACEEpXs2D8DozsDitaADRY2Ak"},13337:{key:"13337",name:"Beam Testnet",shortName:"testnet",chainId:13337,network:"testnet",multicall:"0x9BF49b704EE2A095b95c1f2D4EB9010510c41C9E",rpc:[],explorer:{url:"https://subnets-test.avax.network/beam/"},start:3,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF",testnet:!0},13371:{key:"13371",name:"Immutable zkEVM",shortName:"mainnet",chainId:13371,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.immutable.com"},start:3680945,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi"},13473:{key:"13473",name:"Immutable zkEVM Testnet",shortName:"testnet",chainId:13473,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.testnet.immutable.com"},start:5307209,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi",testnet:!0},16718:{key:"16718",name:"AirDAO",chainId:16718,network:"mainnet",multicall:"0x25e81aC81A8B03389D78CB45faB78353aB528574",rpc:["https://network-archive.ambrosus.io"],ws:["wss://network-archive.ambrosus.io/ws"],explorer:{url:"https://airdao.io/explorer"},start:22922566,logo:"ipfs://QmSxXjvWng3Diz4YwXDV2VqSPgMyzLYBNfkjJcr7rzkxom"},29548:{key:"29548",name:"MCH Verse",shortName:"mainnet",chainId:29548,network:"mainnet",multicall:"0x1d39652386488CE1fE4254E105F5A42a04d43dB2",rpc:[],explorer:{url:"https://explorer.oasys.mycryptoheroes.net"},start:27458402,logo:"ipfs://QmZZnwR1y6cU1sare2TQmwqkNDLXQxD4GdPrmHLmUoPtbU"},42161:{key:"42161",name:"Arbitrum One",chainId:42161,network:"Arbitrum mainnet",multicall:"0x7A7443F8c577d537f1d8cD4a629d40a3148Dd7ee",rpc:["https://rpc.ankr.com/arbitrum","https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/arbitrum/mainnet","https://arb-mainnet.g.alchemy.com/v2/JDvtNGwnHhTltIwfnxQocKwKkCTKA1DL"],explorer:{url:"https://arbiscan.io"},start:256508,logo:"ipfs://QmWZ5SMRfvcK8tycsDqojQaSiKedgtVkS7CkZdxPgeCVsZ"},42170:{key:"42170",name:"Arbitrum Nova",chainId:42170,network:"Arbitrum Nova",multicall:"0x4E74EBd9CABff51cE9a43EFe059bA8c5A28E4A14",rpc:["https://nova.arbitrum.io/rpc","https://arbitrum-nova.public.blastapi.io"],explorer:{url:"https://nova.arbiscan.io/"},start:6006607,logo:"ipfs://bafkreie5xsqt3mrrwu7v32qpmmctibhzhgxf4emfzzddsdhdlfsa7fmplu"},42220:{key:"42220",name:"Celo",shortName:"Celo",chainId:42220,network:"mainnet",multicall:"0xb8d0d2C1391eeB350d2Cd39EfABBaaEC297368D9",rpc:["https://celo.snapshot.org","https://forno.celo.org","https://celo-mainnet--rpc.datahub.figment.io/apikey/e892a66dc36e4d2d98a5d6406d609796/"],explorer:{url:"https://explorer.celo.org"},start:6599803,logo:"ipfs://QmS2tVJ7rdJRe1NHXAi2L86yCbUwVVrmB2mHQeNdJxvQti"},43113:{key:"43113",name:"Avalanche FUJI Testnet",chainId:43113,network:"testnet",testnet:!0,multicall:"0x984476ea55e32e785A9D8FF14329f99D74E3d2A2",rpc:["https://api.avax-test.network/ext/bc/C/rpc"],explorer:{url:"https://testnet.snowtrace.io"},start:10528153,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},43114:{key:"43114",name:"Avalanche",chainId:43114,network:"mainnet",multicall:"0x7E9985aE4C8248fdB07607648406a48C76e9e7eD",rpc:["https://nd-784-543-849.p2pify.com/aa7b29fc5fed65b34f0ee6b8de33f8c0/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://api.avax.network/ext/bc/C/rpc"],explorer:{url:"https://snowtrace.io"},start:536483,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},47805:{key:"47805",name:"REI Mainnet",chainId:47805,network:"mainnet",multicall:"0x9eE9904815B80C39C1a27294E69a8626EAa7952d",rpc:["https://rpc.rei.network"],explorer:{url:"https://scan.rei.network/"},start:1715902,logo:"ipfs://QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"},53935:{key:"53935",name:"DFK Chain",chainId:53935,network:"mainnet",multicall:"0x5b24224dC16508DAD755756639E420817DD4c99E",rpc:["https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"],explorer:{url:"https://subnets.avax.network/defi-kingdoms/"},start:62,logo:"ipfs://QmZNkpVgPbuVbDcsi6arwH1om3456FGnwfDqYQJWUfHDEx"},59141:{key:"59141",name:"Linea Sepolia",shortName:"testnet",chainId:59141,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.lineascan.build/"},start:227427,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce",testnet:!0},59144:{key:"59144",name:"Linea",shortName:"linea",chainId:59144,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://lineascan.build/"},start:42,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce"},80001:{key:"80001",name:"Polygon Mumbai",chainId:80001,network:"testnet",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/polygon/mumbai/archive","https://rpc-mumbai.matic.today"],ws:["wss://ws-mumbai.matic.today"],explorer:{url:"https://mumbai.polygonscan.com",apiUrl:"https://api-mumbai.polygonscan.com"},start:12011090,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},81457:{key:"81457",name:"Blast",shortName:"mainnet",chainId:81457,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://blastscan.io"},start:88189,logo:"ipfs://bafkreibfmkjg22cozxppzcoxswj45clvh2rqhxzax57cmmgudbtkf4dkce"},84532:{key:"84532",name:"Base Sepolia",shortName:"testnet",chainId:84532,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://base-sepolia.blockscout.com/"},start:1059647,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv",testnet:!0},686868:{key:"686868",name:"Merlin Testnet",shortName:"merlin",chainId:686868,network:"testnet",multicall:"0x758BC6321b7c68F4986d62a4D46E83A2DCb58c80",rpc:[],explorer:{url:"https://testnet-scan.merlinchain.io"},start:3562021,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe",testnet:!0},713715:{key:"713715",name:"Sei EVM Devnet",shortName:"devnet",chainId:713715,network:"testnet",multicall:"0xEe8d287B844959ADe40d718Dc23077ba920e2f07",rpc:[],explorer:{url:"https://seitrace.com"},start:1463669,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},810180:{key:"810180",name:"zkLink Nova",shortName:"zlink",chainId:810180,network:"mainnet",multicall:"0x825267E0fA5CAe92F98540828a54198dcB3Eaeb5",rpc:[],explorer:{url:"https://explorer.zklink.io"},start:146055,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74"},810181:{key:"810181",name:"zkLink Nova Sepolia",shortName:"testnet",chainId:810181,network:"testnet",multicall:"0x97148F8fDdd9A1620f72EC1Bb2932916623d9da5",rpc:[],explorer:{url:"https://sepolia.explorer.zklink.io/"},start:43723,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74",testnet:!0},11155111:{key:"11155111",name:"Sepolia testnet",shortName:"Sepolia",chainId:11155111,network:"sepolia",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://sepolia.infura.io/v3/d26b4fd748814fe994b05899fd89e667"],ensResolvers:["0x8FADE66B79cC9f707aB26799354482EB93a5B7dD"],ensNameWrapper:"0x0635513f179D50A207757E05759CbD106d7dFcE8",ensSubgraph:"https://api.studio.thegraph.com/proxy/49574/enssepolia/version/latest",explorer:{url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io"},start:751532,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},11155420:{key:"11155420",name:"OP Sepolia",shortName:"testnet",chainId:11155420,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia-optimism.etherscan.io"},start:1620204,logo:"ipfs://QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb",testnet:!0},111557560:{key:"111557560",name:"Cyber Testnet",shortName:"testnet",chainId:111557560,network:"testnet",multicall:"0xffc391F0018269d4758AEA1a144772E8FB99545E",rpc:[],explorer:{url:"https://testnet.cyberscan.co/"},start:304545,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm",testnet:!0},168587773:{key:"168587773",name:"Blast Sepolia",shortName:"testnet",chainId:168587773,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.blastexplorer.io"},start:756690,logo:"ipfs://bafkreibfmkjg22cozxppzcoxswj45clvh2rqhxzax57cmmgudbtkf4dkce",testnet:!0},245022926:{key:"245022926",name:"Neon Devnet",shortName:"devnet",chainId:245022926,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://devnet.neonscan.org/"},start:205206112,logo:"ipfs://QmecRPQGa4bU7tybg1sUQY48Md9rWnmhrT6WW5ueqvhg6P",testnet:!0},1313161554:{key:"1313161554",name:"Aurora",shortName:"Aurora",chainId:1313161554,network:"mainnet",multicall:"0x32b50c286DEFd2932a0247b8bb940b78c063F16c",rpc:["https://mainnet.aurora.dev"],explorer:{url:"https://explorer.mainnet.aurora.dev"},start:57190533,logo:"ipfs://QmeRhsR1UPRTQCizdhmgr2XxphXebVKU5di97uCV2UMFpa"},16666e5:{key:"1666600000",name:"Harmony",shortName:"HarmonyMainnet",chainId:16666e5,network:"mainnet",multicall:"0x9c31392D2e0229dC4Aa250F043d46B9E82074BF8",rpc:["https://a.api.s0.t.hmny.io"],ws:["wss://ws.s0.t.hmny.io"],explorer:{url:"https://explorer.harmony.one"},start:10911984,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"},16667e5:{key:"1666700000",name:"Harmony Testnet",shortName:"HarmonyTestnet",chainId:16667e5,network:"testnet",testnet:!0,multicall:"0x9923589503Fd205feE3d367DDFF2378f0F7dD2d4",rpc:["https://api.s0.b.hmny.io"],ws:["wss://ws.s0.b.hmny.io"],explorer:{url:"https://explorer.pops.one"},start:7521509,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"}};class sN{constructor(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}static isValidChoice(t,e){return"number"==typeof t&&void 0!==(null==e?void 0:e[t-1])}getValidVotes(){return this.votes.filter((t=>sN.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>{const r=this.getValidVotes().filter((t=>t.choice===e+1));return r.reduce(((t,e)=>t+e.balance),0)}))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>{const r=this.strategies.map(((t,r)=>{const n=this.getValidVotes().filter((t=>t.choice===e+1));return n.reduce(((t,e)=>t+e.scores[r]),0)}));return r}))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices[this.selected-1]}}class aN{constructor(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size}getValidVotes(){return this.votes.filter((t=>aN.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.balance),0)))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.scores[r]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected?this.proposal.choices.filter(((t,e)=>this.selected.includes(e+1))).join(", "):""}}function hN(t,e){const r=t/e.reduce(((t,e)=>t+e),0);return isNaN(r)?0:r}function uN(t,e){return Math.sqrt(t*e)}function lN(t){return t*t}function cN(t,e){return t.map((t=>e*t))}class fN{constructor(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>fN.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>{const n=t.map((t=>uN(hN(t.choice[r+1],Object.values(t.choice)),t.balance))).reduce(((t,e)=>t+e),0);return lN(n)}));return cN(r.map(((t,e)=>hN(r[e],r))),e)}getScoresByStrategy(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>this.strategies.map(((e,n)=>t.map((t=>uN(hN(t.choice[r+1],Object.values(t.choice)),t.scores[n]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[lN(t)]))));return r.map(((t,n)=>cN(this.strategies.map(((t,e)=>hN(r[n][e][0],r.flat(2)))),e)))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1]){const r=hN(this.selected[e+1],Object.values(this.selected));return`${Math.round(1e3*r)/10}% for ${t}`}})).filter((t=>null!=t)).join(", ")}}function dN(t,e){const r=[...new Set(t.map((t=>t[0])).flat())],n=Object.entries(t.reduce(((t,[e],r,n)=>{const i=n[r][1];t[e[0]][0]+=i;const o=n[r][2];return o.length>1?t[e[0]][1]=o.map(((r,n)=>r+t[e[0]][1][n]||r)):t[e[0]][1]=[t[e[0]][1].concat(o).reduce(((t,e)=>t+e),0)],t}),Object.assign({},...r.map((t=>({[t]:[0,[]]})))))),i=n.map((t=>[t[0],t[1][0]])),[o,s]=i.reduce((([t,e],[r,n])=>n>e?[r,n]:[t,e]),["?",-1/0]),[a,h]=i.reduce((([t,e],[r,n])=>n<e?[r,n]:[t,e]),["?",1/0]),u=n.sort(((t,e)=>e[1][0]-t[1][0])),l=t.map((t=>t[1])).reduce(((t,e)=>t+e),0);return e.push({round:e.length+1,sortedByHighest:u}),s>l/2||u.length<3?e:dN(t.map((t=>[t[0].filter((t=>t!=a)),t[1],t[2]])).filter((t=>t[0].length>0)),e)}function pN(t){const e=dN(t.map((t=>[t.choice,t.balance,t.scores])),[]);return e[e.length-1].sortedByHighest}class mN{constructor(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size&&t.length>0&&t.length===e.length}getValidVotes(){return this.votes.filter((t=>mN.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return function(t,e){const r=pN(t);return e.choices.map(((t,e)=>r.filter((t=>Number(t[0])===e+1)).reduce(((t,e)=>t+e[1][0]),0)))}(this.getValidVotes(),this.proposal)}getScoresByStrategy(){const t=pN(this.getValidVotes());return this.proposal.choices.map(((e,r)=>this.strategies.map(((e,n)=>t.filter((t=>Number(t[0])===r+1)).reduce(((t,e)=>t+e[1][1][n]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected.map((t=>{if(this.proposal.choices[t-1])return this.proposal.choices[t-1]})).map(((t,e)=>`(${LN(e+1)}) ${t}`)).join(", ")}}function gN(t,e,r){const n=r.reduce(((t,e)=>t+e),0),i=e[t]/n*100;return isNaN(i)?0:i}function yN(t,e,r){return gN(t+1,e,Object.values(e))/100*r}class vN{constructor(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>vN.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.proposal.choices.map(((t,e)=>this.getValidVotes().map((t=>yN(e,t.choice,t.balance))).reduce(((t,e)=>t+e),0))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((e,r)=>gN(r,t,t))).map((t=>e/100*t))}getScoresByStrategy(){const t=this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().map((t=>yN(e,t.choice,t.scores[r]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[t])))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((r,n)=>this.strategies.map(((e,r)=>gN(0,t[n][r],t.flat(2)))).map((t=>[e/100*t])).flat()))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1])return`${Math.round(10*gN(e+1,this.selected,Object.values(this.selected)))/10}% for ${t}`})).filter((t=>null!=t)).join(", ")}}var wN={"single-choice":sN,approval:aN,quadratic:fN,"ranked-choice":mN,weighted:vN,basic:sN};const bN={1:"https://subgrapher.snapshot.org/delegation/1",10:"https://subgrapher.snapshot.org/delegation/10",56:"https://subgrapher.snapshot.org/delegation/56",100:"https://subgrapher.snapshot.org/delegation/100",137:"https://subgrapher.snapshot.org/delegation/137",250:"https://subgrapher.snapshot.org/delegation/250",42161:"https://subgrapher.snapshot.org/delegation/42161",11155111:"https://subgrapher.snapshot.org/delegation/11155111"},_N=1e3;function EN(t){return t.length===_N&&t[0].timestamp===t[t.length-1].timestamp}function AN(t,e){const r=function(t){return`${t.delegator}-${t.delegate}-${t.space}`}(e);t.has(r)||t.set(r,e)}function kN(t){const e=["",t];return t.includes(".eth")&&e.push(t.replace(".eth","")),e}function MN(t){return e(this,arguments,void 0,(function*({url:t,spaces:e,pivot:r,snapshot:n}){const i={delegations:{__args:{where:{space_in:e,timestamp_gte:r},first:_N,skip:0,orderBy:"timestamp",orderDirection:"asc"},delegator:!0,space:!0,delegate:!0,timestamp:!0}};return"latest"!==n&&(i.delegations.__args.block={number:n}),(yield BN(t,i)).delegations||[]}))}const xN=["function text(bytes32 node, string calldata key) external view returns (string memory)"],SN={Accept:"application/json","Content-Type":"application/json"},NN="https://score.snapshot.org";function IN(t=NN,e={path:""}){const r=new URL(t);e.path&&(r.pathname=e.path);const n=r.searchParams.get("apiKey");let i=Object.assign({},SN);return n&&(r.searchParams.delete("apiKey"),i=Object.assign(Object.assign({},SN),{"X-API-KEY":n})),{url:r.toString(),headers:i}}function CN(t){return e(this,void 0,void 0,(function*(){let e=yield t.text();try{e=JSON.parse(e)}catch(r){return Promise.reject({code:t.status||500,message:"Failed to parse response from score API",data:e})}return e.error?Promise.reject(e.error):e}))}const TN=new Ef({allErrors:!0,allowUnionTypes:!0,$data:!0,passContext:!0});xf(TN),Nf(TN),TN.addFormat("address",{validate:t=>{try{return Re(t)}catch(t){return!1}}}),TN.addFormat("starknetAddress",{validate:t=>{try{return HN(t)}catch(t){return!1}}}),TN.addFormat("long",{validate:()=>!0}),TN.addFormat("ethValue",{validate:t=>{if(!t.match(/^([0-9]|[1-9][0-9]+)(\.[0-9]+)?$/))return!1;try{return function(t,e){if("string"!=typeof t&&Ya.throwArgumentError("value must be a string","value",t),"string"==typeof e){const t=Wa.indexOf(e);-1!==t&&(e=3*t)}Ga(t,null!=e?e:18)}(t,18),!0}catch(t){return!1}}});const PN=Object.keys(oN),RN=Object.keys(oN).filter((t=>!oN[t].testnet));function ON(t,r,n,i){return e(this,void 0,void 0,(function*(){const e=new sa(n[0],r,t);try{const t=n[2]||[];return yield e[n[1]](...t,i||{})}catch(t){return Promise.reject(t)}}))}function $N(t,r,n,i,o){return e(this,void 0,void 0,(function*(){const e=(null==o?void 0:o.multicallAddress)||oN[t].multicall,s=new sa(e,["function aggregate(tuple(address target, bytes callData)[] calls) view returns (uint256 blockNumber, bytes[] returnData)"],r),a=new Yn(n);try{const t=(null==o?void 0:o.limit)||500;(null==o?void 0:o.limit)&&delete o.limit;const e=Math.ceil(i.length/t),r=[];Array.from(Array(e)).forEach(((e,n)=>{const h=i.slice(t*n,t*(n+1));r.push(s.aggregate(h.map((t=>[t[0].toLowerCase(),a.encodeFunctionData(t[1],t[2])])),o||{}))}));let n=yield Promise.all(r);return n=n.reduce(((t,[,e])=>t.concat(e)),[]),n.map(((t,e)=>a.decodeFunctionResult(i[e][1],t)))}catch(t){return Promise.reject(t)}}))}function BN(t,r){return e(this,arguments,void 0,(function*(t,e,r={}){const n=yield a(t,{method:"POST",headers:Object.assign({Accept:"application/json","Content-Type":"application/json"},null==r?void 0:r.headers),body:JSON.stringify({query:Ku.jsonToGraphQLQuery({query:e})})});let i=yield n.text();try{i=JSON.parse(i)}catch(e){throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${i.substring(0,400)}`)}if(i.errors)throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${JSON.stringify(i.errors).substring(0,400)}`);const{data:o}=i;return o||{}}))}function DN(t,e=iN[0]){const r=`https://${e}`;if(!t)return null;if(!(t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("https://")||t.startsWith("http://")))return`${r}/ipfs/${t}`;const n=t.split("://")[0];return"ipfs"===n?t.replace("ipfs://",`${r}/ipfs/`):"ipns"===n?t.replace("ipns://",`${r}/ipns/`):t}function FN(r,n){return e(this,arguments,void 0,(function*(e,r,n="1",i={}){const{ensResolvers:o,broviderUrl:s}=i,a=t(i,["ensResolvers","broviderUrl"]),h=o||oN[n].ensResolvers||oN[1].ensResolvers,u=du(fu(e)),l=cm(n,{broviderUrl:s});return(yield $N(n,l,xN,h.map((t=>[t,"text",[u,r]])),a)).flat().find((t=>t))||""}))}function UN(t){return e(this,arguments,void 0,(function*(t,e="1",r={}){try{return yield FN(t,"snapshot",e,r)}catch(t){return console.log(t),null}}))}function jN(t){return e(this,arguments,void 0,(function*(t,e="1",r={}){const n=cm(e,r),i=new sa("0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",["function owner(bytes32) view returns (address)"],n),o=r.ensNameWrapper||oN[e].ensNameWrapper,s=du(fu(t));let a=yield i.owner(s);if(a===o){const t=new sa(o,["function ownerOf(uint256) view returns (address)"],n);a=yield t.ownerOf(s)}return a}))}function LN(t){const e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])}function zN(t){return!!oN[t]}function qN(t){return Re(t)&&"0x0000000000000000000000000000000000000000"!==t}function VN(t,e){return"latest"===t||"number"==typeof t&&t>=oN[e].start}function HN(t){if(!t)return!1;try{return NS(t),!0}catch(t){return!1}}function GN(t){return Re(t)}function KN(t){return Promise.reject(new Error(t))}TN.addKeyword({keyword:"snapshotNetwork",validate:function(t,e){return"mainnet"===(this.snapshotEnv||"default")?RN.includes(e):PN.includes(e)},error:{message:"network not allowed"}}),TN.addKeyword({keyword:"maxLengthWithSpaceType",validate:function t(e,r){const n=this.spaceType||"default",i=r.length<=e[n];return i||(t.errors=[{keyword:"maxLengthWithSpaceType",message:`must NOT have more than ${e[n]} characters`,params:{limit:e[n]}}]),i},errors:!0}),TN.addKeyword({keyword:"maxItemsWithSpaceType",validate:function t(e,r){const n=this.spaceType||"default",i=r.length<=e[n];return i||(t.errors=[{keyword:"maxItemsWithSpaceType",message:`must NOT have more than ${e[n]} items`,params:{limit:e[n]}}]),i},errors:!0}),TN.addFormat("customUrl",{type:"string",validate:t=>!t.length||(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("snapshot://"))});var ZN={call:ON,multicall:$N,subgraphRequest:BN,ipfsGet:function(t,r){return e(this,arguments,void 0,(function*(t,e,r="ipfs"){return a(`https://${t}/${r}/${e}`).then((t=>t.json()))}))},getUrl:DN,getJSON:function(t){return e(this,arguments,void 0,(function*(t,e={}){const r=DN(t,e.gateways);return a(r).then((t=>t.json()))}))},sendTransaction:function(t,r,n,i,o){return e(this,arguments,void 0,(function*(t,e,r,n,i,o={}){const s=t.getSigner(),a=new sa(e,r,t).connect(s);return yield a[n](...i,o)}))},getScores:function(t,r,n,i){return e(this,arguments,void 0,(function*(t,e,r,n,i="latest",o=NN,s={}){if(!Array.isArray(n))return KN("addresses should be an array of addresses");if(0===n.length)return KN("addresses can not be empty");const h=n.find((t=>!qN(t)));if(h)return KN(`Invalid address: ${h}`);if(!zN(r))return KN(`Invalid network: ${r}`);const u=e.find((t=>t.network&&!zN(t.network)));if(u)return KN(`Invalid network (${u.network}) in strategy ${u.name}`);if(!VN(i,r))return KN(`Snapshot (${i}) must be 'latest' or greater than network start block (${oN[r].start})`);new URL(o).pathname="/api/scores";const{url:l,headers:c}=IN(o,{path:"/api/scores"});try{const o={space:t,network:r,snapshot:i,strategies:e,addresses:n},h=yield a(l,{method:"POST",headers:c,body:JSON.stringify({params:o})}),u=yield CN(h);return"all"===s.returnValue?u.result:u.result[s.returnValue||"scores"]}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},getVp:function(t,r,n,i,o,s,h){return e(this,void 0,void 0,(function*(){const{url:e,headers:u}=IN(null==h?void 0:h.url);if(!qN(t))return KN(`Invalid voter address: ${t}`);if(!zN(r))return KN(`Invalid network: ${r}`);const l=n.find((t=>t.network&&!zN(t.network)));if(l)return KN(`Invalid network (${l.network}) in strategy ${l.name}`);if(!VN(i,r))return KN(`Snapshot (${i}) must be 'latest' or greater than network start block (${oN[r].start})`);const c={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"get_vp",params:{address:t,network:r,strategies:n,snapshot:i,space:o,delegation:s}})};try{const t=yield a(e,c);return(yield CN(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},validateSchema:function(t,e,r={snapshotEnv:"default",spaceType:"default"}){const n=TN.compile(t),i=n.call(r,e);return i||n.errors},getEnsTextRecord:FN,getSpaceUri:UN,getEnsOwner:jN,getSpaceController:function(t){return e(this,arguments,void 0,(function*(t,e="1",r={}){const n=yield UN(t,e,r);if(n){let t=Re(n);if(t)return n;const e=n.split("/"),r=e.includes("testnet")?5:4,i=e[r];if(t=Re(i),t)return i}return yield jN(t,e,r)}))},getDelegatesBySpace:function(t,r){return e(this,arguments,void 0,(function*(t,e,r="latest",n={}){const i=n.subgraphUrl||bN[t];if(!i)return Promise.reject(`Delegation subgraph not available for network ${t}`);let o=0;const s=new Map,a=kN(e);for(;;){const t=yield MN({url:i,spaces:a,pivot:o,snapshot:r});if(EN(t))throw new Error("Unable to paginate delegation");if(t.forEach((t=>{AN(s,t),o=t.timestamp})),t.length<_N)break}return[...s.values()]}))},clone:function(t){return JSON.parse(JSON.stringify(t))},sleep:function(t){return e(this,void 0,void 0,(function*(){return new Promise((e=>{setTimeout(e,t)}))}))},getNumberWithOrdinal:LN,voting:wN,getProvider:cm,signMessage:function(t,r,n){return e(this,void 0,void 0,(function*(){return r=I(new Buffer(r,"utf8")),yield t.send("personal_sign",[r,n])}))},getBlockNumber:function(t){return e(this,void 0,void 0,(function*(){try{const e=yield t.getBlockNumber();return parseInt(e)}catch(t){return Promise.reject()}}))},Multicaller:class{constructor(t,e,r,n){this.options={},this.calls=[],this.paths=[],this.network=t,this.provider=e,this.abi=r,this.options=n||{}}call(t,e,r,n){return this.calls.push([e,r,n]),this.paths.push(t),this}execute(t){return e(this,void 0,void 0,(function*(){const e=t||{};return(yield $N(this.network,this.provider,this.abi,this.calls,this.options)).forEach(((t,r)=>_d(e,this.paths[r],t.length>1?t:t[0]))),this.calls=[],this.paths=[],e}))}},getSnapshots:function(t,r,n,i){return e(this,arguments,void 0,(function*(t,e,r,n,i={}){const o={};if(n.forEach((t=>o[t]="latest")),"latest"===e)return o;const s=`${t}-${e}-${n.join("-")}`,a=Ed[s],h=Date.now();if(a&&Ad>h)return a;Ad<h&&(Ed={},Ad=h+36e5-h%36e5),o[t]=e;const u=Object.keys(o).filter((e=>t!==e));if(0===u.length)return o;const l={blocks:{__args:{where:{ts:(yield r.getBlock(e)).timestamp,network_in:u}},network:!0,number:!0}},c=i.blockFinderUrl||"https://blockfinder.snapshot.org";return(yield BN(c,l)).blocks.forEach((t=>o[t.network]=t.number)),Ed[s]=o,o}))},getHash:function(t,e){return(PS(t)?OS:nN).getHash(t,e)},verify:function(t,r,n){return e(this,arguments,void 0,(function*(t,e,r,n="1",i={}){if(!HN(t)&&!GN(t))throw new Error("Invalid address");const o=PS(r)?OS:nN;return yield o.default(t,e,r,n,i)}))},validate:function(t,r,n,i,o,s,h){return e(this,void 0,void 0,(function*(){if(!qN(r))return KN(`Invalid author: ${r}`);if(!zN(i))return KN(`Invalid network: ${i}`);if(!VN(o,i))return KN(`Snapshot (${o}) must be 'latest' or greater than network start block (${oN[i].start})`);h||(h={});const{url:e,headers:u}=IN(h.url),l={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"validate",params:{validation:t,author:r,space:n,network:i,snapshot:o,params:s}})};try{const t=yield a(e,l);return(yield CN(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},isStarknetAddress:HN,isEvmAddress:GN,getFormattedAddress:function(t,e=["evm","starknet"]){if(e.includes("evm")&&Re(t))return Pe(t);if(e.includes("starknet")&&HN(t))return NS(t);throw new Error(`Invalid address: ${t}`)},SNAPSHOT_SUBGRAPH_URL:bN};return{Client:or,Client712:or,schemas:dr,utils:ZN}}));
|
|
32
|
+
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */(r);return o("function"==typeof e?e.call({"":t},"",t):t,"");function o(t,s){if(Array.isArray(n)){var a=n.find((function(e){return e.test(t)}));if(a){var h=a.stringify(t);if("string"!=typeof h||!iv(h))throw new Error("Invalid JSON number: output of a number stringifier must be a string containing a JSON number "+"(output: ".concat(h,")"));return h}}return"boolean"==typeof t||"number"==typeof t||"string"==typeof t||null===t||t instanceof Date||t instanceof Boolean||t instanceof Number||t instanceof String?JSON.stringify(t):t&&t.isLosslessNumber||"bigint"==typeof t?t.toString():Array.isArray(t)?function(t,r){if(0===t.length)return"[]";for(var n=i?r+i:void 0,s=i?"[\n":"[",a=0;a<t.length;a++){var h="function"==typeof e?e.call(t,String(a),t[a]):t[a];i&&(s+=n),s+=void 0!==h&&"function"!=typeof h?o(h,n):"null",a<t.length-1&&(s+=i?",\n":",")}return s+=i?"\n"+r+"]":"]"}(t,s):t&&"object"===iw(t)?function(t,n){if("function"==typeof t.toJSON)return ow(t.toJSON(),e,r,void 0);var s=Array.isArray(e)?e.map(String):Object.keys(t);if(0===s.length)return"{}";var a=i?n+i:void 0,h=!0,u=i?"{\n":"{";return s.forEach((function(r){var n="function"==typeof e?e.call(t,r,t[r]):t[r];if(function(t,e){return void 0!==e&&"function"!=typeof e&&"symbol"!==iw(e)}(0,n)){h?h=!1:u+=i?",\n":",";var s=JSON.stringify(r);u+=i?a+s+": ":s+":",u+=o(n,a)}})),u+=i?"\n"+n+"}":"}"}(t,s):void 0}}function sw(t){let e=t.length;for(;--e>=0;)t[e]=0}const aw=256,hw=286,uw=30,lw=15,cw=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),fw=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),dw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),pw=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mw=new Array(576);sw(mw);const gw=new Array(60);sw(gw);const yw=new Array(512);sw(yw);const vw=new Array(256);sw(vw);const ww=new Array(29);sw(ww);const bw=new Array(uw);function _w(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let Ew,Aw,kw;function Mw(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}sw(bw);const xw=t=>t<256?yw[t]:yw[256+(t>>>7)],Sw=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},Nw=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,Sw(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},Iw=(t,e,r)=>{Nw(t,r[2*e],r[2*e+1])},Cw=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},Tw=(t,e,r)=>{const n=new Array(16);let i,o,s=0;for(i=1;i<=lw;i++)s=s+r[i-1]<<1,n[i]=s;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=Cw(n[e]++,e))}},Pw=t=>{let e;for(e=0;e<hw;e++)t.dyn_ltree[2*e]=0;for(e=0;e<uw;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},Rw=t=>{t.bi_valid>8?Sw(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},Ow=(t,e,r,n)=>{const i=2*e,o=2*r;return t[i]<t[o]||t[i]===t[o]&&n[e]<=n[r]},$w=(t,e,r)=>{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i<t.heap_len&&Ow(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!Ow(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n},Bw=(t,e,r)=>{let n,i,o,s,a=0;if(0!==t.sym_next)do{n=255&t.pending_buf[t.sym_buf+a++],n+=(255&t.pending_buf[t.sym_buf+a++])<<8,i=t.pending_buf[t.sym_buf+a++],0===n?Iw(t,i,e):(o=vw[i],Iw(t,o+aw+1,e),s=cw[o],0!==s&&(i-=ww[o],Nw(t,i,s)),n--,o=xw(n),Iw(t,o,r),s=fw[o],0!==s&&(n-=bw[o],Nw(t,n,s)))}while(a<t.sym_next);Iw(t,256,e)},Dw=(t,e)=>{const r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,o=e.stat_desc.elems;let s,a,h,u=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<o;s++)0!==r[2*s]?(t.heap[++t.heap_len]=u=s,t.depth[s]=0):r[2*s+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=u<2?++u:0,r[2*h]=1,t.depth[h]=0,t.opt_len--,i&&(t.static_len-=n[2*h+1]);for(e.max_code=u,s=t.heap_len>>1;s>=1;s--)$w(t,r,s);h=o;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],$w(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,r[2*h]=r[2*s]+r[2*a],t.depth[h]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,r[2*s+1]=r[2*a+1]=h,t.heap[1]=h++,$w(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,h=e.stat_desc.max_length;let u,l,c,f,d,p,m=0;for(f=0;f<=lw;f++)t.bl_count[f]=0;for(r[2*t.heap[t.heap_max]+1]=0,u=t.heap_max+1;u<573;u++)l=t.heap[u],f=r[2*r[2*l+1]+1]+1,f>h&&(f=h,m++),r[2*l+1]=f,l>n||(t.bl_count[f]++,d=0,l>=a&&(d=s[l-a]),p=r[2*l],t.opt_len+=p*(f+d),o&&(t.static_len+=p*(i[2*l+1]+d)));if(0!==m){do{for(f=h-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[h]--,m-=2}while(m>0);for(f=h;0!==f;f--)for(l=t.bl_count[f];0!==l;)c=t.heap[--u],c>n||(r[2*c+1]!==f&&(t.opt_len+=(f-r[2*c+1])*r[2*c],r[2*c+1]=f),l--)}})(t,e),Tw(r,u,t.bl_count)},Fw=(t,e,r)=>{let n,i,o=-1,s=e[1],a=0,h=7,u=4;for(0===s&&(h=138,u=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=e[2*(n+1)+1],++a<h&&i===s||(a<u?t.bl_tree[2*i]+=a:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,o=i,0===s?(h=138,u=3):i===s?(h=6,u=3):(h=7,u=4))},Uw=(t,e,r)=>{let n,i,o=-1,s=e[1],a=0,h=7,u=4;for(0===s&&(h=138,u=3),n=0;n<=r;n++)if(i=s,s=e[2*(n+1)+1],!(++a<h&&i===s)){if(a<u)do{Iw(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==o&&(Iw(t,i,t.bl_tree),a--),Iw(t,16,t.bl_tree),Nw(t,a-3,2)):a<=10?(Iw(t,17,t.bl_tree),Nw(t,a-3,3)):(Iw(t,18,t.bl_tree),Nw(t,a-11,7));a=0,o=i,0===s?(h=138,u=3):i===s?(h=6,u=3):(h=7,u=4)}};let jw=!1;const Lw=(t,e,r,n)=>{Nw(t,0+(n?1:0),3),Rw(t),Sw(t,r),Sw(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r};var zw=t=>{jw||((()=>{let t,e,r,n,i;const o=new Array(16);for(r=0,n=0;n<28;n++)for(ww[n]=r,t=0;t<1<<cw[n];t++)vw[r++]=n;for(vw[r-1]=n,i=0,n=0;n<16;n++)for(bw[n]=i,t=0;t<1<<fw[n];t++)yw[i++]=n;for(i>>=7;n<uw;n++)for(bw[n]=i<<7,t=0;t<1<<fw[n]-7;t++)yw[256+i++]=n;for(e=0;e<=lw;e++)o[e]=0;for(t=0;t<=143;)mw[2*t+1]=8,t++,o[8]++;for(;t<=255;)mw[2*t+1]=9,t++,o[9]++;for(;t<=279;)mw[2*t+1]=7,t++,o[7]++;for(;t<=287;)mw[2*t+1]=8,t++,o[8]++;for(Tw(mw,287,o),t=0;t<uw;t++)gw[2*t+1]=5,gw[2*t]=Cw(t,5);Ew=new _w(mw,cw,257,hw,lw),Aw=new _w(gw,fw,0,uw,lw),kw=new _w(new Array(0),dw,0,19,7)})(),jw=!0),t.l_desc=new Mw(t.dyn_ltree,Ew),t.d_desc=new Mw(t.dyn_dtree,Aw),t.bl_desc=new Mw(t.bl_tree,kw),t.bi_buf=0,t.bi_valid=0,Pw(t)},qw=(t,e,r,n)=>{let i,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<aw;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Dw(t,t.l_desc),Dw(t,t.d_desc),s=(t=>{let e;for(Fw(t,t.dyn_ltree,t.l_desc.max_code),Fw(t,t.dyn_dtree,t.d_desc.max_code),Dw(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*pw[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==e?Lw(t,e,r,n):4===t.strategy||o===i?(Nw(t,2+(n?1:0),3),Bw(t,mw,gw)):(Nw(t,4+(n?1:0),3),((t,e,r,n)=>{let i;for(Nw(t,e-257,5),Nw(t,r-1,5),Nw(t,n-4,4),i=0;i<n;i++)Nw(t,t.bl_tree[2*pw[i]+1],3);Uw(t,t.dyn_ltree,e-1),Uw(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),Bw(t,t.dyn_ltree,t.dyn_dtree)),Pw(t),n&&Rw(t)},Vw=(t,e,r)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(vw[r]+aw+1)]++,t.dyn_dtree[2*xw(e)]++),t.sym_next===t.sym_end),Hw=t=>{Nw(t,2,3),Iw(t,256,mw),(t=>{16===t.bi_valid?(Sw(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)},Gw={_tr_init:zw,_tr_stored_block:Lw,_tr_flush_block:qw,_tr_tally:Vw,_tr_align:Hw};var Kw=(t,e,r,n)=>{let i=65535&t|0,o=t>>>16&65535|0,s=0;for(;0!==r;){s=r>2e3?2e3:r,r-=s;do{i=i+e[n++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const Zw=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var Jw=(t,e,r,n)=>{const i=Zw,o=n+r;t^=-1;for(let r=n;r<o;r++)t=t>>>8^i[255&(t^e[r])];return-1^t},Qw={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Yw={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ww,_tr_stored_block:Xw,_tr_flush_block:tb,_tr_tally:eb,_tr_align:rb}=Gw,{Z_NO_FLUSH:nb,Z_PARTIAL_FLUSH:ib,Z_FULL_FLUSH:ob,Z_FINISH:sb,Z_BLOCK:ab,Z_OK:hb,Z_STREAM_END:ub,Z_STREAM_ERROR:lb,Z_DATA_ERROR:cb,Z_BUF_ERROR:fb,Z_DEFAULT_COMPRESSION:db,Z_FILTERED:pb,Z_HUFFMAN_ONLY:mb,Z_RLE:gb,Z_FIXED:yb,Z_DEFAULT_STRATEGY:vb,Z_UNKNOWN:wb,Z_DEFLATED:bb}=Yw,_b=258,Eb=262,Ab=42,kb=113,Mb=666,xb=(t,e)=>(t.msg=Qw[e],e),Sb=t=>2*t-(t>4?9:0),Nb=t=>{let e=t.length;for(;--e>=0;)t[e]=0},Ib=t=>{let e,r,n,i=t.w_size;e=t.hash_size,n=e;do{r=t.head[--n],t.head[n]=r>=i?r-i:0}while(--e);e=i,n=e;do{r=t.prev[--n],t.prev[n]=r>=i?r-i:0}while(--e)};let Cb=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const Tb=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},Pb=(t,e)=>{tb(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Tb(t.strm)},Rb=(t,e)=>{t.pending_buf[t.pending++]=e},Ob=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},$b=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=Kw(t.adler,e,i,r):2===t.state.wrap&&(t.adler=Jw(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},Bb=(t,e)=>{let r,n,i=t.max_chain_length,o=t.strstart,s=t.prev_length,a=t.nice_match;const h=t.strstart>t.w_size-Eb?t.strstart-(t.w_size-Eb):0,u=t.window,l=t.w_mask,c=t.prev,f=t.strstart+_b;let d=u[o+s-1],p=u[o+s];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(r=e,u[r+s]===p&&u[r+s-1]===d&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<f);if(n=_b-(f-o),o=f-_b,n>s){if(t.match_start=e,s=n,n>=a)break;d=u[o+s-1],p=u[o+s]}}}while((e=c[e&l])>h&&0!=--i);return s<=t.lookahead?s:t.lookahead},Db=t=>{const e=t.w_size;let r,n,i;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-Eb)&&(t.window.set(t.window.subarray(e,e+e-n),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),Ib(t),n+=e),0===t.strm.avail_in)break;if(r=$b(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=r,t.lookahead+t.insert>=3)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=Cb(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=Cb(t,t.ins_h,t.window[i+3-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<Eb&&0!==t.strm.avail_in)},Fb=(t,e)=>{let r,n,i,o=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,s=0,a=t.strm.avail_in;do{if(r=65535,i=t.bi_valid+42>>3,t.strm.avail_out<i)break;if(i=t.strm.avail_out-i,n=t.strstart-t.block_start,r>n+t.strm.avail_in&&(r=n+t.strm.avail_in),r>i&&(r=i),r<o&&(0===r&&e!==sb||e===nb||r!==n+t.strm.avail_in))break;s=e===sb&&r===n+t.strm.avail_in?1:0,Xw(t,0,0,s),t.pending_buf[t.pending-4]=r,t.pending_buf[t.pending-3]=r>>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,Tb(t.strm),n&&(n>r&&(n=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,r-=n),r&&($b(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===s);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),s?4:e!==nb&&e!==sb&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(i=t.window_size-t.strstart,t.strm.avail_in>i&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,i+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),i>t.strm.avail_in&&(i=t.strm.avail_in),i&&($b(t.strm,t.window,t.strstart,i),t.strstart+=i,t.insert+=i>t.w_size-t.insert?t.w_size-t.insert:i),t.high_water<t.strstart&&(t.high_water=t.strstart),i=t.bi_valid+42>>3,i=t.pending_buf_size-i>65535?65535:t.pending_buf_size-i,o=i>t.w_size?t.w_size:i,n=t.strstart-t.block_start,(n>=o||(n||e===sb)&&e!==nb&&0===t.strm.avail_in&&n<=i)&&(r=n>i?i:n,s=e===sb&&0===t.strm.avail_in&&r===n?1:0,Xw(t,t.block_start,r,s),t.block_start+=r,Tb(t.strm)),s?3:1)},Ub=(t,e)=>{let r,n;for(;;){if(t.lookahead<Eb){if(Db(t),t.lookahead<Eb&&e===nb)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=Cb(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-Eb&&(t.match_length=Bb(t,r)),t.match_length>=3)if(n=eb(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=Cb(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=Cb(t,t.ins_h,t.window[t.strstart+1]);else n=eb(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Pb(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===sb?(Pb(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Pb(t,!1),0===t.strm.avail_out)?1:2},jb=(t,e)=>{let r,n,i;for(;;){if(t.lookahead<Eb){if(Db(t),t.lookahead<Eb&&e===nb)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=Cb(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-Eb&&(t.match_length=Bb(t,r),t.match_length<=5&&(t.strategy===pb||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=eb(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=Cb(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(Pb(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=eb(t,0,t.window[t.strstart-1]),n&&Pb(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=eb(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===sb?(Pb(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Pb(t,!1),0===t.strm.avail_out)?1:2};function Lb(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}const zb=[new Lb(0,0,0,0,Fb),new Lb(4,4,8,4,Ub),new Lb(4,5,16,8,Ub),new Lb(4,6,32,32,Ub),new Lb(4,4,16,16,jb),new Lb(8,16,32,32,jb),new Lb(8,16,128,128,jb),new Lb(8,32,128,256,jb),new Lb(32,128,258,1024,jb),new Lb(32,258,258,4096,jb)];function qb(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=bb,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Nb(this.dyn_ltree),Nb(this.dyn_dtree),Nb(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Nb(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Nb(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Vb=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==Ab&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==kb&&e.status!==Mb?1:0},Hb=t=>{if(Vb(t))return xb(t,lb);t.total_in=t.total_out=0,t.data_type=wb;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?Ab:kb,t.adler=2===e.wrap?0:1,e.last_flush=-2,Ww(e),hb},Gb=t=>{const e=Hb(t);return e===hb&&(t=>{t.window_size=2*t.w_size,Nb(t.head),t.max_lazy_match=zb[t.level].max_lazy,t.good_match=zb[t.level].good_length,t.nice_match=zb[t.level].nice_length,t.max_chain_length=zb[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0})(t.state),e},Kb=(t,e,r,n,i,o)=>{if(!t)return lb;let s=1;if(e===db&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>9||r!==bb||n<8||n>15||e<0||e>9||o<0||o>yb||8===n&&1!==s)return xb(t,lb);8===n&&(n=9);const a=new qb;return t.state=a,a.strm=t,a.status=Ab,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=o,a.method=r,Gb(t)};var Zb=(t,e)=>{if(Vb(t)||e>ab||e<0)return t?xb(t,lb):lb;const r=t.state;if(!t.output||0!==t.avail_in&&!t.input||r.status===Mb&&e!==sb)return xb(t,0===t.avail_out?fb:lb);const n=r.last_flush;if(r.last_flush=e,0!==r.pending){if(Tb(t),0===t.avail_out)return r.last_flush=-1,hb}else if(0===t.avail_in&&Sb(e)<=Sb(n)&&e!==sb)return xb(t,fb);if(r.status===Mb&&0!==t.avail_in)return xb(t,fb);if(r.status===Ab&&0===r.wrap&&(r.status=kb),r.status===Ab){let e=bb+(r.w_bits-8<<4)<<8,n=-1;if(n=r.strategy>=mb||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=n<<6,0!==r.strstart&&(e|=32),e+=31-e%31,Ob(r,e),0!==r.strstart&&(Ob(r,t.adler>>>16),Ob(r,65535&t.adler)),t.adler=1,r.status=kb,Tb(t),0!==r.pending)return r.last_flush=-1,hb}if(57===r.status)if(t.adler=0,Rb(r,31),Rb(r,139),Rb(r,8),r.gzhead)Rb(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Rb(r,255&r.gzhead.time),Rb(r,r.gzhead.time>>8&255),Rb(r,r.gzhead.time>>16&255),Rb(r,r.gzhead.time>>24&255),Rb(r,9===r.level?2:r.strategy>=mb||r.level<2?4:0),Rb(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Rb(r,255&r.gzhead.extra.length),Rb(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=Jw(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(Rb(r,0),Rb(r,0),Rb(r,0),Rb(r,0),Rb(r,0),Rb(r,9===r.level?2:r.strategy>=mb||r.level<2?4:0),Rb(r,3),r.status=kb,Tb(t),0!==r.pending)return r.last_flush=-1,hb;if(69===r.status){if(r.gzhead.extra){let e=r.pending,n=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+n>r.pending_buf_size;){let i=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>e&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex+=i,Tb(t),0!==r.pending)return r.last_flush=-1,hb;e=0,n-=i}let i=new Uint8Array(r.gzhead.extra);r.pending_buf.set(i.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending+=n,r.gzhead.hcrc&&r.pending>e&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let e,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-n,n)),Tb(t),0!==r.pending)return r.last_flush=-1,hb;n=0}e=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,Rb(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>n&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let e,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-n,n)),Tb(t),0!==r.pending)return r.last_flush=-1,hb;n=0}e=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,Rb(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>n&&(t.adler=Jw(t.adler,r.pending_buf,r.pending-n,n))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(Tb(t),0!==r.pending))return r.last_flush=-1,hb;Rb(r,255&t.adler),Rb(r,t.adler>>8&255),t.adler=0}if(r.status=kb,Tb(t),0!==r.pending)return r.last_flush=-1,hb}if(0!==t.avail_in||0!==r.lookahead||e!==nb&&r.status!==Mb){let n=0===r.level?Fb(r,e):r.strategy===mb?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(Db(t),0===t.lookahead)){if(e===nb)return 1;break}if(t.match_length=0,r=eb(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(Pb(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===sb?(Pb(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Pb(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===gb?((t,e)=>{let r,n,i,o;const s=t.window;for(;;){if(t.lookahead<=_b){if(Db(t),t.lookahead<=_b&&e===nb)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){o=t.strstart+_b;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<o);t.match_length=_b-(o-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=eb(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=eb(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(Pb(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===sb?(Pb(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Pb(t,!1),0===t.strm.avail_out)?1:2})(r,e):zb[r.level].func(r,e);if(3!==n&&4!==n||(r.status=Mb),1===n||3===n)return 0===t.avail_out&&(r.last_flush=-1),hb;if(2===n&&(e===ib?rb(r):e!==ab&&(Xw(r,0,0,!1),e===ob&&(Nb(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),Tb(t),0===t.avail_out))return r.last_flush=-1,hb}return e!==sb?hb:r.wrap<=0?ub:(2===r.wrap?(Rb(r,255&t.adler),Rb(r,t.adler>>8&255),Rb(r,t.adler>>16&255),Rb(r,t.adler>>24&255),Rb(r,255&t.total_in),Rb(r,t.total_in>>8&255),Rb(r,t.total_in>>16&255),Rb(r,t.total_in>>24&255)):(Ob(r,t.adler>>>16),Ob(r,65535&t.adler)),Tb(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?hb:ub)},Jb=(t,e)=>{let r=e.length;if(Vb(t))return lb;const n=t.state,i=n.wrap;if(2===i||1===i&&n.status!==Ab||n.lookahead)return lb;if(1===i&&(t.adler=Kw(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(Nb(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const o=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,Db(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=Cb(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,Db(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=s,t.input=a,t.avail_in=o,n.wrap=i,hb},Qb={deflateInit:(t,e)=>Kb(t,e,bb,15,8,vb),deflateInit2:Kb,deflateReset:Gb,deflateResetKeep:Hb,deflateSetHeader:(t,e)=>Vb(t)||2!==t.state.wrap?lb:(t.state.gzhead=e,hb),deflate:Zb,deflateEnd:t=>{if(Vb(t))return lb;const e=t.state.status;return t.state=null,e===kb?xb(t,cb):hb},deflateSetDictionary:Jb,deflateInfo:"pako deflate (from Nodeca project)"};const Yb=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Wb=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)Yb(r,e)&&(t[e]=r[e])}}return t},Xb=t=>{let e=0;for(let r=0,n=t.length;r<n;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,n=0,i=t.length;e<i;e++){let i=t[e];r.set(i,n),n+=i.length}return r};let t_=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){t_=!1}const e_=new Uint8Array(256);for(let t=0;t<256;t++)e_[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;e_[254]=e_[254]=1;var r_=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,i,o,s=t.length,a=0;for(i=0;i<s;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<s&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),o=0,i=0;o<a;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<s&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[o++]=r:r<2048?(e[o++]=192|r>>>6,e[o++]=128|63&r):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|63&r):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|63&r);return e},n_=(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,i;const o=new Array(2*r);for(i=0,n=0;n<r;){let e=t[n++];if(e<128){o[i++]=e;continue}let s=e_[e];if(s>4)o[i++]=65533,n+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&n<r;)e=e<<6|63&t[n++],s--;s>1?o[i++]=65533:e<65536?o[i++]=e:(e-=65536,o[i++]=55296|e>>10&1023,o[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&t_)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r})(o,i)},i_=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+e_[t[r]]>e?r:e};var o_=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const s_=Object.prototype.toString,{Z_NO_FLUSH:a_,Z_SYNC_FLUSH:h_,Z_FULL_FLUSH:u_,Z_FINISH:l_,Z_OK:c_,Z_STREAM_END:f_,Z_DEFAULT_COMPRESSION:d_,Z_DEFAULT_STRATEGY:p_,Z_DEFLATED:m_}=Yw;function g_(t){this.options=Wb({level:d_,method:m_,chunkSize:16384,windowBits:15,memLevel:8,strategy:p_},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o_,this.strm.avail_out=0;let r=Qb.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==c_)throw new Error(Qw[r]);if(e.header&&Qb.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?r_(e.dictionary):"[object ArrayBuffer]"===s_.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=Qb.deflateSetDictionary(this.strm,t),r!==c_)throw new Error(Qw[r]);this._dict_set=!0}}function y_(t,e){const r=new g_(e);if(r.push(t,!0),r.err)throw r.msg||Qw[r.err];return r.result}g_.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=e===~~e?e:!0===e?l_:a_,"string"==typeof t?r.input=r_(t):"[object ArrayBuffer]"===s_.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(o===h_||o===u_)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(i=Qb.deflate(r,o),i===f_)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Qb.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===c_;if(0!==r.avail_out){if(o>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},g_.prototype.onData=function(t){this.chunks.push(t)},g_.prototype.onEnd=function(t){t===c_&&(this.result=Xb(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var v_={Deflate:g_,deflate:y_,deflateRaw:function(t,e){return(e=e||{}).raw=!0,y_(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,y_(t,e)},constants:Yw};const w_=16209;var b_=function(t,e){let r,n,i,o,s,a,h,u,l,c,f,d,p,m,g,y,v,w,b,_,E,A,k,M;const x=t.state;r=t.next_in,k=t.input,n=r+(t.avail_in-5),i=t.next_out,M=t.output,o=i-(e-t.avail_out),s=i+(t.avail_out-257),a=x.dmax,h=x.wsize,u=x.whave,l=x.wnext,c=x.window,f=x.hold,d=x.bits,p=x.lencode,m=x.distcode,g=(1<<x.lenbits)-1,y=(1<<x.distbits)-1;t:do{d<15&&(f+=k[r++]<<d,d+=8,f+=k[r++]<<d,d+=8),v=p[f&g];e:for(;;){if(w=v>>>24,f>>>=w,d-=w,w=v>>>16&255,0===w)M[i++]=65535&v;else{if(!(16&w)){if(0==(64&w)){v=p[(65535&v)+(f&(1<<w)-1)];continue e}if(32&w){x.mode=16191;break t}t.msg="invalid literal/length code",x.mode=w_;break t}b=65535&v,w&=15,w&&(d<w&&(f+=k[r++]<<d,d+=8),b+=f&(1<<w)-1,f>>>=w,d-=w),d<15&&(f+=k[r++]<<d,d+=8,f+=k[r++]<<d,d+=8),v=m[f&y];r:for(;;){if(w=v>>>24,f>>>=w,d-=w,w=v>>>16&255,!(16&w)){if(0==(64&w)){v=m[(65535&v)+(f&(1<<w)-1)];continue r}t.msg="invalid distance code",x.mode=w_;break t}if(_=65535&v,w&=15,d<w&&(f+=k[r++]<<d,d+=8,d<w&&(f+=k[r++]<<d,d+=8)),_+=f&(1<<w)-1,_>a){t.msg="invalid distance too far back",x.mode=w_;break t}if(f>>>=w,d-=w,w=i-o,_>w){if(w=_-w,w>u&&x.sane){t.msg="invalid distance too far back",x.mode=w_;break t}if(E=0,A=c,0===l){if(E+=h-w,w<b){b-=w;do{M[i++]=c[E++]}while(--w);E=i-_,A=M}}else if(l<w){if(E+=h+l-w,w-=l,w<b){b-=w;do{M[i++]=c[E++]}while(--w);if(E=0,l<b){w=l,b-=w;do{M[i++]=c[E++]}while(--w);E=i-_,A=M}}}else if(E+=l-w,w<b){b-=w;do{M[i++]=c[E++]}while(--w);E=i-_,A=M}for(;b>2;)M[i++]=A[E++],M[i++]=A[E++],M[i++]=A[E++],b-=3;b&&(M[i++]=A[E++],b>1&&(M[i++]=A[E++]))}else{E=i-_;do{M[i++]=M[E++],M[i++]=M[E++],M[i++]=M[E++],b-=3}while(b>2);b&&(M[i++]=M[E++],b>1&&(M[i++]=M[E++]))}break}}break}}while(r<n&&i<s);b=d>>3,r-=b,d-=b<<3,f&=(1<<d)-1,t.next_in=r,t.next_out=i,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=i<s?s-i+257:257-(i-s),x.hold=f,x.bits=d};const __=15,E_=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),A_=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),k_=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),M_=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var x_=(t,e,r,n,i,o,s,a)=>{const h=a.bits;let u,l,c,f,d,p,m=0,g=0,y=0,v=0,w=0,b=0,_=0,E=0,A=0,k=0,M=null;const x=new Uint16Array(16),S=new Uint16Array(16);let N,I,C,T=null;for(m=0;m<=__;m++)x[m]=0;for(g=0;g<n;g++)x[e[r+g]]++;for(w=h,v=__;v>=1&&0===x[v];v--);if(w>v&&(w=v),0===v)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(y=1;y<v&&0===x[y];y++);for(w<y&&(w=y),E=1,m=1;m<=__;m++)if(E<<=1,E-=x[m],E<0)return-1;if(E>0&&(0===t||1!==v))return-1;for(S[1]=0,m=1;m<__;m++)S[m+1]=S[m]+x[m];for(g=0;g<n;g++)0!==e[r+g]&&(s[S[e[r+g]]++]=g);if(0===t?(M=T=s,p=20):1===t?(M=E_,T=A_,p=257):(M=k_,T=M_,p=0),k=0,g=0,m=y,d=o,b=w,_=0,c=-1,A=1<<w,f=A-1,1===t&&A>852||2===t&&A>592)return 1;for(;;){N=m-_,s[g]+1<p?(I=0,C=s[g]):s[g]>=p?(I=T[s[g]-p],C=M[s[g]-p]):(I=96,C=0),u=1<<m-_,l=1<<b,y=l;do{l-=u,i[d+(k>>_)+l]=N<<24|I<<16|C|0}while(0!==l);for(u=1<<m-1;k&u;)u>>=1;if(0!==u?(k&=u-1,k+=u):k=0,g++,0==--x[m]){if(m===v)break;m=e[r+s[g]]}if(m>w&&(k&f)!==c){for(0===_&&(_=w),d+=y,b=m-_,E=1<<b;b+_<v&&(E-=x[b+_],!(E<=0));)b++,E<<=1;if(A+=1<<b,1===t&&A>852||2===t&&A>592)return 1;c=k&f,i[c]=w<<24|b<<16|d-o|0}}return 0!==k&&(i[d+k]=m-_<<24|64<<16|0),a.bits=w,0};const{Z_FINISH:S_,Z_BLOCK:N_,Z_TREES:I_,Z_OK:C_,Z_STREAM_END:T_,Z_NEED_DICT:P_,Z_STREAM_ERROR:R_,Z_DATA_ERROR:O_,Z_MEM_ERROR:$_,Z_BUF_ERROR:B_,Z_DEFLATED:D_}=Yw,F_=16180,U_=16190,j_=16191,L_=16192,z_=16194,q_=16199,V_=16200,H_=16206,G_=16209,K_=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Z_(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const J_=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<F_||e.mode>16211?1:0},Q_=t=>{if(J_(t))return R_;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=F_,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,C_},Y_=t=>{if(J_(t))return R_;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Q_(t)},W_=(t,e)=>{let r;if(J_(t))return R_;const n=t.state;return e<0?(r=0,e=-e):(r=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?R_:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,Y_(t))},X_=(t,e)=>{if(!t)return R_;const r=new Z_;t.state=r,r.strm=t,r.window=null,r.mode=F_;const n=W_(t,e);return n!==C_&&(t.state=null),n};let tE,eE,rE=!0;const nE=t=>{if(rE){tE=new Int32Array(512),eE=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(x_(1,t.lens,0,288,tE,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;x_(2,t.lens,0,32,eE,0,t.work,{bits:5}),rE=!1}t.lencode=tE,t.lenbits=9,t.distcode=eE,t.distbits=5},iE=(t,e,r,n)=>{let i;const o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),n>=o.wsize?(o.window.set(e.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(e.subarray(r-n,r-n+i),o.wnext),(n-=i)?(o.window.set(e.subarray(r-n,r),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0};var oE=(t,e)=>{let r,n,i,o,s,a,h,u,l,c,f,d,p,m,g,y,v,w,b,_,E,A,k=0;const M=new Uint8Array(4);let x,S;const N=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(J_(t)||!t.output||!t.input&&0!==t.avail_in)return R_;r=t.state,r.mode===j_&&(r.mode=L_),s=t.next_out,i=t.output,h=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,u=r.hold,l=r.bits,c=a,f=h,A=C_;t:for(;;)switch(r.mode){case F_:if(0===r.wrap){r.mode=L_;break}for(;l<16;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(2&r.wrap&&35615===u){0===r.wbits&&(r.wbits=15),r.check=0,M[0]=255&u,M[1]=u>>>8&255,r.check=Jw(r.check,M,2,0),u=0,l=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",r.mode=G_;break}if((15&u)!==D_){t.msg="unknown compression method",r.mode=G_;break}if(u>>>=4,l-=4,E=8+(15&u),0===r.wbits&&(r.wbits=E),E>15||E>r.wbits){t.msg="invalid window size",r.mode=G_;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=512&u?16189:j_,u=0,l=0;break;case 16181:for(;l<16;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(r.flags=u,(255&r.flags)!==D_){t.msg="unknown compression method",r.mode=G_;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=G_;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&4&r.wrap&&(M[0]=255&u,M[1]=u>>>8&255,r.check=Jw(r.check,M,2,0)),u=0,l=0,r.mode=16182;case 16182:for(;l<32;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&4&r.wrap&&(M[0]=255&u,M[1]=u>>>8&255,M[2]=u>>>16&255,M[3]=u>>>24&255,r.check=Jw(r.check,M,4,0)),u=0,l=0,r.mode=16183;case 16183:for(;l<16;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&4&r.wrap&&(M[0]=255&u,M[1]=u>>>8&255,r.check=Jw(r.check,M,2,0)),u=0,l=0,r.mode=16184;case 16184:if(1024&r.flags){for(;l<16;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&4&r.wrap&&(M[0]=255&u,M[1]=u>>>8&255,r.check=Jw(r.check,M,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(d=r.length,d>a&&(d=a),d&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(o,o+d),E)),512&r.flags&&4&r.wrap&&(r.check=Jw(r.check,n,d,o)),a-=d,o+=d,r.length-=d),r.length))break t;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===a)break t;d=0;do{E=n[o+d++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&d<a);if(512&r.flags&&4&r.wrap&&(r.check=Jw(r.check,n,d,o)),a-=d,o+=d,E)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===a)break t;d=0;do{E=n[o+d++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&d<a);if(512&r.flags&&4&r.wrap&&(r.check=Jw(r.check,n,d,o)),a-=d,o+=d,E)break t}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;l<16;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(4&r.wrap&&u!==(65535&r.check)){t.msg="header crc mismatch",r.mode=G_;break}u=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=j_;break;case 16189:for(;l<32;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}t.adler=r.check=K_(u),u=0,l=0,r.mode=U_;case U_:if(0===r.havedict)return t.next_out=s,t.avail_out=h,t.next_in=o,t.avail_in=a,r.hold=u,r.bits=l,P_;t.adler=r.check=1,r.mode=j_;case j_:if(e===N_||e===I_)break t;case L_:if(r.last){u>>>=7&l,l-=7&l,r.mode=H_;break}for(;l<3;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}switch(r.last=1&u,u>>>=1,l-=1,3&u){case 0:r.mode=16193;break;case 1:if(nE(r),r.mode=q_,e===I_){u>>>=2,l-=2;break t}break;case 2:r.mode=16196;break;case 3:t.msg="invalid block type",r.mode=G_}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){t.msg="invalid stored block lengths",r.mode=G_;break}if(r.length=65535&u,u=0,l=0,r.mode=z_,e===I_)break t;case z_:r.mode=16195;case 16195:if(d=r.length,d){if(d>a&&(d=a),d>h&&(d=h),0===d)break t;i.set(n.subarray(o,o+d),s),a-=d,o+=d,h-=d,s+=d,r.length-=d;break}r.mode=j_;break;case 16196:for(;l<14;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=G_;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;l<3;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.lens[N[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[N[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,x={bits:r.lenbits},A=x_(0,r.lens,0,19,r.lencode,0,r.work,x),r.lenbits=x.bits,A){t.msg="invalid code lengths set",r.mode=G_;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;k=r.lencode[u&(1<<r.lenbits)-1],g=k>>>24,y=k>>>16&255,v=65535&k,!(g<=l);){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(v<16)u>>>=g,l-=g,r.lens[r.have++]=v;else{if(16===v){for(S=g+2;l<S;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(u>>>=g,l-=g,0===r.have){t.msg="invalid bit length repeat",r.mode=G_;break}E=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===v){for(S=g+3;l<S;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}u>>>=g,l-=g,E=0,d=3+(7&u),u>>>=3,l-=3}else{for(S=g+7;l<S;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}u>>>=g,l-=g,E=0,d=11+(127&u),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=G_;break}for(;d--;)r.lens[r.have++]=E}}if(r.mode===G_)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=G_;break}if(r.lenbits=9,x={bits:r.lenbits},A=x_(1,r.lens,0,r.nlen,r.lencode,0,r.work,x),r.lenbits=x.bits,A){t.msg="invalid literal/lengths set",r.mode=G_;break}if(r.distbits=6,r.distcode=r.distdyn,x={bits:r.distbits},A=x_(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,x),r.distbits=x.bits,A){t.msg="invalid distances set",r.mode=G_;break}if(r.mode=q_,e===I_)break t;case q_:r.mode=V_;case V_:if(a>=6&&h>=258){t.next_out=s,t.avail_out=h,t.next_in=o,t.avail_in=a,r.hold=u,r.bits=l,b_(t,f),s=t.next_out,i=t.output,h=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,u=r.hold,l=r.bits,r.mode===j_&&(r.back=-1);break}for(r.back=0;k=r.lencode[u&(1<<r.lenbits)-1],g=k>>>24,y=k>>>16&255,v=65535&k,!(g<=l);){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(y&&0==(240&y)){for(w=g,b=y,_=v;k=r.lencode[_+((u&(1<<w+b)-1)>>w)],g=k>>>24,y=k>>>16&255,v=65535&k,!(w+g<=l);){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}u>>>=w,l-=w,r.back+=w}if(u>>>=g,l-=g,r.back+=g,r.length=v,0===y){r.mode=16205;break}if(32&y){r.back=-1,r.mode=j_;break}if(64&y){t.msg="invalid literal/length code",r.mode=G_;break}r.extra=15&y,r.mode=16201;case 16201:if(r.extra){for(S=r.extra;l<S;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;k=r.distcode[u&(1<<r.distbits)-1],g=k>>>24,y=k>>>16&255,v=65535&k,!(g<=l);){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(0==(240&y)){for(w=g,b=y,_=v;k=r.distcode[_+((u&(1<<w+b)-1)>>w)],g=k>>>24,y=k>>>16&255,v=65535&k,!(w+g<=l);){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}u>>>=w,l-=w,r.back+=w}if(u>>>=g,l-=g,r.back+=g,64&y){t.msg="invalid distance code",r.mode=G_;break}r.offset=v,r.extra=15&y,r.mode=16203;case 16203:if(r.extra){for(S=r.extra;l<S;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=G_;break}r.mode=16204;case 16204:if(0===h)break t;if(d=f-h,r.offset>d){if(d=r.offset-d,d>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=G_;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=s-r.offset,d=r.length;d>h&&(d=h),h-=d,r.length-=d;do{i[s++]=m[p++]}while(--d);0===r.length&&(r.mode=V_);break;case 16205:if(0===h)break t;i[s++]=r.length,h--,r.mode=V_;break;case H_:if(r.wrap){for(;l<32;){if(0===a)break t;a--,u|=n[o++]<<l,l+=8}if(f-=h,t.total_out+=f,r.total+=f,4&r.wrap&&f&&(t.adler=r.check=r.flags?Jw(r.check,i,f,s-f):Kw(r.check,i,f,s-f)),f=h,4&r.wrap&&(r.flags?u:K_(u))!==r.check){t.msg="incorrect data check",r.mode=G_;break}u=0,l=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;l<32;){if(0===a)break t;a--,u+=n[o++]<<l,l+=8}if(4&r.wrap&&u!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=G_;break}u=0,l=0}r.mode=16208;case 16208:A=T_;break t;case G_:A=O_;break t;case 16210:return $_;default:return R_}return t.next_out=s,t.avail_out=h,t.next_in=o,t.avail_in=a,r.hold=u,r.bits=l,(r.wsize||f!==t.avail_out&&r.mode<G_&&(r.mode<H_||e!==S_))&&iE(t,t.output,t.next_out,f-t.avail_out),c-=t.avail_in,f-=t.avail_out,t.total_in+=c,t.total_out+=f,r.total+=f,4&r.wrap&&f&&(t.adler=r.check=r.flags?Jw(r.check,i,f,t.next_out-f):Kw(r.check,i,f,t.next_out-f)),t.data_type=r.bits+(r.last?64:0)+(r.mode===j_?128:0)+(r.mode===q_||r.mode===z_?256:0),(0===c&&0===f||e===S_)&&A===C_&&(A=B_),A},sE={inflateReset:Y_,inflateReset2:W_,inflateResetKeep:Q_,inflateInit:t=>X_(t,15),inflateInit2:X_,inflate:oE,inflateEnd:t=>{if(J_(t))return R_;let e=t.state;return e.window&&(e.window=null),t.state=null,C_},inflateGetHeader:(t,e)=>{if(J_(t))return R_;const r=t.state;return 0==(2&r.wrap)?R_:(r.head=e,e.done=!1,C_)},inflateSetDictionary:(t,e)=>{const r=e.length;let n,i,o;return J_(t)?R_:(n=t.state,0!==n.wrap&&n.mode!==U_?R_:n.mode===U_&&(i=1,i=Kw(i,e,r,0),i!==n.check)?O_:(o=iE(t,e,r,r),o?(n.mode=16210,$_):(n.havedict=1,C_)))},inflateInfo:"pako inflate (from Nodeca project)"};var aE=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const hE=Object.prototype.toString,{Z_NO_FLUSH:uE,Z_FINISH:lE,Z_OK:cE,Z_STREAM_END:fE,Z_NEED_DICT:dE,Z_STREAM_ERROR:pE,Z_DATA_ERROR:mE,Z_MEM_ERROR:gE}=Yw;function yE(t){this.options=Wb({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o_,this.strm.avail_out=0;let r=sE.inflateInit2(this.strm,e.windowBits);if(r!==cE)throw new Error(Qw[r]);if(this.header=new aE,sE.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=r_(e.dictionary):"[object ArrayBuffer]"===hE.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=sE.inflateSetDictionary(this.strm,e.dictionary),r!==cE)))throw new Error(Qw[r])}function vE(t,e){const r=new yE(e);if(r.push(t),r.err)throw r.msg||Qw[r.err];return r.result}yE.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=e===~~e?e:!0===e?lE:uE,"[object ArrayBuffer]"===hE.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),o=sE.inflate(r,s),o===dE&&i&&(o=sE.inflateSetDictionary(r,i),o===cE?o=sE.inflate(r,s):o===mE&&(o=dE));r.avail_in>0&&o===fE&&r.state.wrap>0&&0!==t[r.next_in];)sE.inflateReset(r),o=sE.inflate(r,s);switch(o){case pE:case mE:case dE:case gE:return this.onEnd(o),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||o===fE))if("string"===this.options.to){let t=i_(r.output,r.next_out),e=r.next_out-t,i=n_(r.output,t);r.next_out=e,r.avail_out=n-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(o!==cE||0!==a){if(o===fE)return o=sE.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},yE.prototype.onData=function(t){this.chunks.push(t)},yE.prototype.onEnd=function(t){t===cE&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Xb(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var wE={Inflate:yE,inflate:vE,inflateRaw:function(t,e){return(e=e||{}).raw=!0,vE(t,e)},ungzip:vE,constants:Yw};const{Deflate:bE,deflate:_E,deflateRaw:EE,gzip:AE}=v_,{Inflate:kE,inflate:ME,inflateRaw:xE,ungzip:SE}=wE;var NE=AE,IE=SE,CE="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==B&&B||{},TE="URLSearchParams"in CE,PE="Symbol"in CE&&"iterator"in Symbol,RE="FileReader"in CE&&"Blob"in CE&&function(){try{return new Blob,!0}catch(t){return!1}}(),OE="FormData"in CE,$E="ArrayBuffer"in CE;if($E)var BE=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],DE=ArrayBuffer.isView||function(t){return t&&BE.indexOf(Object.prototype.toString.call(t))>-1};function FE(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function UE(t){return"string"!=typeof t&&(t=String(t)),t}function jE(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return PE&&(e[Symbol.iterator]=function(){return e}),e}function LE(t){this.map={},t instanceof LE?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function zE(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function qE(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function VE(t){var e=new FileReader,r=qE(e);return e.readAsArrayBuffer(t),r}function HE(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function GE(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:RE&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:OE&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:TE&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():$E&&RE&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=HE(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):$E&&(ArrayBuffer.prototype.isPrototypeOf(t)||DE(t))?this._bodyArrayBuffer=HE(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):TE&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},RE&&(this.blob=function(){var t=zE(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=zE(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(RE)return this.blob().then(VE);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,n,i,o=zE(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=qE(e),n=/charset=([A-Za-z0-9_-]+)/.exec(t.type),i=n?n[1]:"utf-8",e.readAsText(t,i),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},OE&&(this.formData=function(){return this.text().then(JE)}),this.json=function(){return this.text().then(JSON.parse)},this}LE.prototype.append=function(t,e){t=FE(t),e=UE(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},LE.prototype.delete=function(t){delete this.map[FE(t)]},LE.prototype.get=function(t){return t=FE(t),this.has(t)?this.map[t]:null},LE.prototype.has=function(t){return this.map.hasOwnProperty(FE(t))},LE.prototype.set=function(t,e){this.map[FE(t)]=UE(e)},LE.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},LE.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),jE(t)},LE.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),jE(t)},LE.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),jE(t)},PE&&(LE.prototype[Symbol.iterator]=LE.prototype.entries);var KE=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function ZE(t,e){if(!(this instanceof ZE))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,n,i=(e=e||{}).body;if(t instanceof ZE){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new LE(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new LE(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),KE.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in CE)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function JE(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function QE(t,e){if(!(this instanceof QE))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new LE(e.headers),this.url=e.url||"",this._initBody(t)}ZE.prototype.clone=function(){return new ZE(this,{body:this._bodyInit})},GE.call(ZE.prototype),GE.call(QE.prototype),QE.prototype.clone=function(){return new QE(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new LE(this.headers),url:this.url})},QE.error=function(){var t=new QE(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var YE=[301,302,303,307,308];QE.redirect=function(t,e){if(-1===YE.indexOf(e))throw new RangeError("Invalid status code");return new QE(null,{status:e,headers:{location:t}})};var WE=CE.DOMException;try{new WE}catch(xb){WE=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},WE.prototype=Object.create(Error.prototype),WE.prototype.constructor=WE}function XE(t,e){return new Promise((function(r,n){var i=new ZE(t,e);if(i.signal&&i.signal.aborted)return n(new WE("Aborted","AbortError"));var o=new XMLHttpRequest;function s(){o.abort()}if(o.onload=function(){var t,e,n={statusText:o.statusText,headers:(t=o.getAllResponseHeaders()||"",e=new LE,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();try{e.append(n,i)}catch(t){console.warn("Response "+t.message)}}})),e)};0===i.url.indexOf("file://")&&(o.status<200||o.status>599)?n.status=200:n.status=o.status,n.url="responseURL"in o?o.responseURL:n.headers.get("X-Request-URL");var s="response"in o?o.response:o.responseText;setTimeout((function(){r(new QE(s,n))}),0)},o.onerror=function(){setTimeout((function(){n(new TypeError("Network request failed"))}),0)},o.ontimeout=function(){setTimeout((function(){n(new TypeError("Network request timed out"))}),0)},o.onabort=function(){setTimeout((function(){n(new WE("Aborted","AbortError"))}),0)},o.open(i.method,function(t){try{return""===t&&CE.location.href?CE.location.href:t}catch(e){return t}}(i.url),!0),"include"===i.credentials?o.withCredentials=!0:"omit"===i.credentials&&(o.withCredentials=!1),"responseType"in o&&(RE?o.responseType="blob":$E&&(o.responseType="arraybuffer")),e&&"object"==typeof e.headers&&!(e.headers instanceof LE||CE.Headers&&e.headers instanceof CE.Headers)){var a=[];Object.getOwnPropertyNames(e.headers).forEach((function(t){a.push(FE(t)),o.setRequestHeader(t,UE(e.headers[t]))})),i.headers.forEach((function(t,e){-1===a.indexOf(e)&&o.setRequestHeader(e,t)}))}else i.headers.forEach((function(t,e){o.setRequestHeader(e,t)}));i.signal&&(i.signal.addEventListener("abort",s),o.onreadystatechange=function(){4===o.readyState&&i.signal.removeEventListener("abort",s)}),o.send(void 0===i._bodyInit?null:i._bodyInit)}))}XE.polyfill=!0,CE.fetch||(CE.fetch=XE,CE.Headers=LE,CE.Request=ZE,CE.Response=QE);var tA=self.fetch.bind(self),eA=o((function(t){var e,n;e=r,n=function(){function t(t){var e=[];if(0===t.length)return"";if("string"!=typeof t[0])throw new TypeError("Url must be a string. Received "+t[0]);if(t[0].match(/^[^/:]+:\/*$/)&&t.length>1){var r=t.shift();t[0]=r+t[0]}t[0].match(/^file:\/\/\//)?t[0]=t[0].replace(/^([^/:]+):\/*/,"$1:///"):t[0]=t[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<t.length;n++){var i=t[n];if("string"!=typeof i)throw new TypeError("Url must be a string. Received "+i);""!==i&&(n>0&&(i=i.replace(/^[\/]+/,"")),i=n<t.length-1?i.replace(/[\/]+$/,""):i.replace(/[\/]+$/,"/"),e.push(i))}var o=e.join("/"),s=(o=o.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return o=s.shift()+(s.length>0?"?":"")+s.join("&")}return function(){return t("object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments))}},t.exports?t.exports=n():e.urljoin=n()})),rA=Object.defineProperty,nA=(t,e)=>{for(var r in e)rA(t,r,{get:e[r],enumerable:!0})};nA({},{API_VERSION:()=>NA,BN_FEE_TRANSACTION_VERSION_1:()=>AA,BN_FEE_TRANSACTION_VERSION_2:()=>kA,BN_TRANSACTION_VERSION_1:()=>_A,BN_TRANSACTION_VERSION_2:()=>EA,BaseUrl:()=>IA,HEX_STR_TRANSACTION_VERSION_1:()=>wA,HEX_STR_TRANSACTION_VERSION_2:()=>bA,IS_BROWSER:()=>iA,MASK_250:()=>xA,MASK_251:()=>SA,NetworkName:()=>CA,RPC_GOERLI_NODES:()=>OA,RPC_MAINNET_NODES:()=>$A,StarknetChainId:()=>TA,TEXT_TO_FELT_MAX_LEN:()=>vA,TransactionHashPrefix:()=>PA,UDC:()=>RA,ZERO:()=>MA});nA({},{IS_BROWSER:()=>iA,addHexPrefix:()=>fA,arrayBufferToString:()=>oA,atobUniversal:()=>hA,btoaUniversal:()=>uA,buf2hex:()=>lA,calcByteLength:()=>pA,padLeft:()=>dA,pascalToSnake:()=>yA,removeHexPrefix:()=>cA,sanitizeBytes:()=>mA,sanitizeHex:()=>gA,stringToArrayBuffer:()=>aA,utf8ToArray:()=>sA});var iA="undefined"!=typeof window;function oA(t){return new Uint8Array(t).reduce(((t,e)=>t+String.fromCharCode(e)),"")}function sA(t){return(new TextEncoder).encode(t)}function aA(t){return sA(t)}function hA(t){return Em.decode(t)}function uA(t){return Em.encode(new Uint8Array(t))}function lA(t){return t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"")}function cA(t){return t.replace(/^0x/i,"")}function fA(t){return`0x${cA(t)}`}function dA(t,e,r="0"){return function(t,e,r,n="0"){const i=e-t.length;let o=t;if(i>0){const e=n.repeat(i);o=r?e+t:t+e}return o}(t,e,!0,r)}function pA(t,e=8){const{length:r}=t,n=r%e;return n?(r-n)/e*e+e:r}function mA(t,e=8,r="0"){return dA(t,pA(t,e),r)}function gA(t){return(t=mA(t=cA(t),2))&&(t=fA(t)),t}var yA=t=>/[a-z]/.test(t)?t.split(/(?=[A-Z])/).join("_").toUpperCase():t,vA=31,wA="0x1",bA="0x2",_A=1n,EA=2n,AA=2n**128n+_A,kA=2n**128n+EA,MA=0n,xA=2n**250n-1n,SA=2n**251n,NA=MA,IA=(t=>(t.SN_MAIN="https://alpha-mainnet.starknet.io",t.SN_GOERLI="https://alpha4.starknet.io",t))(IA||{}),CA=(t=>(t.SN_MAIN="SN_MAIN",t.SN_GOERLI="SN_GOERLI",t))(CA||{}),TA=(t=>(t.SN_MAIN="0x534e5f4d41494e",t.SN_GOERLI="0x534e5f474f45524c49",t))(TA||{}),PA=(t=>(t.DECLARE="0x6465636c617265",t.DEPLOY="0x6465706c6f79",t.DEPLOY_ACCOUNT="0x6465706c6f795f6163636f756e74",t.INVOKE="0x696e766f6b65",t.L1_HANDLER="0x6c315f68616e646c6572",t))(PA||{}),RA={ADDRESS:"0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",ENTRYPOINT:"deployContract"},OA=["https://starknet-testnet.public.blastapi.io/rpc/v0.5","https://limited-rpc.nethermind.io/goerli-juno/v0_5"],$A=["https://starknet-mainnet.public.blastapi.io/rpc/v0.5","https://limited-rpc.nethermind.io/mainnet-juno/v0_5"];nA({},{BlockStatus:()=>HA,BlockTag:()=>GA,EntryPointType:()=>jA,Litteral:()=>UA,RPC:()=>KA,SIMULATION_FLAG:()=>BA,Sequencer:()=>ik,TransactionExecutionStatus:()=>VA,TransactionFinalityStatus:()=>qA,TransactionStatus:()=>zA,TransactionType:()=>LA,Uint:()=>FA,ValidateType:()=>DA});var BA=(t=>(t.SKIP_VALIDATE="SKIP_VALIDATE",t.SKIP_EXECUTE="SKIP_EXECUTE",t))(BA||{}),DA=(t=>(t.DEPLOY="DEPLOY",t.CALL="CALL",t.INVOKE="INVOKE",t))(DA||{}),FA=(t=>(t.u8="core::integer::u8",t.u16="core::integer::u16",t.u32="core::integer::u32",t.u64="core::integer::u64",t.u128="core::integer::u128",t.u256="core::integer::u256",t))(FA||{}),UA=(t=>(t.ClassHash="core::starknet::class_hash::ClassHash",t.ContractAddress="core::starknet::contract_address::ContractAddress",t))(UA||{}),jA=(t=>(t.EXTERNAL="EXTERNAL",t.L1_HANDLER="L1_HANDLER",t.CONSTRUCTOR="CONSTRUCTOR",t))(jA||{}),LA=(t=>(t.DECLARE="DECLARE",t.DEPLOY="DEPLOY",t.DEPLOY_ACCOUNT="DEPLOY_ACCOUNT",t.INVOKE="INVOKE_FUNCTION",t))(LA||{}),zA=(t=>(t.NOT_RECEIVED="NOT_RECEIVED",t.RECEIVED="RECEIVED",t.ACCEPTED_ON_L2="ACCEPTED_ON_L2",t.ACCEPTED_ON_L1="ACCEPTED_ON_L1",t.REJECTED="REJECTED",t.REVERTED="REVERTED",t))(zA||{}),qA=(t=>(t.NOT_RECEIVED="NOT_RECEIVED",t.RECEIVED="RECEIVED",t.ACCEPTED_ON_L2="ACCEPTED_ON_L2",t.ACCEPTED_ON_L1="ACCEPTED_ON_L1",t))(qA||{}),VA=(t=>(t.REJECTED="REJECTED",t.REVERTED="REVERTED",t.SUCCEEDED="SUCCEEDED",t))(VA||{}),HA=(t=>(t.PENDING="PENDING",t.ACCEPTED_ON_L1="ACCEPTED_ON_L1",t.ACCEPTED_ON_L2="ACCEPTED_ON_L2",t.REJECTED="REJECTED",t))(HA||{}),GA=(t=>(t.pending="pending",t.latest="latest",t))(GA||{}),KA={};nA(KA,{EBlockTag:()=>rk,EDataAvailabilityMode:()=>nk,ESimulationFlag:()=>WA,ETransactionExecutionStatus:()=>ek,ETransactionFinalityStatus:()=>tk,ETransactionStatus:()=>XA,ETransactionType:()=>YA,Errors:()=>JA,JRPC:()=>ZA,SPEC:()=>QA});var ZA={},JA={},QA={},YA=(t=>(t.DECLARE="DECLARE",t.DEPLOY="DEPLOY",t.DEPLOY_ACCOUNT="DEPLOY_ACCOUNT",t.INVOKE="INVOKE",t.L1_HANDLER="L1_HANDLER",t))(YA||{}),WA=(t=>(t.SKIP_VALIDATE="SKIP_VALIDATE",t.SKIP_FEE_CHARGE="SKIP_FEE_CHARGE",t))(WA||{}),XA=(t=>(t.RECEIVED="RECEIVED",t.REJECTED="REJECTED",t.ACCEPTED_ON_L2="ACCEPTED_ON_L2",t.ACCEPTED_ON_L1="ACCEPTED_ON_L1",t))(XA||{}),tk=(t=>(t.ACCEPTED_ON_L2="ACCEPTED_ON_L2",t.ACCEPTED_ON_L1="ACCEPTED_ON_L1",t))(tk||{}),ek=(t=>(t.SUCCEEDED="SUCCEEDED",t.REVERTED="REVERTED",t))(ek||{}),rk=(t=>(t.LATEST="latest",t.PENDING="pending",t))(rk||{}),nk=(t=>(t.L1="L1",t.L2="L2",t))(nk||{}),ik={};function ok(t,e){if(!t)throw new Error(e||"Assertion failure")}function sk(t){return/^0x[0-9a-f]*$/i.test(t)}function ak(t){return BigInt(t)}function hk(t){return"bigint"==typeof t}function uk(t){return fA(ak(t).toString(16))}nA({},{assertInRange:()=>pk,bigNumberishArrayToDecimalStringArray:()=>mk,bigNumberishArrayToHexadecimalStringArray:()=>gk,cleanHex:()=>dk,getDecimalString:()=>vk,getHexString:()=>wk,getHexStringArray:()=>bk,hexToBytes:()=>Ek,hexToDecimalString:()=>fk,isBigInt:()=>hk,isHex:()=>sk,isStringWholeNumber:()=>yk,toBigInt:()=>ak,toCairoBool:()=>_k,toHex:()=>uk,toHexString:()=>lk,toStorageKey:()=>ck});var lk=uk;function ck(t){return fA(ak(t).toString(16).padStart(64,"0"))}function fk(t){return BigInt(fA(t)).toString(10)}var dk=t=>t.toLowerCase().replace(/^(0x)0+/,"$1");function pk(t,e,r,n=""){const i=""===n?"invalid length":`invalid ${n} length`,o=BigInt(t),s=BigInt(e),a=BigInt(r);ok(o>=s&&o<=a,`Message not signable, ${i}.`)}function mk(t){return t.map((t=>ak(t).toString(10)))}function gk(t){return t.map((t=>uk(t)))}var yk=t=>/^\d+$/.test(t);function vk(t){if(sk(t))return fk(t);if(yk(t))return t;throw new Error(`${t} need to be hex-string or whole-number-string`)}function wk(t){if(sk(t))return t;if(yk(t))return lk(t);throw new Error(`${t} need to be hex-string or whole-number-string`)}function bk(t){return t.map((t=>wk(t)))}var _k=t=>(+t).toString();function Ek(t){if(!sk(t))throw new Error(`${t} need to be a hex-string`);let e=cA(t);return e.length%2!=0&&(e=`0${e}`),Tm(e)}function Ak(t){const e=cA(uk(BigInt(t))),r=e.length%2==0?e:`0${e}`;return fA(Gy(Ek(fA(r))).toString(16))}function kk(t){const e=BigInt(function(t){return fA(Gy(sA(t)).toString(16))}(t));return e&xA}function Mk(t){return uk(kk(t))}function xk(t){return sk(t)?t:yk(t)?lk(t):Mk(t)}nA({},{getSelector:()=>xk,getSelectorFromName:()=>Mk,keccakBn:()=>Ak,starknetKeccak:()=>kk});function Sk(t){return/^[\x00-\x7F]*$/.test(t)}function Nk(t){return t.length<=vA}function Ik(t){return/^[0-9]*$/i.test(t)}function Ck(t){return"string"==typeof t&&!sk(t)&&!yk(t)}nA({},{decodeShortString:()=>$k,encodeShortString:()=>Ok,isASCII:()=>Sk,isDecimalString:()=>Ik,isLongText:()=>Pk,isShortString:()=>Nk,isShortText:()=>Tk,isText:()=>Ck,splitLongString:()=>Rk});var Tk=t=>Ck(t)&&Nk(t),Pk=t=>Ck(t)&&!Nk(t);function Rk(t){const e=RegExp(`[^]{1,${vA}}`,"g");return t.match(e)||[]}function Ok(t){if(!Sk(t))throw new Error(`${t} is not an ASCII string`);if(!Nk(t))throw new Error(`${t} is too long`);return fA(t.replace(/./g,(t=>t.charCodeAt(0).toString(16))))}function $k(t){if(!Sk(t))throw new Error(`${t} is not an ASCII string`);if(sk(t))return cA(t).replace(/.{2}/g,(t=>String.fromCharCode(parseInt(t,16))));if(Ik(t))return $k("0X".concat(BigInt(t).toString(16)));throw new Error(`${t} is not Hex or decimal`)}var Bk={};nA(Bk,{felt:()=>uM,getAbiContractVersion:()=>sM,getArrayType:()=>iM,isCairo1Abi:()=>oM,isCairo1Type:()=>nM,isLen:()=>zk,isTypeArray:()=>Vk,isTypeBool:()=>tM,isTypeContractAddress:()=>eM,isTypeEnum:()=>Zk,isTypeEthAddress:()=>rM,isTypeFelt:()=>qk,isTypeLitteral:()=>Wk,isTypeNamedTuple:()=>Gk,isTypeOption:()=>Jk,isTypeResult:()=>Qk,isTypeStruct:()=>Kk,isTypeTuple:()=>Hk,isTypeUint:()=>Yk,isTypeUint256:()=>Xk,tuple:()=>hM,uint256:()=>aM});nA({},{UINT_128_MAX:()=>Dk,UINT_256_MAX:()=>Fk,bnToUint256:()=>Lk,isUint256:()=>jk,uint256ToBN:()=>Uk});var Dk=(1n<<128n)-1n,Fk=(1n<<256n)-1n;function Uk(t){return(ak(t.high)<<128n)+ak(t.low)}function jk(t){return ak(t)<=Fk}function Lk(t){const e=ak(t);if(!jk(e))throw new Error("Number is too large");return{low:fA((e&Dk).toString(16)),high:fA((e>>128n).toString(16))}}var zk=t=>/_len$/.test(t),qk=t=>"felt"===t||"core::felt252"===t,Vk=t=>/\*/.test(t)||t.startsWith("core::array::Array::")||t.startsWith("core::array::Span::"),Hk=t=>/^\(.*\)$/i.test(t),Gk=t=>/\(.*\)/i.test(t)&&t.includes(":"),Kk=(t,e)=>t in e,Zk=(t,e)=>t in e,Jk=t=>t.startsWith("core::option::Option::"),Qk=t=>t.startsWith("core::result::Result::"),Yk=t=>Object.values(FA).includes(t),Wk=t=>Object.values(UA).includes(t),Xk=t=>"core::integer::u256"===t,tM=t=>"core::bool"===t,eM=t=>"core::starknet::contract_address::ContractAddress"===t,rM=t=>"core::starknet::eth_address::EthAddress"===t,nM=t=>t.includes("::"),iM=t=>nM(t)?t.substring(t.indexOf("<")+1,t.lastIndexOf(">")):t.replace("*","");function oM(t){const{cairo:e}=sM(t);if(void 0===e)throw Error("Unable to determine Cairo version");return"1"===e}function sM(t){if(t.find((t=>"interface"===t.type)))return{cairo:"1",compiler:"2"};const e=t.find((t=>"function"===t.type&&(t.inputs.length||t.outputs.length)));if(!e)return{cairo:void 0,compiler:void 0};const r=e.inputs.length?e.inputs:e.outputs;return nM(r[0].type)?{cairo:"1",compiler:"1"}:{cairo:"0",compiler:"0"}}var aM=t=>{const e=BigInt(t);if(!jk(e))throw new Error("Number is too large");return{low:(e&Dk).toString(10),high:(e>>128n).toString(10)}},hM=(...t)=>({...t});function uM(t){if(hk(t)||"number"==typeof t&&Number.isInteger(t))return t.toString();if(Ck(t)){if(!Nk(t))throw new Error(`${t} is a long string > 31 chars, felt can store short strings, split it to array of short strings`);const e=Ok(t);return BigInt(e).toString()}if("string"==typeof t&&sk(t))return BigInt(t).toString();if("string"==typeof t&&yk(t))return t;if("boolean"==typeof t)return""+ +t;throw new Error(`${t} can't be computed by felt()`)}var lM=class{constructor(t){const e=Object.values(t);if(0===e.length)throw new Error("This Enum must have a least 1 variant");if(1!==e.filter((t=>void 0!==t)).length)throw new Error("This Enum must have exactly one active variant");this.variant=t}unwrap(){const t=Object.entries(this.variant).find((t=>void 0!==t[1]));if(void 0!==t)return t[1]}activeVariant(){const t=Object.entries(this.variant).find((t=>void 0!==t[1]));return void 0===t?"":t[0]}},cM=(t=>(t[t.Some=0]="Some",t[t.None=1]="None",t))(cM||{}),fM=class{constructor(t,e){if(!(t in cM))throw new Error("Wrong variant : should be CairoOptionVariant.Some or .None.");if(0===t){if(void 0===e)throw new Error('The creation of a Cairo Option with "Some" variant needs a content as input.');this.Some=e,this.None=void 0}else this.Some=void 0,this.None=!0}unwrap(){if(!this.None)return this.Some}isSome(){return!(void 0===this.Some)}isNone(){return!0===this.None}},dM=(t=>(t[t.Ok=0]="Ok",t[t.Err=1]="Err",t))(dM||{}),pM=class{constructor(t,e){if(!(t in dM))throw new Error("Wrong variant : should be CairoResultVariant.Ok or .Err.");0===t?(this.Ok=e,this.Err=void 0):(this.Ok=void 0,this.Err=e)}unwrap(){if(void 0!==this.Ok)return this.Ok;if(void 0!==this.Err)return this.Err;throw new Error("Both Result.Ok and .Err are undefined. Not authorized.")}isOk(){return!(void 0===this.Ok)}isErr(){return!(void 0===this.Err)}},mM=(t,e,r)=>{if(!hk(t[r]))throw new Error(`Data and formatter mismatch on ${r}:${e[r]}, expected response data ${r}:${t[r]} to be BN instead it is ${typeof t[r]}`)},gM=(t,e,r)=>{throw new Error(`Unhandled formatter type on ${r}:${e[r]} for data ${r}:${t[r]}`)};function yM(t,e,r){return Object.entries(t).reduce(((n,[i,o])=>{const s=r??e[i];if(!(i in e)&&!r)return n[i]=o,n;if("string"===s){if(Array.isArray(t[i])){const e=yM(t[i],t[i].map((t=>s)));return n[i]=Object.values(e).join(""),n}return mM(t,e,i),n[i]=$k(o),n}if("number"===s)return mM(t,e,i),n[i]=Number(o),n;if("function"==typeof s)return n[i]=s(o),n;if(Array.isArray(s)){const e=yM(t[i],s,s[0]);return n[i]=Object.values(e),n}return"object"==typeof s?(n[i]=yM(t[i],s),n):(gM(t,e,i),n)}),{})}function vM(t){const e=function(t){return t.find((t=>"interface"===t.type))?2:oM(t)?1:0}(t);if(0===e||1===e)return new class{constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.reduce(((t,e)=>zk(e.name)?t:t+1),0)}getMethod(t){return this.abi.find((e=>e.name===t))}getLegacyFormat(){return this.abi}}(t);if(2===e)return new class{constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.length}getMethod(t){return this.abi.find((t=>"interface"===t.type)).items.find((e=>e.name===t))}getLegacyFormat(){return this.abi.flatMap((t=>"interface"===t.type?t.items:t))}}(t);throw Error(`Unsupported ABI version ${e}`)}function wM(t,e,r){return"constructor"===t&&!r&&!e.length}function bM(t){if(!t.includes("("))return{subTuple:[],result:t};const e=[];let r="",n=0;for(;n<t.length;){if("("===t[n]){let i=1;const o=n;for(n++;i;)")"===t[n]&&i--,"("===t[n]&&i++,n++;e.push(t.substring(o,n)),r+=" ",n--}else r+=t[n];n++}return{subTuple:e,result:r}}function _M(t){return nM(t)?function(t){const e=t.replace(/\s/g,"").slice(1,-1),{subTuple:r,result:n}=bM(e);return n.split(",").map((t=>r.length?t.replace(" ",r.shift()):t))}(t):function(t){const e=t.replace(/\s/g,"").slice(1,-1),{subTuple:r,result:n}=bM(e);let i=n.split(",").map((t=>r.length?t.replace(" ",r.shift()):t));return Gk(t)&&(i=i.reduce(((t,e)=>t.concat(function(t){const e=t.substring(0,t.indexOf(":"));return{name:e,type:t.substring(e.length+":".length)}}(e))),[])),i}(t)}function EM(t,e,r,n){const i=(t,e)=>{if(Vk(e))return function(t,e){const r=iM(e);if("string"==typeof t)return t;return t.map((t=>i(t,r)))}(t,e);if(Zk(e,n)){const r=n[e];return s(t,r)}if(Hk(e))return function(t,e){const r=_M(e).reduce(((e,r,n)=>{const o=Object.keys(t),s=r=>Object.defineProperty(e,n.toString(),{enumerable:!0,value:r??t[o[n]]}),a=r?.type?r.type:r;return s(i(t[o[n]],a)),e}),{});return r}(t,e);if(rM(e))return t;if(Xk(e)){const r=t;if("object"!=typeof r)return r;if(!("low"in r)||!("high"in r))throw function(t){return Error(`Your object includes the property : ${t}, containing an Uint256 object without the 'low' and 'high' keys.`)}(e);return{low:r.low,high:r.high}}if(Kk(e,r)){const n=r[e].members;return o(t,n)}return t},o=(t,e)=>e.reduce(((e,r)=>{if("undefined"===t[r.name]&&(nM(r.type)||!zk(r.name)))throw Error(`Your object needs a property with key : ${r.name} .`);var n;return n=i(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:n??t[r.name]}),e}),{});const s=(t,e)=>{if(Qk(e.name)){const r=t,n=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(",")),o=e.name.substring(e.name.indexOf(",")+1,e.name.lastIndexOf(">"));return r.isOk()?new pM(0,i(t.unwrap(),n)):new pM(1,i(t.unwrap(),o))}if(Jk(e.name)){const r=t,n=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(">"));return r.isSome()?new fM(0,i(r.unwrap(),n)):new fM(1,{})}const r=t,n=Object.entries(r.variant).map((t=>{if(void 0===t[1])return t;const n=e.type.substring(e.type.lastIndexOf("<")+1,e.type.lastIndexOf(">"));return"()"===n?t:[t[0],i(r.unwrap(),n)]}));return new lM(Object.fromEntries(n))};return e.reduce(((e,r)=>{return zk(r.name)&&!nM(r.type)||(n=i(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:n})),e;var n}),{})}function AM(t,e){if(!0===Xk(t)){const t=aM(e);return[uM(t.low),uM(t.high)]}return uM(e)}function kM(t){if("object"==typeof t){const{low:e,high:r}=t;return[uM(e),uM(r)]}const e=aM(t);return[uM(e.low),uM(e.high)]}function MM(t,e,r,n){if(void 0===t)throw Error(`Missing parameter for type ${e}`);if(Array.isArray(t)){const i=[];i.push(uM(t.length));const o=iM(e);return t.reduce(((t,e)=>t.concat(MM(e,o,r,n))),i)}if(r[e]&&r[e].members.length){if(Xk(e))return kM(t);if("core::starknet::eth_address::EthAddress"===e)return AM(e,t);const{members:i}=r[e],o=t;return i.reduce(((t,e)=>t.concat(MM(o[e.name],e.type,r,n))),[])}if(Hk(e)){const i=function(t,e){const r=_M(e),n=Object.values(t);if(n.length!==r.length)throw Error(`ParseTuple: provided and expected abi tuple size do not match.\n provided: ${n} \n expected: ${r}`);return r.map(((t,e)=>({element:n[e],type:t.type??t})))}(t,e);return i.reduce(((t,e)=>{const i=MM(e.element,e.type,r,n);return t.concat(i)}),[])}if(Xk(e))return kM(t);if(Zk(e,n)){const{variants:i}=n[e];if(Jk(e)){const e=t;if(e.isSome()){const t=i.find((t=>"Some"===t.name));if(void 0===t)throw Error("Error in abi : Option has no 'Some' variant.");const o=t.type;if("()"===o)return(0).toString();const s=MM(e.unwrap(),o,r,n);return Array.isArray(s)?[(0).toString(),...s]:[(0).toString(),s]}return 1..toString()}if(Qk(e)){const e=t;if(e.isOk()){const t=i.find((t=>"Ok"===t.name));if(void 0===t)throw Error("Error in abi : Result has no 'Ok' variant.");const o=t.type;if("()"===o)return(0).toString();const s=MM(e.unwrap(),o,r,n);return Array.isArray(s)?[(0).toString(),...s]:[(0).toString(),s]}const o=i.find((t=>"Err"===t.name));if(void 0===o)throw Error("Error in abi : Result has no 'Err' variant.");const s=o.type;if("()"===s)return 1..toString();const a=MM(e.unwrap(),s,r,n);return Array.isArray(a)?[1..toString(),...a]:[1..toString(),a]}const o=t,s=o.activeVariant(),a=i.find((t=>t.name===s));if(void 0===a)throw Error(`Not find in abi : Enum has no '${s}' variant.`);const h=a.type,u=i.findIndex((t=>t.name===s));if("()"===h)return u.toString();const l=MM(o.unwrap(),h,r,n);return Array.isArray(l)?[u.toString(),...l]:[u.toString(),l]}if("object"==typeof t)throw Error(`Parameter ${t} do not align with abi parameter ${e}`);return AM(e,t)}function xM(t,e){let r;switch(!0){case tM(t):return r=e.next().value,Boolean(BigInt(r));case Xk(t):return Uk({low:e.next().value,high:e.next().value});default:return r=e.next().value,BigInt(r)}}function SM(t,e,r,n){if("()"===e.type)return{};if(Xk(e.type)){return Uk({low:t.next().value,high:t.next().value})}if(Vk(e.type)){const i=[],o={name:"",type:iM(e.type)},s=BigInt(t.next().value);for(;i.length<s;)i.push(SM(t,o,r,n));return i}if(r&&e.type in r&&r[e.type])return"core::starknet::eth_address::EthAddress"===e.type?xM(e.type,t):r[e.type].members.reduce(((e,i)=>(e[i.name]=SM(t,i,r,n),e)),{});if(n&&e.type in n&&n[e.type]){const i=Number(t.next().value),o=n[e.type].variants.reduce(((e,o,s)=>s===i?(e[o.name]=SM(t,{name:"",type:o.type},r,n),e):(e[o.name]=void 0,e)),{});if(e.type.startsWith("core::option::Option")){const t=0===i?o.Some:void 0;return new fM(i,t)}if(e.type.startsWith("core::result::Result")){let t;return t=0===i?o.Ok:o.Err,new pM(i,t)}return new lM(o)}if(Hk(e.type)){return _M(e.type).reduce(((e,i,o)=>{const s=i?.name?i.name:o,a={name:s,type:i?.type?i.type:i};return e[s]=SM(t,a,r,n),e}),{})}if(Vk(e.type)){const i=[],o={name:"",type:iM(e.type)},s=BigInt(t.next().value);for(;i.length<s;)i.push(SM(t,o,r,n));return i}return xM(e.type,t)}function NM(t,e,r,n,i){const{name:o,type:s}=e;let a;switch(!0){case zk(o):return a=t.next().value,BigInt(a);case r&&s in r||Hk(s):case n&&Zk(s,n):return SM(t,e,r,n);case Vk(s):if(nM(s))return SM(t,e,r,n);const h=[];if(i&&i[`${o}_len`]){const s=i[`${o}_len`];for(;h.length<s;)h.push(SM(t,{name:o,type:e.type.replace("*","")},r,n))}return h;default:return xM(s,t)}}var IM=(t,e)=>{if(ok("string"==typeof t||"number"==typeof t||"bigint"==typeof t,`Validate: arg ${e.name} should be a felt typed as (String, Number or BigInt)`),"string"==typeof t&&!sk(t))return;const r=BigInt(t.toString(10));ok(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`)},CM=(t,e)=>{"number"==typeof t&&ok(t<=Number.MAX_SAFE_INTEGER,"Validation: Parameter is to large to be typed as Number use (BigInt or String)"),ok("string"==typeof t||"number"==typeof t||"bigint"==typeof t||"object"==typeof t&&"low"in t&&"high"in t,`Validate: arg ${e.name} of cairo type ${e.type} should be type (String, Number or BigInt), but is ${typeof t} ${t}.`);const r="object"==typeof t?Uk(t):ak(t);switch(e.type){case"core::integer::u8":ok(r>=0n&&r<=255n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0 - 255]`);break;case"core::integer::u16":ok(r>=0n&&r<=65535n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 65535]`);break;case"core::integer::u32":ok(r>=0n&&r<=4294967295n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 4294967295]`);break;case"core::integer::u64":ok(r>=0n&&r<=2n**64n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^64-1]`);break;case"core::integer::u128":ok(r>=0n&&r<=2n**128n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^128-1]`);break;case"core::integer::u256":ok(r>=0n&&r<=2n**256n-1n,`Validate: arg ${e.name} is ${e.type} 0 - 2^256-1`);break;case"core::starknet::class_hash::ClassHash":case"core::starknet::contract_address::ContractAddress":ok(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`)}},TM=(t,e)=>{ok("boolean"==typeof t,`Validate: arg ${e.name} of cairo type ${e.type} should be type (Boolean)`)},PM=(t,e,r)=>{if("core::integer::u256"!==e.type)if("core::starknet::eth_address::EthAddress"!==e.type)ok("object"==typeof t&&!Array.isArray(t),`Validate: arg ${e.name} is cairo type struct (${e.type}), and should be defined as js object (not array)`),r[e.type].members.forEach((({name:r})=>{ok(Object.keys(t).includes(r),`Validate: arg ${e.name} should have a property ${r}`)}));else{ok("object"!=typeof t,`EthAdress type is waiting a BigNumberish. Got ${t}`);const r=BigInt(t.toString(10));ok(r>=0n&&r<=2n**160n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^160-1]`)}else CM(t,e)},RM=(t,e)=>{ok("object"==typeof t&&!Array.isArray(t),`Validate: arg ${e.name} is cairo type Enum (${e.type}), and should be defined as js object (not array)`);const r=Object.getOwnPropertyNames(Object.getPrototypeOf(t)),n=[...Object.getOwnPropertyNames(t),...r];if(!(Jk(e.type)&&n.includes("isSome")&&n.includes("isNone")||Qk(e.type)&&n.includes("isOk")&&n.includes("isErr")||n.includes("variant")&&n.includes("activeVariant")))throw new Error(`Validate Enum: argument ${e.name}, type ${e.type}, value received ${t}, is not an Enum.`)},OM=(t,e)=>{ok("object"==typeof t&&!Array.isArray(t),`Validate: arg ${e.name} should be a tuple (defined as object)`)},$M=(t,e,r,n)=>{const i=iM(e.type);if(!qk(i)||!Pk(t))switch(ok(Array.isArray(t),`Validate: arg ${e.name} should be an Array`),!0){case qk(i):t.forEach((t=>IM(t,e)));break;case Hk(i):t.forEach((t=>OM(t,{name:e.name,type:i})));break;case Vk(i):t.forEach((t=>$M(t,{name:"",type:i},r,n)));break;case Kk(i,r):t.forEach((t=>PM(t,{name:e.name,type:i},r)));break;case Zk(i,n):t.forEach((t=>RM(t,{name:e.name,type:i})));break;case Yk(i)||Wk(i):t.forEach((t=>CM(t,e)));break;case tM(i):t.forEach((t=>TM(t,e)));break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value ${t}`)}};function BM(t,e,r,n){t.inputs.reduce(((t,i)=>{const o=e[t];switch(!0){case zk(i.name):return t;case qk(i.type):IM(o,i);break;case Yk(i.type)||Wk(i.type):CM(o,i);break;case tM(i.type):TM(o,i);break;case Vk(i.type):$M(o,i,r,n);break;case Kk(i.type,r):PM(o,i,r);break;case Zk(i.type,n):RM(o,i);break;case Hk(i.type):OM(o,i);break;default:throw new Error(`Validate Unhandled: argument ${i.name}, type ${i.type}, value ${o}`)}return t+1}),0)}var DM=class{constructor(t){this.structs=DM.getAbiStruct(t),this.enums=DM.getAbiEnum(t),this.parser=vM(t),this.abi=this.parser.getLegacyFormat()}validate(t,e,r=[]){if("DEPLOY"!==t){ok(this.abi.filter((e=>{if("function"!==e.type)return!1;const r="view"===e.stateMutability||"view"===e.state_mutability;return"INVOKE"===t?!r:r})).map((t=>t.name)).includes(e),("INVOKE"===t?"invocable":"viewable")+" method not found in abi")}const n=this.abi.find((r=>"DEPLOY"===t?r.name===e&&"constructor"===r.type:r.name===e&&"function"===r.type));if(wM(e,r,n))return;const i=this.parser.methodInputsLength(n);if(r.length!==i)throw Error(`Invalid number of arguments, expected ${i} arguments, but got ${r.length}`);BM(n,r,this.structs,this.enums)}compile(t,e){const r=this.abi.find((e=>e.name===t));if(wM(t,e,r))return[];let n;if(Array.isArray(e))n=e;else{const t=EM(e,r.inputs,this.structs,this.enums);n=Object.values(t),BM(r,n,this.structs,this.enums)}const i=n[Symbol.iterator](),o=r.inputs.reduce(((t,e)=>zk(e.name)&&!nM(e.type)?t:t.concat(function(t,e,r,n){const{name:i,type:o}=e;let{value:s}=t.next();switch(!0){case Vk(o):if(!Array.isArray(s)&&!Ck(s))throw Error(`ABI expected parameter ${i} to be array or long string, got ${s}`);return"string"==typeof s&&(s=Rk(s)),MM(s,e.type,r,n);case"core::starknet::eth_address::EthAddress"===o:return AM(o,s);case Kk(o,r)||Hk(o)||Xk(o):case Zk(o,n):return MM(s,o,r,n);default:return AM(o,s)}}(i,e,this.structs,this.enums))),[]);return Object.defineProperty(o,"__compiled__",{enumerable:!1,writable:!1,value:!0}),o}static compile(t){const e=t=>{const e=(t,r=".")=>{const n=Array.isArray(t)?[t.length.toString(),...t]:t;return Object.entries(n).flatMap((([t,i])=>{let o=i;Pk(o)&&(o=Rk(o)),"entrypoint"===t&&(o=Mk(o));const s=Array.isArray(n)&&"0"===t?"$$len":t;if(hk(o))return[[`${r}${s}`,uM(o)]];if(Object(o)===o){const t=Object.getOwnPropertyNames(Object.getPrototypeOf(o)),n=[...Object.getOwnPropertyNames(o),...t];if(n.includes("isSome")&&n.includes("isNone")){const t=o,n=t.isSome()?0:1;return t.isSome()?e({0:n,1:t.unwrap()},`${r}${s}.`):[[`${r}${s}`,uM(n)]]}if(n.includes("isOk")&&n.includes("isErr")){const t=o,n=t.isOk()?0:1;return e({0:n,1:t.unwrap()},`${r}${s}.`)}if(n.includes("variant")&&n.includes("activeVariant")){const t=o,n=t.activeVariant(),i=Object.keys(t.variant).findIndex((t=>t===n));return"object"==typeof t.unwrap()&&0===Object.keys(t.unwrap()).length?[[`${r}${s}`,uM(i)]]:e({0:i,1:t.unwrap()},`${r}${s}.`)}return e(o,`${r}${s}.`)}return[[`${r}${s}`,uM(o)]]}))};return Object.fromEntries(e(t))};let r;if(Array.isArray(t)){const n=e({...t});r=Object.values(n)}else{const n=e(t);r=Object.values(n)}return Object.defineProperty(r,"__compiled__",{enumerable:!1,writable:!1,value:!0}),r}parse(t,e){const{outputs:r}=this.abi.find((e=>e.name===t)),n=e.flat()[Symbol.iterator](),i=r.flat().reduce(((t,e,r)=>{const i=e.name??r;return t[i]=NM(n,e,this.structs,this.enums,t),t[i]&&t[`${i}_len`]&&delete t[`${i}_len`],t}),{});return 1===Object.keys(i).length&&0 in i?i[0]:i}format(t,e,r){return yM(this.parse(t,e),r)}static getAbiStruct(t){return t.filter((t=>"struct"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{})}static getAbiEnum(t){const e=t.filter((t=>"enum"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{});return delete e["core::bool"],e}static toCalldata(t=[]){return DM.compile(t)}static toHex(t=[]){return DM.compile(t).map((t=>uk(t)))}};nA({},{calculateContractAddressFromHash:()=>tx,calculateDeclareTransactionHash:()=>YM,calculateDeployAccountTransactionHash:()=>WM,calculateDeployTransactionHash:()=>QM,calculateTransactionHash:()=>XM,calculateTransactionHashCommon:()=>JM,computeCompiledClassHash:()=>sx,computeContractClassHash:()=>ux,computeHashOnElements:()=>ZM,computeLegacyContractClassHash:()=>ix,computeSierraContractClassHash:()=>hx,default:()=>nx,feeTransactionVersion:()=>HM,feeTransactionVersion_2:()=>GM,formatSpaces:()=>rx,getSelector:()=>xk,getSelectorFromName:()=>Mk,getVersionsByType:()=>KM,keccakBn:()=>Ak,poseidon:()=>Zg,starknetKeccak:()=>kk,transactionVersion:()=>qM,transactionVersion_2:()=>VM});nA({},{starkCurve:()=>ev,weierstrass:()=>uy});nA({},{parse:()=>UM,parseAlwaysAsBig:()=>jM,stringify:()=>LM,stringifyAlwaysAsBig:()=>zM});var FM=t=>{if(!rv(t))return parseFloat(t);const e=parseInt(t,10);return Number.isSafeInteger(e)?e:BigInt(t)},UM=t=>Mv(String(t),void 0,FM),jM=t=>Mv(String(t),void 0,vv),LM=(t,e,r,n)=>ow(t,e,r,n),zM=LM,qM=_A,VM=EA,HM=AA,GM=kA;function KM(t){return"fee"===t?{v1:HM,v2:GM}:{v1:qM,v2:VM}}function ZM(t){return[...t,t.length].reduce(((t,e)=>Vy(ak(t),ak(e))),0).toString()}function JM(t,e,r,n,i,o,s,a=[]){const h=ZM(i);return ZM([t,e,r,n,h,o,s,...a])}function QM(t,e,r,n,i="constructor"){return JM("0x6465706c6f79",r,t,Mk(i),e,0,n)}function YM(t,e,r,n,i,o,s){return JM("0x6465636c617265",r,e,0,[t],n,i,[o,...s?[s]:[]])}function WM(t,e,r,n,i,o,s,a){return JM("0x6465706c6f795f6163636f756e74",i,t,0,[e,n,...r],o,s,[a])}function XM(t,e,r,n,i,o){return JM("0x696e766f6b65",e,t,0,r,n,i,[o])}function tx(t,e,r,n){const i=ZM(DM.compile(r));return ZM([uM("0x535441524b4e45545f434f4e54524143545f41444452455353"),n,t,e,i])}function ex(t,e){return"attributes"===t||"accessible_scopes"===t?Array.isArray(e)&&0===e.length?void 0:e:"debug_info"===t?null:null===e?void 0:e}function rx(t){let e=!1;const r=[];for(const n of t)'"'===n&&!1==(r.length>0&&"\\"===r.slice(-1)[0])&&(e=!e),e?r.push(n):r.push(":"===n?": ":","===n?", ":n);return r.join("")}function nx(t){const{abi:e,program:r}=t,n=rx(LM({abi:e,program:r},ex));return fA(Gy(sA(n)).toString(16))}function ix(t){const e="string"==typeof t?UM(t):t,r=uk(NA),n=ZM(e.entry_points_by_type.EXTERNAL.flatMap((t=>[t.selector,t.offset]))),i=ZM(e.entry_points_by_type.L1_HANDLER.flatMap((t=>[t.selector,t.offset]))),o=ZM(e.entry_points_by_type.CONSTRUCTOR.flatMap((t=>[t.selector,t.offset]))),s=ZM(e.program.builtins.map((t=>Ok(t)))),a=nx(e),h=ZM(e.program.data);return ZM([r,n,i,o,s,a,h])}function ox(t){const e=t.flatMap((t=>{return[BigInt(t.selector),BigInt(t.offset),(e=t.builtins,tv(e.flatMap((t=>BigInt(Ok(t))))))];var e}));return tv(e)}function sx(t){const e=BigInt(Ok("COMPILED_CLASS_V1")),r=ox(t.entry_points_by_type.EXTERNAL),n=ox(t.entry_points_by_type.L1_HANDLER),i=ox(t.entry_points_by_type.CONSTRUCTOR),o=tv(t.bytecode.map((t=>BigInt(t))));return uk(tv([e,r,n,i,o]))}function ax(t){return tv(t.flatMap((t=>[BigInt(t.selector),BigInt(t.function_idx)])))}function hx(t){const e=BigInt(Ok("CONTRACT_CLASS_V0.1.0")),r=ax(t.entry_points_by_type.EXTERNAL),n=ax(t.entry_points_by_type.L1_HANDLER),i=ax(t.entry_points_by_type.CONSTRUCTOR),o=function(t){const e=rx(LM(t.abi,null));return BigInt(fA(Gy(sA(e)).toString(16)))}(t),s=tv(t.sierra_program.map((t=>BigInt(t))));return uk(tv([e,r,n,i,o,s]))}function ux(t){const e="string"==typeof t?UM(t):t;return"sierra_program"in e?hx(e):ix(e)}function lx(t){const e="string"==typeof t?t:LM(t);return uA(NE(e))}function cx(t){if(Array.isArray(t))return t;const e=oA(IE(hA(t)));return UM(e)}function fx(){return By(Py.randomPrivateKey())}function dx(t){return fA(t).toLowerCase()}function px(t){if(!t)throw Error("formatSignature: provided signature is undefined");if(Array.isArray(t))return t.map((t=>uk(t)));try{const{r:e,s:r}=t;return[uk(e),uk(r)]}catch(t){throw new Error("Signature need to be weierstrass.SignatureType or an array for custom")}}function mx(t){return mk(px(t))}function gx(t){return gk(px(t))}function yx(t,e=.5){const r=Math.round(100*(1+e));return ak(t)*ak(r)/100n}function vx(t){return"sierra_program"in("string"==typeof t?UM(t):t)}nA({},{compressProgram:()=>lx,decompressProgram:()=>cx,estimatedFeeToMaxFee:()=>yx,formatSignature:()=>px,makeAddress:()=>dx,randomAddress:()=>fx,signatureToDecimalArray:()=>mx,signatureToHexArray:()=>gx});var wx="undefined"!=typeof window&&window.fetch||"undefined"!=typeof global&&global.fetch||tA;function bx(t){return new Promise((e=>{setTimeout(e,t)}))}function _x(t){const e={...t};return delete e.sierra_program_debug_info,e.abi=rx(LM(t.abi)),e.sierra_program=rx(LM(t.sierra_program)),e.sierra_program=lx(e.sierra_program),e}function Ex(t){const e="string"==typeof t?UM(t):t;return vx(t)?_x(e):{...e,..."program"in e&&{program:lx(e.program)}}}nA({},{createSierraContractClass:()=>_x,parseContract:()=>Ex,wait:()=>bx});var Ax=class extends Error{constructor(t){super(t),Object.defineProperty(this,"name",{value:new.target.name,enumerable:!1,configurable:!0}),function(t,e){const{setPrototypeOf:r}=Object;r?r(t,e):t.__proto__=e}(this,new.target.prototype),function(t,e=t.constructor){const{captureStackTrace:r}=Error;r&&r(t,e)}(this)}},kx=class extends Ax{},Mx=class extends kx{constructor(t,e){super(t),this.errorCode=e}},xx=class extends kx{constructor(t,e){super(t),this.errorCode=e}};nA({},{StarknetIdContract:()=>Bx,getStarknetIdContract:()=>Dx,useDecoded:()=>Ox,useEncoded:()=>$x});var Sx="abcdefghijklmnopqrstuvwxyz0123456789-",Nx=BigInt(Sx.length+1),Ix="这来",Cx=BigInt(Sx.length),Tx=BigInt(Ix.length),Px=BigInt(Ix.length+1);function Rx(t){let e=0;for(;t.endsWith(Ix[Ix.length-1]);)t=t.substring(0,t.length-1),e+=1;return[t,e]}function Ox(t){let e="";return t.forEach((t=>{for(;t!==MA;){const r=t%Nx;if(t/=Nx,r===BigInt(Sx.length)){const r=t/Px;if(r===MA){const n=t%Px;t=r,e+=n===MA?Sx[0]:Ix[Number(n)-1]}else{e+=Ix[Number(t%Tx)],t/=Tx}}else e+=Sx[Number(r)]}const[r,n]=Rx(e);n&&(e=r+(n%2==0?Ix[Ix.length-1].repeat(n/2-1)+Ix[0]+Sx[1]:Ix[Ix.length-1].repeat((n-1)/2+1))),e+="."})),e?e.concat("stark"):e}function $x(t){let e=BigInt(0),r=BigInt(1);if(t.endsWith(Ix[0]+Sx[1])){const[e,r]=Rx(t.substring(0,t.length-2));t=e+Ix[Ix.length-1].repeat(2*(r+1))}else{const[e,r]=Rx(t);r&&(t=e+Ix[Ix.length-1].repeat(1+2*(r-1)))}for(let n=0;n<t.length;n+=1){const i=t[n],o=Sx.indexOf(i),s=BigInt(Sx.indexOf(i));if(-1!==o)n===t.length-1&&t[n]===Sx[0]?(e+=r*Cx,r*=Nx,r*=Nx):(e+=r*s,r*=Nx);else if(-1!==Ix.indexOf(i)){e+=r*Cx,r*=Nx;const o=(n===t.length-1?1:0)+Ix.indexOf(i);e+=r*BigInt(o),r*=Tx}}return e}var Bx=(t=>(t.MAINNET="0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678",t.TESTNET="0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce",t))(Bx||{});function Dx(t){switch(t){case"0x534e5f4d41494e":return"0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678";case"0x534e5f474f45524c49":return"0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce";default:throw new Error("Starknet.id is not yet deployed on this network")}}async function Fx(t,e,r){const n=await t.getChainId(),i=r??Dx(n);try{const r=await t.callContract({contractAddress:i,entrypoint:"address_to_domain",calldata:DM.compile({address:e})}),n=Ox(r.result.map((t=>BigInt(t))).slice(1));if(!n)throw Error("Starkname not found");return n}catch(t){if(t instanceof Error&&"Starkname not found"===t.message)throw t;throw Error("Could not get stark name")}}async function Ux(t,e,r){const n=await t.getChainId(),i=r??Dx(n);try{return(await t.callContract({contractAddress:i,entrypoint:"domain_to_address",calldata:DM.compile({domain:[$x(e.replace(".stark","")).toString(10)]})})).result[0]}catch{throw Error("Could not get address from stark name")}}var jx=Object.values(GA),Lx=class{constructor(t){this.hash=null,this.number=null,this.tag=null,this.valueOf=()=>this.number,this.toString=()=>this.hash,this.setIdentifier(t)}setIdentifier(t){"string"==typeof t&&sk(t)?this.hash=t:"bigint"==typeof t?this.hash=uk(t):"number"==typeof t?this.number=t:"string"==typeof t&&jx.includes(t)?this.tag=t:this.tag="pending"}get queryIdentifier(){return null!==this.number?`blockNumber=${this.number}`:null!==this.hash?`blockHash=${this.hash}`:`blockNumber=${this.tag}`}get identifier(){return null!==this.number?{block_number:this.number}:null!==this.hash?{block_hash:this.hash}:this.tag}set identifier(t){this.setIdentifier(t)}get sequencerIdentifier(){return null!==this.hash?{blockHash:this.hash}:{blockNumber:this.number??this.tag}}},zx=(t,e=!1)=>{e||console.warn("Using default public node url, please provide nodeUrl in provider options!");const r="SN_MAIN"===t?$A:OA;return r[Math.floor(Math.random()*r.length)]},qx={"Content-Type":"application/json"},Vx="pending",Hx=200,Gx=class{constructor(t){this.responseParser=new class{parseGetBlockResponse(t){return{timestamp:t.timestamp,block_hash:"block_hash"in t?t.block_hash:"",block_number:"block_number"in t?t.block_number:-1,new_root:"new_root"in t?t.new_root:"",parent_hash:t.parent_hash,status:"status"in t?t.status:"PENDING",transactions:t.transactions}}parseGetTransactionResponse(t){return{calldata:"calldata"in t?t.calldata:[],contract_address:"contract_address"in t?t.contract_address:"",sender_address:"sender_address"in t?t.sender_address:"",max_fee:"max_fee"in t?t.max_fee:"",nonce:"nonce"in t?t.nonce:"",signature:"signature"in t?t.signature:[],transaction_hash:t.transaction_hash,version:t.version}}parseFeeEstimateResponse(t){return{overall_fee:ak(t[0].overall_fee),gas_consumed:ak(t[0].gas_consumed),gas_price:ak(t[0].gas_price)}}parseFeeEstimateBulkResponse(t){return t.map((t=>({overall_fee:ak(t.overall_fee),gas_consumed:ak(t.gas_consumed),gas_price:ak(t.gas_price)})))}parseCallContractResponse(t){return{result:t}}parseSimulateTransactionResponse(t){return t.map((t=>({...t,suggestedMaxFee:yx(BigInt(t.fee_estimation.overall_fee))})))}parseContractClassResponse(t){return{...t,abi:"string"==typeof t.abi?JSON.parse(t.abi):t.abi}}},this.getBlockHashAndNumber=this.getBlockLatestAccepted,this.getStateUpdate=this.getBlockStateUpdate,this.traceBlockTransactions=this.getBlockTransactionsTraces,this.getTransactionCount=this.getBlockTransactionCount,this.traceTransaction=this.getTransactionTrace,this.getSimulateTransaction=this.simulateTransaction;const{nodeUrl:e,retries:r,headers:n,blockIdentifier:i,chainId:o}=t||{};Object.values(CA).includes(e)?this.nodeUrl=zx(e,t?.default):this.nodeUrl=e||zx(void 0,t?.default),this.retries=r||Hx,this.headers={...qx,...n},this.blockIdentifier=i||Vx,this.chainId=o}fetch(t,e,r=0){const n={id:r,jsonrpc:"2.0",method:t,...e&&{params:e}};return wx(this.nodeUrl,{method:"POST",body:LM(n),headers:this.headers})}errorHandler(t,e,r,n){if(r){const{code:n,message:i,data:o}=r;throw new kx(`RPC: ${t} with params ${LM(e)}\n ${n}: ${i}: ${LM(o)}`)}if(n instanceof kx)throw n;if(n)throw Error(n.message)}async fetchEndpoint(t,e){try{const r=await this.fetch(t,e),{error:n,result:i}=await r.json();return this.errorHandler(t,e,n),i}catch(r){throw this.errorHandler(t,e,r?.response?.data,r),r}}async getChainId(){return this.chainId??(this.chainId=await this.fetchEndpoint("starknet_chainId")),this.chainId}async getSpecVersion(){return this.fetchEndpoint("starknet_specVersion")}async getNonceForAddress(t,e=this.blockIdentifier){const r=uk(t),n=new Lx(e).identifier;return this.fetchEndpoint("starknet_getNonce",{contract_address:r,block_id:n})}async getBlock(t=this.blockIdentifier){return this.getBlockWithTxHashes(t).then(this.responseParser.parseGetBlockResponse)}async getBlockLatestAccepted(){return this.fetchEndpoint("starknet_blockHashAndNumber")}async getBlockNumber(){return this.fetchEndpoint("starknet_blockNumber")}async getBlockWithTxHashes(t=this.blockIdentifier){const e=new Lx(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxHashes",{block_id:e})}async getBlockWithTxs(t=this.blockIdentifier){const e=new Lx(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxs",{block_id:e})}async getBlockStateUpdate(t=this.blockIdentifier){const e=new Lx(t).identifier;return this.fetchEndpoint("starknet_getStateUpdate",{block_id:e})}async getBlockTransactionsTraces(t=this.blockIdentifier){const e=new Lx(t).identifier;return this.fetchEndpoint("starknet_traceBlockTransactions",{block_id:e})}async getBlockTransactionCount(t=this.blockIdentifier){const e=new Lx(t).identifier;return this.fetchEndpoint("starknet_getBlockTransactionCount",{block_id:e})}async getPendingTransactions(){const{transactions:t}=await this.getBlock("pending");return Promise.all(t.map((t=>this.getTransactionByHash(t))))}async getTransaction(t){return this.getTransactionByHash(t).then(this.responseParser.parseGetTransactionResponse)}async getTransactionByHash(t){const e=uk(t);return this.fetchEndpoint("starknet_getTransactionByHash",{transaction_hash:e})}async getTransactionByBlockIdAndIndex(t,e){const r=new Lx(t).identifier;return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex",{block_id:r,index:e})}async getTransactionReceipt(t){const e=uk(t);return this.fetchEndpoint("starknet_getTransactionReceipt",{transaction_hash:e})}async getTransactionTrace(t){const e=uk(t);return this.fetchEndpoint("starknet_traceTransaction",{transaction_hash:e})}async getTransactionStatus(t){const e=uk(t);return this.fetchEndpoint("starknet_getTransactionStatus",{transaction_hash:e})}async simulateTransaction(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!1,skipFeeCharge:n=!0}){const i=new Lx(e).identifier,o=[];return r&&o.push(KA.ESimulationFlag.SKIP_VALIDATE),n&&o.push(KA.ESimulationFlag.SKIP_FEE_CHARGE),this.fetchEndpoint("starknet_simulateTransactions",{block_id:i,transactions:t.map((t=>this.buildTransaction(t))),simulation_flags:o}).then(this.responseParser.parseSimulateTransactionResponse)}async waitForTransaction(t,e){const r=uk(t);let{retries:n}=this,i=!1,o=!1;const s=e?.retryInterval??5e3,a=e?.errorStates??[KA.ETransactionStatus.REJECTED,KA.ETransactionExecutionStatus.REVERTED],h=e?.successStates??[KA.ETransactionExecutionStatus.SUCCEEDED,KA.ETransactionStatus.ACCEPTED_ON_L2,KA.ETransactionStatus.ACCEPTED_ON_L1];let u;for(;!i;){await bx(s);try{u=await this.getTransactionStatus(r);const t=u.execution_status,e=u.finality_status;if(!e){throw new Error("waiting for transaction status")}if(h.includes(t)||h.includes(e))i=!0;else if(a.includes(t)||a.includes(e)){const r=`${t}: ${e}`,n=new Error(r);throw n.response=u,o=!0,n}}catch(t){if(t instanceof Error&&o)throw t;if(n<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}n-=1}let l=null;for(;null===l;){try{l=await this.getTransactionReceipt(r)}catch(t){if(n<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}n-=1,await bx(s)}return l}async getStorageAt(t,e,r=this.blockIdentifier){const n=uk(t),i=ck(e),o=new Lx(r).identifier;return this.fetchEndpoint("starknet_getStorageAt",{contract_address:n,key:i,block_id:o})}async getClassHashAt(t,e=this.blockIdentifier){const r=uk(t),n=new Lx(e).identifier;return this.fetchEndpoint("starknet_getClassHashAt",{block_id:n,contract_address:r})}async getClassByHash(t){return this.getClass(t)}async getClass(t,e=this.blockIdentifier){const r=uk(t),n=new Lx(e).identifier;return this.fetchEndpoint("starknet_getClass",{class_hash:r,block_id:n}).then(this.responseParser.parseContractClassResponse)}async getClassAt(t,e=this.blockIdentifier){const r=uk(t),n=new Lx(e).identifier;return this.fetchEndpoint("starknet_getClassAt",{block_id:n,contract_address:r}).then(this.responseParser.parseContractClassResponse)}async getCode(t,e){throw new Error("RPC does not implement getCode function")}async getContractVersion(t,e,{blockIdentifier:r=this.blockIdentifier,compiler:n=!0}={}){let i;if(t)i=await this.getClassAt(t,r);else{if(!e)throw Error("getContractVersion require contractAddress or classHash");i=await this.getClass(e,r)}if(vx(i)){if(n){return{cairo:"1",compiler:sM(i.abi).compiler}}return{cairo:"1",compiler:void 0}}return{cairo:"0",compiler:"0"}}async getEstimateFee(t,e,r=this.blockIdentifier){return this.getInvokeEstimateFee(t,e,r)}async getInvokeEstimateFee(t,e,r=this.blockIdentifier){const n=new Lx(r).identifier,i=this.buildTransaction({type:"INVOKE_FUNCTION",...t,...e},"fee");return this.fetchEndpoint("starknet_estimateFee",{request:[i],block_id:n}).then(this.responseParser.parseFeeEstimateResponse)}async getDeclareEstimateFee(t,e,r=this.blockIdentifier){const n=new Lx(r).identifier,i=this.buildTransaction({type:"DECLARE",...t,...e},"fee");return this.fetchEndpoint("starknet_estimateFee",{request:[i],block_id:n}).then(this.responseParser.parseFeeEstimateResponse)}async getDeployAccountEstimateFee(t,e,r=this.blockIdentifier){const n=new Lx(r).identifier,i=this.buildTransaction({type:"DEPLOY_ACCOUNT",...t,...e},"fee");return this.fetchEndpoint("starknet_estimateFee",{request:[i],block_id:n}).then(this.responseParser.parseFeeEstimateResponse)}async getEstimateFeeBulk(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!1}){r&&console.warn("getEstimateFeeBulk RPC does not support skipValidate");const n=new Lx(e).identifier;return this.fetchEndpoint("starknet_estimateFee",{request:t.map((t=>this.buildTransaction(t,"fee"))),block_id:n}).then(this.responseParser.parseFeeEstimateBulkResponse)}async invokeFunction(t,e){return this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{sender_address:t.contractAddress,calldata:DM.toHex(t.calldata),type:KA.ETransactionType.INVOKE,max_fee:uk(e.maxFee||0),version:"0x1",signature:gx(t.signature),nonce:uk(e.nonce)}})}async declareContract({contract:t,signature:e,senderAddress:r,compiledClassHash:n},i){return vx(t)?this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:KA.ETransactionType.DECLARE,contract_class:{sierra_program:cx(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},compiled_class_hash:n||"",version:bA,max_fee:uk(i.maxFee||0),signature:gx(e),sender_address:r,nonce:uk(i.nonce)}}):this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:KA.ETransactionType.DECLARE,contract_class:{program:t.program,entry_points_by_type:t.entry_points_by_type,abi:t.abi},version:wA,max_fee:uk(i.maxFee||0),signature:gx(e),sender_address:r,nonce:uk(i.nonce)}})}async deployAccountContract({classHash:t,constructorCalldata:e,addressSalt:r,signature:n},i){return this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{constructor_calldata:DM.toHex(e||[]),class_hash:uk(t),contract_address_salt:uk(r||0),type:KA.ETransactionType.DEPLOY_ACCOUNT,max_fee:uk(i.maxFee||0),version:uk(i.version||0),signature:gx(n),nonce:uk(i.nonce)}})}async callContract(t,e=this.blockIdentifier){const r=new Lx(e).identifier,n=await this.fetchEndpoint("starknet_call",{request:{contract_address:t.contractAddress,entry_point_selector:Mk(t.entrypoint),calldata:DM.toHex(t.calldata)},block_id:r});return this.responseParser.parseCallContractResponse(n)}async estimateMessageFee(t,e=this.blockIdentifier){const{from_address:r,to_address:n,entry_point_selector:i,payload:o}=t,s={from_address:uk(r),to_address:uk(n),entry_point_selector:xk(i),payload:bk(o)},a=new Lx(e).identifier;return this.fetchEndpoint("starknet_estimateMessageFee",{message:s,block_id:a})}async getSyncingStats(){return this.fetchEndpoint("starknet_syncing")}async getEvents(t){return this.fetchEndpoint("starknet_getEvents",{filter:t})}async getStarkName(t,e){return Fx(this,t,e)}async getAddressFromStarkName(t,e){return Ux(this,t,e)}buildTransaction(t,e){const r=KM(e),n={signature:gx(t.signature),nonce:uk(t.nonce),max_fee:uk(t.maxFee||0)};if("INVOKE_FUNCTION"===t.type)return{type:KA.ETransactionType.INVOKE,sender_address:t.contractAddress,calldata:DM.toHex(t.calldata),version:uk(t.version||r.v1),...n};if("DECLARE"===t.type)return vx(t.contract)?{type:t.type,contract_class:{...t.contract,sierra_program:cx(t.contract.sierra_program)},compiled_class_hash:t.compiledClassHash||"",sender_address:t.senderAddress,version:uk(t.version||r.v2),...n}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:uk(t.version||r.v1),...n};if("DEPLOY_ACCOUNT"===t.type)return{type:t.type,constructor_calldata:DM.toHex(t.constructorCalldata||[]),class_hash:uk(t.classHash),contract_address_salt:uk(t.addressSalt||0),version:uk(t.version||r.v1),...n};throw Error("RPC buildTransaction received unknown TransactionType")}},Kx=/^(?:\w+:)?\/\/(\S+)$/,Zx=/^localhost[:?\d]*(?:[^:?\d]\S*)?$/,Jx=/^[^\s.]+\.\S{2,}$/;function Qx(t,e,r){return function(t){if(!t)return!1;if("string"!=typeof t)return!1;const e=t.match(Kx);if(!e)return!1;const r=e[1];return!(!r||!Zx.test(r)&&!Jx.test(r))}(r)?r:eA(t,r??e)}var Yx={network:"SN_GOERLI",blockIdentifier:"pending"},Wx=class{constructor(t=Yx){this.responseParser=new class extends class{}{parseGetBlockResponse(t){return{...t,new_root:t.state_root,parent_hash:t.parent_block_hash,transactions:Object.values(t.transactions).map((t=>"transaction_hash"in t&&t.transaction_hash)).filter(Boolean)}}parseGetTransactionResponse(t){if("NOT_RECEIVED"===t.status&&"NOT_RECEIVED"===t.finality_status)throw new kx;return{...t,calldata:"calldata"in t.transaction?t.transaction.calldata:[],contract_class:"contract_class"in t.transaction?t.transaction.contract_class:void 0,entry_point_selector:"entry_point_selector"in t.transaction?t.transaction.entry_point_selector:void 0,max_fee:"max_fee"in t.transaction?t.transaction.max_fee:void 0,nonce:t.transaction.nonce,sender_address:"sender_address"in t.transaction?t.transaction.sender_address:void 0,signature:"signature"in t.transaction?t.transaction.signature:void 0,transaction_hash:"transaction_hash"in t.transaction?t.transaction.transaction_hash:void 0,version:"version"in t.transaction?t.transaction.version:void 0}}parseGetTransactionReceiptResponse(t){return{...t,messages_sent:t.l2_to_l1_messages,..."revert_error"in t&&{revert_reason:t.revert_error}}}parseFeeEstimateResponse(t){if("overall_fee"in t){let e={};try{e={gas_consumed:ak(t.gas_usage),gas_price:ak(t.gas_price)}}catch{}return{overall_fee:ak(t.overall_fee),...e}}return{overall_fee:ak(t.amount)}}parseFeeEstimateBulkResponse(t){return[].concat(t).map((t=>{if("overall_fee"in t){let e={};try{e={gas_consumed:ak(t.gas_usage),gas_price:ak(t.gas_price)}}catch{}return{overall_fee:ak(t.overall_fee),...e}}return{overall_fee:ak(t.amount)}}))}parseSimulateTransactionResponse(t){const e="overall_fee"in t.fee_estimation?t.fee_estimation.overall_fee:t.fee_estimation.amount;return[{transaction_trace:t.trace,fee_estimation:t.fee_estimation,suggestedMaxFee:yx(BigInt(e))}]}parseCallContractResponse(t){return{result:t.result}}parseInvokeFunctionResponse(t){return{transaction_hash:t.transaction_hash}}parseDeployContractResponse(t){return{transaction_hash:t.transaction_hash,contract_address:t.address}}parseDeclareContractResponse(t){return{transaction_hash:t.transaction_hash,class_hash:t.class_hash}}parseGetStateUpdateResponse(t){const e=Object.entries(t.state_diff.nonces).map((([t,e])=>({contract_address:t,nonce:e}))),r=Object.entries(t.state_diff.storage_diffs).map((([t,e])=>({address:t,storage_entries:e})));return{...t,state_diff:{...t.state_diff,storage_diffs:r,nonces:e}}}parseContractClassResponse(t){const e=vx(t)?t:Ex(t);return{...e,abi:"string"==typeof e.abi?JSON.parse(e.abi):e.abi}}},"network"in t?(this.baseUrl=Wx.getNetworkFromName(t.network),this.feederGatewayUrl=Qx(this.baseUrl,"feeder_gateway"),this.gatewayUrl=Qx(this.baseUrl,"gateway")):(this.baseUrl=t.baseUrl,this.feederGatewayUrl=Qx(this.baseUrl,"feeder_gateway",t.feederGatewayUrl),this.gatewayUrl=Qx(this.baseUrl,"gateway",t.gatewayUrl)),this.chainId=t?.chainId??Wx.getChainIdFromBaseUrl(this.baseUrl),this.headers=t.headers,this.blockIdentifier=t?.blockIdentifier||Yx.blockIdentifier}static getNetworkFromName(t){switch(t){case"SN_MAIN":case"0x534e5f4d41494e":return"https://alpha-mainnet.starknet.io";case"SN_GOERLI":case"0x534e5f474f45524c49":return"https://alpha4.starknet.io";default:throw new Error("Could not detect base url from NetworkName")}}static getChainIdFromBaseUrl(t){try{return new URL(t).host.includes("mainnet.starknet.io")?"0x534e5f4d41494e":"0x534e5f474f45524c49"}catch{return console.error(`Could not parse baseUrl: ${t}`),"0x534e5f474f45524c49"}}getFetchUrl(t){return["add_transaction"].includes(t)?this.gatewayUrl:this.feederGatewayUrl}getFetchMethod(t){return["add_transaction","call_contract","estimate_fee","estimate_message_fee","estimate_fee_bulk","simulate_transaction"].includes(t)?"POST":"GET"}getQueryString(t){if(void 0===(e=t)||0===Object.keys(e).length||1===Object.keys(e).length&&Object.entries(e).every((([t,e])=>"blockIdentifier"===t&&null===e)))return"";var e;const r=Object.entries(t).map((([t,e])=>{if("blockIdentifier"===t){return`${new Lx(e).queryIdentifier}`}return`${t}=${e}`})).join("&");return`?${r}`}getHeaders(t){return"POST"===t?{"Content-Type":"application/json",...this.headers}:this.headers}async fetchEndpoint(t,...[e,r]){const n=this.getFetchUrl(t),i=this.getFetchMethod(t),o=this.getQueryString(e),s=eA(n,t,o);return this.fetch(s,{method:i,body:r})}async fetch(t,e){const r=Qx(this.baseUrl,"",t),n=e?.method??"GET",i=this.getHeaders(n),o=LM(e?.body);try{const t=await wx(r,{method:n,body:o,headers:i}),s=await t.text();if(!t.ok){let e;try{e=UM(s)}catch{throw new xx(t.statusText,t.status)}throw new Mx(e.message,e.code)}return(e?.parseAlwaysAsBigInt?jM:UM)(s)}catch(t){if(t instanceof Error&&!(t instanceof kx))throw Error(`Could not ${n} from endpoint \`${r}\`: ${t.message}`);throw t}}async getChainId(){return Promise.resolve(this.chainId)}async callContract({contractAddress:t,entrypoint:e,calldata:r=[]},n=this.blockIdentifier){return this.fetchEndpoint("call_contract",{blockIdentifier:n},{contract_address:t,entry_point_selector:Mk(e),calldata:DM.compile(r)}).then(this.responseParser.parseCallContractResponse)}async getBlock(t=this.blockIdentifier){return this.fetchEndpoint("get_block",{blockIdentifier:t}).then(this.responseParser.parseGetBlockResponse)}async getNonceForAddress(t,e=this.blockIdentifier){return this.fetchEndpoint("get_nonce",{contractAddress:t,blockIdentifier:e})}async getStorageAt(t,e,r=this.blockIdentifier){const n=ak(e).toString(10);return this.fetchEndpoint("get_storage_at",{blockIdentifier:r,contractAddress:t,key:n})}async getTransaction(t){const e=uk(t);return this.fetchEndpoint("get_transaction",{transactionHash:e}).then((t=>{if(1===Object.values(t).length)throw new kx(t.status);return this.responseParser.parseGetTransactionResponse(t)}))}async getTransactionReceipt(t){const e=uk(t);return this.fetchEndpoint("get_transaction_receipt",{transactionHash:e}).then(this.responseParser.parseGetTransactionReceiptResponse)}async getClassAt(t,e=this.blockIdentifier){return this.fetchEndpoint("get_full_contract",{blockIdentifier:e,contractAddress:t}).then(this.responseParser.parseContractClassResponse)}async getClassHashAt(t,e=this.blockIdentifier){return this.fetchEndpoint("get_class_hash_at",{blockIdentifier:e,contractAddress:t})}async getClassByHash(t,e=this.blockIdentifier){return this.fetchEndpoint("get_class_by_hash",{classHash:t,blockIdentifier:e}).then(this.responseParser.parseContractClassResponse)}async getCompiledClassByClassHash(t,e=this.blockIdentifier){return this.fetchEndpoint("get_compiled_class_by_class_hash",{classHash:t,blockIdentifier:e})}async getContractVersion(t,e,{blockIdentifier:r=this.blockIdentifier,compiler:n=!0}={}){let i;if(t)i=await this.getClassAt(t,r);else{if(!e)throw Error("getContractVersion require contractAddress or classHash");i=await this.getClassByHash(e,r)}if(vx(i)){if(n){return{cairo:"1",compiler:sM(i.abi).compiler}}return{cairo:"1",compiler:void 0}}return{cairo:"0",compiler:"0"}}async invokeFunction(t,e){return this.fetchEndpoint("add_transaction",void 0,{type:"INVOKE_FUNCTION",sender_address:t.contractAddress,calldata:DM.compile(t.calldata??[]),signature:mx(t.signature),nonce:uk(e.nonce),max_fee:uk(e.maxFee||0),version:"0x1"}).then(this.responseParser.parseInvokeFunctionResponse)}async deployAccountContract({classHash:t,constructorCalldata:e,addressSalt:r,signature:n},i){return this.fetchEndpoint("add_transaction",void 0,{type:"DEPLOY_ACCOUNT",contract_address_salt:r??fx(),constructor_calldata:DM.compile(e??[]),class_hash:uk(t),max_fee:uk(i.maxFee||0),version:uk(i.version||0),nonce:uk(i.nonce),signature:mx(n)}).then(this.responseParser.parseDeployContractResponse)}async declareContract({senderAddress:t,contract:e,signature:r,compiledClassHash:n},i){return vx(e)?this.fetchEndpoint("add_transaction",void 0,{type:"DECLARE",sender_address:t,compiled_class_hash:n,contract_class:e,nonce:uk(i.nonce),signature:mx(r),max_fee:uk(i.maxFee||0),version:uk(VM)}).then(this.responseParser.parseDeclareContractResponse):this.fetchEndpoint("add_transaction",void 0,{type:"DECLARE",contract_class:e,nonce:uk(i.nonce),signature:mx(r),sender_address:t,max_fee:uk(i.maxFee||0),version:uk(qM)}).then(this.responseParser.parseDeclareContractResponse)}async getEstimateFee(t,e,r=this.blockIdentifier,n=!1){return this.getInvokeEstimateFee(t,e,r,n)}async getInvokeEstimateFee(t,e,r=this.blockIdentifier,n=!1){const i=this.buildTransaction({type:"INVOKE_FUNCTION",...t,...e},"fee");return this.fetchEndpoint("estimate_fee",{blockIdentifier:r,skipValidate:n},i).then(this.responseParser.parseFeeEstimateResponse)}async getDeclareEstimateFee(t,e,r=this.blockIdentifier,n=!1){const i=this.buildTransaction({type:"DECLARE",...t,...e},"fee");return this.fetchEndpoint("estimate_fee",{blockIdentifier:r,skipValidate:n},i).then(this.responseParser.parseFeeEstimateResponse)}async getDeployAccountEstimateFee(t,e,r=this.blockIdentifier,n=!1){const i=this.buildTransaction({type:"DEPLOY_ACCOUNT",...t,...e},"fee");return this.fetchEndpoint("estimate_fee",{blockIdentifier:r,skipValidate:n},i).then(this.responseParser.parseFeeEstimateResponse)}async getEstimateFeeBulk(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!1}){const n=t.map((t=>this.buildTransaction(t,"fee")));return this.fetchEndpoint("estimate_fee_bulk",{blockIdentifier:e,skipValidate:r},n).then(this.responseParser.parseFeeEstimateBulkResponse)}async getCode(t,e=this.blockIdentifier){return this.fetchEndpoint("get_code",{contractAddress:t,blockIdentifier:e})}async waitForTransaction(t,e){let r,n=!1,i=0;const o=e?.retryInterval??5e3,s=e?.errorStates??["REJECTED","NOT_RECEIVED","REVERTED"],a=e?.successStates??["SUCCEEDED","ACCEPTED_ON_L1","ACCEPTED_ON_L2"];for(;!n;)if(await bx(o),r=await this.getTransactionStatus(t),"NOT_RECEIVED"===r.finality_status&&i<3)i+=1;else if(a.includes(r.finality_status)||a.includes(r.execution_status))n=!0;else if(s.includes(r.finality_status)||s.includes(r.execution_status)){let t;t=r.tx_failure_reason?`${r.tx_status}: ${r.tx_failure_reason.code}\n${r.tx_failure_reason.error_message}`:r.tx_revert_reason?`${r.tx_status}: ${r.tx_revert_reason}`:r.tx_status;const e=new Error(t);throw e.response=r,e}return await this.getTransactionReceipt(t)}async getTransactionStatus(t){const e=uk(t);return this.fetchEndpoint("get_transaction_status",{transactionHash:e})}async getContractAddresses(){return this.fetchEndpoint("get_contract_addresses")}async getTransactionTrace(t){const e=uk(t);return this.fetchEndpoint("get_transaction_trace",{transactionHash:e})}async estimateMessageFee({from_address:t,to_address:e,entry_point_selector:r,payload:n},i=this.blockIdentifier){const o={from_address:vk(t),to_address:wk(e),entry_point_selector:xk(r),payload:bk(n)};return this.fetchEndpoint("estimate_message_fee",{blockIdentifier:i},o)}async getSimulateTransaction(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!1,skipExecute:n=!1}){t.length>1&&console.warn("Sequencer simulate process only first element from invocations list"),n&&console.warn("Sequencer can't skip account __execute__");const i=this.buildTransaction(t[0]);return this.fetchEndpoint("simulate_transaction",{blockIdentifier:e,skipValidate:r??!1},i).then(this.responseParser.parseSimulateTransactionResponse)}async getStateUpdate(t=this.blockIdentifier){const e=new Lx(t).sequencerIdentifier;return this.fetchEndpoint("get_state_update",{...e}).then(this.responseParser.parseGetStateUpdateResponse)}async getBlockTraces(t=this.blockIdentifier){const e=new Lx(t).sequencerIdentifier;return this.fetchEndpoint("get_block_traces",{...e})}async getStarkName(t,e){return Fx(this,t,e)}async getAddressFromStarkName(t,e){return Ux(this,t,e)}buildTransaction(t,e){const r=KM(e),n={signature:mx(t.signature),nonce:uk(t.nonce)};if("INVOKE_FUNCTION"===t.type)return{type:t.type,sender_address:t.contractAddress,calldata:DM.compile(t.calldata??[]),version:uk(t.version||r.v1),...n};if("DECLARE"===t.type)return vx(t.contract)?{type:t.type,contract_class:t.contract,compiled_class_hash:t.compiledClassHash,sender_address:t.senderAddress,version:uk(t.version||r.v2),...n}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:uk(t.version||r.v1),...n};if("DEPLOY_ACCOUNT"===t.type)return{type:t.type,constructor_calldata:DM.compile(t.constructorCalldata||[]),class_hash:uk(t.classHash),contract_address_salt:uk(t.addressSalt||0),version:uk(t.version||r.v1),...n};throw Error("Sequencer buildTransaction received unknown TransactionType")}},Xx=class{constructor(t){this.provider=t instanceof Xx?t.provider:t instanceof Gx||t instanceof Wx?t:t&&"rpc"in t?new Gx(t.rpc):t&&"sequencer"in t?new Wx(t.sequencer):new Gx}async getChainId(){return this.provider.getChainId()}async getBlock(t){return this.provider.getBlock(t)}async getClassAt(t,e){return this.provider.getClassAt(t,e)}async getClassHashAt(t,e){return this.provider.getClassHashAt(t,e)}getClassByHash(t){return this.provider.getClassByHash(t)}async getEstimateFee(t,e,r){return this.provider.getEstimateFee(t,e,r)}async getInvokeEstimateFee(t,e,r,n){return this.provider.getInvokeEstimateFee(t,e,r,n)}async getEstimateFeeBulk(t,e){return this.provider.getEstimateFeeBulk(t,e)}async getNonceForAddress(t,e){return this.provider.getNonceForAddress(t,e)}async getStorageAt(t,e,r){return this.provider.getStorageAt(t,e,r)}async getTransaction(t){return this.provider.getTransaction(t)}async getTransactionReceipt(t){return this.provider.getTransactionReceipt(t)}async callContract(t,e){return this.provider.callContract(t,e)}async invokeFunction(t,e){return this.provider.invokeFunction(t,e)}async deployAccountContract(t,e){return this.provider.deployAccountContract(t,e)}async declareContract(t,e){return this.provider.declareContract(t,e)}async getDeclareEstimateFee(t,e,r,n){return this.provider.getDeclareEstimateFee(t,e,r,n)}getDeployAccountEstimateFee(t,e,r,n){return this.provider.getDeployAccountEstimateFee(t,e,r,n)}async getCode(t,e){return this.provider.getCode(t,e)}async waitForTransaction(t,e){return this.provider.waitForTransaction(t,e)}async getSimulateTransaction(t,e){return this.provider.getSimulateTransaction(t,e)}async getStateUpdate(t){return this.provider.getStateUpdate(t)}async getStarkName(t,e){return Fx(this,t,e)}async getAddressFromStarkName(t,e){return Ux(this,t,e)}async getContractVersion(t,e,r){return this.provider.getContractVersion(t,e,r)}};nA({},{fromCallsToExecuteCalldata:()=>eS,fromCallsToExecuteCalldataWithNonce:()=>rS,fromCallsToExecuteCalldata_cairo1:()=>iS,getExecuteCalldata:()=>oS,transformCallsToMulticallArrays:()=>tS,transformCallsToMulticallArrays_cairo1:()=>nS});var tS=t=>{const e=[],r=[];return t.forEach((t=>{const n=DM.compile(t.calldata||[]);e.push({to:ak(t.contractAddress).toString(10),selector:ak(Mk(t.entrypoint)).toString(10),data_offset:r.length.toString(),data_len:n.length.toString()}),r.push(...n)})),{callArray:e,calldata:DM.compile({calldata:r})}},eS=t=>{const{callArray:e,calldata:r}=tS(t);return[...DM.compile({callArray:e}),...r]},rS=(t,e)=>[...eS(t),ak(e).toString()],nS=t=>{const e=t.map((t=>({to:ak(t.contractAddress).toString(10),selector:ak(Mk(t.entrypoint)).toString(10),calldata:DM.compile(t.calldata||[])})));return e},iS=t=>{const e=t.map((t=>({contractAddress:t.contractAddress,entrypoint:t.entrypoint,calldata:Array.isArray(t.calldata)&&"__compiled__"in t.calldata?t.calldata:DM.compile(t.calldata)})));return DM.compile({orderCalls:e})},oS=(t,e="0")=>"1"===e?iS(t):eS(t),sS={};nA(sS,{encodeData:()=>gS,encodeType:()=>dS,encodeValue:()=>mS,getDependencies:()=>fS,getMessageHash:()=>vS,getStructHash:()=>yS,getTypeHash:()=>pS,isMerkleTreeType:()=>cS,prepareSelector:()=>lS});nA({},{MerkleTree:()=>aS,proofMerklePath:()=>hS});var aS=class{constructor(t){this.branches=[],this.leaves=t,this.root=this.build(t)}build(t){if(1===t.length)return t[0];t.length!==this.leaves.length&&this.branches.push(t);const e=[];for(let r=0;r<t.length;r+=2)r+1===t.length?e.push(aS.hash(t[r],"0x0")):e.push(aS.hash(t[r],t[r+1]));return this.build(e)}static hash(t,e){const[r,n]=[ak(t),ak(e)].sort(((t,e)=>t>=e?1:-1));return Vy(r,n)}getProof(t,e=this.leaves,r=[]){const n=e.indexOf(t);if(-1===n)throw new Error("leaf not found");if(1===e.length)return r;const i=n%2==0,o=(i?e[n+1]:e[n-1])??"0x0",s=[...r,o],a=this.leaves.length===e.length?-1:this.branches.findIndex((t=>t.length===e.length)),h=this.branches[a+1]??[this.root];return this.getProof(aS.hash(i?t:o,i?o:t),h,s)}};function hS(t,e,r){if(0===r.length)return t===e;const[n,...i]=r;return hS(t,aS.hash(e,n),i)}function uS(t){try{return uk(t)}catch(e){if("string"==typeof t)return uk(Ok(t));throw new Error(`Invalid BigNumberish: ${t}`)}}function lS(t){return sk(t)?t:Mk(t)}function cS(t){return"merkletree"===t.type}var fS=(t,e,r=[])=>("*"===e[e.length-1]&&(e=e.slice(0,-1)),r.includes(e)?r:t[e]?[e,...t[e].reduce(((e,r)=>[...e,...fS(t,r.type,e).filter((t=>!e.includes(t)))]),[])]:r);var dS=(t,e)=>{const[r,...n]=fS(t,e);return(r?[r,...n.sort()]:[]).map((e=>`${e}(${t[e].map((t=>`${t.name}:${t.type}`))})`)).join("")},pS=(t,e)=>Mk(dS(t,e)),mS=(t,e,r,n={})=>{if(t[e])return[e,yS(t,e,r)];if(Object.keys(t).map((t=>`${t}*`)).includes(e)){const n=r.map((r=>yS(t,e.slice(0,-1),r)));return[e,ZM(n)]}if("merkletree"===e){const e=function(t,e){if(e.parent&&e.key){const r=t[e.parent].find((t=>t.name===e.key));if(!cS(r))throw new Error(`${e.key} is not a merkle tree`);if(r.contains.endsWith("*"))throw new Error(`Merkle tree contain property must not be an array but was given ${e.key}`);return r.contains}return"raw"}(t,n),i=r.map((r=>mS(t,e,r)[1])),{root:o}=new aS(i);return["felt",o]}return"felt*"===e?["felt*",ZM(r)]:"selector"===e?["felt",lS(r)]:[e,uS(r)]},gS=(t,e,r)=>{const[n,i]=t[e].reduce((([n,i],o)=>{if(void 0===r[o.name]||null===r[o.name])throw new Error(`Cannot encode data: missing data for '${o.name}'`);const s=r[o.name],[a,h]=mS(t,o.type,s,{parent:e,key:o.name});return[[...n,a],[...i,h]]}),[["felt"],[pS(t,e)]]);return[n,i]},yS=(t,e,r)=>ZM(gS(t,e,r)[1]),vS=(t,e)=>{if(!(t=>{const e=t;return Boolean(e.types&&e.primaryType&&e.message)})(t))throw new Error("Typed data does not match JSON schema");return ZM([Ok("StarkNet Message"),yS(t.types,"StarkNetDomain",t.domain),e,yS(t.types,t.primaryType,t.message)])},wS=new Xx({rpc:{default:!0}});function bS(t){return t.filter((t=>"event"===t.type&&(t.size||"enum"!==t.kind))).reduce(((t,e)=>{const r=e.name.slice(e.name.lastIndexOf(":")+1),n={...e};return n.name=r,{...t,[fA(Gy(sA(r)).toString(16))]:n}}),{})}function _S(t,e,r,n){const i=t.flat().reduce(((t,i)=>{const o=e[i.keys[0]];if(!o)return t;const s={};s[o.name]={},i.keys.shift();const a=i.keys[Symbol.iterator](),h=i.data[Symbol.iterator](),u=o.members?.filter((t=>"key"===t.kind))||o.keys,l=o.members?.filter((t=>"data"===t.kind))||o.data;return u.forEach((t=>{s[o.name][t.name]=NM(a,t,r,n,s[o.name])})),l.forEach((t=>{s[o.name][t.name]=NM(h,t,r,n,s[o.name])})),t.push(s),t}),[]);return i}nA({},{getAbiEvents:()=>bS,parseEvents:()=>_S});var ES=t=>{const e=t[t.length-1];return"object"==typeof e&&["blockIdentifier","parseRequest","parseResponse","formatResponse","maxFee","nonce","signature","addressSalt"].some((t=>t in e))?{args:t,options:t.pop()}:{args:t}};function AS(t,e){return async function(...r){const n=ES(r);return t.call(e.name,n.args,{parseRequest:!0,parseResponse:!0,...n.options})}}function kS(t,e){return"view"===e.stateMutability||"view"===e.state_mutability?AS(t,e):function(t,e){return async function(...r){const n=ES(r);return t.invoke(e.name,n.args,{parseRequest:!0,...n.options})}}(t,e)}function MS(t,e){return function(...r){return t.estimate(e.name,r)}}function xS(t,e){return Array.isArray(t)&&"__compiled__"in t?t:Array.isArray(t)&&Array.isArray(t[0])&&"__compiled__"in t[0]?t[0]:e()}var SS=class{constructor(t,e,r=wS){this.address=e&&e.toLowerCase(),this.providerOrAccount=r,this.callData=new DM(t),this.structs=DM.getAbiStruct(t),this.events=bS(t);const n=vM(t);this.abi=n.getLegacyFormat();const i={enumerable:!0,value:{},writable:!1};Object.defineProperties(this,{functions:{enumerable:!0,value:{},writable:!1},callStatic:{enumerable:!0,value:{},writable:!1},populateTransaction:{enumerable:!0,value:{},writable:!1},estimateFee:{enumerable:!0,value:{},writable:!1}}),this.abi.forEach((t=>{if("function"!==t.type)return;const e=t.name;var r,n;this[e]||Object.defineProperty(this,e,{...i,value:kS(this,t)}),this.functions[e]||Object.defineProperty(this.functions,e,{...i,value:kS(this,t)}),this.callStatic[e]||Object.defineProperty(this.callStatic,e,{...i,value:AS(this,t)}),this.populateTransaction[e]||Object.defineProperty(this.populateTransaction,e,{...i,value:(r=this,n=t,function(...t){return r.populate(n.name,t)})}),this.estimateFee[e]||Object.defineProperty(this.estimateFee,e,{...i,value:MS(this,t)})}))}attach(t){this.address=t}connect(t){this.providerOrAccount=t}async deployed(){return this.deployTransactionHash&&(await this.providerOrAccount.waitForTransaction(this.deployTransactionHash),this.deployTransactionHash=void 0),this}async call(t,e=[],{parseRequest:r=!0,parseResponse:n=!0,formatResponse:i,blockIdentifier:o}={}){ok(null!==this.address,"contract is not connected to an address");const s=xS(e,(()=>r?(this.callData.validate("CALL",t,e),this.callData.compile(t,e)):(console.warn("Call skipped parsing but provided rawArgs, possible malfunction request"),e)));return this.providerOrAccount.callContract({contractAddress:this.address,calldata:s,entrypoint:t},o).then((e=>n?i?this.callData.format(t,e.result,i):this.callData.parse(t,e.result):e.result))}invoke(t,e=[],{parseRequest:r=!0,maxFee:n,nonce:i,signature:o}={}){ok(null!==this.address,"contract is not connected to an address");const s=xS(e,(()=>r?(this.callData.validate("INVOKE",t,e),this.callData.compile(t,e)):(console.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request"),e))),a={contractAddress:this.address,calldata:s,entrypoint:t};if("execute"in this.providerOrAccount)return this.providerOrAccount.execute(a,void 0,{maxFee:n,nonce:i});if(!i)throw new Error("Nonce is required when invoking a function without an account");return console.warn(`Invoking ${t} without an account. This will not work on a public node.`),this.providerOrAccount.invokeFunction({...a,signature:o},{nonce:i})}async estimate(t,e=[]){ok(null!==this.address,"contract is not connected to an address"),xS(e,(()=>!1))||this.callData.validate("INVOKE",t,e);const r=this.populate(t,e);if("estimateInvokeFee"in this.providerOrAccount)return this.providerOrAccount.estimateInvokeFee(r);throw Error("Contract must be connected to the account contract to estimate")}populate(t,e=[]){const r=xS(e,(()=>this.callData.compile(t,e)));return{contractAddress:this.address,entrypoint:t,calldata:r}}parseEvents(t){return _S(t.events?.filter((t=>dk(t.from_address)===dk(this.address)),[])||[],this.events,this.structs,DM.getAbiEnum(this.abi))}isCairo1(){return Bk.isCairo1Abi(this.abi)}async getVersion(){return this.providerOrAccount.getContractVersion(this.address)}typed(t){return this}};function NS(t){pk(t,MA,SA,"Starknet Address");const e=function(t){return fA(cA(uk(t)).padStart(64,"0"))}(t);if(!e.match(/^(0x)?[0-9a-fA-F]{64}$/))throw new Error("Invalid Address Format");return e}const IS={SN_MAIN:"https://starknet-mainnet.public.blastapi.io",SN_SEPOLIA:"https://starknet-sepolia.public.blastapi.io"},CS=[{name:"argent::account::interface::IDeprecatedArgentAccount",type:"interface",items:[{name:"isValidSignature",type:"function",inputs:[{name:"hash",type:"core::felt252"},{name:"signatures",type:"core::array::Array::<core::felt252>"}],outputs:[{type:"core::felt252"}],state_mutability:"view"}]}];function TS(t,e){var r;if(!IS[t])throw new Error("Invalid network");return new Gx({nodeUrl:null!==(r=null==e?void 0:e.broviderUrl)&&void 0!==r?r:IS[t]})}function PS(t){return!!t.primaryType&&!!t.types.StarkNetDomain}function RS(t,e){const{domain:r,types:n,primaryType:i,message:o}=t;return sS.getMessageHash({types:n,primaryType:i,domain:r,message:o},e)}var OS=Object.freeze({__proto__:null,isStarknetMessage:PS,getHash:RS,default:function(t,r,n){return e(this,arguments,void 0,(function*(t,e,r,n="SN_MAIN",i={}){const o=new SS(CS,t,TS(n,i));return yield o.isValidSignature(RS(r,t),[e[0],e[1]]),!0}))}});function $S(t){return we(En(t))}var BS=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const DS=new y("hash/5.6.1"),FS=new Uint8Array(32);FS.fill(0);const US=qt.from(-1),jS=qt.from(0),LS=qt.from(1),zS=qt.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const qS=O(LS.toHexString(),32),VS=O(jS.toHexString(),32),HS={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},GS=["name","version","chainId","verifyingContract","salt"];function KS(t){return function(e){return"string"!=typeof e&&DS.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const ZS={name:KS("name"),version:KS("version"),chainId:function(t){try{return qt.from(t).toString()}catch(t){}return DS.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return Pe(t).toLowerCase()}catch(t){}return DS.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=k(t);if(32!==e.length)throw new Error("bad length");return I(e)}catch(t){}return DS.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function JS(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],n=parseInt(e[2]||"256");(n%8!=0||n>256||e[2]&&e[2]!==String(n))&&DS.throwArgumentError("invalid numeric width","type",t);const i=zS.mask(r?n-1:n),o=r?i.add(LS).mul(US):jS;return function(e){const r=qt.from(e);return(r.lt(o)||r.gt(i))&&DS.throwArgumentError(`value out-of-bounds for ${t}`,"value",e),O(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&DS.throwArgumentError("invalid bytes width","type",t),function(e){return k(e).length!==r&&DS.throwArgumentError(`invalid length for ${t}`,"value",e),function(t){const e=k(t),r=e.length%32;return r?P([e,FS.slice(r)]):I(e)}(e)}}}switch(t){case"address":return function(t){return O(Pe(t),32)};case"bool":return function(t){return t?qS:VS};case"bytes":return function(t){return we(t)};case"string":return function(t){return $S(t)}}return null}function QS(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class YS{constructor(t){gr(this,"types",Object.freeze(Ar(t))),gr(this,"_encoderCache",{}),gr(this,"_types",{});const e={},r={},n={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],n[t]={}}));for(const n in t){const i={};t[n].forEach((o=>{i[o.name]&&DS.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",t),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&DS.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",t);JS(s)||(r[s]||DS.throwArgumentError(`unknown type ${JSON.stringify(s)}`,"types",t),r[s].push(n),e[n][s]=!0)}))}const i=Object.keys(r).filter((t=>0===r[t].length));0===i.length?DS.throwArgumentError("missing primary type","types",t):i.length>1&&DS.throwArgumentError(`ambiguous primary types or unused types: ${i.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),gr(this,"primaryType",i[0]),function i(o,s){s[o]&&DS.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",t),s[o]=!0,Object.keys(e[o]).forEach((t=>{r[t]&&(i(t,s),Object.keys(s).forEach((e=>{n[e][t]=!0})))})),delete s[o]}(this.primaryType,{});for(const e in n){const r=Object.keys(n[e]);r.sort(),this._types[e]=QS(e,t[e])+r.map((e=>QS(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=JS(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),n=parseInt(e[3]);return e=>{n>=0&&e.length!==n&&DS.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let i=e.map(r);return this._types[t]&&(i=i.map(we)),we(P(i))}}const r=this.types[t];if(r){const e=$S(this._types[t]);return t=>{const n=r.map((({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return this._types[r]?we(n):n}));return n.unshift(e),P(n)}}return DS.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||DS.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return we(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(JS(t))return r(t,e);const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],i=parseInt(n[3]);return i>=0&&e.length!==i&&DS.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const i=this.types[t];return i?i.reduce(((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t)),{}):DS.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new YS(t)}static getPrimaryType(t){return YS.from(t).primaryType}static hashStruct(t,e,r){return YS.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const n=HS[r];n||DS.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:n})}return e.sort(((t,e)=>GS.indexOf(t.name)-GS.indexOf(e.name))),YS.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return P(["0x1901",YS.hashDomain(t),YS.from(e).hash(r)])}static hash(t,e,r){return we(YS.encode(t,e,r))}static resolveNames(t,e,r,n){return BS(this,void 0,void 0,(function*(){t=wr(t);const i={};t.verifyingContract&&!S(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const o=YS.from(e);o.visit(r,((t,e)=>("address"!==t||S(e,20)||(i[e]="0x"),e)));for(const t in i)i[t]=yield n(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),r=o.visit(r,((t,e)=>"address"===t&&i[e]?i[e]:e)),{domain:t,value:r}}))}static getPayload(t,e,r){YS.hashDomain(t);const n={},i=[];GS.forEach((e=>{const r=t[e];null!=r&&(n[e]=ZS[e](r),i.push({name:e,type:HS[e]}))}));const o=YS.from(e),s=wr(e);return s.EIP712Domain?DS.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):s.EIP712Domain=i,o.encode(r),{types:s,domain:n,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return I(k(e));if(t.match(/^u?int/))return qt.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&DS.throwArgumentError("invalid string","value",e),e}return DS.throwArgumentError("unsupported type","type",t)}))}}}window&&window.__awaiter;new y("wallet/5.6.2");function WS(t,e,r,n){return Fs(YS.hash(t,e,r),n)}function XS(t,e){return t.toLowerCase()===e.toLowerCase()}function tN(t){const{domain:e,types:r,message:n}=t;return Lu.hash(e,r,n)}function eN(t,r,n,i){return e(this,void 0,void 0,(function*(){let e;try{e=yield ON(i,["function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[k(n),r]])}catch(t){if(t.message.startsWith("missing revert data in call exception"))return!1;throw t}return XS(e,"0x1626ba7e")}))}function rN(t,r,n,i){return e(this,void 0,void 0,(function*(){return XS(yield ON(i,["function isValidSignature(bytes _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[k(n),r]]),"0x20c13b0b")}))}var nN=Object.freeze({__proto__:null,getHash:tN,default:function(t,r,n){return e(this,arguments,void 0,(function*(t,e,r,n="1",i={}){const{domain:o,types:s,message:a}=r;try{if(XS(t,WS(o,s,a,e)))return!0}catch(t){}const h=cm(n,i),u=tN(r);return!!(yield eN(t,e,u,h))||(yield rN(t,e,u,h))}))}});var iN=["snapshot.4everland.link","ipfs.io","ipfs.fleek.co","gateway.pinata.cloud","dweb.link","ipfs.infura.io"],oN={1:{key:"1",name:"Ethereum",chainId:1,network:"homestead",multicall:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",ensResolvers:["0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63","0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"],ensNameWrapper:"0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401",ensSubgraph:"https://subgrapher.snapshot.org/subgraph/arbitrum/5XqPmWe6gjyrJtFn9cLy237i4cWw2j9HcUJEXsP5qGtH",rpc:["https://rpc.ankr.com/eth",{url:"https://api-geth-archive.ankr.com",user:"balancer_user",password:"balancerAnkr20201015"},"https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/eth/mainnet/archive","https://apis.ankr.com/e62bc219f9c9462b8749defe472d2dc5/6106d4a3ec1d1bcc87ec72158f8fd089/eth/archive/main","https://eth-archival.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://eth-mainnet.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],light:["https://cloudflare-eth.com"],ws:["wss://eth-mainnet.ws.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],explorer:{url:"https://etherscan.io",apiUrl:"https://api.etherscan.io"},start:7929876,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},8:{key:"8",name:"Ubiq",chainId:8,network:"Ubiq",multicall:"0x6668750957e4083725926B71C41bDF1434C73262",rpc:["https://rpc.octano.dev"],ws:["wss://ws.octano.dev"],explorer:{url:"https://ubiqscan.io"},start:1,logo:"ipfs://Qmec3HLoN4QhwZAhw4XTi2aN8Wwmcko5hHN22sHARzb9tw"},10:{key:"10",name:"Optimism",chainId:10,network:"Optimism mainnet",multicall:"0x35A6Cdb2C9AD4a45112df4a04147EB07dFA01aB7",rpc:["https://opt-mainnet.g.alchemy.com/v2/JzmIL4Q3jBj7it2duxLFeuCa9Wobmm7D"],explorer:{url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io"},start:657806,logo:"ipfs://QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb"},19:{key:"19",name:"Songbird Canary-Network",shortName:"Songbird",chainId:19,network:"songbird",multicall:"0x17032Ea9c3a13Ed337665145364c0d2aD1108c91",rpc:["https://songbird-api.flare.network/ext/C/rpc"],explorer:{url:"https://songbird-explorer.flare.network"},start:21807126,logo:"ipfs://QmXyvnrZY8FUxSULfnKKA99sAEkjAHtvhRx5WeHixgaEdu"},24:{key:"24",name:"KardiaChain Mainnet",shortName:"KAI",chainId:24,network:"mainnet",multicall:"0xd9c92F2287B7802A37eC9BEce96Aa65fb5f31E1b",rpc:["https://kai-internal.kardiachain.io"],explorer:{url:"https://explorer.kardiachain.io"},start:8260245,logo:"ipfs://bafkreig73yfyqzbxydv6e3dbj5nks3f57px2iez7tywayey4rilfhhrr34"},25:{key:"25",name:"Cronos",shortName:"Cronos",chainId:25,network:"mainnet",multicall:"0x6F522a3982e8F9A50A2EDc9E46ed1A3aE2B3FD3a",rpc:["https://evm-cronos.crypto.org"],explorer:{url:"https://cronos.crypto.org/explorer"},start:4067,logo:"ipfs://QmfSJbtirJoa3Pt7o5Fdm85wbyw9V1hpzqLr5PQbdnfsAj"},30:{key:"30",name:"RSK",chainId:30,network:"rsk mainnet",multicall:"0x4eeebb5580769ba6d26bfd07be636300076d1831",rpc:["https://public-node.rsk.co"],explorer:{url:"https://explorer.rsk.co"},start:2516442,logo:"ipfs://QmXTwpE1SqoNZmyY4c3fYWy6qUgQELsyWKbgJo2Pg6K6V9"},46:{key:"46",name:"Darwinia Network",shortName:"Darwinia",chainId:46,network:"mainnet",multicall:"0x67f9ae42EaA9a8aBf065D60ec6Ab3C1A11370607",rpc:["https://rpc.darwinia.network"],explorer:{url:"https://darwinia.subscan.io"},start:141853,logo:"ipfs://bafkreicf55maidhx46pyu3mwsshlr43xbewr6tkckkonh4nesbkp7krwkm"},56:{key:"56",name:"Binance Smart Chain",shortName:"BSC",chainId:56,network:"mainnet",multicall:"0x1ee38d535d541c55c9dae27b12edf090c608e6fb",rpc:["https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/bsc/mainnet/archive","https://rpc.ankr.com/bsc","https://bsc.getblock.io/mainnet/?api_key=91f8195f-bf46-488f-846a-73d6853790e7","https://bsc-private-dataseed1.nariox.org","https://bsc-dataseed1.ninicoin.io","https://bsc-dataseed1.binance.org"],explorer:{url:"https://bscscan.com"},start:461230,logo:"ipfs://QmWQaQ4Tv28DwA4DRKjSDJFWY9mZboGvuu77J8nh7kucxv"},61:{key:"61",name:"Ethereum Classic",shortName:"Ethereum Classic",chainId:61,network:"mainnet",multicall:"0x51be3a92C56ae7E207C5b5Fd87F7798Ce82C1AC2",rpc:["https://www.ethercluster.com/etc"],explorer:{url:"https://blockscout.com/etc/mainnet"},start:13307544,logo:"ipfs://QmVegc28DvA7LjKUFysab81c9BSuN4wQVDQkRXyAtuEBis"},66:{key:"66",name:"OKExChain",shortName:"OEC Mainnet",chainId:66,network:"oec mainnet",multicall:"0x6EB187d8197Ac265c945b69f3c3064A6f3831866",rpc:["https://exchainrpc.okex.org"],ws:["wss://exchainws.okex.org:8443"],explorer:{url:"https://www.oklink.com/okexchain"},start:5076543,logo:"ipfs://Qmd7dKnNwHRZ4HRCbCXUbkNV7gP28fGqPdjbHtjRtT9sQF"},75:{key:"75",name:"Decimal",shortName:"mainnet",chainId:75,network:"mainnet",multicall:"0x949d1A0757803C51F2EfFFEb5472C861A898B8E8",rpc:[],explorer:{url:"https://explorer.decimalchain.com"},start:16031065,logo:"ipfs://bafkreihkdhbce5rkogl63xegaarlirjrvbfarxbtbf5mqme3s5grvbjyxm"},81:{key:"81",name:"Shibuya Network",shortName:"Shibuya",chainId:81,network:"testnet",testnet:!0,multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shibuya.astar.network:8545"],explorer:{url:"https://blockscout.com/shibuya"},start:856303,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},82:{key:"82",name:"Meter",shortName:"Meter",chainId:82,network:"mainnet",multicall:"0x579De77CAEd0614e3b158cb738fcD5131B9719Ae",rpc:["https://rpc.meter.io"],explorer:{url:"https://scan.meter.io"},start:4992871,logo:"ipfs://QmSZvT9w9eUDvV1YVaq3BKKEbubtNVqu1Rin44FuN4wz11"},97:{key:"97",name:"Binance Smart Chain Testnet",shortName:"BSC Testnet",chainId:97,network:"testnet",testnet:!0,multicall:"0x8b54247c6BAe96A6ccAFa468ebae96c4D7445e46",rpc:["https://data-seed-prebsc-1-s1.binance.org:8545","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/bsc/testnet/archive"],explorer:{url:"https://testnet.bscscan.com"},start:3599656,logo:"ipfs://QmWQaQ4Tv28DwA4DRKjSDJFWY9mZboGvuu77J8nh7kucxv"},100:{key:"100",name:"Gnosis Chain",shortName:"xDAI",chainId:100,network:"mainnet",multicall:"0xb5b692a88bdfc81ca69dcb1d924f59f0413a602a",rpc:["https://gno.getblock.io/mainnet/6c1d1e6e-75d9-452f-a863-a694bff93d5c/","https://xdai-archive.blockscout.com","https://poa-xdai.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://rpc.gnosischain.com"],light:["https://rpc.gnosischain.com"],ws:["wss://rpc.xdaichain.com/wss"],explorer:{url:"https://gnosis.blockscout.com"},start:4108192,logo:"ipfs://QmZeiy8Ax4133wzxUQM9ky8z5XFVf6YLFjJMmTWbWVniZR"},108:{key:"108",name:"Thundercore",chainId:108,network:"mainnet",multicall:"0x3017086deef56679e267f67f66c4415109b7a97f",rpc:["https://mainnet-rpc.thundercore.com/archived/SNAPSHOTEuR82a75fLYA"],explorer:{url:"https://viewblock.io/thundercore"},start:94425385,logo:"ipfs://bafkreifc5z5vtvqx2luzgateyvoocwpd2ifv2hwufxdnyl2a767wa6icli"},122:{key:"122",name:"Fuse",shortName:"Fuse",chainId:122,network:"mainnet",multicall:"0x7a59441fb06666F6d2D766393d876945D06a169c",rpc:["https://explorer-node.fuse.io/","https://oefusefull1.liquify.info/"],explorer:{url:"https://explorer.fuse.io"},start:11923459,logo:"ipfs://QmXjWb64nako7voaVEifgdjAbDbswpTY8bghsiHpv8yWtb"},137:{key:"137",name:"Polygon PoS",shortName:"Polygon",chainId:137,network:"mainnet",multicall:"0xCBca837161be50EfA5925bB9Cc77406468e76751",rpc:["https://rpc.ankr.com/polygon","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/polygon/mainnet/archive","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mainnet/archive","https://rpc-mainnet.maticvigil.com/v1/1cfd7598e5ba6dcf0b4db58e8be484badc6ea08e"],ws:["wss://ws-mainnet.matic.network"],explorer:{url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com"},start:9834491,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},144:{key:"144",name:"PHI Network",shortName:"PHI",chainId:144,network:"mainnet",multicall:"0xc2f41B404a6757863AAeF49ff93039421acCd630",rpc:["https://connect.phi.network"],explorer:{url:"https://phiscan.com"},start:360030,logo:"ipfs://bafkreid6pm3mic7izp3a6zlfwhhe7etd276bjfsq2xash6a4s2vmcdf65a"},148:{key:"148",name:"ShimmerEVM",shortName:"ShimmerEVM",chainId:148,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.evm.shimmer.network/"},start:1290,logo:"ipfs://bafkreib4xhbgbhrwkmizp4d4nz3wzbpyhdm6wpz2v2pbkk7jxsgg3hdt74"},169:{key:"169",name:"Manta Pacific",shortName:"Manta",chainId:169,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://www.oklink.com/manta"},start:332890,logo:"ipfs://bafkreibbrwgwdcfh755dqh4ndta6tja77qbaa36bfv4pstub6prhhore7a"},204:{key:"204",name:"opBNB",shortName:"mainnet",chainId:204,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"http://opbnbscan.com/"},start:512881,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},246:{key:"246",name:"Energy Web Chain",shortName:"EWC",chainId:246,network:"mainnet",multicall:"0x0767F26d0D568aB61A98b279C0b28a4164A6f05e",rpc:["https://voting-rpc.carbonswap.exchange"],explorer:{url:"https://explorer.energyweb.org"},start:12086501,logo:"ipfs://Qmai7AGHgs8NpeGeXgbMZz7pS2i4kw44qubCJYGrZW2f3a"},250:{key:"250",name:"Fantom Opera",shortName:"fantom",chainId:250,network:"Mainnet",multicall:"0x7f6A10218264a22B4309F3896745687E712962a0",rpc:["https://rpc.ankr.com/fantom","https://rpc.ftm.tools","https://rpcapi.fantom.network"],explorer:{url:"https://ftmscan.com"},start:2497732,logo:"ipfs://QmVEgNeQDKnXygeGxfY9FywZpNGQu98ktZtRJ9bToYF6g7"},269:{key:"269",name:"High Performance Blockchain",shortName:"HPB",chainId:269,network:"mainnet",multicall:"0x67D0f263aef2F6167FA77353695D75b582Ff4Bca",rpc:["https://hpbnode.com"],ws:["wss://ws.hpbnode.com"],explorer:{url:"https://hscan.org"},start:13960096,logo:"ipfs://QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"},300:{key:"300",name:"zkSync Sepolia Testnet",shortName:"testnet",chainId:300,network:"testnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:[],explorer:{url:"https://sepolia.explorer.zksync.dev/"},start:2292,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy",testnet:!0},314:{key:"314",name:"Filecoin",shortName:"mainnet",chainId:314,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://filfox.io"},start:3328594,logo:"ipfs://bafybeibyvjfmk6aqlfdrczvth55jkmnoadtrch7ht3rdmvqmy2bfxynecm"},321:{key:"321",name:"KCC",shortName:"KCC",chainId:321,network:"mainnet",multicall:"0xa64D6AFb48225BDA3259246cfb418c0b91de6D7a",rpc:["https://rpc-mainnet.kcc.network"],ws:["wss://rpc-ws-mainnet.kcc.network"],explorer:{url:"https://explorer.kcc.io"},start:1487453,logo:"ipfs://QmRdzYGhFRG8QLzMJahHrw3vETE2YZ9sywQbEkenSjKEvb"},324:{key:"324",name:"zkSync Era",shortName:"zkSync-era",chainId:324,network:"zkSync Era Mainnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:["https://mainnet.era.zksync.io"],explorer:{url:"https://explorer.zksync.io/"},start:3908235,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy"},336:{key:"336",name:"Shiden Network",shortName:"Shiden",chainId:336,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shiden.astar.network:8545","https://shiden.api.onfinality.io/public"],explorer:{url:"https://blockscout.com/shiden"},start:1170016,logo:"ipfs://QmcqGQE4Sk73zXc3e91TUFFefKBVeaNgbxV141XkSNE4xj"},369:{key:"369",name:"Pulsechain",shortName:"Pulsechain",chainId:369,network:"mainnet",multicall:"0xdbdd0FD8B16F0092f306392b699D7fbddaA9011B",rpc:["https://rpc.pulsechain.com"],explorer:{url:"https://scan.pulsechain.com/"},start:17657774,logo:"ipfs://QmWUsiEWdejtHZ9B9981TYXn7Ds8C7fkB1S4h5rP3kCCZR"},416:{key:"416",name:"SX Network",shortName:"SX",chainId:416,network:"mainnet",multicall:"0x834a005DDCF990Ba1a79f259e840e58F2D14F49a",rpc:["https://rpc.sx.technology"],ws:["wss://rpc.sx.technology/ws"],explorer:{url:"https://explorer.sx.technology"},start:2680605,logo:"ipfs://QmSXLXqyr2H6Ja5XrmznXbWTEvF2gFaL8RXNXgyLmDHjAF"},592:{key:"592",name:"Astar Network",shortName:"Astar",chainId:592,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://astar.api.onfinality.io/public","https://rpc.astar.network:8545"],explorer:{url:"https://blockscout.com/astar"},start:366482,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},813:{key:"813",name:"Qitmeer",shortName:"MEER",chainId:813,network:"mainnet",multicall:"0x55034b2cF530ae3A8fC1e2e4523F58496796610F",rpc:["https://evm-dataseed1.meerscan.io","https://evm-dataseed.meerscan.com","https://evm-dataseed2.meerscan.io","https://evm-dataseed3.meerscan.io"],explorer:{url:"https://evm.meerscan.io"},start:43317,logo:"ipfs://QmXvum7SNVaAqAc2jNzR1NpNZN1GGvNaKWydg8a1GEDQ7y"},841:{key:"841",name:"Taraxa",shortName:"841",chainId:841,network:"mainnet",multicall:"0xFCe7a3121B42664AaD145712e1c2Bf2e38f60AA1",rpc:["https://rpc.mainnet.taraxa.io"],ws:["wss://ws.mainnet.taraxa.io"],explorer:{url:"https://mainnet.explorer.taraxa.io"},start:1515906,logo:"ipfs://Qmcc6ZCAGESMzZzoj5LsTVcCo2E35x3Ydk71uPJyov6Mwx"},888:{key:"888",name:"Wanchain",chainId:888,network:"mainnet",multicall:"0xba5934ab3056fca1fa458d30fbb3810c3eb5145f",rpc:["https://gwan-ssl.wandevs.org:56891"],ws:["wss://api.wanchain.org:8443/ws/v3/ddd16770c68f30350a21114802d5418eafe039b722de52b488e7eee1ee2cd73f"],explorer:{url:"https://www.wanscan.org"},start:11302663,logo:"ipfs://QmewFFN44rkxESFsHG8edaLt1znr62hjvZhGynfXqruzX3"},1001:{key:"1001",name:"Klaytn Baobab Testnet",shortName:"Boabab",chainId:1001,network:"testnet",testnet:!0,multicall:"0x40643B8Aeaaca0b87Ea1A1E596e64a0e14B1d244",rpc:["https://archive-en.baobab.klaytn.net"],ws:["wss://archive-en.baobab.klaytn.net/ws"],explorer:{url:"https://baobab.scope.klaytn.com"},start:87232478,logo:"ipfs://QmYACyZcidcFtMo4Uf9H6ZKUxTP2TQPjGzNjcUjqYa64dt"},1072:{key:"1072",name:"Shimmer EVM Testnet",shortName:"ShimmerEVM",chainId:1072,network:"testnet",testnet:!0,multicall:"0x751d21047C116413895c259f3f305e38C10B7cF6",rpc:["https://archive.evm.testnet.shimmer.network/v1/chains/rms1pr75wa5xuepg2hew44vnr28wz5h6n6x99zptk2g68sp2wuu2karywgrztx3/evm"],explorer:{url:"https://explorer.evm.testnet.shimmer.network/"},start:10614,logo:"ipfs://bafkreihtwfwrue7klzedwx4rqlk6agklz4lbbk7owsyw6xzn6c2m4t5tgy"},1088:{key:"1088",name:"Metis",shortName:"metis",chainId:1088,network:"mainnet",multicall:"0xc39aBB6c4451089dE48Cffb013c39d3110530e5C",rpc:["https://andromeda.metis.io/?owner=1088"],explorer:{url:"https://andromeda-explorer.metis.io"},start:451,logo:"ipfs://bafkreiaqr4atnjpdnk3c4vu4377ai7bzqpgaefefbl5j5imfsvr4puimtu"},1101:{key:"1101",name:"Polygon zkEVM",shortName:"mainnet",chainId:1101,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://zkevm.polygonscan.com"},start:57746,logo:"ipfs://bafkreibfiyvhqnme2vbxxfcku7qkxgjpkg6ywdkplxh4oxlkqsbznyorfm"},1116:{key:"1116",name:"Core Chain",shortName:"Core",chainId:1116,network:"mainnet",multicall:"0x024f0041b76B598c2A0a75004F8447FaF67BD004",rpc:["https://rpcar.coredao.org/"],explorer:{url:"https://scan.coredao.org"},start:853908,logo:"ipfs://bafkreigjv5yb7uhlrryzib7j2f73nnwqan2tmfnwjdu26vkk365fyesoiu"},1284:{key:"1284",name:"Moonbeam",shortName:"GLMR",chainId:1284,network:"mainnet",multicall:"0x83e3b61886770de2F64AAcaD2724ED4f08F7f36B",rpc:["https://rpc.api.moonbeam.network"],explorer:{url:"https://moonscan.io/"},start:171135,logo:"ipfs://QmWKTEK2pj5sBBbHnMHQbWgw6euVdBrk2Ligpi2chrWASk"},1285:{key:"1285",name:"Moonriver (Kusama)",shortName:"Moonriver",chainId:1285,network:"mainnet",multicall:"0x537004440ffFE1D4AE9F009031Fc2b0385FCA9F1",rpc:["https://rpc.api.moonriver.moonbeam.network"],explorer:{url:"https://blockscout.moonriver.moonbeam.network"},start:413539,logo:"ipfs://QmXtgPesL87Ejhq2Y7yxsaPYpf4RcnoTYPJWPcv6iiYhoi"},1287:{key:"1287",name:"Moonbase Alpha TestNet",shortName:"Moonbase",chainId:1287,network:"testnet",testnet:!0,multicall:"0xf09FD6B6FF3f41614b9d6be2166A0D07045A3A97",rpc:["https://rpc.testnet.moonbeam.network"],explorer:{url:"https://moonbase-blockscout.testnet.moonbeam.network"},start:859041,logo:"ipfs://QmeGbNTU2Jqwg8qLTMGW8n8HSi2VdgCncAaeGzLx6gYnD7"},1328:{key:"1328",name:"Sei atlantic testnet",shortName:"testnet",chainId:1328,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://seitrace.com"},start:96978658,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},1329:{key:"1329",name:"Sei",shortName:"mainnet",chainId:1329,network:"mainnet",multicall:"0xe033Bed7cae4114Af84Be1e9F1CA7DEa07Dfe1Cf",rpc:[],explorer:{url:"https://seitrace.com/"},start:79164574,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq"},1559:{key:"1559",name:"Tenet",shortName:"tenet",chainId:1559,network:"mainnet",multicall:"0xcCB3F00bE353950E4C08501ac8Af48765EAAa738",rpc:[],explorer:{url:"https://tenetscan.io"},start:944415,logo:"ipfs://Qmc1gqjWTzNo4pyFSGtQuCu7kRSZZBUVybtTjHn2nNEEPA"},1663:{key:"1663",name:"Horizen Gobi Testnet",shortName:"Gobi",chainId:1663,network:"testnet",testnet:!0,multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:["https://gobi-testnet.horizenlabs.io/ethv1"],explorer:{url:"https://gobi-explorer.horizen.io"},start:1,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},2e3:{key:"2000",name:"Doge Chain",shortName:"dogechain",chainId:2e3,network:"mainnet",multicall:"0x6f9D3f3932B417bd4957585D236Cbc32b32C0BDc",rpc:["https://rpc.dogechain.dog"],explorer:{url:"https://explorer.dogechain.dog"},start:877115,logo:"ipfs://bafkreigovfh3pinsdih777issfgaflwu2yjzroljs2642gbvwikcd3nm4i"},2109:{key:"2109",name:"Exosama Network",shortName:"EXN",chainId:2109,network:"mainnet",multicall:"0x2feFC828e2fEfdE0C9f7740919c6A9139F886067",rpc:["https://rpc.exosama.com"],explorer:{url:"https://explorer.exosama.com"},start:94085,logo:"ipfs://QmaQxfwpXYTomUd24PMx5tKjosupXcm99z1jL1XLq9LWBS"},2152:{key:"2152",name:"Findora",shortName:"Findora",chainId:2152,network:"mainnet",multicall:"0xCF7D1e21CBe9bdEF235aef06C5d8051B3d4DF0f5",rpc:["https://archive.prod.findora.org:8545/"],explorer:{url:"https://evm.findorascan.io"},start:4219343,logo:"ipfs://QmXkneyRB6HbHTHRLCZpZqSsawiyJY7b2kZ2V8ydvKYAgv"},2221:{key:"2221",name:"Kava Testnet",shortName:"testnet",chainId:2221,network:"testnet",multicall:"0xc7193EFE367DF0C9349a1149F4E95A2A35604262",rpc:[],explorer:{url:"https://testnet.kavascan.com"},start:6193104,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4",testnet:!0},2222:{key:"2222",name:"Kava",shortName:"mainnet",chainId:2222,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://kavascan.com/"},start:3661165,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4"},2400:{key:"2400",name:"TCG Verse",shortName:"TCGV",chainId:2400,network:"mainnet",multicall:"0xceC65DEE0b5012F1b7321b2647681F997c7204FC",rpc:["https://rpc.tcgverse.xyz"],explorer:{url:"https://explorer.tcgverse.xyz"},start:57500,logo:"ipfs://bafkreidg4wpewve5mdxrofneqblydkrjl3oevtgpdf3fk3z3vjqam6ocoe"},4200:{key:"4200",name:"Merlin",shortName:"merlin",chainId:4200,network:"mainnet",multicall:"0x830E7E548F4D80947a40A7Cf3a2a53166a0C3980",rpc:[],explorer:{url:"https://scan.merlinchain.io"},start:589494,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe"},4337:{key:"4337",name:"Beam",shortName:"Beam",chainId:4337,network:"mainnet",multicall:"0x4956F15eFdc3dC16645e90Cc356eAFA65fFC65Ec",rpc:[],explorer:{url:"https://subnets.avax.network/beam/"},start:1,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF"},4689:{key:"4689",name:"IoTeX",shortName:"IoTeX",chainId:4689,network:"mainnet",multicall:"0x9c8B105c94282CDB0F3ecF27e3cfA96A35c07be6",rpc:["https://babel-api.mainnet.iotex.io"],explorer:{url:"https://iotexscan.io"},start:11533283,logo:"ipfs://QmNkr1UPcBYbvLp7d7Pk4eF3YCsHpaNkfusKZNtykL2EQC"},5e3:{key:"5000",name:"Mantle",chainId:5e3,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.mantle.xyz"],explorer:{url:"https://explorer.mantle.xyz"},start:304717,logo:"ipfs://bafkreidkucwfn4mzo2gtydrt2wogk3je5xpugom67vhi4h4comaxxjzoz4"},5555:{key:"5555",name:"Chain Verse",shortName:"ChainVerse",chainId:5555,network:"ChainVerse",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.chainverse.info"],explorer:{url:"https://explorer.chainverse.info"},start:6334180,logo:"ipfs://QmQyJt28h4wN3QHPXUQJQYQqGiFUD77han3zibZPzHbitk"},6102:{key:"6102",name:"Cascadia Testnet",shortName:"Cascadia",chainId:6102,network:"testnet",multicall:"0x728989819bAD588F193563008E0a03E8cD6a3e4a",rpc:["https://testnet.cascadia.foundation"],explorer:{url:"https://explorer.cascadia.foundation"},testnet:!0,start:370457,logo:"ipfs://QmWkhZYhReYyaa5pQXj32hEGxoRcBqarFMcfQScELmjYQj"},7332:{key:"7332",name:"Horizen EON",shortName:"EON",chainId:7332,network:"mainnet",multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:[],explorer:{url:"https://eon-explorer.horizenlabs.io"},start:85108,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},7341:{key:"7341",name:"Shyft",shortName:"Shyft",chainId:7341,network:"mainnet",multicall:"0xceb10e9133D771cA93c8002Be527A465E85381a2",rpc:["https://rpc.shyft.network"],explorer:{url:"https://bx.shyft.network"},start:3673983,logo:"ipfs://bafkreifwxnnfk6koabzmxgcxcwlrwt6b5gijdain2gyqee77q4ajfb7fu4"},7560:{key:"7560",name:"Cyber",shortName:"mainnet",chainId:7560,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://cyberscan.co"},start:1731707,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm"},8217:{key:"8217",name:"Klaytn Cypress",shortName:"Cypress",chainId:8217,network:"mainnet",multicall:"0x5f5f0d1b9ff8b3dcace308e39b13b203354906e9",rpc:["https://archive-en.cypress.klaytn.net"],ws:["wss://archive-en.cypress.klaytn.net/ws"],explorer:{url:"https://scope.klaytn.com"},start:91582357,logo:"ipfs://QmYACyZcidcFtMo4Uf9H6ZKUxTP2TQPjGzNjcUjqYa64dt"},8453:{key:"8453",name:"Base",shortName:"mainnet",chainId:8453,network:"mainnet",multicall:"0xca11bde05977b3631167028862be2a173976ca11",rpc:[],explorer:{url:"https://basescan.org/"},start:5022,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv"},9001:{key:"9001",name:"Evmos Network",shortName:"Evmos",chainId:9001,network:"mainnet",multicall:"0x37763d16f8dBf6F185368E0f256350cAb7E24b26",rpc:["https://eth.bd.evmos.org:8545"],ws:["wss://eth.bd.evmos.org:8546"],explorer:{url:"https://escan.live"},start:13959539,logo:"ipfs://bafkreif4obrdoiretpozdd56seziywc6clha7wwkbldng3ovry2bpzly34"},1e4:{key:"10000",name:"smartBCH",shortName:"BCH",chainId:1e4,network:"mainnet",multicall:"0x1b38EBAd553f218e2962Cb1C0539Abb5d6A37774",rpc:["https://smartbch.greyh.at/"],explorer:{url:"https://smartbch-explorer.web.app"},start:268248,logo:"ipfs://QmWG1p7om4hZ4Yi4uQvDpxg4si7qVYhtppGbcDGrhVFvMd"},10243:{key:"10243",name:"Arthera Testnet",shortName:"Arthera_",chainId:10243,network:"testnet",testnet:!0,multicall:"0x27c7FC597aD2E81C4c1cA1769972f79DaF042Da7",rpc:["https://rpc-test.arthera.net"],explorer:{url:"https://explorer-test.arthera.net"},start:10523,logo:"ipfs://QmYQp3e52KjkT4bYdAvB6ACEEpXs2D8DozsDitaADRY2Ak"},13337:{key:"13337",name:"Beam Testnet",shortName:"testnet",chainId:13337,network:"testnet",multicall:"0x9BF49b704EE2A095b95c1f2D4EB9010510c41C9E",rpc:[],explorer:{url:"https://subnets-test.avax.network/beam/"},start:3,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF",testnet:!0},13371:{key:"13371",name:"Immutable zkEVM",shortName:"mainnet",chainId:13371,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.immutable.com"},start:3680945,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi"},13473:{key:"13473",name:"Immutable zkEVM Testnet",shortName:"testnet",chainId:13473,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.testnet.immutable.com"},start:5307209,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi",testnet:!0},16718:{key:"16718",name:"AirDAO",chainId:16718,network:"mainnet",multicall:"0x25e81aC81A8B03389D78CB45faB78353aB528574",rpc:["https://network-archive.ambrosus.io"],ws:["wss://network-archive.ambrosus.io/ws"],explorer:{url:"https://airdao.io/explorer"},start:22922566,logo:"ipfs://QmSxXjvWng3Diz4YwXDV2VqSPgMyzLYBNfkjJcr7rzkxom"},29548:{key:"29548",name:"MCH Verse",shortName:"mainnet",chainId:29548,network:"mainnet",multicall:"0x1d39652386488CE1fE4254E105F5A42a04d43dB2",rpc:[],explorer:{url:"https://explorer.oasys.mycryptoheroes.net"},start:27458402,logo:"ipfs://QmZZnwR1y6cU1sare2TQmwqkNDLXQxD4GdPrmHLmUoPtbU"},42161:{key:"42161",name:"Arbitrum One",chainId:42161,network:"Arbitrum mainnet",multicall:"0x7A7443F8c577d537f1d8cD4a629d40a3148Dd7ee",rpc:["https://rpc.ankr.com/arbitrum","https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/arbitrum/mainnet","https://arb-mainnet.g.alchemy.com/v2/JDvtNGwnHhTltIwfnxQocKwKkCTKA1DL"],explorer:{url:"https://arbiscan.io"},start:256508,logo:"ipfs://QmWZ5SMRfvcK8tycsDqojQaSiKedgtVkS7CkZdxPgeCVsZ"},42170:{key:"42170",name:"Arbitrum Nova",chainId:42170,network:"Arbitrum Nova",multicall:"0x4E74EBd9CABff51cE9a43EFe059bA8c5A28E4A14",rpc:["https://nova.arbitrum.io/rpc","https://arbitrum-nova.public.blastapi.io"],explorer:{url:"https://nova.arbiscan.io/"},start:6006607,logo:"ipfs://bafkreie5xsqt3mrrwu7v32qpmmctibhzhgxf4emfzzddsdhdlfsa7fmplu"},42220:{key:"42220",name:"Celo",shortName:"Celo",chainId:42220,network:"mainnet",multicall:"0xb8d0d2C1391eeB350d2Cd39EfABBaaEC297368D9",rpc:["https://celo.snapshot.org","https://forno.celo.org","https://celo-mainnet--rpc.datahub.figment.io/apikey/e892a66dc36e4d2d98a5d6406d609796/"],explorer:{url:"https://explorer.celo.org"},start:6599803,logo:"ipfs://QmS2tVJ7rdJRe1NHXAi2L86yCbUwVVrmB2mHQeNdJxvQti"},43113:{key:"43113",name:"Avalanche FUJI Testnet",chainId:43113,network:"testnet",testnet:!0,multicall:"0x984476ea55e32e785A9D8FF14329f99D74E3d2A2",rpc:["https://api.avax-test.network/ext/bc/C/rpc"],explorer:{url:"https://testnet.snowtrace.io"},start:10528153,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},43114:{key:"43114",name:"Avalanche",chainId:43114,network:"mainnet",multicall:"0x7E9985aE4C8248fdB07607648406a48C76e9e7eD",rpc:["https://nd-784-543-849.p2pify.com/aa7b29fc5fed65b34f0ee6b8de33f8c0/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://api.avax.network/ext/bc/C/rpc"],explorer:{url:"https://snowtrace.io"},start:536483,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},47805:{key:"47805",name:"REI Mainnet",chainId:47805,network:"mainnet",multicall:"0x9eE9904815B80C39C1a27294E69a8626EAa7952d",rpc:["https://rpc.rei.network"],explorer:{url:"https://scan.rei.network/"},start:1715902,logo:"ipfs://QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"},53935:{key:"53935",name:"DFK Chain",chainId:53935,network:"mainnet",multicall:"0x5b24224dC16508DAD755756639E420817DD4c99E",rpc:["https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"],explorer:{url:"https://subnets.avax.network/defi-kingdoms/"},start:62,logo:"ipfs://QmZNkpVgPbuVbDcsi6arwH1om3456FGnwfDqYQJWUfHDEx"},59141:{key:"59141",name:"Linea Sepolia",shortName:"testnet",chainId:59141,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.lineascan.build/"},start:227427,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce",testnet:!0},59144:{key:"59144",name:"Linea",shortName:"linea",chainId:59144,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://lineascan.build/"},start:42,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce"},80001:{key:"80001",name:"Polygon Mumbai",chainId:80001,network:"testnet",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/polygon/mumbai/archive","https://rpc-mumbai.matic.today"],ws:["wss://ws-mumbai.matic.today"],explorer:{url:"https://mumbai.polygonscan.com",apiUrl:"https://api-mumbai.polygonscan.com"},start:12011090,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},81457:{key:"81457",name:"Blast",shortName:"mainnet",chainId:81457,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://blastscan.io"},start:88189,logo:"ipfs://bafkreibfmkjg22cozxppzcoxswj45clvh2rqhxzax57cmmgudbtkf4dkce"},84532:{key:"84532",name:"Base Sepolia",shortName:"testnet",chainId:84532,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://base-sepolia.blockscout.com/"},start:1059647,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv",testnet:!0},686868:{key:"686868",name:"Merlin Testnet",shortName:"merlin",chainId:686868,network:"testnet",multicall:"0x758BC6321b7c68F4986d62a4D46E83A2DCb58c80",rpc:[],explorer:{url:"https://testnet-scan.merlinchain.io"},start:3562021,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe",testnet:!0},713715:{key:"713715",name:"Sei EVM Devnet",shortName:"devnet",chainId:713715,network:"testnet",multicall:"0xEe8d287B844959ADe40d718Dc23077ba920e2f07",rpc:[],explorer:{url:"https://seitrace.com"},start:1463669,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},810180:{key:"810180",name:"zkLink Nova",shortName:"zlink",chainId:810180,network:"mainnet",multicall:"0x825267E0fA5CAe92F98540828a54198dcB3Eaeb5",rpc:[],explorer:{url:"https://explorer.zklink.io"},start:146055,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74"},810181:{key:"810181",name:"zkLink Nova Sepolia",shortName:"testnet",chainId:810181,network:"testnet",multicall:"0x97148F8fDdd9A1620f72EC1Bb2932916623d9da5",rpc:[],explorer:{url:"https://sepolia.explorer.zklink.io/"},start:43723,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74",testnet:!0},11155111:{key:"11155111",name:"Sepolia testnet",shortName:"Sepolia",chainId:11155111,network:"sepolia",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://sepolia.infura.io/v3/d26b4fd748814fe994b05899fd89e667"],ensResolvers:["0x8FADE66B79cC9f707aB26799354482EB93a5B7dD"],ensNameWrapper:"0x0635513f179D50A207757E05759CbD106d7dFcE8",ensSubgraph:"https://api.studio.thegraph.com/proxy/49574/enssepolia/version/latest",explorer:{url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io"},start:751532,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},11155420:{key:"11155420",name:"OP Sepolia",shortName:"testnet",chainId:11155420,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia-optimism.etherscan.io"},start:1620204,logo:"ipfs://QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb",testnet:!0},111557560:{key:"111557560",name:"Cyber Testnet",shortName:"testnet",chainId:111557560,network:"testnet",multicall:"0xffc391F0018269d4758AEA1a144772E8FB99545E",rpc:[],explorer:{url:"https://testnet.cyberscan.co/"},start:304545,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm",testnet:!0},168587773:{key:"168587773",name:"Blast Sepolia",shortName:"testnet",chainId:168587773,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.blastexplorer.io"},start:756690,logo:"ipfs://bafkreibfmkjg22cozxppzcoxswj45clvh2rqhxzax57cmmgudbtkf4dkce",testnet:!0},245022926:{key:"245022926",name:"Neon Devnet",shortName:"devnet",chainId:245022926,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://devnet.neonscan.org/"},start:205206112,logo:"ipfs://QmecRPQGa4bU7tybg1sUQY48Md9rWnmhrT6WW5ueqvhg6P",testnet:!0},1313161554:{key:"1313161554",name:"Aurora",shortName:"Aurora",chainId:1313161554,network:"mainnet",multicall:"0x32b50c286DEFd2932a0247b8bb940b78c063F16c",rpc:["https://mainnet.aurora.dev"],explorer:{url:"https://explorer.mainnet.aurora.dev"},start:57190533,logo:"ipfs://QmeRhsR1UPRTQCizdhmgr2XxphXebVKU5di97uCV2UMFpa"},16666e5:{key:"1666600000",name:"Harmony",shortName:"HarmonyMainnet",chainId:16666e5,network:"mainnet",multicall:"0x9c31392D2e0229dC4Aa250F043d46B9E82074BF8",rpc:["https://a.api.s0.t.hmny.io"],ws:["wss://ws.s0.t.hmny.io"],explorer:{url:"https://explorer.harmony.one"},start:10911984,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"},16667e5:{key:"1666700000",name:"Harmony Testnet",shortName:"HarmonyTestnet",chainId:16667e5,network:"testnet",testnet:!0,multicall:"0x9923589503Fd205feE3d367DDFF2378f0F7dD2d4",rpc:["https://api.s0.b.hmny.io"],ws:["wss://ws.s0.b.hmny.io"],explorer:{url:"https://explorer.pops.one"},start:7521509,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"}};class sN{constructor(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}static isValidChoice(t,e){return"number"==typeof t&&void 0!==(null==e?void 0:e[t-1])}getValidVotes(){return this.votes.filter((t=>sN.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>{const r=this.getValidVotes().filter((t=>t.choice===e+1));return r.reduce(((t,e)=>t+e.balance),0)}))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>{const r=this.strategies.map(((t,r)=>{const n=this.getValidVotes().filter((t=>t.choice===e+1));return n.reduce(((t,e)=>t+e.scores[r]),0)}));return r}))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices[this.selected-1]}}class aN{constructor(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size}getValidVotes(){return this.votes.filter((t=>aN.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.balance),0)))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.scores[r]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected?this.proposal.choices.filter(((t,e)=>this.selected.includes(e+1))).join(", "):""}}function hN(t,e){const r=t/e.reduce(((t,e)=>t+e),0);return isNaN(r)?0:r}function uN(t,e){return Math.sqrt(t*e)}function lN(t){return t*t}function cN(t,e){return t.map((t=>e*t))}class fN{constructor(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>fN.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>{const n=t.map((t=>uN(hN(t.choice[r+1],Object.values(t.choice)),t.balance))).reduce(((t,e)=>t+e),0);return lN(n)}));return cN(r.map(((t,e)=>hN(r[e],r))),e)}getScoresByStrategy(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>this.strategies.map(((e,n)=>t.map((t=>uN(hN(t.choice[r+1],Object.values(t.choice)),t.scores[n]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[lN(t)]))));return r.map(((t,n)=>cN(this.strategies.map(((t,e)=>hN(r[n][e][0],r.flat(2)))),e)))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1]){const r=hN(this.selected[e+1],Object.values(this.selected));return`${Math.round(1e3*r)/10}% for ${t}`}})).filter((t=>null!=t)).join(", ")}}function dN(t,e){const r=[...new Set(t.map((t=>t[0])).flat())],n=Object.entries(t.reduce(((t,[e],r,n)=>{const i=n[r][1];t[e[0]][0]+=i;const o=n[r][2];return o.length>1?t[e[0]][1]=o.map(((r,n)=>r+t[e[0]][1][n]||r)):t[e[0]][1]=[t[e[0]][1].concat(o).reduce(((t,e)=>t+e),0)],t}),Object.assign({},...r.map((t=>({[t]:[0,[]]})))))),i=n.map((t=>[t[0],t[1][0]])),[o,s]=i.reduce((([t,e],[r,n])=>n>e?[r,n]:[t,e]),["?",-1/0]),[a,h]=i.reduce((([t,e],[r,n])=>n<e?[r,n]:[t,e]),["?",1/0]),u=n.sort(((t,e)=>e[1][0]-t[1][0])),l=t.map((t=>t[1])).reduce(((t,e)=>t+e),0);return e.push({round:e.length+1,sortedByHighest:u}),s>l/2||u.length<3?e:dN(t.map((t=>[t[0].filter((t=>t!=a)),t[1],t[2]])).filter((t=>t[0].length>0)),e)}function pN(t){const e=dN(t.map((t=>[t.choice,t.balance,t.scores])),[]);return e[e.length-1].sortedByHighest}class mN{constructor(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size&&t.length>0&&t.length===e.length}getValidVotes(){return this.votes.filter((t=>mN.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return function(t,e){const r=pN(t);return e.choices.map(((t,e)=>r.filter((t=>Number(t[0])===e+1)).reduce(((t,e)=>t+e[1][0]),0)))}(this.getValidVotes(),this.proposal)}getScoresByStrategy(){const t=pN(this.getValidVotes());return this.proposal.choices.map(((e,r)=>this.strategies.map(((e,n)=>t.filter((t=>Number(t[0])===r+1)).reduce(((t,e)=>t+e[1][1][n]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected.map((t=>{if(this.proposal.choices[t-1])return this.proposal.choices[t-1]})).map(((t,e)=>`(${LN(e+1)}) ${t}`)).join(", ")}}function gN(t,e,r){const n=r.reduce(((t,e)=>t+e),0),i=e[t]/n*100;return isNaN(i)?0:i}function yN(t,e,r){return gN(t+1,e,Object.values(e))/100*r}class vN{constructor(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>vN.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.proposal.choices.map(((t,e)=>this.getValidVotes().map((t=>yN(e,t.choice,t.balance))).reduce(((t,e)=>t+e),0))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((e,r)=>gN(r,t,t))).map((t=>e/100*t))}getScoresByStrategy(){const t=this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().map((t=>yN(e,t.choice,t.scores[r]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[t])))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((r,n)=>this.strategies.map(((e,r)=>gN(0,t[n][r],t.flat(2)))).map((t=>[e/100*t])).flat()))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1])return`${Math.round(10*gN(e+1,this.selected,Object.values(this.selected)))/10}% for ${t}`})).filter((t=>null!=t)).join(", ")}}var wN={"single-choice":sN,approval:aN,quadratic:fN,"ranked-choice":mN,weighted:vN,basic:sN};const bN={1:"https://subgrapher.snapshot.org/delegation/1",10:"https://subgrapher.snapshot.org/delegation/10",56:"https://subgrapher.snapshot.org/delegation/56",100:"https://subgrapher.snapshot.org/delegation/100",137:"https://subgrapher.snapshot.org/delegation/137",250:"https://subgrapher.snapshot.org/delegation/250",42161:"https://subgrapher.snapshot.org/delegation/42161",11155111:"https://subgrapher.snapshot.org/delegation/11155111"},_N=1e3;function EN(t){return t.length===_N&&t[0].timestamp===t[t.length-1].timestamp}function AN(t,e){const r=function(t){return`${t.delegator}-${t.delegate}-${t.space}`}(e);t.has(r)||t.set(r,e)}function kN(t){const e=["",t];return t.includes(".eth")&&e.push(t.replace(".eth","")),e}function MN(t){return e(this,arguments,void 0,(function*({url:t,spaces:e,pivot:r,snapshot:n}){const i={delegations:{__args:{where:{space_in:e,timestamp_gte:r},first:_N,skip:0,orderBy:"timestamp",orderDirection:"asc"},delegator:!0,space:!0,delegate:!0,timestamp:!0}};return"latest"!==n&&(i.delegations.__args.block={number:n}),(yield BN(t,i)).delegations||[]}))}const xN=["function text(bytes32 node, string calldata key) external view returns (string memory)"],SN={Accept:"application/json","Content-Type":"application/json"},NN="https://score.snapshot.org";function IN(t=NN,e={path:""}){const r=new URL(t);e.path&&(r.pathname=e.path);const n=r.searchParams.get("apiKey");let i=Object.assign({},SN);return n&&(r.searchParams.delete("apiKey"),i=Object.assign(Object.assign({},SN),{"X-API-KEY":n})),{url:r.toString(),headers:i}}function CN(t){return e(this,void 0,void 0,(function*(){let e=yield t.text();try{e=JSON.parse(e)}catch(r){return Promise.reject({code:t.status||500,message:"Failed to parse response from score API",data:e})}return e.error?Promise.reject(e.error):e}))}const TN=new Ef({allErrors:!0,allowUnionTypes:!0,$data:!0,passContext:!0});xf(TN),Nf(TN),TN.addFormat("address",{validate:t=>{try{return Re(t)}catch(t){return!1}}}),TN.addFormat("starknetAddress",{validate:t=>{try{return HN(t)}catch(t){return!1}}}),TN.addFormat("long",{validate:()=>!0}),TN.addFormat("ethValue",{validate:t=>{if(!t.match(/^([0-9]|[1-9][0-9]+)(\.[0-9]+)?$/))return!1;try{return function(t,e){if("string"!=typeof t&&Ya.throwArgumentError("value must be a string","value",t),"string"==typeof e){const t=Wa.indexOf(e);-1!==t&&(e=3*t)}Ga(t,null!=e?e:18)}(t,18),!0}catch(t){return!1}}});const PN=Object.keys(oN),RN=Object.keys(oN).filter((t=>!oN[t].testnet));function ON(t,r,n,i){return e(this,void 0,void 0,(function*(){const e=new sa(n[0],r,t);try{const t=n[2]||[];return yield e[n[1]](...t,i||{})}catch(t){return Promise.reject(t)}}))}function $N(t,r,n,i,o){return e(this,void 0,void 0,(function*(){const e=(null==o?void 0:o.multicallAddress)||oN[t].multicall,s=new sa(e,["function aggregate(tuple(address target, bytes callData)[] calls) view returns (uint256 blockNumber, bytes[] returnData)"],r),a=new Yn(n);try{const t=(null==o?void 0:o.limit)||500;(null==o?void 0:o.limit)&&delete o.limit;const e=Math.ceil(i.length/t),r=[];Array.from(Array(e)).forEach(((e,n)=>{const h=i.slice(t*n,t*(n+1));r.push(s.aggregate(h.map((t=>[t[0].toLowerCase(),a.encodeFunctionData(t[1],t[2])])),o||{}))}));let n=yield Promise.all(r);return n=n.reduce(((t,[,e])=>t.concat(e)),[]),n.map(((t,e)=>a.decodeFunctionResult(i[e][1],t)))}catch(t){return Promise.reject(t)}}))}function BN(t,r){return e(this,arguments,void 0,(function*(t,e,r={}){const n=yield a(t,{method:"POST",headers:Object.assign({Accept:"application/json","Content-Type":"application/json"},null==r?void 0:r.headers),body:JSON.stringify({query:Ku.jsonToGraphQLQuery({query:e})})});let i=yield n.text();try{i=JSON.parse(i)}catch(e){throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${i.substring(0,400)}`)}if(i.errors)throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${JSON.stringify(i.errors).substring(0,400)}`);const{data:o}=i;return o||{}}))}function DN(t,e=iN[0]){const r=`https://${e}`;if(!t)return null;if(!(t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("https://")||t.startsWith("http://")))return`${r}/ipfs/${t}`;const n=t.split("://")[0];return"ipfs"===n?t.replace("ipfs://",`${r}/ipfs/`):"ipns"===n?t.replace("ipns://",`${r}/ipns/`):t}function FN(r,n){return e(this,arguments,void 0,(function*(e,r,n="1",i={}){const{ensResolvers:o,broviderUrl:s}=i,a=t(i,["ensResolvers","broviderUrl"]),h=o||oN[n].ensResolvers||oN[1].ensResolvers,u=du(fu(e)),l=cm(n,{broviderUrl:s});return(yield $N(n,l,xN,h.map((t=>[t,"text",[u,r]])),a)).flat().find((t=>t))||""}))}function UN(t){return e(this,arguments,void 0,(function*(t,e="1",r={}){try{return yield FN(t,"snapshot",e,r)}catch(t){return console.log(t),null}}))}function jN(t){return e(this,arguments,void 0,(function*(t,e="1",r={}){const n=cm(e,r),i=new sa("0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",["function owner(bytes32) view returns (address)"],n),o=r.ensNameWrapper||oN[e].ensNameWrapper,s=du(fu(t));let a=yield i.owner(s);if(a===o){const t=new sa(o,["function ownerOf(uint256) view returns (address)"],n);a=yield t.ownerOf(s)}return a}))}function LN(t){const e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])}function zN(t){return!!oN[t]}function qN(t){return Re(t)&&"0x0000000000000000000000000000000000000000"!==t}function VN(t,e){return"latest"===t||"number"==typeof t&&t>=oN[e].start}function HN(t){if(!t)return!1;try{return NS(t),!0}catch(t){return!1}}function GN(t){return Re(t)}function KN(t){return Promise.reject(new Error(t))}TN.addKeyword({keyword:"snapshotNetwork",validate:function(t,e){return"mainnet"===(this.snapshotEnv||"default")?RN.includes(e):PN.includes(e)},error:{message:"network not allowed"}}),TN.addKeyword({keyword:"maxLengthWithSpaceType",validate:function t(e,r){const n=this.spaceType||"default",i=r.length<=e[n];return i||(t.errors=[{keyword:"maxLengthWithSpaceType",message:`must NOT have more than ${e[n]} characters`,params:{limit:e[n]}}]),i},errors:!0}),TN.addKeyword({keyword:"maxItemsWithSpaceType",validate:function t(e,r){const n=this.spaceType||"default",i=r.length<=e[n];return i||(t.errors=[{keyword:"maxItemsWithSpaceType",message:`must NOT have more than ${e[n]} items`,params:{limit:e[n]}}]),i},errors:!0}),TN.addFormat("customUrl",{type:"string",validate:t=>!t.length||(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("snapshot://"))});var ZN={call:ON,multicall:$N,subgraphRequest:BN,ipfsGet:function(t,r){return e(this,arguments,void 0,(function*(t,e,r="ipfs"){return a(`https://${t}/${r}/${e}`).then((t=>t.json()))}))},getUrl:DN,getJSON:function(t){return e(this,arguments,void 0,(function*(t,e={}){const r=DN(t,e.gateways);return a(r).then((t=>t.json()))}))},sendTransaction:function(t,r,n,i,o){return e(this,arguments,void 0,(function*(t,e,r,n,i,o={}){const s=t.getSigner(),a=new sa(e,r,t).connect(s);return yield a[n](...i,o)}))},getScores:function(t,r,n,i){return e(this,arguments,void 0,(function*(t,e,r,n,i="latest",o=NN,s={}){if(!Array.isArray(n))return KN("addresses should be an array of addresses");if(0===n.length)return KN("addresses can not be empty");const h=n.find((t=>!qN(t)));if(h)return KN(`Invalid address: ${h}`);if(!zN(r))return KN(`Invalid network: ${r}`);const u=e.find((t=>t.network&&!zN(t.network)));if(u)return KN(`Invalid network (${u.network}) in strategy ${u.name}`);if(!VN(i,r))return KN(`Snapshot (${i}) must be 'latest' or greater than network start block (${oN[r].start})`);new URL(o).pathname="/api/scores";const{url:l,headers:c}=IN(o,{path:"/api/scores"});try{const o={space:t,network:r,snapshot:i,strategies:e,addresses:n},h=yield a(l,{method:"POST",headers:c,body:JSON.stringify({params:o})}),u=yield CN(h);return"all"===s.returnValue?u.result:u.result[s.returnValue||"scores"]}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},getVp:function(t,r,n,i,o,s,h){return e(this,void 0,void 0,(function*(){const{url:e,headers:u}=IN(null==h?void 0:h.url);if(!qN(t))return KN(`Invalid voter address: ${t}`);if(!zN(r))return KN(`Invalid network: ${r}`);const l=n.find((t=>t.network&&!zN(t.network)));if(l)return KN(`Invalid network (${l.network}) in strategy ${l.name}`);if(!VN(i,r))return KN(`Snapshot (${i}) must be 'latest' or greater than network start block (${oN[r].start})`);const c={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"get_vp",params:{address:t,network:r,strategies:n,snapshot:i,space:o,delegation:s}})};try{const t=yield a(e,c);return(yield CN(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},validateSchema:function(t,e,r={snapshotEnv:"default",spaceType:"default"}){const n=TN.compile(t),i=n.call(r,e);return i||n.errors},getEnsTextRecord:FN,getSpaceUri:UN,getEnsOwner:jN,getSpaceController:function(t){return e(this,arguments,void 0,(function*(t,e="1",r={}){const n=yield UN(t,e,r);if(n){let t=Re(n);if(t)return n;const e=n.split("/"),r=e.includes("testnet")?5:4,i=e[r];if(t=Re(i),t)return i}return yield jN(t,e,r)}))},getDelegatesBySpace:function(t,r){return e(this,arguments,void 0,(function*(t,e,r="latest",n={}){const i=n.subgraphUrl||bN[t];if(!i)return Promise.reject(`Delegation subgraph not available for network ${t}`);let o=0;const s=new Map,a=kN(e);for(;;){const t=yield MN({url:i,spaces:a,pivot:o,snapshot:r});if(EN(t))throw new Error("Unable to paginate delegation");if(t.forEach((t=>{AN(s,t),o=t.timestamp})),t.length<_N)break}return[...s.values()]}))},clone:function(t){return JSON.parse(JSON.stringify(t))},sleep:function(t){return e(this,void 0,void 0,(function*(){return new Promise((e=>{setTimeout(e,t)}))}))},getNumberWithOrdinal:LN,voting:wN,getProvider:cm,signMessage:function(t,r,n){return e(this,void 0,void 0,(function*(){return r=I(new Buffer(r,"utf8")),yield t.send("personal_sign",[r,n])}))},getBlockNumber:function(t){return e(this,void 0,void 0,(function*(){try{const e=yield t.getBlockNumber();return parseInt(e)}catch(t){return Promise.reject()}}))},Multicaller:class{constructor(t,e,r,n){this.options={},this.calls=[],this.paths=[],this.network=t,this.provider=e,this.abi=r,this.options=n||{}}call(t,e,r,n){return this.calls.push([e,r,n]),this.paths.push(t),this}execute(t){return e(this,void 0,void 0,(function*(){const e=t||{};return(yield $N(this.network,this.provider,this.abi,this.calls,this.options)).forEach(((t,r)=>_d(e,this.paths[r],t.length>1?t:t[0]))),this.calls=[],this.paths=[],e}))}},getSnapshots:function(t,r,n,i){return e(this,arguments,void 0,(function*(t,e,r,n,i={}){const o={};if(n.forEach((t=>o[t]="latest")),"latest"===e)return o;const s=`${t}-${e}-${n.join("-")}`,a=Ed[s],h=Date.now();if(a&&Ad>h)return a;Ad<h&&(Ed={},Ad=h+36e5-h%36e5),o[t]=e;const u=Object.keys(o).filter((e=>t!==e));if(0===u.length)return o;const l={blocks:{__args:{where:{ts:(yield r.getBlock(e)).timestamp,network_in:u}},network:!0,number:!0}},c=i.blockFinderUrl||"https://blockfinder.snapshot.org";return(yield BN(c,l)).blocks.forEach((t=>o[t.network]=t.number)),Ed[s]=o,o}))},getHash:function(t,e){return(PS(t)?OS:nN).getHash(t,e)},verify:function(t,r,n){return e(this,arguments,void 0,(function*(t,e,r,n="1",i={}){if(!HN(t)&&!GN(t))throw new Error("Invalid address");const o=PS(r)?OS:nN;return yield o.default(t,e,r,n,i)}))},validate:function(t,r,n,i,o,s,h){return e(this,void 0,void 0,(function*(){if(!qN(r))return KN(`Invalid author: ${r}`);if(!zN(i))return KN(`Invalid network: ${i}`);if(!VN(o,i))return KN(`Snapshot (${o}) must be 'latest' or greater than network start block (${oN[i].start})`);h||(h={});const{url:e,headers:u}=IN(h.url),l={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"validate",params:{validation:t,author:r,space:n,network:i,snapshot:o,params:s}})};try{const t=yield a(e,l);return(yield CN(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},isStarknetAddress:HN,isEvmAddress:GN,getFormattedAddress:function(t,e){if("evm"===e&&GN(t))return Pe(t);if("starknet"===e&&HN(t))return NS(t);throw new Error(`Invalid address: ${t}`)},SNAPSHOT_SUBGRAPH_URL:bN};return{Client:or,Client712:or,schemas:dr,utils:ZN}}));
|