@solarpunkltd/swarm-chat-js 3.0.0 → 3.1.0
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/index.esm.js +11313 -10982
- package/dist/index.js +19 -19
- package/dist/src/lib/core.d.ts.map +1 -1
- package/dist/src/lib/types/chat.d.ts +1 -1
- package/dist/src/lib/types/chat.d.ts.map +1 -1
- package/dist/swarm-chat-umd.js +19 -19
- package/package.json +4 -1
- package/dist/src/utils/queue.d.ts +0 -16
- package/dist/src/utils/queue.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";var MC=Object.defineProperty;var __=n=>{throw TypeError(n)};var LC=(n,t,e)=>t in n?MC(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Z=(n,t,e)=>LC(n,typeof t!="symbol"?t+"":t,e),fy=(n,t,e)=>t.has(n)||__("Cannot "+e);var T=(n,t,e)=>(fy(n,t,"read from private field"),e?e.call(n):t.get(n)),nt=(n,t,e)=>t.has(n)?__("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),$=(n,t,e,r)=>(fy(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e),_t=(n,t,e)=>(fy(n,t,"access private method"),e);var df=(n,t,e,r)=>({set _(i){$(n,t,i,e)},get _(){return T(n,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qt=require("@ethersphere/bee-js");var Zn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ea(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function q0(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}function UC(){this.__data__=[],this.size=0}var DC=UC;function FC(n,t){return n===t||n!==n&&t!==t}var Zv=FC,$C=Zv;function HC(n,t){for(var e=n.length;e--;)if($C(n[e][0],t))return e;return-1}var Q0=HC,zC=Q0,GC=Array.prototype,VC=GC.splice;function KC(n){var t=this.__data__,e=zC(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():VC.call(t,e,1),--this.size,!0}var jC=KC,WC=Q0;function ZC(n){var t=this.__data__,e=WC(t,n);return e<0?void 0:t[e][1]}var qC=ZC,QC=Q0;function JC(n){return QC(this.__data__,n)>-1}var YC=JC,XC=Q0;function t3(n,t){var e=this.__data__,r=XC(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var e3=t3,n3=DC,r3=jC,i3=qC,s3=YC,o3=e3;function Al(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Al.prototype.clear=n3;Al.prototype.delete=r3;Al.prototype.get=i3;Al.prototype.has=s3;Al.prototype.set=o3;var J0=Al,a3=J0;function c3(){this.__data__=new a3,this.size=0}var u3=c3;function l3(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var f3=l3;function h3(n){return this.__data__.get(n)}var d3=h3;function p3(n){return this.__data__.has(n)}var g3=p3,y3=typeof Zn=="object"&&Zn&&Zn.Object===Object&&Zn,qv=y3,m3=qv,w3=typeof self=="object"&&self&&self.Object===Object&&self,b3=m3||w3||Function("return this")(),Qs=b3,_3=Qs,A3=_3.Symbol,Lw=A3,A_=Lw,Qv=Object.prototype,E3=Qv.hasOwnProperty,v3=Qv.toString,pf=A_?A_.toStringTag:void 0;function x3(n){var t=E3.call(n,pf),e=n[pf];try{n[pf]=void 0;var r=!0}catch{}var i=v3.call(n);return r&&(t?n[pf]=e:delete n[pf]),i}var R3=x3,S3=Object.prototype,I3=S3.toString;function k3(n){return I3.call(n)}var T3=k3,E_=Lw,O3=R3,N3=T3,C3="[object Null]",B3="[object Undefined]",v_=E_?E_.toStringTag:void 0;function P3(n){return n==null?n===void 0?B3:C3:v_&&v_ in Object(n)?O3(n):N3(n)}var Y0=P3;function M3(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var Jv=M3,L3=Y0,U3=Jv,D3="[object AsyncFunction]",F3="[object Function]",$3="[object GeneratorFunction]",H3="[object Proxy]";function z3(n){if(!U3(n))return!1;var t=L3(n);return t==F3||t==$3||t==D3||t==H3}var Yv=z3,G3=Qs,V3=G3["__core-js_shared__"],K3=V3,hy=K3,x_=function(){var n=/[^.]+$/.exec(hy&&hy.keys&&hy.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function j3(n){return!!x_&&x_ in n}var W3=j3,Z3=Function.prototype,q3=Z3.toString;function Q3(n){if(n!=null){try{return q3.call(n)}catch{}try{return n+""}catch{}}return""}var Xv=Q3,J3=Yv,Y3=W3,X3=Jv,tB=Xv,eB=/[\\^$.*+?()[\]{}|]/g,nB=/^\[object .+?Constructor\]$/,rB=Function.prototype,iB=Object.prototype,sB=rB.toString,oB=iB.hasOwnProperty,aB=RegExp("^"+sB.call(oB).replace(eB,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function cB(n){if(!X3(n)||Y3(n))return!1;var t=J3(n)?aB:nB;return t.test(tB(n))}var uB=cB;function lB(n,t){return n==null?void 0:n[t]}var fB=lB,hB=uB,dB=fB;function pB(n,t){var e=dB(n,t);return hB(e)?e:void 0}var El=pB,gB=El,yB=Qs,mB=gB(yB,"Map"),Uw=mB,wB=El,bB=wB(Object,"create"),X0=bB,R_=X0;function _B(){this.__data__=R_?R_(null):{},this.size=0}var AB=_B;function EB(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var vB=EB,xB=X0,RB="__lodash_hash_undefined__",SB=Object.prototype,IB=SB.hasOwnProperty;function kB(n){var t=this.__data__;if(xB){var e=t[n];return e===RB?void 0:e}return IB.call(t,n)?t[n]:void 0}var TB=kB,OB=X0,NB=Object.prototype,CB=NB.hasOwnProperty;function BB(n){var t=this.__data__;return OB?t[n]!==void 0:CB.call(t,n)}var PB=BB,MB=X0,LB="__lodash_hash_undefined__";function UB(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=MB&&t===void 0?LB:t,this}var DB=UB,FB=AB,$B=vB,HB=TB,zB=PB,GB=DB;function vl(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}vl.prototype.clear=FB;vl.prototype.delete=$B;vl.prototype.get=HB;vl.prototype.has=zB;vl.prototype.set=GB;var VB=vl,S_=VB,KB=J0,jB=Uw;function WB(){this.size=0,this.__data__={hash:new S_,map:new(jB||KB),string:new S_}}var ZB=WB;function qB(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var QB=qB,JB=QB;function YB(n,t){var e=n.__data__;return JB(t)?e[typeof t=="string"?"string":"hash"]:e.map}var tp=YB,XB=tp;function t8(n){var t=XB(this,n).delete(n);return this.size-=t?1:0,t}var e8=t8,n8=tp;function r8(n){return n8(this,n).get(n)}var i8=r8,s8=tp;function o8(n){return s8(this,n).has(n)}var a8=o8,c8=tp;function u8(n,t){var e=c8(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var l8=u8,f8=ZB,h8=e8,d8=i8,p8=a8,g8=l8;function xl(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}xl.prototype.clear=f8;xl.prototype.delete=h8;xl.prototype.get=d8;xl.prototype.has=p8;xl.prototype.set=g8;var tx=xl,y8=J0,m8=Uw,w8=tx,b8=200;function _8(n,t){var e=this.__data__;if(e instanceof y8){var r=e.__data__;if(!m8||r.length<b8-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new w8(r)}return e.set(n,t),this.size=e.size,this}var A8=_8,E8=J0,v8=u3,x8=f3,R8=d3,S8=g3,I8=A8;function Rl(n){var t=this.__data__=new E8(n);this.size=t.size}Rl.prototype.clear=v8;Rl.prototype.delete=x8;Rl.prototype.get=R8;Rl.prototype.has=S8;Rl.prototype.set=I8;var k8=Rl,T8="__lodash_hash_undefined__";function O8(n){return this.__data__.set(n,T8),this}var N8=O8;function C8(n){return this.__data__.has(n)}var B8=C8,P8=tx,M8=N8,L8=B8;function i0(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new P8;++t<e;)this.add(n[t])}i0.prototype.add=i0.prototype.push=M8;i0.prototype.has=L8;var U8=i0;function D8(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var F8=D8;function $8(n,t){return n.has(t)}var H8=$8,z8=U8,G8=F8,V8=H8,K8=1,j8=2;function W8(n,t,e,r,i,s){var o=e&K8,c=n.length,u=t.length;if(c!=u&&!(o&&u>c))return!1;var f=s.get(n),h=s.get(t);if(f&&h)return f==t&&h==n;var y=-1,A=!0,b=e&j8?new z8:void 0;for(s.set(n,t),s.set(t,n);++y<c;){var R=n[y],k=t[y];if(r)var S=o?r(k,R,y,t,n,s):r(R,k,y,n,t,s);if(S!==void 0){if(S)continue;A=!1;break}if(b){if(!G8(t,function(B,H){if(!V8(b,H)&&(R===B||i(R,B,e,r,s)))return b.push(H)})){A=!1;break}}else if(!(R===k||i(R,k,e,r,s))){A=!1;break}}return s.delete(n),s.delete(t),A}var ex=W8,Z8=Qs,q8=Z8.Uint8Array,Q8=q8;function J8(n){var t=-1,e=Array(n.size);return n.forEach(function(r,i){e[++t]=[i,r]}),e}var Y8=J8;function X8(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var t5=X8,I_=Lw,k_=Q8,e5=Zv,n5=ex,r5=Y8,i5=t5,s5=1,o5=2,a5="[object Boolean]",c5="[object Date]",u5="[object Error]",l5="[object Map]",f5="[object Number]",h5="[object RegExp]",d5="[object Set]",p5="[object String]",g5="[object Symbol]",y5="[object ArrayBuffer]",m5="[object DataView]",T_=I_?I_.prototype:void 0,dy=T_?T_.valueOf:void 0;function w5(n,t,e,r,i,s,o){switch(e){case m5:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case y5:return!(n.byteLength!=t.byteLength||!s(new k_(n),new k_(t)));case a5:case c5:case f5:return e5(+n,+t);case u5:return n.name==t.name&&n.message==t.message;case h5:case p5:return n==t+"";case l5:var c=r5;case d5:var u=r&s5;if(c||(c=i5),n.size!=t.size&&!u)return!1;var f=o.get(n);if(f)return f==t;r|=o5,o.set(n,t);var h=n5(c(n),c(t),r,i,s,o);return o.delete(n),h;case g5:if(dy)return dy.call(n)==dy.call(t)}return!1}var b5=w5;function _5(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var A5=_5,E5=Array.isArray,Dw=E5,v5=A5,x5=Dw;function R5(n,t,e){var r=t(n);return x5(n)?r:v5(r,e(n))}var S5=R5;function I5(n,t){for(var e=-1,r=n==null?0:n.length,i=0,s=[];++e<r;){var o=n[e];t(o,e,n)&&(s[i++]=o)}return s}var k5=I5;function T5(){return[]}var O5=T5,N5=k5,C5=O5,B5=Object.prototype,P5=B5.propertyIsEnumerable,O_=Object.getOwnPropertySymbols,M5=O_?function(n){return n==null?[]:(n=Object(n),N5(O_(n),function(t){return P5.call(n,t)}))}:C5,L5=M5;function U5(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var D5=U5;function F5(n){return n!=null&&typeof n=="object"}var ep=F5,$5=Y0,H5=ep,z5="[object Arguments]";function G5(n){return H5(n)&&$5(n)==z5}var V5=G5,N_=V5,K5=ep,nx=Object.prototype,j5=nx.hasOwnProperty,W5=nx.propertyIsEnumerable,Z5=N_(function(){return arguments}())?N_:function(n){return K5(n)&&j5.call(n,"callee")&&!W5.call(n,"callee")},q5=Z5,s0={exports:{}};function Q5(){return!1}var J5=Q5;s0.exports;(function(n,t){var e=Qs,r=J5,i=t&&!t.nodeType&&t,s=i&&!0&&n&&!n.nodeType&&n,o=s&&s.exports===i,c=o?e.Buffer:void 0,u=c?c.isBuffer:void 0,f=u||r;n.exports=f})(s0,s0.exports);var rx=s0.exports,Y5=9007199254740991,X5=/^(?:0|[1-9]\d*)$/;function t4(n,t){var e=typeof n;return t=t??Y5,!!t&&(e=="number"||e!="symbol"&&X5.test(n))&&n>-1&&n%1==0&&n<t}var e4=t4,n4=9007199254740991;function r4(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=n4}var ix=r4,i4=Y0,s4=ix,o4=ep,a4="[object Arguments]",c4="[object Array]",u4="[object Boolean]",l4="[object Date]",f4="[object Error]",h4="[object Function]",d4="[object Map]",p4="[object Number]",g4="[object Object]",y4="[object RegExp]",m4="[object Set]",w4="[object String]",b4="[object WeakMap]",_4="[object ArrayBuffer]",A4="[object DataView]",E4="[object Float32Array]",v4="[object Float64Array]",x4="[object Int8Array]",R4="[object Int16Array]",S4="[object Int32Array]",I4="[object Uint8Array]",k4="[object Uint8ClampedArray]",T4="[object Uint16Array]",O4="[object Uint32Array]",ze={};ze[E4]=ze[v4]=ze[x4]=ze[R4]=ze[S4]=ze[I4]=ze[k4]=ze[T4]=ze[O4]=!0;ze[a4]=ze[c4]=ze[_4]=ze[u4]=ze[A4]=ze[l4]=ze[f4]=ze[h4]=ze[d4]=ze[p4]=ze[g4]=ze[y4]=ze[m4]=ze[w4]=ze[b4]=!1;function N4(n){return o4(n)&&s4(n.length)&&!!ze[i4(n)]}var C4=N4;function B4(n){return function(t){return n(t)}}var P4=B4,o0={exports:{}};o0.exports;(function(n,t){var e=qv,r=t&&!t.nodeType&&t,i=r&&!0&&n&&!n.nodeType&&n,s=i&&i.exports===r,o=s&&e.process,c=function(){try{var u=i&&i.require&&i.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}}();n.exports=c})(o0,o0.exports);var M4=o0.exports,L4=C4,U4=P4,C_=M4,B_=C_&&C_.isTypedArray,D4=B_?U4(B_):L4,sx=D4,F4=D5,$4=q5,H4=Dw,z4=rx,G4=e4,V4=sx,K4=Object.prototype,j4=K4.hasOwnProperty;function W4(n,t){var e=H4(n),r=!e&&$4(n),i=!e&&!r&&z4(n),s=!e&&!r&&!i&&V4(n),o=e||r||i||s,c=o?F4(n.length,String):[],u=c.length;for(var f in n)(t||j4.call(n,f))&&!(o&&(f=="length"||i&&(f=="offset"||f=="parent")||s&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||G4(f,u)))&&c.push(f);return c}var Z4=W4,q4=Object.prototype;function Q4(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||q4;return n===e}var J4=Q4;function Y4(n,t){return function(e){return n(t(e))}}var X4=Y4,tP=X4,eP=tP(Object.keys,Object),nP=eP,rP=J4,iP=nP,sP=Object.prototype,oP=sP.hasOwnProperty;function aP(n){if(!rP(n))return iP(n);var t=[];for(var e in Object(n))oP.call(n,e)&&e!="constructor"&&t.push(e);return t}var cP=aP,uP=Yv,lP=ix;function fP(n){return n!=null&&lP(n.length)&&!uP(n)}var hP=fP,dP=Z4,pP=cP,gP=hP;function yP(n){return gP(n)?dP(n):pP(n)}var mP=yP,wP=S5,bP=L5,_P=mP;function AP(n){return wP(n,_P,bP)}var EP=AP,P_=EP,vP=1,xP=Object.prototype,RP=xP.hasOwnProperty;function SP(n,t,e,r,i,s){var o=e&vP,c=P_(n),u=c.length,f=P_(t),h=f.length;if(u!=h&&!o)return!1;for(var y=u;y--;){var A=c[y];if(!(o?A in t:RP.call(t,A)))return!1}var b=s.get(n),R=s.get(t);if(b&&R)return b==t&&R==n;var k=!0;s.set(n,t),s.set(t,n);for(var S=o;++y<u;){A=c[y];var B=n[A],H=t[A];if(r)var U=o?r(H,B,A,t,n,s):r(B,H,A,n,t,s);if(!(U===void 0?B===H||i(B,H,e,r,s):U)){k=!1;break}S||(S=A=="constructor")}if(k&&!S){var G=n.constructor,W=t.constructor;G!=W&&"constructor"in n&&"constructor"in t&&!(typeof G=="function"&&G instanceof G&&typeof W=="function"&&W instanceof W)&&(k=!1)}return s.delete(n),s.delete(t),k}var IP=SP,kP=El,TP=Qs,OP=kP(TP,"DataView"),NP=OP,CP=El,BP=Qs,PP=CP(BP,"Promise"),MP=PP,LP=El,UP=Qs,DP=LP(UP,"Set"),FP=DP,$P=El,HP=Qs,zP=$P(HP,"WeakMap"),GP=zP,bm=NP,_m=Uw,Am=MP,Em=FP,vm=GP,ox=Y0,Sl=Xv,M_="[object Map]",VP="[object Object]",L_="[object Promise]",U_="[object Set]",D_="[object WeakMap]",F_="[object DataView]",KP=Sl(bm),jP=Sl(_m),WP=Sl(Am),ZP=Sl(Em),qP=Sl(vm),la=ox;(bm&&la(new bm(new ArrayBuffer(1)))!=F_||_m&&la(new _m)!=M_||Am&&la(Am.resolve())!=L_||Em&&la(new Em)!=U_||vm&&la(new vm)!=D_)&&(la=function(n){var t=ox(n),e=t==VP?n.constructor:void 0,r=e?Sl(e):"";if(r)switch(r){case KP:return F_;case jP:return M_;case WP:return L_;case ZP:return U_;case qP:return D_}return t});var QP=la,py=k8,JP=ex,YP=b5,XP=IP,$_=QP,H_=Dw,z_=rx,tM=sx,eM=1,G_="[object Arguments]",V_="[object Array]",_d="[object Object]",nM=Object.prototype,K_=nM.hasOwnProperty;function rM(n,t,e,r,i,s){var o=H_(n),c=H_(t),u=o?V_:$_(n),f=c?V_:$_(t);u=u==G_?_d:u,f=f==G_?_d:f;var h=u==_d,y=f==_d,A=u==f;if(A&&z_(n)){if(!z_(t))return!1;o=!0,h=!1}if(A&&!h)return s||(s=new py),o||tM(n)?JP(n,t,e,r,i,s):YP(n,t,u,e,r,i,s);if(!(e&eM)){var b=h&&K_.call(n,"__wrapped__"),R=y&&K_.call(t,"__wrapped__");if(b||R){var k=b?n.value():n,S=R?t.value():t;return s||(s=new py),i(k,S,e,r,s)}}return A?(s||(s=new py),XP(n,t,e,r,i,s)):!1}var iM=rM,sM=iM,j_=ep;function ax(n,t,e,r,i){return n===t?!0:n==null||t==null||!j_(n)&&!j_(t)?n!==n&&t!==t:sM(n,t,e,r,ax,i)}var oM=ax,aM=oM;function cM(n,t){return aM(n,t)}var uM=cM;const lM=ea(uM),$n=[];for(let n=0;n<256;++n)$n.push((n+256).toString(16).slice(1));function fM(n,t=0){return($n[n[t+0]]+$n[n[t+1]]+$n[n[t+2]]+$n[n[t+3]]+"-"+$n[n[t+4]]+$n[n[t+5]]+"-"+$n[n[t+6]]+$n[n[t+7]]+"-"+$n[n[t+8]]+$n[n[t+9]]+"-"+$n[n[t+10]]+$n[n[t+11]]+$n[n[t+12]]+$n[n[t+13]]+$n[n[t+14]]+$n[n[t+15]]).toLowerCase()}let gy;const hM=new Uint8Array(16);function dM(){if(!gy){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");gy=crypto.getRandomValues.bind(crypto)}return gy(hM)}const pM=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),W_={randomUUID:pM};function gM(n,t,e){if(W_.randomUUID&&!t&&!n)return W_.randomUUID();n=n||{};const r=n.random||(n.rng||dM)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,fM(r)}function xm(n){return new Promise(t=>{setTimeout(t,n)})}function Ff(n){return(n.startsWith("0x")?n.slice(2):n).toLowerCase()}class Qi{constructor(){}static getInstance(){return Qi.instance||(Qi.instance=new Qi),Qi.instance}formatMessage(t,...e){return`[${new Date().toISOString()}] [${t.toUpperCase()}] - ${e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(" ")}`}log(...t){console.log(this.formatMessage("log",...t))}info(...t){console.info(this.formatMessage("info",...t))}warn(...t){console.warn(this.formatMessage("warn",...t))}error(...t){console.error(this.formatMessage("error",...t))}debug(...t){console.debug(this.formatMessage("debug",...t))}}class np{constructor(){this.logger=Qi.getInstance()}handleError(t,e){const r=t instanceof Error?t.message:"Unknown error occurred",i=t instanceof Error?t.stack:null;this.logger.error(`Error in ${e||"unknown context"}: ${r}`,{stack:i})}}let yM=class{constructor(){this.events={},this.on=this.on.bind(this),this.off=this.off.bind(this),this.cleanAll=this.cleanAll.bind(this),this.emit=this.emit.bind(this)}on(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)}off(t,e){if(!this.events[t])return;const r=this.events[t].indexOf(e);r>-1&&this.events[t].splice(r,1)}cleanAll(){this.events={}}emit(t,e){this.events[t]&&this.events[t].forEach(r=>r(e))}};class Z_{constructor(t={}){this.tasks=[],this.isProcessing=!1,this.isWaiting=!1,this.errorHandler=new np,this.clearWaitTime=t.clearWaitTime||500}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.tasks.length>0;){const t=this.tasks.shift();if(t)try{const e=t();e instanceof Promise&&await e}catch(e){this.errorHandler.handleError(e,"Queue.processQueue")}}this.isProcessing=!1}}enqueue(t){this.tasks.push(t),this.processQueue()}async waitForProcessing(){if(this.isWaiting)return!0;for(this.isWaiting=!0;this.isProcessing;)await xm(this.clearWaitTime);return this.isWaiting=!1,!1}}var cx={};(function(n){var t;Object.defineProperty(n,"__esModule",{value:!0}),n.Vector=n.Cache=n.Assertions=n.Strings=n.Types=n.Objects=n.Dates=n.Promises=n.Numbers=n.System=n.Arrays=n.Random=n.Elliptic=n.Binary=n.AsyncQueue=n.PubSubChannel=n.FixedPointNumber=n.MerkleTree=n.Chunk=n.Uint8ArrayWriter=n.Uint8ArrayReader=n.AsyncLazy=n.Lazy=n.Optional=void 0;async function e(a){return new Promise((l,d)=>a.then(d,l))}async function r(a){return e(Promise.all(a.map(e)))}async function i(a,l=1){const d=Kb(a,l),g=[],x=d.map(async L=>{for(const Q of L)g.push(await Q())});return await Promise.all(x),g}async function s(a){return new Promise(l=>setTimeout(()=>{l(!0)},a))}function o(a,l=Math.random){for(let d=a.length-1;d>0;d--){const g=Math.floor(l()*(d+1)),x=a[d];a[d]=a[g],a[g]=x}return a}function c(a){if(a.length===1)return a[0];throw Error(`Expected exactly one element, actual: ${a.length}`)}function u(a){return a.length===1?a[0]:null}function f(a){return a.length>0?a[0]:null}function h(a){if(!a.length)throw Error("Received empty array");return a[0]}function y(a,l){const d=[];for(let g=0;g<a;g++)d.push(l(g));return d}function A(a){const l=[];for(let d=0;d<a[0].length;d++){l.push([]);for(let g=0;g<a.length;g++)l[d].push(a[g][d])}return l}function b(a,l,d){const g=[];for(let x=0;x<a;x++){g.push([]);for(let L=0;L<l;L++)g[x].push(d)}return g}function R(a,l,d,g){if(d<0||g<0||g+l[0].length>a[0].length||d+l.length>a.length)return!1;for(let x=0;x<l.length;x++)for(let L=0;L<l[x].length;L++)if(l[x][L]!==void 0&&a[d+x][g+L]!==l[x][L])return!1;return!0}function k(a,l,d=Math.random){return o(db(0,a.length-1),d).slice(0,l)}function S(a,l){return a.map(d=>d[l])}function B(a){let l=a,d=3405648695,g=3735928559;return function(){return l+=d,d^=l<<7,l*=g,g^=l<<13,l^=d^g,(l>>>0)/4294967296}}function H(a,l,d=Math.random){return Math.floor(d()*(l-a+1))+a}function U(a,l,d=Math.random){return d()*(l-a)+a}function G(){return Math.random()*2-1}function W(a,l,d){return l>=a.x&&l<a.x+a.width&&d>=a.y&&d<a.y+a.height}function Y(a,l,d,g=Math.random){let x,L;do x=H(0,a-1,g),L=H(0,l-1,g);while(d&&W(d,x,L));return[x,L]}function j(a,l=Math.random){const d=Math.floor(a),g=a-d;return J(g,l)?d+1:d}function J(a,l=Math.random){return l()<a}function it(a,l=Math.random){return a[Math.floor(a.length*l())]}function ut(a,l,d=Math.random){if(l>a.length)throw new Error(`Count (${l}) is greater than array length (${a.length})`);return k(a,l,d).map(g=>a[g])}function rt(a,l,d,g=Math.random){if(l>a.length)throw new Error(`Count (${l}) is greater than array length (${a.length})`);const x=[];for(;x.length<l;){const L=it(a,g);x.some(Q=>d(Q,L))||x.push(L)}return x}function ot(a,l,d,g,x,L=Math.random){const Q=a.filter(at=>at!==l&&at!==d),lt=[];for(l!==null&<.push(l);Q.length&<.length<g;){const at=n.Random.intBetween(0,Q.length-1,L);x(Q[at],lt)&<.push(Q[at]),Q.splice(at,1)}return o(lt,L),{values:lt,indexOfGuaranteed:l!==null?lt.indexOf(l):-1}}function C(a){if(!a.length)throw Error("Received empty array");return a[a.length-1]}function p(a,l,d){return d(l.reduce((g,x)=>x(g),a))}function m(a,l){return d=>p(d,a,l)}function v(a,l,d){if(d===void 0&&(d=Math.random()),a.length!==l.length)throw new Error("Array length mismatch");let g=l.reduce((L,Q)=>L+Q,0);const x=d*g;for(let L=0;L<a.length-1;L++)if(g-=l[L],x>=g)return a[L];return C(a)}function I(a,l,d=Math.random){const g=l.map(L=>d()*L),x=[];for(let L=0;L<a.length;L++)x.push([a[L],g[L]]);return x.sort((L,Q)=>Q[1]-L[1]).map(L=>L[0])}function N(a,l){if(a==null)return null;const d=l.split(".");let g=a;for(const x of d){if(g[x]===null||g[x]===void 0)return null;g=g[x]}return g}function M(a,l,d){const g=l.split(/\.|\[/);let x=a;for(let L=0;L<g.length;L++){const Q=g[L],lt=L<g.length-1&&g[L+1].includes("]"),at=Q.includes("]")?Q.replace(/\[|\]/g,""):Q;if(L===g.length-1)return x[at]=d,d;Qe(x[at])||(lt?x[at]=[]:x[at]={}),x=x[at]}return d}function z(a,l,d=1){const g=N(a,l)||0;return M(a,l,g+d),g}function P(a,l,d){return N(a,l)||M(a,l,d)}function _(a,l){const d=Qp(l,"."),g=gb(l,".");if(!d||!g)return;const x=N(a,d);delete x[g]}function F(a,l,d){const g=N(a,l);if(!g)throw new Error("Key '"+l+"' does not exist.");return M(a,l,d),g}function ct(a,l,d){for(const g of l){const x=N(a,g);if(x)return x}if(d){const g=Object.values(a);if(g.length)return g[0]}return null}async function ft(a,l,d){for(;;){try{await a()}catch(g){d&&d("Error in forever",g)}await s(l)}}function mt(a,l){a();const d=setInterval(()=>{a()},l);return()=>clearInterval(d)}function Ht(a){return a/1024/1024}function Lt(a){return a>=1024*1024*1024*1024?(a/1024/1024/1024/1024).toFixed(3)+" TB":a>=1024*1024*1024?(a/1024/1024/1024).toFixed(3)+" GB":a>=1024*1024?(a/1024/1024).toFixed(3)+" MB":a>=1024?(a/1024).toFixed(3)+" KB":a+" B"}function Mt(a){const l=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a.toLowerCase());if(!l)throw new Error("Invalid hex color: "+a);return[parseInt(l[1],16),parseInt(l[2],16),parseInt(l[3],16)]}function Ae(a){return"#"+a.map(l=>l.toString(16).padStart(2,"0")).join("")}function Vt(a,l,d,g){const x=a*Math.PI/180,L=d*Math.PI/180,Q=(d-a)*Math.PI/180,lt=(g-l)*Math.PI/180,at=Math.sin(Q/2)*Math.sin(Q/2)+Math.cos(x)*Math.cos(L)*Math.sin(lt/2)*Math.sin(lt/2);return 6371e3*(2*Math.atan2(Math.sqrt(at),Math.sqrt(1-at)))}function Ut(a,l){return Math.round(a/l)*l}function Re(a){return a>1e3?(a/1e3).toFixed(0)+" km":a>=500?Ut(a,100)+" m":a>=100?Ut(a,50)+" m":Ut(a,10)+" m"}function Yt(a){return a*(a+1)/2}function ie(a){const l=a.match(/-?\d+(\.\d+)?/);if(!l)throw Error("No float found in "+a);return parseFloat(l[0])}function Qe(a,l=!0){return!a||l&&!Ee(a._readableState)||l&&a.constructor&&(a.constructor.isBuffer||a.constructor.name=="Uint8Array"||a.constructor.name==="ArrayBuffer"||a.constructor.name==="ReadableStream")?!1:typeof a=="object"}function ce(a){return Qe(a)&&!Array.isArray(a)}function Me(a){return Array.isArray(a)&&a.length===0}function Xs(a){return ce(a)&&Object.keys(a).length===0}function Ee(a){return a===void 0}function Ie(a){return Object.prototype.toString.call(a)==="[object Function]"||Object.prototype.toString.call(a)==="[object AsyncFunction]"}function _n(a){return Object.prototype.toString.call(a)==="[object String]"}function ue(a){return typeof a=="number"&&isFinite(a)}function ve(a){return a===!0||a===!1}function Je(a){return Object.prototype.toString.call(a)==="[object Date]"}function me(a){return!_n(a)||a.trim().length===0}function ke(a){return ue(a)&&Number.isInteger(a)&&a>=1}function Jn(a){return _n(a)&&a.match(/^-?\d+$/)!==null}function Le(a){return _n(a)&&a.match(/^(0x)?[0-9a-f]+$/i)!==null}const O="!@#$%^&*()_+-=[]{}|;:<>?,./",w="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),E="abcdefghijklmnopqrstuvwxyz",D="ABCDEFGHIJKLMNOPQRSTUVWXYZ",V="1234567890",q=E+D+V,st=q+O,Wt=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],jt="0123456789abcdef";function Kt(a,l=Math.random){let d="";for(let g=0;g<a;g++)d+=E[Math.floor(l()*E.length)];return d}function Ue(a,l=Math.random){let d="";for(let g=0;g<a;g++)d+=q[Math.floor(l()*q.length)];return d}function Ft(a,l=Math.random){let d="";for(let g=0;g<a;g++)d+=st[Math.floor(l()*st.length)];return d}function on(a,l=Math.random){let d="";for(let g=0;g<a;g++)d+=Wt[Math.floor(l()*Wt.length)];return d}function sd(a,l){const d=new RegExp(`[0-9a-f]{${l}}`,"i"),g=a.match(d);return g?g[0]:null}function an(a,l,d=w){const g=yb(a,d);for(const x of g)if(l(x))return x;return null}function cn(a,l=Math.random){let d="";for(let g=0;g<a;g++)d+=jt[Math.floor(l()*jt.length)];return d}function od(a,l){if(!Jn(a))throw new TypeError(`Expected integer string${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);const d=BigInt(a);if(l&&(l.min&&d<l.min||l.max&&d>l.max))throw RangeError(`Expected integer string${l!=null&&l.name?` for ${l.name}`:""} in range: ${l.min??"-inf"}..${l.max??"inf"}; got: `+d);return a}function Ye(a,l){if(me(a))throw new TypeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);if(l&&(l.min!==void 0&&a.length<l.min||l.max!==void 0&&a.length>l.max))throw RangeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""} length in range: ${l.min??"-inf"}..${l.max??"inf"}; got: ${a.length}`);return a}function un(a,l){if(!Le(a))throw new TypeError(`Expected hex string${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);const d=a.replace(/^0x/,"");if(l&&l.byteLength&&d.length!==l.byteLength*2)throw RangeError(`Expected hex string${l!=null&&l.name?` for ${l.name}`:""} of byte length ${l.byteLength}; got: `+d);return d}function ad(a,l){if(!Ye(a,l).split("").every(d=>d==="_"||Xl(d)))throw new TypeError(`Expected safe string${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function Xe(a,l){if(l.min!==void 0&&a<l.min||l.max!==void 0&&a>l.max)throw RangeError(`Expected value${l!=null&&l.name?` for ${l.name}`:""} in range: ${l.min??"-inf"}..${l.max??"inf"}; got: ${a}`)}function ln(a,l){if(!Ie(a))throw new TypeError(`Expected function${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function ia(a,l){if(ue(a))return l&&Xe(a,l),a;if(!_n(a)||!a.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);const d=parseFloat(a);return l&&Xe(d,l),d}function je(a,l){return ia(a,l)|0}function fn(a,l){if(a==="true")return!0;if(a==="false")return!1;if(!ve(a))throw new TypeError(`Expected boolean${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function cd(a,l){if(!Je(a))throw new TypeError(`Expected date${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function hn(a){return me(a)?null:a}function dn(a,l){if(!_n(a))throw new TypeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function ud(a,l){if(ke(a))return a;const d=parseInt(a,10);if(!ke(d))throw new TypeError(`Expected id${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return d}function pn(a,l){if(!_n(a))throw new TypeError(`Expected time${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);const d=a.split(":");if(d.length!==2)throw new TypeError(`Expected time${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);const g=parseInt(d[0],10),x=parseInt(d[1],10);if(!ue(g)||!ue(x)||g<0||g>23||x<0||x>59)throw new TypeError(`Expected time, got${l!=null&&l.name?` for ${l.name}`:""}: `+a);return`${String(g).padStart(2,"0")}:${String(x).padStart(2,"0")}`}function gn(a,l){if(!Array.isArray(a))throw new TypeError(`Expected array${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function sa(a,l){if(!ce(a))throw new TypeError(`Expected object${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function yn(a,l){return a===null?null:sa(a,l)}function mn(a,l){const d=sa(a,l);for(const g of Object.keys(d))if(!_n(d[g]))throw new TypeError(`Expected string map${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return d}function Fl(a,l){const d=sa(a),g=Object.keys(d),x=Object.values(d);if(!g.every(_n)||!x.every(ue))throw new TypeError(`Expected numeric dictionary${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return d}function Ic(a){return _n(a)&&a.match(/^https?:\/\/.+/)!==null}function $l(a,l){if(!Ic(a))throw new TypeError(`Expected url${l!=null&&l.name?` for ${l.name}`:""}, got: `+a);return a}function Hl(a,l){return l==null?!0:a(l)}function zl(a,l){return l==null?null:a(l)}function Gl(a,l){return l==null?void 0:a(l)}function kc(a,l){for(const[d,g]of Object.entries(l))if(!g(a[d]))throw TypeError(`${d} in value does not exist or match shape`);for(const d of Object.keys(a))if(!l[d])throw TypeError(`${d} exists in value but not in shape`);return!0}function Vl(a,l){return a.every(d=>kc(d,l))}function ls(a,l="json",d=0){if(Qe(a,!1)){if(d>1)return"[object Object]";if(l==="json"){if(Array.isArray(a)){const x=a.map(L=>ls(L,"json",d+1));return d===0?JSON.stringify(x):x}const g={};a.message&&(g.message=ls(a.message,"json",d+1));for(const[x,L]of Object.entries(a))g[x]=ls(L,"json",d+1);return d===0?JSON.stringify(g):g}else if(l==="key-value"){const g=Object.keys(a);return a.message&&!g.includes("message")&&g.unshift("message"),g.map(x=>`${x}=${JSON.stringify(ls(a[x],"json",d+1))}`).join(" ")}}return Ee(a)&&(a="undefined"),d===0?JSON.stringify(a):a}function Kl(a,l){if(_n(a))return a;const d=Object.keys(a);a.message&&!d.includes("message")&&d.push("message");const g=d.map(x=>`${x}: ${a[x]}`).join("; ");return l&&a.stack?g+`
|
|
2
|
-
`+
|
|
1
|
+
"use strict";var h3=Object.defineProperty;var z_=n=>{throw TypeError(n)};var d3=(n,t,e)=>t in n?h3(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Z=(n,t,e)=>d3(n,typeof t!="symbol"?t+"":t,e),Oy=(n,t,e)=>t.has(n)||z_("Cannot "+e);var S=(n,t,e)=>(Oy(n,t,"read from private field"),e?e.call(n):t.get(n)),J=(n,t,e)=>t.has(n)?z_("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),F=(n,t,e,r)=>(Oy(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e),yt=(n,t,e)=>(Oy(n,t,"access private method"),e);var ms=(n,t,e,r)=>({set _(i){F(n,t,i,e)},get _(){return S(n,t,r)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qt=require("@ethersphere/bee-js");var qn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ua(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function gp(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}function p3(){this.__data__=[],this.size=0}var g3=p3;function y3(n,t){return n===t||n!==n&&t!==t}var bx=y3,m3=bx;function w3(n,t){for(var e=n.length;e--;)if(m3(n[e][0],t))return e;return-1}var yp=w3,b3=yp,_3=Array.prototype,A3=_3.splice;function E3(n){var t=this.__data__,e=b3(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():A3.call(t,e,1),--this.size,!0}var v3=E3,x3=yp;function R3(n){var t=this.__data__,e=x3(t,n);return e<0?void 0:t[e][1]}var I3=R3,S3=yp;function k3(n){return S3(this.__data__,n)>-1}var T3=k3,O3=yp;function N3(n,t){var e=this.__data__,r=O3(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var C3=N3,B3=g3,P3=v3,M3=I3,L3=T3,U3=C3;function Pl(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Pl.prototype.clear=B3;Pl.prototype.delete=P3;Pl.prototype.get=M3;Pl.prototype.has=L3;Pl.prototype.set=U3;var mp=Pl,D3=mp;function F3(){this.__data__=new D3,this.size=0}var $3=F3;function H3(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var z3=H3;function G3(n){return this.__data__.get(n)}var V3=G3;function K3(n){return this.__data__.has(n)}var j3=K3,W3=typeof qn=="object"&&qn&&qn.Object===Object&&qn,_x=W3,Z3=_x,q3=typeof self=="object"&&self&&self.Object===Object&&self,Q3=Z3||q3||Function("return this")(),ro=Q3,J3=ro,Y3=J3.Symbol,n1=Y3,G_=n1,Ax=Object.prototype,X3=Ax.hasOwnProperty,tB=Ax.toString,If=G_?G_.toStringTag:void 0;function eB(n){var t=X3.call(n,If),e=n[If];try{n[If]=void 0;var r=!0}catch{}var i=tB.call(n);return r&&(t?n[If]=e:delete n[If]),i}var nB=eB,rB=Object.prototype,iB=rB.toString;function sB(n){return iB.call(n)}var oB=sB,V_=n1,aB=nB,cB=oB,uB="[object Null]",lB="[object Undefined]",K_=V_?V_.toStringTag:void 0;function fB(n){return n==null?n===void 0?lB:uB:K_&&K_ in Object(n)?aB(n):cB(n)}var wp=fB;function hB(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var Ex=hB,dB=wp,pB=Ex,gB="[object AsyncFunction]",yB="[object Function]",mB="[object GeneratorFunction]",wB="[object Proxy]";function bB(n){if(!pB(n))return!1;var t=dB(n);return t==yB||t==mB||t==gB||t==wB}var vx=bB,_B=ro,AB=_B["__core-js_shared__"],EB=AB,Ny=EB,j_=function(){var n=/[^.]+$/.exec(Ny&&Ny.keys&&Ny.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function vB(n){return!!j_&&j_ in n}var xB=vB,RB=Function.prototype,IB=RB.toString;function SB(n){if(n!=null){try{return IB.call(n)}catch{}try{return n+""}catch{}}return""}var xx=SB,kB=vx,TB=xB,OB=Ex,NB=xx,CB=/[\\^$.*+?()[\]{}|]/g,BB=/^\[object .+?Constructor\]$/,PB=Function.prototype,MB=Object.prototype,LB=PB.toString,UB=MB.hasOwnProperty,DB=RegExp("^"+LB.call(UB).replace(CB,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function FB(n){if(!OB(n)||TB(n))return!1;var t=kB(n)?DB:BB;return t.test(NB(n))}var $B=FB;function HB(n,t){return n==null?void 0:n[t]}var zB=HB,GB=$B,VB=zB;function KB(n,t){var e=VB(n,t);return GB(e)?e:void 0}var Ml=KB,jB=Ml,WB=ro,ZB=jB(WB,"Map"),r1=ZB,qB=Ml,QB=qB(Object,"create"),bp=QB,W_=bp;function JB(){this.__data__=W_?W_(null):{},this.size=0}var YB=JB;function XB(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var t8=XB,e8=bp,n8="__lodash_hash_undefined__",r8=Object.prototype,i8=r8.hasOwnProperty;function s8(n){var t=this.__data__;if(e8){var e=t[n];return e===n8?void 0:e}return i8.call(t,n)?t[n]:void 0}var o8=s8,a8=bp,c8=Object.prototype,u8=c8.hasOwnProperty;function l8(n){var t=this.__data__;return a8?t[n]!==void 0:u8.call(t,n)}var f8=l8,h8=bp,d8="__lodash_hash_undefined__";function p8(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=h8&&t===void 0?d8:t,this}var g8=p8,y8=YB,m8=t8,w8=o8,b8=f8,_8=g8;function Ll(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Ll.prototype.clear=y8;Ll.prototype.delete=m8;Ll.prototype.get=w8;Ll.prototype.has=b8;Ll.prototype.set=_8;var A8=Ll,Z_=A8,E8=mp,v8=r1;function x8(){this.size=0,this.__data__={hash:new Z_,map:new(v8||E8),string:new Z_}}var R8=x8;function I8(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var S8=I8,k8=S8;function T8(n,t){var e=n.__data__;return k8(t)?e[typeof t=="string"?"string":"hash"]:e.map}var _p=T8,O8=_p;function N8(n){var t=O8(this,n).delete(n);return this.size-=t?1:0,t}var C8=N8,B8=_p;function P8(n){return B8(this,n).get(n)}var M8=P8,L8=_p;function U8(n){return L8(this,n).has(n)}var D8=U8,F8=_p;function $8(n,t){var e=F8(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var H8=$8,z8=R8,G8=C8,V8=M8,K8=D8,j8=H8;function Ul(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Ul.prototype.clear=z8;Ul.prototype.delete=G8;Ul.prototype.get=V8;Ul.prototype.has=K8;Ul.prototype.set=j8;var Rx=Ul,W8=mp,Z8=r1,q8=Rx,Q8=200;function J8(n,t){var e=this.__data__;if(e instanceof W8){var r=e.__data__;if(!Z8||r.length<Q8-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new q8(r)}return e.set(n,t),this.size=e.size,this}var Y8=J8,X8=mp,t5=$3,e5=z3,n5=V3,r5=j3,i5=Y8;function Dl(n){var t=this.__data__=new X8(n);this.size=t.size}Dl.prototype.clear=t5;Dl.prototype.delete=e5;Dl.prototype.get=n5;Dl.prototype.has=r5;Dl.prototype.set=i5;var s5=Dl,o5="__lodash_hash_undefined__";function a5(n){return this.__data__.set(n,o5),this}var c5=a5;function u5(n){return this.__data__.has(n)}var l5=u5,f5=Rx,h5=c5,d5=l5;function v0(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new f5;++t<e;)this.add(n[t])}v0.prototype.add=v0.prototype.push=h5;v0.prototype.has=d5;var p5=v0;function g5(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var y5=g5;function m5(n,t){return n.has(t)}var w5=m5,b5=p5,_5=y5,A5=w5,E5=1,v5=2;function x5(n,t,e,r,i,s){var o=e&E5,a=n.length,u=t.length;if(a!=u&&!(o&&u>a))return!1;var f=s.get(n),h=s.get(t);if(f&&h)return f==t&&h==n;var y=-1,_=!0,w=e&v5?new b5:void 0;for(s.set(n,t),s.set(t,n);++y<a;){var R=n[y],T=t[y];if(r)var I=o?r(T,R,y,t,n,s):r(R,T,y,n,t,s);if(I!==void 0){if(I)continue;_=!1;break}if(w){if(!_5(t,function(B,H){if(!A5(w,H)&&(R===B||i(R,B,e,r,s)))return w.push(H)})){_=!1;break}}else if(!(R===T||i(R,T,e,r,s))){_=!1;break}}return s.delete(n),s.delete(t),_}var Ix=x5,R5=ro,I5=R5.Uint8Array,S5=I5;function k5(n){var t=-1,e=Array(n.size);return n.forEach(function(r,i){e[++t]=[i,r]}),e}var T5=k5;function O5(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var N5=O5,q_=n1,Q_=S5,C5=bx,B5=Ix,P5=T5,M5=N5,L5=1,U5=2,D5="[object Boolean]",F5="[object Date]",$5="[object Error]",H5="[object Map]",z5="[object Number]",G5="[object RegExp]",V5="[object Set]",K5="[object String]",j5="[object Symbol]",W5="[object ArrayBuffer]",Z5="[object DataView]",J_=q_?q_.prototype:void 0,Cy=J_?J_.valueOf:void 0;function q5(n,t,e,r,i,s,o){switch(e){case Z5:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case W5:return!(n.byteLength!=t.byteLength||!s(new Q_(n),new Q_(t)));case D5:case F5:case z5:return C5(+n,+t);case $5:return n.name==t.name&&n.message==t.message;case G5:case K5:return n==t+"";case H5:var a=P5;case V5:var u=r&L5;if(a||(a=M5),n.size!=t.size&&!u)return!1;var f=o.get(n);if(f)return f==t;r|=U5,o.set(n,t);var h=B5(a(n),a(t),r,i,s,o);return o.delete(n),h;case j5:if(Cy)return Cy.call(n)==Cy.call(t)}return!1}var Q5=q5;function J5(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var Y5=J5,X5=Array.isArray,i1=X5,tP=Y5,eP=i1;function nP(n,t,e){var r=t(n);return eP(n)?r:tP(r,e(n))}var rP=nP;function iP(n,t){for(var e=-1,r=n==null?0:n.length,i=0,s=[];++e<r;){var o=n[e];t(o,e,n)&&(s[i++]=o)}return s}var sP=iP;function oP(){return[]}var aP=oP,cP=sP,uP=aP,lP=Object.prototype,fP=lP.propertyIsEnumerable,Y_=Object.getOwnPropertySymbols,hP=Y_?function(n){return n==null?[]:(n=Object(n),cP(Y_(n),function(t){return fP.call(n,t)}))}:uP,dP=hP;function pP(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var gP=pP;function yP(n){return n!=null&&typeof n=="object"}var Ap=yP,mP=wp,wP=Ap,bP="[object Arguments]";function _P(n){return wP(n)&&mP(n)==bP}var AP=_P,X_=AP,EP=Ap,Sx=Object.prototype,vP=Sx.hasOwnProperty,xP=Sx.propertyIsEnumerable,RP=X_(function(){return arguments}())?X_:function(n){return EP(n)&&vP.call(n,"callee")&&!xP.call(n,"callee")},IP=RP,x0={exports:{}};function SP(){return!1}var kP=SP;x0.exports;(function(n,t){var e=ro,r=kP,i=t&&!t.nodeType&&t,s=i&&!0&&n&&!n.nodeType&&n,o=s&&s.exports===i,a=o?e.Buffer:void 0,u=a?a.isBuffer:void 0,f=u||r;n.exports=f})(x0,x0.exports);var kx=x0.exports,TP=9007199254740991,OP=/^(?:0|[1-9]\d*)$/;function NP(n,t){var e=typeof n;return t=t??TP,!!t&&(e=="number"||e!="symbol"&&OP.test(n))&&n>-1&&n%1==0&&n<t}var CP=NP,BP=9007199254740991;function PP(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=BP}var Tx=PP,MP=wp,LP=Tx,UP=Ap,DP="[object Arguments]",FP="[object Array]",$P="[object Boolean]",HP="[object Date]",zP="[object Error]",GP="[object Function]",VP="[object Map]",KP="[object Number]",jP="[object Object]",WP="[object RegExp]",ZP="[object Set]",qP="[object String]",QP="[object WeakMap]",JP="[object ArrayBuffer]",YP="[object DataView]",XP="[object Float32Array]",t4="[object Float64Array]",e4="[object Int8Array]",n4="[object Int16Array]",r4="[object Int32Array]",i4="[object Uint8Array]",s4="[object Uint8ClampedArray]",o4="[object Uint16Array]",a4="[object Uint32Array]",Ge={};Ge[XP]=Ge[t4]=Ge[e4]=Ge[n4]=Ge[r4]=Ge[i4]=Ge[s4]=Ge[o4]=Ge[a4]=!0;Ge[DP]=Ge[FP]=Ge[JP]=Ge[$P]=Ge[YP]=Ge[HP]=Ge[zP]=Ge[GP]=Ge[VP]=Ge[KP]=Ge[jP]=Ge[WP]=Ge[ZP]=Ge[qP]=Ge[QP]=!1;function c4(n){return UP(n)&&LP(n.length)&&!!Ge[MP(n)]}var u4=c4;function l4(n){return function(t){return n(t)}}var f4=l4,R0={exports:{}};R0.exports;(function(n,t){var e=_x,r=t&&!t.nodeType&&t,i=r&&!0&&n&&!n.nodeType&&n,s=i&&i.exports===r,o=s&&e.process,a=function(){try{var u=i&&i.require&&i.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}}();n.exports=a})(R0,R0.exports);var h4=R0.exports,d4=u4,p4=f4,tA=h4,eA=tA&&tA.isTypedArray,g4=eA?p4(eA):d4,Ox=g4,y4=gP,m4=IP,w4=i1,b4=kx,_4=CP,A4=Ox,E4=Object.prototype,v4=E4.hasOwnProperty;function x4(n,t){var e=w4(n),r=!e&&m4(n),i=!e&&!r&&b4(n),s=!e&&!r&&!i&&A4(n),o=e||r||i||s,a=o?y4(n.length,String):[],u=a.length;for(var f in n)(t||v4.call(n,f))&&!(o&&(f=="length"||i&&(f=="offset"||f=="parent")||s&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||_4(f,u)))&&a.push(f);return a}var R4=x4,I4=Object.prototype;function S4(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||I4;return n===e}var k4=S4;function T4(n,t){return function(e){return n(t(e))}}var O4=T4,N4=O4,C4=N4(Object.keys,Object),B4=C4,P4=k4,M4=B4,L4=Object.prototype,U4=L4.hasOwnProperty;function D4(n){if(!P4(n))return M4(n);var t=[];for(var e in Object(n))U4.call(n,e)&&e!="constructor"&&t.push(e);return t}var F4=D4,$4=vx,H4=Tx;function z4(n){return n!=null&&H4(n.length)&&!$4(n)}var G4=z4,V4=R4,K4=F4,j4=G4;function W4(n){return j4(n)?V4(n):K4(n)}var Z4=W4,q4=rP,Q4=dP,J4=Z4;function Y4(n){return q4(n,J4,Q4)}var X4=Y4,nA=X4,tM=1,eM=Object.prototype,nM=eM.hasOwnProperty;function rM(n,t,e,r,i,s){var o=e&tM,a=nA(n),u=a.length,f=nA(t),h=f.length;if(u!=h&&!o)return!1;for(var y=u;y--;){var _=a[y];if(!(o?_ in t:nM.call(t,_)))return!1}var w=s.get(n),R=s.get(t);if(w&&R)return w==t&&R==n;var T=!0;s.set(n,t),s.set(t,n);for(var I=o;++y<u;){_=a[y];var B=n[_],H=t[_];if(r)var U=o?r(H,B,_,t,n,s):r(B,H,_,n,t,s);if(!(U===void 0?B===H||i(B,H,e,r,s):U)){T=!1;break}I||(I=_=="constructor")}if(T&&!I){var G=n.constructor,W=t.constructor;G!=W&&"constructor"in n&&"constructor"in t&&!(typeof G=="function"&&G instanceof G&&typeof W=="function"&&W instanceof W)&&(T=!1)}return s.delete(n),s.delete(t),T}var iM=rM,sM=Ml,oM=ro,aM=sM(oM,"DataView"),cM=aM,uM=Ml,lM=ro,fM=uM(lM,"Promise"),hM=fM,dM=Ml,pM=ro,gM=dM(pM,"Set"),yM=gM,mM=Ml,wM=ro,bM=mM(wM,"WeakMap"),_M=bM,Dm=cM,Fm=r1,$m=hM,Hm=yM,zm=_M,Nx=wp,Fl=xx,rA="[object Map]",AM="[object Object]",iA="[object Promise]",sA="[object Set]",oA="[object WeakMap]",aA="[object DataView]",EM=Fl(Dm),vM=Fl(Fm),xM=Fl($m),RM=Fl(Hm),IM=Fl(zm),wa=Nx;(Dm&&wa(new Dm(new ArrayBuffer(1)))!=aA||Fm&&wa(new Fm)!=rA||$m&&wa($m.resolve())!=iA||Hm&&wa(new Hm)!=sA||zm&&wa(new zm)!=oA)&&(wa=function(n){var t=Nx(n),e=t==AM?n.constructor:void 0,r=e?Fl(e):"";if(r)switch(r){case EM:return aA;case vM:return rA;case xM:return iA;case RM:return sA;case IM:return oA}return t});var SM=wa,By=s5,kM=Ix,TM=Q5,OM=iM,cA=SM,uA=i1,lA=kx,NM=Ox,CM=1,fA="[object Arguments]",hA="[object Array]",Ld="[object Object]",BM=Object.prototype,dA=BM.hasOwnProperty;function PM(n,t,e,r,i,s){var o=uA(n),a=uA(t),u=o?hA:cA(n),f=a?hA:cA(t);u=u==fA?Ld:u,f=f==fA?Ld:f;var h=u==Ld,y=f==Ld,_=u==f;if(_&&lA(n)){if(!lA(t))return!1;o=!0,h=!1}if(_&&!h)return s||(s=new By),o||NM(n)?kM(n,t,e,r,i,s):TM(n,t,u,e,r,i,s);if(!(e&CM)){var w=h&&dA.call(n,"__wrapped__"),R=y&&dA.call(t,"__wrapped__");if(w||R){var T=w?n.value():n,I=R?t.value():t;return s||(s=new By),i(T,I,e,r,s)}}return _?(s||(s=new By),OM(n,t,e,r,i,s)):!1}var MM=PM,LM=MM,pA=Ap;function Cx(n,t,e,r,i){return n===t?!0:n==null||t==null||!pA(n)&&!pA(t)?n!==n&&t!==t:LM(n,t,e,r,Cx,i)}var UM=Cx,DM=UM;function FM(n,t){return DM(n,t)}var $M=FM;const HM=ua($M);var Bx={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function i(u,f,h){this.fn=u,this.context=f,this.once=h||!1}function s(u,f,h,y,_){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,y||u,_),R=e?e+f:f;return u._events[R]?u._events[R].fn?u._events[R]=[u._events[R],w]:u._events[R].push(w):(u._events[R]=w,u._eventsCount++),u}function o(u,f){--u._eventsCount===0?u._events=new r:delete u._events[f]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var f=[],h,y;if(this._eventsCount===0)return f;for(y in h=this._events)t.call(h,y)&&f.push(e?y.slice(1):y);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},a.prototype.listeners=function(f){var h=e?e+f:f,y=this._events[h];if(!y)return[];if(y.fn)return[y.fn];for(var _=0,w=y.length,R=new Array(w);_<w;_++)R[_]=y[_].fn;return R},a.prototype.listenerCount=function(f){var h=e?e+f:f,y=this._events[h];return y?y.fn?1:y.length:0},a.prototype.emit=function(f,h,y,_,w,R){var T=e?e+f:f;if(!this._events[T])return!1;var I=this._events[T],B=arguments.length,H,U;if(I.fn){switch(I.once&&this.removeListener(f,I.fn,void 0,!0),B){case 1:return I.fn.call(I.context),!0;case 2:return I.fn.call(I.context,h),!0;case 3:return I.fn.call(I.context,h,y),!0;case 4:return I.fn.call(I.context,h,y,_),!0;case 5:return I.fn.call(I.context,h,y,_,w),!0;case 6:return I.fn.call(I.context,h,y,_,w,R),!0}for(U=1,H=new Array(B-1);U<B;U++)H[U-1]=arguments[U];I.fn.apply(I.context,H)}else{var G=I.length,W;for(U=0;U<G;U++)switch(I[U].once&&this.removeListener(f,I[U].fn,void 0,!0),B){case 1:I[U].fn.call(I[U].context);break;case 2:I[U].fn.call(I[U].context,h);break;case 3:I[U].fn.call(I[U].context,h,y);break;case 4:I[U].fn.call(I[U].context,h,y,_);break;default:if(!H)for(W=1,H=new Array(B-1);W<B;W++)H[W-1]=arguments[W];I[U].fn.apply(I[U].context,H)}}return!0},a.prototype.on=function(f,h,y){return s(this,f,h,y,!1)},a.prototype.once=function(f,h,y){return s(this,f,h,y,!0)},a.prototype.removeListener=function(f,h,y,_){var w=e?e+f:f;if(!this._events[w])return this;if(!h)return o(this,w),this;var R=this._events[w];if(R.fn)R.fn===h&&(!_||R.once)&&(!y||R.context===y)&&o(this,w);else{for(var T=0,I=[],B=R.length;T<B;T++)(R[T].fn!==h||_&&!R[T].once||y&&R[T].context!==y)&&I.push(R[T]);I.length?this._events[w]=I.length===1?I[0]:I:o(this,w)}return this},a.prototype.removeAllListeners=function(f){var h;return f?(h=e?e+f:f,this._events[h]&&o(this,h)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,n.exports=a})(Bx);var zM=Bx.exports;const s1=ua(zM);class Px extends Error{constructor(t){super(t),this.name="TimeoutError"}}class GM extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const gA=n=>globalThis.DOMException===void 0?new GM(n):new DOMException(n),yA=n=>{const t=n.reason===void 0?gA("This operation was aborted."):n.reason;return t instanceof Error?t:gA(t)};function VM(n,t){const{milliseconds:e,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=t;let o,a;const f=new Promise((h,y)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(t.signal){const{signal:w}=t;w.aborted&&y(yA(w)),a=()=>{y(yA(w))},w.addEventListener("abort",a,{once:!0})}if(e===Number.POSITIVE_INFINITY){n.then(h,y);return}const _=new Px;o=s.setTimeout.call(void 0,()=>{if(r){try{h(r())}catch(w){y(w)}return}typeof n.cancel=="function"&&n.cancel(),i===!1?h():i instanceof Error?y(i):(_.message=i??`Promise timed out after ${e} milliseconds`,y(_))},e),(async()=>{try{h(await n)}catch(w){y(w)}})()}).finally(()=>{f.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return f.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},f}function KM(n,t,e){let r=0,i=n.length;for(;i>0;){const s=Math.trunc(i/2);let o=r+s;e(n[o],t)<=0?(r=++o,i-=s+1):i=s}return r}var Xr;class jM{constructor(){J(this,Xr,[])}enqueue(t,e){e={priority:0,...e};const r={priority:e.priority,id:e.id,run:t};if(this.size===0||S(this,Xr)[this.size-1].priority>=e.priority){S(this,Xr).push(r);return}const i=KM(S(this,Xr),r,(s,o)=>o.priority-s.priority);S(this,Xr).splice(i,0,r)}setPriority(t,e){const r=S(this,Xr).findIndex(s=>s.id===t);if(r===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);const[i]=S(this,Xr).splice(r,1);this.enqueue(i.run,{priority:e,id:t})}dequeue(){const t=S(this,Xr).shift();return t==null?void 0:t.run}filter(t){return S(this,Xr).filter(e=>e.priority===t.priority).map(e=>e.run)}get size(){return S(this,Xr).length}}Xr=new WeakMap;var Au,Eu,xo,Lh,vu,Uh,ti,xu,lr,Dh,ei,Ru,Os,Fh,ap,Ae,Mx,Lx,Ux,Dx,Fx,s0,Gm,Vm,o0,$x,a0;class mA extends s1{constructor(e){var r,i;super();J(this,Ae);J(this,Au);J(this,Eu);J(this,xo,0);J(this,Lh);J(this,vu);J(this,Uh,0);J(this,ti);J(this,xu);J(this,lr);J(this,Dh);J(this,ei,0);J(this,Ru);J(this,Os);J(this,Fh);J(this,ap,1n);Z(this,"timeout");if(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:jM,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${((r=e.intervalCap)==null?void 0:r.toString())??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${((i=e.interval)==null?void 0:i.toString())??""}\` (${typeof e.interval})`);F(this,Au,e.carryoverConcurrencyCount),F(this,Eu,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0),F(this,Lh,e.intervalCap),F(this,vu,e.interval),F(this,lr,new e.queueClass),F(this,Dh,e.queueClass),this.concurrency=e.concurrency,this.timeout=e.timeout,F(this,Fh,e.throwOnTimeout===!0),F(this,Os,e.autoStart===!1)}get concurrency(){return S(this,Ru)}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);F(this,Ru,e),yt(this,Ae,o0).call(this)}setPriority(e,r){S(this,lr).setPriority(e,r)}async add(e,r={}){return r.id??(r.id=(ms(this,ap)._++).toString()),r={timeout:this.timeout,throwOnTimeout:S(this,Fh),...r},new Promise((i,s)=>{S(this,lr).enqueue(async()=>{var o;ms(this,ei)._++,ms(this,xo)._++;try{(o=r.signal)==null||o.throwIfAborted();let a=e({signal:r.signal});r.timeout&&(a=VM(Promise.resolve(a),{milliseconds:r.timeout})),r.signal&&(a=Promise.race([a,yt(this,Ae,$x).call(this,r.signal)]));const u=await a;i(u),this.emit("completed",u)}catch(a){if(a instanceof Px&&!r.throwOnTimeout){i();return}s(a),this.emit("error",a)}finally{yt(this,Ae,Ux).call(this)}},r),this.emit("add"),yt(this,Ae,s0).call(this)})}async addAll(e,r){return Promise.all(e.map(async i=>this.add(i,r)))}start(){return S(this,Os)?(F(this,Os,!1),yt(this,Ae,o0).call(this),this):this}pause(){F(this,Os,!0)}clear(){F(this,lr,new(S(this,Dh)))}async onEmpty(){S(this,lr).size!==0&&await yt(this,Ae,a0).call(this,"empty")}async onSizeLessThan(e){S(this,lr).size<e||await yt(this,Ae,a0).call(this,"next",()=>S(this,lr).size<e)}async onIdle(){S(this,ei)===0&&S(this,lr).size===0||await yt(this,Ae,a0).call(this,"idle")}get size(){return S(this,lr).size}sizeBy(e){return S(this,lr).filter(e).length}get pending(){return S(this,ei)}get isPaused(){return S(this,Os)}}Au=new WeakMap,Eu=new WeakMap,xo=new WeakMap,Lh=new WeakMap,vu=new WeakMap,Uh=new WeakMap,ti=new WeakMap,xu=new WeakMap,lr=new WeakMap,Dh=new WeakMap,ei=new WeakMap,Ru=new WeakMap,Os=new WeakMap,Fh=new WeakMap,ap=new WeakMap,Ae=new WeakSet,Mx=function(){return S(this,Eu)||S(this,xo)<S(this,Lh)},Lx=function(){return S(this,ei)<S(this,Ru)},Ux=function(){ms(this,ei)._--,yt(this,Ae,s0).call(this),this.emit("next")},Dx=function(){yt(this,Ae,Vm).call(this),yt(this,Ae,Gm).call(this),F(this,xu,void 0)},Fx=function(){const e=Date.now();if(S(this,ti)===void 0){const r=S(this,Uh)-e;if(r<0)F(this,xo,S(this,Au)?S(this,ei):0);else return S(this,xu)===void 0&&F(this,xu,setTimeout(()=>{yt(this,Ae,Dx).call(this)},r)),!0}return!1},s0=function(){if(S(this,lr).size===0)return S(this,ti)&&clearInterval(S(this,ti)),F(this,ti,void 0),this.emit("empty"),S(this,ei)===0&&this.emit("idle"),!1;if(!S(this,Os)){const e=!S(this,Ae,Fx);if(S(this,Ae,Mx)&&S(this,Ae,Lx)){const r=S(this,lr).dequeue();return r?(this.emit("active"),r(),e&&yt(this,Ae,Gm).call(this),!0):!1}}return!1},Gm=function(){S(this,Eu)||S(this,ti)!==void 0||(F(this,ti,setInterval(()=>{yt(this,Ae,Vm).call(this)},S(this,vu))),F(this,Uh,Date.now()+S(this,vu)))},Vm=function(){S(this,xo)===0&&S(this,ei)===0&&S(this,ti)&&(clearInterval(S(this,ti)),F(this,ti,void 0)),F(this,xo,S(this,Au)?S(this,ei):0),yt(this,Ae,o0).call(this)},o0=function(){for(;yt(this,Ae,s0).call(this););},$x=async function(e){return new Promise((r,i)=>{e.addEventListener("abort",()=>{i(e.reason)},{once:!0})})},a0=async function(e,r){return new Promise(i=>{const s=()=>{r&&!r()||(this.off(e,s),i())};this.on(e,s)})};const Hn=[];for(let n=0;n<256;++n)Hn.push((n+256).toString(16).slice(1));function WM(n,t=0){return(Hn[n[t+0]]+Hn[n[t+1]]+Hn[n[t+2]]+Hn[n[t+3]]+"-"+Hn[n[t+4]]+Hn[n[t+5]]+"-"+Hn[n[t+6]]+Hn[n[t+7]]+"-"+Hn[n[t+8]]+Hn[n[t+9]]+"-"+Hn[n[t+10]]+Hn[n[t+11]]+Hn[n[t+12]]+Hn[n[t+13]]+Hn[n[t+14]]+Hn[n[t+15]]).toLowerCase()}let Py;const ZM=new Uint8Array(16);function qM(){if(!Py){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Py=crypto.getRandomValues.bind(crypto)}return Py(ZM)}const QM=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),wA={randomUUID:QM};function JM(n,t,e){if(wA.randomUUID&&!t&&!n)return wA.randomUUID();n=n||{};const r=n.random||(n.rng||qM)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,WM(r)}function bA(n){return new Promise(t=>{setTimeout(t,n)})}function Jf(n){return(n.startsWith("0x")?n.slice(2):n).toLowerCase()}class es{constructor(){}static getInstance(){return es.instance||(es.instance=new es),es.instance}formatMessage(t,...e){return`[${new Date().toISOString()}] [${t.toUpperCase()}] - ${e.map(i=>typeof i=="object"?JSON.stringify(i):i).join(" ")}`}log(...t){console.log(this.formatMessage("log",...t))}info(...t){console.info(this.formatMessage("info",...t))}warn(...t){console.warn(this.formatMessage("warn",...t))}error(...t){console.error(this.formatMessage("error",...t))}debug(...t){console.debug(this.formatMessage("debug",...t))}}class o1{constructor(){this.logger=es.getInstance()}handleError(t,e){const r=t instanceof Error?t.message:"Unknown error occurred",i=t instanceof Error?t.stack:null;this.logger.error(`Error in ${e||"unknown context"}: ${r}`,{stack:i})}}let YM=class{constructor(){this.events={},this.on=this.on.bind(this),this.off=this.off.bind(this),this.cleanAll=this.cleanAll.bind(this),this.emit=this.emit.bind(this)}on(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)}off(t,e){if(!this.events[t])return;const r=this.events[t].indexOf(e);r>-1&&this.events[t].splice(r,1)}cleanAll(){this.events={}}emit(t,e){this.events[t]&&this.events[t].forEach(r=>r(e))}};var Hx={};(function(n){var t;Object.defineProperty(n,"__esModule",{value:!0}),n.Vector=n.Cache=n.Assertions=n.Strings=n.Types=n.Objects=n.Dates=n.Promises=n.Numbers=n.System=n.Arrays=n.Random=n.Elliptic=n.Binary=n.AsyncQueue=n.PubSubChannel=n.FixedPointNumber=n.MerkleTree=n.Chunk=n.Uint8ArrayWriter=n.Uint8ArrayReader=n.AsyncLazy=n.Lazy=n.Optional=void 0;async function e(c){return new Promise((l,d)=>c.then(d,l))}async function r(c){return e(Promise.all(c.map(e)))}async function i(c,l=1){const d=d_(c,l),g=[],x=d.map(async L=>{for(const Q of L)g.push(await Q())});return await Promise.all(x),g}async function s(c){return new Promise(l=>setTimeout(()=>{l(!0)},c))}function o(c,l=Math.random){for(let d=c.length-1;d>0;d--){const g=Math.floor(l()*(d+1)),x=c[d];c[d]=c[g],c[g]=x}return c}function a(c){if(c.length===1)return c[0];throw Error(`Expected exactly one element, actual: ${c.length}`)}function u(c){return c.length===1?c[0]:null}function f(c){return c.length>0?c[0]:null}function h(c){if(!c.length)throw Error("Received empty array");return c[0]}function y(c,l){const d=[];for(let g=0;g<c;g++)d.push(l(g));return d}function _(c){const l=[];for(let d=0;d<c[0].length;d++){l.push([]);for(let g=0;g<c.length;g++)l[d].push(c[g][d])}return l}function w(c,l,d){const g=[];for(let x=0;x<c;x++){g.push([]);for(let L=0;L<l;L++)g[x].push(d)}return g}function R(c,l,d,g){if(d<0||g<0||g+l[0].length>c[0].length||d+l.length>c.length)return!1;for(let x=0;x<l.length;x++)for(let L=0;L<l[x].length;L++)if(l[x][L]!==void 0&&c[d+x][g+L]!==l[x][L])return!1;return!0}function T(c,l,d=Math.random){return o(Mb(0,c.length-1),d).slice(0,l)}function I(c,l){return c.map(d=>d[l])}function B(c){let l=c,d=3405648695,g=3735928559;return function(){return l+=d,d^=l<<7,l*=g,g^=l<<13,l^=d^g,(l>>>0)/4294967296}}function H(c,l,d=Math.random){return Math.floor(d()*(l-c+1))+c}function U(c,l,d=Math.random){return d()*(l-c)+c}function G(){return Math.random()*2-1}function W(c,l,d){return l>=c.x&&l<c.x+c.width&&d>=c.y&&d<c.y+c.height}function X(c,l,d,g=Math.random){let x,L;do x=H(0,c-1,g),L=H(0,l-1,g);while(d&&W(d,x,L));return[x,L]}function j(c,l=Math.random){const d=Math.floor(c),g=c-d;return Y(g,l)?d+1:d}function Y(c,l=Math.random){return l()<c}function it(c,l=Math.random){return c[Math.floor(c.length*l())]}function ut(c,l,d=Math.random){if(l>c.length)throw new Error(`Count (${l}) is greater than array length (${c.length})`);return T(c,l,d).map(g=>c[g])}function rt(c,l,d,g=Math.random){if(l>c.length)throw new Error(`Count (${l}) is greater than array length (${c.length})`);const x=[];for(;x.length<l;){const L=it(c,g);x.some(Q=>d(Q,L))||x.push(L)}return x}function ot(c,l,d,g,x,L=Math.random){const Q=c.filter(at=>at!==l&&at!==d),lt=[];for(l!==null&<.push(l);Q.length&<.length<g;){const at=n.Random.intBetween(0,Q.length-1,L);x(Q[at],lt)&<.push(Q[at]),Q.splice(at,1)}return o(lt,L),{values:lt,indexOfGuaranteed:l!==null?lt.indexOf(l):-1}}function C(c){if(!c.length)throw Error("Received empty array");return c[c.length-1]}function p(c,l,d){return d(l.reduce((g,x)=>x(g),c))}function m(c,l){return d=>p(d,c,l)}function v(c,l,d){if(d===void 0&&(d=Math.random()),c.length!==l.length)throw new Error("Array length mismatch");let g=l.reduce((L,Q)=>L+Q,0);const x=d*g;for(let L=0;L<c.length-1;L++)if(g-=l[L],x>=g)return c[L];return C(c)}function k(c,l,d=Math.random){const g=l.map(L=>d()*L),x=[];for(let L=0;L<c.length;L++)x.push([c[L],g[L]]);return x.sort((L,Q)=>Q[1]-L[1]).map(L=>L[0])}function N(c,l){if(c==null)return null;const d=l.split(".");let g=c;for(const x of d){if(g[x]===null||g[x]===void 0)return null;g=g[x]}return g}function M(c,l,d){const g=l.split(/\.|\[/);let x=c;for(let L=0;L<g.length;L++){const Q=g[L],lt=L<g.length-1&&g[L+1].includes("]"),at=Q.includes("]")?Q.replace(/\[|\]/g,""):Q;if(L===g.length-1)return x[at]=d,d;Je(x[at])||(lt?x[at]=[]:x[at]={}),x=x[at]}return d}function z(c,l,d=1){const g=N(c,l)||0;return M(c,l,g+d),g}function P(c,l,d){return N(c,l)||M(c,l,d)}function A(c,l){const d=gg(l,"."),g=Ub(l,".");if(!d||!g)return;const x=N(c,d);delete x[g]}function $(c,l,d){const g=N(c,l);if(!g)throw new Error("Key '"+l+"' does not exist.");return M(c,l,d),g}function ct(c,l,d){for(const g of l){const x=N(c,g);if(x)return x}if(d){const g=Object.values(c);if(g.length)return g[0]}return null}async function ft(c,l,d){for(;;){try{await c()}catch(g){d&&d("Error in forever",g)}await s(l)}}function wt(c,l){c();const d=setInterval(()=>{c()},l);return()=>clearInterval(d)}function Ht(c){return c/1024/1024}function Lt(c){return c>=1024*1024*1024*1024?(c/1024/1024/1024/1024).toFixed(3)+" TB":c>=1024*1024*1024?(c/1024/1024/1024).toFixed(3)+" GB":c>=1024*1024?(c/1024/1024).toFixed(3)+" MB":c>=1024?(c/1024).toFixed(3)+" KB":c+" B"}function Mt(c){const l=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c.toLowerCase());if(!l)throw new Error("Invalid hex color: "+c);return[parseInt(l[1],16),parseInt(l[2],16),parseInt(l[3],16)]}function Ee(c){return"#"+c.map(l=>l.toString(16).padStart(2,"0")).join("")}function Vt(c,l,d,g){const x=c*Math.PI/180,L=d*Math.PI/180,Q=(d-c)*Math.PI/180,lt=(g-l)*Math.PI/180,at=Math.sin(Q/2)*Math.sin(Q/2)+Math.cos(x)*Math.cos(L)*Math.sin(lt/2)*Math.sin(lt/2);return 6371e3*(2*Math.atan2(Math.sqrt(at),Math.sqrt(1-at)))}function Ut(c,l){return Math.round(c/l)*l}function Ie(c){return c>1e3?(c/1e3).toFixed(0)+" km":c>=500?Ut(c,100)+" m":c>=100?Ut(c,50)+" m":Ut(c,10)+" m"}function Yt(c){return c*(c+1)/2}function ie(c){const l=c.match(/-?\d+(\.\d+)?/);if(!l)throw Error("No float found in "+c);return parseFloat(l[0])}function Je(c,l=!0){return!c||l&&!ve(c._readableState)||l&&c.constructor&&(c.constructor.isBuffer||c.constructor.name=="Uint8Array"||c.constructor.name==="ArrayBuffer"||c.constructor.name==="ReadableStream")?!1:typeof c=="object"}function ce(c){return Je(c)&&!Array.isArray(c)}function Le(c){return Array.isArray(c)&&c.length===0}function oo(c){return ce(c)&&Object.keys(c).length===0}function ve(c){return c===void 0}function ke(c){return Object.prototype.toString.call(c)==="[object Function]"||Object.prototype.toString.call(c)==="[object AsyncFunction]"}function An(c){return Object.prototype.toString.call(c)==="[object String]"}function ue(c){return typeof c=="number"&&isFinite(c)}function xe(c){return c===!0||c===!1}function Ye(c){return Object.prototype.toString.call(c)==="[object Date]"}function me(c){return!An(c)||c.trim().length===0}function Te(c){return ue(c)&&Number.isInteger(c)&&c>=1}function Yn(c){return An(c)&&c.match(/^-?\d+$/)!==null}function Ue(c){return An(c)&&c.match(/^(0x)?[0-9a-f]+$/i)!==null}const O="!@#$%^&*()_+-=[]{}|;:<>?,./",b="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),E="abcdefghijklmnopqrstuvwxyz",D="ABCDEFGHIJKLMNOPQRSTUVWXYZ",V="1234567890",q=E+D+V,st=q+O,Wt=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],jt="0123456789abcdef";function Kt(c,l=Math.random){let d="";for(let g=0;g<c;g++)d+=E[Math.floor(l()*E.length)];return d}function De(c,l=Math.random){let d="";for(let g=0;g<c;g++)d+=q[Math.floor(l()*q.length)];return d}function Ft(c,l=Math.random){let d="";for(let g=0;g<c;g++)d+=st[Math.floor(l()*st.length)];return d}function an(c,l=Math.random){let d="";for(let g=0;g<c;g++)d+=Wt[Math.floor(l()*Wt.length)];return d}function Ad(c,l){const d=new RegExp(`[0-9a-f]{${l}}`,"i"),g=c.match(d);return g?g[0]:null}function cn(c,l,d=b){const g=Db(c,d);for(const x of g)if(l(x))return x;return null}function un(c,l=Math.random){let d="";for(let g=0;g<c;g++)d+=jt[Math.floor(l()*jt.length)];return d}function Ed(c,l){if(!Yn(c))throw new TypeError(`Expected integer string${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);const d=BigInt(c);if(l&&(l.min&&d<l.min||l.max&&d>l.max))throw RangeError(`Expected integer string${l!=null&&l.name?` for ${l.name}`:""} in range: ${l.min??"-inf"}..${l.max??"inf"}; got: `+d);return c}function Xe(c,l){if(me(c))throw new TypeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);if(l&&(l.min!==void 0&&c.length<l.min||l.max!==void 0&&c.length>l.max))throw RangeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""} length in range: ${l.min??"-inf"}..${l.max??"inf"}; got: ${c.length}`);return c}function ln(c,l){if(!Ue(c))throw new TypeError(`Expected hex string${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);const d=c.replace(/^0x/,"");if(l&&l.byteLength&&d.length!==l.byteLength*2)throw RangeError(`Expected hex string${l!=null&&l.name?` for ${l.name}`:""} of byte length ${l.byteLength}; got: `+d);return d}function vd(c,l){if(!Xe(c,l).split("").every(d=>d==="_"||df(d)))throw new TypeError(`Expected safe string${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function tn(c,l){if(l.min!==void 0&&c<l.min||l.max!==void 0&&c>l.max)throw RangeError(`Expected value${l!=null&&l.name?` for ${l.name}`:""} in range: ${l.min??"-inf"}..${l.max??"inf"}; got: ${c}`)}function fn(c,l){if(!ke(c))throw new TypeError(`Expected function${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function ha(c,l){if(ue(c))return l&&tn(c,l),c;if(!An(c)||!c.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);const d=parseFloat(c);return l&&tn(d,l),d}function We(c,l){return ha(c,l)|0}function hn(c,l){if(c==="true")return!0;if(c==="false")return!1;if(!xe(c))throw new TypeError(`Expected boolean${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function xd(c,l){if(!Ye(c))throw new TypeError(`Expected date${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function dn(c){return me(c)?null:c}function pn(c,l){if(!An(c))throw new TypeError(`Expected string${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function Rd(c,l){if(Te(c))return c;const d=parseInt(c,10);if(!Te(d))throw new TypeError(`Expected id${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return d}function gn(c,l){if(!An(c))throw new TypeError(`Expected time${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);const d=c.split(":");if(d.length!==2)throw new TypeError(`Expected time${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);const g=parseInt(d[0],10),x=parseInt(d[1],10);if(!ue(g)||!ue(x)||g<0||g>23||x<0||x>59)throw new TypeError(`Expected time, got${l!=null&&l.name?` for ${l.name}`:""}: `+c);return`${String(g).padStart(2,"0")}:${String(x).padStart(2,"0")}`}function yn(c,l){if(!Array.isArray(c))throw new TypeError(`Expected array${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function da(c,l){if(!ce(c))throw new TypeError(`Expected object${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function mn(c,l){return c===null?null:da(c,l)}function wn(c,l){const d=da(c,l);for(const g of Object.keys(d))if(!An(d[g]))throw new TypeError(`Expected string map${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return d}function Yl(c,l){const d=da(c),g=Object.keys(d),x=Object.values(d);if(!g.every(An)||!x.every(ue))throw new TypeError(`Expected numeric dictionary${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return d}function Mc(c){return An(c)&&c.match(/^https?:\/\/.+/)!==null}function Xl(c,l){if(!Mc(c))throw new TypeError(`Expected url${l!=null&&l.name?` for ${l.name}`:""}, got: `+c);return c}function tf(c,l){return l==null?!0:c(l)}function ef(c,l){return l==null?null:c(l)}function nf(c,l){return l==null?void 0:c(l)}function Lc(c,l){for(const[d,g]of Object.entries(l))if(!g(c[d]))throw TypeError(`${d} in value does not exist or match shape`);for(const d of Object.keys(c))if(!l[d])throw TypeError(`${d} exists in value but not in shape`);return!0}function rf(c,l){return c.every(d=>Lc(d,l))}function gs(c,l="json",d=0){if(Je(c,!1)){if(d>1)return"[object Object]";if(l==="json"){if(Array.isArray(c)){const x=c.map(L=>gs(L,"json",d+1));return d===0?JSON.stringify(x):x}const g={};c.message&&(g.message=gs(c.message,"json",d+1));for(const[x,L]of Object.entries(c))g[x]=gs(L,"json",d+1);return d===0?JSON.stringify(g):g}else if(l==="key-value"){const g=Object.keys(c);return c.message&&!g.includes("message")&&g.unshift("message"),g.map(x=>`${x}=${JSON.stringify(gs(c[x],"json",d+1))}`).join(" ")}}return ve(c)&&(c="undefined"),d===0?JSON.stringify(c):c}function sf(c,l){if(An(c))return c;const d=Object.keys(c);c.message&&!d.includes("message")&&d.push("message");const g=d.map(x=>`${x}: ${c[x]}`).join("; ");return l&&c.stack?g+`
|
|
2
|
+
`+c.stack:g}function di(c,l){if(ce(c)&&ce(l))for(const d in l)ce(l[d])?(c[d]||(c[d]={}),di(c[d],l[d])):Array.isArray(l[d])?c[d]=[...l[d]]:(l[d]!==null&&l[d]!==void 0||c[d]===null||c[d]===void 0)&&(c[d]=l[d]);return c}function of(c,l){const d={};return di(d,c),di(d,l),d}function af(c,l,d){const g={};return di(g,c),di(g,l),di(g,d),g}function Uc(c,l){const d={};for(const g of c)for(const x of Object.keys(g))d[x]?d[x]=l(d[x],g[x]):d[x]=g[x];return d}function cf(c){return Uc(c,(l,d)=>l+d)}function uf(c,l,d){c[l]||(c[l]=[]),c[l].push(d)}function lf(c,l,d){for(c.unshift(l);c.length>d;)c.pop()}function ff(c,l){let d=l%c.length;return d<0&&(d+=c.length),c[d]}function ao(c,l){Array.prototype.push.apply(c,l)}function lO(c,l){Array.prototype.unshift.apply(c,l)}async function fO(c,l){const d=[];for(const g of c)d.push(await l(g));return d}function hO(c,l){const d=[];for(let g=0;g<c.length;g++)d.push(c[g]),g<c.length-1&&(ke(l)?d.push(l()):d.push(l));return d}function dO(c,l){if(c!==l)throw Error(`Expected [${c}] to equal [${l}]`);return[c,l]}function pO(c){if(c!==!0)throw Error(`Expected [true], got: [${c}]`);return c}function gO(c){if(!c)throw Error(`Expected truthy value, got: [${c}]`);return c}function yO(c){if(c!==!1)throw Error(`Expected [false], got: [${c}]`);return c}function mO(c){if(c)throw Error(`Expected falsy value, got: [${c}]`);return c}function wO(c,l){if(!l.includes(c))throw Error(`Expected any of [${l.join(", ")}], got: [${c}]`);return c}function bO(c,l){for(let d=0;d<c.length;d++){const g=c[d],x=l[d],L=Math.max(0,x.getTime()-Date.now());setTimeout(g,L)}}function _O(c,l,d){return c+(l-c)*d}function AO(c){return c.reduce((l,d)=>l+d,0)}function EO(c){return c.reduce((l,d)=>l+d,0)/c.length}function vO(c){const l=[...c].sort((g,x)=>g-x),d=Math.floor(l.length/2);return l.length%2===0?(l[d]+l[d-1])/2:l[d]}function xO(c,l){return c-(l-1)/2}function Mb(c,l){const d=[];for(let g=c;g<=l;g++)d.push(g);return d}function RO(c,l){return l.some(d=>c.includes(d))}function IO(c){return/^[\u4E00-\u9FA5]+$/.test(c)}function dg(c,l=()=>!1){return c.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(d=>/[a-z0-9]/.test(d)||l(d)?d:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function SO(c){return dg(c).replaceAll("-","")}function kO(c){return Sd(c.replace(/([A-Z])/g," $1"))}function TO(c){return c.split("-").map(Sd).join(" ")}function OO(c){return $b(c.split("-").map(Sd).join(""))}function NO(c,l=", ",d=" and "){return!c||!c.length?"":c.length===1?c[0]:c.length===2?`${c[0]}${d}${c[1]}`:`${c.slice(0,c.length-1).join(l)}${d}${c[c.length-1]}`}function CO(c,l){return l+c.split("").join(l)+l}function BO(c){return dg(c).replace(/-/g,"_").toUpperCase()}function Id(c,l){if(l.length===0)return 0;const d=c.toLowerCase(),g=l.toLowerCase();return c===l?1e4:d.startsWith(g)?1e4-c.length:d.includes(g)?5e3-c.length:new RegExp(".*"+g.split("").join(".*")+".*").test(d)?1e3-c.length:0}function PO(c,l){return c.filter(d=>Id(d,l)).sort((d,g)=>Id(g,l)-Id(d,l))}function MO(c){return c.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const LO={"&":"&",""":'"',"'":"'",">":">","<":"<"};function UO(c){let l=c.replace(/&#(\d+);/g,(d,g)=>String.fromCharCode(g)).replace(/&#x(\d+);/g,(d,g)=>String.fromCharCode(parseInt(g,16)));for(const[d,g]of Object.entries(LO))l=l.replaceAll(d,g);return l}function Lb(c,l){const d=c.indexOf(l);return d===-1?null:c.slice(0,d)}function pg(c,l){const d=c.indexOf(l);return d===-1?null:c.slice(d+l.length)}function gg(c,l){const d=c.lastIndexOf(l);return d===-1?null:c.slice(0,d)}function Ub(c,l){const d=c.lastIndexOf(l);return d===-1?null:c.slice(d+l.length)}function DO(c,l,d){const g=gg(c,d);return g?pg(g,l):null}function FO(c,l,d){const g=pg(c,l);return g?Lb(g,d):null}function yg(c,l,d=!1){const g=d?c.lastIndexOf(l):c.indexOf(l);return g===-1?d?[null,c]:[c,null]:[c.slice(0,g),c.slice(g+l.length)]}function Db(c,l){let d=[c];for(const g of l)d=d.flatMap(x=>x.split(g));return d.filter(g=>g)}function mg(c){const l=C(c.split(/\\|\//g)),d=l.lastIndexOf(".",l.length-1);return d<=0?"":l.slice(d+1)}function wg(c){const l=C(c.split(/\\|\//g)),d=l.lastIndexOf(".",l.length-1);return d<=0?l:l.slice(0,d)}function $O(c){let[l,d]=c.split("@");l=hf(l.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[g]=l.split("+");if(!g||!d||d.indexOf(".")===-1||d.indexOf(".")===d.length-1)throw new Error("Invalid email");return d=hf(d.toLowerCase()).replaceAll(" ",""),`${g}@${d}`}function HO(c){const l=wg(c),d=mg(c);return d?`${l}.${d}`:l}function zO(c){const l=wg(c),d=mg(c);return{basename:l,extension:d,filename:d?`${l}.${d}`:l}}function GO(c,l=Math.random){return c.replace(/\{(.+?)\}/g,(d,g)=>it(g.split("|"),l))}function Fb(c){const l=/\{(.+?)\}/,d=c.match(l);if(!d||!d.index)return[c];const g=d[1].split(","),x=c.slice(0,d.index),L=c.slice(d.index+d[0].length);let Q=[];for(const lt of g){const at=Fb(x+lt+L);Q=Q.concat(at)}return Q}function hf(c){return c.split(`
|
|
3
3
|
`).map(l=>l.trim().replace(/\s+/g," ")).filter(l=>l.length>0).join(`
|
|
4
|
-
`)}function
|
|
5
|
-
\r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");function
|
|
6
|
-
`],l.start||0):
|
|
7
|
-
`],l.start||0):
|
|
8
|
-
`],g+x.length):
|
|
9
|
-
`],g);if(x===-1){g>d&&l.push({string:a.slice(d,g),symbol:null}),l.push({string:a.slice(g),symbol:"http"});break}g>d&&l.push({string:a.slice(d,g),symbol:null}),l.push({string:a.slice(g,x),symbol:"http"}),d=x}return l}const Sb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ib="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function SO(a){return kb(a,Sb)}function IO(a){return Tb(a,Sb)}function kO(a){return kb(a,Ib)}function TO(a){return Tb(a,Ib)}function kb(a,l){const d="=",g=l.length;let x=0,L=0;const Q=[];for(let lt=0;lt<a.length;lt++){const at=a[lt];if(at===d)break;const Ct=l.indexOf(at);if(Ct===-1)throw new Error(`Invalid character: ${at}`);L=L<<Math.log2(g)|Ct,x+=Math.log2(g),x>=8&&(x-=8,Q.push(L>>x&255))}return new Uint8Array(Q)}function Tb(a,l){const d=l.length;let g=0,x=0,L="";for(let Q=0;Q<a.length;Q++)for(x=x<<8|a[Q],g+=8;g>=Math.log2(d);)g-=Math.log2(d),L+=l[x>>g&d-1];return g>0&&(L+=l[x<<Math.log2(d)-g&d-1]),L.length%4!==0&&(L+="=".repeat(4-L.length%4)),L}function OO(a){a.startsWith("0x")&&(a=a.slice(2));const l=a.length/2,d=new Uint8Array(l);for(let g=0;g<l;g++){const x=parseInt(a.slice(g*2,g*2+2),16);d[g]=x}return d}function NO(a){return Array.from(a).map(l=>l.toString(16).padStart(2,"0")).join("")}function CO(a,l){const d=a.split("/").filter(L=>L),g=l.split("/").filter(L=>L);if(d.length!==g.length)return null;const x={};for(let L=0;L<d.length;L++){const Q=d[L];if(Q.startsWith(":"))x[Q.slice(1)]=g[L];else if(Q!==g[L])return null}return x}function tg(a,l,d){const g=[];for(const x of d)x!==l&&g.push(a.replace(l,x));return g}function BO(a,l,d,g=Math.random){const x=n.Arrays.shuffle(l.map(Q=>({variants:n.Arrays.shuffle(Q.variants.map(lt=>lt),g),avoid:Q.avoid})),g),L=[];for(const Q of x){const lt=Q.variants.filter(Ct=>Ct!==Q.avoid),at=lt.find(Ct=>a.includes(Ct));if(at&&(to(L,tg(a,at,lt)),L.length>=d))break}if(L.length<d)for(const Q of x){const lt=Q.variants.find(at=>a.includes(at));if(lt&&(to(L,tg(a,lt,Q.variants)),L.length>=d))break}return L.slice(0,d)}function PO(a,l,d,g=!1){const x=new RegExp(g?`(?<=\\s|^)${l}(?=\\s|$)`:`\\b${l}\\b`,"g");return a.replace(x,d)}function MO(a,l){const d=/\b[A-Z][a-zA-Z0-9]*\b/g;return a.replace(d,g=>g.toUpperCase()===g?g:l(g))}function LO(a){return a.replace(/<[^>]*>/g,"")}function Ob(a){const l=a.lastIndexOf(" ");if(l===-1)return{line:a,rest:""};const d=a.slice(0,l),g=a.slice(l+1);return{line:d,rest:g}}function UO(a,l={}){return[...a].reduce((d,g)=>d+(l[g]||1),0)}function DO(a,l,d={}){const g=[];let x="",L=0;for(let Q=0;Q<a.length;Q++){const lt=a[Q],at=d[lt]||1;if(x+=lt,L+=at,L>l){const{line:Ct,rest:Ce}=Ob(x);g.push(Ct),x=Ce,L=Ce.split("").map(Cn=>d[Cn]||1).reduce((Cn,Pc)=>Cn+Pc,0)}}return x&&g.push(x),g}function FO(a,l){const d=[];for(let g=0;g<=a.length;g++)d[g]=[g];for(let g=0;g<=l.length;g++)d[0][g]=g;for(let g=1;g<=a.length;g++)for(let x=1;x<=l.length;x++){const L=a[g-1]===l[x-1]?0:1;d[g][x]=Math.min(d[g-1][x]+1,d[g][x-1]+1,d[g-1][x-1]+L)}return d[a.length][l.length]}function eg(a,l){return new RegExp(`\\b${l}\\b`).test(a)}function $O(a,l,d){return d==="any"?l.some(g=>eg(a,g)):l.every(g=>eg(a,g))}function HO(a){const l={},d=a.match(/([a-z\-]+)="([^"]+)"/g);if(d)for(const g of d){const[x,L]=Jp(g,"=");l[x]=L.slice(1,L.length-1)}return l}function hd(a,l,d=[]){let g="";for(;l<a.length&&(Xl(a[l])||d.includes(a[l]));)g+=a[l++];return g}function zO(a,l,d="$",g=":"){for(const x in l)a=Nb(a,x,l[x],d,g);return a=Cb(a),a}function Nb(a,l,d,g="$",x=":"){if(d==="")return a;let L=a.indexOf(`${g}${l}`);for(;L!==-1;){if(a[L+l.length+1]===x)if(a[L+l.length+2]===x)a=a.replace(`${g}${l}${x}${x}`,d);else{const Q=hd(a,L+l.length+2,["_"]);a=a.replace(`${g}${l}${x}${Q}`,d)}else a=a.replace(`${g}${l}`,d);L=a.indexOf(`${g}${l}`,L+d.length)}return a}function Cb(a,l="$",d=":"){let g=a.indexOf(l);for(;g!==-1;){const x=hd(a,g+1);if(a[g+x.length+1]===d)if(a[g+x.length+2]===d)a=a.replace(`${l}${x}${d}${d}`,"");else{const L=hd(a,g+x.length+2);a=a.replace(`${l}${x}${d}${L}`,L)}g=a.indexOf(l,g+1)}return a}function GO(a,l){let d=a.indexOf("](");for(;d!==-1;){const g=vb(a,"[",d),x=a.indexOf(")",d);if(g!==-1&&x!==-1){const[L,Q]=a.slice(g+1,x).split("]("),lt=l(L,Q);a=a.slice(0,g)+lt+a.slice(x+1)}d=a.indexOf("](",d+1)}return a}function Bb(a,l=!0){const d=Object.entries(a).filter(([g,x])=>x!=null).map(([g,x])=>`${g}=${encodeURIComponent(x)}`).join("&");return d?(l?"?":"")+d:""}function VO(a){const l={},d=a.split("&");for(const g of d){const[x,L]=g.split("=");x&&L&&(l[x]=decodeURIComponent(L))}return l}function KO(a,l){return Object.prototype.hasOwnProperty.call(a,l)}function jO(a,l){let d=null,g=-1/0;for(const[x,L]of Object.entries(a)){const Q=l(L);Q>g&&(g=Q,d=x)}return d?[d,a[d]]:null}function WO(a,l,d,g){const x=a.find(Q=>Q[l]===d),L=a.find(Q=>Q[l]===d+g);x&&L?(x[l]=d+g,L[l]=d):x&&(x[l]=d+g),a.sort((Q,lt)=>ia(Q[l])-ia(lt[l])),a.forEach((Q,lt)=>Q[l]=lt+1)}function ZO(a){const l=Object.keys(a);if(l.length===1)return a[l[0]];throw new Error("Expected object to have a single key")}function qO(a,l=":"){return Object.fromEntries(a.map(d=>Jp(d,l)).map(d=>d[0]&&d[1]?[Yl(d[0]),Yl(d[1])]:null).filter(d=>d))}function QO(a,l,d){return Ub(a,l)+Bb(d||{})}function JO(a,l=",",d='"'){const g=[];let x="",L=!1;const Q=a.split("");for(const lt of Q)lt===l&&!L?(g.push(x),x=""):lt===d&&(!x&&!L||L)?L=!L:x+=lt;return g.push(x),g}function YO(a){return`[${Math.floor(a.progress*100)}%] ${dd(a.deltaMs)} out of ${dd(a.totalTimeMs)} (${dd(a.remainingTimeMs)} left) [${Math.round(a.baseTimeMs)} ms each]`}async function XO(a,l,d){for(let g=0;g<d;g++){try{if(await a())return!0}catch{}g<d-1&&await s(l)}return!1}function tN(a,l){const d=[];for(let g=a.length-1;g>=0;g--)l(a[g])&&d.push(a.splice(g,1)[0]);return d}function eN(a){return JSON.parse(JSON.stringify(a))}function nN(a){return Math.ceil((a||Date.now())/1e3)}function rN(a){return(a||new Date).toISOString().slice(0,10)}function iN(a){return(a||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")}function sN(a){const l=new Date(a);return new Date(l.getTime()-l.getTimezoneOffset()*6e4)}function oN(a){return new Date(a)}function ki(a){return String(Math.floor(a)).padStart(2,"0")}function aN(a){let[l,d]=a.split(":");ue(parseInt(l,10))||(l="0"),ue(parseInt(d,10))||(d="0");let g=og(je(l),0,23),x=og(je(d),0,59);return`${ki(g)}:${ki(x)}`}function dd(a){const l=Math.floor(a/36e5);a=a%36e5;const d=Math.floor(a/6e4);a=a%6e4;const g=Math.floor(a/1e3);return l?`${ki(l)}:${ki(d)}:${ki(g)}`:`${ki(d)}:${ki(g)}`}function oa(a){return Math.floor((Je(a)?a.getTime():a)/864e5)}const cN={today:(a,l)=>ki(a)+":"+ki(l),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:a=>`${a}w`};function uN(a,l){const d=new Date((l==null?void 0:l.now)||Date.now()),g=(l==null?void 0:l.labels)||cN,x=Je(a)?a:new Date(a);if(oa(d)===oa(x))return g.today(x.getUTCHours(),x.getUTCMinutes(),x.getUTCHours()>12);if(oa(d)-oa(x)===1)return g.yesterday();const L=rg(x);return oa(d)-oa(x)<7?g[L.day]():g.weeks(Math.round((d.getTime()-x.getTime())/6048e5))}const Pb={now:()=>"A few seconds",seconds:a=>`${a} seconds`,minutes:a=>`${a} minutes`,hours:a=>`${a} hours`,days:a=>`${a} days`,weeks:a=>`${a} weeks`};function Mb(a,l){const d=(l==null?void 0:l.now)??Date.now(),g=(l==null?void 0:l.labels)||Pb,x=n.Types.isDate(a)?a.getTime():a;let L=(d-x)/1e3;return L<10?g.now():L<120?g.seconds(Math.floor(L)):(L/=60,L<120?g.minutes(Math.floor(L)):(L/=60,L<48?g.hours(Math.floor(L)):(L/=24,L<14?g.days(Math.floor(L)):(L/=7,g.weeks(Math.floor(L))))))}function lN(a,l=Pb){return Mb(0,{now:a*1e3,labels:l})}function fN(a,l,d){const g=((d==null?void 0:d.now)??Date.now())-a,x=Math.floor(g/l),L=l/((d==null?void 0:d.precision)??1)-Math.ceil(g%l/((d==null?void 0:d.precision)??1));return{cycles:x,remaining:L}}const ng={};function hN(a,l){return!ng[a]||Date.now()>ng[a]?(ng[a]=Date.now()+l,!0):!1}const dN={s:1e3,m:6e4,h:36e5,d:864e5};function pN(a,l,d){return l=Je(l)?l.getTime():l,d=d?Je(d)?d.getTime():d:Date.now(),(d-l)/dN[a]}function gN(a,l,d,g){g||(g=Date.now());const x=l/d,L=g-a,Q=L/l,lt=Q*d,at=lt-L;return{deltaMs:L,progress:x,baseTimeMs:Q,totalTimeMs:lt,remainingTimeMs:at}}const yN={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Lb(a){return{zeroBasedIndex:a,day:yN[a]}}function rg(a){return Lb(a.getDay())}function mN(a){return rg(new Date(a))}function wN(a){return a*1e3}function bN(a){return a*6e4}function _N(a){return a*36e5}function AN(a){return a*864e5}const EN={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6};function vN(a){const l=parseFloat(a);if(isNaN(l))throw Error("makeDate got NaN for input");const d=a.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),g=EN[d];if(!g)throw Error(`Unknown unit: "${d}"`);return l*g}const xN={b:1,byte:1,bytes:1,kb:1024,kilobyte:1024,kilobytes:1024,mb:1024**2,megabyte:1024**2,megabytes:1024**2,gb:1024**3,gigabyte:1024**3,gigabytes:1024**3,tb:1024**4,terabyte:1024**4,terabytes:1024**4};function RN(a){const l=parseFloat(a);if(isNaN(l))throw Error("makeDate got NaN for input");const d=a.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),g=xN[d];if(!g)throw Error(`Unknown unit: "${d}"`);return l*g}function SN(a){return a.replace(/ +/g," ").replace(/^ /gm,"")}const ig={};async function IN(a,l,d){const g=Date.now(),x=ig[a];if(x&&x.validUntil>g)return x.value;const L=await d(),Q=g+l;return ig[a]={value:L,validUntil:Q},L}function kN(a){delete ig[a]}function Ub(...a){return a.filter(l=>l).join("/").replace(new RegExp("(?<!:)\\/+","g"),"/")}function TN(a,l,d,g,x=!0){const L=a.indexOf(l),Q=a.indexOf(d,L+l.length);if(L===-1||Q===-1)throw Error("Start or end not found");return x?a.substring(0,L+l.length)+g+a.substring(Q):a.substring(0,L)+g+a.substring(Q+d.length)}function ON(a){let l="p";a.startsWith("#")?(l="h1",a=a.slice(1).trim()):a.startsWith("-")&&(l="li",a=a.slice(1).trim());const d=a[0]===a[0].toUpperCase(),g=/[.?!]$/.test(a),x=/:$/.test(a);return{type:l,isCapitalized:d,hasPunctuation:g,endsWithColon:x}}function NN(a,l="(",d=")"){let g=0,x=0;for(;x<a.length;)if(a.startsWith(l,x)?(g++,x+=l.length):a.startsWith(d,x)?(g--,x+=d.length):x++,g<0)return!1;return l===d?g%2===0:g===0}function CN(a){a=a.normalize("NFD").replace(/[\u0300-\u036f]/g,"");let l=a.length;for(;a=a.replace(/(\w+)[\s,']+\w+/g,"$1"),a.length!==l;)l=a.length;return a=a.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A"),a=a.replaceAll(/[a-z][a-zA-Z0-9]*/g,"a"),a=a.replaceAll(/[\u4E00-\u9FA5]+/g,"Z"),a}function Db(a){const l=Object.keys(a).sort((g,x)=>g.localeCompare(x)),d={};for(const g of l)d[g]=aa(a[g]);return d}function Fb(a){const l=[];return a.sort((d,g)=>JSON.stringify(aa(d)).localeCompare(JSON.stringify(aa(g)))).forEach(d=>l.push(aa(d))),l}function aa(a){return Array.isArray(a)?Fb(a):Qe(a)?Db(a):a}function $b(a,l){return JSON.stringify(aa(a))===JSON.stringify(aa(l))}function BN(...a){for(let l=1;l<a.length;l++)if(!$b(a[l-1],a[l]))return!1;return!0}function PN(a){try{return JSON.parse(a)}catch{return null}}function MN(){let a=0;return{next:()=>a++}}function LN(a){let l=0;return{next:()=>a[l++%a.length]}}function UN(a){let l;return d=>{const g=d===a&&l!==a;return l=d,g}}function DN(a,l,d,g,x){const L={};for(const Q of Object.keys(l))L[Q]=[];L[g]=[],x&&(a=a.sort(x));for(const Q of a){const lt=Q[d],at=l[lt]?lt:g;L[at].length>=l[at]?L[g].push(Q):L[at].push(Q)}return L}function FN(a,l){const d=Object.keys(a),g=Object.keys(l);return{uniqueToA:d.filter(x=>!g.includes(x)),uniqueToB:g.filter(x=>!d.includes(x))}}function Hb(a){const l=Object.keys(a);return l[Math.floor(Math.random()*l.length)]}function $N(a,l){const d=Hb(a);return a[d]=l(a[d]),d}function HN(a){return a=a.replace(/\r\n/g,`
|
|
10
|
-
`),a=a.replace(/(\w+)\((.+)\)/g,(l,d,g)=>`${d}(${g.replaceAll(",",",")})`),a=a.replace(/(,)(\s+})/g,"$2"),a=a.replace(/\.\.\..+?,/g,""),a=a.replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),a=a.replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),a=a.replace(/:(.+)\?(.+):/g,(l,d,g)=>`: (${d.trim()} && ${g.trim()}) ||`),a=a.replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2'),a=a.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(l,d,g,x)=>`"${d}":"${g.trim()}"${x}`),a=a.replace(/("'|'")/g,'"'),a=a.replaceAll(",",","),JSON.parse(a)}const eo=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],zN=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],zb=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function GN(a,l,d){let g=a.length-l;if(g<=0)return"0."+"0".repeat(-g)+a+(d?" "+d:"");let x=a.substring(0,g),L=a.substring(g);return x===""&&(x="0"),x+"."+L+(d?" "+d:"")}function VN(a,l){const d=(l==null?void 0:l.longForm)??!1,g=l!=null&&l.unit?` ${l.unit}`:"",x=d?zN:zb,L=(l==null?void 0:l.precision)??1;if(a<eo[0])return`${a}${g}`;for(let Q=0;Q<eo.length-1;Q++)if(a<eo[Q+1])return`${(a/eo[Q]).toFixed(L)}${d?" ":""}${x[Q]}${g}`;return`${(a/eo[eo.length-1]).toFixed(L)}${d?" ":""}${x[eo.length-1]}${g}`}function sg(a){const l=parseFloat(a);if(isNaN(l))throw Error("makeNumber got NaN for input");const d=a.replace(/^-?[0-9.]+/,"").trim(),g=zb.findIndex(x=>x.toLowerCase()===d.toLowerCase());return g===-1?l:l*eo[g]}function og(a,l,d){return a<l?l:a>d?d:a}function KN(a,l,d){const g=a+l;return g>d?d:g}function jN(a,l,d){const g=a-l;return g<d?d:g}function WN(a,l){return l(a),a}function ZN(a,l){a&&l(a)}function qN(a,l){const d=Object.keys(l);for(const g of d)Array.isArray(l[g])&&Array.isArray(a[g])&&to(a[g],l[g])}function QN(a){return a.splice(0,a.length),a}function JN(a){for(const l of Object.keys(a))(Me(a[l])||Array.isArray(a[l])&&a[l].every(d=>d==null))&&delete a[l];return a}function YN(a){for(const l of Object.entries(a))(l[1]===null||l[1]===void 0||_n(l[1])&&me(l[1]))&&delete a[l[0]];return a}function XN(a,l){const d={};for(const[g,x]of Object.entries(a))l(g)&&(d[g]=x);return d}function t6(a,l){const d={};for(const[g,x]of Object.entries(a))l(x)&&(d[g]=x);return d}function e6(a,l){const d={};for(const g of Object.entries(a))d[g[0]]=l(g[1]);return d}function n6(a,l){const d=[];let g=0;for(const x of a)d.push(l(x,g++));return d}async function r6(a,l){try{return await a()}catch{throw l}}function i6(a,l,d){d!=null&&(a[l]=d)}function s6(a,l,d,g){const x=N(d,g);x!=null&&M(a,l,x)}function o6(a){const l={};for(const[d,g]of Object.entries(a))l[g]=d;return l}function a6(a){const l=Object.keys(a),d=l.map(lt=>a[lt].length),g=d.reduce((lt,at)=>lt*=at);let x=1;const L=[1];for(let lt=0;lt<d.length-1;lt++)x*=d[lt],L.push(x);const Q=[];for(let lt=0;lt<g;lt++){const at={};for(let Ct=0;Ct<l.length;Ct++){const Ce=a[l[Ct]],Cn=Math.floor(lt/L[Ct])%Ce.length;at[l[Ct]]=Ce[Cn]}Q.push(at)}return Q}function c6(a){return Object.values(a).filter(l=>l).length}function u6(a,l,d){return a+(d?"["+l+"]":(a.length?".":"")+l)}function pd(a,l,d,g,x){if(!Qe(l))return l;for(const[L,Q]of Object.entries(l)){const lt=u6(d,L,g);Array.isArray(Q)?x?pd(a,Q,lt,!0,x):a[lt]=Q.map(at=>pd(Array.isArray(at)?[]:{},at,"",!1,x)):Qe(Q)?pd(a,Q,lt,!1,x):a[lt]=Q}return a}function l6(a,l=!1,d){return pd({},a,d||"",!1,l)}function Gb(a){if(!Qe(a))return a;const l=Array.isArray(a)?[]:{};for(const[d,g]of Object.entries(a))Array.isArray(g)?M(l,d,g.map(x=>Gb(x))):M(l,d,g);return l}function f6(a,l,d){return l[a]?l[a]:d}function Vb(a,l){const d={};for(const g of a){const x=l(g);d[x]=g}return d}function h6(a,l){const d={};for(const g of a){const x=l(g);d[x]||(d[x]=[]),d[x].push(g)}return d}function d6(a,l){const d=[];for(let g=0;g<a.length;g+=l)d.push(a.slice(g,g+l));return d}function Kb(a,l){const d=Math.ceil(a.length/l),g=[];for(let x=0;x<a.length;x+=d)g.push(a.slice(x,x+d));return g}function jb(a,l){const d=[],g=Math.ceil(a.length/l);for(let x=0;x<g;x++)d.push(a.slice(x*l,x*l+l));return d}function p6(a,l){const d=Math.ceil(a.length/l);return jb(a,d)}function g6(a,l){return Object.values(Vb(a,l))}function y6(a,l,d,g,x){const L=l?a.map(l):a,Q={};for(const at of L)Q[at]=(Q[at]||0)+1;const lt=g?Wb(Q,x?(at,Ct)=>at[1]-Ct[1]:(at,Ct)=>Ct[1]-at[1]):Q;return d?Object.keys(lt):lt}function Wb(a,l){return Object.fromEntries(Object.entries(a).sort(l))}function m6(a){const l=[],d=Object.keys(a),g=a[d[0]].length;for(let x=0;x<g;x++){const L={};for(const Q of d)L[Q]=a[Q][x];l.push(L)}return l}function w6(a,l,d=1){for(const g of a)g[l]+=d}function b6(a,l,d){for(const g of a)g[l]=d}function ag(a,l){const d=[];let g=[];return a.forEach((x,L)=>{(L===0||!l(x,a[L-1]))&&(g=[],d.push(g)),g.push(x)}),d}function _6(){return{map:new Map,keys:[]}}function A6(){return{map:new Map,keys:[]}}function Zb(a,l,d,g=100){if(a.map.has(l)){const x=a.keys.indexOf(l);a.keys.splice(x,1)}if(a.map.set(l,d),a.keys.push(l),a.keys.length>g){const x=a.keys.shift();x&&a.map.delete(x)}}function E6(a,l,d,g=100){if(a.map.has(l)){const x=a.keys.indexOf(l);a.keys.splice(x,1)}if(a.map.set(l,d),a.keys.unshift(l),a.keys.length>g){const x=a.keys.shift();x&&a.map.delete(x)}}function v6(a,l,d,g,x=100){Zb(a,l,{validUntil:Date.now()+g,data:d},x)}function x6(a,l){const d=a.map.get(l);return d&&d.validUntil>Date.now()?d.data:null}class no{constructor(l){this.value=l}static of(l){return new no(l)}static empty(){return new no(null)}map(l){return new no(this.value!==null&&this.value!==void 0?l(this.value):null)}mapAsync(l){return this.value!==null&&this.value!==void 0?l(this.value).then(d=>no.of(d)):Promise.resolve(no.empty())}ifPresent(l){return this.value!==null&&this.value!==void 0&&l(this.value),this}ifPresentAsync(l){return this.value!==null&&this.value!==void 0?l(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(l){return(this.value===null||this.value===void 0)&&l(),this}ifAbsentAsync(l){return this.value===null||this.value===void 0?l().then(()=>this):Promise.resolve(this)}getOrFallback(l){return this.value??l()}getOrFallbackAsync(l){return this.value!==null&&this.value!==void 0?Promise.resolve(this.value):l()}getOrThrow(){if(this.value===null||this.value===void 0)throw Error("Optional.value is empty");return this.value}}n.Optional=no;class R6{constructor(l){this.supplier=l,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}}n.Lazy=R6;class S6{constructor(l){this.supplier=l,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}}n.AsyncLazy=S6;function I6(a){return()=>a.forEach(l=>l())}function k6(a,l){return a.reduce((d,g)=>l(d)>l(g)?d:g)}function T6(a,l){const d=a.find(g=>g instanceof l);return no.of(d)}function O6(a,l){return a.filter(d=>d instanceof l)}function N6(a,l){const d=[],g=Math.max(a.length,l.length);for(let x=0;x<g;x++)a[x]&&d.push(a[x]),l[x]&&d.push(l[x]);return d}function C6(a,l){return a.includes(l)?a.filter(d=>d!==l):[...a,l]}class B6{constructor(l){this.value=l,this.children=[]}}function P6(a,l,d,g,x=!1){const L=new Map,Q=[];a.forEach(at=>{const Ct=new B6(at);L.set(at[l],Ct)}),a.forEach(at=>{const Ct=L.get(at[l]);if(!Ct)return;const Ce=at[d];if(Ce){const Cn=L.get(Ce);Cn&&Cn.children.push(Ct)}else Q.push(Ct)});const lt=at=>{at.children.sort((Ct,Ce)=>{const Cn=Ct.value[g],Pc=Ce.value[g];return x?Pc-Cn:Cn-Pc}),at.children.forEach(lt)};return Q.forEach(lt),Q}function qb(a,l){if(Math.log2(a.length)%1!==0)throw new Error("Array length must be a power of 2");let d=[...a];for(;d.length>1;){const g=[];for(let x=0;x<d.length;x+=2){const L=d[x+1];g.push(l(d[x],L))}d=g}return d[0]}function Nc(...a){const l=a.reduce((x,L)=>x+L.length,0),d=new Uint8Array(l);let g=0;return a.forEach(x=>{d.set(x,g),g+=x.length}),d}function Qb(a){return a[0]===137&&a[1]===80&&a[2]===78&&a[3]===71}function Jb(a){return a[0]===255&&a[1]===216}function Yb(a){return a[8]===87&&a[9]===69&&a[10]===66&&a[11]===80}function M6(a){return Qb(a)||Jb(a)||Yb(a)}function L6(a){return new Uint8Array([a])}function U6(a){return a[0]}function D6(a,l){const d=new ArrayBuffer(2);return new DataView(d).setUint16(0,a,l==="LE"),new Uint8Array(d)}function F6(a,l){return new DataView(a.buffer).getUint16(a.byteOffset,l==="LE")}function $6(a,l){const d=new ArrayBuffer(4);return new DataView(d).setUint32(0,a,l==="LE"),new Uint8Array(d)}function H6(a,l){return new DataView(a.buffer).getUint32(a.byteOffset,l==="LE")}function cg(a,l){const d=new ArrayBuffer(8);return new DataView(d).setBigUint64(0,BigInt(a),l==="LE"),new Uint8Array(d)}function z6(a,l){return new DataView(a.buffer).getBigUint64(a.byteOffset,l==="LE")}function Cc(a,l){const d=new Uint8Array(32);let g=a;if(l==="LE"){for(let x=0;x<32;x++)d[x]=Number(g&0xffn),g>>=8n;return d}for(let x=31;x>=0;x--)d[x]=Number(g&0xffn),g>>=8n;return d}function Bc(a,l){let d=0n;if(l==="LE"){for(let g=31;g>=0;g--)d=d<<8n|BigInt(a[g]);return d}for(let g=0;g<32;g++)d=d<<8n|BigInt(a[g]);return d}function G6(a,l){const d=[];let g=0;for(const x of l)d.push(a.subarray(g,g+x)),g+=x;return d}function ug(a,l){const d=[];for(let g=0;g<a.length;g+=l)d.push(a.subarray(g,g+l));return d}const Xb=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function V6(a){for(let l=0;l<24;l++){const d=a[0]^a[10]^a[20]^a[30]^a[40],g=a[1]^a[11]^a[21]^a[31]^a[41],x=a[2]^a[12]^a[22]^a[32]^a[42],L=a[3]^a[13]^a[23]^a[33]^a[43],Q=a[4]^a[14]^a[24]^a[34]^a[44],lt=a[5]^a[15]^a[25]^a[35]^a[45],at=a[6]^a[16]^a[26]^a[36]^a[46],Ct=a[7]^a[17]^a[27]^a[37]^a[47],Ce=a[8]^a[18]^a[28]^a[38]^a[48],Cn=a[9]^a[19]^a[29]^a[39]^a[49],Pc=x<<1|L>>>31,SC=L<<1|x>>>31,nf=Ce^Pc,rf=Cn^SC,IC=Q<<1|lt>>>31,kC=lt<<1|Q>>>31,sf=d^IC,of=g^kC,TC=at<<1|Ct>>>31,OC=Ct<<1|at>>>31,af=x^TC,cf=L^OC,NC=Ce<<1|Cn>>>31,CC=Cn<<1|Ce>>>31,uf=Q^NC,lf=lt^CC,BC=d<<1|g>>>31,PC=g<<1|d>>>31,ff=at^BC,hf=Ct^PC;a[0]^=nf,a[1]^=rf,a[2]^=sf,a[3]^=of,a[4]^=af,a[5]^=cf,a[6]^=uf,a[7]^=lf,a[8]^=ff,a[9]^=hf,a[10]^=nf,a[11]^=rf,a[12]^=sf,a[13]^=of,a[14]^=af,a[15]^=cf,a[16]^=uf,a[17]^=lf,a[18]^=ff,a[19]^=hf,a[20]^=nf,a[21]^=rf,a[22]^=sf,a[23]^=of,a[24]^=af,a[25]^=cf,a[26]^=uf,a[27]^=lf,a[28]^=ff,a[29]^=hf,a[30]^=nf,a[31]^=rf,a[32]^=sf,a[33]^=of,a[34]^=af,a[35]^=cf,a[36]^=uf,a[37]^=lf,a[38]^=ff,a[39]^=hf,a[40]^=nf,a[41]^=rf,a[42]^=sf,a[43]^=of,a[44]^=af,a[45]^=cf,a[46]^=uf,a[47]^=lf,a[48]^=ff,a[49]^=hf;const gg=a[0],yg=a[1],mg=a[2]<<1|a[3]>>>31,wg=a[3]<<1|a[2]>>>31,bg=a[5]<<30|a[4]>>>2,_g=a[4]<<30|a[5]>>>2,Ag=a[6]<<28|a[7]>>>4,Eg=a[7]<<28|a[6]>>>4,vg=a[8]<<27|a[9]>>>5,xg=a[9]<<27|a[8]>>>5,Rg=a[11]<<4|a[10]>>>28,Sg=a[10]<<4|a[11]>>>28,Ig=a[13]<<12|a[12]>>>20,kg=a[12]<<12|a[13]>>>20,Tg=a[14]<<6|a[15]>>>26,Og=a[15]<<6|a[14]>>>26,Ng=a[17]<<23|a[16]>>>9,Cg=a[16]<<23|a[17]>>>9,Bg=a[18]<<20|a[19]>>>12,Pg=a[19]<<20|a[18]>>>12,Mg=a[20]<<3|a[21]>>>29,Lg=a[21]<<3|a[20]>>>29,Ug=a[22]<<10|a[23]>>>22,Dg=a[23]<<10|a[22]>>>22,Fg=a[25]<<11|a[24]>>>21,$g=a[24]<<11|a[25]>>>21,Hg=a[26]<<25|a[27]>>>7,zg=a[27]<<25|a[26]>>>7,Gg=a[29]<<7|a[28]>>>25,Vg=a[28]<<7|a[29]>>>25,Kg=a[31]<<9|a[30]>>>23,jg=a[30]<<9|a[31]>>>23,Wg=a[33]<<13|a[32]>>>19,Zg=a[32]<<13|a[33]>>>19,qg=a[34]<<15|a[35]>>>17,Qg=a[35]<<15|a[34]>>>17,Jg=a[36]<<21|a[37]>>>11,Yg=a[37]<<21|a[36]>>>11,Xg=a[38]<<8|a[39]>>>24,ty=a[39]<<8|a[38]>>>24,ey=a[40]<<18|a[41]>>>14,ny=a[41]<<18|a[40]>>>14,ry=a[42]<<2|a[43]>>>30,iy=a[43]<<2|a[42]>>>30,sy=a[45]<<29|a[44]>>>3,oy=a[44]<<29|a[45]>>>3,ay=a[47]<<24|a[46]>>>8,cy=a[46]<<24|a[47]>>>8,uy=a[48]<<14|a[49]>>>18,ly=a[49]<<14|a[48]>>>18;a[0]=gg^~Ig&Fg,a[1]=yg^~kg&$g,a[2]=Ig^~Fg&Jg,a[3]=kg^~$g&Yg,a[4]=Fg^~Jg&uy,a[5]=$g^~Yg&ly,a[6]=Jg^~uy&gg,a[7]=Yg^~ly&yg,a[8]=uy^~gg&Ig,a[9]=ly^~yg&kg,a[10]=Ag^~Bg&Mg,a[11]=Eg^~Pg&Lg,a[12]=Bg^~Mg&Wg,a[13]=Pg^~Lg&Zg,a[14]=Mg^~Wg&sy,a[15]=Lg^~Zg&oy,a[16]=Wg^~sy&Ag,a[17]=Zg^~oy&Eg,a[18]=sy^~Ag&Bg,a[19]=oy^~Eg&Pg,a[20]=mg^~Tg&Hg,a[21]=wg^~Og&zg,a[22]=Tg^~Hg&Xg,a[23]=Og^~zg&ty,a[24]=Hg^~Xg&ey,a[25]=zg^~ty&ny,a[26]=Xg^~ey&mg,a[27]=ty^~ny&wg,a[28]=ey^~mg&Tg,a[29]=ny^~wg&Og,a[30]=vg^~Rg&Ug,a[31]=xg^~Sg&Dg,a[32]=Rg^~Ug&qg,a[33]=Sg^~Dg&Qg,a[34]=Ug^~qg&ay,a[35]=Dg^~Qg&cy,a[36]=qg^~ay&vg,a[37]=Qg^~cy&xg,a[38]=ay^~vg&Rg,a[39]=cy^~xg&Sg,a[40]=bg^~Ng&Gg,a[41]=_g^~Cg&Vg,a[42]=Ng^~Gg&Kg,a[43]=Cg^~Vg&jg,a[44]=Gg^~Kg&ry,a[45]=Vg^~jg&iy,a[46]=Kg^~ry&bg,a[47]=jg^~iy&_g,a[48]=ry^~bg&Ng,a[49]=iy^~_g&Cg,a[0]^=Xb[l*2],a[1]^=Xb[l*2+1]}}function t_(a){const l=[];for(let d=0;d<a.length;d+=4)l.push(a[d]|a[d+1]<<8|a[d+2]<<16|a[d+3]<<24);return l}function e_(a,l){if(!a.length){const x=new Uint8Array(136);return x[0]=l,x[135]=128,[t_(x)]}const d=ug(a,136),g=d[d.length-1];if(g.length<136){const x=new Uint8Array(136);x.set(g),x[g.length]=l,x[135]|=128,d[d.length-1]=x}if(g.length===136){const x=new Uint8Array(136);x[0]=l,x[135]=128,d.push(x)}return d.map(t_)}function n_(a,l){for(const d of l){for(let g=0;g<34;g+=2)a[g]^=d[g+1],a[g+1]^=d[g];V6(a)}return a}function r_(a){return new Uint8Array([a[1],a[1]>>-24,a[1]>>-16,a[1]>>-8,a[0],a[0]>>8,a[0]>>16,a[0]>>24,a[3],a[3]>>-24,a[3]>>-16,a[3]>>-8,a[2],a[2]>>8,a[2]>>16,a[2]>>24,a[5],a[5]>>-24,a[5]>>-16,a[5]>>-8,a[4],a[4]>>8,a[4]>>16,a[4]>>24,a[7],a[7]>>-24,a[7]>>-16,a[7]>>-8,a[6],a[6]>>8,a[6]>>16,a[6]>>24])}function fs(a){return r_(n_(new Array(50).fill(0),e_(a,1)))}function K6(a){return r_(n_(new Array(50).fill(0),e_(a,6)))}function j6(a,l,d){const g=Math.min(a.length,l.length,d/8+1);for(let x=0;x<g;x++){const L=a[x]^l[x];for(let Q=0;Q<8;Q++)if(L>>7-Q&1)return x*8+Q}return d}function W6(a,l){const d=Math.min(a.length,l.length);for(let g=0;g<d;g++)if(a[g]!==l[g])return a.subarray(0,g);return a.subarray(0,d)}function Z6(a,l,d,g){const x=Math.floor(l/8),L=l%8;d===1?a[x]|=1<<(g==="BE"?7-L:L):a[x]&=~(1<<(g==="BE"?7-L:L))}function q6(a,l,d){const g=Math.floor(l/8),x=l%8;return a[g]>>(d==="BE"?7-x:x)&1}function Q6(a,l,d=0){for(let g=d;g<a.length;g++)for(let x=0;x<l.length&&a[g+x]===l[x];x++)if(x===l.length-1)return g;return-1}function i_(a,l,d=0){if(a.length>=l)return a;const g=new Uint8Array(l);return g.fill(d),g.set(a,l-a.length),g}function J6(a,l,d=0){const g=a.length%l;return g===0?a:i_(a,a.length+l-g,d)}function s_(a,l,d=0){if(a.length>=l)return a;const g=new Uint8Array(l);return g.fill(d),g.set(a,0),g}function Y6(a,l,d=0){const g=a.length%l;return g===0?a:s_(a,a.length+l-g,d)}function X6(a,l){const d=new Uint8Array(a.length);for(let g=0;g<a.length;g++)d[g]=a[g]^l[g%l.length];return d}function tC(a,l){if(a.length!==l.length)return!1;for(let d=0;d<a.length;d++)if(a[d]!==l[d])return!1;return!0}function De(a,l){return(a%l+l)%l}function tf(a,l){a=De(a,l);let[d,g]=[0n,1n],[x,L]=[l,a];for(;L!==0n;){const Q=x/L;[d,g]=[g,d-Q*g],[x,L]=[L,x-Q*L]}if(x>1n)throw new Error("a is not invertible");return d<0n&&(d+=l),d}function eC(a,l,d){let g=1n;for(a=De(a,d);l>0;)l%2n===1n&&(g=De(g*a,d)),a=De(a*a,d),l=l/2n;return g}function o_(a,l){return De(a,l)===0n?0n:l%4n===3n?eC(a,(l+1n)/4n,l):null}const Yn=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Nn=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,gd=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,yd=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function lg(a,l,d){if(l===0n)return[0n,0n];const g=De(3n*a*a*tf(2n*l,d),d),x=De(g*g-2n*a,d),L=De(g*(a-x)-l,d);return[x,L]}function md(a,l,d,g,x){if(a===0n&&l===0n)return[d,g];if(d===0n&&g===0n)return[a,l];if(a===d&&l===De(-g,x))return[0n,0n];if(a===d&&l===g)return lg(a,l,x);const L=De((g-l)*tf(d-a,x),x),Q=De(L*L-a-d,x),lt=De(L*(a-Q)-l,x);return[Q,lt]}function nC(a){if(a<=0n||a>=Nn)throw new Error("Invalid private key");return ca(gd,yd,a,Yn)}function rC(a){const l=a[1]%2n===0n?2:3;return new Uint8Array([l,...Cc(a[0],"BE")])}function iC(a){if(a.length!==33||a[0]!==2&&a[0]!==3)throw new Error("Invalid compressed public key");const l=Bc(a.slice(1),"BE"),d=o_(De(l**3n+7n,Yn),Yn);if(!d)throw Error("Invalid x: does not correspond to a valid curve point");const g=De(-d,Yn),x=d%2n===0n;return[l,a[0]===2?x?d:g:x?g:d]}function sC(a){const l=new Uint8Array(20),d=fs(Nc(Cc(a[0],"BE"),Cc(a[1],"BE")));return l.set(d.subarray(12)),l}function oC(a){const l=n.Binary.uint8ArrayToHex(a),d=n.Binary.uint8ArrayToHex(n.Binary.keccak256(new Uint8Array([...l].map(x=>x.charCodeAt(0)))));let g="0x";for(let x=0;x<l.length;x++)parseInt(d[x],16)>7?g+=l[x].toUpperCase():g+=l[x];return g}function ca(a,l,d,g){let x=[0n,0n],L=[a,l];const Q=d.toString(2);for(const lt of Q)lt==="0"?(L=md(x[0],x[1],L[0],L[1],g),x=lg(x[0],x[1],g)):(x=md(x[0],x[1],L[0],L[1],g),L=lg(L[0],L[1],g));return x}function aC(a,l,d){return a_(Bc(fs(a),"BE"),l,d)}function a_(a,l,d){if(l<=0n||l>=Nn)throw new Error("Invalid private key");if(d||(d=De(Bc(fs(Nc(fs(Cc(l,"BE")),Cc(a,"BE"))),"BE"),Nn)),d<=0n||d>=Nn)throw new Error("Invalid nonce");const g=De(a,Nn),x=ca(gd,yd,d,Yn),L=De(x[0],Nn);let Q=De((g+De(L,Nn)*l)*tf(d,Nn),Nn);if(L===0n||Q===0n)throw new Error("Invalid r or s value");let lt=x[1]%2n===0n?27n:28n;return Q>Nn/2n&&(Q=Nn-Q,lt=lt===27n?28n:27n),[L,Q,lt]}function cC(a,l,d,g){const x=o_(De(l**3n+7n,Yn),Yn);if(!x)throw new Error("Invalid r: does not correspond to a valid curve point");const L=g===27n?0n:1n,Q=x%2n===L?x:Yn-x,lt=De(Bc(fs(a),"BE"),Nn),at=ca(l,Q,d,Yn),Ct=ca(gd,yd,lt,Yn),Ce=md(at[0],at[1],Ct[0],De(-Ct[1],Yn),Yn);return ca(Ce[0],Ce[1],tf(l,Nn),Yn)}function uC(a,l,d,g){const x=De(Bc(fs(a),"BE"),Nn),L=tf(g,Nn),Q=De(x*L,Nn),lt=De(d*L,Nn),at=ca(gd,yd,Q,Yn),Ct=ca(l[0],l[1],lt,Yn),Ce=md(at[0],at[1],Ct[0],Ct[1],Yn);return d===De(Ce[0],Nn)}class c_{constructor(l){this.cursor=0,this.buffer=l}read(l){const d=this.buffer.subarray(this.cursor,this.cursor+l);return this.cursor+=l,d}max(){return this.buffer.length-this.cursor}}n.Uint8ArrayReader=c_;class u_{constructor(l){this.buffer=l,this.cursor=0}write(l){const d=Math.min(this.max(),l.max());return this.buffer.set(l.read(d),this.cursor),this.cursor+=d,d}max(){return this.buffer.length-this.cursor}}n.Uint8ArrayWriter=u_;class wd{constructor(l,d=0n){this.span=d,this.writer=new u_(new Uint8Array(l))}build(){return Nc(cg(this.span,"LE"),this.writer.buffer)}hash(){const l=qb(ug(this.writer.buffer,32),(d,g)=>fs(Nc(d,g)));return fs(Nc(cg(this.span,"LE"),l))}}n.Chunk=wd;class fg{constructor(l,d=4096){this.counters=[1],this.capacity=d,this.chunks=[new wd(d)],this.onChunk=l}static async root(l,d=4096){const g=new t(t.NOOP,d);return await g.append(l),g.finalize()}async append(l,d=0,g=0n){const x=new c_(l);for(;x.max()>0;){this.chunks[d].writer.max()===0&&await this.elevate(d);const L=this.chunks[d].writer.write(x);g?this.chunks[d].span+=g:this.chunks[0].span+=BigInt(L)}}async elevate(l){this.counters[l]=++this.counters[l]%(this.capacity/32),this.chunks[l+1]||(this.chunks.push(new wd(this.capacity)),this.counters.push(1)),await this.append(this.chunks[l].hash(),l+1,this.chunks[l].span),await this.onChunk(this.chunks[l]),this.chunks[l]=new wd(this.capacity)}async finalize(l=0){return this.chunks[l+1]?this.counters[l]===1?(await this.elevate(l+1),this.chunks[l+1]=this.chunks[l],this.finalize(l+1)):(await this.elevate(l),this.finalize(l+1)):(await this.onChunk(this.chunks[l]),this.chunks[l])}}n.MerkleTree=fg,t=fg,fg.NOOP=async a=>{};class Ti{constructor(l,d){if(d<0)throw Error("Scale must be non-negative");this.value=BigInt(l),this.scale=d}static fromDecimalString(l,d){let[g,x]=l.split(".");return x=(x||"").padEnd(d,"0").slice(0,d),new Ti(BigInt(g+x),d)}add(l){return this.assertSameScale(l),new Ti(this.value+l.value,this.scale)}subtract(l){return this.assertSameScale(l),new Ti(this.value-l.value,this.scale)}multiply(l){return new Ti(this.value*l,this.scale)}divmod(l){if(l===0n)throw new Error("Division by zero is not allowed");const d=this.value/l,g=this.value%l;return[new Ti(d,this.scale),new Ti(g,this.scale)]}exchange(l,d,g){if(l==="*"){const L=this.value*d.value/10n**BigInt(this.scale);return new Ti(L,g)}this.assertSameScale(d);const x=this.value*10n**BigInt(g)/d.value;return new Ti(x,g)}compare(l){return this.assertSameScale(l),this.value>l.value?1:this.value<l.value?-1:0}toDecimalString(){if(this.scale===0)return this.value.toString();const l=this.value.toString(),d=l.slice(0,-this.scale)||"0",g=l.slice(-this.scale).padStart(this.scale,"0");return`${d}.${g}`}toString(){return this.value.toString()}toJSON(){return this.toString()}assertSameScale(l){if(this.scale!==l.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${l.scale}`)}}n.FixedPointNumber=Ti;function lC(a){if(a.length===0)return null;const l=a[0];return l.ttlMax?--l.ttl<=0&&a.shift():l.ttlMax=l.ttl,{progress:(l.ttlMax-l.ttl)/l.ttlMax,data:l.data}}function bd(a,l,d,g){const x=a.findIndex(lt=>lt===`--${l}`||lt.startsWith(`--${l}=`)),L=a[x];if(!L)return(d||{})[g||l||""]||null;if(L.includes("="))return L.split("=")[1];const Q=a[x+1];return Q&&!Q.startsWith("-")?Q:(d||{})[g||l||""]||null}function fC(a,l,d,g){const x=bd(a,l,d,g);if(!x)return null;try{return sg(x)}catch{throw new Error(`Invalid number argument ${l}: ${x}`)}}function hC(a,l,d,g){const x=a.some(at=>at.endsWith("-"+l)),L=bd(a,l,d,g);if(!L&&x)return!0;if(!L&&!x)return null;const Q=["true","1","yes","y","on"],lt=["false","0","no","n","off"];if(Q.includes(L.toLowerCase()))return!0;if(lt.includes(L.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${l}: ${L}`)}function l_(a,l,d,g){const x=bd(a,l,d,g);if(!x)throw new Error(`Missing argument ${l}`);return x}function dC(a,l,d,g){const x=l_(a,l,d,g);try{return sg(x)}catch{throw new Error(`Invalid argument ${l}: ${x}`)}}function f_(a,l){const d=a[l];a.splice(l,1),a.unshift(d)}function pC(a,l){const d=[...a];return f_(d,l),d}function h_(a,l){return{x:a.x+l.x,y:a.y+l.y}}function gC(a,l){return{x:a.x-l.x,y:a.y-l.y}}function hg(a,l){return{x:a.x*l,y:a.y*l}}function yC(a){const l=Math.sqrt(a.x*a.x+a.y*a.y);return{x:a.x/l,y:a.y/l}}function d_(a,l,d){return{x:a.x+Math.cos(l)*d,y:a.y+Math.sin(l)*d}}function p_(a,l){return Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2)}function ef(a,l,d="row-first"){const g=[];if(d==="column-first")for(let x=0;x<a.length;x++)for(let L=0;L<a[0].length;L++)l(x,L)&&g.push({x,y:L});else for(let x=0;x<a[0].length;x++)for(let L=0;L<a.length;L++)l(L,x)&&g.push({x:L,y:x});return g}function mC(a,l,d){var g,x;return((g=a[l+1])==null?void 0:g[d])&&((x=a[l-1])==null?void 0:x[d])&&!a[l][d-1]&&!a[l][d+1]}function wC(a,l,d){var g,x;return a[l][d+1]&&a[l][d-1]&&!((g=a[l-1])!=null&&g[d])&&!((x=a[l+1])!=null&&x[d])}function g_(a,l,d){var g;return!((g=a[l-1])!=null&&g[d])}function y_(a,l,d){var g;return!((g=a[l+1])!=null&&g[d])}function m_(a,l,d){return!a[l][d-1]}function w_(a,l,d){return!a[l][d+1]}function bC(a,l,d){var x,L,Q,lt,at,Ct,Ce,Cn;const g=[];return a[l][d]?mC(a,l,d)||wC(a,l,d)?[]:(!((x=a[l-1])!=null&&x[d-1])&&g_(a,l,d)&&m_(a,l,d)&&g.push({x:l,y:d}),!((L=a[l+1])!=null&&L[d-1])&&y_(a,l,d)&&m_(a,l,d)&&g.push({x:l+1,y:d}),!((Q=a[l-1])!=null&&Q[d+1])&&g_(a,l,d)&&w_(a,l,d)&&g.push({x:l,y:d+1}),!((lt=a[l+1])!=null&<[d+1])&&y_(a,l,d)&&w_(a,l,d)&&g.push({x:l+1,y:d+1}),g):((at=a[l-1])!=null&&at[d]&&a[l][d-1]&&g.push({x:l,y:d}),(Ct=a[l+1])!=null&&Ct[d]&&a[l][d-1]&&g.push({x:l+1,y:d}),(Ce=a[l-1])!=null&&Ce[d]&&a[l][d+1]&&g.push({x:l,y:d+1}),(Cn=a[l+1])!=null&&Cn[d]&&a[l][d+1]&&g.push({x:l+1,y:d+1}),g)}function _C(a,l,d,g){const x=[{x:0,y:0},{x:d,y:0},{x:0,y:g},{x:d,y:g}];for(let L=0;L<a.length;L++)for(let Q=0;Q<a[0].length;Q++){const lt=bC(a,L,Q);for(const at of lt)x.some(Ct=>Ct.x===at.x&&Ct.y===at.y)||x.push(at)}return x.map(L=>({x:L.x*l,y:L.y*l}))}function AC(a,l){const d=ef(a,(at,Ct)=>a[at][Ct]===0&&a[at][Ct+1]!==0,"row-first").map(at=>({...at,dx:1,dy:0})),g=ef(a,(at,Ct)=>a[at][Ct]===0&&a[at][Ct-1]!==0,"row-first").map(at=>({...at,dx:1,dy:0})),x=ef(a,(at,Ct)=>{var Ce;return a[at][Ct]===0&&((Ce=a[at-1])==null?void 0:Ce[Ct])!==0},"column-first").map(at=>({...at,dx:0,dy:1})),L=ef(a,(at,Ct)=>{var Ce;return a[at][Ct]===0&&((Ce=a[at+1])==null?void 0:Ce[Ct])!==0},"column-first").map(at=>({...at,dx:0,dy:1}));d.forEach(at=>at.y++),L.forEach(at=>at.x++);const Q=ag([...x,...L],(at,Ct)=>at.x===Ct.x&&at.y-1===Ct.y),lt=ag([...g,...d],(at,Ct)=>at.y===Ct.y&&at.x-1===Ct.x);return[...Q,...lt].map(at=>({start:at[0],end:C(at)})).map(at=>({start:hg(at.start,l),end:hg(h_(at.end,{x:at.start.dx,y:at.start.dy}),l)}))}function EC(a,l){return Math.atan2(l.y-a.y,l.x-a.x)}function vC(a,l){return l.map(d=>EC(a,d)).sort((d,g)=>d-g)}function b_(a,l,d,g){const x=(g.y-d.y)*(l.x-a.x)-(g.x-d.x)*(l.y-a.y);if(x===0)return null;let L=a.y-d.y,Q=a.x-d.x;const lt=(g.x-d.x)*L-(g.y-d.y)*Q,at=(l.x-a.x)*L-(l.y-a.y)*Q;return L=lt/x,Q=at/x,L>0&&L<1&&Q>0&&Q<1?{x:a.x+L*(l.x-a.x),y:a.y+L*(l.y-a.y)}:null}function dg(a,l,d){const g=[],x=d_(a,d,1e4);for(const L of l){const Q=b_(a,x,L.start,L.end);Q&&g.push(Q)}return g.length?g.reduce((L,Q)=>{const lt=p_(a,Q),at=p_(a,L);return lt<at?Q:L}):null}function xC(a,l,d){const g=vC(a,d),x=[];for(const L of g){const Q=dg(a,l,L-.001),lt=dg(a,l,L+.001);Q&&x.push(Q),lt&&x.push(lt)}return x}class pg{constructor(){this.subscribers=[]}subscribe(l){return this.subscribers.push(l),()=>{this.subscribers=this.subscribers.filter(d=>d!==l)}}publish(l){this.subscribers.forEach(d=>d(l))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}n.PubSubChannel=pg;class RC{constructor(l,d){this.queue=[],this.running=0,this.onProcessed=new pg,this.onDrained=new pg,this.concurrency=l,this.capacity=d}process(){if(this.running>=this.concurrency)return;const l=this.queue.shift();l&&(this.running++,l().finally(()=>{this.running--,this.process(),this.onProcessed.publish(),this.running===0&&this.onDrained.publish()}))}enqueue(l){if(this.queue.length<this.capacity)return this.queue.push(l),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise(d=>{this.onProcessed.subscribe(()=>{this.queue.length<this.capacity&&(this.queue.push(l),this.process(),this.onProcessed.clear(),d())})})}drain(){if(this.running===0)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise(l=>{this.onDrained.subscribe(()=>{this.onDrained.clear(),l()})})}}n.AsyncQueue=RC,n.Binary={hexToUint8Array:OO,uint8ArrayToHex:NO,base64ToUint8Array:SO,uint8ArrayToBase64:IO,base32ToUint8Array:kO,uint8ArrayToBase32:TO,log2Reduce:qb,partition:ug,concatBytes:Nc,numberToUint8:L6,uint8ToNumber:U6,numberToUint16:D6,uint16ToNumber:F6,numberToUint32:$6,uint32ToNumber:H6,numberToUint64:cg,uint64ToNumber:z6,numberToUint256:Cc,uint256ToNumber:Bc,sliceBytes:G6,keccak256:fs,sha3_256:K6,proximity:j6,commonPrefix:W6,setBit:Z6,getBit:q6,indexOf:Q6,equals:tC,padStart:i_,padStartToMultiple:J6,padEnd:s_,padEndToMultiple:Y6,xorCypher:X6},n.Elliptic={privateKeyToPublicKey:nC,compressPublicKey:rC,publicKeyFromCompressed:iC,publicKeyToAddress:sC,signMessage:aC,signHash:a_,verifySignature:uC,recoverPublicKey:cC,checksumEncode:oC},n.Random={intBetween:H,floatBetween:U,chance:J,signed:G,makeSeededRng:B,point:Y,procs:j},n.Arrays={countUnique:y6,makeUnique:g6,splitBySize:d6,splitByCount:Kb,index:Vb,indexCollection:h6,onlyOrThrow:c,onlyOrNull:u,firstOrThrow:h,firstOrNull:f,shuffle:o,initialize:y,initialize2D:b,rotate2D:A,containsShape:R,glue:MT,pluck:S,pick:it,pickMany:ut,pickManyUnique:rt,pickWeighted:v,pickRandomIndices:k,pickGuaranteed:ot,last:C,pipe:p,makePipe:m,sortWeighted:I,pushAll:to,unshiftAll:BT,filterAndRemove:tN,merge:qN,empty:QN,pushToBucket:ql,unshiftAndLimit:Ql,atRolling:Jl,group:ag,createOscillator:LN,organiseWithLimits:DN,tickPlaybook:lC,getArgument:bd,getBooleanArgument:hC,getNumberArgument:fC,requireStringArgument:l_,requireNumberArgument:dC,bringToFront:pC,bringToFrontInPlace:f_,findInstance:T6,filterInstances:O6,interleave:N6,toggle:C6,createHierarchy:P6,multicall:I6,maxBy:k6},n.System={sleepMillis:s,forever:ft,scheduleMany:zT,waitFor:XO,expandError:Kl,runAndSetInterval:mt},n.Numbers={make:sg,sum:VT,average:KT,median:jT,getDistanceFromMidpoint:WT,clamp:og,range:db,interpolate:GT,createSequence:MN,increment:KN,decrement:jN,format:VN,fromDecimals:GN,makeStorage:RN,asMegabytes:Ht,convertBytes:Lt,hexToRgb:Mt,rgbToHex:Ae,haversineDistanceToMeters:Vt,roundToNearest:Ut,formatDistance:Re,triangularNumber:Yt,searchFloat:ie},n.Promises={raceFulfilled:r,invert:e,runInParallelBatches:i},n.Dates={getTimestamp:uN,getTimeDelta:Mb,secondsToHumanTime:lN,countCycles:fN,isoDate:rN,throttle:hN,timeSince:pN,dateTimeSlug:iN,unixTimestamp:nN,fromUtcString:sN,fromMillis:oN,getProgress:gN,humanizeTime:dd,humanizeProgress:YO,createTimeDigits:ki,mapDayNumber:Lb,getDayInfoFromDate:rg,getDayInfoFromDateTimeString:mN,seconds:wN,minutes:bN,hours:_N,days:AN,make:vN,normalizeTime:aN,absoluteDays:oa},n.Objects={safeParse:PN,deleteDeep:_,getDeep:N,setDeep:M,incrementDeep:z,ensureDeep:P,replaceDeep:F,getFirstDeep:ct,deepMergeInPlace:ci,deepMerge2:jl,deepMerge3:Wl,mapAllAsync:PT,cloneWithJson:eN,sortObject:Db,sortArray:Fb,sortAny:aa,deepEquals:$b,deepEqualsEvery:BN,runOn:WN,ifPresent:ZN,zip:Tc,zipSum:Zl,removeEmptyArrays:JN,removeEmptyValues:YN,flatten:l6,unflatten:Gb,match:f6,sort:Wb,map:e6,mapIterable:n6,filterKeys:XN,filterValues:t6,rethrow:r6,setSomeOnObject:i6,setSomeDeep:s6,flip:o6,getAllPermutations:a6,countTruthyValues:c6,transformToArray:m6,setMulti:b6,incrementMulti:w6,createBidirectionalMap:_6,createTemporalBidirectionalMap:A6,pushToBidirectionalMap:Zb,unshiftToBidirectionalMap:E6,addToTemporalBidirectionalMap:v6,getFromTemporalBidirectionalMap:x6,createStatefulToggle:UN,diffKeys:FN,pickRandomKey:Hb,mapRandomKey:$N,fromObjectString:HN,toQueryString:Bb,parseQueryString:VO,hasKey:KO,selectMax:jO,reposition:WO,unwrapSingleKey:ZO,parseKeyValues:qO},n.Types={isFunction:Ie,isObject:Qe,isStrictlyObject:ce,isEmptyArray:Me,isEmptyObject:Xs,isUndefined:Ee,isString:_n,isNumber:ue,isBoolean:ve,isDate:Je,isBlank:me,isId:ke,isIntegerString:Jn,isHexString:Le,isUrl:Ic,isNullable:Hl,asString:Ye,asHexString:un,asSafeString:ad,asIntegerString:od,asNumber:ia,asFunction:ln,asInteger:je,asBoolean:fn,asDate:cd,asNullableString:hn,asEmptiableString:dn,asId:ud,asTime:pn,asArray:gn,asObject:sa,asNullableObject:yn,asStringMap:mn,asNumericDictionary:Fl,asUrl:$l,asNullable:zl,asOptional:Gl,enforceObjectShape:kc,enforceArrayShape:Vl,isPng:Qb,isJpg:Jb,isWebp:Yb,isImage:M6},n.Strings={tokenizeByCount:p6,tokenizeByLength:jb,searchHex:sd,searchSubstring:an,randomHex:cn,randomLetter:Kt,randomAlphanumeric:Ue,randomRichAscii:Ft,randomUnicode:on,includesAny:ZT,slugify:Zp,normalForm:QT,enumify:nO,escapeHtml:iO,decodeHtmlEntities:oO,after:qp,afterLast:gb,before:pb,beforeLast:Qp,betweenWide:aO,betweenNarrow:cO,getPreLine:SN,containsWord:eg,containsWords:$O,joinUrl:Ub,getFuzzyMatchScore:ld,sortByFuzzyScore:rO,splitOnce:Jp,splitAll:yb,randomize:hO,expand:mb,shrinkTrim:Yl,capitalize:fd,decapitalize:wb,csvEscape:wO,parseCsv:JO,surroundInOut:eO,getExtension:Yp,getBasename:Xp,normalizeEmail:uO,normalizeFilename:lO,parseFilename:fO,camelToTitle:JT,slugToTitle:YT,slugToCamel:XT,joinHumanly:tO,findWeightedPair:xb,extractBlock:Rb,extractAllBlocks:AO,replaceBlocks:EO,indexOfEarliest:Oc,lastIndexOfBefore:vb,parseHtmlAttributes:HO,readNextWord:hd,resolveVariables:zO,resolveVariableWithDefaultSyntax:Nb,resolveRemainingVariablesWithDefaults:Cb,isLetter:bb,isDigit:_b,isLetterOrDigit:Xl,isValidObjectPathCharacter:gO,insert:yO,indexOfRegex:Ab,lineMatches:Eb,linesMatchInOrder:mO,represent:ls,resolveMarkdownLinks:GO,buildUrl:QO,isChinese:qT,replaceBetweenStrings:TN,describeMarkdown:ON,isBalanced:NN,textToFormat:CN,splitFormatting:vO,splitHashtags:xO,splitUrls:RO,route:CO,explodeReplace:tg,generateVariants:BO,replaceWord:PO,replacePascalCaseWords:MO,stripHtml:LO,breakLine:Ob,measureTextWidth:UO,toLines:DO,levenshteinDistance:FO},n.Assertions={asEqual:LT,asTrue:UT,asTruthy:DT,asFalse:FT,asFalsy:$T,asEither:HT},n.Cache={get:IN,invalidate:kN},n.Vector={addPoint:h_,subtractPoint:gC,multiplyPoint:hg,normalizePoint:yC,pushPoint:d_,filterCoordinates:ef,findCorners:_C,findLines:AC,raycast:dg,raycastCircle:xC,getLineIntersectionPoint:b_}})(cx);const Ke=ea(cx);Ke.Arrays;Ke.Assertions;const or=Ke.Binary;Ke.Cache;Ke.Dates;Ke.Elliptic;Ke.Numbers;Ke.Objects;Ke.Pagination;Ke.Promises;Ke.Random;Ke.Strings;Ke.System;Ke.Types;Ke.Optional;Ke.Vector;Ke.PubSubChannel;Ke.Chunk;const mM=Ke.MerkleTree;Ke.FixedPointNumber;Ke.Lazy;Ke.AsyncLazy;Ke.AsyncQueue;Ke.Uint8ArrayReader;Ke.Uint8ArrayWriter;var pe;(function(n){n.assertEqual=i=>i;function t(i){}n.assertIs=t;function e(i){throw new Error}n.assertNever=e,n.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},n.getValidEnumValues=i=>{const s=n.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(const c of s)o[c]=i[c];return n.objectValues(o)},n.objectValues=i=>n.objectKeys(i).map(function(s){return i[s]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},n.find=(i,s)=>{for(const o of i)if(s(o))return o},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}n.joinValues=r,n.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(pe||(pe={}));var Rm;(function(n){n.mergeShapes=(t,e)=>({...t,...e})})(Rm||(Rm={}));const Rt=pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),bs=n=>{switch(typeof n){case"undefined":return Rt.undefined;case"string":return Rt.string;case"number":return isNaN(n)?Rt.nan:Rt.number;case"boolean":return Rt.boolean;case"function":return Rt.function;case"bigint":return Rt.bigint;case"symbol":return Rt.symbol;case"object":return Array.isArray(n)?Rt.array:n===null?Rt.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Rt.promise:typeof Map<"u"&&n instanceof Map?Rt.map:typeof Set<"u"&&n instanceof Set?Rt.set:typeof Date<"u"&&n instanceof Date?Rt.date:Rt.object;default:return Rt.unknown}},gt=pe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),wM=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class Vr extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(e(o));else{let c=r,u=0;for(;u<o.path.length;){const f=o.path[u];u===o.path.length-1?(c[f]=c[f]||{_errors:[]},c[f]._errors.push(e(o))):c[f]=c[f]||{_errors:[]},c=c[f],u++}}};return i(this),r}static assert(t){if(!(t instanceof Vr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},r=[];for(const i of this.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:e}}get formErrors(){return this.flatten()}}Vr.create=n=>new Vr(n);const Xu=(n,t)=>{let e;switch(n.code){case gt.invalid_type:n.received===Rt.undefined?e="Required":e=`Expected ${n.expected}, received ${n.received}`;break;case gt.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(n.expected,pe.jsonStringifyReplacer)}`;break;case gt.unrecognized_keys:e=`Unrecognized key(s) in object: ${pe.joinValues(n.keys,", ")}`;break;case gt.invalid_union:e="Invalid input";break;case gt.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${pe.joinValues(n.options)}`;break;case gt.invalid_enum_value:e=`Invalid enum value. Expected ${pe.joinValues(n.options)}, received '${n.received}'`;break;case gt.invalid_arguments:e="Invalid function arguments";break;case gt.invalid_return_type:e="Invalid function return type";break;case gt.invalid_date:e="Invalid date";break;case gt.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(e=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?e=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?e=`Invalid input: must end with "${n.validation.endsWith}"`:pe.assertNever(n.validation):n.validation!=="regex"?e=`Invalid ${n.validation}`:e="Invalid";break;case gt.too_small:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:e="Invalid input";break;case gt.too_big:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?e=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:e="Invalid input";break;case gt.custom:e="Invalid input";break;case gt.invalid_intersection_types:e="Intersection results could not be merged";break;case gt.not_multiple_of:e=`Number must be a multiple of ${n.multipleOf}`;break;case gt.not_finite:e="Number must be finite";break;default:e=t.defaultError,pe.assertNever(n)}return{message:e}};let ux=Xu;function bM(n){ux=n}function a0(){return ux}const c0=n=>{const{data:t,path:e,errorMaps:r,issueData:i}=n,s=[...e,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="";const u=r.filter(f=>!!f).slice().reverse();for(const f of u)c=f(o,{data:t,defaultError:c}).message;return{...i,path:s,message:c}},_M=[];function At(n,t){const e=a0(),r=c0({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,e,e===Xu?void 0:Xu].filter(i=>!!i)});n.common.issues.push(r)}class cr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const r=[];for(const i of e){if(i.status==="aborted")return Gt;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,e){const r=[];for(const i of e){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return cr.mergeObjectSync(t,r)}static mergeObjectSync(t,e){const r={};for(const i of e){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Gt;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Gt=Object.freeze({status:"aborted"}),Zc=n=>({status:"dirty",value:n}),wr=n=>({status:"valid",value:n}),Sm=n=>n.status==="aborted",Im=n=>n.status==="dirty",rc=n=>n.status==="valid",$f=n=>typeof Promise<"u"&&n instanceof Promise;function u0(n,t,e,r){if(typeof t=="function"?n!==t||!r:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(n)}function lx(n,t,e,r,i){if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(n,e),e}var Bt;(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Bt||(Bt={}));var Af,Ef;class rs{constructor(t,e,r,i){this._cachedPath=[],this.parent=t,this.data=e,this._path=r,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const q_=(n,t)=>{if(rc(t))return{success:!0,data:t.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new Vr(n.common.issues);return this._error=e,this._error}}};function Jt(n){if(!n)return{};const{errorMap:t,invalid_type_error:e,required_error:r,description:i}=n;if(t&&(e||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,c)=>{var u,f;const{message:h}=n;return o.code==="invalid_enum_value"?{message:h??c.defaultError}:typeof c.data>"u"?{message:(u=h??r)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(f=h??e)!==null&&f!==void 0?f:c.defaultError}},description:i}}class re{get description(){return this._def.description}_getType(t){return bs(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:bs(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new cr,ctx:{common:t.parent.common,data:t.data,parsedType:bs(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if($f(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){var r;const i={common:{issues:[],async:(r=e==null?void 0:e.async)!==null&&r!==void 0?r:!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:bs(t)},s=this._parseSync({data:t,path:i.path,parent:i});return q_(i,s)}"~validate"(t){var e,r;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:bs(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:i});return rc(s)?{value:s.value}:{issues:i.common.issues}}catch(s){!((r=(e=s==null?void 0:s.message)===null||e===void 0?void 0:e.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:i}).then(s=>rc(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(t,e){const r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){const r={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:bs(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await($f(i)?i:Promise.resolve(i));return q_(r,s)}refine(t,e){const r=i=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(i):e;return this._refinement((i,s)=>{const o=t(i),c=()=>s.addIssue({code:gt.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(t,e){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof e=="function"?e(r,i):e),!1))}_refinement(t){return new Ei({schema:this,typeName:zt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Yi.create(this,this._def)}nullable(){return Qo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _i.create(this)}promise(){return el.create(this,this._def)}or(t){return Vf.create([this,t],this._def)}and(t){return Kf.create(this,t,this._def)}transform(t){return new Ei({...Jt(this._def),schema:this,typeName:zt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new Qf({...Jt(this._def),innerType:this,defaultValue:e,typeName:zt.ZodDefault})}brand(){return new Fw({typeName:zt.ZodBranded,type:this,...Jt(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new Jf({...Jt(this._def),innerType:this,catchValue:e,typeName:zt.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Dh.create(this,t)}readonly(){return Yf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const AM=/^c[^\s-]{8,}$/i,EM=/^[0-9a-z]+$/,vM=/^[0-9A-HJKMNP-TV-Z]{26}$/i,xM=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,RM=/^[a-z0-9_-]{21}$/i,SM=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,IM=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,kM=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,TM="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let yy;const OM=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,NM=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,CM=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,BM=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,PM=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,MM=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,fx="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",LM=new RegExp(`^${fx}$`);function hx(n){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`),t}function UM(n){return new RegExp(`^${hx(n)}$`)}function dx(n){let t=`${fx}T${hx(n)}`;const e=[];return e.push(n.local?"Z?":"Z"),n.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function DM(n,t){return!!((t==="v4"||!t)&&OM.test(n)||(t==="v6"||!t)&&CM.test(n))}function FM(n,t){if(!SM.test(n))return!1;try{const[e]=n.split("."),r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||!i.typ||!i.alg||t&&i.alg!==t)}catch{return!1}}function $M(n,t){return!!((t==="v4"||!t)&&NM.test(n)||(t==="v6"||!t)&&BM.test(n))}class wi extends re{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Rt.string){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:Rt.string,received:s.parsedType}),Gt}const r=new cr;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,c=t.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(t,i),o?At(i,{code:gt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&At(i,{code:gt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")kM.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"email",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")yy||(yy=new RegExp(TM,"u")),yy.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"emoji",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")xM.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"uuid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")RM.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"nanoid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")AM.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cuid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")EM.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cuid2",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")vM.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"ulid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),At(i,{validation:"url",code:gt.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"regex",code:gt.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?dx(s).test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?LM.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?UM(s).test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?IM.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"duration",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?DM(t.data,s.version)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"ip",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?FM(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"jwt",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?$M(t.data,s.version)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cidr",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?PM.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"base64",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?MM.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"base64url",code:gt.invalid_string,message:s.message}),r.dirty()):pe.assertNever(s);return{status:r.value,value:t.data}}_regex(t,e,r){return this.refinement(i=>t.test(i),{validation:e,code:gt.invalid_string,...Bt.errToObj(r)})}_addCheck(t){return new wi({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Bt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Bt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Bt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Bt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Bt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Bt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Bt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Bt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Bt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Bt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Bt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Bt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Bt.errToObj(t)})}datetime(t){var e,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(e=t==null?void 0:t.offset)!==null&&e!==void 0?e:!1,local:(r=t==null?void 0:t.local)!==null&&r!==void 0?r:!1,...Bt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Bt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Bt.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...Bt.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e==null?void 0:e.position,...Bt.errToObj(e==null?void 0:e.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...Bt.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...Bt.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...Bt.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...Bt.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...Bt.errToObj(e)})}nonempty(t){return this.min(1,Bt.errToObj(t))}trim(){return new wi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new wi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new wi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}wi.create=n=>{var t;return new wi({checks:[],typeName:zt.ZodString,coerce:(t=n==null?void 0:n.coerce)!==null&&t!==void 0?t:!1,...Jt(n)})};function HM(n,t){const e=(n.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=e>r?e:r,s=parseInt(n.toFixed(i).replace(".","")),o=parseInt(t.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class Wo extends re{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Rt.number){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:Rt.number,received:s.parsedType}),Gt}let r;const i=new cr;for(const s of this._def.checks)s.kind==="int"?pe.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),At(r,{code:gt.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?HM(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_finite,message:s.message}),i.dirty()):pe.assertNever(s);return{status:i.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,Bt.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Bt.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Bt.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Bt.toString(e))}setLimit(t,e,r,i){return new Wo({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Bt.toString(i)}]})}_addCheck(t){return new Wo({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Bt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Bt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Bt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Bt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Bt.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Bt.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:Bt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Bt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Bt.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&pe.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(e===null||r.value>e)&&(e=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(e)&&Number.isFinite(t)}}Wo.create=n=>new Wo({checks:[],typeName:zt.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...Jt(n)});class Zo extends re{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Rt.bigint)return this._getInvalidInput(t);let r;const i=new cr;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):pe.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return At(e,{code:gt.invalid_type,expected:Rt.bigint,received:e.parsedType}),Gt}gte(t,e){return this.setLimit("min",t,!0,Bt.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Bt.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Bt.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Bt.toString(e))}setLimit(t,e,r,i){return new Zo({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Bt.toString(i)}]})}_addCheck(t){return new Zo({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Bt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Bt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Bt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Bt.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Bt.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}Zo.create=n=>{var t;return new Zo({checks:[],typeName:zt.ZodBigInt,coerce:(t=n==null?void 0:n.coerce)!==null&&t!==void 0?t:!1,...Jt(n)})};class Hf extends re{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Rt.boolean){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.boolean,received:r.parsedType}),Gt}return wr(t.data)}}Hf.create=n=>new Hf({typeName:zt.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...Jt(n)});class ic extends re{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Rt.date){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:Rt.date,received:s.parsedType}),Gt}if(isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_date}),Gt}const r=new cr;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):pe.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ic({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:Bt.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:Bt.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}ic.create=n=>new ic({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:zt.ZodDate,...Jt(n)});class l0 extends re{_parse(t){if(this._getType(t)!==Rt.symbol){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.symbol,received:r.parsedType}),Gt}return wr(t.data)}}l0.create=n=>new l0({typeName:zt.ZodSymbol,...Jt(n)});class zf extends re{_parse(t){if(this._getType(t)!==Rt.undefined){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.undefined,received:r.parsedType}),Gt}return wr(t.data)}}zf.create=n=>new zf({typeName:zt.ZodUndefined,...Jt(n)});class Gf extends re{_parse(t){if(this._getType(t)!==Rt.null){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.null,received:r.parsedType}),Gt}return wr(t.data)}}Gf.create=n=>new Gf({typeName:zt.ZodNull,...Jt(n)});class tl extends re{constructor(){super(...arguments),this._any=!0}_parse(t){return wr(t.data)}}tl.create=n=>new tl({typeName:zt.ZodAny,...Jt(n)});class Ya extends re{constructor(){super(...arguments),this._unknown=!0}_parse(t){return wr(t.data)}}Ya.create=n=>new Ya({typeName:zt.ZodUnknown,...Jt(n)});class js extends re{_parse(t){const e=this._getOrReturnCtx(t);return At(e,{code:gt.invalid_type,expected:Rt.never,received:e.parsedType}),Gt}}js.create=n=>new js({typeName:zt.ZodNever,...Jt(n)});class f0 extends re{_parse(t){if(this._getType(t)!==Rt.undefined){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.void,received:r.parsedType}),Gt}return wr(t.data)}}f0.create=n=>new f0({typeName:zt.ZodVoid,...Jt(n)});class _i extends re{_parse(t){const{ctx:e,status:r}=this._processInputParams(t),i=this._def;if(e.parsedType!==Rt.array)return At(e,{code:gt.invalid_type,expected:Rt.array,received:e.parsedType}),Gt;if(i.exactLength!==null){const o=e.data.length>i.exactLength.value,c=e.data.length<i.exactLength.value;(o||c)&&(At(e,{code:o?gt.too_big:gt.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&e.data.length<i.minLength.value&&(At(e,{code:gt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&e.data.length>i.maxLength.value&&(At(e,{code:gt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),e.common.async)return Promise.all([...e.data].map((o,c)=>i.type._parseAsync(new rs(e,o,e.path,c)))).then(o=>cr.mergeArray(r,o));const s=[...e.data].map((o,c)=>i.type._parseSync(new rs(e,o,e.path,c)));return cr.mergeArray(r,s)}get element(){return this._def.type}min(t,e){return new _i({...this._def,minLength:{value:t,message:Bt.toString(e)}})}max(t,e){return new _i({...this._def,maxLength:{value:t,message:Bt.toString(e)}})}length(t,e){return new _i({...this._def,exactLength:{value:t,message:Bt.toString(e)}})}nonempty(t){return this.min(1,t)}}_i.create=(n,t)=>new _i({type:n,minLength:null,maxLength:null,exactLength:null,typeName:zt.ZodArray,...Jt(t)});function zc(n){if(n instanceof tn){const t={};for(const e in n.shape){const r=n.shape[e];t[e]=Yi.create(zc(r))}return new tn({...n._def,shape:()=>t})}else return n instanceof _i?new _i({...n._def,type:zc(n.element)}):n instanceof Yi?Yi.create(zc(n.unwrap())):n instanceof Qo?Qo.create(zc(n.unwrap())):n instanceof is?is.create(n.items.map(t=>zc(t))):n}class tn extends re{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=pe.objectKeys(t);return this._cached={shape:t,keys:e}}_parse(t){if(this._getType(t)!==Rt.object){const f=this._getOrReturnCtx(t);return At(f,{code:gt.invalid_type,expected:Rt.object,received:f.parsedType}),Gt}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof js&&this._def.unknownKeys==="strip"))for(const f in i.data)o.includes(f)||c.push(f);const u=[];for(const f of o){const h=s[f],y=i.data[f];u.push({key:{status:"valid",value:f},value:h._parse(new rs(i,y,i.path,f)),alwaysSet:f in i.data})}if(this._def.catchall instanceof js){const f=this._def.unknownKeys;if(f==="passthrough")for(const h of c)u.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(f==="strict")c.length>0&&(At(i,{code:gt.unrecognized_keys,keys:c}),r.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const f=this._def.catchall;for(const h of c){const y=i.data[h];u.push({key:{status:"valid",value:h},value:f._parse(new rs(i,y,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const f=[];for(const h of u){const y=await h.key,A=await h.value;f.push({key:y,value:A,alwaysSet:h.alwaysSet})}return f}).then(f=>cr.mergeObjectSync(r,f)):cr.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return Bt.errToObj,new tn({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,r)=>{var i,s,o,c;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,e,r).message)!==null&&o!==void 0?o:r.defaultError;return e.code==="unrecognized_keys"?{message:(c=Bt.errToObj(t).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new tn({...this._def,unknownKeys:"strip"})}passthrough(){return new tn({...this._def,unknownKeys:"passthrough"})}extend(t){return new tn({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new tn({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:zt.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new tn({...this._def,catchall:t})}pick(t){const e={};return pe.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(e[r]=this.shape[r])}),new tn({...this._def,shape:()=>e})}omit(t){const e={};return pe.objectKeys(this.shape).forEach(r=>{t[r]||(e[r]=this.shape[r])}),new tn({...this._def,shape:()=>e})}deepPartial(){return zc(this)}partial(t){const e={};return pe.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?e[r]=i:e[r]=i.optional()}),new tn({...this._def,shape:()=>e})}required(t){const e={};return pe.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])e[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Yi;)s=s._def.innerType;e[r]=s}}),new tn({...this._def,shape:()=>e})}keyof(){return px(pe.objectKeys(this.shape))}}tn.create=(n,t)=>new tn({shape:()=>n,unknownKeys:"strip",catchall:js.create(),typeName:zt.ZodObject,...Jt(t)});tn.strictCreate=(n,t)=>new tn({shape:()=>n,unknownKeys:"strict",catchall:js.create(),typeName:zt.ZodObject,...Jt(t)});tn.lazycreate=(n,t)=>new tn({shape:n,unknownKeys:"strip",catchall:js.create(),typeName:zt.ZodObject,...Jt(t)});class Vf extends re{_parse(t){const{ctx:e}=this._processInputParams(t),r=this._def.options;function i(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return e.common.issues.push(...c.ctx.common.issues),c.result;const o=s.map(c=>new Vr(c.ctx.common.issues));return At(e,{code:gt.invalid_union,unionErrors:o}),Gt}if(e.common.async)return Promise.all(r.map(async s=>{const o={...e,common:{...e.common,issues:[]},parent:null};return{result:await s._parseAsync({data:e.data,path:e.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of r){const f={...e,common:{...e.common,issues:[]},parent:null},h=u._parseSync({data:e.data,path:e.path,parent:f});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(s)return e.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(u=>new Vr(u));return At(e,{code:gt.invalid_union,unionErrors:c}),Gt}}get options(){return this._def.options}}Vf.create=(n,t)=>new Vf({options:n,typeName:zt.ZodUnion,...Jt(t)});const ps=n=>n instanceof Wf?ps(n.schema):n instanceof Ei?ps(n.innerType()):n instanceof Zf?[n.value]:n instanceof qo?n.options:n instanceof qf?pe.objectValues(n.enum):n instanceof Qf?ps(n._def.innerType):n instanceof zf?[void 0]:n instanceof Gf?[null]:n instanceof Yi?[void 0,...ps(n.unwrap())]:n instanceof Qo?[null,...ps(n.unwrap())]:n instanceof Fw||n instanceof Yf?ps(n.unwrap()):n instanceof Jf?ps(n._def.innerType):[];class rp extends re{_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==Rt.object)return At(e,{code:gt.invalid_type,expected:Rt.object,received:e.parsedType}),Gt;const r=this.discriminator,i=e.data[r],s=this.optionsMap.get(i);return s?e.common.async?s._parseAsync({data:e.data,path:e.path,parent:e}):s._parseSync({data:e.data,path:e.path,parent:e}):(At(e,{code:gt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Gt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,e,r){const i=new Map;for(const s of e){const o=ps(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const c of o){if(i.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);i.set(c,s)}}return new rp({typeName:zt.ZodDiscriminatedUnion,discriminator:t,options:e,optionsMap:i,...Jt(r)})}}function km(n,t){const e=bs(n),r=bs(t);if(n===t)return{valid:!0,data:n};if(e===Rt.object&&r===Rt.object){const i=pe.objectKeys(t),s=pe.objectKeys(n).filter(c=>i.indexOf(c)!==-1),o={...n,...t};for(const c of s){const u=km(n[c],t[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(e===Rt.array&&r===Rt.array){if(n.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<n.length;s++){const o=n[s],c=t[s],u=km(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return e===Rt.date&&r===Rt.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}class Kf extends re{_parse(t){const{status:e,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(Sm(s)||Sm(o))return Gt;const c=km(s.value,o.value);return c.valid?((Im(s)||Im(o))&&e.dirty(),{status:e.value,value:c.data}):(At(r,{code:gt.invalid_intersection_types}),Gt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Kf.create=(n,t,e)=>new Kf({left:n,right:t,typeName:zt.ZodIntersection,...Jt(e)});class is extends re{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Rt.array)return At(r,{code:gt.invalid_type,expected:Rt.array,received:r.parsedType}),Gt;if(r.data.length<this._def.items.length)return At(r,{code:gt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Gt;!this._def.rest&&r.data.length>this._def.items.length&&(At(r,{code:gt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const s=[...r.data].map((o,c)=>{const u=this._def.items[c]||this._def.rest;return u?u._parse(new rs(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>cr.mergeArray(e,o)):cr.mergeArray(e,s)}get items(){return this._def.items}rest(t){return new is({...this._def,rest:t})}}is.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new is({items:n,typeName:zt.ZodTuple,rest:null,...Jt(t)})};class jf extends re{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Rt.object)return At(r,{code:gt.invalid_type,expected:Rt.object,received:r.parsedType}),Gt;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in r.data)i.push({key:s._parse(new rs(r,c,r.path,c)),value:o._parse(new rs(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?cr.mergeObjectAsync(e,i):cr.mergeObjectSync(e,i)}get element(){return this._def.valueType}static create(t,e,r){return e instanceof re?new jf({keyType:t,valueType:e,typeName:zt.ZodRecord,...Jt(r)}):new jf({keyType:wi.create(),valueType:t,typeName:zt.ZodRecord,...Jt(e)})}}class h0 extends re{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Rt.map)return At(r,{code:gt.invalid_type,expected:Rt.map,received:r.parsedType}),Gt;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([c,u],f)=>({key:i._parse(new rs(r,c,r.path,[f,"key"])),value:s._parse(new rs(r,u,r.path,[f,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of o){const f=await u.key,h=await u.value;if(f.status==="aborted"||h.status==="aborted")return Gt;(f.status==="dirty"||h.status==="dirty")&&e.dirty(),c.set(f.value,h.value)}return{status:e.value,value:c}})}else{const c=new Map;for(const u of o){const f=u.key,h=u.value;if(f.status==="aborted"||h.status==="aborted")return Gt;(f.status==="dirty"||h.status==="dirty")&&e.dirty(),c.set(f.value,h.value)}return{status:e.value,value:c}}}}h0.create=(n,t,e)=>new h0({valueType:t,keyType:n,typeName:zt.ZodMap,...Jt(e)});class sc extends re{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Rt.set)return At(r,{code:gt.invalid_type,expected:Rt.set,received:r.parsedType}),Gt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(At(r,{code:gt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),e.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(At(r,{code:gt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),e.dirty());const s=this._def.valueType;function o(u){const f=new Set;for(const h of u){if(h.status==="aborted")return Gt;h.status==="dirty"&&e.dirty(),f.add(h.value)}return{status:e.value,value:f}}const c=[...r.data.values()].map((u,f)=>s._parse(new rs(r,u,r.path,f)));return r.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(t,e){return new sc({...this._def,minSize:{value:t,message:Bt.toString(e)}})}max(t,e){return new sc({...this._def,maxSize:{value:t,message:Bt.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}sc.create=(n,t)=>new sc({valueType:n,minSize:null,maxSize:null,typeName:zt.ZodSet,...Jt(t)});class iu extends re{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==Rt.function)return At(e,{code:gt.invalid_type,expected:Rt.function,received:e.parsedType}),Gt;function r(c,u){return c0({data:c,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,a0(),Xu].filter(f=>!!f),issueData:{code:gt.invalid_arguments,argumentsError:u}})}function i(c,u){return c0({data:c,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,a0(),Xu].filter(f=>!!f),issueData:{code:gt.invalid_return_type,returnTypeError:u}})}const s={errorMap:e.common.contextualErrorMap},o=e.data;if(this._def.returns instanceof el){const c=this;return wr(async function(...u){const f=new Vr([]),h=await c._def.args.parseAsync(u,s).catch(b=>{throw f.addIssue(r(u,b)),f}),y=await Reflect.apply(o,this,h);return await c._def.returns._def.type.parseAsync(y,s).catch(b=>{throw f.addIssue(i(y,b)),f})})}else{const c=this;return wr(function(...u){const f=c._def.args.safeParse(u,s);if(!f.success)throw new Vr([r(u,f.error)]);const h=Reflect.apply(o,this,f.data),y=c._def.returns.safeParse(h,s);if(!y.success)throw new Vr([i(h,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new iu({...this._def,args:is.create(t).rest(Ya.create())})}returns(t){return new iu({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,e,r){return new iu({args:t||is.create([]).rest(Ya.create()),returns:e||Ya.create(),typeName:zt.ZodFunction,...Jt(r)})}}class Wf extends re{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}Wf.create=(n,t)=>new Wf({getter:n,typeName:zt.ZodLazy,...Jt(t)});class Zf extends re{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return At(e,{received:e.data,code:gt.invalid_literal,expected:this._def.value}),Gt}return{status:"valid",value:t.data}}get value(){return this._def.value}}Zf.create=(n,t)=>new Zf({value:n,typeName:zt.ZodLiteral,...Jt(t)});function px(n,t){return new qo({values:n,typeName:zt.ZodEnum,...Jt(t)})}class qo extends re{constructor(){super(...arguments),Af.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),r=this._def.values;return At(e,{expected:pe.joinValues(r),received:e.parsedType,code:gt.invalid_type}),Gt}if(u0(this,Af)||lx(this,Af,new Set(this._def.values)),!u0(this,Af).has(t.data)){const e=this._getOrReturnCtx(t),r=this._def.values;return At(e,{received:e.data,code:gt.invalid_enum_value,options:r}),Gt}return wr(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return qo.create(t,{...this._def,...e})}exclude(t,e=this._def){return qo.create(this.options.filter(r=>!t.includes(r)),{...this._def,...e})}}Af=new WeakMap;qo.create=px;class qf extends re{constructor(){super(...arguments),Ef.set(this,void 0)}_parse(t){const e=pe.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Rt.string&&r.parsedType!==Rt.number){const i=pe.objectValues(e);return At(r,{expected:pe.joinValues(i),received:r.parsedType,code:gt.invalid_type}),Gt}if(u0(this,Ef)||lx(this,Ef,new Set(pe.getValidEnumValues(this._def.values))),!u0(this,Ef).has(t.data)){const i=pe.objectValues(e);return At(r,{received:r.data,code:gt.invalid_enum_value,options:i}),Gt}return wr(t.data)}get enum(){return this._def.values}}Ef=new WeakMap;qf.create=(n,t)=>new qf({values:n,typeName:zt.ZodNativeEnum,...Jt(t)});class el extends re{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==Rt.promise&&e.common.async===!1)return At(e,{code:gt.invalid_type,expected:Rt.promise,received:e.parsedType}),Gt;const r=e.parsedType===Rt.promise?e.data:Promise.resolve(e.data);return wr(r.then(i=>this._def.type.parseAsync(i,{path:e.path,errorMap:e.common.contextualErrorMap})))}}el.create=(n,t)=>new el({type:n,typeName:zt.ZodPromise,...Jt(t)});class Ei extends re{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===zt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{At(r,o),o.fatal?e.abort():e.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async c=>{if(e.value==="aborted")return Gt;const u=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return u.status==="aborted"?Gt:u.status==="dirty"||e.value==="dirty"?Zc(u.value):u});{if(e.value==="aborted")return Gt;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?Gt:c.status==="dirty"||e.value==="dirty"?Zc(c.value):c}}if(i.type==="refinement"){const o=c=>{const u=i.refinement(c,s);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?Gt:(c.status==="dirty"&&e.dirty(),o(c.value),{status:e.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?Gt:(c.status==="dirty"&&e.dirty(),o(c.value).then(()=>({status:e.value,value:c.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!rc(o))return o;const c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>rc(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:e.value,value:c})):o);pe.assertNever(i)}}Ei.create=(n,t,e)=>new Ei({schema:n,typeName:zt.ZodEffects,effect:t,...Jt(e)});Ei.createWithPreprocess=(n,t,e)=>new Ei({schema:t,effect:{type:"preprocess",transform:n},typeName:zt.ZodEffects,...Jt(e)});class Yi extends re{_parse(t){return this._getType(t)===Rt.undefined?wr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Yi.create=(n,t)=>new Yi({innerType:n,typeName:zt.ZodOptional,...Jt(t)});class Qo extends re{_parse(t){return this._getType(t)===Rt.null?wr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Qo.create=(n,t)=>new Qo({innerType:n,typeName:zt.ZodNullable,...Jt(t)});class Qf extends re{_parse(t){const{ctx:e}=this._processInputParams(t);let r=e.data;return e.parsedType===Rt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}Qf.create=(n,t)=>new Qf({innerType:n,typeName:zt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Jt(t)});class Jf extends re{_parse(t){const{ctx:e}=this._processInputParams(t),r={...e,common:{...e.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return $f(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Vr(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Vr(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Jf.create=(n,t)=>new Jf({innerType:n,typeName:zt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Jt(t)});class d0 extends re{_parse(t){if(this._getType(t)!==Rt.nan){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.nan,received:r.parsedType}),Gt}return{status:"valid",value:t.data}}}d0.create=n=>new d0({typeName:zt.ZodNaN,...Jt(n)});const zM=Symbol("zod_brand");class Fw extends re{_parse(t){const{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}}class Dh extends re{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Gt:s.status==="dirty"?(e.dirty(),Zc(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Gt:i.status==="dirty"?(e.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,e){return new Dh({in:t,out:e,typeName:zt.ZodPipeline})}}class Yf extends re{_parse(t){const e=this._def.innerType._parse(t),r=i=>(rc(i)&&(i.value=Object.freeze(i.value)),i);return $f(e)?e.then(i=>r(i)):r(e)}unwrap(){return this._def.innerType}}Yf.create=(n,t)=>new Yf({innerType:n,typeName:zt.ZodReadonly,...Jt(t)});function gx(n,t={},e){return n?tl.create().superRefine((r,i)=>{var s,o;if(!n(r)){const c=typeof t=="function"?t(r):typeof t=="string"?{message:t}:t,u=(o=(s=c.fatal)!==null&&s!==void 0?s:e)!==null&&o!==void 0?o:!0,f=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...f,fatal:u})}}):tl.create()}const GM={object:tn.lazycreate};var zt;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(zt||(zt={}));const VM=(n,t={message:`Input not instance of ${n.name}`})=>gx(e=>e instanceof n,t),yx=wi.create,mx=Wo.create,KM=d0.create,jM=Zo.create,wx=Hf.create,WM=ic.create,ZM=l0.create,qM=zf.create,QM=Gf.create,JM=tl.create,YM=Ya.create,XM=js.create,tL=f0.create,eL=_i.create,nL=tn.create,rL=tn.strictCreate,iL=Vf.create,sL=rp.create,oL=Kf.create,aL=is.create,cL=jf.create,uL=h0.create,lL=sc.create,fL=iu.create,hL=Wf.create,dL=Zf.create,pL=qo.create,gL=qf.create,yL=el.create,Q_=Ei.create,mL=Yi.create,wL=Qo.create,bL=Ei.createWithPreprocess,_L=Dh.create,AL=()=>yx().optional(),EL=()=>mx().optional(),vL=()=>wx().optional(),xL={string:n=>wi.create({...n,coerce:!0}),number:n=>Wo.create({...n,coerce:!0}),boolean:n=>Hf.create({...n,coerce:!0}),bigint:n=>Zo.create({...n,coerce:!0}),date:n=>ic.create({...n,coerce:!0})},RL=Gt;var po=Object.freeze({__proto__:null,defaultErrorMap:Xu,setErrorMap:bM,getErrorMap:a0,makeIssue:c0,EMPTY_PATH:_M,addIssueToContext:At,ParseStatus:cr,INVALID:Gt,DIRTY:Zc,OK:wr,isAborted:Sm,isDirty:Im,isValid:rc,isAsync:$f,get util(){return pe},get objectUtil(){return Rm},ZodParsedType:Rt,getParsedType:bs,ZodType:re,datetimeRegex:dx,ZodString:wi,ZodNumber:Wo,ZodBigInt:Zo,ZodBoolean:Hf,ZodDate:ic,ZodSymbol:l0,ZodUndefined:zf,ZodNull:Gf,ZodAny:tl,ZodUnknown:Ya,ZodNever:js,ZodVoid:f0,ZodArray:_i,ZodObject:tn,ZodUnion:Vf,ZodDiscriminatedUnion:rp,ZodIntersection:Kf,ZodTuple:is,ZodRecord:jf,ZodMap:h0,ZodSet:sc,ZodFunction:iu,ZodLazy:Wf,ZodLiteral:Zf,ZodEnum:qo,ZodNativeEnum:qf,ZodPromise:el,ZodEffects:Ei,ZodTransformer:Ei,ZodOptional:Yi,ZodNullable:Qo,ZodDefault:Qf,ZodCatch:Jf,ZodNaN:d0,BRAND:zM,ZodBranded:Fw,ZodPipeline:Dh,ZodReadonly:Yf,custom:gx,Schema:re,ZodSchema:re,late:GM,get ZodFirstPartyTypeKind(){return zt},coerce:xL,any:JM,array:eL,bigint:jM,boolean:wx,date:WM,discriminatedUnion:sL,effect:Q_,enum:pL,function:fL,instanceof:VM,intersection:oL,lazy:hL,literal:dL,map:uL,nan:KM,nativeEnum:gL,never:XM,null:QM,nullable:wL,number:mx,object:nL,oboolean:vL,onumber:EL,optional:mL,ostring:AL,pipeline:_L,preprocess:bL,promise:yL,record:cL,set:lL,strictObject:rL,string:yx,symbol:ZM,transformer:Q_,tuple:aL,undefined:qM,union:iL,unknown:YM,void:tL,NEVER:RL,ZodIssueCode:gt,quotelessJson:wM,ZodError:Vr});const $w=Qi.getInstance(),bx=po.object({username:po.string(),address:po.string(),timestamp:po.number(),index:po.number(),signature:po.string()}),SL=po.object({topic:po.string(),messageSender:bx});function IL(n){const t=SL.safeParse(n);return t.success?n.messageSender&&!kL(n.messageSender)?(console.warn("Invalid messageSender"),!1):!0:($w.warn(t.error.format()),!1)}function kL(n){const t=bx.safeParse(n);return t.success?TL(n):($w.warn(t.error.format()),!1)}function TL(n){try{const t={username:n.username,address:n.address,timestamp:n.timestamp},e=new TextEncoder,r=or.concatBytes(e.encode(`Ethereum Signed Message:
|
|
11
|
-
32`),
|
|
4
|
+
`)}function Sd(c){return c.charAt(0).toUpperCase()+c.slice(1)}function $b(c){return c.charAt(0).toLowerCase()+c.slice(1)}function Hb(c){if(!c)return!1;const l=c.charCodeAt(0);return l>=65&&l<=90||l>=97&&l<=122}function zb(c){if(!c)return!1;const l=c.charCodeAt(0);return l>=48&&l<=57}function df(c){return Hb(c)||zb(c)}const VO=`
|
|
5
|
+
\r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");function KO(c){return VO.includes(c)}function jO(c){return df(c)||c==="."||c==="["||c==="]"||c==="_"}function WO(c,l,d,g,x){return c.slice(0,l)+g+c.slice(l,l+d)+x+c.slice(l+d)}function Gb(c,l,d=0){const g=l.exec(c.slice(d));return g?{index:g.index,match:g[0]}:null}function Vb(c,l,d=!0){if(!d)return l.every(x=>x instanceof RegExp?x.test(c):c.indexOf(x,0)!==-1);let g=0;for(const x of l)if(x instanceof RegExp){const L=Gb(c,x,g);if(!L)return!1;g=L.index+L.match.length}else{const L=c.indexOf(x,g);if(L===-1)return!1;g=L+x.length}return!0}function ZO(c,l,d=!0){let g=0;for(const x of l){let L=!1;for(;!L&&g<c.length;)Vb(c[g],x,d)&&(L=!0),g++;if(!L)return!1}return!0}function qO(c){return c.match(/"|,/)?`"${c.replace(/"/g,'""')}"`:c}function Dc(c,l,d=0){let g=-1;for(const x of l){const L=c.indexOf(x,d);L!==-1&&(g===-1||L<g)&&(g=L)}return g}function QO(c,l=0){for(let d=l;d<c.length;d++)if(KO(c[d]))return d;return-1}function JO(c,l=0){for(let d=l;d<c.length;d++)if(c[d]==="#"&&df(c[d+1]))return d;return-1}function Kb(c,l,d=0){return c.slice(0,d).lastIndexOf(l)}function jb(c,l=0,d="{",g="}"){let x=1;for(let L=l;L<c.length;L++)if(c.slice(L,L+g.length)===g){if(--x===0)return L}else c.slice(L,L+d.length)===d&&x++;return-1}function Wb(c,l){const d=l.wordBoundary?Dc(c,[`${l.opening} `,`${l.opening}
|
|
6
|
+
`],l.start||0):c.indexOf(l.opening,l.start||0);if(d===-1)return null;const g=jb(c,d+l.opening.length,l.opening,l.closing);return g===-1?null:l.exclusive?c.slice(d+l.opening.length,g):c.slice(d,g+l.closing.length)}function YO(c,l){const d=[];let g=l.wordBoundary?Dc(c,[`${l.opening} `,`${l.opening}
|
|
7
|
+
`],l.start||0):c.indexOf(l.opening,l.start||0);for(;;){if(g===-1)return d;const x=Wb(c,{...l,start:g});if(!x)return d;d.push(x),g=l.wordBoundary?Dc(c,[`${l.opening} `,`${l.opening}
|
|
8
|
+
`],g+x.length):c.indexOf(l.opening,g+x.length)}}function XO(c,l,d){let g=0;for(;;){const x=n.Strings.extractBlock(c,{...d,start:g});if(!x)return c;const L=l(x);g=c.indexOf(x,g)+L.length,c=c.replace(x,L)}}function tN(c,l){const d=[];let g=0;for(;g<c.length;){const x=c.indexOf(l,g);if(x===-1){d.push({string:c.slice(g),symbol:null});break}const L=c.indexOf(l,x+l.length);if(x>g&&L!==-1&&d.push({string:c.slice(g,x),symbol:null}),L===-1){d.push({string:c.slice(g),symbol:null});break}d.push({string:c.slice(x+l.length,L),symbol:l}),g=L+l.length}return d}function eN(c){const l=[];let d=0;for(;d<c.length;){const g=JO(c,d);if(g===-1){l.push({string:c.slice(d),symbol:null});break}const x=QO(c,g+1);if(x===-1){l.push({string:c.slice(d,g),symbol:null}),l.push({string:c.slice(g+1),symbol:"#"});break}g>d&&l.push({string:c.slice(d,g),symbol:null}),l.push({string:c.slice(g+1,x),symbol:"#"}),d=x}return l}function nN(c){const l=[];let d=0;for(;d<c.length;){const g=Dc(c,["http://","https://"],d);if(g===-1){l.push({string:c.slice(d),symbol:null});break}const x=Dc(c,[" ",`
|
|
9
|
+
`],g);if(x===-1){g>d&&l.push({string:c.slice(d,g),symbol:null}),l.push({string:c.slice(g),symbol:"http"});break}g>d&&l.push({string:c.slice(d,g),symbol:null}),l.push({string:c.slice(g,x),symbol:"http"}),d=x}return l}const Zb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qb="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function rN(c){return Qb(c,Zb)}function iN(c){return Jb(c,Zb)}function sN(c){return Qb(c,qb)}function oN(c){return Jb(c,qb)}function Qb(c,l){const d="=",g=l.length;let x=0,L=0;const Q=[];for(let lt=0;lt<c.length;lt++){const at=c[lt];if(at===d)break;const Ct=l.indexOf(at);if(Ct===-1)throw new Error(`Invalid character: ${at}`);L=L<<Math.log2(g)|Ct,x+=Math.log2(g),x>=8&&(x-=8,Q.push(L>>x&255))}return new Uint8Array(Q)}function Jb(c,l){const d=l.length;let g=0,x=0,L="";for(let Q=0;Q<c.length;Q++)for(x=x<<8|c[Q],g+=8;g>=Math.log2(d);)g-=Math.log2(d),L+=l[x>>g&d-1];return g>0&&(L+=l[x<<Math.log2(d)-g&d-1]),L.length%4!==0&&(L+="=".repeat(4-L.length%4)),L}function aN(c){c.startsWith("0x")&&(c=c.slice(2));const l=c.length/2,d=new Uint8Array(l);for(let g=0;g<l;g++){const x=parseInt(c.slice(g*2,g*2+2),16);d[g]=x}return d}function cN(c){return Array.from(c).map(l=>l.toString(16).padStart(2,"0")).join("")}function uN(c,l){const d=c.split("/").filter(L=>L),g=l.split("/").filter(L=>L);if(d.length!==g.length)return null;const x={};for(let L=0;L<d.length;L++){const Q=d[L];if(Q.startsWith(":"))x[Q.slice(1)]=g[L];else if(Q!==g[L])return null}return x}function bg(c,l,d){const g=[];for(const x of d)x!==l&&g.push(c.replace(l,x));return g}function lN(c,l,d,g=Math.random){const x=n.Arrays.shuffle(l.map(Q=>({variants:n.Arrays.shuffle(Q.variants.map(lt=>lt),g),avoid:Q.avoid})),g),L=[];for(const Q of x){const lt=Q.variants.filter(Ct=>Ct!==Q.avoid),at=lt.find(Ct=>c.includes(Ct));if(at&&(ao(L,bg(c,at,lt)),L.length>=d))break}if(L.length<d)for(const Q of x){const lt=Q.variants.find(at=>c.includes(at));if(lt&&(ao(L,bg(c,lt,Q.variants)),L.length>=d))break}return L.slice(0,d)}function fN(c,l,d,g=!1){const x=new RegExp(g?`(?<=\\s|^)${l}(?=\\s|$)`:`\\b${l}\\b`,"g");return c.replace(x,d)}function hN(c,l){const d=/\b[A-Z][a-zA-Z0-9]*\b/g;return c.replace(d,g=>g.toUpperCase()===g?g:l(g))}function dN(c){return c.replace(/<[^>]*>/g,"")}function Yb(c){const l=c.lastIndexOf(" ");if(l===-1)return{line:c,rest:""};const d=c.slice(0,l),g=c.slice(l+1);return{line:d,rest:g}}function pN(c,l={}){return[...c].reduce((d,g)=>d+(l[g]||1),0)}function gN(c,l,d={}){const g=[];let x="",L=0;for(let Q=0;Q<c.length;Q++){const lt=c[Q],at=d[lt]||1;if(x+=lt,L+=at,L>l){const{line:Ct,rest:Be}=Yb(x);g.push(Ct),x=Be,L=Be.split("").map(Bn=>d[Bn]||1).reduce((Bn,zc)=>Bn+zc,0)}}return x&&g.push(x),g}function yN(c,l){const d=[];for(let g=0;g<=c.length;g++)d[g]=[g];for(let g=0;g<=l.length;g++)d[0][g]=g;for(let g=1;g<=c.length;g++)for(let x=1;x<=l.length;x++){const L=c[g-1]===l[x-1]?0:1;d[g][x]=Math.min(d[g-1][x]+1,d[g][x-1]+1,d[g-1][x-1]+L)}return d[c.length][l.length]}function _g(c,l){return new RegExp(`\\b${l}\\b`).test(c)}function mN(c,l,d){return d==="any"?l.some(g=>_g(c,g)):l.every(g=>_g(c,g))}function wN(c){const l={},d=c.match(/([a-z\-]+)="([^"]+)"/g);if(d)for(const g of d){const[x,L]=yg(g,"=");l[x]=L.slice(1,L.length-1)}return l}function kd(c,l,d=[]){let g="";for(;l<c.length&&(df(c[l])||d.includes(c[l]));)g+=c[l++];return g}function bN(c,l,d="$",g=":"){for(const x in l)c=Xb(c,x,l[x],d,g);return c=t_(c),c}function Xb(c,l,d,g="$",x=":"){if(d==="")return c;let L=c.indexOf(`${g}${l}`);for(;L!==-1;){if(c[L+l.length+1]===x)if(c[L+l.length+2]===x)c=c.replace(`${g}${l}${x}${x}`,d);else{const Q=kd(c,L+l.length+2,["_"]);c=c.replace(`${g}${l}${x}${Q}`,d)}else c=c.replace(`${g}${l}`,d);L=c.indexOf(`${g}${l}`,L+d.length)}return c}function t_(c,l="$",d=":"){let g=c.indexOf(l);for(;g!==-1;){const x=kd(c,g+1);if(c[g+x.length+1]===d)if(c[g+x.length+2]===d)c=c.replace(`${l}${x}${d}${d}`,"");else{const L=kd(c,g+x.length+2);c=c.replace(`${l}${x}${d}${L}`,L)}g=c.indexOf(l,g+1)}return c}function _N(c,l){let d=c.indexOf("](");for(;d!==-1;){const g=Kb(c,"[",d),x=c.indexOf(")",d);if(g!==-1&&x!==-1){const[L,Q]=c.slice(g+1,x).split("]("),lt=l(L,Q);c=c.slice(0,g)+lt+c.slice(x+1)}d=c.indexOf("](",d+1)}return c}function e_(c,l=!0){const d=Object.entries(c).filter(([g,x])=>x!=null).map(([g,x])=>`${g}=${encodeURIComponent(x)}`).join("&");return d?(l?"?":"")+d:""}function AN(c){const l={},d=c.split("&");for(const g of d){const[x,L]=g.split("=");x&&L&&(l[x]=decodeURIComponent(L))}return l}function EN(c,l){return Object.prototype.hasOwnProperty.call(c,l)}function vN(c,l){let d=null,g=-1/0;for(const[x,L]of Object.entries(c)){const Q=l(L);Q>g&&(g=Q,d=x)}return d?[d,c[d]]:null}function xN(c,l,d,g){const x=c.find(Q=>Q[l]===d),L=c.find(Q=>Q[l]===d+g);x&&L?(x[l]=d+g,L[l]=d):x&&(x[l]=d+g),c.sort((Q,lt)=>ha(Q[l])-ha(lt[l])),c.forEach((Q,lt)=>Q[l]=lt+1)}function RN(c){const l=Object.keys(c);if(l.length===1)return c[l[0]];throw new Error("Expected object to have a single key")}function IN(c,l=":"){return Object.fromEntries(c.map(d=>yg(d,l)).map(d=>d[0]&&d[1]?[hf(d[0]),hf(d[1])]:null).filter(d=>d))}function SN(c,l,d){return s_(c,l)+e_(d||{})}function kN(c,l=",",d='"'){const g=[];let x="",L=!1;const Q=c.split("");for(const lt of Q)lt===l&&!L?(g.push(x),x=""):lt===d&&(!x&&!L||L)?L=!L:x+=lt;return g.push(x),g}function TN(c){return`[${Math.floor(c.progress*100)}%] ${Td(c.deltaMs)} out of ${Td(c.totalTimeMs)} (${Td(c.remainingTimeMs)} left) [${Math.round(c.baseTimeMs)} ms each]`}async function ON(c,l,d){for(let g=0;g<d;g++){try{if(await c())return!0}catch{}g<d-1&&await s(l)}return!1}function NN(c,l){const d=[];for(let g=c.length-1;g>=0;g--)l(c[g])&&d.push(c.splice(g,1)[0]);return d}function CN(c){return JSON.parse(JSON.stringify(c))}function BN(c){return Math.ceil((c||Date.now())/1e3)}function PN(c){return(c||new Date).toISOString().slice(0,10)}function MN(c){return(c||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")}function LN(c){const l=new Date(c);return new Date(l.getTime()-l.getTimezoneOffset()*6e4)}function UN(c){return new Date(c)}function Bi(c){return String(Math.floor(c)).padStart(2,"0")}function DN(c){let[l,d]=c.split(":");ue(parseInt(l,10))||(l="0"),ue(parseInt(d,10))||(d="0");let g=Rg(We(l),0,23),x=Rg(We(d),0,59);return`${Bi(g)}:${Bi(x)}`}function Td(c){const l=Math.floor(c/36e5);c=c%36e5;const d=Math.floor(c/6e4);c=c%6e4;const g=Math.floor(c/1e3);return l?`${Bi(l)}:${Bi(d)}:${Bi(g)}`:`${Bi(d)}:${Bi(g)}`}function pa(c){return Math.floor((Ye(c)?c.getTime():c)/864e5)}const FN={today:(c,l)=>Bi(c)+":"+Bi(l),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:c=>`${c}w`};function $N(c,l){const d=new Date((l==null?void 0:l.now)||Date.now()),g=(l==null?void 0:l.labels)||FN,x=Ye(c)?c:new Date(c);if(pa(d)===pa(x))return g.today(x.getUTCHours(),x.getUTCMinutes(),x.getUTCHours()>12);if(pa(d)-pa(x)===1)return g.yesterday();const L=Eg(x);return pa(d)-pa(x)<7?g[L.day]():g.weeks(Math.round((d.getTime()-x.getTime())/6048e5))}const n_={now:()=>"A few seconds",seconds:c=>`${c} seconds`,minutes:c=>`${c} minutes`,hours:c=>`${c} hours`,days:c=>`${c} days`,weeks:c=>`${c} weeks`};function r_(c,l){const d=(l==null?void 0:l.now)??Date.now(),g=(l==null?void 0:l.labels)||n_,x=n.Types.isDate(c)?c.getTime():c;let L=(d-x)/1e3;return L<10?g.now():L<120?g.seconds(Math.floor(L)):(L/=60,L<120?g.minutes(Math.floor(L)):(L/=60,L<48?g.hours(Math.floor(L)):(L/=24,L<14?g.days(Math.floor(L)):(L/=7,g.weeks(Math.floor(L))))))}function HN(c,l=n_){return r_(0,{now:c*1e3,labels:l})}function zN(c,l,d){const g=((d==null?void 0:d.now)??Date.now())-c,x=Math.floor(g/l),L=l/((d==null?void 0:d.precision)??1)-Math.ceil(g%l/((d==null?void 0:d.precision)??1));return{cycles:x,remaining:L}}const Ag={};function GN(c,l){return!Ag[c]||Date.now()>Ag[c]?(Ag[c]=Date.now()+l,!0):!1}const VN={s:1e3,m:6e4,h:36e5,d:864e5};function KN(c,l,d){return l=Ye(l)?l.getTime():l,d=d?Ye(d)?d.getTime():d:Date.now(),(d-l)/VN[c]}function jN(c,l,d,g){g||(g=Date.now());const x=l/d,L=g-c,Q=L/l,lt=Q*d,at=lt-L;return{deltaMs:L,progress:x,baseTimeMs:Q,totalTimeMs:lt,remainingTimeMs:at}}const WN={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function i_(c){return{zeroBasedIndex:c,day:WN[c]}}function Eg(c){return i_(c.getDay())}function ZN(c){return Eg(new Date(c))}function qN(c){return c*1e3}function QN(c){return c*6e4}function JN(c){return c*36e5}function YN(c){return c*864e5}const XN={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6};function t6(c){const l=parseFloat(c);if(isNaN(l))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),g=XN[d];if(!g)throw Error(`Unknown unit: "${d}"`);return l*g}const e6={b:1,byte:1,bytes:1,kb:1024,kilobyte:1024,kilobytes:1024,mb:1024**2,megabyte:1024**2,megabytes:1024**2,gb:1024**3,gigabyte:1024**3,gigabytes:1024**3,tb:1024**4,terabyte:1024**4,terabytes:1024**4};function n6(c){const l=parseFloat(c);if(isNaN(l))throw Error("makeDate got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),g=e6[d];if(!g)throw Error(`Unknown unit: "${d}"`);return l*g}function r6(c){return c.replace(/ +/g," ").replace(/^ /gm,"")}const vg={};async function i6(c,l,d){const g=Date.now(),x=vg[c];if(x&&x.validUntil>g)return x.value;const L=await d(),Q=g+l;return vg[c]={value:L,validUntil:Q},L}function s6(c){delete vg[c]}function s_(...c){return c.filter(l=>l).join("/").replace(new RegExp("(?<!:)\\/+","g"),"/")}function o6(c,l,d,g,x=!0){const L=c.indexOf(l),Q=c.indexOf(d,L+l.length);if(L===-1||Q===-1)throw Error("Start or end not found");return x?c.substring(0,L+l.length)+g+c.substring(Q):c.substring(0,L)+g+c.substring(Q+d.length)}function a6(c){let l="p";c.startsWith("#")?(l="h1",c=c.slice(1).trim()):c.startsWith("-")&&(l="li",c=c.slice(1).trim());const d=c[0]===c[0].toUpperCase(),g=/[.?!]$/.test(c),x=/:$/.test(c);return{type:l,isCapitalized:d,hasPunctuation:g,endsWithColon:x}}function c6(c,l="(",d=")"){let g=0,x=0;for(;x<c.length;)if(c.startsWith(l,x)?(g++,x+=l.length):c.startsWith(d,x)?(g--,x+=d.length):x++,g<0)return!1;return l===d?g%2===0:g===0}function u6(c){c=c.normalize("NFD").replace(/[\u0300-\u036f]/g,"");let l=c.length;for(;c=c.replace(/(\w+)[\s,']+\w+/g,"$1"),c.length!==l;)l=c.length;return c=c.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A"),c=c.replaceAll(/[a-z][a-zA-Z0-9]*/g,"a"),c=c.replaceAll(/[\u4E00-\u9FA5]+/g,"Z"),c}function o_(c){const l=Object.keys(c).sort((g,x)=>g.localeCompare(x)),d={};for(const g of l)d[g]=ga(c[g]);return d}function a_(c){const l=[];return c.sort((d,g)=>JSON.stringify(ga(d)).localeCompare(JSON.stringify(ga(g)))).forEach(d=>l.push(ga(d))),l}function ga(c){return Array.isArray(c)?a_(c):Je(c)?o_(c):c}function c_(c,l){return JSON.stringify(ga(c))===JSON.stringify(ga(l))}function l6(...c){for(let l=1;l<c.length;l++)if(!c_(c[l-1],c[l]))return!1;return!0}function f6(c){try{return JSON.parse(c)}catch{return null}}function h6(){let c=0;return{next:()=>c++}}function d6(c){let l=0;return{next:()=>c[l++%c.length]}}function p6(c){let l;return d=>{const g=d===c&&l!==c;return l=d,g}}function g6(c,l,d,g,x){const L={};for(const Q of Object.keys(l))L[Q]=[];L[g]=[],x&&(c=c.sort(x));for(const Q of c){const lt=Q[d],at=l[lt]?lt:g;L[at].length>=l[at]?L[g].push(Q):L[at].push(Q)}return L}function y6(c,l){const d=Object.keys(c),g=Object.keys(l);return{uniqueToA:d.filter(x=>!g.includes(x)),uniqueToB:g.filter(x=>!d.includes(x))}}function u_(c){const l=Object.keys(c);return l[Math.floor(Math.random()*l.length)]}function m6(c,l){const d=u_(c);return c[d]=l(c[d]),d}function w6(c){return c=c.replace(/\r\n/g,`
|
|
10
|
+
`),c=c.replace(/(\w+)\((.+)\)/g,(l,d,g)=>`${d}(${g.replaceAll(",",",")})`),c=c.replace(/(,)(\s+})/g,"$2"),c=c.replace(/\.\.\..+?,/g,""),c=c.replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),c=c.replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),c=c.replace(/:(.+)\?(.+):/g,(l,d,g)=>`: (${d.trim()} && ${g.trim()}) ||`),c=c.replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2'),c=c.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(l,d,g,x)=>`"${d}":"${g.trim()}"${x}`),c=c.replace(/("'|'")/g,'"'),c=c.replaceAll(",",","),JSON.parse(c)}const co=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],b6=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],l_=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function _6(c,l,d){let g=c.length-l;if(g<=0)return"0."+"0".repeat(-g)+c+(d?" "+d:"");let x=c.substring(0,g),L=c.substring(g);return x===""&&(x="0"),x+"."+L+(d?" "+d:"")}function A6(c,l){const d=(l==null?void 0:l.longForm)??!1,g=l!=null&&l.unit?` ${l.unit}`:"",x=d?b6:l_,L=(l==null?void 0:l.precision)??1;if(c<co[0])return`${c}${g}`;for(let Q=0;Q<co.length-1;Q++)if(c<co[Q+1])return`${(c/co[Q]).toFixed(L)}${d?" ":""}${x[Q]}${g}`;return`${(c/co[co.length-1]).toFixed(L)}${d?" ":""}${x[co.length-1]}${g}`}function xg(c){const l=parseFloat(c);if(isNaN(l))throw Error("makeNumber got NaN for input");const d=c.replace(/^-?[0-9.]+/,"").trim(),g=l_.findIndex(x=>x.toLowerCase()===d.toLowerCase());return g===-1?l:l*co[g]}function Rg(c,l,d){return c<l?l:c>d?d:c}function E6(c,l,d){const g=c+l;return g>d?d:g}function v6(c,l,d){const g=c-l;return g<d?d:g}function x6(c,l){return l(c),c}function R6(c,l){c&&l(c)}function I6(c,l){const d=Object.keys(l);for(const g of d)Array.isArray(l[g])&&Array.isArray(c[g])&&ao(c[g],l[g])}function S6(c){return c.splice(0,c.length),c}function k6(c){for(const l of Object.keys(c))(Le(c[l])||Array.isArray(c[l])&&c[l].every(d=>d==null))&&delete c[l];return c}function T6(c){for(const l of Object.entries(c))(l[1]===null||l[1]===void 0||An(l[1])&&me(l[1]))&&delete c[l[0]];return c}function O6(c,l){const d={};for(const[g,x]of Object.entries(c))l(g)&&(d[g]=x);return d}function N6(c,l){const d={};for(const[g,x]of Object.entries(c))l(x)&&(d[g]=x);return d}function C6(c,l){const d={};for(const g of Object.entries(c))d[g[0]]=l(g[1]);return d}function B6(c,l){const d=[];let g=0;for(const x of c)d.push(l(x,g++));return d}async function P6(c,l){try{return await c()}catch{throw l}}function M6(c,l,d){d!=null&&(c[l]=d)}function L6(c,l,d,g){const x=N(d,g);x!=null&&M(c,l,x)}function U6(c){const l={};for(const[d,g]of Object.entries(c))l[g]=d;return l}function D6(c){const l=Object.keys(c),d=l.map(lt=>c[lt].length),g=d.reduce((lt,at)=>lt*=at);let x=1;const L=[1];for(let lt=0;lt<d.length-1;lt++)x*=d[lt],L.push(x);const Q=[];for(let lt=0;lt<g;lt++){const at={};for(let Ct=0;Ct<l.length;Ct++){const Be=c[l[Ct]],Bn=Math.floor(lt/L[Ct])%Be.length;at[l[Ct]]=Be[Bn]}Q.push(at)}return Q}function F6(c){return Object.values(c).filter(l=>l).length}function $6(c,l,d){return c+(d?"["+l+"]":(c.length?".":"")+l)}function Od(c,l,d,g,x){if(!Je(l))return l;for(const[L,Q]of Object.entries(l)){const lt=$6(d,L,g);Array.isArray(Q)?x?Od(c,Q,lt,!0,x):c[lt]=Q.map(at=>Od(Array.isArray(at)?[]:{},at,"",!1,x)):Je(Q)?Od(c,Q,lt,!1,x):c[lt]=Q}return c}function H6(c,l=!1,d){return Od({},c,d||"",!1,l)}function f_(c){if(!Je(c))return c;const l=Array.isArray(c)?[]:{};for(const[d,g]of Object.entries(c))Array.isArray(g)?M(l,d,g.map(x=>f_(x))):M(l,d,g);return l}function z6(c,l,d){return l[c]?l[c]:d}function h_(c,l){const d={};for(const g of c){const x=l(g);d[x]=g}return d}function G6(c,l){const d={};for(const g of c){const x=l(g);d[x]||(d[x]=[]),d[x].push(g)}return d}function V6(c,l){const d=[];for(let g=0;g<c.length;g+=l)d.push(c.slice(g,g+l));return d}function d_(c,l){const d=Math.ceil(c.length/l),g=[];for(let x=0;x<c.length;x+=d)g.push(c.slice(x,x+d));return g}function p_(c,l){const d=[],g=Math.ceil(c.length/l);for(let x=0;x<g;x++)d.push(c.slice(x*l,x*l+l));return d}function K6(c,l){const d=Math.ceil(c.length/l);return p_(c,d)}function j6(c,l){return Object.values(h_(c,l))}function W6(c,l,d,g,x){const L=l?c.map(l):c,Q={};for(const at of L)Q[at]=(Q[at]||0)+1;const lt=g?g_(Q,x?(at,Ct)=>at[1]-Ct[1]:(at,Ct)=>Ct[1]-at[1]):Q;return d?Object.keys(lt):lt}function g_(c,l){return Object.fromEntries(Object.entries(c).sort(l))}function Z6(c){const l=[],d=Object.keys(c),g=c[d[0]].length;for(let x=0;x<g;x++){const L={};for(const Q of d)L[Q]=c[Q][x];l.push(L)}return l}function q6(c,l,d=1){for(const g of c)g[l]+=d}function Q6(c,l,d){for(const g of c)g[l]=d}function Ig(c,l){const d=[];let g=[];return c.forEach((x,L)=>{(L===0||!l(x,c[L-1]))&&(g=[],d.push(g)),g.push(x)}),d}function J6(){return{map:new Map,keys:[]}}function Y6(){return{map:new Map,keys:[]}}function y_(c,l,d,g=100){if(c.map.has(l)){const x=c.keys.indexOf(l);c.keys.splice(x,1)}if(c.map.set(l,d),c.keys.push(l),c.keys.length>g){const x=c.keys.shift();x&&c.map.delete(x)}}function X6(c,l,d,g=100){if(c.map.has(l)){const x=c.keys.indexOf(l);c.keys.splice(x,1)}if(c.map.set(l,d),c.keys.unshift(l),c.keys.length>g){const x=c.keys.shift();x&&c.map.delete(x)}}function tC(c,l,d,g,x=100){y_(c,l,{validUntil:Date.now()+g,data:d},x)}function eC(c,l){const d=c.map.get(l);return d&&d.validUntil>Date.now()?d.data:null}class uo{constructor(l){this.value=l}static of(l){return new uo(l)}static empty(){return new uo(null)}map(l){return new uo(this.value!==null&&this.value!==void 0?l(this.value):null)}mapAsync(l){return this.value!==null&&this.value!==void 0?l(this.value).then(d=>uo.of(d)):Promise.resolve(uo.empty())}ifPresent(l){return this.value!==null&&this.value!==void 0&&l(this.value),this}ifPresentAsync(l){return this.value!==null&&this.value!==void 0?l(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(l){return(this.value===null||this.value===void 0)&&l(),this}ifAbsentAsync(l){return this.value===null||this.value===void 0?l().then(()=>this):Promise.resolve(this)}getOrFallback(l){return this.value??l()}getOrFallbackAsync(l){return this.value!==null&&this.value!==void 0?Promise.resolve(this.value):l()}getOrThrow(){if(this.value===null||this.value===void 0)throw Error("Optional.value is empty");return this.value}}n.Optional=uo;class nC{constructor(l){this.supplier=l,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}}n.Lazy=nC;class rC{constructor(l){this.supplier=l,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}}n.AsyncLazy=rC;function iC(c){return()=>c.forEach(l=>l())}function sC(c,l){return c.reduce((d,g)=>l(d)>l(g)?d:g)}function oC(c,l){const d=c.find(g=>g instanceof l);return uo.of(d)}function aC(c,l){return c.filter(d=>d instanceof l)}function cC(c,l){const d=[],g=Math.max(c.length,l.length);for(let x=0;x<g;x++)c[x]&&d.push(c[x]),l[x]&&d.push(l[x]);return d}function uC(c,l){return c.includes(l)?c.filter(d=>d!==l):[...c,l]}class lC{constructor(l){this.value=l,this.children=[]}}function fC(c,l,d,g,x=!1){const L=new Map,Q=[];c.forEach(at=>{const Ct=new lC(at);L.set(at[l],Ct)}),c.forEach(at=>{const Ct=L.get(at[l]);if(!Ct)return;const Be=at[d];if(Be){const Bn=L.get(Be);Bn&&Bn.children.push(Ct)}else Q.push(Ct)});const lt=at=>{at.children.sort((Ct,Be)=>{const Bn=Ct.value[g],zc=Be.value[g];return x?zc-Bn:Bn-zc}),at.children.forEach(lt)};return Q.forEach(lt),Q}function m_(c,l){if(Math.log2(c.length)%1!==0)throw new Error("Array length must be a power of 2");let d=[...c];for(;d.length>1;){const g=[];for(let x=0;x<d.length;x+=2){const L=d[x+1];g.push(l(d[x],L))}d=g}return d[0]}function Fc(...c){const l=c.reduce((x,L)=>x+L.length,0),d=new Uint8Array(l);let g=0;return c.forEach(x=>{d.set(x,g),g+=x.length}),d}function w_(c){return c[0]===137&&c[1]===80&&c[2]===78&&c[3]===71}function b_(c){return c[0]===255&&c[1]===216}function __(c){return c[8]===87&&c[9]===69&&c[10]===66&&c[11]===80}function hC(c){return w_(c)||b_(c)||__(c)}function dC(c){return new Uint8Array([c])}function pC(c){return c[0]}function gC(c,l){const d=new ArrayBuffer(2);return new DataView(d).setUint16(0,c,l==="LE"),new Uint8Array(d)}function yC(c,l){return new DataView(c.buffer).getUint16(c.byteOffset,l==="LE")}function mC(c,l){const d=new ArrayBuffer(4);return new DataView(d).setUint32(0,c,l==="LE"),new Uint8Array(d)}function wC(c,l){return new DataView(c.buffer).getUint32(c.byteOffset,l==="LE")}function Sg(c,l){const d=new ArrayBuffer(8);return new DataView(d).setBigUint64(0,BigInt(c),l==="LE"),new Uint8Array(d)}function bC(c,l){return new DataView(c.buffer).getBigUint64(c.byteOffset,l==="LE")}function $c(c,l){const d=new Uint8Array(32);let g=c;if(l==="LE"){for(let x=0;x<32;x++)d[x]=Number(g&0xffn),g>>=8n;return d}for(let x=31;x>=0;x--)d[x]=Number(g&0xffn),g>>=8n;return d}function Hc(c,l){let d=0n;if(l==="LE"){for(let g=31;g>=0;g--)d=d<<8n|BigInt(c[g]);return d}for(let g=0;g<32;g++)d=d<<8n|BigInt(c[g]);return d}function _C(c,l){const d=[];let g=0;for(const x of l)d.push(c.subarray(g,g+x)),g+=x;return d}function kg(c,l){const d=[];for(let g=0;g<c.length;g+=l)d.push(c.subarray(g,g+l));return d}const A_=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function AC(c){for(let l=0;l<24;l++){const d=c[0]^c[10]^c[20]^c[30]^c[40],g=c[1]^c[11]^c[21]^c[31]^c[41],x=c[2]^c[12]^c[22]^c[32]^c[42],L=c[3]^c[13]^c[23]^c[33]^c[43],Q=c[4]^c[14]^c[24]^c[34]^c[44],lt=c[5]^c[15]^c[25]^c[35]^c[45],at=c[6]^c[16]^c[26]^c[36]^c[46],Ct=c[7]^c[17]^c[27]^c[37]^c[47],Be=c[8]^c[18]^c[28]^c[38]^c[48],Bn=c[9]^c[19]^c[29]^c[39]^c[49],zc=x<<1|L>>>31,r3=L<<1|x>>>31,yf=Be^zc,mf=Bn^r3,i3=Q<<1|lt>>>31,s3=lt<<1|Q>>>31,wf=d^i3,bf=g^s3,o3=at<<1|Ct>>>31,a3=Ct<<1|at>>>31,_f=x^o3,Af=L^a3,c3=Be<<1|Bn>>>31,u3=Bn<<1|Be>>>31,Ef=Q^c3,vf=lt^u3,l3=d<<1|g>>>31,f3=g<<1|d>>>31,xf=at^l3,Rf=Ct^f3;c[0]^=yf,c[1]^=mf,c[2]^=wf,c[3]^=bf,c[4]^=_f,c[5]^=Af,c[6]^=Ef,c[7]^=vf,c[8]^=xf,c[9]^=Rf,c[10]^=yf,c[11]^=mf,c[12]^=wf,c[13]^=bf,c[14]^=_f,c[15]^=Af,c[16]^=Ef,c[17]^=vf,c[18]^=xf,c[19]^=Rf,c[20]^=yf,c[21]^=mf,c[22]^=wf,c[23]^=bf,c[24]^=_f,c[25]^=Af,c[26]^=Ef,c[27]^=vf,c[28]^=xf,c[29]^=Rf,c[30]^=yf,c[31]^=mf,c[32]^=wf,c[33]^=bf,c[34]^=_f,c[35]^=Af,c[36]^=Ef,c[37]^=vf,c[38]^=xf,c[39]^=Rf,c[40]^=yf,c[41]^=mf,c[42]^=wf,c[43]^=bf,c[44]^=_f,c[45]^=Af,c[46]^=Ef,c[47]^=vf,c[48]^=xf,c[49]^=Rf;const Pg=c[0],Mg=c[1],Lg=c[2]<<1|c[3]>>>31,Ug=c[3]<<1|c[2]>>>31,Dg=c[5]<<30|c[4]>>>2,Fg=c[4]<<30|c[5]>>>2,$g=c[6]<<28|c[7]>>>4,Hg=c[7]<<28|c[6]>>>4,zg=c[8]<<27|c[9]>>>5,Gg=c[9]<<27|c[8]>>>5,Vg=c[11]<<4|c[10]>>>28,Kg=c[10]<<4|c[11]>>>28,jg=c[13]<<12|c[12]>>>20,Wg=c[12]<<12|c[13]>>>20,Zg=c[14]<<6|c[15]>>>26,qg=c[15]<<6|c[14]>>>26,Qg=c[17]<<23|c[16]>>>9,Jg=c[16]<<23|c[17]>>>9,Yg=c[18]<<20|c[19]>>>12,Xg=c[19]<<20|c[18]>>>12,ty=c[20]<<3|c[21]>>>29,ey=c[21]<<3|c[20]>>>29,ny=c[22]<<10|c[23]>>>22,ry=c[23]<<10|c[22]>>>22,iy=c[25]<<11|c[24]>>>21,sy=c[24]<<11|c[25]>>>21,oy=c[26]<<25|c[27]>>>7,ay=c[27]<<25|c[26]>>>7,cy=c[29]<<7|c[28]>>>25,uy=c[28]<<7|c[29]>>>25,ly=c[31]<<9|c[30]>>>23,fy=c[30]<<9|c[31]>>>23,hy=c[33]<<13|c[32]>>>19,dy=c[32]<<13|c[33]>>>19,py=c[34]<<15|c[35]>>>17,gy=c[35]<<15|c[34]>>>17,yy=c[36]<<21|c[37]>>>11,my=c[37]<<21|c[36]>>>11,wy=c[38]<<8|c[39]>>>24,by=c[39]<<8|c[38]>>>24,_y=c[40]<<18|c[41]>>>14,Ay=c[41]<<18|c[40]>>>14,Ey=c[42]<<2|c[43]>>>30,vy=c[43]<<2|c[42]>>>30,xy=c[45]<<29|c[44]>>>3,Ry=c[44]<<29|c[45]>>>3,Iy=c[47]<<24|c[46]>>>8,Sy=c[46]<<24|c[47]>>>8,ky=c[48]<<14|c[49]>>>18,Ty=c[49]<<14|c[48]>>>18;c[0]=Pg^~jg&iy,c[1]=Mg^~Wg&sy,c[2]=jg^~iy&yy,c[3]=Wg^~sy&my,c[4]=iy^~yy&ky,c[5]=sy^~my&Ty,c[6]=yy^~ky&Pg,c[7]=my^~Ty&Mg,c[8]=ky^~Pg&jg,c[9]=Ty^~Mg&Wg,c[10]=$g^~Yg&ty,c[11]=Hg^~Xg&ey,c[12]=Yg^~ty&hy,c[13]=Xg^~ey&dy,c[14]=ty^~hy&xy,c[15]=ey^~dy&Ry,c[16]=hy^~xy&$g,c[17]=dy^~Ry&Hg,c[18]=xy^~$g&Yg,c[19]=Ry^~Hg&Xg,c[20]=Lg^~Zg&oy,c[21]=Ug^~qg&ay,c[22]=Zg^~oy&wy,c[23]=qg^~ay&by,c[24]=oy^~wy&_y,c[25]=ay^~by&Ay,c[26]=wy^~_y&Lg,c[27]=by^~Ay&Ug,c[28]=_y^~Lg&Zg,c[29]=Ay^~Ug&qg,c[30]=zg^~Vg&ny,c[31]=Gg^~Kg&ry,c[32]=Vg^~ny&py,c[33]=Kg^~ry&gy,c[34]=ny^~py&Iy,c[35]=ry^~gy&Sy,c[36]=py^~Iy&zg,c[37]=gy^~Sy&Gg,c[38]=Iy^~zg&Vg,c[39]=Sy^~Gg&Kg,c[40]=Dg^~Qg&cy,c[41]=Fg^~Jg&uy,c[42]=Qg^~cy&ly,c[43]=Jg^~uy&fy,c[44]=cy^~ly&Ey,c[45]=uy^~fy&vy,c[46]=ly^~Ey&Dg,c[47]=fy^~vy&Fg,c[48]=Ey^~Dg&Qg,c[49]=vy^~Fg&Jg,c[0]^=A_[l*2],c[1]^=A_[l*2+1]}}function E_(c){const l=[];for(let d=0;d<c.length;d+=4)l.push(c[d]|c[d+1]<<8|c[d+2]<<16|c[d+3]<<24);return l}function v_(c,l){if(!c.length){const x=new Uint8Array(136);return x[0]=l,x[135]=128,[E_(x)]}const d=kg(c,136),g=d[d.length-1];if(g.length<136){const x=new Uint8Array(136);x.set(g),x[g.length]=l,x[135]|=128,d[d.length-1]=x}if(g.length===136){const x=new Uint8Array(136);x[0]=l,x[135]=128,d.push(x)}return d.map(E_)}function x_(c,l){for(const d of l){for(let g=0;g<34;g+=2)c[g]^=d[g+1],c[g+1]^=d[g];AC(c)}return c}function R_(c){return new Uint8Array([c[1],c[1]>>-24,c[1]>>-16,c[1]>>-8,c[0],c[0]>>8,c[0]>>16,c[0]>>24,c[3],c[3]>>-24,c[3]>>-16,c[3]>>-8,c[2],c[2]>>8,c[2]>>16,c[2]>>24,c[5],c[5]>>-24,c[5]>>-16,c[5]>>-8,c[4],c[4]>>8,c[4]>>16,c[4]>>24,c[7],c[7]>>-24,c[7]>>-16,c[7]>>-8,c[6],c[6]>>8,c[6]>>16,c[6]>>24])}function ys(c){return R_(x_(new Array(50).fill(0),v_(c,1)))}function EC(c){return R_(x_(new Array(50).fill(0),v_(c,6)))}function vC(c,l,d){const g=Math.min(c.length,l.length,d/8+1);for(let x=0;x<g;x++){const L=c[x]^l[x];for(let Q=0;Q<8;Q++)if(L>>7-Q&1)return x*8+Q}return d}function xC(c,l){const d=Math.min(c.length,l.length);for(let g=0;g<d;g++)if(c[g]!==l[g])return c.subarray(0,g);return c.subarray(0,d)}function RC(c,l,d,g){const x=Math.floor(l/8),L=l%8;d===1?c[x]|=1<<(g==="BE"?7-L:L):c[x]&=~(1<<(g==="BE"?7-L:L))}function IC(c,l,d){const g=Math.floor(l/8),x=l%8;return c[g]>>(d==="BE"?7-x:x)&1}function SC(c,l,d=0){for(let g=d;g<c.length;g++)for(let x=0;x<l.length&&c[g+x]===l[x];x++)if(x===l.length-1)return g;return-1}function I_(c,l,d=0){if(c.length>=l)return c;const g=new Uint8Array(l);return g.fill(d),g.set(c,l-c.length),g}function kC(c,l,d=0){const g=c.length%l;return g===0?c:I_(c,c.length+l-g,d)}function S_(c,l,d=0){if(c.length>=l)return c;const g=new Uint8Array(l);return g.fill(d),g.set(c,0),g}function TC(c,l,d=0){const g=c.length%l;return g===0?c:S_(c,c.length+l-g,d)}function OC(c,l){const d=new Uint8Array(c.length);for(let g=0;g<c.length;g++)d[g]=c[g]^l[g%l.length];return d}function NC(c,l){if(c.length!==l.length)return!1;for(let d=0;d<c.length;d++)if(c[d]!==l[d])return!1;return!0}function Fe(c,l){return(c%l+l)%l}function pf(c,l){c=Fe(c,l);let[d,g]=[0n,1n],[x,L]=[l,c];for(;L!==0n;){const Q=x/L;[d,g]=[g,d-Q*g],[x,L]=[L,x-Q*L]}if(x>1n)throw new Error("a is not invertible");return d<0n&&(d+=l),d}function CC(c,l,d){let g=1n;for(c=Fe(c,d);l>0;)l%2n===1n&&(g=Fe(g*c,d)),c=Fe(c*c,d),l=l/2n;return g}function k_(c,l){return Fe(c,l)===0n?0n:l%4n===3n?CC(c,(l+1n)/4n,l):null}const Xn=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Cn=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Nd=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Cd=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Tg(c,l,d){if(l===0n)return[0n,0n];const g=Fe(3n*c*c*pf(2n*l,d),d),x=Fe(g*g-2n*c,d),L=Fe(g*(c-x)-l,d);return[x,L]}function Bd(c,l,d,g,x){if(c===0n&&l===0n)return[d,g];if(d===0n&&g===0n)return[c,l];if(c===d&&l===Fe(-g,x))return[0n,0n];if(c===d&&l===g)return Tg(c,l,x);const L=Fe((g-l)*pf(d-c,x),x),Q=Fe(L*L-c-d,x),lt=Fe(L*(c-Q)-l,x);return[Q,lt]}function BC(c){if(c<=0n||c>=Cn)throw new Error("Invalid private key");return ya(Nd,Cd,c,Xn)}function PC(c){const l=c[1]%2n===0n?2:3;return new Uint8Array([l,...$c(c[0],"BE")])}function MC(c){if(c.length!==33||c[0]!==2&&c[0]!==3)throw new Error("Invalid compressed public key");const l=Hc(c.slice(1),"BE"),d=k_(Fe(l**3n+7n,Xn),Xn);if(!d)throw Error("Invalid x: does not correspond to a valid curve point");const g=Fe(-d,Xn),x=d%2n===0n;return[l,c[0]===2?x?d:g:x?g:d]}function LC(c){const l=new Uint8Array(20),d=ys(Fc($c(c[0],"BE"),$c(c[1],"BE")));return l.set(d.subarray(12)),l}function UC(c){const l=n.Binary.uint8ArrayToHex(c),d=n.Binary.uint8ArrayToHex(n.Binary.keccak256(new Uint8Array([...l].map(x=>x.charCodeAt(0)))));let g="0x";for(let x=0;x<l.length;x++)parseInt(d[x],16)>7?g+=l[x].toUpperCase():g+=l[x];return g}function ya(c,l,d,g){let x=[0n,0n],L=[c,l];const Q=d.toString(2);for(const lt of Q)lt==="0"?(L=Bd(x[0],x[1],L[0],L[1],g),x=Tg(x[0],x[1],g)):(x=Bd(x[0],x[1],L[0],L[1],g),L=Tg(L[0],L[1],g));return x}function DC(c,l,d){return T_(Hc(ys(c),"BE"),l,d)}function T_(c,l,d){if(l<=0n||l>=Cn)throw new Error("Invalid private key");if(d||(d=Fe(Hc(ys(Fc(ys($c(l,"BE")),$c(c,"BE"))),"BE"),Cn)),d<=0n||d>=Cn)throw new Error("Invalid nonce");const g=Fe(c,Cn),x=ya(Nd,Cd,d,Xn),L=Fe(x[0],Cn);let Q=Fe((g+Fe(L,Cn)*l)*pf(d,Cn),Cn);if(L===0n||Q===0n)throw new Error("Invalid r or s value");let lt=x[1]%2n===0n?27n:28n;return Q>Cn/2n&&(Q=Cn-Q,lt=lt===27n?28n:27n),[L,Q,lt]}function FC(c,l,d,g){const x=k_(Fe(l**3n+7n,Xn),Xn);if(!x)throw new Error("Invalid r: does not correspond to a valid curve point");const L=g===27n?0n:1n,Q=x%2n===L?x:Xn-x,lt=Fe(Hc(ys(c),"BE"),Cn),at=ya(l,Q,d,Xn),Ct=ya(Nd,Cd,lt,Xn),Be=Bd(at[0],at[1],Ct[0],Fe(-Ct[1],Xn),Xn);return ya(Be[0],Be[1],pf(l,Cn),Xn)}function $C(c,l,d,g){const x=Fe(Hc(ys(c),"BE"),Cn),L=pf(g,Cn),Q=Fe(x*L,Cn),lt=Fe(d*L,Cn),at=ya(Nd,Cd,Q,Xn),Ct=ya(l[0],l[1],lt,Xn),Be=Bd(at[0],at[1],Ct[0],Ct[1],Xn);return d===Fe(Be[0],Cn)}class O_{constructor(l){this.cursor=0,this.buffer=l}read(l){const d=this.buffer.subarray(this.cursor,this.cursor+l);return this.cursor+=l,d}max(){return this.buffer.length-this.cursor}}n.Uint8ArrayReader=O_;class N_{constructor(l){this.buffer=l,this.cursor=0}write(l){const d=Math.min(this.max(),l.max());return this.buffer.set(l.read(d),this.cursor),this.cursor+=d,d}max(){return this.buffer.length-this.cursor}}n.Uint8ArrayWriter=N_;class Pd{constructor(l,d=0n){this.span=d,this.writer=new N_(new Uint8Array(l))}build(){return Fc(Sg(this.span,"LE"),this.writer.buffer)}hash(){const l=m_(kg(this.writer.buffer,32),(d,g)=>ys(Fc(d,g)));return ys(Fc(Sg(this.span,"LE"),l))}}n.Chunk=Pd;class Og{constructor(l,d=4096){this.counters=[1],this.capacity=d,this.chunks=[new Pd(d)],this.onChunk=l}static async root(l,d=4096){const g=new t(t.NOOP,d);return await g.append(l),g.finalize()}async append(l,d=0,g=0n){const x=new O_(l);for(;x.max()>0;){this.chunks[d].writer.max()===0&&await this.elevate(d);const L=this.chunks[d].writer.write(x);g?this.chunks[d].span+=g:this.chunks[0].span+=BigInt(L)}}async elevate(l){this.counters[l]=++this.counters[l]%(this.capacity/32),this.chunks[l+1]||(this.chunks.push(new Pd(this.capacity)),this.counters.push(1)),await this.append(this.chunks[l].hash(),l+1,this.chunks[l].span),await this.onChunk(this.chunks[l]),this.chunks[l]=new Pd(this.capacity)}async finalize(l=0){return this.chunks[l+1]?this.counters[l]===1?(await this.elevate(l+1),this.chunks[l+1]=this.chunks[l],this.finalize(l+1)):(await this.elevate(l),this.finalize(l+1)):(await this.onChunk(this.chunks[l]),this.chunks[l])}}n.MerkleTree=Og,t=Og,Og.NOOP=async c=>{};class Pi{constructor(l,d){if(d<0)throw Error("Scale must be non-negative");this.value=BigInt(l),this.scale=d}static fromDecimalString(l,d){let[g,x]=l.split(".");return x=(x||"").padEnd(d,"0").slice(0,d),new Pi(BigInt(g+x),d)}add(l){return this.assertSameScale(l),new Pi(this.value+l.value,this.scale)}subtract(l){return this.assertSameScale(l),new Pi(this.value-l.value,this.scale)}multiply(l){return new Pi(this.value*l,this.scale)}divmod(l){if(l===0n)throw new Error("Division by zero is not allowed");const d=this.value/l,g=this.value%l;return[new Pi(d,this.scale),new Pi(g,this.scale)]}exchange(l,d,g){if(l==="*"){const L=this.value*d.value/10n**BigInt(this.scale);return new Pi(L,g)}this.assertSameScale(d);const x=this.value*10n**BigInt(g)/d.value;return new Pi(x,g)}compare(l){return this.assertSameScale(l),this.value>l.value?1:this.value<l.value?-1:0}toDecimalString(){if(this.scale===0)return this.value.toString();const l=this.value.toString(),d=l.slice(0,-this.scale)||"0",g=l.slice(-this.scale).padStart(this.scale,"0");return`${d}.${g}`}toString(){return this.value.toString()}toJSON(){return this.toString()}assertSameScale(l){if(this.scale!==l.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${l.scale}`)}}n.FixedPointNumber=Pi;function HC(c){if(c.length===0)return null;const l=c[0];return l.ttlMax?--l.ttl<=0&&c.shift():l.ttlMax=l.ttl,{progress:(l.ttlMax-l.ttl)/l.ttlMax,data:l.data}}function Md(c,l,d,g){const x=c.findIndex(lt=>lt===`--${l}`||lt.startsWith(`--${l}=`)),L=c[x];if(!L)return(d||{})[g||l||""]||null;if(L.includes("="))return L.split("=")[1];const Q=c[x+1];return Q&&!Q.startsWith("-")?Q:(d||{})[g||l||""]||null}function zC(c,l,d,g){const x=Md(c,l,d,g);if(!x)return null;try{return xg(x)}catch{throw new Error(`Invalid number argument ${l}: ${x}`)}}function GC(c,l,d,g){const x=c.some(at=>at.endsWith("-"+l)),L=Md(c,l,d,g);if(!L&&x)return!0;if(!L&&!x)return null;const Q=["true","1","yes","y","on"],lt=["false","0","no","n","off"];if(Q.includes(L.toLowerCase()))return!0;if(lt.includes(L.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${l}: ${L}`)}function C_(c,l,d,g){const x=Md(c,l,d,g);if(!x)throw new Error(`Missing argument ${l}`);return x}function VC(c,l,d,g){const x=C_(c,l,d,g);try{return xg(x)}catch{throw new Error(`Invalid argument ${l}: ${x}`)}}function B_(c,l){const d=c[l];c.splice(l,1),c.unshift(d)}function KC(c,l){const d=[...c];return B_(d,l),d}function P_(c,l){return{x:c.x+l.x,y:c.y+l.y}}function jC(c,l){return{x:c.x-l.x,y:c.y-l.y}}function Ng(c,l){return{x:c.x*l,y:c.y*l}}function WC(c){const l=Math.sqrt(c.x*c.x+c.y*c.y);return{x:c.x/l,y:c.y/l}}function M_(c,l,d){return{x:c.x+Math.cos(l)*d,y:c.y+Math.sin(l)*d}}function L_(c,l){return Math.sqrt((c.x-l.x)**2+(c.y-l.y)**2)}function gf(c,l,d="row-first"){const g=[];if(d==="column-first")for(let x=0;x<c.length;x++)for(let L=0;L<c[0].length;L++)l(x,L)&&g.push({x,y:L});else for(let x=0;x<c[0].length;x++)for(let L=0;L<c.length;L++)l(L,x)&&g.push({x:L,y:x});return g}function ZC(c,l,d){var g,x;return((g=c[l+1])==null?void 0:g[d])&&((x=c[l-1])==null?void 0:x[d])&&!c[l][d-1]&&!c[l][d+1]}function qC(c,l,d){var g,x;return c[l][d+1]&&c[l][d-1]&&!((g=c[l-1])!=null&&g[d])&&!((x=c[l+1])!=null&&x[d])}function U_(c,l,d){var g;return!((g=c[l-1])!=null&&g[d])}function D_(c,l,d){var g;return!((g=c[l+1])!=null&&g[d])}function F_(c,l,d){return!c[l][d-1]}function $_(c,l,d){return!c[l][d+1]}function QC(c,l,d){var x,L,Q,lt,at,Ct,Be,Bn;const g=[];return c[l][d]?ZC(c,l,d)||qC(c,l,d)?[]:(!((x=c[l-1])!=null&&x[d-1])&&U_(c,l,d)&&F_(c,l,d)&&g.push({x:l,y:d}),!((L=c[l+1])!=null&&L[d-1])&&D_(c,l,d)&&F_(c,l,d)&&g.push({x:l+1,y:d}),!((Q=c[l-1])!=null&&Q[d+1])&&U_(c,l,d)&&$_(c,l,d)&&g.push({x:l,y:d+1}),!((lt=c[l+1])!=null&<[d+1])&&D_(c,l,d)&&$_(c,l,d)&&g.push({x:l+1,y:d+1}),g):((at=c[l-1])!=null&&at[d]&&c[l][d-1]&&g.push({x:l,y:d}),(Ct=c[l+1])!=null&&Ct[d]&&c[l][d-1]&&g.push({x:l+1,y:d}),(Be=c[l-1])!=null&&Be[d]&&c[l][d+1]&&g.push({x:l,y:d+1}),(Bn=c[l+1])!=null&&Bn[d]&&c[l][d+1]&&g.push({x:l+1,y:d+1}),g)}function JC(c,l,d,g){const x=[{x:0,y:0},{x:d,y:0},{x:0,y:g},{x:d,y:g}];for(let L=0;L<c.length;L++)for(let Q=0;Q<c[0].length;Q++){const lt=QC(c,L,Q);for(const at of lt)x.some(Ct=>Ct.x===at.x&&Ct.y===at.y)||x.push(at)}return x.map(L=>({x:L.x*l,y:L.y*l}))}function YC(c,l){const d=gf(c,(at,Ct)=>c[at][Ct]===0&&c[at][Ct+1]!==0,"row-first").map(at=>({...at,dx:1,dy:0})),g=gf(c,(at,Ct)=>c[at][Ct]===0&&c[at][Ct-1]!==0,"row-first").map(at=>({...at,dx:1,dy:0})),x=gf(c,(at,Ct)=>{var Be;return c[at][Ct]===0&&((Be=c[at-1])==null?void 0:Be[Ct])!==0},"column-first").map(at=>({...at,dx:0,dy:1})),L=gf(c,(at,Ct)=>{var Be;return c[at][Ct]===0&&((Be=c[at+1])==null?void 0:Be[Ct])!==0},"column-first").map(at=>({...at,dx:0,dy:1}));d.forEach(at=>at.y++),L.forEach(at=>at.x++);const Q=Ig([...x,...L],(at,Ct)=>at.x===Ct.x&&at.y-1===Ct.y),lt=Ig([...g,...d],(at,Ct)=>at.y===Ct.y&&at.x-1===Ct.x);return[...Q,...lt].map(at=>({start:at[0],end:C(at)})).map(at=>({start:Ng(at.start,l),end:Ng(P_(at.end,{x:at.start.dx,y:at.start.dy}),l)}))}function XC(c,l){return Math.atan2(l.y-c.y,l.x-c.x)}function t3(c,l){return l.map(d=>XC(c,d)).sort((d,g)=>d-g)}function H_(c,l,d,g){const x=(g.y-d.y)*(l.x-c.x)-(g.x-d.x)*(l.y-c.y);if(x===0)return null;let L=c.y-d.y,Q=c.x-d.x;const lt=(g.x-d.x)*L-(g.y-d.y)*Q,at=(l.x-c.x)*L-(l.y-c.y)*Q;return L=lt/x,Q=at/x,L>0&&L<1&&Q>0&&Q<1?{x:c.x+L*(l.x-c.x),y:c.y+L*(l.y-c.y)}:null}function Cg(c,l,d){const g=[],x=M_(c,d,1e4);for(const L of l){const Q=H_(c,x,L.start,L.end);Q&&g.push(Q)}return g.length?g.reduce((L,Q)=>{const lt=L_(c,Q),at=L_(c,L);return lt<at?Q:L}):null}function e3(c,l,d){const g=t3(c,d),x=[];for(const L of g){const Q=Cg(c,l,L-.001),lt=Cg(c,l,L+.001);Q&&x.push(Q),lt&&x.push(lt)}return x}class Bg{constructor(){this.subscribers=[]}subscribe(l){return this.subscribers.push(l),()=>{this.subscribers=this.subscribers.filter(d=>d!==l)}}publish(l){this.subscribers.forEach(d=>d(l))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}n.PubSubChannel=Bg;class n3{constructor(l,d){this.queue=[],this.running=0,this.onProcessed=new Bg,this.onDrained=new Bg,this.concurrency=l,this.capacity=d}process(){if(this.running>=this.concurrency)return;const l=this.queue.shift();l&&(this.running++,l().finally(()=>{this.running--,this.process(),this.onProcessed.publish(),this.running===0&&this.onDrained.publish()}))}enqueue(l){if(this.queue.length<this.capacity)return this.queue.push(l),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise(d=>{this.onProcessed.subscribe(()=>{this.queue.length<this.capacity&&(this.queue.push(l),this.process(),this.onProcessed.clear(),d())})})}drain(){if(this.running===0)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise(l=>{this.onDrained.subscribe(()=>{this.onDrained.clear(),l()})})}}n.AsyncQueue=n3,n.Binary={hexToUint8Array:aN,uint8ArrayToHex:cN,base64ToUint8Array:rN,uint8ArrayToBase64:iN,base32ToUint8Array:sN,uint8ArrayToBase32:oN,log2Reduce:m_,partition:kg,concatBytes:Fc,numberToUint8:dC,uint8ToNumber:pC,numberToUint16:gC,uint16ToNumber:yC,numberToUint32:mC,uint32ToNumber:wC,numberToUint64:Sg,uint64ToNumber:bC,numberToUint256:$c,uint256ToNumber:Hc,sliceBytes:_C,keccak256:ys,sha3_256:EC,proximity:vC,commonPrefix:xC,setBit:RC,getBit:IC,indexOf:SC,equals:NC,padStart:I_,padStartToMultiple:kC,padEnd:S_,padEndToMultiple:TC,xorCypher:OC},n.Elliptic={privateKeyToPublicKey:BC,compressPublicKey:PC,publicKeyFromCompressed:MC,publicKeyToAddress:LC,signMessage:DC,signHash:T_,verifySignature:$C,recoverPublicKey:FC,checksumEncode:UC},n.Random={intBetween:H,floatBetween:U,chance:Y,signed:G,makeSeededRng:B,point:X,procs:j},n.Arrays={countUnique:W6,makeUnique:j6,splitBySize:V6,splitByCount:d_,index:h_,indexCollection:G6,onlyOrThrow:a,onlyOrNull:u,firstOrThrow:h,firstOrNull:f,shuffle:o,initialize:y,initialize2D:w,rotate2D:_,containsShape:R,glue:hO,pluck:I,pick:it,pickMany:ut,pickManyUnique:rt,pickWeighted:v,pickRandomIndices:T,pickGuaranteed:ot,last:C,pipe:p,makePipe:m,sortWeighted:k,pushAll:ao,unshiftAll:lO,filterAndRemove:NN,merge:I6,empty:S6,pushToBucket:uf,unshiftAndLimit:lf,atRolling:ff,group:Ig,createOscillator:d6,organiseWithLimits:g6,tickPlaybook:HC,getArgument:Md,getBooleanArgument:GC,getNumberArgument:zC,requireStringArgument:C_,requireNumberArgument:VC,bringToFront:KC,bringToFrontInPlace:B_,findInstance:oC,filterInstances:aC,interleave:cC,toggle:uC,createHierarchy:fC,multicall:iC,maxBy:sC},n.System={sleepMillis:s,forever:ft,scheduleMany:bO,waitFor:ON,expandError:sf,runAndSetInterval:wt},n.Numbers={make:xg,sum:AO,average:EO,median:vO,getDistanceFromMidpoint:xO,clamp:Rg,range:Mb,interpolate:_O,createSequence:h6,increment:E6,decrement:v6,format:A6,fromDecimals:_6,makeStorage:n6,asMegabytes:Ht,convertBytes:Lt,hexToRgb:Mt,rgbToHex:Ee,haversineDistanceToMeters:Vt,roundToNearest:Ut,formatDistance:Ie,triangularNumber:Yt,searchFloat:ie},n.Promises={raceFulfilled:r,invert:e,runInParallelBatches:i},n.Dates={getTimestamp:$N,getTimeDelta:r_,secondsToHumanTime:HN,countCycles:zN,isoDate:PN,throttle:GN,timeSince:KN,dateTimeSlug:MN,unixTimestamp:BN,fromUtcString:LN,fromMillis:UN,getProgress:jN,humanizeTime:Td,humanizeProgress:TN,createTimeDigits:Bi,mapDayNumber:i_,getDayInfoFromDate:Eg,getDayInfoFromDateTimeString:ZN,seconds:qN,minutes:QN,hours:JN,days:YN,make:t6,normalizeTime:DN,absoluteDays:pa},n.Objects={safeParse:f6,deleteDeep:A,getDeep:N,setDeep:M,incrementDeep:z,ensureDeep:P,replaceDeep:$,getFirstDeep:ct,deepMergeInPlace:di,deepMerge2:of,deepMerge3:af,mapAllAsync:fO,cloneWithJson:CN,sortObject:o_,sortArray:a_,sortAny:ga,deepEquals:c_,deepEqualsEvery:l6,runOn:x6,ifPresent:R6,zip:Uc,zipSum:cf,removeEmptyArrays:k6,removeEmptyValues:T6,flatten:H6,unflatten:f_,match:z6,sort:g_,map:C6,mapIterable:B6,filterKeys:O6,filterValues:N6,rethrow:P6,setSomeOnObject:M6,setSomeDeep:L6,flip:U6,getAllPermutations:D6,countTruthyValues:F6,transformToArray:Z6,setMulti:Q6,incrementMulti:q6,createBidirectionalMap:J6,createTemporalBidirectionalMap:Y6,pushToBidirectionalMap:y_,unshiftToBidirectionalMap:X6,addToTemporalBidirectionalMap:tC,getFromTemporalBidirectionalMap:eC,createStatefulToggle:p6,diffKeys:y6,pickRandomKey:u_,mapRandomKey:m6,fromObjectString:w6,toQueryString:e_,parseQueryString:AN,hasKey:EN,selectMax:vN,reposition:xN,unwrapSingleKey:RN,parseKeyValues:IN},n.Types={isFunction:ke,isObject:Je,isStrictlyObject:ce,isEmptyArray:Le,isEmptyObject:oo,isUndefined:ve,isString:An,isNumber:ue,isBoolean:xe,isDate:Ye,isBlank:me,isId:Te,isIntegerString:Yn,isHexString:Ue,isUrl:Mc,isNullable:tf,asString:Xe,asHexString:ln,asSafeString:vd,asIntegerString:Ed,asNumber:ha,asFunction:fn,asInteger:We,asBoolean:hn,asDate:xd,asNullableString:dn,asEmptiableString:pn,asId:Rd,asTime:gn,asArray:yn,asObject:da,asNullableObject:mn,asStringMap:wn,asNumericDictionary:Yl,asUrl:Xl,asNullable:ef,asOptional:nf,enforceObjectShape:Lc,enforceArrayShape:rf,isPng:w_,isJpg:b_,isWebp:__,isImage:hC},n.Strings={tokenizeByCount:K6,tokenizeByLength:p_,searchHex:Ad,searchSubstring:cn,randomHex:un,randomLetter:Kt,randomAlphanumeric:De,randomRichAscii:Ft,randomUnicode:an,includesAny:RO,slugify:dg,normalForm:SO,enumify:BO,escapeHtml:MO,decodeHtmlEntities:UO,after:pg,afterLast:Ub,before:Lb,beforeLast:gg,betweenWide:DO,betweenNarrow:FO,getPreLine:r6,containsWord:_g,containsWords:mN,joinUrl:s_,getFuzzyMatchScore:Id,sortByFuzzyScore:PO,splitOnce:yg,splitAll:Db,randomize:GO,expand:Fb,shrinkTrim:hf,capitalize:Sd,decapitalize:$b,csvEscape:qO,parseCsv:kN,surroundInOut:CO,getExtension:mg,getBasename:wg,normalizeEmail:$O,normalizeFilename:HO,parseFilename:zO,camelToTitle:kO,slugToTitle:TO,slugToCamel:OO,joinHumanly:NO,findWeightedPair:jb,extractBlock:Wb,extractAllBlocks:YO,replaceBlocks:XO,indexOfEarliest:Dc,lastIndexOfBefore:Kb,parseHtmlAttributes:wN,readNextWord:kd,resolveVariables:bN,resolveVariableWithDefaultSyntax:Xb,resolveRemainingVariablesWithDefaults:t_,isLetter:Hb,isDigit:zb,isLetterOrDigit:df,isValidObjectPathCharacter:jO,insert:WO,indexOfRegex:Gb,lineMatches:Vb,linesMatchInOrder:ZO,represent:gs,resolveMarkdownLinks:_N,buildUrl:SN,isChinese:IO,replaceBetweenStrings:o6,describeMarkdown:a6,isBalanced:c6,textToFormat:u6,splitFormatting:tN,splitHashtags:eN,splitUrls:nN,route:uN,explodeReplace:bg,generateVariants:lN,replaceWord:fN,replacePascalCaseWords:hN,stripHtml:dN,breakLine:Yb,measureTextWidth:pN,toLines:gN,levenshteinDistance:yN},n.Assertions={asEqual:dO,asTrue:pO,asTruthy:gO,asFalse:yO,asFalsy:mO,asEither:wO},n.Cache={get:i6,invalidate:s6},n.Vector={addPoint:P_,subtractPoint:jC,multiplyPoint:Ng,normalizePoint:WC,pushPoint:M_,filterCoordinates:gf,findCorners:JC,findLines:YC,raycast:Cg,raycastCircle:e3,getLineIntersectionPoint:H_}})(Hx);const je=ua(Hx);je.Arrays;je.Assertions;const ar=je.Binary;je.Cache;je.Dates;je.Elliptic;je.Numbers;je.Objects;je.Pagination;je.Promises;je.Random;je.Strings;je.System;je.Types;je.Optional;je.Vector;je.PubSubChannel;je.Chunk;const XM=je.MerkleTree;je.FixedPointNumber;je.Lazy;je.AsyncLazy;je.AsyncQueue;je.Uint8ArrayReader;je.Uint8ArrayWriter;var pe;(function(n){n.assertEqual=i=>i;function t(i){}n.assertIs=t;function e(i){throw new Error}n.assertNever=e,n.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},n.getValidEnumValues=i=>{const s=n.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return n.objectValues(o)},n.objectValues=i=>n.objectKeys(i).map(function(s){return i[s]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},n.find=(i,s)=>{for(const o of i)if(s(o))return o},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}n.joinValues=r,n.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(pe||(pe={}));var Km;(function(n){n.mergeShapes=(t,e)=>({...t,...e})})(Km||(Km={}));const Rt=pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Rs=n=>{switch(typeof n){case"undefined":return Rt.undefined;case"string":return Rt.string;case"number":return isNaN(n)?Rt.nan:Rt.number;case"boolean":return Rt.boolean;case"function":return Rt.function;case"bigint":return Rt.bigint;case"symbol":return Rt.symbol;case"object":return Array.isArray(n)?Rt.array:n===null?Rt.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Rt.promise:typeof Map<"u"&&n instanceof Map?Rt.map:typeof Set<"u"&&n instanceof Set?Rt.set:typeof Date<"u"&&n instanceof Date?Rt.date:Rt.object;default:return Rt.unknown}},gt=pe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),tL=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class jr extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(e(o));else{let a=r,u=0;for(;u<o.path.length;){const f=o.path[u];u===o.path.length-1?(a[f]=a[f]||{_errors:[]},a[f]._errors.push(e(o))):a[f]=a[f]||{_errors:[]},a=a[f],u++}}};return i(this),r}static assert(t){if(!(t instanceof jr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},r=[];for(const i of this.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:e}}get formErrors(){return this.flatten()}}jr.create=n=>new jr(n);const hl=(n,t)=>{let e;switch(n.code){case gt.invalid_type:n.received===Rt.undefined?e="Required":e=`Expected ${n.expected}, received ${n.received}`;break;case gt.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(n.expected,pe.jsonStringifyReplacer)}`;break;case gt.unrecognized_keys:e=`Unrecognized key(s) in object: ${pe.joinValues(n.keys,", ")}`;break;case gt.invalid_union:e="Invalid input";break;case gt.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${pe.joinValues(n.options)}`;break;case gt.invalid_enum_value:e=`Invalid enum value. Expected ${pe.joinValues(n.options)}, received '${n.received}'`;break;case gt.invalid_arguments:e="Invalid function arguments";break;case gt.invalid_return_type:e="Invalid function return type";break;case gt.invalid_date:e="Invalid date";break;case gt.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(e=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?e=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?e=`Invalid input: must end with "${n.validation.endsWith}"`:pe.assertNever(n.validation):n.validation!=="regex"?e=`Invalid ${n.validation}`:e="Invalid";break;case gt.too_small:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:e="Invalid input";break;case gt.too_big:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?e=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:e="Invalid input";break;case gt.custom:e="Invalid input";break;case gt.invalid_intersection_types:e="Intersection results could not be merged";break;case gt.not_multiple_of:e=`Number must be a multiple of ${n.multipleOf}`;break;case gt.not_finite:e="Number must be finite";break;default:e=t.defaultError,pe.assertNever(n)}return{message:e}};let zx=hl;function eL(n){zx=n}function I0(){return zx}const S0=n=>{const{data:t,path:e,errorMaps:r,issueData:i}=n,s=[...e,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const u=r.filter(f=>!!f).slice().reverse();for(const f of u)a=f(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}},nL=[];function At(n,t){const e=I0(),r=S0({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,e,e===hl?void 0:hl].filter(i=>!!i)});n.common.issues.push(r)}class ur{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const r=[];for(const i of e){if(i.status==="aborted")return Gt;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,e){const r=[];for(const i of e){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return ur.mergeObjectSync(t,r)}static mergeObjectSync(t,e){const r={};for(const i of e){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Gt;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Gt=Object.freeze({status:"aborted"}),nu=n=>({status:"dirty",value:n}),_r=n=>({status:"valid",value:n}),jm=n=>n.status==="aborted",Wm=n=>n.status==="dirty",fc=n=>n.status==="valid",Yf=n=>typeof Promise<"u"&&n instanceof Promise;function k0(n,t,e,r){if(typeof t=="function"?n!==t||!r:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(n)}function Gx(n,t,e,r,i){if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(n,e),e}var Bt;(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Bt||(Bt={}));var Bf,Pf;class cs{constructor(t,e,r,i){this._cachedPath=[],this.parent=t,this.data=e,this._path=r,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const _A=(n,t)=>{if(fc(t))return{success:!0,data:t.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new jr(n.common.issues);return this._error=e,this._error}}};function Jt(n){if(!n)return{};const{errorMap:t,invalid_type_error:e,required_error:r,description:i}=n;if(t&&(e||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{var u,f;const{message:h}=n;return o.code==="invalid_enum_value"?{message:h??a.defaultError}:typeof a.data>"u"?{message:(u=h??r)!==null&&u!==void 0?u:a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:(f=h??e)!==null&&f!==void 0?f:a.defaultError}},description:i}}class re{get description(){return this._def.description}_getType(t){return Rs(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Rs(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ur,ctx:{common:t.parent.common,data:t.data,parsedType:Rs(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(Yf(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){var r;const i={common:{issues:[],async:(r=e==null?void 0:e.async)!==null&&r!==void 0?r:!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Rs(t)},s=this._parseSync({data:t,path:i.path,parent:i});return _A(i,s)}"~validate"(t){var e,r;const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Rs(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:i});return fc(s)?{value:s.value}:{issues:i.common.issues}}catch(s){!((r=(e=s==null?void 0:s.message)===null||e===void 0?void 0:e.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:i}).then(s=>fc(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(t,e){const r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){const r={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Rs(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(Yf(i)?i:Promise.resolve(i));return _A(r,s)}refine(t,e){const r=i=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(i):e;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:gt.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,e){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof e=="function"?e(r,i):e),!1))}_refinement(t){return new Si({schema:this,typeName:zt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return rs.create(this,this._def)}nullable(){return ia.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ri.create(this)}promise(){return pl.create(this,this._def)}or(t){return nh.create([this,t],this._def)}and(t){return rh.create(this,t,this._def)}transform(t){return new Si({...Jt(this._def),schema:this,typeName:zt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new ch({...Jt(this._def),innerType:this,defaultValue:e,typeName:zt.ZodDefault})}brand(){return new a1({typeName:zt.ZodBranded,type:this,...Jt(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new uh({...Jt(this._def),innerType:this,catchValue:e,typeName:zt.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return td.create(this,t)}readonly(){return lh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const rL=/^c[^\s-]{8,}$/i,iL=/^[0-9a-z]+$/,sL=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oL=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,aL=/^[a-z0-9_-]{21}$/i,cL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,uL=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,lL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,fL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let My;const hL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,dL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,pL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,gL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Vx="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",wL=new RegExp(`^${Vx}$`);function Kx(n){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`),t}function bL(n){return new RegExp(`^${Kx(n)}$`)}function jx(n){let t=`${Vx}T${Kx(n)}`;const e=[];return e.push(n.local?"Z?":"Z"),n.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function _L(n,t){return!!((t==="v4"||!t)&&hL.test(n)||(t==="v6"||!t)&&pL.test(n))}function AL(n,t){if(!cL.test(n))return!1;try{const[e]=n.split("."),r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||!i.typ||!i.alg||t&&i.alg!==t)}catch{return!1}}function EL(n,t){return!!((t==="v4"||!t)&&dL.test(n)||(t==="v6"||!t)&&gL.test(n))}class vi extends re{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Rt.string){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:Rt.string,received:s.parsedType}),Gt}const r=new ur;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?At(i,{code:gt.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&At(i,{code:gt.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")lL.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"email",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")My||(My=new RegExp(fL,"u")),My.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"emoji",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")oL.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"uuid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")aL.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"nanoid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")rL.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cuid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")iL.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cuid2",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")sL.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"ulid",code:gt.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),At(i,{validation:"url",code:gt.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"regex",code:gt.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?jx(s).test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?wL.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?bL(s).test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{code:gt.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?uL.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"duration",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?_L(t.data,s.version)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"ip",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?AL(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"jwt",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?EL(t.data,s.version)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"cidr",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?yL.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"base64",code:gt.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?mL.test(t.data)||(i=this._getOrReturnCtx(t,i),At(i,{validation:"base64url",code:gt.invalid_string,message:s.message}),r.dirty()):pe.assertNever(s);return{status:r.value,value:t.data}}_regex(t,e,r){return this.refinement(i=>t.test(i),{validation:e,code:gt.invalid_string,...Bt.errToObj(r)})}_addCheck(t){return new vi({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Bt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Bt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Bt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Bt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Bt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Bt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Bt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Bt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Bt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Bt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Bt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Bt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Bt.errToObj(t)})}datetime(t){var e,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(e=t==null?void 0:t.offset)!==null&&e!==void 0?e:!1,local:(r=t==null?void 0:t.local)!==null&&r!==void 0?r:!1,...Bt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Bt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Bt.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...Bt.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e==null?void 0:e.position,...Bt.errToObj(e==null?void 0:e.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...Bt.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...Bt.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...Bt.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...Bt.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...Bt.errToObj(e)})}nonempty(t){return this.min(1,Bt.errToObj(t))}trim(){return new vi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new vi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new vi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}vi.create=n=>{var t;return new vi({checks:[],typeName:zt.ZodString,coerce:(t=n==null?void 0:n.coerce)!==null&&t!==void 0?t:!1,...Jt(n)})};function vL(n,t){const e=(n.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=e>r?e:r,s=parseInt(n.toFixed(i).replace(".","")),o=parseInt(t.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class ea extends re{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Rt.number){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:Rt.number,received:s.parsedType}),Gt}let r;const i=new ur;for(const s of this._def.checks)s.kind==="int"?pe.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),At(r,{code:gt.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?vL(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_finite,message:s.message}),i.dirty()):pe.assertNever(s);return{status:i.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,Bt.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Bt.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Bt.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Bt.toString(e))}setLimit(t,e,r,i){return new ea({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Bt.toString(i)}]})}_addCheck(t){return new ea({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Bt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Bt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Bt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Bt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Bt.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Bt.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:Bt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Bt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Bt.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&pe.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(e===null||r.value>e)&&(e=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(e)&&Number.isFinite(t)}}ea.create=n=>new ea({checks:[],typeName:zt.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...Jt(n)});class na extends re{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Rt.bigint)return this._getInvalidInput(t);let r;const i=new ur;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),At(r,{code:gt.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):pe.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return At(e,{code:gt.invalid_type,expected:Rt.bigint,received:e.parsedType}),Gt}gte(t,e){return this.setLimit("min",t,!0,Bt.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Bt.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Bt.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Bt.toString(e))}setLimit(t,e,r,i){return new na({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Bt.toString(i)}]})}_addCheck(t){return new na({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Bt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Bt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Bt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Bt.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Bt.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}na.create=n=>{var t;return new na({checks:[],typeName:zt.ZodBigInt,coerce:(t=n==null?void 0:n.coerce)!==null&&t!==void 0?t:!1,...Jt(n)})};class Xf extends re{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Rt.boolean){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.boolean,received:r.parsedType}),Gt}return _r(t.data)}}Xf.create=n=>new Xf({typeName:zt.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...Jt(n)});class hc extends re{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Rt.date){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_type,expected:Rt.date,received:s.parsedType}),Gt}if(isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return At(s,{code:gt.invalid_date}),Gt}const r=new ur;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),At(i,{code:gt.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):pe.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new hc({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:Bt.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:Bt.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}hc.create=n=>new hc({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:zt.ZodDate,...Jt(n)});class T0 extends re{_parse(t){if(this._getType(t)!==Rt.symbol){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.symbol,received:r.parsedType}),Gt}return _r(t.data)}}T0.create=n=>new T0({typeName:zt.ZodSymbol,...Jt(n)});class th extends re{_parse(t){if(this._getType(t)!==Rt.undefined){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.undefined,received:r.parsedType}),Gt}return _r(t.data)}}th.create=n=>new th({typeName:zt.ZodUndefined,...Jt(n)});class eh extends re{_parse(t){if(this._getType(t)!==Rt.null){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.null,received:r.parsedType}),Gt}return _r(t.data)}}eh.create=n=>new eh({typeName:zt.ZodNull,...Jt(n)});class dl extends re{constructor(){super(...arguments),this._any=!0}_parse(t){return _r(t.data)}}dl.create=n=>new dl({typeName:zt.ZodAny,...Jt(n)});class oc extends re{constructor(){super(...arguments),this._unknown=!0}_parse(t){return _r(t.data)}}oc.create=n=>new oc({typeName:zt.ZodUnknown,...Jt(n)});class Xs extends re{_parse(t){const e=this._getOrReturnCtx(t);return At(e,{code:gt.invalid_type,expected:Rt.never,received:e.parsedType}),Gt}}Xs.create=n=>new Xs({typeName:zt.ZodNever,...Jt(n)});class O0 extends re{_parse(t){if(this._getType(t)!==Rt.undefined){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.void,received:r.parsedType}),Gt}return _r(t.data)}}O0.create=n=>new O0({typeName:zt.ZodVoid,...Jt(n)});class Ri extends re{_parse(t){const{ctx:e,status:r}=this._processInputParams(t),i=this._def;if(e.parsedType!==Rt.array)return At(e,{code:gt.invalid_type,expected:Rt.array,received:e.parsedType}),Gt;if(i.exactLength!==null){const o=e.data.length>i.exactLength.value,a=e.data.length<i.exactLength.value;(o||a)&&(At(e,{code:o?gt.too_big:gt.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&e.data.length<i.minLength.value&&(At(e,{code:gt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&e.data.length>i.maxLength.value&&(At(e,{code:gt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),e.common.async)return Promise.all([...e.data].map((o,a)=>i.type._parseAsync(new cs(e,o,e.path,a)))).then(o=>ur.mergeArray(r,o));const s=[...e.data].map((o,a)=>i.type._parseSync(new cs(e,o,e.path,a)));return ur.mergeArray(r,s)}get element(){return this._def.type}min(t,e){return new Ri({...this._def,minLength:{value:t,message:Bt.toString(e)}})}max(t,e){return new Ri({...this._def,maxLength:{value:t,message:Bt.toString(e)}})}length(t,e){return new Ri({...this._def,exactLength:{value:t,message:Bt.toString(e)}})}nonempty(t){return this.min(1,t)}}Ri.create=(n,t)=>new Ri({type:n,minLength:null,maxLength:null,exactLength:null,typeName:zt.ZodArray,...Jt(t)});function Qc(n){if(n instanceof en){const t={};for(const e in n.shape){const r=n.shape[e];t[e]=rs.create(Qc(r))}return new en({...n._def,shape:()=>t})}else return n instanceof Ri?new Ri({...n._def,type:Qc(n.element)}):n instanceof rs?rs.create(Qc(n.unwrap())):n instanceof ia?ia.create(Qc(n.unwrap())):n instanceof us?us.create(n.items.map(t=>Qc(t))):n}class en extends re{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=pe.objectKeys(t);return this._cached={shape:t,keys:e}}_parse(t){if(this._getType(t)!==Rt.object){const f=this._getOrReturnCtx(t);return At(f,{code:gt.invalid_type,expected:Rt.object,received:f.parsedType}),Gt}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Xs&&this._def.unknownKeys==="strip"))for(const f in i.data)o.includes(f)||a.push(f);const u=[];for(const f of o){const h=s[f],y=i.data[f];u.push({key:{status:"valid",value:f},value:h._parse(new cs(i,y,i.path,f)),alwaysSet:f in i.data})}if(this._def.catchall instanceof Xs){const f=this._def.unknownKeys;if(f==="passthrough")for(const h of a)u.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(f==="strict")a.length>0&&(At(i,{code:gt.unrecognized_keys,keys:a}),r.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const f=this._def.catchall;for(const h of a){const y=i.data[h];u.push({key:{status:"valid",value:h},value:f._parse(new cs(i,y,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const f=[];for(const h of u){const y=await h.key,_=await h.value;f.push({key:y,value:_,alwaysSet:h.alwaysSet})}return f}).then(f=>ur.mergeObjectSync(r,f)):ur.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return Bt.errToObj,new en({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,r)=>{var i,s,o,a;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,e,r).message)!==null&&o!==void 0?o:r.defaultError;return e.code==="unrecognized_keys"?{message:(a=Bt.errToObj(t).message)!==null&&a!==void 0?a:u}:{message:u}}}:{}})}strip(){return new en({...this._def,unknownKeys:"strip"})}passthrough(){return new en({...this._def,unknownKeys:"passthrough"})}extend(t){return new en({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new en({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:zt.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new en({...this._def,catchall:t})}pick(t){const e={};return pe.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(e[r]=this.shape[r])}),new en({...this._def,shape:()=>e})}omit(t){const e={};return pe.objectKeys(this.shape).forEach(r=>{t[r]||(e[r]=this.shape[r])}),new en({...this._def,shape:()=>e})}deepPartial(){return Qc(this)}partial(t){const e={};return pe.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];t&&!t[r]?e[r]=i:e[r]=i.optional()}),new en({...this._def,shape:()=>e})}required(t){const e={};return pe.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])e[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof rs;)s=s._def.innerType;e[r]=s}}),new en({...this._def,shape:()=>e})}keyof(){return Wx(pe.objectKeys(this.shape))}}en.create=(n,t)=>new en({shape:()=>n,unknownKeys:"strip",catchall:Xs.create(),typeName:zt.ZodObject,...Jt(t)});en.strictCreate=(n,t)=>new en({shape:()=>n,unknownKeys:"strict",catchall:Xs.create(),typeName:zt.ZodObject,...Jt(t)});en.lazycreate=(n,t)=>new en({shape:n,unknownKeys:"strip",catchall:Xs.create(),typeName:zt.ZodObject,...Jt(t)});class nh extends re{_parse(t){const{ctx:e}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return e.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new jr(a.ctx.common.issues));return At(e,{code:gt.invalid_union,unionErrors:o}),Gt}if(e.common.async)return Promise.all(r.map(async s=>{const o={...e,common:{...e.common,issues:[]},parent:null};return{result:await s._parseAsync({data:e.data,path:e.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of r){const f={...e,common:{...e.common,issues:[]},parent:null},h=u._parseSync({data:e.data,path:e.path,parent:f});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(s)return e.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(u=>new jr(u));return At(e,{code:gt.invalid_union,unionErrors:a}),Gt}}get options(){return this._def.options}}nh.create=(n,t)=>new nh({options:n,typeName:zt.ZodUnion,...Jt(t)});const _s=n=>n instanceof sh?_s(n.schema):n instanceof Si?_s(n.innerType()):n instanceof oh?[n.value]:n instanceof ra?n.options:n instanceof ah?pe.objectValues(n.enum):n instanceof ch?_s(n._def.innerType):n instanceof th?[void 0]:n instanceof eh?[null]:n instanceof rs?[void 0,..._s(n.unwrap())]:n instanceof ia?[null,..._s(n.unwrap())]:n instanceof a1||n instanceof lh?_s(n.unwrap()):n instanceof uh?_s(n._def.innerType):[];class Ep extends re{_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==Rt.object)return At(e,{code:gt.invalid_type,expected:Rt.object,received:e.parsedType}),Gt;const r=this.discriminator,i=e.data[r],s=this.optionsMap.get(i);return s?e.common.async?s._parseAsync({data:e.data,path:e.path,parent:e}):s._parseSync({data:e.data,path:e.path,parent:e}):(At(e,{code:gt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Gt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,e,r){const i=new Map;for(const s of e){const o=_s(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new Ep({typeName:zt.ZodDiscriminatedUnion,discriminator:t,options:e,optionsMap:i,...Jt(r)})}}function Zm(n,t){const e=Rs(n),r=Rs(t);if(n===t)return{valid:!0,data:n};if(e===Rt.object&&r===Rt.object){const i=pe.objectKeys(t),s=pe.objectKeys(n).filter(a=>i.indexOf(a)!==-1),o={...n,...t};for(const a of s){const u=Zm(n[a],t[a]);if(!u.valid)return{valid:!1};o[a]=u.data}return{valid:!0,data:o}}else if(e===Rt.array&&r===Rt.array){if(n.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<n.length;s++){const o=n[s],a=t[s],u=Zm(o,a);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return e===Rt.date&&r===Rt.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}class rh extends re{_parse(t){const{status:e,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(jm(s)||jm(o))return Gt;const a=Zm(s.value,o.value);return a.valid?((Wm(s)||Wm(o))&&e.dirty(),{status:e.value,value:a.data}):(At(r,{code:gt.invalid_intersection_types}),Gt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}rh.create=(n,t,e)=>new rh({left:n,right:t,typeName:zt.ZodIntersection,...Jt(e)});class us extends re{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Rt.array)return At(r,{code:gt.invalid_type,expected:Rt.array,received:r.parsedType}),Gt;if(r.data.length<this._def.items.length)return At(r,{code:gt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Gt;!this._def.rest&&r.data.length>this._def.items.length&&(At(r,{code:gt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const s=[...r.data].map((o,a)=>{const u=this._def.items[a]||this._def.rest;return u?u._parse(new cs(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>ur.mergeArray(e,o)):ur.mergeArray(e,s)}get items(){return this._def.items}rest(t){return new us({...this._def,rest:t})}}us.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new us({items:n,typeName:zt.ZodTuple,rest:null,...Jt(t)})};class ih extends re{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Rt.object)return At(r,{code:gt.invalid_type,expected:Rt.object,received:r.parsedType}),Gt;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new cs(r,a,r.path,a)),value:o._parse(new cs(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?ur.mergeObjectAsync(e,i):ur.mergeObjectSync(e,i)}get element(){return this._def.valueType}static create(t,e,r){return e instanceof re?new ih({keyType:t,valueType:e,typeName:zt.ZodRecord,...Jt(r)}):new ih({keyType:vi.create(),valueType:t,typeName:zt.ZodRecord,...Jt(e)})}}class N0 extends re{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Rt.map)return At(r,{code:gt.invalid_type,expected:Rt.map,received:r.parsedType}),Gt;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,u],f)=>({key:i._parse(new cs(r,a,r.path,[f,"key"])),value:s._parse(new cs(r,u,r.path,[f,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const u of o){const f=await u.key,h=await u.value;if(f.status==="aborted"||h.status==="aborted")return Gt;(f.status==="dirty"||h.status==="dirty")&&e.dirty(),a.set(f.value,h.value)}return{status:e.value,value:a}})}else{const a=new Map;for(const u of o){const f=u.key,h=u.value;if(f.status==="aborted"||h.status==="aborted")return Gt;(f.status==="dirty"||h.status==="dirty")&&e.dirty(),a.set(f.value,h.value)}return{status:e.value,value:a}}}}N0.create=(n,t,e)=>new N0({valueType:t,keyType:n,typeName:zt.ZodMap,...Jt(e)});class dc extends re{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Rt.set)return At(r,{code:gt.invalid_type,expected:Rt.set,received:r.parsedType}),Gt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(At(r,{code:gt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),e.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(At(r,{code:gt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),e.dirty());const s=this._def.valueType;function o(u){const f=new Set;for(const h of u){if(h.status==="aborted")return Gt;h.status==="dirty"&&e.dirty(),f.add(h.value)}return{status:e.value,value:f}}const a=[...r.data.values()].map((u,f)=>s._parse(new cs(r,u,r.path,f)));return r.common.async?Promise.all(a).then(u=>o(u)):o(a)}min(t,e){return new dc({...this._def,minSize:{value:t,message:Bt.toString(e)}})}max(t,e){return new dc({...this._def,maxSize:{value:t,message:Bt.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}dc.create=(n,t)=>new dc({valueType:n,minSize:null,maxSize:null,typeName:zt.ZodSet,...Jt(t)});class hu extends re{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==Rt.function)return At(e,{code:gt.invalid_type,expected:Rt.function,received:e.parsedType}),Gt;function r(a,u){return S0({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,I0(),hl].filter(f=>!!f),issueData:{code:gt.invalid_arguments,argumentsError:u}})}function i(a,u){return S0({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,I0(),hl].filter(f=>!!f),issueData:{code:gt.invalid_return_type,returnTypeError:u}})}const s={errorMap:e.common.contextualErrorMap},o=e.data;if(this._def.returns instanceof pl){const a=this;return _r(async function(...u){const f=new jr([]),h=await a._def.args.parseAsync(u,s).catch(w=>{throw f.addIssue(r(u,w)),f}),y=await Reflect.apply(o,this,h);return await a._def.returns._def.type.parseAsync(y,s).catch(w=>{throw f.addIssue(i(y,w)),f})})}else{const a=this;return _r(function(...u){const f=a._def.args.safeParse(u,s);if(!f.success)throw new jr([r(u,f.error)]);const h=Reflect.apply(o,this,f.data),y=a._def.returns.safeParse(h,s);if(!y.success)throw new jr([i(h,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new hu({...this._def,args:us.create(t).rest(oc.create())})}returns(t){return new hu({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,e,r){return new hu({args:t||us.create([]).rest(oc.create()),returns:e||oc.create(),typeName:zt.ZodFunction,...Jt(r)})}}class sh extends re{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}sh.create=(n,t)=>new sh({getter:n,typeName:zt.ZodLazy,...Jt(t)});class oh extends re{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return At(e,{received:e.data,code:gt.invalid_literal,expected:this._def.value}),Gt}return{status:"valid",value:t.data}}get value(){return this._def.value}}oh.create=(n,t)=>new oh({value:n,typeName:zt.ZodLiteral,...Jt(t)});function Wx(n,t){return new ra({values:n,typeName:zt.ZodEnum,...Jt(t)})}class ra extends re{constructor(){super(...arguments),Bf.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),r=this._def.values;return At(e,{expected:pe.joinValues(r),received:e.parsedType,code:gt.invalid_type}),Gt}if(k0(this,Bf)||Gx(this,Bf,new Set(this._def.values)),!k0(this,Bf).has(t.data)){const e=this._getOrReturnCtx(t),r=this._def.values;return At(e,{received:e.data,code:gt.invalid_enum_value,options:r}),Gt}return _r(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return ra.create(t,{...this._def,...e})}exclude(t,e=this._def){return ra.create(this.options.filter(r=>!t.includes(r)),{...this._def,...e})}}Bf=new WeakMap;ra.create=Wx;class ah extends re{constructor(){super(...arguments),Pf.set(this,void 0)}_parse(t){const e=pe.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Rt.string&&r.parsedType!==Rt.number){const i=pe.objectValues(e);return At(r,{expected:pe.joinValues(i),received:r.parsedType,code:gt.invalid_type}),Gt}if(k0(this,Pf)||Gx(this,Pf,new Set(pe.getValidEnumValues(this._def.values))),!k0(this,Pf).has(t.data)){const i=pe.objectValues(e);return At(r,{received:r.data,code:gt.invalid_enum_value,options:i}),Gt}return _r(t.data)}get enum(){return this._def.values}}Pf=new WeakMap;ah.create=(n,t)=>new ah({values:n,typeName:zt.ZodNativeEnum,...Jt(t)});class pl extends re{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==Rt.promise&&e.common.async===!1)return At(e,{code:gt.invalid_type,expected:Rt.promise,received:e.parsedType}),Gt;const r=e.parsedType===Rt.promise?e.data:Promise.resolve(e.data);return _r(r.then(i=>this._def.type.parseAsync(i,{path:e.path,errorMap:e.common.contextualErrorMap})))}}pl.create=(n,t)=>new pl({type:n,typeName:zt.ZodPromise,...Jt(t)});class Si extends re{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===zt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{At(r,o),o.fatal?e.abort():e.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(e.value==="aborted")return Gt;const u=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return u.status==="aborted"?Gt:u.status==="dirty"||e.value==="dirty"?nu(u.value):u});{if(e.value==="aborted")return Gt;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Gt:a.status==="dirty"||e.value==="dirty"?nu(a.value):a}}if(i.type==="refinement"){const o=a=>{const u=i.refinement(a,s);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Gt:(a.status==="dirty"&&e.dirty(),o(a.value),{status:e.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Gt:(a.status==="dirty"&&e.dirty(),o(a.value).then(()=>({status:e.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!fc(o))return o;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>fc(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:e.value,value:a})):o);pe.assertNever(i)}}Si.create=(n,t,e)=>new Si({schema:n,typeName:zt.ZodEffects,effect:t,...Jt(e)});Si.createWithPreprocess=(n,t,e)=>new Si({schema:t,effect:{type:"preprocess",transform:n},typeName:zt.ZodEffects,...Jt(e)});class rs extends re{_parse(t){return this._getType(t)===Rt.undefined?_r(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}rs.create=(n,t)=>new rs({innerType:n,typeName:zt.ZodOptional,...Jt(t)});class ia extends re{_parse(t){return this._getType(t)===Rt.null?_r(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ia.create=(n,t)=>new ia({innerType:n,typeName:zt.ZodNullable,...Jt(t)});class ch extends re{_parse(t){const{ctx:e}=this._processInputParams(t);let r=e.data;return e.parsedType===Rt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}ch.create=(n,t)=>new ch({innerType:n,typeName:zt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Jt(t)});class uh extends re{_parse(t){const{ctx:e}=this._processInputParams(t),r={...e,common:{...e.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Yf(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new jr(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new jr(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}uh.create=(n,t)=>new uh({innerType:n,typeName:zt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Jt(t)});class C0 extends re{_parse(t){if(this._getType(t)!==Rt.nan){const r=this._getOrReturnCtx(t);return At(r,{code:gt.invalid_type,expected:Rt.nan,received:r.parsedType}),Gt}return{status:"valid",value:t.data}}}C0.create=n=>new C0({typeName:zt.ZodNaN,...Jt(n)});const xL=Symbol("zod_brand");class a1 extends re{_parse(t){const{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}}class td extends re{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Gt:s.status==="dirty"?(e.dirty(),nu(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Gt:i.status==="dirty"?(e.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,e){return new td({in:t,out:e,typeName:zt.ZodPipeline})}}class lh extends re{_parse(t){const e=this._def.innerType._parse(t),r=i=>(fc(i)&&(i.value=Object.freeze(i.value)),i);return Yf(e)?e.then(i=>r(i)):r(e)}unwrap(){return this._def.innerType}}lh.create=(n,t)=>new lh({innerType:n,typeName:zt.ZodReadonly,...Jt(t)});function Zx(n,t={},e){return n?dl.create().superRefine((r,i)=>{var s,o;if(!n(r)){const a=typeof t=="function"?t(r):typeof t=="string"?{message:t}:t,u=(o=(s=a.fatal)!==null&&s!==void 0?s:e)!==null&&o!==void 0?o:!0,f=typeof a=="string"?{message:a}:a;i.addIssue({code:"custom",...f,fatal:u})}}):dl.create()}const RL={object:en.lazycreate};var zt;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(zt||(zt={}));const IL=(n,t={message:`Input not instance of ${n.name}`})=>Zx(e=>e instanceof n,t),qx=vi.create,Qx=ea.create,SL=C0.create,kL=na.create,Jx=Xf.create,TL=hc.create,OL=T0.create,NL=th.create,CL=eh.create,BL=dl.create,PL=oc.create,ML=Xs.create,LL=O0.create,UL=Ri.create,DL=en.create,FL=en.strictCreate,$L=nh.create,HL=Ep.create,zL=rh.create,GL=us.create,VL=ih.create,KL=N0.create,jL=dc.create,WL=hu.create,ZL=sh.create,qL=oh.create,QL=ra.create,JL=ah.create,YL=pl.create,AA=Si.create,XL=rs.create,tU=ia.create,eU=Si.createWithPreprocess,nU=td.create,rU=()=>qx().optional(),iU=()=>Qx().optional(),sU=()=>Jx().optional(),oU={string:n=>vi.create({...n,coerce:!0}),number:n=>ea.create({...n,coerce:!0}),boolean:n=>Xf.create({...n,coerce:!0}),bigint:n=>na.create({...n,coerce:!0}),date:n=>hc.create({...n,coerce:!0})},aU=Gt;var Ao=Object.freeze({__proto__:null,defaultErrorMap:hl,setErrorMap:eL,getErrorMap:I0,makeIssue:S0,EMPTY_PATH:nL,addIssueToContext:At,ParseStatus:ur,INVALID:Gt,DIRTY:nu,OK:_r,isAborted:jm,isDirty:Wm,isValid:fc,isAsync:Yf,get util(){return pe},get objectUtil(){return Km},ZodParsedType:Rt,getParsedType:Rs,ZodType:re,datetimeRegex:jx,ZodString:vi,ZodNumber:ea,ZodBigInt:na,ZodBoolean:Xf,ZodDate:hc,ZodSymbol:T0,ZodUndefined:th,ZodNull:eh,ZodAny:dl,ZodUnknown:oc,ZodNever:Xs,ZodVoid:O0,ZodArray:Ri,ZodObject:en,ZodUnion:nh,ZodDiscriminatedUnion:Ep,ZodIntersection:rh,ZodTuple:us,ZodRecord:ih,ZodMap:N0,ZodSet:dc,ZodFunction:hu,ZodLazy:sh,ZodLiteral:oh,ZodEnum:ra,ZodNativeEnum:ah,ZodPromise:pl,ZodEffects:Si,ZodTransformer:Si,ZodOptional:rs,ZodNullable:ia,ZodDefault:ch,ZodCatch:uh,ZodNaN:C0,BRAND:xL,ZodBranded:a1,ZodPipeline:td,ZodReadonly:lh,custom:Zx,Schema:re,ZodSchema:re,late:RL,get ZodFirstPartyTypeKind(){return zt},coerce:oU,any:BL,array:UL,bigint:kL,boolean:Jx,date:TL,discriminatedUnion:HL,effect:AA,enum:QL,function:WL,instanceof:IL,intersection:zL,lazy:ZL,literal:qL,map:KL,nan:SL,nativeEnum:JL,never:ML,null:CL,nullable:tU,number:Qx,object:DL,oboolean:sU,onumber:iU,optional:XL,ostring:rU,pipeline:nU,preprocess:eU,promise:YL,record:VL,set:jL,strictObject:FL,string:qx,symbol:OL,transformer:AA,tuple:GL,undefined:NL,union:$L,unknown:PL,void:LL,NEVER:aU,ZodIssueCode:gt,quotelessJson:tL,ZodError:jr});const c1=es.getInstance(),Yx=Ao.object({username:Ao.string(),address:Ao.string(),timestamp:Ao.number(),index:Ao.number(),signature:Ao.string()}),cU=Ao.object({topic:Ao.string(),messageSender:Yx});function uU(n){const t=cU.safeParse(n);return t.success?n.messageSender&&!lU(n.messageSender)?(console.warn("Invalid messageSender"),!1):!0:(c1.warn(t.error.format()),!1)}function lU(n){const t=Yx.safeParse(n);return t.success?fU(n):(c1.warn(t.error.format()),!1)}function fU(n){try{const t={username:n.username,address:n.address,timestamp:n.timestamp},e=new TextEncoder,r=ar.concatBytes(e.encode(`Ethereum Signed Message:
|
|
11
|
+
32`),ar.keccak256(e.encode(JSON.stringify(t))));if(new Qt.Signature(n.signature).isValid(r,n.address))throw new Error("Signature verification failed!");return!0}catch(t){return c1.warn("Error in validateUserSignature",t),!1}}async function hU(n){const{condition:t,broadcast:e,maxRetries:r=2,initialDelayMs:i=2e3,checkIntervalMs:s=1e3,checkCount:o=10}=n;return new Promise((a,u)=>{let f=0;const h=async()=>{await bA(i);for(let y=0;y<o;y++){if(await Promise.resolve(t()))return a();await bA(s)}if(++f>=r)return u(new Error("Broadcast wait timeout"));console.warn(`Retrying broadcast... Attempt ${f} of ${r}`),await e(),h()};console.log("Starting broadcast..."),e().then(()=>h()).catch(u)})}const Mr={LOADING_INIT:"loadingInit",LOADING_PREVIOUS_MESSAGES:"loadingPreviousMessages",MESSAGE_RECEIVED:"messageReceived",MESSAGE_REQUEST_INITIATED:"messageRequestInitiated",MESSAGE_REQUEST_UPLOADED:"messageRequestUploaded",MESSAGE_REQUEST_ERROR:"messageRequestError",CRITICAL_ERROR:"criticalError"},dU=1e3;class pU{constructor(t,e){this.utils=t,this.emitter=e,this.logger=es.getInstance(),this.errorHandler=new o1,this.historyIndex=null}async init(){try{const t=await this.utils.fetchLatestChatMessage();this.historyIndex=t.index,await this.fetchPreviousMessages()}catch(t){this.errorHandler.handleError(t,"SwarmHistory.init")}}async fetchPreviousMessages(t=10){try{if(!this.historyIndex){this.logger.warn("History index is not set. Cannot fetch previous messages.");return}if(this.historyIndex.toBigInt()===0n){this.logger.warn("No previous messages to fetch.");return}const e=this.historyIndex.toBigInt(),r=e>BigInt(t)?e-BigInt(t):0n;for(let i=e-1n;i>=r;i--){const s=await this.utils.fetchChatMessage(Qt.FeedIndex.fromBigInt(i));if(this.emitter.emit(Mr.MESSAGE_RECEIVED,s),this.historyIndex=Qt.FeedIndex.fromBigInt(i),i===0n)break}}catch(e){this.errorHandler.handleError(e,"SwarmHistory.fetchPreviousMessages")}}}const gl=globalThis||void 0||self;var u1={},vp={};vp.byteLength=mU;vp.toByteArray=bU;vp.fromByteArray=EU;var Zi=[],Yr=[],gU=typeof Uint8Array<"u"?Uint8Array:Array,Ly="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Gc=0,yU=Ly.length;Gc<yU;++Gc)Zi[Gc]=Ly[Gc],Yr[Ly.charCodeAt(Gc)]=Gc;Yr[45]=62;Yr[95]=63;function Xx(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function mU(n){var t=Xx(n),e=t[0],r=t[1];return(e+r)*3/4-r}function wU(n,t,e){return(t+e)*3/4-e}function bU(n){var t,e=Xx(n),r=e[0],i=e[1],s=new gU(wU(n,r,i)),o=0,a=i>0?r-4:r,u;for(u=0;u<a;u+=4)t=Yr[n.charCodeAt(u)]<<18|Yr[n.charCodeAt(u+1)]<<12|Yr[n.charCodeAt(u+2)]<<6|Yr[n.charCodeAt(u+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=Yr[n.charCodeAt(u)]<<2|Yr[n.charCodeAt(u+1)]>>4,s[o++]=t&255),i===1&&(t=Yr[n.charCodeAt(u)]<<10|Yr[n.charCodeAt(u+1)]<<4|Yr[n.charCodeAt(u+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function _U(n){return Zi[n>>18&63]+Zi[n>>12&63]+Zi[n>>6&63]+Zi[n&63]}function AU(n,t,e){for(var r,i=[],s=t;s<e;s+=3)r=(n[s]<<16&16711680)+(n[s+1]<<8&65280)+(n[s+2]&255),i.push(_U(r));return i.join("")}function EU(n){for(var t,e=n.length,r=e%3,i=[],s=16383,o=0,a=e-r;o<a;o+=s)i.push(AU(n,o,o+s>a?a:o+s));return r===1?(t=n[e-1],i.push(Zi[t>>2]+Zi[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],i.push(Zi[t>>10]+Zi[t>>4&63]+Zi[t<<2&63]+"=")),i.join("")}var l1={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */l1.read=function(n,t,e,r,i){var s,o,a=i*8-r-1,u=(1<<a)-1,f=u>>1,h=-7,y=e?i-1:0,_=e?-1:1,w=n[t+y];for(y+=_,s=w&(1<<-h)-1,w>>=-h,h+=a;h>0;s=s*256+n[t+y],y+=_,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=r;h>0;o=o*256+n[t+y],y+=_,h-=8);if(s===0)s=1-f;else{if(s===u)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-f}return(w?-1:1)*o*Math.pow(2,s-r)};l1.write=function(n,t,e,r,i,s){var o,a,u,f=s*8-i-1,h=(1<<f)-1,y=h>>1,_=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=r?0:s-1,R=r?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+y>=1?t+=_/u:t+=_*Math.pow(2,1-y),t*u>=2&&(o++,u/=2),o+y>=h?(a=0,o=h):o+y>=1?(a=(t*u-1)*Math.pow(2,i),o=o+y):(a=t*Math.pow(2,y-1)*Math.pow(2,i),o=0));i>=8;n[e+w]=a&255,w+=R,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;n[e+w]=o&255,w+=R,o/=256,f-=8);n[e+w-R]|=T*128};/*!
|
|
12
12
|
* The buffer module from node.js, for the browser.
|
|
13
13
|
*
|
|
14
14
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
15
15
|
* @license MIT
|
|
16
|
-
*/(function(n){const t=ip,e=zw,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=h,n.SlowBuffer=W,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i;const{Uint8Array:s,ArrayBuffer:o,SharedArrayBuffer:c}=globalThis;h.TYPED_ARRAY_SUPPORT=u(),!h.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{const O=new s(1),w={foo:function(){return 42}};return Object.setPrototypeOf(w,s.prototype),Object.setPrototypeOf(O,w),O.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function f(O){if(O>i)throw new RangeError('The value "'+O+'" is invalid for option "size"');const w=new s(O);return Object.setPrototypeOf(w,h.prototype),w}function h(O,w,E){if(typeof O=="number"){if(typeof w=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return R(O)}return y(O,w,E)}h.poolSize=8192;function y(O,w,E){if(typeof O=="string")return k(O,w);if(o.isView(O))return B(O);if(O==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof O);if(Je(O,o)||O&&Je(O.buffer,o)||typeof c<"u"&&(Je(O,c)||O&&Je(O.buffer,c)))return H(O,w,E);if(typeof O=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const D=O.valueOf&&O.valueOf();if(D!=null&&D!==O)return h.from(D,w,E);const V=U(O);if(V)return V;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof O[Symbol.toPrimitive]=="function")return h.from(O[Symbol.toPrimitive]("string"),w,E);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof O)}h.from=function(O,w,E){return y(O,w,E)},Object.setPrototypeOf(h.prototype,s.prototype),Object.setPrototypeOf(h,s);function A(O){if(typeof O!="number")throw new TypeError('"size" argument must be of type number');if(O<0)throw new RangeError('The value "'+O+'" is invalid for option "size"')}function b(O,w,E){return A(O),O<=0?f(O):w!==void 0?typeof E=="string"?f(O).fill(w,E):f(O).fill(w):f(O)}h.alloc=function(O,w,E){return b(O,w,E)};function R(O){return A(O),f(O<0?0:G(O)|0)}h.allocUnsafe=function(O){return R(O)},h.allocUnsafeSlow=function(O){return R(O)};function k(O,w){if((typeof w!="string"||w==="")&&(w="utf8"),!h.isEncoding(w))throw new TypeError("Unknown encoding: "+w);const E=Y(O,w)|0;let D=f(E);const V=D.write(O,w);return V!==E&&(D=D.slice(0,V)),D}function S(O){const w=O.length<0?0:G(O.length)|0,E=f(w);for(let D=0;D<w;D+=1)E[D]=O[D]&255;return E}function B(O){if(Je(O,s)){const w=new s(O);return H(w.buffer,w.byteOffset,w.byteLength)}return S(O)}function H(O,w,E){if(w<0||O.byteLength<w)throw new RangeError('"offset" is outside of buffer bounds');if(O.byteLength<w+(E||0))throw new RangeError('"length" is outside of buffer bounds');let D;return w===void 0&&E===void 0?D=new s(O):E===void 0?D=new s(O,w):D=new s(O,w,E),Object.setPrototypeOf(D,h.prototype),D}function U(O){if(h.isBuffer(O)){const w=G(O.length)|0,E=f(w);return E.length===0||O.copy(E,0,0,w),E}if(O.length!==void 0)return typeof O.length!="number"||me(O.length)?f(0):S(O);if(O.type==="Buffer"&&Array.isArray(O.data))return S(O.data)}function G(O){if(O>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return O|0}function W(O){return+O!=O&&(O=0),h.alloc(+O)}h.isBuffer=function(w){return w!=null&&w._isBuffer===!0&&w!==h.prototype},h.compare=function(w,E){if(Je(w,s)&&(w=h.from(w,w.offset,w.byteLength)),Je(E,s)&&(E=h.from(E,E.offset,E.byteLength)),!h.isBuffer(w)||!h.isBuffer(E))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(w===E)return 0;let D=w.length,V=E.length;for(let q=0,st=Math.min(D,V);q<st;++q)if(w[q]!==E[q]){D=w[q],V=E[q];break}return D<V?-1:V<D?1:0},h.isEncoding=function(w){switch(String(w).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(w,E){if(!Array.isArray(w))throw new TypeError('"list" argument must be an Array of Buffers');if(w.length===0)return h.alloc(0);let D;if(E===void 0)for(E=0,D=0;D<w.length;++D)E+=w[D].length;const V=h.allocUnsafe(E);let q=0;for(D=0;D<w.length;++D){let st=w[D];if(Je(st,s))q+st.length>V.length?(h.isBuffer(st)||(st=h.from(st)),st.copy(V,q)):s.prototype.set.call(V,st,q);else if(h.isBuffer(st))st.copy(V,q);else throw new TypeError('"list" argument must be an Array of Buffers');q+=st.length}return V};function Y(O,w){if(h.isBuffer(O))return O.length;if(o.isView(O)||Je(O,o))return O.byteLength;if(typeof O!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof O);const E=O.length,D=arguments.length>2&&arguments[2]===!0;if(!D&&E===0)return 0;let V=!1;for(;;)switch(w){case"ascii":case"latin1":case"binary":return E;case"utf8":case"utf-8":return Ee(O).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E*2;case"hex":return E>>>1;case"base64":return ue(O).length;default:if(V)return D?-1:Ee(O).length;w=(""+w).toLowerCase(),V=!0}}h.byteLength=Y;function j(O,w,E){let D=!1;if((w===void 0||w<0)&&(w=0),w>this.length||((E===void 0||E>this.length)&&(E=this.length),E<=0)||(E>>>=0,w>>>=0,E<=w))return"";for(O||(O="utf8");;)switch(O){case"hex":return _(this,w,E);case"utf8":case"utf-8":return I(this,w,E);case"ascii":return z(this,w,E);case"latin1":case"binary":return P(this,w,E);case"base64":return v(this,w,E);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,w,E);default:if(D)throw new TypeError("Unknown encoding: "+O);O=(O+"").toLowerCase(),D=!0}}h.prototype._isBuffer=!0;function J(O,w,E){const D=O[w];O[w]=O[E],O[E]=D}h.prototype.swap16=function(){const w=this.length;if(w%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let E=0;E<w;E+=2)J(this,E,E+1);return this},h.prototype.swap32=function(){const w=this.length;if(w%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let E=0;E<w;E+=4)J(this,E,E+3),J(this,E+1,E+2);return this},h.prototype.swap64=function(){const w=this.length;if(w%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let E=0;E<w;E+=8)J(this,E,E+7),J(this,E+1,E+6),J(this,E+2,E+5),J(this,E+3,E+4);return this},h.prototype.toString=function(){const w=this.length;return w===0?"":arguments.length===0?I(this,0,w):j.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(w){if(!h.isBuffer(w))throw new TypeError("Argument must be a Buffer");return this===w?!0:h.compare(this,w)===0},h.prototype.inspect=function(){let w="";const E=n.INSPECT_MAX_BYTES;return w=this.toString("hex",0,E).replace(/(.{2})/g,"$1 ").trim(),this.length>E&&(w+=" ... "),"<Buffer "+w+">"},r&&(h.prototype[r]=h.prototype.inspect),h.prototype.compare=function(w,E,D,V,q){if(Je(w,s)&&(w=h.from(w,w.offset,w.byteLength)),!h.isBuffer(w))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof w);if(E===void 0&&(E=0),D===void 0&&(D=w?w.length:0),V===void 0&&(V=0),q===void 0&&(q=this.length),E<0||D>w.length||V<0||q>this.length)throw new RangeError("out of range index");if(V>=q&&E>=D)return 0;if(V>=q)return-1;if(E>=D)return 1;if(E>>>=0,D>>>=0,V>>>=0,q>>>=0,this===w)return 0;let st=q-V,Wt=D-E;const jt=Math.min(st,Wt),Kt=this.slice(V,q),Ue=w.slice(E,D);for(let Ft=0;Ft<jt;++Ft)if(Kt[Ft]!==Ue[Ft]){st=Kt[Ft],Wt=Ue[Ft];break}return st<Wt?-1:Wt<st?1:0};function it(O,w,E,D,V){if(O.length===0)return-1;if(typeof E=="string"?(D=E,E=0):E>2147483647?E=2147483647:E<-2147483648&&(E=-2147483648),E=+E,me(E)&&(E=V?0:O.length-1),E<0&&(E=O.length+E),E>=O.length){if(V)return-1;E=O.length-1}else if(E<0)if(V)E=0;else return-1;if(typeof w=="string"&&(w=h.from(w,D)),h.isBuffer(w))return w.length===0?-1:ut(O,w,E,D,V);if(typeof w=="number")return w=w&255,typeof s.prototype.indexOf=="function"?V?s.prototype.indexOf.call(O,w,E):s.prototype.lastIndexOf.call(O,w,E):ut(O,[w],E,D,V);throw new TypeError("val must be string, number or Buffer")}function ut(O,w,E,D,V){let q=1,st=O.length,Wt=w.length;if(D!==void 0&&(D=String(D).toLowerCase(),D==="ucs2"||D==="ucs-2"||D==="utf16le"||D==="utf-16le")){if(O.length<2||w.length<2)return-1;q=2,st/=2,Wt/=2,E/=2}function jt(Ue,Ft){return q===1?Ue[Ft]:Ue.readUInt16BE(Ft*q)}let Kt;if(V){let Ue=-1;for(Kt=E;Kt<st;Kt++)if(jt(O,Kt)===jt(w,Ue===-1?0:Kt-Ue)){if(Ue===-1&&(Ue=Kt),Kt-Ue+1===Wt)return Ue*q}else Ue!==-1&&(Kt-=Kt-Ue),Ue=-1}else for(E+Wt>st&&(E=st-Wt),Kt=E;Kt>=0;Kt--){let Ue=!0;for(let Ft=0;Ft<Wt;Ft++)if(jt(O,Kt+Ft)!==jt(w,Ft)){Ue=!1;break}if(Ue)return Kt}return-1}h.prototype.includes=function(w,E,D){return this.indexOf(w,E,D)!==-1},h.prototype.indexOf=function(w,E,D){return it(this,w,E,D,!0)},h.prototype.lastIndexOf=function(w,E,D){return it(this,w,E,D,!1)};function rt(O,w,E,D){E=Number(E)||0;const V=O.length-E;D?(D=Number(D),D>V&&(D=V)):D=V;const q=w.length;D>q/2&&(D=q/2);let st;for(st=0;st<D;++st){const Wt=parseInt(w.substr(st*2,2),16);if(me(Wt))return st;O[E+st]=Wt}return st}function ot(O,w,E,D){return ve(Ee(w,O.length-E),O,E,D)}function C(O,w,E,D){return ve(Ie(w),O,E,D)}function p(O,w,E,D){return ve(ue(w),O,E,D)}function m(O,w,E,D){return ve(_n(w,O.length-E),O,E,D)}h.prototype.write=function(w,E,D,V){if(E===void 0)V="utf8",D=this.length,E=0;else if(D===void 0&&typeof E=="string")V=E,D=this.length,E=0;else if(isFinite(E))E=E>>>0,isFinite(D)?(D=D>>>0,V===void 0&&(V="utf8")):(V=D,D=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const q=this.length-E;if((D===void 0||D>q)&&(D=q),w.length>0&&(D<0||E<0)||E>this.length)throw new RangeError("Attempt to write outside buffer bounds");V||(V="utf8");let st=!1;for(;;)switch(V){case"hex":return rt(this,w,E,D);case"utf8":case"utf-8":return ot(this,w,E,D);case"ascii":case"latin1":case"binary":return C(this,w,E,D);case"base64":return p(this,w,E,D);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,w,E,D);default:if(st)throw new TypeError("Unknown encoding: "+V);V=(""+V).toLowerCase(),st=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function v(O,w,E){return w===0&&E===O.length?t.fromByteArray(O):t.fromByteArray(O.slice(w,E))}function I(O,w,E){E=Math.min(O.length,E);const D=[];let V=w;for(;V<E;){const q=O[V];let st=null,Wt=q>239?4:q>223?3:q>191?2:1;if(V+Wt<=E){let jt,Kt,Ue,Ft;switch(Wt){case 1:q<128&&(st=q);break;case 2:jt=O[V+1],(jt&192)===128&&(Ft=(q&31)<<6|jt&63,Ft>127&&(st=Ft));break;case 3:jt=O[V+1],Kt=O[V+2],(jt&192)===128&&(Kt&192)===128&&(Ft=(q&15)<<12|(jt&63)<<6|Kt&63,Ft>2047&&(Ft<55296||Ft>57343)&&(st=Ft));break;case 4:jt=O[V+1],Kt=O[V+2],Ue=O[V+3],(jt&192)===128&&(Kt&192)===128&&(Ue&192)===128&&(Ft=(q&15)<<18|(jt&63)<<12|(Kt&63)<<6|Ue&63,Ft>65535&&Ft<1114112&&(st=Ft))}}st===null?(st=65533,Wt=1):st>65535&&(st-=65536,D.push(st>>>10&1023|55296),st=56320|st&1023),D.push(st),V+=Wt}return M(D)}const N=4096;function M(O){const w=O.length;if(w<=N)return String.fromCharCode.apply(String,O);let E="",D=0;for(;D<w;)E+=String.fromCharCode.apply(String,O.slice(D,D+=N));return E}function z(O,w,E){let D="";E=Math.min(O.length,E);for(let V=w;V<E;++V)D+=String.fromCharCode(O[V]&127);return D}function P(O,w,E){let D="";E=Math.min(O.length,E);for(let V=w;V<E;++V)D+=String.fromCharCode(O[V]);return D}function _(O,w,E){const D=O.length;(!w||w<0)&&(w=0),(!E||E<0||E>D)&&(E=D);let V="";for(let q=w;q<E;++q)V+=ke[O[q]];return V}function F(O,w,E){const D=O.slice(w,E);let V="";for(let q=0;q<D.length-1;q+=2)V+=String.fromCharCode(D[q]+D[q+1]*256);return V}h.prototype.slice=function(w,E){const D=this.length;w=~~w,E=E===void 0?D:~~E,w<0?(w+=D,w<0&&(w=0)):w>D&&(w=D),E<0?(E+=D,E<0&&(E=0)):E>D&&(E=D),E<w&&(E=w);const V=this.subarray(w,E);return Object.setPrototypeOf(V,h.prototype),V};function ct(O,w,E){if(O%1!==0||O<0)throw new RangeError("offset is not uint");if(O+w>E)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(w,E,D){w=w>>>0,E=E>>>0,D||ct(w,E,this.length);let V=this[w],q=1,st=0;for(;++st<E&&(q*=256);)V+=this[w+st]*q;return V},h.prototype.readUintBE=h.prototype.readUIntBE=function(w,E,D){w=w>>>0,E=E>>>0,D||ct(w,E,this.length);let V=this[w+--E],q=1;for(;E>0&&(q*=256);)V+=this[w+--E]*q;return V},h.prototype.readUint8=h.prototype.readUInt8=function(w,E){return w=w>>>0,E||ct(w,1,this.length),this[w]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(w,E){return w=w>>>0,E||ct(w,2,this.length),this[w]|this[w+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(w,E){return w=w>>>0,E||ct(w,2,this.length),this[w]<<8|this[w+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),(this[w]|this[w+1]<<8|this[w+2]<<16)+this[w+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),this[w]*16777216+(this[w+1]<<16|this[w+2]<<8|this[w+3])},h.prototype.readBigUInt64LE=Jn(function(w){w=w>>>0,Qe(w,"offset");const E=this[w],D=this[w+7];(E===void 0||D===void 0)&&ce(w,this.length-8);const V=E+this[++w]*2**8+this[++w]*2**16+this[++w]*2**24,q=this[++w]+this[++w]*2**8+this[++w]*2**16+D*2**24;return BigInt(V)+(BigInt(q)<<BigInt(32))}),h.prototype.readBigUInt64BE=Jn(function(w){w=w>>>0,Qe(w,"offset");const E=this[w],D=this[w+7];(E===void 0||D===void 0)&&ce(w,this.length-8);const V=E*2**24+this[++w]*2**16+this[++w]*2**8+this[++w],q=this[++w]*2**24+this[++w]*2**16+this[++w]*2**8+D;return(BigInt(V)<<BigInt(32))+BigInt(q)}),h.prototype.readIntLE=function(w,E,D){w=w>>>0,E=E>>>0,D||ct(w,E,this.length);let V=this[w],q=1,st=0;for(;++st<E&&(q*=256);)V+=this[w+st]*q;return q*=128,V>=q&&(V-=Math.pow(2,8*E)),V},h.prototype.readIntBE=function(w,E,D){w=w>>>0,E=E>>>0,D||ct(w,E,this.length);let V=E,q=1,st=this[w+--V];for(;V>0&&(q*=256);)st+=this[w+--V]*q;return q*=128,st>=q&&(st-=Math.pow(2,8*E)),st},h.prototype.readInt8=function(w,E){return w=w>>>0,E||ct(w,1,this.length),this[w]&128?(255-this[w]+1)*-1:this[w]},h.prototype.readInt16LE=function(w,E){w=w>>>0,E||ct(w,2,this.length);const D=this[w]|this[w+1]<<8;return D&32768?D|4294901760:D},h.prototype.readInt16BE=function(w,E){w=w>>>0,E||ct(w,2,this.length);const D=this[w+1]|this[w]<<8;return D&32768?D|4294901760:D},h.prototype.readInt32LE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),this[w]|this[w+1]<<8|this[w+2]<<16|this[w+3]<<24},h.prototype.readInt32BE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),this[w]<<24|this[w+1]<<16|this[w+2]<<8|this[w+3]},h.prototype.readBigInt64LE=Jn(function(w){w=w>>>0,Qe(w,"offset");const E=this[w],D=this[w+7];(E===void 0||D===void 0)&&ce(w,this.length-8);const V=this[w+4]+this[w+5]*2**8+this[w+6]*2**16+(D<<24);return(BigInt(V)<<BigInt(32))+BigInt(E+this[++w]*2**8+this[++w]*2**16+this[++w]*2**24)}),h.prototype.readBigInt64BE=Jn(function(w){w=w>>>0,Qe(w,"offset");const E=this[w],D=this[w+7];(E===void 0||D===void 0)&&ce(w,this.length-8);const V=(E<<24)+this[++w]*2**16+this[++w]*2**8+this[++w];return(BigInt(V)<<BigInt(32))+BigInt(this[++w]*2**24+this[++w]*2**16+this[++w]*2**8+D)}),h.prototype.readFloatLE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),e.read(this,w,!0,23,4)},h.prototype.readFloatBE=function(w,E){return w=w>>>0,E||ct(w,4,this.length),e.read(this,w,!1,23,4)},h.prototype.readDoubleLE=function(w,E){return w=w>>>0,E||ct(w,8,this.length),e.read(this,w,!0,52,8)},h.prototype.readDoubleBE=function(w,E){return w=w>>>0,E||ct(w,8,this.length),e.read(this,w,!1,52,8)};function ft(O,w,E,D,V,q){if(!h.isBuffer(O))throw new TypeError('"buffer" argument must be a Buffer instance');if(w>V||w<q)throw new RangeError('"value" argument is out of bounds');if(E+D>O.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(w,E,D,V){if(w=+w,E=E>>>0,D=D>>>0,!V){const Wt=Math.pow(2,8*D)-1;ft(this,w,E,D,Wt,0)}let q=1,st=0;for(this[E]=w&255;++st<D&&(q*=256);)this[E+st]=w/q&255;return E+D},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(w,E,D,V){if(w=+w,E=E>>>0,D=D>>>0,!V){const Wt=Math.pow(2,8*D)-1;ft(this,w,E,D,Wt,0)}let q=D-1,st=1;for(this[E+q]=w&255;--q>=0&&(st*=256);)this[E+q]=w/st&255;return E+D},h.prototype.writeUint8=h.prototype.writeUInt8=function(w,E,D){return w=+w,E=E>>>0,D||ft(this,w,E,1,255,0),this[E]=w&255,E+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(w,E,D){return w=+w,E=E>>>0,D||ft(this,w,E,2,65535,0),this[E]=w&255,this[E+1]=w>>>8,E+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(w,E,D){return w=+w,E=E>>>0,D||ft(this,w,E,2,65535,0),this[E]=w>>>8,this[E+1]=w&255,E+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(w,E,D){return w=+w,E=E>>>0,D||ft(this,w,E,4,4294967295,0),this[E+3]=w>>>24,this[E+2]=w>>>16,this[E+1]=w>>>8,this[E]=w&255,E+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(w,E,D){return w=+w,E=E>>>0,D||ft(this,w,E,4,4294967295,0),this[E]=w>>>24,this[E+1]=w>>>16,this[E+2]=w>>>8,this[E+3]=w&255,E+4};function mt(O,w,E,D,V){ie(w,D,V,O,E,7);let q=Number(w&BigInt(4294967295));O[E++]=q,q=q>>8,O[E++]=q,q=q>>8,O[E++]=q,q=q>>8,O[E++]=q;let st=Number(w>>BigInt(32)&BigInt(4294967295));return O[E++]=st,st=st>>8,O[E++]=st,st=st>>8,O[E++]=st,st=st>>8,O[E++]=st,E}function Ht(O,w,E,D,V){ie(w,D,V,O,E,7);let q=Number(w&BigInt(4294967295));O[E+7]=q,q=q>>8,O[E+6]=q,q=q>>8,O[E+5]=q,q=q>>8,O[E+4]=q;let st=Number(w>>BigInt(32)&BigInt(4294967295));return O[E+3]=st,st=st>>8,O[E+2]=st,st=st>>8,O[E+1]=st,st=st>>8,O[E]=st,E+8}h.prototype.writeBigUInt64LE=Jn(function(w,E=0){return mt(this,w,E,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Jn(function(w,E=0){return Ht(this,w,E,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(w,E,D,V){if(w=+w,E=E>>>0,!V){const jt=Math.pow(2,8*D-1);ft(this,w,E,D,jt-1,-jt)}let q=0,st=1,Wt=0;for(this[E]=w&255;++q<D&&(st*=256);)w<0&&Wt===0&&this[E+q-1]!==0&&(Wt=1),this[E+q]=(w/st>>0)-Wt&255;return E+D},h.prototype.writeIntBE=function(w,E,D,V){if(w=+w,E=E>>>0,!V){const jt=Math.pow(2,8*D-1);ft(this,w,E,D,jt-1,-jt)}let q=D-1,st=1,Wt=0;for(this[E+q]=w&255;--q>=0&&(st*=256);)w<0&&Wt===0&&this[E+q+1]!==0&&(Wt=1),this[E+q]=(w/st>>0)-Wt&255;return E+D},h.prototype.writeInt8=function(w,E,D){return w=+w,E=E>>>0,D||ft(this,w,E,1,127,-128),w<0&&(w=255+w+1),this[E]=w&255,E+1},h.prototype.writeInt16LE=function(w,E,D){return w=+w,E=E>>>0,D||ft(this,w,E,2,32767,-32768),this[E]=w&255,this[E+1]=w>>>8,E+2},h.prototype.writeInt16BE=function(w,E,D){return w=+w,E=E>>>0,D||ft(this,w,E,2,32767,-32768),this[E]=w>>>8,this[E+1]=w&255,E+2},h.prototype.writeInt32LE=function(w,E,D){return w=+w,E=E>>>0,D||ft(this,w,E,4,2147483647,-2147483648),this[E]=w&255,this[E+1]=w>>>8,this[E+2]=w>>>16,this[E+3]=w>>>24,E+4},h.prototype.writeInt32BE=function(w,E,D){return w=+w,E=E>>>0,D||ft(this,w,E,4,2147483647,-2147483648),w<0&&(w=4294967295+w+1),this[E]=w>>>24,this[E+1]=w>>>16,this[E+2]=w>>>8,this[E+3]=w&255,E+4},h.prototype.writeBigInt64LE=Jn(function(w,E=0){return mt(this,w,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Jn(function(w,E=0){return Ht(this,w,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Lt(O,w,E,D,V,q){if(E+D>O.length)throw new RangeError("Index out of range");if(E<0)throw new RangeError("Index out of range")}function Mt(O,w,E,D,V){return w=+w,E=E>>>0,V||Lt(O,w,E,4),e.write(O,w,E,D,23,4),E+4}h.prototype.writeFloatLE=function(w,E,D){return Mt(this,w,E,!0,D)},h.prototype.writeFloatBE=function(w,E,D){return Mt(this,w,E,!1,D)};function Ae(O,w,E,D,V){return w=+w,E=E>>>0,V||Lt(O,w,E,8),e.write(O,w,E,D,52,8),E+8}h.prototype.writeDoubleLE=function(w,E,D){return Ae(this,w,E,!0,D)},h.prototype.writeDoubleBE=function(w,E,D){return Ae(this,w,E,!1,D)},h.prototype.copy=function(w,E,D,V){if(!h.isBuffer(w))throw new TypeError("argument should be a Buffer");if(D||(D=0),!V&&V!==0&&(V=this.length),E>=w.length&&(E=w.length),E||(E=0),V>0&&V<D&&(V=D),V===D||w.length===0||this.length===0)return 0;if(E<0)throw new RangeError("targetStart out of bounds");if(D<0||D>=this.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("sourceEnd out of bounds");V>this.length&&(V=this.length),w.length-E<V-D&&(V=w.length-E+D);const q=V-D;return this===w&&typeof s.prototype.copyWithin=="function"?this.copyWithin(E,D,V):s.prototype.set.call(w,this.subarray(D,V),E),q},h.prototype.fill=function(w,E,D,V){if(typeof w=="string"){if(typeof E=="string"?(V=E,E=0,D=this.length):typeof D=="string"&&(V=D,D=this.length),V!==void 0&&typeof V!="string")throw new TypeError("encoding must be a string");if(typeof V=="string"&&!h.isEncoding(V))throw new TypeError("Unknown encoding: "+V);if(w.length===1){const st=w.charCodeAt(0);(V==="utf8"&&st<128||V==="latin1")&&(w=st)}}else typeof w=="number"?w=w&255:typeof w=="boolean"&&(w=Number(w));if(E<0||this.length<E||this.length<D)throw new RangeError("Out of range index");if(D<=E)return this;E=E>>>0,D=D===void 0?this.length:D>>>0,w||(w=0);let q;if(typeof w=="number")for(q=E;q<D;++q)this[q]=w;else{const st=h.isBuffer(w)?w:h.from(w,V),Wt=st.length;if(Wt===0)throw new TypeError('The value "'+w+'" is invalid for argument "value"');for(q=0;q<D-E;++q)this[q+E]=st[q%Wt]}return this};const Vt={};function Ut(O,w,E){Vt[O]=class extends E{constructor(){super(),Object.defineProperty(this,"message",{value:w.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${O}]`,this.stack,delete this.name}get code(){return O}set code(V){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:V,writable:!0})}toString(){return`${this.name} [${O}]: ${this.message}`}}}Ut("ERR_BUFFER_OUT_OF_BOUNDS",function(O){return O?`${O} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ut("ERR_INVALID_ARG_TYPE",function(O,w){return`The "${O}" argument must be of type number. Received type ${typeof w}`},TypeError),Ut("ERR_OUT_OF_RANGE",function(O,w,E){let D=`The value of "${O}" is out of range.`,V=E;return Number.isInteger(E)&&Math.abs(E)>2**32?V=Re(String(E)):typeof E=="bigint"&&(V=String(E),(E>BigInt(2)**BigInt(32)||E<-(BigInt(2)**BigInt(32)))&&(V=Re(V)),V+="n"),D+=` It must be ${w}. Received ${V}`,D},RangeError);function Re(O){let w="",E=O.length;const D=O[0]==="-"?1:0;for(;E>=D+4;E-=3)w=`_${O.slice(E-3,E)}${w}`;return`${O.slice(0,E)}${w}`}function Yt(O,w,E){Qe(w,"offset"),(O[w]===void 0||O[w+E]===void 0)&&ce(w,O.length-(E+1))}function ie(O,w,E,D,V,q){if(O>E||O<w){const st=typeof w=="bigint"?"n":"";let Wt;throw w===0||w===BigInt(0)?Wt=`>= 0${st} and < 2${st} ** ${(q+1)*8}${st}`:Wt=`>= -(2${st} ** ${(q+1)*8-1}${st}) and < 2 ** ${(q+1)*8-1}${st}`,new Vt.ERR_OUT_OF_RANGE("value",Wt,O)}Yt(D,V,q)}function Qe(O,w){if(typeof O!="number")throw new Vt.ERR_INVALID_ARG_TYPE(w,"number",O)}function ce(O,w,E){throw Math.floor(O)!==O?(Qe(O,E),new Vt.ERR_OUT_OF_RANGE("offset","an integer",O)):w<0?new Vt.ERR_BUFFER_OUT_OF_BOUNDS:new Vt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${w}`,O)}const Me=/[^+/0-9A-Za-z-_]/g;function Xs(O){if(O=O.split("=")[0],O=O.trim().replace(Me,""),O.length<2)return"";for(;O.length%4!==0;)O=O+"=";return O}function Ee(O,w){w=w||1/0;let E;const D=O.length;let V=null;const q=[];for(let st=0;st<D;++st){if(E=O.charCodeAt(st),E>55295&&E<57344){if(!V){if(E>56319){(w-=3)>-1&&q.push(239,191,189);continue}else if(st+1===D){(w-=3)>-1&&q.push(239,191,189);continue}V=E;continue}if(E<56320){(w-=3)>-1&&q.push(239,191,189),V=E;continue}E=(V-55296<<10|E-56320)+65536}else V&&(w-=3)>-1&&q.push(239,191,189);if(V=null,E<128){if((w-=1)<0)break;q.push(E)}else if(E<2048){if((w-=2)<0)break;q.push(E>>6|192,E&63|128)}else if(E<65536){if((w-=3)<0)break;q.push(E>>12|224,E>>6&63|128,E&63|128)}else if(E<1114112){if((w-=4)<0)break;q.push(E>>18|240,E>>12&63|128,E>>6&63|128,E&63|128)}else throw new Error("Invalid code point")}return q}function Ie(O){const w=[];for(let E=0;E<O.length;++E)w.push(O.charCodeAt(E)&255);return w}function _n(O,w){let E,D,V;const q=[];for(let st=0;st<O.length&&!((w-=2)<0);++st)E=O.charCodeAt(st),D=E>>8,V=E%256,q.push(V),q.push(D);return q}function ue(O){return t.toByteArray(Xs(O))}function ve(O,w,E,D){let V;for(V=0;V<D&&!(V+E>=w.length||V>=O.length);++V)w[V+E]=O[V];return V}function Je(O,w){return O instanceof w||O!=null&&O.constructor!=null&&O.constructor.name!=null&&O.constructor.name===w.name}function me(O){return O!==O}const ke=function(){const O="0123456789abcdef",w=new Array(256);for(let E=0;E<16;++E){const D=E*16;for(let V=0;V<16;++V)w[D+V]=O[E]+O[V]}return w}();function Jn(O){return typeof BigInt>"u"?Le:O}function Le(){throw new Error("BigInt not supported")}})(Hw);const Zt=Hw.Buffer,It=Hw.Buffer,HL=Object.freeze(Object.defineProperty({__proto__:null,Buffer:It,default:Zt},Symbol.toStringTag,{value:"Module"}));var Gw={exports:{}};const Vw=q0(HL);Gw.exports;(function(n){(function(t,e){function r(C,p){if(!C)throw new Error(p||"Assertion failed")}function i(C,p){C.super_=p;var m=function(){};m.prototype=p.prototype,C.prototype=new m,C.prototype.constructor=C}function s(C,p,m){if(s.isBN(C))return C;this.negative=0,this.words=null,this.length=0,this.red=null,C!==null&&((p==="le"||p==="be")&&(m=p,p=10),this._init(C||0,p||10,m||"be"))}typeof t=="object"?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Vw.Buffer}catch{}s.isBN=function(p){return p instanceof s?!0:p!==null&&typeof p=="object"&&p.constructor.wordSize===s.wordSize&&Array.isArray(p.words)},s.max=function(p,m){return p.cmp(m)>0?p:m},s.min=function(p,m){return p.cmp(m)<0?p:m},s.prototype._init=function(p,m,v){if(typeof p=="number")return this._initNumber(p,m,v);if(typeof p=="object")return this._initArray(p,m,v);m==="hex"&&(m=16),r(m===(m|0)&&m>=2&&m<=36),p=p.toString().replace(/\s+/g,"");var I=0;p[0]==="-"&&(I++,this.negative=1),I<p.length&&(m===16?this._parseHex(p,I,v):(this._parseBase(p,m,I),v==="le"&&this._initArray(this.toArray(),m,v)))},s.prototype._initNumber=function(p,m,v){p<0&&(this.negative=1,p=-p),p<67108864?(this.words=[p&67108863],this.length=1):p<4503599627370496?(this.words=[p&67108863,p/67108864&67108863],this.length=2):(r(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),v==="le"&&this._initArray(this.toArray(),m,v)},s.prototype._initArray=function(p,m,v){if(r(typeof p.length=="number"),p.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(p.length/3),this.words=new Array(this.length);for(var I=0;I<this.length;I++)this.words[I]=0;var N,M,z=0;if(v==="be")for(I=p.length-1,N=0;I>=0;I-=3)M=p[I]|p[I-1]<<8|p[I-2]<<16,this.words[N]|=M<<z&67108863,this.words[N+1]=M>>>26-z&67108863,z+=24,z>=26&&(z-=26,N++);else if(v==="le")for(I=0,N=0;I<p.length;I+=3)M=p[I]|p[I+1]<<8|p[I+2]<<16,this.words[N]|=M<<z&67108863,this.words[N+1]=M>>>26-z&67108863,z+=24,z>=26&&(z-=26,N++);return this._strip()};function c(C,p){var m=C.charCodeAt(p);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;r(!1,"Invalid character in "+C)}function u(C,p,m){var v=c(C,m);return m-1>=p&&(v|=c(C,m-1)<<4),v}s.prototype._parseHex=function(p,m,v){this.length=Math.ceil((p.length-m)/6),this.words=new Array(this.length);for(var I=0;I<this.length;I++)this.words[I]=0;var N=0,M=0,z;if(v==="be")for(I=p.length-1;I>=m;I-=2)z=u(p,m,I)<<N,this.words[M]|=z&67108863,N>=18?(N-=18,M+=1,this.words[M]|=z>>>26):N+=8;else{var P=p.length-m;for(I=P%2===0?m+1:m;I<p.length;I+=2)z=u(p,m,I)<<N,this.words[M]|=z&67108863,N>=18?(N-=18,M+=1,this.words[M]|=z>>>26):N+=8}this._strip()};function f(C,p,m,v){for(var I=0,N=0,M=Math.min(C.length,m),z=p;z<M;z++){var P=C.charCodeAt(z)-48;I*=v,P>=49?N=P-49+10:P>=17?N=P-17+10:N=P,r(P>=0&&N<v,"Invalid character"),I+=N}return I}s.prototype._parseBase=function(p,m,v){this.words=[0],this.length=1;for(var I=0,N=1;N<=67108863;N*=m)I++;I--,N=N/m|0;for(var M=p.length-v,z=M%I,P=Math.min(M,M-z)+v,_=0,F=v;F<P;F+=I)_=f(p,F,F+I,m),this.imuln(N),this.words[0]+_<67108864?this.words[0]+=_:this._iaddn(_);if(z!==0){var ct=1;for(_=f(p,F,p.length,m),F=0;F<z;F++)ct*=m;this.imuln(ct),this.words[0]+_<67108864?this.words[0]+=_:this._iaddn(_)}this._strip()},s.prototype.copy=function(p){p.words=new Array(this.length);for(var m=0;m<this.length;m++)p.words[m]=this.words[m];p.length=this.length,p.negative=this.negative,p.red=this.red};function h(C,p){C.words=p.words,C.length=p.length,C.negative=p.negative,C.red=p.red}if(s.prototype._move=function(p){h(p,this)},s.prototype.clone=function(){var p=new s(null);return this.copy(p),p},s.prototype._expand=function(p){for(;this.length<p;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=y}catch{s.prototype.inspect=y}else s.prototype.inspect=y;function y(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var A=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],R=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(p,m){p=p||10,m=m|0||1;var v;if(p===16||p==="hex"){v="";for(var I=0,N=0,M=0;M<this.length;M++){var z=this.words[M],P=((z<<I|N)&16777215).toString(16);N=z>>>24-I&16777215,I+=2,I>=26&&(I-=26,M--),N!==0||M!==this.length-1?v=A[6-P.length]+P+v:v=P+v}for(N!==0&&(v=N.toString(16)+v);v.length%m!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(p===(p|0)&&p>=2&&p<=36){var _=b[p],F=R[p];v="";var ct=this.clone();for(ct.negative=0;!ct.isZero();){var ft=ct.modrn(F).toString(p);ct=ct.idivn(F),ct.isZero()?v=ft+v:v=A[_-ft.length]+ft+v}for(this.isZero()&&(v="0"+v);v.length%m!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}r(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var p=this.words[0];return this.length===2?p+=this.words[1]*67108864:this.length===3&&this.words[2]===1?p+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-p:p},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(p,m){return this.toArrayLike(o,p,m)}),s.prototype.toArray=function(p,m){return this.toArrayLike(Array,p,m)};var k=function(p,m){return p.allocUnsafe?p.allocUnsafe(m):new p(m)};s.prototype.toArrayLike=function(p,m,v){this._strip();var I=this.byteLength(),N=v||Math.max(1,I);r(I<=N,"byte array longer than desired length"),r(N>0,"Requested array length <= 0");var M=k(p,N),z=m==="le"?"LE":"BE";return this["_toArrayLike"+z](M,I),M},s.prototype._toArrayLikeLE=function(p,m){for(var v=0,I=0,N=0,M=0;N<this.length;N++){var z=this.words[N]<<M|I;p[v++]=z&255,v<p.length&&(p[v++]=z>>8&255),v<p.length&&(p[v++]=z>>16&255),M===6?(v<p.length&&(p[v++]=z>>24&255),I=0,M=0):(I=z>>>24,M+=2)}if(v<p.length)for(p[v++]=I;v<p.length;)p[v++]=0},s.prototype._toArrayLikeBE=function(p,m){for(var v=p.length-1,I=0,N=0,M=0;N<this.length;N++){var z=this.words[N]<<M|I;p[v--]=z&255,v>=0&&(p[v--]=z>>8&255),v>=0&&(p[v--]=z>>16&255),M===6?(v>=0&&(p[v--]=z>>24&255),I=0,M=0):(I=z>>>24,M+=2)}if(v>=0)for(p[v--]=I;v>=0;)p[v--]=0},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var m=p,v=0;return m>=4096&&(v+=13,m>>>=13),m>=64&&(v+=7,m>>>=7),m>=8&&(v+=4,m>>>=4),m>=2&&(v+=2,m>>>=2),v+m},s.prototype._zeroBits=function(p){if(p===0)return 26;var m=p,v=0;return m&8191||(v+=13,m>>>=13),m&127||(v+=7,m>>>=7),m&15||(v+=4,m>>>=4),m&3||(v+=2,m>>>=2),m&1||v++,v},s.prototype.bitLength=function(){var p=this.words[this.length-1],m=this._countBits(p);return(this.length-1)*26+m};function S(C){for(var p=new Array(C.bitLength()),m=0;m<p.length;m++){var v=m/26|0,I=m%26;p[m]=C.words[v]>>>I&1}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,m=0;m<this.length;m++){var v=this._zeroBits(this.words[m]);if(p+=v,v!==26)break}return p},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(p){return this.negative!==0?this.abs().inotn(p).iaddn(1):this.clone()},s.prototype.fromTwos=function(p){return this.testn(p-1)?this.notn(p).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(p){for(;this.length<p.length;)this.words[this.length++]=0;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]|p.words[m];return this._strip()},s.prototype.ior=function(p){return r((this.negative|p.negative)===0),this.iuor(p)},s.prototype.or=function(p){return this.length>p.length?this.clone().ior(p):p.clone().ior(this)},s.prototype.uor=function(p){return this.length>p.length?this.clone().iuor(p):p.clone().iuor(this)},s.prototype.iuand=function(p){var m;this.length>p.length?m=p:m=this;for(var v=0;v<m.length;v++)this.words[v]=this.words[v]&p.words[v];return this.length=m.length,this._strip()},s.prototype.iand=function(p){return r((this.negative|p.negative)===0),this.iuand(p)},s.prototype.and=function(p){return this.length>p.length?this.clone().iand(p):p.clone().iand(this)},s.prototype.uand=function(p){return this.length>p.length?this.clone().iuand(p):p.clone().iuand(this)},s.prototype.iuxor=function(p){var m,v;this.length>p.length?(m=this,v=p):(m=p,v=this);for(var I=0;I<v.length;I++)this.words[I]=m.words[I]^v.words[I];if(this!==m)for(;I<m.length;I++)this.words[I]=m.words[I];return this.length=m.length,this._strip()},s.prototype.ixor=function(p){return r((this.negative|p.negative)===0),this.iuxor(p)},s.prototype.xor=function(p){return this.length>p.length?this.clone().ixor(p):p.clone().ixor(this)},s.prototype.uxor=function(p){return this.length>p.length?this.clone().iuxor(p):p.clone().iuxor(this)},s.prototype.inotn=function(p){r(typeof p=="number"&&p>=0);var m=Math.ceil(p/26)|0,v=p%26;this._expand(m),v>0&&m--;for(var I=0;I<m;I++)this.words[I]=~this.words[I]&67108863;return v>0&&(this.words[I]=~this.words[I]&67108863>>26-v),this._strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,m){r(typeof p=="number"&&p>=0);var v=p/26|0,I=p%26;return this._expand(v+1),m?this.words[v]=this.words[v]|1<<I:this.words[v]=this.words[v]&~(1<<I),this._strip()},s.prototype.iadd=function(p){var m;if(this.negative!==0&&p.negative===0)return this.negative=0,m=this.isub(p),this.negative^=1,this._normSign();if(this.negative===0&&p.negative!==0)return p.negative=0,m=this.isub(p),p.negative=1,m._normSign();var v,I;this.length>p.length?(v=this,I=p):(v=p,I=this);for(var N=0,M=0;M<I.length;M++)m=(v.words[M]|0)+(I.words[M]|0)+N,this.words[M]=m&67108863,N=m>>>26;for(;N!==0&&M<v.length;M++)m=(v.words[M]|0)+N,this.words[M]=m&67108863,N=m>>>26;if(this.length=v.length,N!==0)this.words[this.length]=N,this.length++;else if(v!==this)for(;M<v.length;M++)this.words[M]=v.words[M];return this},s.prototype.add=function(p){var m;return p.negative!==0&&this.negative===0?(p.negative=0,m=this.sub(p),p.negative^=1,m):p.negative===0&&this.negative!==0?(this.negative=0,m=p.sub(this),this.negative=1,m):this.length>p.length?this.clone().iadd(p):p.clone().iadd(this)},s.prototype.isub=function(p){if(p.negative!==0){p.negative=0;var m=this.iadd(p);return p.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(p),this.negative=1,this._normSign();var v=this.cmp(p);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var I,N;v>0?(I=this,N=p):(I=p,N=this);for(var M=0,z=0;z<N.length;z++)m=(I.words[z]|0)-(N.words[z]|0)+M,M=m>>26,this.words[z]=m&67108863;for(;M!==0&&z<I.length;z++)m=(I.words[z]|0)+M,M=m>>26,this.words[z]=m&67108863;if(M===0&&z<I.length&&I!==this)for(;z<I.length;z++)this.words[z]=I.words[z];return this.length=Math.max(this.length,z),I!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function B(C,p,m){m.negative=p.negative^C.negative;var v=C.length+p.length|0;m.length=v,v=v-1|0;var I=C.words[0]|0,N=p.words[0]|0,M=I*N,z=M&67108863,P=M/67108864|0;m.words[0]=z;for(var _=1;_<v;_++){for(var F=P>>>26,ct=P&67108863,ft=Math.min(_,p.length-1),mt=Math.max(0,_-C.length+1);mt<=ft;mt++){var Ht=_-mt|0;I=C.words[Ht]|0,N=p.words[mt]|0,M=I*N+ct,F+=M/67108864|0,ct=M&67108863}m.words[_]=ct|0,P=F|0}return P!==0?m.words[_]=P|0:m.length--,m._strip()}var H=function(p,m,v){var I=p.words,N=m.words,M=v.words,z=0,P,_,F,ct=I[0]|0,ft=ct&8191,mt=ct>>>13,Ht=I[1]|0,Lt=Ht&8191,Mt=Ht>>>13,Ae=I[2]|0,Vt=Ae&8191,Ut=Ae>>>13,Re=I[3]|0,Yt=Re&8191,ie=Re>>>13,Qe=I[4]|0,ce=Qe&8191,Me=Qe>>>13,Xs=I[5]|0,Ee=Xs&8191,Ie=Xs>>>13,_n=I[6]|0,ue=_n&8191,ve=_n>>>13,Je=I[7]|0,me=Je&8191,ke=Je>>>13,Jn=I[8]|0,Le=Jn&8191,O=Jn>>>13,w=I[9]|0,E=w&8191,D=w>>>13,V=N[0]|0,q=V&8191,st=V>>>13,Wt=N[1]|0,jt=Wt&8191,Kt=Wt>>>13,Ue=N[2]|0,Ft=Ue&8191,on=Ue>>>13,sd=N[3]|0,an=sd&8191,cn=sd>>>13,od=N[4]|0,Ye=od&8191,un=od>>>13,ad=N[5]|0,Xe=ad&8191,ln=ad>>>13,ia=N[6]|0,je=ia&8191,fn=ia>>>13,cd=N[7]|0,hn=cd&8191,dn=cd>>>13,ud=N[8]|0,pn=ud&8191,gn=ud>>>13,sa=N[9]|0,yn=sa&8191,mn=sa>>>13;v.negative=p.negative^m.negative,v.length=19,P=Math.imul(ft,q),_=Math.imul(ft,st),_=_+Math.imul(mt,q)|0,F=Math.imul(mt,st);var Fl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Fl>>>26)|0,Fl&=67108863,P=Math.imul(Lt,q),_=Math.imul(Lt,st),_=_+Math.imul(Mt,q)|0,F=Math.imul(Mt,st),P=P+Math.imul(ft,jt)|0,_=_+Math.imul(ft,Kt)|0,_=_+Math.imul(mt,jt)|0,F=F+Math.imul(mt,Kt)|0;var Ic=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Ic>>>26)|0,Ic&=67108863,P=Math.imul(Vt,q),_=Math.imul(Vt,st),_=_+Math.imul(Ut,q)|0,F=Math.imul(Ut,st),P=P+Math.imul(Lt,jt)|0,_=_+Math.imul(Lt,Kt)|0,_=_+Math.imul(Mt,jt)|0,F=F+Math.imul(Mt,Kt)|0,P=P+Math.imul(ft,Ft)|0,_=_+Math.imul(ft,on)|0,_=_+Math.imul(mt,Ft)|0,F=F+Math.imul(mt,on)|0;var $l=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+($l>>>26)|0,$l&=67108863,P=Math.imul(Yt,q),_=Math.imul(Yt,st),_=_+Math.imul(ie,q)|0,F=Math.imul(ie,st),P=P+Math.imul(Vt,jt)|0,_=_+Math.imul(Vt,Kt)|0,_=_+Math.imul(Ut,jt)|0,F=F+Math.imul(Ut,Kt)|0,P=P+Math.imul(Lt,Ft)|0,_=_+Math.imul(Lt,on)|0,_=_+Math.imul(Mt,Ft)|0,F=F+Math.imul(Mt,on)|0,P=P+Math.imul(ft,an)|0,_=_+Math.imul(ft,cn)|0,_=_+Math.imul(mt,an)|0,F=F+Math.imul(mt,cn)|0;var Hl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Hl>>>26)|0,Hl&=67108863,P=Math.imul(ce,q),_=Math.imul(ce,st),_=_+Math.imul(Me,q)|0,F=Math.imul(Me,st),P=P+Math.imul(Yt,jt)|0,_=_+Math.imul(Yt,Kt)|0,_=_+Math.imul(ie,jt)|0,F=F+Math.imul(ie,Kt)|0,P=P+Math.imul(Vt,Ft)|0,_=_+Math.imul(Vt,on)|0,_=_+Math.imul(Ut,Ft)|0,F=F+Math.imul(Ut,on)|0,P=P+Math.imul(Lt,an)|0,_=_+Math.imul(Lt,cn)|0,_=_+Math.imul(Mt,an)|0,F=F+Math.imul(Mt,cn)|0,P=P+Math.imul(ft,Ye)|0,_=_+Math.imul(ft,un)|0,_=_+Math.imul(mt,Ye)|0,F=F+Math.imul(mt,un)|0;var zl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(zl>>>26)|0,zl&=67108863,P=Math.imul(Ee,q),_=Math.imul(Ee,st),_=_+Math.imul(Ie,q)|0,F=Math.imul(Ie,st),P=P+Math.imul(ce,jt)|0,_=_+Math.imul(ce,Kt)|0,_=_+Math.imul(Me,jt)|0,F=F+Math.imul(Me,Kt)|0,P=P+Math.imul(Yt,Ft)|0,_=_+Math.imul(Yt,on)|0,_=_+Math.imul(ie,Ft)|0,F=F+Math.imul(ie,on)|0,P=P+Math.imul(Vt,an)|0,_=_+Math.imul(Vt,cn)|0,_=_+Math.imul(Ut,an)|0,F=F+Math.imul(Ut,cn)|0,P=P+Math.imul(Lt,Ye)|0,_=_+Math.imul(Lt,un)|0,_=_+Math.imul(Mt,Ye)|0,F=F+Math.imul(Mt,un)|0,P=P+Math.imul(ft,Xe)|0,_=_+Math.imul(ft,ln)|0,_=_+Math.imul(mt,Xe)|0,F=F+Math.imul(mt,ln)|0;var Gl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Gl>>>26)|0,Gl&=67108863,P=Math.imul(ue,q),_=Math.imul(ue,st),_=_+Math.imul(ve,q)|0,F=Math.imul(ve,st),P=P+Math.imul(Ee,jt)|0,_=_+Math.imul(Ee,Kt)|0,_=_+Math.imul(Ie,jt)|0,F=F+Math.imul(Ie,Kt)|0,P=P+Math.imul(ce,Ft)|0,_=_+Math.imul(ce,on)|0,_=_+Math.imul(Me,Ft)|0,F=F+Math.imul(Me,on)|0,P=P+Math.imul(Yt,an)|0,_=_+Math.imul(Yt,cn)|0,_=_+Math.imul(ie,an)|0,F=F+Math.imul(ie,cn)|0,P=P+Math.imul(Vt,Ye)|0,_=_+Math.imul(Vt,un)|0,_=_+Math.imul(Ut,Ye)|0,F=F+Math.imul(Ut,un)|0,P=P+Math.imul(Lt,Xe)|0,_=_+Math.imul(Lt,ln)|0,_=_+Math.imul(Mt,Xe)|0,F=F+Math.imul(Mt,ln)|0,P=P+Math.imul(ft,je)|0,_=_+Math.imul(ft,fn)|0,_=_+Math.imul(mt,je)|0,F=F+Math.imul(mt,fn)|0;var kc=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(kc>>>26)|0,kc&=67108863,P=Math.imul(me,q),_=Math.imul(me,st),_=_+Math.imul(ke,q)|0,F=Math.imul(ke,st),P=P+Math.imul(ue,jt)|0,_=_+Math.imul(ue,Kt)|0,_=_+Math.imul(ve,jt)|0,F=F+Math.imul(ve,Kt)|0,P=P+Math.imul(Ee,Ft)|0,_=_+Math.imul(Ee,on)|0,_=_+Math.imul(Ie,Ft)|0,F=F+Math.imul(Ie,on)|0,P=P+Math.imul(ce,an)|0,_=_+Math.imul(ce,cn)|0,_=_+Math.imul(Me,an)|0,F=F+Math.imul(Me,cn)|0,P=P+Math.imul(Yt,Ye)|0,_=_+Math.imul(Yt,un)|0,_=_+Math.imul(ie,Ye)|0,F=F+Math.imul(ie,un)|0,P=P+Math.imul(Vt,Xe)|0,_=_+Math.imul(Vt,ln)|0,_=_+Math.imul(Ut,Xe)|0,F=F+Math.imul(Ut,ln)|0,P=P+Math.imul(Lt,je)|0,_=_+Math.imul(Lt,fn)|0,_=_+Math.imul(Mt,je)|0,F=F+Math.imul(Mt,fn)|0,P=P+Math.imul(ft,hn)|0,_=_+Math.imul(ft,dn)|0,_=_+Math.imul(mt,hn)|0,F=F+Math.imul(mt,dn)|0;var Vl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Vl>>>26)|0,Vl&=67108863,P=Math.imul(Le,q),_=Math.imul(Le,st),_=_+Math.imul(O,q)|0,F=Math.imul(O,st),P=P+Math.imul(me,jt)|0,_=_+Math.imul(me,Kt)|0,_=_+Math.imul(ke,jt)|0,F=F+Math.imul(ke,Kt)|0,P=P+Math.imul(ue,Ft)|0,_=_+Math.imul(ue,on)|0,_=_+Math.imul(ve,Ft)|0,F=F+Math.imul(ve,on)|0,P=P+Math.imul(Ee,an)|0,_=_+Math.imul(Ee,cn)|0,_=_+Math.imul(Ie,an)|0,F=F+Math.imul(Ie,cn)|0,P=P+Math.imul(ce,Ye)|0,_=_+Math.imul(ce,un)|0,_=_+Math.imul(Me,Ye)|0,F=F+Math.imul(Me,un)|0,P=P+Math.imul(Yt,Xe)|0,_=_+Math.imul(Yt,ln)|0,_=_+Math.imul(ie,Xe)|0,F=F+Math.imul(ie,ln)|0,P=P+Math.imul(Vt,je)|0,_=_+Math.imul(Vt,fn)|0,_=_+Math.imul(Ut,je)|0,F=F+Math.imul(Ut,fn)|0,P=P+Math.imul(Lt,hn)|0,_=_+Math.imul(Lt,dn)|0,_=_+Math.imul(Mt,hn)|0,F=F+Math.imul(Mt,dn)|0,P=P+Math.imul(ft,pn)|0,_=_+Math.imul(ft,gn)|0,_=_+Math.imul(mt,pn)|0,F=F+Math.imul(mt,gn)|0;var ls=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(ls>>>26)|0,ls&=67108863,P=Math.imul(E,q),_=Math.imul(E,st),_=_+Math.imul(D,q)|0,F=Math.imul(D,st),P=P+Math.imul(Le,jt)|0,_=_+Math.imul(Le,Kt)|0,_=_+Math.imul(O,jt)|0,F=F+Math.imul(O,Kt)|0,P=P+Math.imul(me,Ft)|0,_=_+Math.imul(me,on)|0,_=_+Math.imul(ke,Ft)|0,F=F+Math.imul(ke,on)|0,P=P+Math.imul(ue,an)|0,_=_+Math.imul(ue,cn)|0,_=_+Math.imul(ve,an)|0,F=F+Math.imul(ve,cn)|0,P=P+Math.imul(Ee,Ye)|0,_=_+Math.imul(Ee,un)|0,_=_+Math.imul(Ie,Ye)|0,F=F+Math.imul(Ie,un)|0,P=P+Math.imul(ce,Xe)|0,_=_+Math.imul(ce,ln)|0,_=_+Math.imul(Me,Xe)|0,F=F+Math.imul(Me,ln)|0,P=P+Math.imul(Yt,je)|0,_=_+Math.imul(Yt,fn)|0,_=_+Math.imul(ie,je)|0,F=F+Math.imul(ie,fn)|0,P=P+Math.imul(Vt,hn)|0,_=_+Math.imul(Vt,dn)|0,_=_+Math.imul(Ut,hn)|0,F=F+Math.imul(Ut,dn)|0,P=P+Math.imul(Lt,pn)|0,_=_+Math.imul(Lt,gn)|0,_=_+Math.imul(Mt,pn)|0,F=F+Math.imul(Mt,gn)|0,P=P+Math.imul(ft,yn)|0,_=_+Math.imul(ft,mn)|0,_=_+Math.imul(mt,yn)|0,F=F+Math.imul(mt,mn)|0;var Kl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Kl>>>26)|0,Kl&=67108863,P=Math.imul(E,jt),_=Math.imul(E,Kt),_=_+Math.imul(D,jt)|0,F=Math.imul(D,Kt),P=P+Math.imul(Le,Ft)|0,_=_+Math.imul(Le,on)|0,_=_+Math.imul(O,Ft)|0,F=F+Math.imul(O,on)|0,P=P+Math.imul(me,an)|0,_=_+Math.imul(me,cn)|0,_=_+Math.imul(ke,an)|0,F=F+Math.imul(ke,cn)|0,P=P+Math.imul(ue,Ye)|0,_=_+Math.imul(ue,un)|0,_=_+Math.imul(ve,Ye)|0,F=F+Math.imul(ve,un)|0,P=P+Math.imul(Ee,Xe)|0,_=_+Math.imul(Ee,ln)|0,_=_+Math.imul(Ie,Xe)|0,F=F+Math.imul(Ie,ln)|0,P=P+Math.imul(ce,je)|0,_=_+Math.imul(ce,fn)|0,_=_+Math.imul(Me,je)|0,F=F+Math.imul(Me,fn)|0,P=P+Math.imul(Yt,hn)|0,_=_+Math.imul(Yt,dn)|0,_=_+Math.imul(ie,hn)|0,F=F+Math.imul(ie,dn)|0,P=P+Math.imul(Vt,pn)|0,_=_+Math.imul(Vt,gn)|0,_=_+Math.imul(Ut,pn)|0,F=F+Math.imul(Ut,gn)|0,P=P+Math.imul(Lt,yn)|0,_=_+Math.imul(Lt,mn)|0,_=_+Math.imul(Mt,yn)|0,F=F+Math.imul(Mt,mn)|0;var ci=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(ci>>>26)|0,ci&=67108863,P=Math.imul(E,Ft),_=Math.imul(E,on),_=_+Math.imul(D,Ft)|0,F=Math.imul(D,on),P=P+Math.imul(Le,an)|0,_=_+Math.imul(Le,cn)|0,_=_+Math.imul(O,an)|0,F=F+Math.imul(O,cn)|0,P=P+Math.imul(me,Ye)|0,_=_+Math.imul(me,un)|0,_=_+Math.imul(ke,Ye)|0,F=F+Math.imul(ke,un)|0,P=P+Math.imul(ue,Xe)|0,_=_+Math.imul(ue,ln)|0,_=_+Math.imul(ve,Xe)|0,F=F+Math.imul(ve,ln)|0,P=P+Math.imul(Ee,je)|0,_=_+Math.imul(Ee,fn)|0,_=_+Math.imul(Ie,je)|0,F=F+Math.imul(Ie,fn)|0,P=P+Math.imul(ce,hn)|0,_=_+Math.imul(ce,dn)|0,_=_+Math.imul(Me,hn)|0,F=F+Math.imul(Me,dn)|0,P=P+Math.imul(Yt,pn)|0,_=_+Math.imul(Yt,gn)|0,_=_+Math.imul(ie,pn)|0,F=F+Math.imul(ie,gn)|0,P=P+Math.imul(Vt,yn)|0,_=_+Math.imul(Vt,mn)|0,_=_+Math.imul(Ut,yn)|0,F=F+Math.imul(Ut,mn)|0;var jl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(jl>>>26)|0,jl&=67108863,P=Math.imul(E,an),_=Math.imul(E,cn),_=_+Math.imul(D,an)|0,F=Math.imul(D,cn),P=P+Math.imul(Le,Ye)|0,_=_+Math.imul(Le,un)|0,_=_+Math.imul(O,Ye)|0,F=F+Math.imul(O,un)|0,P=P+Math.imul(me,Xe)|0,_=_+Math.imul(me,ln)|0,_=_+Math.imul(ke,Xe)|0,F=F+Math.imul(ke,ln)|0,P=P+Math.imul(ue,je)|0,_=_+Math.imul(ue,fn)|0,_=_+Math.imul(ve,je)|0,F=F+Math.imul(ve,fn)|0,P=P+Math.imul(Ee,hn)|0,_=_+Math.imul(Ee,dn)|0,_=_+Math.imul(Ie,hn)|0,F=F+Math.imul(Ie,dn)|0,P=P+Math.imul(ce,pn)|0,_=_+Math.imul(ce,gn)|0,_=_+Math.imul(Me,pn)|0,F=F+Math.imul(Me,gn)|0,P=P+Math.imul(Yt,yn)|0,_=_+Math.imul(Yt,mn)|0,_=_+Math.imul(ie,yn)|0,F=F+Math.imul(ie,mn)|0;var Wl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Wl>>>26)|0,Wl&=67108863,P=Math.imul(E,Ye),_=Math.imul(E,un),_=_+Math.imul(D,Ye)|0,F=Math.imul(D,un),P=P+Math.imul(Le,Xe)|0,_=_+Math.imul(Le,ln)|0,_=_+Math.imul(O,Xe)|0,F=F+Math.imul(O,ln)|0,P=P+Math.imul(me,je)|0,_=_+Math.imul(me,fn)|0,_=_+Math.imul(ke,je)|0,F=F+Math.imul(ke,fn)|0,P=P+Math.imul(ue,hn)|0,_=_+Math.imul(ue,dn)|0,_=_+Math.imul(ve,hn)|0,F=F+Math.imul(ve,dn)|0,P=P+Math.imul(Ee,pn)|0,_=_+Math.imul(Ee,gn)|0,_=_+Math.imul(Ie,pn)|0,F=F+Math.imul(Ie,gn)|0,P=P+Math.imul(ce,yn)|0,_=_+Math.imul(ce,mn)|0,_=_+Math.imul(Me,yn)|0,F=F+Math.imul(Me,mn)|0;var Tc=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Tc>>>26)|0,Tc&=67108863,P=Math.imul(E,Xe),_=Math.imul(E,ln),_=_+Math.imul(D,Xe)|0,F=Math.imul(D,ln),P=P+Math.imul(Le,je)|0,_=_+Math.imul(Le,fn)|0,_=_+Math.imul(O,je)|0,F=F+Math.imul(O,fn)|0,P=P+Math.imul(me,hn)|0,_=_+Math.imul(me,dn)|0,_=_+Math.imul(ke,hn)|0,F=F+Math.imul(ke,dn)|0,P=P+Math.imul(ue,pn)|0,_=_+Math.imul(ue,gn)|0,_=_+Math.imul(ve,pn)|0,F=F+Math.imul(ve,gn)|0,P=P+Math.imul(Ee,yn)|0,_=_+Math.imul(Ee,mn)|0,_=_+Math.imul(Ie,yn)|0,F=F+Math.imul(Ie,mn)|0;var Zl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Zl>>>26)|0,Zl&=67108863,P=Math.imul(E,je),_=Math.imul(E,fn),_=_+Math.imul(D,je)|0,F=Math.imul(D,fn),P=P+Math.imul(Le,hn)|0,_=_+Math.imul(Le,dn)|0,_=_+Math.imul(O,hn)|0,F=F+Math.imul(O,dn)|0,P=P+Math.imul(me,pn)|0,_=_+Math.imul(me,gn)|0,_=_+Math.imul(ke,pn)|0,F=F+Math.imul(ke,gn)|0,P=P+Math.imul(ue,yn)|0,_=_+Math.imul(ue,mn)|0,_=_+Math.imul(ve,yn)|0,F=F+Math.imul(ve,mn)|0;var ql=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(ql>>>26)|0,ql&=67108863,P=Math.imul(E,hn),_=Math.imul(E,dn),_=_+Math.imul(D,hn)|0,F=Math.imul(D,dn),P=P+Math.imul(Le,pn)|0,_=_+Math.imul(Le,gn)|0,_=_+Math.imul(O,pn)|0,F=F+Math.imul(O,gn)|0,P=P+Math.imul(me,yn)|0,_=_+Math.imul(me,mn)|0,_=_+Math.imul(ke,yn)|0,F=F+Math.imul(ke,mn)|0;var Ql=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Ql>>>26)|0,Ql&=67108863,P=Math.imul(E,pn),_=Math.imul(E,gn),_=_+Math.imul(D,pn)|0,F=Math.imul(D,gn),P=P+Math.imul(Le,yn)|0,_=_+Math.imul(Le,mn)|0,_=_+Math.imul(O,yn)|0,F=F+Math.imul(O,mn)|0;var Jl=(z+P|0)+((_&8191)<<13)|0;z=(F+(_>>>13)|0)+(Jl>>>26)|0,Jl&=67108863,P=Math.imul(E,yn),_=Math.imul(E,mn),_=_+Math.imul(D,yn)|0,F=Math.imul(D,mn);var to=(z+P|0)+((_&8191)<<13)|0;return z=(F+(_>>>13)|0)+(to>>>26)|0,to&=67108863,M[0]=Fl,M[1]=Ic,M[2]=$l,M[3]=Hl,M[4]=zl,M[5]=Gl,M[6]=kc,M[7]=Vl,M[8]=ls,M[9]=Kl,M[10]=ci,M[11]=jl,M[12]=Wl,M[13]=Tc,M[14]=Zl,M[15]=ql,M[16]=Ql,M[17]=Jl,M[18]=to,z!==0&&(M[19]=z,v.length++),v};Math.imul||(H=B);function U(C,p,m){m.negative=p.negative^C.negative,m.length=C.length+p.length;for(var v=0,I=0,N=0;N<m.length-1;N++){var M=I;I=0;for(var z=v&67108863,P=Math.min(N,p.length-1),_=Math.max(0,N-C.length+1);_<=P;_++){var F=N-_,ct=C.words[F]|0,ft=p.words[_]|0,mt=ct*ft,Ht=mt&67108863;M=M+(mt/67108864|0)|0,Ht=Ht+z|0,z=Ht&67108863,M=M+(Ht>>>26)|0,I+=M>>>26,M&=67108863}m.words[N]=z,v=M,M=I}return v!==0?m.words[N]=v:m.length--,m._strip()}function G(C,p,m){return U(C,p,m)}s.prototype.mulTo=function(p,m){var v,I=this.length+p.length;return this.length===10&&p.length===10?v=H(this,p,m):I<63?v=B(this,p,m):I<1024?v=U(this,p,m):v=G(this,p,m),v},s.prototype.mul=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),this.mulTo(p,m)},s.prototype.mulf=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),G(this,p,m)},s.prototype.imul=function(p){return this.clone().mulTo(p,this)},s.prototype.imuln=function(p){var m=p<0;m&&(p=-p),r(typeof p=="number"),r(p<67108864);for(var v=0,I=0;I<this.length;I++){var N=(this.words[I]|0)*p,M=(N&67108863)+(v&67108863);v>>=26,v+=N/67108864|0,v+=M>>>26,this.words[I]=M&67108863}return v!==0&&(this.words[I]=v,this.length++),m?this.ineg():this},s.prototype.muln=function(p){return this.clone().imuln(p)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(p){var m=S(p);if(m.length===0)return new s(1);for(var v=this,I=0;I<m.length&&m[I]===0;I++,v=v.sqr());if(++I<m.length)for(var N=v.sqr();I<m.length;I++,N=N.sqr())m[I]!==0&&(v=v.mul(N));return v},s.prototype.iushln=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26,I=67108863>>>26-m<<26-m,N;if(m!==0){var M=0;for(N=0;N<this.length;N++){var z=this.words[N]&I,P=(this.words[N]|0)-z<<m;this.words[N]=P|M,M=z>>>26-m}M&&(this.words[N]=M,this.length++)}if(v!==0){for(N=this.length-1;N>=0;N--)this.words[N+v]=this.words[N];for(N=0;N<v;N++)this.words[N]=0;this.length+=v}return this._strip()},s.prototype.ishln=function(p){return r(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,m,v){r(typeof p=="number"&&p>=0);var I;m?I=(m-m%26)/26:I=0;var N=p%26,M=Math.min((p-N)/26,this.length),z=67108863^67108863>>>N<<N,P=v;if(I-=M,I=Math.max(0,I),P){for(var _=0;_<M;_++)P.words[_]=this.words[_];P.length=M}if(M!==0)if(this.length>M)for(this.length-=M,_=0;_<this.length;_++)this.words[_]=this.words[_+M];else this.words[0]=0,this.length=1;var F=0;for(_=this.length-1;_>=0&&(F!==0||_>=I);_--){var ct=this.words[_]|0;this.words[_]=F<<26-N|ct>>>N,F=ct&z}return P&&F!==0&&(P.words[P.length++]=F),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(p,m,v){return r(this.negative===0),this.iushrn(p,m,v)},s.prototype.shln=function(p){return this.clone().ishln(p)},s.prototype.ushln=function(p){return this.clone().iushln(p)},s.prototype.shrn=function(p){return this.clone().ishrn(p)},s.prototype.ushrn=function(p){return this.clone().iushrn(p)},s.prototype.testn=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26,I=1<<m;if(this.length<=v)return!1;var N=this.words[v];return!!(N&I)},s.prototype.imaskn=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(m!==0&&v++,this.length=Math.min(v,this.length),m!==0){var I=67108863^67108863>>>m<<m;this.words[this.length-1]&=I}return this._strip()},s.prototype.maskn=function(p){return this.clone().imaskn(p)},s.prototype.iaddn=function(p){return r(typeof p=="number"),r(p<67108864),p<0?this.isubn(-p):this.negative!==0?this.length===1&&(this.words[0]|0)<=p?(this.words[0]=p-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(p),this.negative=1,this):this._iaddn(p)},s.prototype._iaddn=function(p){this.words[0]+=p;for(var m=0;m<this.length&&this.words[m]>=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},s.prototype.isubn=function(p){if(r(typeof p=="number"),r(p<67108864),p<0)return this.iaddn(-p);if(this.negative!==0)return this.negative=0,this.iaddn(p),this.negative=1,this;if(this.words[0]-=p,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m<this.length&&this.words[m]<0;m++)this.words[m]+=67108864,this.words[m+1]-=1;return this._strip()},s.prototype.addn=function(p){return this.clone().iaddn(p)},s.prototype.subn=function(p){return this.clone().isubn(p)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(p,m,v){var I=p.length+v,N;this._expand(I);var M,z=0;for(N=0;N<p.length;N++){M=(this.words[N+v]|0)+z;var P=(p.words[N]|0)*m;M-=P&67108863,z=(M>>26)-(P/67108864|0),this.words[N+v]=M&67108863}for(;N<this.length-v;N++)M=(this.words[N+v]|0)+z,z=M>>26,this.words[N+v]=M&67108863;if(z===0)return this._strip();for(r(z===-1),z=0,N=0;N<this.length;N++)M=-(this.words[N]|0)+z,z=M>>26,this.words[N]=M&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(p,m){var v=this.length-p.length,I=this.clone(),N=p,M=N.words[N.length-1]|0,z=this._countBits(M);v=26-z,v!==0&&(N=N.ushln(v),I.iushln(v),M=N.words[N.length-1]|0);var P=I.length-N.length,_;if(m!=="mod"){_=new s(null),_.length=P+1,_.words=new Array(_.length);for(var F=0;F<_.length;F++)_.words[F]=0}var ct=I.clone()._ishlnsubmul(N,1,P);ct.negative===0&&(I=ct,_&&(_.words[P]=1));for(var ft=P-1;ft>=0;ft--){var mt=(I.words[N.length+ft]|0)*67108864+(I.words[N.length+ft-1]|0);for(mt=Math.min(mt/M|0,67108863),I._ishlnsubmul(N,mt,ft);I.negative!==0;)mt--,I.negative=0,I._ishlnsubmul(N,1,ft),I.isZero()||(I.negative^=1);_&&(_.words[ft]=mt)}return _&&_._strip(),I._strip(),m!=="div"&&v!==0&&I.iushrn(v),{div:_||null,mod:I}},s.prototype.divmod=function(p,m,v){if(r(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var I,N,M;return this.negative!==0&&p.negative===0?(M=this.neg().divmod(p,m),m!=="mod"&&(I=M.div.neg()),m!=="div"&&(N=M.mod.neg(),v&&N.negative!==0&&N.iadd(p)),{div:I,mod:N}):this.negative===0&&p.negative!==0?(M=this.divmod(p.neg(),m),m!=="mod"&&(I=M.div.neg()),{div:I,mod:M.mod}):this.negative&p.negative?(M=this.neg().divmod(p.neg(),m),m!=="div"&&(N=M.mod.neg(),v&&N.negative!==0&&N.isub(p)),{div:M.div,mod:N}):p.length>this.length||this.cmp(p)<0?{div:new s(0),mod:this}:p.length===1?m==="div"?{div:this.divn(p.words[0]),mod:null}:m==="mod"?{div:null,mod:new s(this.modrn(p.words[0]))}:{div:this.divn(p.words[0]),mod:new s(this.modrn(p.words[0]))}:this._wordDiv(p,m)},s.prototype.div=function(p){return this.divmod(p,"div",!1).div},s.prototype.mod=function(p){return this.divmod(p,"mod",!1).mod},s.prototype.umod=function(p){return this.divmod(p,"mod",!0).mod},s.prototype.divRound=function(p){var m=this.divmod(p);if(m.mod.isZero())return m.div;var v=m.div.negative!==0?m.mod.isub(p):m.mod,I=p.ushrn(1),N=p.andln(1),M=v.cmp(I);return M<0||N===1&&M===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},s.prototype.modrn=function(p){var m=p<0;m&&(p=-p),r(p<=67108863);for(var v=(1<<26)%p,I=0,N=this.length-1;N>=0;N--)I=(v*I+(this.words[N]|0))%p;return m?-I:I},s.prototype.modn=function(p){return this.modrn(p)},s.prototype.idivn=function(p){var m=p<0;m&&(p=-p),r(p<=67108863);for(var v=0,I=this.length-1;I>=0;I--){var N=(this.words[I]|0)+v*67108864;this.words[I]=N/p|0,v=N%p}return this._strip(),m?this.ineg():this},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){r(p.negative===0),r(!p.isZero());var m=this,v=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var I=new s(1),N=new s(0),M=new s(0),z=new s(1),P=0;m.isEven()&&v.isEven();)m.iushrn(1),v.iushrn(1),++P;for(var _=v.clone(),F=m.clone();!m.isZero();){for(var ct=0,ft=1;!(m.words[0]&ft)&&ct<26;++ct,ft<<=1);if(ct>0)for(m.iushrn(ct);ct-- >0;)(I.isOdd()||N.isOdd())&&(I.iadd(_),N.isub(F)),I.iushrn(1),N.iushrn(1);for(var mt=0,Ht=1;!(v.words[0]&Ht)&&mt<26;++mt,Ht<<=1);if(mt>0)for(v.iushrn(mt);mt-- >0;)(M.isOdd()||z.isOdd())&&(M.iadd(_),z.isub(F)),M.iushrn(1),z.iushrn(1);m.cmp(v)>=0?(m.isub(v),I.isub(M),N.isub(z)):(v.isub(m),M.isub(I),z.isub(N))}return{a:M,b:z,gcd:v.iushln(P)}},s.prototype._invmp=function(p){r(p.negative===0),r(!p.isZero());var m=this,v=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var I=new s(1),N=new s(0),M=v.clone();m.cmpn(1)>0&&v.cmpn(1)>0;){for(var z=0,P=1;!(m.words[0]&P)&&z<26;++z,P<<=1);if(z>0)for(m.iushrn(z);z-- >0;)I.isOdd()&&I.iadd(M),I.iushrn(1);for(var _=0,F=1;!(v.words[0]&F)&&_<26;++_,F<<=1);if(_>0)for(v.iushrn(_);_-- >0;)N.isOdd()&&N.iadd(M),N.iushrn(1);m.cmp(v)>=0?(m.isub(v),I.isub(N)):(v.isub(m),N.isub(I))}var ct;return m.cmpn(1)===0?ct=I:ct=N,ct.cmpn(0)<0&&ct.iadd(p),ct},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var m=this.clone(),v=p.clone();m.negative=0,v.negative=0;for(var I=0;m.isEven()&&v.isEven();I++)m.iushrn(1),v.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;v.isEven();)v.iushrn(1);var N=m.cmp(v);if(N<0){var M=m;m=v,v=M}else if(N===0||v.cmpn(1)===0)break;m.isub(v)}while(!0);return v.iushln(I)},s.prototype.invm=function(p){return this.egcd(p).a.umod(p)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(p){return this.words[0]&p},s.prototype.bincn=function(p){r(typeof p=="number");var m=p%26,v=(p-m)/26,I=1<<m;if(this.length<=v)return this._expand(v+1),this.words[v]|=I,this;for(var N=I,M=v;N!==0&&M<this.length;M++){var z=this.words[M]|0;z+=N,N=z>>>26,z&=67108863,this.words[M]=z}return N!==0&&(this.words[M]=N,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(p){var m=p<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this._strip();var v;if(this.length>1)v=1;else{m&&(p=-p),r(p<=67108863,"Number is too big");var I=this.words[0]|0;v=I===p?0:I<p?-1:1}return this.negative!==0?-v|0:v},s.prototype.cmp=function(p){if(this.negative!==0&&p.negative===0)return-1;if(this.negative===0&&p.negative!==0)return 1;var m=this.ucmp(p);return this.negative!==0?-m|0:m},s.prototype.ucmp=function(p){if(this.length>p.length)return 1;if(this.length<p.length)return-1;for(var m=0,v=this.length-1;v>=0;v--){var I=this.words[v]|0,N=p.words[v]|0;if(I!==N){I<N?m=-1:I>N&&(m=1);break}}return m},s.prototype.gtn=function(p){return this.cmpn(p)===1},s.prototype.gt=function(p){return this.cmp(p)===1},s.prototype.gten=function(p){return this.cmpn(p)>=0},s.prototype.gte=function(p){return this.cmp(p)>=0},s.prototype.ltn=function(p){return this.cmpn(p)===-1},s.prototype.lt=function(p){return this.cmp(p)===-1},s.prototype.lten=function(p){return this.cmpn(p)<=0},s.prototype.lte=function(p){return this.cmp(p)<=0},s.prototype.eqn=function(p){return this.cmpn(p)===0},s.prototype.eq=function(p){return this.cmp(p)===0},s.red=function(p){return new rt(p)},s.prototype.toRed=function(p){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(p){return this.red=p,this},s.prototype.forceRed=function(p){return r(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},s.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(p){return r(this.red&&!p.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,p)};var W={k256:null,p224:null,p192:null,p25519:null};function Y(C,p){this.name=C,this.p=new s(p,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}Y.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},Y.prototype.ireduce=function(p){var m=p,v;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),v=m.bitLength();while(v>this.n);var I=v<this.n?-1:m.ucmp(this.p);return I===0?(m.words[0]=0,m.length=1):I>0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},Y.prototype.split=function(p,m){p.iushrn(this.n,0,m)},Y.prototype.imulK=function(p){return p.imul(this.k)};function j(){Y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(j,Y),j.prototype.split=function(p,m){for(var v=4194303,I=Math.min(p.length,9),N=0;N<I;N++)m.words[N]=p.words[N];if(m.length=I,p.length<=9){p.words[0]=0,p.length=1;return}var M=p.words[9];for(m.words[m.length++]=M&v,N=10;N<p.length;N++){var z=p.words[N]|0;p.words[N-10]=(z&v)<<4|M>>>22,M=z}M>>>=22,p.words[N-10]=M,M===0&&p.length>10?p.length-=10:p.length-=9},j.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var m=0,v=0;v<p.length;v++){var I=p.words[v]|0;m+=I*977,p.words[v]=m&67108863,m=I*64+(m/67108864|0)}return p.words[p.length-1]===0&&(p.length--,p.words[p.length-1]===0&&p.length--),p};function J(){Y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(J,Y);function it(){Y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(it,Y);function ut(){Y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(ut,Y),ut.prototype.imulK=function(p){for(var m=0,v=0;v<p.length;v++){var I=(p.words[v]|0)*19+m,N=I&67108863;I>>>=26,p.words[v]=N,m=I}return m!==0&&(p.words[p.length++]=m),p},s._prime=function(p){if(W[p])return W[p];var m;if(p==="k256")m=new j;else if(p==="p224")m=new J;else if(p==="p192")m=new it;else if(p==="p25519")m=new ut;else throw new Error("Unknown prime "+p);return W[p]=m,m};function rt(C){if(typeof C=="string"){var p=s._prime(C);this.m=p.p,this.prime=p}else r(C.gtn(1),"modulus must be greater than 1"),this.m=C,this.prime=null}rt.prototype._verify1=function(p){r(p.negative===0,"red works only with positives"),r(p.red,"red works only with red numbers")},rt.prototype._verify2=function(p,m){r((p.negative|m.negative)===0,"red works only with positives"),r(p.red&&p.red===m.red,"red works only with red numbers")},rt.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):(h(p,p.umod(this.m)._forceRed(this)),p)},rt.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},rt.prototype.add=function(p,m){this._verify2(p,m);var v=p.add(m);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},rt.prototype.iadd=function(p,m){this._verify2(p,m);var v=p.iadd(m);return v.cmp(this.m)>=0&&v.isub(this.m),v},rt.prototype.sub=function(p,m){this._verify2(p,m);var v=p.sub(m);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},rt.prototype.isub=function(p,m){this._verify2(p,m);var v=p.isub(m);return v.cmpn(0)<0&&v.iadd(this.m),v},rt.prototype.shl=function(p,m){return this._verify1(p),this.imod(p.ushln(m))},rt.prototype.imul=function(p,m){return this._verify2(p,m),this.imod(p.imul(m))},rt.prototype.mul=function(p,m){return this._verify2(p,m),this.imod(p.mul(m))},rt.prototype.isqr=function(p){return this.imul(p,p.clone())},rt.prototype.sqr=function(p){return this.mul(p,p)},rt.prototype.sqrt=function(p){if(p.isZero())return p.clone();var m=this.m.andln(3);if(r(m%2===1),m===3){var v=this.m.add(new s(1)).iushrn(2);return this.pow(p,v)}for(var I=this.m.subn(1),N=0;!I.isZero()&&I.andln(1)===0;)N++,I.iushrn(1);r(!I.isZero());var M=new s(1).toRed(this),z=M.redNeg(),P=this.m.subn(1).iushrn(1),_=this.m.bitLength();for(_=new s(2*_*_).toRed(this);this.pow(_,P).cmp(z)!==0;)_.redIAdd(z);for(var F=this.pow(_,I),ct=this.pow(p,I.addn(1).iushrn(1)),ft=this.pow(p,I),mt=N;ft.cmp(M)!==0;){for(var Ht=ft,Lt=0;Ht.cmp(M)!==0;Lt++)Ht=Ht.redSqr();r(Lt<mt);var Mt=this.pow(F,new s(1).iushln(mt-Lt-1));ct=ct.redMul(Mt),F=Mt.redSqr(),ft=ft.redMul(F),mt=Lt}return ct},rt.prototype.invm=function(p){var m=p._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},rt.prototype.pow=function(p,m){if(m.isZero())return new s(1).toRed(this);if(m.cmpn(1)===0)return p.clone();var v=4,I=new Array(1<<v);I[0]=new s(1).toRed(this),I[1]=p;for(var N=2;N<I.length;N++)I[N]=this.mul(I[N-1],p);var M=I[0],z=0,P=0,_=m.bitLength()%26;for(_===0&&(_=26),N=m.length-1;N>=0;N--){for(var F=m.words[N],ct=_-1;ct>=0;ct--){var ft=F>>ct&1;if(M!==I[0]&&(M=this.sqr(M)),ft===0&&z===0){P=0;continue}z<<=1,z|=ft,P++,!(P!==v&&(N!==0||ct!==0))&&(M=this.mul(M,I[z]),P=0,z=0)}_=26}return M},rt.prototype.convertTo=function(p){var m=p.umod(this.m);return m===p?m.clone():m},rt.prototype.convertFrom=function(p){var m=p.clone();return m.red=null,m},s.mont=function(p){return new ot(p)};function ot(C){rt.call(this,C),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(ot,rt),ot.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},ot.prototype.convertFrom=function(p){var m=this.imod(p.mul(this.rinv));return m.red=null,m},ot.prototype.imul=function(p,m){if(p.isZero()||m.isZero())return p.words[0]=0,p.length=1,p;var v=p.imul(m),I=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=v.isub(I).iushrn(this.shift),M=N;return N.cmp(this.m)>=0?M=N.isub(this.m):N.cmpn(0)<0&&(M=N.iadd(this.m)),M._forceRed(this)},ot.prototype.mul=function(p,m){if(p.isZero()||m.isZero())return new s(0)._forceRed(this);var v=p.mul(m),I=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=v.isub(I).iushrn(this.shift),M=N;return N.cmp(this.m)>=0?M=N.isub(this.m):N.cmpn(0)<0&&(M=N.iadd(this.m)),M._forceRed(this)},ot.prototype.invm=function(p){var m=this.imod(p._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(n,Zn)})(Gw);var Kw=Gw.exports;const Ls=ea(Kw);function p0(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function zL(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function Fh(n,...t){if(!zL(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error("Uint8Array expected of length "+t+", got length="+n.length)}function GL(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");p0(n.outputLen),p0(n.blockLen)}function rl(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function Ax(n,t){Fh(n);const e=t.outputLen;if(n.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}const Lc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function VL(n){return new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4))}function wy(n){return new DataView(n.buffer,n.byteOffset,n.byteLength)}function Oi(n,t){return n<<32-t|n>>>t}const J_=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function KL(n){return n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255}function Y_(n){for(let t=0;t<n.length;t++)n[t]=KL(n[t])}function jL(n){if(typeof n!="string")throw new Error("utf8ToBytes expected string, got "+typeof n);return new Uint8Array(new TextEncoder().encode(n))}function sp(n){return typeof n=="string"&&(n=jL(n)),Fh(n),n}function WL(...n){let t=0;for(let r=0;r<n.length;r++){const i=n[r];Fh(i),t+=i.length}const e=new Uint8Array(t);for(let r=0,i=0;r<n.length;r++){const s=n[r];e.set(s,i),i+=s.length}return e}let jw=class{clone(){return this._cloneInto()}};function Ww(n){const t=r=>n().update(sp(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function Ex(n=32){if(Lc&&typeof Lc.getRandomValues=="function")return Lc.getRandomValues(new Uint8Array(n));if(Lc&&typeof Lc.randomBytes=="function")return Lc.randomBytes(n);throw new Error("crypto.getRandomValues must be defined")}function ZL(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),c=Number(e&s),u=r?4:0,f=r?0:4;n.setUint32(t+u,o,r),n.setUint32(t+f,c,r)}function qL(n,t,e){return n&t^~n&e}function QL(n,t,e){return n&t^n&e^t&e}class vx extends jw{constructor(t,e,r,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=wy(this.buffer)}update(t){rl(this);const{view:e,buffer:r,blockLen:i}=this;t=sp(t);const s=t.length;for(let o=0;o<s;){const c=Math.min(i-this.pos,s-o);if(c===i){const u=wy(t);for(;i<=s-o;o+=i)this.process(u,o);continue}r.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){rl(this),Ax(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let y=o;y<i;y++)e[y]=0;ZL(r,i-8,BigInt(this.length*8),s),this.process(r,0);const c=wy(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<f;y++)c.setUint32(4*y,h[y],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:i,finished:s,destroyed:o,pos:c}=this;return t.length=i,t.pos=c,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(r),t}}const Ad=BigInt(2**32-1),Tm=BigInt(32);function xx(n,t=!1){return t?{h:Number(n&Ad),l:Number(n>>Tm&Ad)}:{h:Number(n>>Tm&Ad)|0,l:Number(n&Ad)|0}}function Rx(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let i=0;i<n.length;i++){const{h:s,l:o}=xx(n[i],t);[e[i],r[i]]=[s,o]}return[e,r]}const JL=(n,t)=>BigInt(n>>>0)<<Tm|BigInt(t>>>0),YL=(n,t,e)=>n>>>e,XL=(n,t,e)=>n<<32-e|t>>>e,tU=(n,t,e)=>n>>>e|t<<32-e,eU=(n,t,e)=>n<<32-e|t>>>e,nU=(n,t,e)=>n<<64-e|t>>>e-32,rU=(n,t,e)=>n>>>e-32|t<<64-e,iU=(n,t)=>t,sU=(n,t)=>n,Sx=(n,t,e)=>n<<e|t>>>32-e,Ix=(n,t,e)=>t<<e|n>>>32-e,kx=(n,t,e)=>t<<e-32|n>>>64-e,Tx=(n,t,e)=>n<<e-32|t>>>64-e;function oU(n,t,e,r){const i=(t>>>0)+(r>>>0);return{h:n+e+(i/2**32|0)|0,l:i|0}}const aU=(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),cU=(n,t,e,r)=>t+e+r+(n/2**32|0)|0,uU=(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),lU=(n,t,e,r,i)=>t+e+r+i+(n/2**32|0)|0,fU=(n,t,e,r,i)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),hU=(n,t,e,r,i,s)=>t+e+r+i+s+(n/2**32|0)|0,Xt={fromBig:xx,split:Rx,toBig:JL,shrSH:YL,shrSL:XL,rotrSH:tU,rotrSL:eU,rotrBH:nU,rotrBL:rU,rotr32H:iU,rotr32L:sU,rotlSH:Sx,rotlSL:Ix,rotlBH:kx,rotlBL:Tx,add:oU,add3L:aU,add3H:cU,add4L:uU,add4H:lU,add5H:hU,add5L:fU},[dU,pU]=Xt.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),ro=new Uint32Array(80),io=new Uint32Array(80);let gU=class extends vx{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:f,El:h,Fh:y,Fl:A,Gh:b,Gl:R,Hh:k,Hl:S}=this;return[t,e,r,i,s,o,c,u,f,h,y,A,b,R,k,S]}set(t,e,r,i,s,o,c,u,f,h,y,A,b,R,k,S){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=f|0,this.El=h|0,this.Fh=y|0,this.Fl=A|0,this.Gh=b|0,this.Gl=R|0,this.Hh=k|0,this.Hl=S|0}process(t,e){for(let U=0;U<16;U++,e+=4)ro[U]=t.getUint32(e),io[U]=t.getUint32(e+=4);for(let U=16;U<80;U++){const G=ro[U-15]|0,W=io[U-15]|0,Y=Xt.rotrSH(G,W,1)^Xt.rotrSH(G,W,8)^Xt.shrSH(G,W,7),j=Xt.rotrSL(G,W,1)^Xt.rotrSL(G,W,8)^Xt.shrSL(G,W,7),J=ro[U-2]|0,it=io[U-2]|0,ut=Xt.rotrSH(J,it,19)^Xt.rotrBH(J,it,61)^Xt.shrSH(J,it,6),rt=Xt.rotrSL(J,it,19)^Xt.rotrBL(J,it,61)^Xt.shrSL(J,it,6),ot=Xt.add4L(j,rt,io[U-7],io[U-16]),C=Xt.add4H(ot,Y,ut,ro[U-7],ro[U-16]);ro[U]=C|0,io[U]=ot|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:f,Dl:h,Eh:y,El:A,Fh:b,Fl:R,Gh:k,Gl:S,Hh:B,Hl:H}=this;for(let U=0;U<80;U++){const G=Xt.rotrSH(y,A,14)^Xt.rotrSH(y,A,18)^Xt.rotrBH(y,A,41),W=Xt.rotrSL(y,A,14)^Xt.rotrSL(y,A,18)^Xt.rotrBL(y,A,41),Y=y&b^~y&k,j=A&R^~A&S,J=Xt.add5L(H,W,j,pU[U],io[U]),it=Xt.add5H(J,B,G,Y,dU[U],ro[U]),ut=J|0,rt=Xt.rotrSH(r,i,28)^Xt.rotrBH(r,i,34)^Xt.rotrBH(r,i,39),ot=Xt.rotrSL(r,i,28)^Xt.rotrBL(r,i,34)^Xt.rotrBL(r,i,39),C=r&s^r&c^s&c,p=i&o^i&u^o&u;B=k|0,H=S|0,k=b|0,S=R|0,b=y|0,R=A|0,{h:y,l:A}=Xt.add(f|0,h|0,it|0,ut|0),f=c|0,h=u|0,c=s|0,u=o|0,s=r|0,o=i|0;const m=Xt.add3L(ut,ot,p);r=Xt.add3H(m,it,rt,C),i=m|0}({h:r,l:i}=Xt.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=Xt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=Xt.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:f,l:h}=Xt.add(this.Dh|0,this.Dl|0,f|0,h|0),{h:y,l:A}=Xt.add(this.Eh|0,this.El|0,y|0,A|0),{h:b,l:R}=Xt.add(this.Fh|0,this.Fl|0,b|0,R|0),{h:k,l:S}=Xt.add(this.Gh|0,this.Gl|0,k|0,S|0),{h:B,l:H}=Xt.add(this.Hh|0,this.Hl|0,B|0,H|0),this.set(r,i,s,o,c,u,f,h,y,A,b,R,k,S,B,H)}roundClean(){ro.fill(0),io.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const yU=Ww(()=>new gU);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const op=BigInt(0),ap=BigInt(1),mU=BigInt(2);function oc(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function $h(n){if(!oc(n))throw new Error("Uint8Array expected")}function Gs(n,t){if(typeof t!="boolean")throw new Error(n+" boolean expected, got "+t)}const wU=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function ac(n){$h(n);let t="";for(let e=0;e<n.length;e++)t+=wU[n[e]];return t}function qc(n){const t=n.toString(16);return t.length&1?"0"+t:t}function Zw(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return n===""?op:BigInt("0x"+n)}const hs={_0:48,_9:57,A:65,F:70,a:97,f:102};function X_(n){if(n>=hs._0&&n<=hs._9)return n-hs._0;if(n>=hs.A&&n<=hs.F)return n-(hs.A-10);if(n>=hs.a&&n<=hs.f)return n-(hs.a-10)}function il(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const t=n.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(e);for(let i=0,s=0;i<e;i++,s+=2){const o=X_(n.charCodeAt(s)),c=X_(n.charCodeAt(s+1));if(o===void 0||c===void 0){const u=n[s]+n[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}r[i]=o*16+c}return r}function Xa(n){return Zw(ac(n))}function su(n){return $h(n),Zw(ac(Uint8Array.from(n).reverse()))}function sl(n,t){return il(n.toString(16).padStart(t*2,"0"))}function Xf(n,t){return sl(n,t).reverse()}function bU(n){return il(qc(n))}function Sn(n,t,e){let r;if(typeof t=="string")try{r=il(t)}catch(s){throw new Error(n+" must be hex string or Uint8Array, cause: "+s)}else if(oc(t))r=Uint8Array.from(t);else throw new Error(n+" must be hex string or Uint8Array");const i=r.length;if(typeof e=="number"&&i!==e)throw new Error(n+" of length "+e+" expected, got "+i);return r}function cc(...n){let t=0;for(let r=0;r<n.length;r++){const i=n[r];$h(i),t+=i.length}const e=new Uint8Array(t);for(let r=0,i=0;r<n.length;r++){const s=n[r];e.set(s,i),i+=s.length}return e}function _U(n,t){if(n.length!==t.length)return!1;let e=0;for(let r=0;r<n.length;r++)e|=n[r]^t[r];return e===0}function AU(n){if(typeof n!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(n))}const by=n=>typeof n=="bigint"&&op<=n;function cp(n,t,e){return by(n)&&by(t)&&by(e)&&t<=n&&n<e}function ri(n,t,e,r){if(!cp(t,e,r))throw new Error("expected valid "+n+": "+e+" <= n < "+r+", got "+t)}function Ox(n){let t;for(t=0;n>op;n>>=ap,t+=1);return t}function EU(n,t){return n>>BigInt(t)&ap}function vU(n,t,e){return n|(e?ap:op)<<BigInt(t)}const qw=n=>(mU<<BigInt(n-1))-ap,_y=n=>new Uint8Array(n),tA=n=>Uint8Array.from(n);function Nx(n,t,e){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let r=_y(n),i=_y(n),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},c=(...y)=>e(i,r,...y),u=(y=_y())=>{i=c(tA([0]),y),r=c(),y.length!==0&&(i=c(tA([1]),y),r=c())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let y=0;const A=[];for(;y<t;){r=c();const b=r.slice();A.push(b),y+=r.length}return cc(...A)};return(y,A)=>{o(),u(y);let b;for(;!(b=A(f()));)u();return o(),b}}const xU={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||oc(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,t)=>t.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function Il(n,t,e={}){const r=(i,s,o)=>{const c=xU[s];if(typeof c!="function")throw new Error("invalid validator function");const u=n[i];if(!(o&&u===void 0)&&!c(u,n))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+u)};for(const[i,s]of Object.entries(t))r(i,s,!1);for(const[i,s]of Object.entries(e))r(i,s,!0);return n}const RU=()=>{throw new Error("not implemented")};function th(n){const t=new WeakMap;return(e,...r)=>{const i=t.get(e);if(i!==void 0)return i;const s=n(e,...r);return t.set(e,s),s}}const SU=Object.freeze(Object.defineProperty({__proto__:null,aInRange:ri,abool:Gs,abytes:$h,bitGet:EU,bitLen:Ox,bitMask:qw,bitSet:vU,bytesToHex:ac,bytesToNumberBE:Xa,bytesToNumberLE:su,concatBytes:cc,createHmacDrbg:Nx,ensureBytes:Sn,equalBytes:_U,hexToBytes:il,hexToNumber:Zw,inRange:cp,isBytes:oc,memoized:th,notImplemented:RU,numberToBytesBE:sl,numberToBytesLE:Xf,numberToHexUnpadded:qc,numberToVarBytesBE:bU,utf8ToBytes:AU,validateObject:Il},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Dn=BigInt(0),nn=BigInt(1),ha=BigInt(2),IU=BigInt(3),Om=BigInt(4),eA=BigInt(5),nA=BigInt(8);function qe(n,t){const e=n%t;return e>=Dn?e:t+e}function kU(n,t,e){if(t<Dn)throw new Error("invalid exponent, negatives unsupported");if(e<=Dn)throw new Error("invalid modulus");if(e===nn)return Dn;let r=nn;for(;t>Dn;)t&nn&&(r=r*n%e),n=n*n%e,t>>=nn;return r}function wn(n,t,e){let r=n;for(;t-- >Dn;)r*=r,r%=e;return r}function Nm(n,t){if(n===Dn)throw new Error("invert: expected non-zero number");if(t<=Dn)throw new Error("invert: expected positive modulus, got "+t);let e=qe(n,t),r=t,i=Dn,s=nn;for(;e!==Dn;){const c=r/e,u=r%e,f=i-s*c;r=e,e=u,i=s,s=f}if(r!==nn)throw new Error("invert: does not exist");return qe(i,t)}function TU(n){const t=(n-nn)/ha;let e,r,i;for(e=n-nn,r=0;e%ha===Dn;e/=ha,r++);for(i=ha;i<n&&kU(i,t,n)!==n-nn;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(n+nn)/Om;return function(u,f){const h=u.pow(f,o);if(!u.eql(u.sqr(h),f))throw new Error("Cannot find square root");return h}}const s=(e+nn)/ha;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=r,h=c.pow(c.mul(c.ONE,i),e),y=c.pow(u,s),A=c.pow(u,e);for(;!c.eql(A,c.ONE);){if(c.eql(A,c.ZERO))return c.ZERO;let b=1;for(let k=c.sqr(A);b<f&&!c.eql(k,c.ONE);b++)k=c.sqr(k);const R=c.pow(h,nn<<BigInt(f-b-1));h=c.sqr(R),y=c.mul(y,R),A=c.mul(A,h),f=b}return y}}function OU(n){if(n%Om===IU){const t=(n+nn)/Om;return function(r,i){const s=r.pow(i,t);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(n%nA===eA){const t=(n-eA)/nA;return function(r,i){const s=r.mul(i,ha),o=r.pow(s,t),c=r.mul(i,o),u=r.mul(r.mul(c,ha),o),f=r.mul(c,r.sub(u,r.ONE));if(!r.eql(r.sqr(f),i))throw new Error("Cannot find square root");return f}}return TU(n)}const NU=(n,t)=>(qe(n,t)&nn)===nn,CU=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function BU(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=CU.reduce((r,i)=>(r[i]="function",r),t);return Il(n,e)}function PU(n,t,e){if(e<Dn)throw new Error("invalid exponent, negatives unsupported");if(e===Dn)return n.ONE;if(e===nn)return t;let r=n.ONE,i=t;for(;e>Dn;)e&nn&&(r=n.mul(r,i)),i=n.sqr(i),e>>=nn;return r}function MU(n,t){const e=new Array(t.length),r=t.reduce((s,o,c)=>n.is0(o)?s:(e[c]=s,n.mul(s,o)),n.ONE),i=n.inv(r);return t.reduceRight((s,o,c)=>n.is0(o)?s:(e[c]=n.mul(s,e[c]),n.mul(s,o)),i),e}function Cx(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function up(n,t,e=!1,r={}){if(n<=Dn)throw new Error("invalid field: expected ORDER > 0, got "+n);const{nBitLength:i,nByteLength:s}=Cx(n,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const c=Object.freeze({ORDER:n,isLE:e,BITS:i,BYTES:s,MASK:qw(i),ZERO:Dn,ONE:nn,create:u=>qe(u,n),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return Dn<=u&&u<n},is0:u=>u===Dn,isOdd:u=>(u&nn)===nn,neg:u=>qe(-u,n),eql:(u,f)=>u===f,sqr:u=>qe(u*u,n),add:(u,f)=>qe(u+f,n),sub:(u,f)=>qe(u-f,n),mul:(u,f)=>qe(u*f,n),pow:(u,f)=>PU(c,u,f),div:(u,f)=>qe(u*Nm(f,n),n),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>Nm(u,n),sqrt:r.sqrt||(u=>(o||(o=OU(n)),o(c,u))),invertBatch:u=>MU(c,u),cmov:(u,f,h)=>h?f:u,toBytes:u=>e?Xf(u,s):sl(u,s),fromBytes:u=>{if(u.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+u.length);return e?su(u):Xa(u)}});return Object.freeze(c)}function Bx(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function Px(n){const t=Bx(n);return t+Math.ceil(t/2)}function LU(n,t,e=!1){const r=n.length,i=Bx(t),s=Px(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const o=e?su(n):Xa(n),c=qe(o,t-nn)+nn;return e?Xf(c,i):sl(c,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rA=BigInt(0),Ed=BigInt(1);function Ay(n,t){const e=t.negate();return n?e:t}function Mx(n,t){if(!Number.isSafeInteger(n)||n<=0||n>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+n)}function Ey(n,t){Mx(n,t);const e=Math.ceil(t/n)+1,r=2**(n-1);return{windows:e,windowSize:r}}function UU(n,t){if(!Array.isArray(n))throw new Error("array expected");n.forEach((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)})}function DU(n,t){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)})}const vy=new WeakMap,Lx=new WeakMap;function xy(n){return Lx.get(n)||1}function Ux(n,t){return{constTimeNegate:Ay,hasPrecomputes(e){return xy(e)!==1},unsafeLadder(e,r,i=n.ZERO){let s=e;for(;r>rA;)r&Ed&&(i=i.add(s)),s=s.double(),r>>=Ed;return i},precomputeWindow(e,r){const{windows:i,windowSize:s}=Ey(r,t),o=[];let c=e,u=c;for(let f=0;f<i;f++){u=c,o.push(u);for(let h=1;h<s;h++)u=u.add(c),o.push(u);c=u.double()}return o},wNAF(e,r,i){const{windows:s,windowSize:o}=Ey(e,t);let c=n.ZERO,u=n.BASE;const f=BigInt(2**e-1),h=2**e,y=BigInt(e);for(let A=0;A<s;A++){const b=A*o;let R=Number(i&f);i>>=y,R>o&&(R-=h,i+=Ed);const k=b,S=b+Math.abs(R)-1,B=A%2!==0,H=R<0;R===0?u=u.add(Ay(B,r[k])):c=c.add(Ay(H,r[S]))}return{p:c,f:u}},wNAFUnsafe(e,r,i,s=n.ZERO){const{windows:o,windowSize:c}=Ey(e,t),u=BigInt(2**e-1),f=2**e,h=BigInt(e);for(let y=0;y<o;y++){const A=y*c;if(i===rA)break;let b=Number(i&u);if(i>>=h,b>c&&(b-=f,i+=Ed),b===0)continue;let R=r[A+Math.abs(b)-1];b<0&&(R=R.negate()),s=s.add(R)}return s},getPrecomputes(e,r,i){let s=vy.get(r);return s||(s=this.precomputeWindow(r,e),e!==1&&vy.set(r,i(s))),s},wNAFCached(e,r,i){const s=xy(e);return this.wNAF(s,this.getPrecomputes(s,e,i),r)},wNAFCachedUnsafe(e,r,i,s){const o=xy(e);return o===1?this.unsafeLadder(e,r,s):this.wNAFUnsafe(o,this.getPrecomputes(o,e,i),r,s)},setWindowSize(e,r){Mx(r,t),Lx.set(e,r),vy.delete(e)}}}function Dx(n,t,e,r){if(UU(e,n),DU(r,t),e.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=n.ZERO,s=Ox(BigInt(e.length)),o=s>12?s-3:s>4?s-2:s?2:1,c=(1<<o)-1,u=new Array(c+1).fill(i),f=Math.floor((t.BITS-1)/o)*o;let h=i;for(let y=f;y>=0;y-=o){u.fill(i);for(let b=0;b<r.length;b++){const R=r[b],k=Number(R>>BigInt(y)&BigInt(c));u[k]=u[k].add(e[b])}let A=i;for(let b=u.length-1,R=i;b>0;b--)R=R.add(u[b]),A=A.add(R);if(h=h.add(A),y!==0)for(let b=0;b<o;b++)h=h.double()}return h}function Qw(n){return BU(n.Fp),Il(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Cx(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ui=BigInt(0),_r=BigInt(1),vd=BigInt(2),FU=BigInt(8),$U={zip215:!0};function HU(n){const t=Qw(n);return Il(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function zU(n){const t=HU(n),{Fp:e,n:r,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:u}=t,f=vd<<BigInt(c*8)-_r,h=e.create,y=up(t.n,t.nBitLength),A=t.uvRatio||((v,I)=>{try{return{isValid:!0,value:e.sqrt(v*e.inv(I))}}catch{return{isValid:!1,value:ui}}}),b=t.adjustScalarBytes||(v=>v),R=t.domain||((v,I,N)=>{if(Gs("phflag",N),I.length||N)throw new Error("Contexts/pre-hash are not supported");return v});function k(v,I){ri("coordinate "+v,I,ui,f)}function S(v){if(!(v instanceof U))throw new Error("ExtendedPoint expected")}const B=th((v,I)=>{const{ex:N,ey:M,ez:z}=v,P=v.is0();I==null&&(I=P?FU:e.inv(z));const _=h(N*I),F=h(M*I),ct=h(z*I);if(P)return{x:ui,y:_r};if(ct!==_r)throw new Error("invZ was invalid");return{x:_,y:F}}),H=th(v=>{const{a:I,d:N}=t;if(v.is0())throw new Error("bad point: ZERO");const{ex:M,ey:z,ez:P,et:_}=v,F=h(M*M),ct=h(z*z),ft=h(P*P),mt=h(ft*ft),Ht=h(F*I),Lt=h(ft*h(Ht+ct)),Mt=h(mt+h(N*h(F*ct)));if(Lt!==Mt)throw new Error("bad point: equation left != right (1)");const Ae=h(M*z),Vt=h(P*_);if(Ae!==Vt)throw new Error("bad point: equation left != right (2)");return!0});class U{constructor(I,N,M,z){this.ex=I,this.ey=N,this.ez=M,this.et=z,k("x",I),k("y",N),k("z",M),k("t",z),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof U)throw new Error("extended point not allowed");const{x:N,y:M}=I||{};return k("x",N),k("y",M),new U(N,M,_r,h(N*M))}static normalizeZ(I){const N=e.invertBatch(I.map(M=>M.ez));return I.map((M,z)=>M.toAffine(N[z])).map(U.fromAffine)}static msm(I,N){return Dx(U,y,I,N)}_setWindowSize(I){Y.setWindowSize(this,I)}assertValidity(){H(this)}equals(I){S(I);const{ex:N,ey:M,ez:z}=this,{ex:P,ey:_,ez:F}=I,ct=h(N*F),ft=h(P*z),mt=h(M*F),Ht=h(_*z);return ct===ft&&mt===Ht}is0(){return this.equals(U.ZERO)}negate(){return new U(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:I}=t,{ex:N,ey:M,ez:z}=this,P=h(N*N),_=h(M*M),F=h(vd*h(z*z)),ct=h(I*P),ft=N+M,mt=h(h(ft*ft)-P-_),Ht=ct+_,Lt=Ht-F,Mt=ct-_,Ae=h(mt*Lt),Vt=h(Ht*Mt),Ut=h(mt*Mt),Re=h(Lt*Ht);return new U(Ae,Vt,Re,Ut)}add(I){S(I);const{a:N,d:M}=t,{ex:z,ey:P,ez:_,et:F}=this,{ex:ct,ey:ft,ez:mt,et:Ht}=I;if(N===BigInt(-1)){const Ee=h((P-z)*(ft+ct)),Ie=h((P+z)*(ft-ct)),_n=h(Ie-Ee);if(_n===ui)return this.double();const ue=h(_*vd*Ht),ve=h(F*vd*mt),Je=ve+ue,me=Ie+Ee,ke=ve-ue,Jn=h(Je*_n),Le=h(me*ke),O=h(Je*ke),w=h(_n*me);return new U(Jn,Le,w,O)}const Lt=h(z*ct),Mt=h(P*ft),Ae=h(F*M*Ht),Vt=h(_*mt),Ut=h((z+P)*(ct+ft)-Lt-Mt),Re=Vt-Ae,Yt=Vt+Ae,ie=h(Mt-N*Lt),Qe=h(Ut*Re),ce=h(Yt*ie),Me=h(Ut*ie),Xs=h(Re*Yt);return new U(Qe,ce,Xs,Me)}subtract(I){return this.add(I.negate())}wNAF(I){return Y.wNAFCached(this,I,U.normalizeZ)}multiply(I){const N=I;ri("scalar",N,_r,r);const{p:M,f:z}=this.wNAF(N);return U.normalizeZ([M,z])[0]}multiplyUnsafe(I,N=U.ZERO){const M=I;return ri("scalar",M,ui,r),M===ui?W:this.is0()||M===_r?this:Y.wNAFCachedUnsafe(this,M,U.normalizeZ,N)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return Y.unsafeLadder(this,r).is0()}toAffine(I){return B(this,I)}clearCofactor(){const{h:I}=t;return I===_r?this:this.multiplyUnsafe(I)}static fromHex(I,N=!1){const{d:M,a:z}=t,P=e.BYTES;I=Sn("pointHex",I,P),Gs("zip215",N);const _=I.slice(),F=I[P-1];_[P-1]=F&-129;const ct=su(_),ft=N?f:e.ORDER;ri("pointHex.y",ct,ui,ft);const mt=h(ct*ct),Ht=h(mt-_r),Lt=h(M*mt-z);let{isValid:Mt,value:Ae}=A(Ht,Lt);if(!Mt)throw new Error("Point.fromHex: invalid y coordinate");const Vt=(Ae&_r)===_r,Ut=(F&128)!==0;if(!N&&Ae===ui&&Ut)throw new Error("Point.fromHex: x=0 and x_0=1");return Ut!==Vt&&(Ae=h(-Ae)),U.fromAffine({x:Ae,y:ct})}static fromPrivateKey(I){return it(I).point}toRawBytes(){const{x:I,y:N}=this.toAffine(),M=Xf(N,e.BYTES);return M[M.length-1]|=I&_r?128:0,M}toHex(){return ac(this.toRawBytes())}}U.BASE=new U(t.Gx,t.Gy,_r,h(t.Gx*t.Gy)),U.ZERO=new U(ui,_r,_r,ui);const{BASE:G,ZERO:W}=U,Y=Ux(U,c*8);function j(v){return qe(v,r)}function J(v){return j(su(v))}function it(v){const I=e.BYTES;v=Sn("private key",v,I);const N=Sn("hashed private key",s(v),2*I),M=b(N.slice(0,I)),z=N.slice(I,2*I),P=J(M),_=G.multiply(P),F=_.toRawBytes();return{head:M,prefix:z,scalar:P,point:_,pointBytes:F}}function ut(v){return it(v).pointBytes}function rt(v=new Uint8Array,...I){const N=cc(...I);return J(s(R(N,Sn("context",v),!!i)))}function ot(v,I,N={}){v=Sn("message",v),i&&(v=i(v));const{prefix:M,scalar:z,pointBytes:P}=it(I),_=rt(N.context,M,v),F=G.multiply(_).toRawBytes(),ct=rt(N.context,F,P,v),ft=j(_+ct*z);ri("signature.s",ft,ui,r);const mt=cc(F,Xf(ft,e.BYTES));return Sn("result",mt,e.BYTES*2)}const C=$U;function p(v,I,N,M=C){const{context:z,zip215:P}=M,_=e.BYTES;v=Sn("signature",v,2*_),I=Sn("message",I),N=Sn("publicKey",N,_),P!==void 0&&Gs("zip215",P),i&&(I=i(I));const F=su(v.slice(_,2*_));let ct,ft,mt;try{ct=U.fromHex(N,P),ft=U.fromHex(v.slice(0,_),P),mt=G.multiplyUnsafe(F)}catch{return!1}if(!P&&ct.isSmallOrder())return!1;const Ht=rt(z,ft.toRawBytes(),ct.toRawBytes(),I);return ft.add(ct.multiplyUnsafe(Ht)).subtract(mt).clearCofactor().equals(U.ZERO)}return G._setWindowSize(8),{CURVE:t,getPublicKey:ut,sign:ot,verify:p,ExtendedPoint:U,utils:{getExtendedPublicKey:it,randomPrivateKey:()=>o(e.BYTES),precompute(v=8,I=U.BASE){return I._setWindowSize(v),I.multiply(BigInt(3)),I}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Jw=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),iA=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const GU=BigInt(1),sA=BigInt(2);BigInt(3);const VU=BigInt(5),KU=BigInt(8);function jU(n){const t=BigInt(10),e=BigInt(20),r=BigInt(40),i=BigInt(80),s=Jw,c=n*n%s*n%s,u=wn(c,sA,s)*c%s,f=wn(u,GU,s)*n%s,h=wn(f,VU,s)*f%s,y=wn(h,t,s)*h%s,A=wn(y,e,s)*y%s,b=wn(A,r,s)*A%s,R=wn(b,i,s)*b%s,k=wn(R,i,s)*b%s,S=wn(k,t,s)*h%s;return{pow_p_5_8:wn(S,sA,s)*n%s,b2:c}}function WU(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function ZU(n,t){const e=Jw,r=qe(t*t*t,e),i=qe(r*r*t,e),s=jU(n*i).pow_p_5_8;let o=qe(n*r*s,e);const c=qe(t*o*o,e),u=o,f=qe(o*iA,e),h=c===n,y=c===qe(-n,e),A=c===qe(-n*iA,e);return h&&(o=u),(y||A)&&(o=f),NU(o,e)&&(o=qe(-o,e)),{isValid:h||y,value:o}}const qU=up(Jw,void 0,!0),QU={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:qU,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:KU,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:yU,randomBytes:Ex,adjustScalarBytes:WU,uvRatio:ZU},kl=zU(QU);var Cm={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,t){var e=Vw,r=e.Buffer;function i(o,c){for(var u in o)c[u]=o[u]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(i(e,t),t.Buffer=s);function s(o,c,u){return r(o,c,u)}s.prototype=Object.create(r.prototype),i(r,s),s.from=function(o,c,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,c,u)},s.alloc=function(o,c,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var f=r(o);return c!==void 0?typeof u=="string"?f.fill(c,u):f.fill(c):f.fill(0),f},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(Cm,Cm.exports);var JU=Cm.exports,xd=JU.Buffer;function YU(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),e=0;e<t.length;e++)t[e]=255;for(var r=0;r<n.length;r++){var i=n.charAt(r),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=r}var o=n.length,c=n.charAt(0),u=Math.log(o)/Math.log(256),f=Math.log(256)/Math.log(o);function h(b){if((Array.isArray(b)||b instanceof Uint8Array)&&(b=xd.from(b)),!xd.isBuffer(b))throw new TypeError("Expected Buffer");if(b.length===0)return"";for(var R=0,k=0,S=0,B=b.length;S!==B&&b[S]===0;)S++,R++;for(var H=(B-S)*f+1>>>0,U=new Uint8Array(H);S!==B;){for(var G=b[S],W=0,Y=H-1;(G!==0||W<k)&&Y!==-1;Y--,W++)G+=256*U[Y]>>>0,U[Y]=G%o>>>0,G=G/o>>>0;if(G!==0)throw new Error("Non-zero carry");k=W,S++}for(var j=H-k;j!==H&&U[j]===0;)j++;for(var J=c.repeat(R);j<H;++j)J+=n.charAt(U[j]);return J}function y(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return xd.alloc(0);for(var R=0,k=0,S=0;b[R]===c;)k++,R++;for(var B=(b.length-R)*u+1>>>0,H=new Uint8Array(B);R<b.length;){var U=b.charCodeAt(R);if(U>255)return;var G=t[U];if(G===255)return;for(var W=0,Y=B-1;(G!==0||W<S)&&Y!==-1;Y--,W++)G+=o*H[Y]>>>0,H[Y]=G%256>>>0,G=G/256>>>0;if(G!==0)throw new Error("Non-zero carry");S=W,R++}for(var j=B-S;j!==B&&H[j]===0;)j++;var J=xd.allocUnsafe(k+(B-j));J.fill(0,0,k);for(var it=k;j!==B;)J[it++]=H[j++];return J}function A(b){var R=y(b);if(R)return R;throw new Error("Non-base"+o+" character")}return{encode:h,decodeUnsafe:y,decode:A}}var XU=YU,tD=XU,eD="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Fx=tD(eD);const In=ea(Fx),nD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),so=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),oo=new Uint32Array(64);let rD=class extends vx{constructor(){super(64,32,8,!1),this.A=so[0]|0,this.B=so[1]|0,this.C=so[2]|0,this.D=so[3]|0,this.E=so[4]|0,this.F=so[5]|0,this.G=so[6]|0,this.H=so[7]|0}get(){const{A:t,B:e,C:r,D:i,E:s,F:o,G:c,H:u}=this;return[t,e,r,i,s,o,c,u]}set(t,e,r,i,s,o,c,u){this.A=t|0,this.B=e|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(t,e){for(let y=0;y<16;y++,e+=4)oo[y]=t.getUint32(e,!1);for(let y=16;y<64;y++){const A=oo[y-15],b=oo[y-2],R=Oi(A,7)^Oi(A,18)^A>>>3,k=Oi(b,17)^Oi(b,19)^b>>>10;oo[y]=k+oo[y-7]+R+oo[y-16]|0}let{A:r,B:i,C:s,D:o,E:c,F:u,G:f,H:h}=this;for(let y=0;y<64;y++){const A=Oi(c,6)^Oi(c,11)^Oi(c,25),b=h+A+qL(c,u,f)+nD[y]+oo[y]|0,k=(Oi(r,2)^Oi(r,13)^Oi(r,22))+QL(r,i,s)|0;h=f,f=u,u=c,c=o+b|0,o=s,s=i,i=r,r=b+k|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(r,i,s,o,c,u,f,h)}roundClean(){oo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Bm=Ww(()=>new rD);var Kn={};function Us(n,t,e){return t<=n&&n<=e}function lp(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function iD(n){for(var t=String(n),e=t.length,r=0,i=[];r<e;){var s=t.charCodeAt(r);if(s<55296||s>57343)i.push(s);else if(56320<=s&&s<=57343)i.push(65533);else if(55296<=s&&s<=56319)if(r===e-1)i.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var c=s&1023,u=o&1023;i.push(65536+(c<<10)+u),r+=1}else i.push(65533)}r+=1}return i}function sD(n){for(var t="",e=0;e<n.length;++e){var r=n[e];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}var g0=-1;function Yw(n){this.tokens=[].slice.call(n)}Yw.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():g0},prepend:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.push(t.shift());else this.tokens.push(n)}};var ol=-1;function Ry(n,t){if(n)throw TypeError("Decoder error");return t||65533}var y0="utf-8";function m0(n,t){if(!(this instanceof m0))return new m0(n,t);if(n=n!==void 0?String(n).toLowerCase():y0,n!==y0)throw new Error("Encoding not supported. Only utf-8 is supported");t=lp(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}m0.prototype={decode:function(t,e){var r;typeof t=="object"&&t instanceof ArrayBuffer?r=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):r=new Uint8Array(0),e=lp(e),this._streaming||(this._decoder=new oD({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var i=new Yw(r),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==ol);)o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o));if(!this._streaming){do{if(o=this._decoder.handler(i,i.read()),o===ol)break;o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o))}while(!i.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),sD(s)}};function w0(n,t){if(!(this instanceof w0))return new w0(n,t);if(n=n!==void 0?String(n).toLowerCase():y0,n!==y0)throw new Error("Encoding not supported. Only utf-8 is supported");t=lp(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}w0.prototype={encode:function(t,e){t=t?String(t):"",e=lp(e),this._streaming||(this._encoder=new aD(this._options)),this._streaming=!!e.stream;for(var r=[],i=new Yw(iD(t)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==ol);)Array.isArray(s)?r.push.apply(r,s):r.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==ol;)Array.isArray(s)?r.push.apply(r,s):r.push(s);this._encoder=null}return new Uint8Array(r)}};function oD(n){var t=n.fatal,e=0,r=0,i=0,s=128,o=191;this.handler=function(c,u){if(u===g0&&i!==0)return i=0,Ry(t);if(u===g0)return ol;if(i===0){if(Us(u,0,127))return u;if(Us(u,194,223))i=1,e=u-192;else if(Us(u,224,239))u===224&&(s=160),u===237&&(o=159),i=2,e=u-224;else if(Us(u,240,244))u===240&&(s=144),u===244&&(o=143),i=3,e=u-240;else return Ry(t);return e=e<<6*i,null}if(!Us(u,s,o))return e=i=r=0,s=128,o=191,c.prepend(u),Ry(t);if(s=128,o=191,r+=1,e+=u-128<<6*(i-r),r!==i)return null;var f=e;return e=i=r=0,f}}function aD(n){n.fatal,this.handler=function(t,e){if(e===g0)return ol;if(Us(e,0,127))return e;var r,i;Us(e,128,2047)?(r=1,i=192):Us(e,2048,65535)?(r=2,i=224):Us(e,65536,1114111)&&(r=3,i=240);for(var s=[(e>>6*r)+i];r>0;){var o=e>>6*(r-1);s.push(128|o&63),r-=1}return s}}const cD=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:m0,TextEncoder:w0},Symbol.toStringTag,{value:"Module"})),uD=q0(cD);var lD=Zn&&Zn.__createBinding||(Object.create?function(n,t,e,r){r===void 0&&(r=e),Object.defineProperty(n,r,{enumerable:!0,get:function(){return t[e]}})}:function(n,t,e,r){r===void 0&&(r=e),n[r]=t[e]}),fD=Zn&&Zn.__setModuleDefault||(Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t}),os=Zn&&Zn.__decorate||function(n,t,e,r){var i=arguments.length,s=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,r);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(i<3?o(s):i>3?o(t,e,s):o(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s},hD=Zn&&Zn.__importStar||function(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e in n)e!=="default"&&Object.hasOwnProperty.call(n,e)&&lD(t,n,e);return fD(t,n),t},$x=Zn&&Zn.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Kn,"__esModule",{value:!0});var Hx=Kn.deserializeUnchecked=Wx=Kn.deserialize=jx=Kn.serialize=Kn.BinaryReader=Kn.BinaryWriter=Kn.BorshError=Kn.baseDecode=Kn.baseEncode=void 0;const Uo=$x(Kw),zx=$x(Fx),dD=hD(uD),pD=typeof TextDecoder!="function"?dD.TextDecoder:TextDecoder,gD=new pD("utf-8",{fatal:!0});function yD(n){return typeof n=="string"&&(n=Zt.from(n,"utf8")),zx.default.encode(Zt.from(n))}Kn.baseEncode=yD;function mD(n){return Zt.from(zx.default.decode(n))}Kn.baseDecode=mD;const Sy=1024;class hr extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Kn.BorshError=hr;class Gx{constructor(){this.buf=Zt.alloc(Sy),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Zt.concat([this.buf,Zt.alloc(Sy)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Zt.from(new Uo.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Zt.from(new Uo.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Zt.from(new Uo.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Zt.from(new Uo.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Zt.concat([Zt.from(this.buf.subarray(0,this.length)),t,Zt.alloc(Sy)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Zt.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Zt.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}Kn.BinaryWriter=Gx;function as(n,t,e){const r=e.value;e.value=function(...i){try{return r.apply(this,i)}catch(s){if(s instanceof RangeError){const o=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new hr("Reached the end of buffer when deserializing")}throw s}}}class Kr{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new Uo.default(t,"le")}readU128(){const t=this.readBuffer(16);return new Uo.default(t,"le")}readU256(){const t=this.readBuffer(32);return new Uo.default(t,"le")}readU512(){const t=this.readBuffer(64);return new Uo.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new hr(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return gD.decode(e)}catch(r){throw new hr(`Error decoding UTF-8 string: ${r}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let i=0;i<e;++i)r.push(t());return r}}os([as],Kr.prototype,"readU8",null);os([as],Kr.prototype,"readU16",null);os([as],Kr.prototype,"readU32",null);os([as],Kr.prototype,"readU64",null);os([as],Kr.prototype,"readU128",null);os([as],Kr.prototype,"readU256",null);os([as],Kr.prototype,"readU512",null);os([as],Kr.prototype,"readString",null);os([as],Kr.prototype,"readFixedArray",null);os([as],Kr.prototype,"readArray",null);Kn.BinaryReader=Kr;function Vx(n){return n.charAt(0).toUpperCase()+n.slice(1)}function da(n,t,e,r,i){try{if(typeof r=="string")i[`write${Vx(r)}`](e);else if(r instanceof Array)if(typeof r[0]=="number"){if(e.length!==r[0])throw new hr(`Expecting byte array of length ${r[0]}, but got ${e.length} bytes`);i.writeFixedArray(e)}else if(r.length===2&&typeof r[1]=="number"){if(e.length!==r[1])throw new hr(`Expecting byte array of length ${r[1]}, but got ${e.length} bytes`);for(let s=0;s<r[1];s++)da(n,null,e[s],r[0],i)}else i.writeArray(e,s=>{da(n,t,s,r[0],i)});else if(r.kind!==void 0)switch(r.kind){case"option":{e==null?i.writeU8(0):(i.writeU8(1),da(n,t,e,r.type,i));break}case"map":{i.writeU32(e.size),e.forEach((s,o)=>{da(n,t,o,r.key,i),da(n,t,s,r.value,i)});break}default:throw new hr(`FieldType ${r} unrecognized`)}else Kx(n,e,i)}catch(s){throw s instanceof hr&&s.addToFieldPath(t),s}}function Kx(n,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const r=n.get(t.constructor);if(!r)throw new hr(`Class ${t.constructor.name} is missing in schema`);if(r.kind==="struct")r.fields.map(([i,s])=>{da(n,i,t[i],s,e)});else if(r.kind==="enum"){const i=t[r.field];for(let s=0;s<r.values.length;++s){const[o,c]=r.values[s];if(o===i){e.writeU8(s),da(n,o,t[o],c,e);break}}}else throw new hr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function wD(n,t,e=Gx){const r=new e;return Kx(n,t,r),r.toArray()}var jx=Kn.serialize=wD;function pa(n,t,e,r){try{if(typeof e=="string")return r[`read${Vx(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return r.readFixedArray(e[0]);if(typeof e[1]=="number"){const i=[];for(let s=0;s<e[1];s++)i.push(pa(n,null,e[0],r));return i}else return r.readArray(()=>pa(n,t,e[0],r))}if(e.kind==="option")return r.readU8()?pa(n,t,e.type,r):void 0;if(e.kind==="map"){let i=new Map;const s=r.readU32();for(let o=0;o<s;o++){const c=pa(n,t,e.key,r),u=pa(n,t,e.value,r);i.set(c,u)}return i}return Xw(n,e,r)}catch(i){throw i instanceof hr&&i.addToFieldPath(t),i}}function Xw(n,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const r=n.get(t);if(!r)throw new hr(`Class ${t.name} is missing in schema`);if(r.kind==="struct"){const i={};for(const[s,o]of n.get(t).fields)i[s]=pa(n,s,o,e);return new t(i)}if(r.kind==="enum"){const i=e.readU8();if(i>=r.values.length)throw new hr(`Enum index: ${i} is out of range`);const[s,o]=r.values[i],c=pa(n,s,o,e);return new t({[s]:c})}throw new hr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function bD(n,t,e,r=Kr){const i=new r(e),s=Xw(n,t,i);if(i.offset<e.length)throw new hr(`Unexpected ${e.length-i.offset} bytes after deserialized data`);return s}var Wx=Kn.deserialize=bD;function _D(n,t,e,r=Kr){const i=new r(e);return Xw(n,t,i)}Hx=Kn.deserializeUnchecked=_D;var et={};Object.defineProperty(et,"__esModule",{value:!0});et.s16=et.s8=et.nu64be=et.u48be=et.u40be=et.u32be=et.u24be=et.u16be=zn=et.nu64=et.u48=et.u40=Tt=et.u32=et.u24=ni=et.u16=ge=et.u8=$o=et.offset=et.greedy=et.Constant=et.UTF8=et.CString=et.Blob=et.Boolean=et.BitField=et.BitStructure=et.VariantLayout=et.Union=et.UnionLayoutDiscriminator=et.UnionDiscriminator=et.Structure=et.Sequence=et.DoubleBE=et.Double=et.FloatBE=et.Float=et.NearInt64BE=et.NearInt64=et.NearUInt64BE=et.NearUInt64=et.IntBE=et.Int=et.UIntBE=et.UInt=et.OffsetLayout=et.GreedyCount=et.ExternalLayout=et.bindConstructorLayout=et.nameWithProperty=et.Layout=et.uint8ArrayToBuffer=et.checkUint8Array=void 0;et.constant=et.utf8=et.cstr=Ge=et.blob=et.unionLayoutDiscriminator=et.union=qn=et.seq=et.bits=Ot=et.struct=et.f64be=et.f64=et.f32be=et.f32=et.ns64be=et.s48be=et.s40be=et.s32be=et.s24be=et.s16be=Hr=et.ns64=et.s48=et.s40=et.s32=et.s24=void 0;const t1=Vw;function Tl(n){if(!(n instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}et.checkUint8Array=Tl;function _e(n){return Tl(n),t1.Buffer.from(n.buffer,n.byteOffset,n.length)}et.uint8ArrayToBuffer=_e;let Oe=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};et.Layout=Oe;function e1(n,t){return t.property?n+"["+t.property+"]":n}et.nameWithProperty=e1;function AD(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(n,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Oe))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(n,"decode",{value(e,r){return t.decode(e,r)},writable:!0})}et.bindConstructorLayout=AD;let Ir=class extends Oe{isCount(){throw new Error("ExternalLayout is abstract")}};et.ExternalLayout=Ir;let Zx=class extends Ir{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){Tl(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}};et.GreedyCount=Zx;let n1=class extends Ir{constructor(t,e=0,r){if(!(t instanceof Oe))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof si||this.layout instanceof Ai}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,r=0){return this.layout.encode(t,e,r+this.offset)}};et.OffsetLayout=n1;let si=class extends Oe{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return _e(t).readUIntLE(e,this.span)}encode(t,e,r=0){return _e(e).writeUIntLE(t,r,this.span),this.span}};et.UInt=si;let Ai=class extends Oe{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return _e(t).readUIntBE(e,this.span)}encode(t,e,r=0){return _e(e).writeUIntBE(t,r,this.span),this.span}};et.UIntBE=Ai;let _c=class extends Oe{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return _e(t).readIntLE(e,this.span)}encode(t,e,r=0){return _e(e).writeIntLE(t,r,this.span),this.span}};et.Int=_c;let Ol=class extends Oe{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return _e(t).readIntBE(e,this.span)}encode(t,e,r=0){return _e(e).writeIntBE(t,r,this.span),this.span}};et.IntBE=Ol;const Pm=Math.pow(2,32);function fp(n){const t=Math.floor(n/Pm),e=n-t*Pm;return{hi32:t,lo32:e}}function hp(n,t){return n*Pm+t}let qx=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){const r=_e(t),i=r.readUInt32LE(e),s=r.readUInt32LE(e+4);return hp(s,i)}encode(t,e,r=0){const i=fp(t),s=_e(e);return s.writeUInt32LE(i.lo32,r),s.writeUInt32LE(i.hi32,r+4),8}};et.NearUInt64=qx;let Qx=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){const r=_e(t),i=r.readUInt32BE(e),s=r.readUInt32BE(e+4);return hp(i,s)}encode(t,e,r=0){const i=fp(t),s=_e(e);return s.writeUInt32BE(i.hi32,r),s.writeUInt32BE(i.lo32,r+4),8}};et.NearUInt64BE=Qx;let Jx=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){const r=_e(t),i=r.readUInt32LE(e),s=r.readInt32LE(e+4);return hp(s,i)}encode(t,e,r=0){const i=fp(t),s=_e(e);return s.writeUInt32LE(i.lo32,r),s.writeInt32LE(i.hi32,r+4),8}};et.NearInt64=Jx;let Yx=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){const r=_e(t),i=r.readInt32BE(e),s=r.readUInt32BE(e+4);return hp(i,s)}encode(t,e,r=0){const i=fp(t),s=_e(e);return s.writeInt32BE(i.hi32,r),s.writeUInt32BE(i.lo32,r+4),8}};et.NearInt64BE=Yx;let Xx=class extends Oe{constructor(t){super(4,t)}decode(t,e=0){return _e(t).readFloatLE(e)}encode(t,e,r=0){return _e(e).writeFloatLE(t,r),4}};et.Float=Xx;let t2=class extends Oe{constructor(t){super(4,t)}decode(t,e=0){return _e(t).readFloatBE(e)}encode(t,e,r=0){return _e(e).writeFloatBE(t,r),4}};et.FloatBE=t2;let e2=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){return _e(t).readDoubleLE(e)}encode(t,e,r=0){return _e(e).writeDoubleLE(t,r),8}};et.Double=e2;let n2=class extends Oe{constructor(t){super(8,t)}decode(t,e=0){return _e(t).readDoubleBE(e)}encode(t,e,r=0){return _e(e).writeDoubleBE(t,r),8}};et.DoubleBE=n2;let r2=class extends Oe{constructor(t,e,r){if(!(t instanceof Oe))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Ir&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(e instanceof Ir)&&0<t.span&&(i=e*t.span),super(i,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,i=this.count;if(i instanceof Ir&&(i=i.decode(t,e)),0<this.elementLayout.span)r=i*this.elementLayout.span;else{let s=0;for(;s<i;)r+=this.elementLayout.getSpan(t,e+r),++s}return r}decode(t,e=0){const r=[];let i=0,s=this.count;for(s instanceof Ir&&(s=s.decode(t,e));i<s;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),i+=1;return r}encode(t,e,r=0){const i=this.elementLayout,s=t.reduce((o,c)=>o+i.encode(c,e,r+o),0);return this.count instanceof Ir&&this.count.encode(t.length,e,r),s}};et.Sequence=r2;let i2=class extends Oe{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Oe,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e=0){Tl(t);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const i=r;let s=0,o=0;for(const c of this.fields){let u=c.span;if(o=0<u?u:0,c.property!==void 0){const f=t[c.property];f!==void 0&&(o=c.encode(f,e,r),0>u&&(u=c.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}};et.Structure=i2;let r1=class{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}};et.UnionDiscriminator=r1;let b0=class extends r1{constructor(t,e){if(!(t instanceof Ir&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}};et.UnionLayoutDiscriminator=b0;let i1=class extends Oe{constructor(t,e,r){let i;if(t instanceof si||t instanceof Ai)i=new b0(new n1(t));else if(t instanceof Ir&&t.isCount())i=new b0(t);else if(t instanceof r1)i=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Oe))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&(t instanceof si||t instanceof Ai)&&(s+=i.layout.span)),super(s,r),this.discriminator=i,this.usesPrefixDiscriminator=t instanceof si||t instanceof Ai,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(c){return o(c)},this.configGetSourceVariant=function(c){o=c.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const i=this.discriminator,s=i.decode(t,e),o=this.registry[s];if(o===void 0){const c=this.defaultLayout;let u=0;this.usesPrefixDiscriminator&&(u=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[c.property]=c.decode(t,e+u)}else r=o.decode(t,e);return r}encode(t,e,r=0){const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let c=0;return this.usesPrefixDiscriminator&&(c=s.layout.span),s.encode(t[s.property],e,r),c+o.encode(t[o.property],e,r+c)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new s2(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e=0){let r;return t instanceof Uint8Array?r=this.discriminator.decode(t,e):r=t,this.registry[r]}};et.Union=i1;let s2=class extends Oe{constructor(t,e,r,i){if(!(t instanceof i1))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Oe))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(t,e+r)),r+i}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};et.VariantLayout=s2;function Gc(n){return 0>n&&(n+=4294967296),n}let s1=class extends Oe{constructor(t,e,r){if(!(t instanceof si||t instanceof Ai))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&r===void 0&&(r=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let i=0;this._packedSetValue=function(s){return i=Gc(s),this},this._packedGetValue=function(){return i}}decode(t,e=0){const r=this.makeDestinationObject(),i=this.word.decode(t,e);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(r[s.property]=s.decode(t));return r}encode(t,e,r=0){const i=this.word.decode(e,r);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=t[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new o1(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new o2(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}};et.BitStructure=s1;let o1=class{constructor(t,e,r){if(!(t instanceof s1))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const i=8*t.span,s=t.fields.reduce((o,c)=>o+c.bits,0);if(e+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-e),this.wordMask=Gc(this.valueMask<<this.start),this.property=r}decode(t,e){const r=this.container._packedGetValue();return Gc(r&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==Gc(t&this.valueMask))throw new TypeError(e1("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=Gc(t<<this.start);this.container._packedSetValue(Gc(e&~this.wordMask)|r)}};et.BitField=o1;let o2=class extends o1{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){typeof t=="boolean"&&(t=+t),super.encode(t)}};et.Boolean=o2;let a2=class extends Oe{constructor(t,e){if(!(t instanceof Ir&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Ir||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),_e(t).slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof Ir&&(i=t.length),!(t instanceof Uint8Array&&i===t.length))throw new TypeError(e1("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(r+i>e.length)throw new RangeError("encoding overruns Uint8Array");const s=_e(t);return _e(e).write(s.toString("hex"),r,i,"hex"),this.length instanceof Ir&&this.length.encode(i,e,r),i}};et.Blob=a2;let c2=class extends Oe{constructor(t){super(-1,t)}getSpan(t,e=0){Tl(t);let r=e;for(;r<t.length&&t[r]!==0;)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return _e(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const i=t1.Buffer.from(t,"utf8"),s=i.length;if(r+s>e.length)throw new RangeError("encoding overruns Buffer");const o=_e(e);return i.copy(o,r),o[r+s]=0,s+1}};et.CString=c2;let u2=class extends Oe{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return Tl(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return _e(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const i=t1.Buffer.from(t,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(_e(e),r),s}};et.UTF8=u2;let l2=class extends Oe{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}};et.Constant=l2;et.greedy=(n,t)=>new Zx(n,t);var $o=et.offset=(n,t,e)=>new n1(n,t,e),ge=et.u8=n=>new si(1,n),ni=et.u16=n=>new si(2,n);et.u24=n=>new si(3,n);var Tt=et.u32=n=>new si(4,n);et.u40=n=>new si(5,n);et.u48=n=>new si(6,n);var zn=et.nu64=n=>new qx(n);et.u16be=n=>new Ai(2,n);et.u24be=n=>new Ai(3,n);et.u32be=n=>new Ai(4,n);et.u40be=n=>new Ai(5,n);et.u48be=n=>new Ai(6,n);et.nu64be=n=>new Qx(n);et.s8=n=>new _c(1,n);et.s16=n=>new _c(2,n);et.s24=n=>new _c(3,n);et.s32=n=>new _c(4,n);et.s40=n=>new _c(5,n);et.s48=n=>new _c(6,n);var Hr=et.ns64=n=>new Jx(n);et.s16be=n=>new Ol(2,n);et.s24be=n=>new Ol(3,n);et.s32be=n=>new Ol(4,n);et.s40be=n=>new Ol(5,n);et.s48be=n=>new Ol(6,n);et.ns64be=n=>new Yx(n);et.f32=n=>new Xx(n);et.f32be=n=>new t2(n);et.f64=n=>new e2(n);et.f64be=n=>new n2(n);var Ot=et.struct=(n,t,e)=>new i2(n,t,e);et.bits=(n,t,e)=>new s1(n,t,e);var qn=et.seq=(n,t,e)=>new r2(n,t,e);et.union=(n,t,e)=>new i1(n,t,e);et.unionLayoutDiscriminator=(n,t)=>new b0(n,t);var Ge=et.blob=(n,t)=>new a2(n,t);et.cstr=n=>new c2(n);et.utf8=(n,t)=>new u2(n,t);et.constant=(n,t)=>new l2(n,t);var Hh={};Object.defineProperty(Hh,"__esModule",{value:!0});function ED(n){{const t=Zt.from(n);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var vD=Hh.toBigIntLE=ED;function xD(n){{const t=n.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}Hh.toBigIntBE=xD;function RD(n,t){{const e=n.toString(16),r=Zt.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return r.reverse(),r}}var f2=Hh.toBufferLE=RD;function SD(n,t){{const e=n.toString(16);return Zt.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}Hh.toBufferBE=SD;let ID=class extends TypeError{constructor(t,e){let r;const{message:i,explanation:s,...o}=t,{path:c}=t,u=c.length===0?i:`At path: ${c.join(".")} -- ${i}`;super(s??u),s!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}};function kD(n){return zh(n)&&typeof n[Symbol.iterator]=="function"}function zh(n){return typeof n=="object"&&n!=null}function _0(n){return zh(n)&&!Array.isArray(n)}function vi(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function TD(n){const{done:t,value:e}=n.next();return t?void 0:e}function OD(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:i,branch:s}=t,{type:o}=e,{refinement:c,message:u=`Expected a value of type \`${o}\`${c?` with refinement \`${c}\``:""}, but received: \`${vi(r)}\``}=n;return{value:r,type:o,refinement:c,key:i[i.length-1],path:i,branch:s,...n,message:u}}function*oA(n,t,e,r){kD(n)||(n=[n]);for(const i of n){const s=OD(i,t,e,r);s&&(yield s)}}function*a1(n,t,e={}){const{path:r=[],branch:i=[n],coerce:s=!1,mask:o=!1}=e,c={path:r,branch:i,mask:o};s&&(n=t.coercer(n,c));let u="valid";for(const f of t.validator(n,c))f.explanation=e.message,u="not_valid",yield[f,void 0];for(let[f,h,y]of t.entries(n,c)){const A=a1(h,y,{path:f===void 0?r:[...r,f],branch:f===void 0?i:[...i,h],coerce:s,mask:o,message:e.message});for(const b of A)b[0]?(u=b[0].refinement!=null?"not_refined":"not_valid",yield[b[0],void 0]):s&&(h=b[1],f===void 0?n=h:n instanceof Map?n.set(f,h):n instanceof Set?n.add(h):zh(n)&&(h!==void 0||f in n)&&(n[f]=h))}if(u!=="not_valid")for(const f of t.refiner(n,c))f.explanation=e.message,u="not_refined",yield[f,void 0];u==="valid"&&(yield[void 0,n])}let cs=class{constructor(t){const{type:e,schema:r,validator:i,refiner:s,coercer:o=u=>u,entries:c=function*(){}}=t;this.type=e,this.schema=r,this.entries=c,this.coercer=o,i?this.validator=(u,f)=>{const h=i(u,f);return oA(h,f,this,u)}:this.validator=()=>[],s?this.refiner=(u,f)=>{const h=s(u,f);return oA(h,f,this,u)}:this.refiner=()=>[]}assert(t,e){return h2(t,this,e)}create(t,e){return wt(t,this,e)}is(t){return d2(t,this)}mask(t,e){return ND(t,this,e)}validate(t,e={}){return Gh(t,this,e)}};function h2(n,t,e){const r=Gh(n,t,{message:e});if(r[0])throw r[0]}function wt(n,t,e){const r=Gh(n,t,{coerce:!0,message:e});if(r[0])throw r[0];return r[1]}function ND(n,t,e){const r=Gh(n,t,{coerce:!0,mask:!0,message:e});if(r[0])throw r[0];return r[1]}function d2(n,t){return!Gh(n,t)[0]}function Gh(n,t,e={}){const r=a1(n,t,e),i=TD(r);return i[0]?[new ID(i[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function Ac(n,t){return new cs({type:n,schema:null,validator:t})}function CD(){return Ac("any",()=>!0)}function Et(n){return new cs({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[e,r]of t.entries())yield[e,r,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${vi(t)}`}})}function ss(){return Ac("boolean",n=>typeof n=="boolean")}function c1(n){return Ac("instance",t=>t instanceof n||`Expected a \`${n.name}\` instance, but received: ${vi(t)}`)}function en(n){const t=vi(n),e=typeof n;return new cs({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${t}\`, but received: ${vi(r)}`}})}function BD(){return Ac("never",()=>!1)}function vt(n){return new cs({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function X(){return Ac("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${vi(n)}`)}function Dt(n){return new cs({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function p2(n,t){return new cs({type:"record",schema:null,*entries(e){if(zh(e))for(const r in e){const i=e[r];yield[r,r,n],yield[r,i,t]}},validator(e){return _0(e)||`Expected an object, but received: ${vi(e)}`},coercer(e){return _0(e)?{...e}:e}})}function yt(){return Ac("string",n=>typeof n=="string"||`Expected a string, but received: ${vi(n)}`)}function u1(n){const t=BD();return new cs({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const r=Math.max(n.length,e.length);for(let i=0;i<r;i++)yield[i,e[i],n[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${vi(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function dt(n){const t=Object.keys(n);return new cs({type:"type",schema:n,*entries(e){if(zh(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return _0(e)||`Expected an object, but received: ${vi(e)}`},coercer(e){return _0(e)?{...e}:e}})}function br(n){const t=n.map(e=>e.type).join(" | ");return new cs({type:"union",schema:null,coercer(e,r){for(const i of n){const[s,o]=i.validate(e,{coerce:!0,mask:r.mask});if(!s)return o}return e},validator(e,r){const i=[];for(const s of n){const[...o]=a1(e,s,r),[c]=o;if(c[0])for(const[u]of o)u&&i.push(u);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${vi(e)}`,...i]}})}function Nl(){return Ac("unknown",()=>!0)}function Vh(n,t,e){return new cs({...n,coercer:(r,i)=>d2(r,t)?n.coercer(e(r,i),i):n.coercer(r,i)})}var Rd,PD=new Uint8Array(16);function g2(){if(!Rd&&(Rd=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Rd))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Rd(PD)}const MD=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function dp(n){return typeof n=="string"&&MD.test(n)}var Hn=[];for(var Iy=0;Iy<256;++Iy)Hn.push((Iy+256).toString(16).substr(1));function pp(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(Hn[n[t+0]]+Hn[n[t+1]]+Hn[n[t+2]]+Hn[n[t+3]]+"-"+Hn[n[t+4]]+Hn[n[t+5]]+"-"+Hn[n[t+6]]+Hn[n[t+7]]+"-"+Hn[n[t+8]]+Hn[n[t+9]]+"-"+Hn[n[t+10]]+Hn[n[t+11]]+Hn[n[t+12]]+Hn[n[t+13]]+Hn[n[t+14]]+Hn[n[t+15]]).toLowerCase();if(!dp(e))throw TypeError("Stringified UUID is invalid");return e}var aA,ky,Ty=0,Oy=0;function LD(n,t,e){var r=t&&e||0,i=t||new Array(16);n=n||{};var s=n.node||aA,o=n.clockseq!==void 0?n.clockseq:ky;if(s==null||o==null){var c=n.random||(n.rng||g2)();s==null&&(s=aA=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),o==null&&(o=ky=(c[6]<<8|c[7])&16383)}var u=n.msecs!==void 0?n.msecs:Date.now(),f=n.nsecs!==void 0?n.nsecs:Oy+1,h=u-Ty+(f-Oy)/1e4;if(h<0&&n.clockseq===void 0&&(o=o+1&16383),(h<0||u>Ty)&&n.nsecs===void 0&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ty=u,Oy=f,ky=o,u+=122192928e5;var y=((u&268435455)*1e4+f)%4294967296;i[r++]=y>>>24&255,i[r++]=y>>>16&255,i[r++]=y>>>8&255,i[r++]=y&255;var A=u/4294967296*1e4&268435455;i[r++]=A>>>8&255,i[r++]=A&255,i[r++]=A>>>24&15|16,i[r++]=A>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var b=0;b<6;++b)i[r+b]=s[b];return t||pp(i)}function y2(n){if(!dp(n))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(n.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(n.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(n.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(n.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(n.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function UD(n){n=unescape(encodeURIComponent(n));for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var DD="6ba7b810-9dad-11d1-80b4-00c04fd430c8",FD="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function m2(n,t,e){function r(i,s,o,c){if(typeof i=="string"&&(i=UD(i)),typeof s=="string"&&(s=y2(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+i.length);if(u.set(s),u.set(i,s.length),u=e(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,o){c=c||0;for(var f=0;f<16;++f)o[c+f]=u[f];return o}return pp(u)}try{r.name=n}catch{}return r.DNS=DD,r.URL=FD,r}function $D(n){if(typeof n=="string"){var t=unescape(encodeURIComponent(n));n=new Uint8Array(t.length);for(var e=0;e<t.length;++e)n[e]=t.charCodeAt(e)}return HD(zD(GD(n),n.length*8))}function HD(n){for(var t=[],e=n.length*32,r="0123456789abcdef",i=0;i<e;i+=8){var s=n[i>>5]>>>i%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);t.push(o)}return t}function w2(n){return(n+64>>>9<<4)+14+1}function zD(n,t){n[t>>5]|=128<<t%32,n[w2(t)-1]=t;for(var e=1732584193,r=-271733879,i=-1732584194,s=271733878,o=0;o<n.length;o+=16){var c=e,u=r,f=i,h=s;e=Xn(e,r,i,s,n[o],7,-680876936),s=Xn(s,e,r,i,n[o+1],12,-389564586),i=Xn(i,s,e,r,n[o+2],17,606105819),r=Xn(r,i,s,e,n[o+3],22,-1044525330),e=Xn(e,r,i,s,n[o+4],7,-176418897),s=Xn(s,e,r,i,n[o+5],12,1200080426),i=Xn(i,s,e,r,n[o+6],17,-1473231341),r=Xn(r,i,s,e,n[o+7],22,-45705983),e=Xn(e,r,i,s,n[o+8],7,1770035416),s=Xn(s,e,r,i,n[o+9],12,-1958414417),i=Xn(i,s,e,r,n[o+10],17,-42063),r=Xn(r,i,s,e,n[o+11],22,-1990404162),e=Xn(e,r,i,s,n[o+12],7,1804603682),s=Xn(s,e,r,i,n[o+13],12,-40341101),i=Xn(i,s,e,r,n[o+14],17,-1502002290),r=Xn(r,i,s,e,n[o+15],22,1236535329),e=tr(e,r,i,s,n[o+1],5,-165796510),s=tr(s,e,r,i,n[o+6],9,-1069501632),i=tr(i,s,e,r,n[o+11],14,643717713),r=tr(r,i,s,e,n[o],20,-373897302),e=tr(e,r,i,s,n[o+5],5,-701558691),s=tr(s,e,r,i,n[o+10],9,38016083),i=tr(i,s,e,r,n[o+15],14,-660478335),r=tr(r,i,s,e,n[o+4],20,-405537848),e=tr(e,r,i,s,n[o+9],5,568446438),s=tr(s,e,r,i,n[o+14],9,-1019803690),i=tr(i,s,e,r,n[o+3],14,-187363961),r=tr(r,i,s,e,n[o+8],20,1163531501),e=tr(e,r,i,s,n[o+13],5,-1444681467),s=tr(s,e,r,i,n[o+2],9,-51403784),i=tr(i,s,e,r,n[o+7],14,1735328473),r=tr(r,i,s,e,n[o+12],20,-1926607734),e=er(e,r,i,s,n[o+5],4,-378558),s=er(s,e,r,i,n[o+8],11,-2022574463),i=er(i,s,e,r,n[o+11],16,1839030562),r=er(r,i,s,e,n[o+14],23,-35309556),e=er(e,r,i,s,n[o+1],4,-1530992060),s=er(s,e,r,i,n[o+4],11,1272893353),i=er(i,s,e,r,n[o+7],16,-155497632),r=er(r,i,s,e,n[o+10],23,-1094730640),e=er(e,r,i,s,n[o+13],4,681279174),s=er(s,e,r,i,n[o],11,-358537222),i=er(i,s,e,r,n[o+3],16,-722521979),r=er(r,i,s,e,n[o+6],23,76029189),e=er(e,r,i,s,n[o+9],4,-640364487),s=er(s,e,r,i,n[o+12],11,-421815835),i=er(i,s,e,r,n[o+15],16,530742520),r=er(r,i,s,e,n[o+2],23,-995338651),e=nr(e,r,i,s,n[o],6,-198630844),s=nr(s,e,r,i,n[o+7],10,1126891415),i=nr(i,s,e,r,n[o+14],15,-1416354905),r=nr(r,i,s,e,n[o+5],21,-57434055),e=nr(e,r,i,s,n[o+12],6,1700485571),s=nr(s,e,r,i,n[o+3],10,-1894986606),i=nr(i,s,e,r,n[o+10],15,-1051523),r=nr(r,i,s,e,n[o+1],21,-2054922799),e=nr(e,r,i,s,n[o+8],6,1873313359),s=nr(s,e,r,i,n[o+15],10,-30611744),i=nr(i,s,e,r,n[o+6],15,-1560198380),r=nr(r,i,s,e,n[o+13],21,1309151649),e=nr(e,r,i,s,n[o+4],6,-145523070),s=nr(s,e,r,i,n[o+11],10,-1120210379),i=nr(i,s,e,r,n[o+2],15,718787259),r=nr(r,i,s,e,n[o+9],21,-343485551),e=Do(e,c),r=Do(r,u),i=Do(i,f),s=Do(s,h)}return[e,r,i,s]}function GD(n){if(n.length===0)return[];for(var t=n.length*8,e=new Uint32Array(w2(t)),r=0;r<t;r+=8)e[r>>5]|=(n[r/8]&255)<<r%32;return e}function Do(n,t){var e=(n&65535)+(t&65535),r=(n>>16)+(t>>16)+(e>>16);return r<<16|e&65535}function VD(n,t){return n<<t|n>>>32-t}function gp(n,t,e,r,i,s){return Do(VD(Do(Do(t,n),Do(r,s)),i),e)}function Xn(n,t,e,r,i,s,o){return gp(t&e|~t&r,n,t,i,s,o)}function tr(n,t,e,r,i,s,o){return gp(t&r|e&~r,n,t,i,s,o)}function er(n,t,e,r,i,s,o){return gp(t^e^r,n,t,i,s,o)}function nr(n,t,e,r,i,s,o){return gp(e^(t|~r),n,t,i,s,o)}var KD=m2("v3",48,$D);function jD(n,t,e){n=n||{};var r=n.random||(n.rng||g2)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){e=e||0;for(var i=0;i<16;++i)t[e+i]=r[i];return t}return pp(r)}function WD(n,t,e,r){switch(n){case 0:return t&e^~t&r;case 1:return t^e^r;case 2:return t&e^t&r^e&r;case 3:return t^e^r}}function Ny(n,t){return n<<t|n>>>32-t}function ZD(n){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var r=unescape(encodeURIComponent(n));n=[];for(var i=0;i<r.length;++i)n.push(r.charCodeAt(i))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var s=n.length/4+2,o=Math.ceil(s/16),c=new Array(o),u=0;u<o;++u){for(var f=new Uint32Array(16),h=0;h<16;++h)f[h]=n[u*64+h*4]<<24|n[u*64+h*4+1]<<16|n[u*64+h*4+2]<<8|n[u*64+h*4+3];c[u]=f}c[o-1][14]=(n.length-1)*8/Math.pow(2,32),c[o-1][14]=Math.floor(c[o-1][14]),c[o-1][15]=(n.length-1)*8&4294967295;for(var y=0;y<o;++y){for(var A=new Uint32Array(80),b=0;b<16;++b)A[b]=c[y][b];for(var R=16;R<80;++R)A[R]=Ny(A[R-3]^A[R-8]^A[R-14]^A[R-16],1);for(var k=e[0],S=e[1],B=e[2],H=e[3],U=e[4],G=0;G<80;++G){var W=Math.floor(G/20),Y=Ny(k,5)+WD(W,S,B,H)+U+t[W]+A[G]>>>0;U=H,H=B,B=Ny(S,30)>>>0,S=k,k=Y}e[0]=e[0]+k>>>0,e[1]=e[1]+S>>>0,e[2]=e[2]+B>>>0,e[3]=e[3]+H>>>0,e[4]=e[4]+U>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var qD=m2("v5",80,ZD);const QD="00000000-0000-0000-0000-000000000000";function JD(n){if(!dp(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const YD=Object.freeze(Object.defineProperty({__proto__:null,NIL:QD,parse:y2,stringify:pp,v1:LD,v3:KD,v4:jD,v5:qD,validate:dp,version:JD},Symbol.toStringTag,{value:"Module"})),b2=q0(YD),XD=b2.v4,t9=function(n,t,e,r){if(typeof n!="string")throw new TypeError(n+" must be a string");r=r||{};const i=typeof r.version=="number"?r.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const s={method:n};if(i===2&&(s.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");s.params=t}if(typeof e>"u"){const o=typeof r.generator=="function"?r.generator:function(){return XD()};s.id=o(s,r)}else i===2&&e===null?r.notificationIdNull&&(s.id=null):s.id=e;return s};var e9=t9;const n9=b2.v4,r9=e9,eh=function(n,t){if(!(this instanceof eh))return new eh(n,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return n9()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=n};var i9=eh;eh.prototype.request=function(n,t,e,r){const i=this;let s=null;const o=Array.isArray(n)&&typeof t=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&n&&typeof n=="object"&&typeof t=="function")r=t,s=n;else{typeof e=="function"&&(r=e,e=void 0);const f=typeof r=="function";try{s=r9(n,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(h){if(f)return r(h);throw h}if(!f)return s}let u;try{u=JSON.stringify(s,this.options.replacer)}catch(f){return r(f)}return this.callServer(u,function(f,h){i._parseResponse(f,h,r)}),s};eh.prototype._parseResponse=function(n,t,e){if(n){e(n);return}if(!t)return e();let r;try{r=JSON.parse(t,this.options.reviver)}catch(i){return e(i)}if(e.length===3)if(Array.isArray(r)){const i=function(o){return typeof o.error<"u"},s=function(o){return!i(o)};return e(null,r.filter(i),r.filter(s))}else return e(null,r.error,r.result);e(null,r)};const s9=ea(i9);var _2={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function i(u,f,h){this.fn=u,this.context=f,this.once=h||!1}function s(u,f,h,y,A){if(typeof h!="function")throw new TypeError("The listener must be a function");var b=new i(h,y||u,A),R=e?e+f:f;return u._events[R]?u._events[R].fn?u._events[R]=[u._events[R],b]:u._events[R].push(b):(u._events[R]=b,u._eventsCount++),u}function o(u,f){--u._eventsCount===0?u._events=new r:delete u._events[f]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var f=[],h,y;if(this._eventsCount===0)return f;for(y in h=this._events)t.call(h,y)&&f.push(e?y.slice(1):y);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},c.prototype.listeners=function(f){var h=e?e+f:f,y=this._events[h];if(!y)return[];if(y.fn)return[y.fn];for(var A=0,b=y.length,R=new Array(b);A<b;A++)R[A]=y[A].fn;return R},c.prototype.listenerCount=function(f){var h=e?e+f:f,y=this._events[h];return y?y.fn?1:y.length:0},c.prototype.emit=function(f,h,y,A,b,R){var k=e?e+f:f;if(!this._events[k])return!1;var S=this._events[k],B=arguments.length,H,U;if(S.fn){switch(S.once&&this.removeListener(f,S.fn,void 0,!0),B){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,h),!0;case 3:return S.fn.call(S.context,h,y),!0;case 4:return S.fn.call(S.context,h,y,A),!0;case 5:return S.fn.call(S.context,h,y,A,b),!0;case 6:return S.fn.call(S.context,h,y,A,b,R),!0}for(U=1,H=new Array(B-1);U<B;U++)H[U-1]=arguments[U];S.fn.apply(S.context,H)}else{var G=S.length,W;for(U=0;U<G;U++)switch(S[U].once&&this.removeListener(f,S[U].fn,void 0,!0),B){case 1:S[U].fn.call(S[U].context);break;case 2:S[U].fn.call(S[U].context,h);break;case 3:S[U].fn.call(S[U].context,h,y);break;case 4:S[U].fn.call(S[U].context,h,y,A);break;default:if(!H)for(W=1,H=new Array(B-1);W<B;W++)H[W-1]=arguments[W];S[U].fn.apply(S[U].context,H)}}return!0},c.prototype.on=function(f,h,y){return s(this,f,h,y,!1)},c.prototype.once=function(f,h,y){return s(this,f,h,y,!0)},c.prototype.removeListener=function(f,h,y,A){var b=e?e+f:f;if(!this._events[b])return this;if(!h)return o(this,b),this;var R=this._events[b];if(R.fn)R.fn===h&&(!A||R.once)&&(!y||R.context===y)&&o(this,b);else{for(var k=0,S=[],B=R.length;k<B;k++)(R[k].fn!==h||A&&!R[k].once||y&&R[k].context!==y)&&S.push(R[k]);S.length?this._events[b]=S.length===1?S[0]:S:o(this,b)}return this},c.prototype.removeAllListeners=function(f){var h;return f?(h=e?e+f:f,this._events[h]&&o(this,h)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=e,c.EventEmitter=c,n.exports=c})(_2);var o9=_2.exports;const A2=ea(o9);var a9=class extends A2{constructor(t,e,r){super();Z(this,"socket");this.socket=new window.WebSocket(t,r),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=i=>this.emit("message",i.data),this.socket.onerror=i=>this.emit("error",i),this.socket.onclose=i=>{this.emit("close",i.code,i.reason)}}send(t,e,r){const i=r||e;try{this.socket.send(t),i()}catch(s){i(s)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,r){this.socket.addEventListener(t,e,r)}};function c9(n,t){return new a9(n,t)}var u9=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},l9=class extends A2{constructor(t,e="ws://localhost:8080",{autoconnect:r=!0,reconnect:i=!0,reconnect_interval:s=1e3,max_reconnects:o=5,...c}={},u,f){super();Z(this,"address");Z(this,"rpc_id");Z(this,"queue");Z(this,"options");Z(this,"autoconnect");Z(this,"ready");Z(this,"reconnect");Z(this,"reconnect_timer_id");Z(this,"reconnect_interval");Z(this,"max_reconnects");Z(this,"rest_options");Z(this,"current_reconnects");Z(this,"generate_request_id");Z(this,"socket");Z(this,"webSocketFactory");Z(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=r,this.ready=!1,this.reconnect=i,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=o,this.rest_options=c,this.current_reconnects=0,this.generate_request_id=u||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),f?this.dataPack=f:this.dataPack=new u9,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(t,e,r,i){return!i&&typeof r=="object"&&(i=r,r=null),new Promise((s,o)=>{if(!this.ready)return o(new Error("socket not ready"));const c=this.generate_request_id(t,e),u={jsonrpc:"2.0",method:t,params:e||void 0,id:c};this.socket.send(this.dataPack.encode(u),i,f=>{if(f)return o(f);this.queue[c]={promise:[s,o]},r&&(this.queue[c].timeout=setTimeout(()=>{delete this.queue[c],o(new Error("reply timeout"))},r))})})}async login(t){const e=await this.call("rpc.login",t);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(t,e){return new Promise((r,i)=>{if(!this.ready)return i(new Error("socket not ready"));const s={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(s),o=>{if(o)return i(o);r()})})}async subscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.on",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed subscribing to an event '"+t+"' with: "+e[t]);return e}async unsubscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.off",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(t,e){this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}_connect(t,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:r})=>{r instanceof ArrayBuffer&&(r=It.from(r).toString());try{r=this.dataPack.decode(r)}catch{return}if(r.notification&&this.listeners(r.notification).length){if(!Object.keys(r.params).length)return this.emit(r.notification);const i=[r.notification];if(r.params.constructor===Object)i.push(r.params);else for(let s=0;s<r.params.length;s++)i.push(r.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,i)})}if(!this.queue[r.id])return r.method?Promise.resolve().then(()=>{this.emit(r.method,r==null?void 0:r.params)}):void 0;"error"in r=="result"in r&&this.queue[r.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[r.id].timeout&&clearTimeout(this.queue[r.id].timeout),r.error?this.queue[r.id].promise[1](r.error):this.queue[r.id].promise[0](r.result),delete this.queue[r.id]}),this.socket.addEventListener("error",r=>this.emit("error",r)),this.socket.addEventListener("close",({code:r,reason:i})=>{this.ready&&setTimeout(()=>this.emit("close",r,i),0),this.ready=!1,this.socket=void 0,r!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(t,e),this.reconnect_interval)))})}};const E2=[],v2=[],x2=[],f9=BigInt(0),gf=BigInt(1),h9=BigInt(2),d9=BigInt(7),p9=BigInt(256),g9=BigInt(113);for(let n=0,t=gf,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],E2.push(2*(5*r+e)),v2.push((n+1)*(n+2)/2%64);let i=f9;for(let s=0;s<7;s++)t=(t<<gf^(t>>d9)*g9)%p9,t&h9&&(i^=gf<<(gf<<BigInt(s))-gf);x2.push(i)}const[y9,m9]=Rx(x2,!0),cA=(n,t,e)=>e>32?kx(n,t,e):Sx(n,t,e),uA=(n,t,e)=>e>32?Tx(n,t,e):Ix(n,t,e);function w9(n,t=24){const e=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)e[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const c=(o+8)%10,u=(o+2)%10,f=e[u],h=e[u+1],y=cA(f,h,1)^e[c],A=uA(f,h,1)^e[c+1];for(let b=0;b<50;b+=10)n[o+b]^=y,n[o+b+1]^=A}let i=n[2],s=n[3];for(let o=0;o<24;o++){const c=v2[o],u=cA(i,s,c),f=uA(i,s,c),h=E2[o];i=n[h],s=n[h+1],n[h]=u,n[h+1]=f}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)e[c]=n[o+c];for(let c=0;c<10;c++)n[o+c]^=~e[(c+2)%10]&e[(c+4)%10]}n[0]^=y9[r],n[1]^=m9[r]}e.fill(0)}let b9=class R2 extends jw{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,p0(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=VL(this.state)}keccak(){J_||Y_(this.state32),w9(this.state32,this.rounds),J_||Y_(this.state32),this.posOut=0,this.pos=0}update(t){rl(this);const{blockLen:e,state:r}=this;t=sp(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(e-this.pos,i-s);for(let c=0;c<o;c++)r[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:i}=this;t[r]^=e,e&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){rl(this,!1),Fh(t),this.finish();const e=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(e.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return p0(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ax(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new R2(e,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}};const _9=(n,t,e)=>Ww(()=>new b9(t,n,e)),lA=_9(1,136,256/8);let S2=class extends jw{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,GL(t);const r=sp(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=t.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(t){return rl(this),this.iHash.update(t),this}digestInto(t){rl(this),Fh(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:i,destroyed:s,blockLen:o,outputLen:c}=this;return t=t,t.finished=i,t.destroyed=s,t.blockLen=o,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const I2=(n,t,e)=>new S2(n,t).update(e).digest();I2.create=(n,t)=>new S2(n,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function fA(n){n.lowS!==void 0&&Gs("lowS",n.lowS),n.prehash!==void 0&&Gs("prehash",n.prehash)}function A9(n){const t=Qw(n);Il(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:i}=t;if(e){if(!r.eql(i,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:E9,hexToBytes:v9}=SU;class x9 extends Error{constructor(t=""){super(t)}}const _s={Err:x9,_tlv:{encode:(n,t)=>{const{Err:e}=_s;if(n<0||n>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");const r=t.length/2,i=qc(r);if(i.length/2&128)throw new e("tlv.encode: long form length too big");const s=r>127?qc(i.length/2|128):"";return qc(n)+s+i+t},decode(n,t){const{Err:e}=_s;let r=0;if(n<0||n>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[r++]!==n)throw new e("tlv.decode: wrong tlv");const i=t[r++],s=!!(i&128);let o=0;if(!s)o=i;else{const u=i&127;if(!u)throw new e("tlv.decode(long): indefinite length not supported");if(u>4)throw new e("tlv.decode(long): byte length is too big");const f=t.subarray(r,r+u);if(f.length!==u)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(const h of f)o=o<<8|h;if(r+=u,o<128)throw new e("tlv.decode(long): not minimal encoding")}const c=t.subarray(r,r+o);if(c.length!==o)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+o)}}},_int:{encode(n){const{Err:t}=_s;if(n<Ds)throw new t("integer: negative integers are not allowed");let e=qc(n);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(n){const{Err:t}=_s;if(n[0]&128)throw new t("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return E9(n)}},toSig(n){const{Err:t,_int:e,_tlv:r}=_s,i=typeof n=="string"?v9(n):n;$h(i);const{v:s,l:o}=r.decode(48,i);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:u}=r.decode(2,s),{v:f,l:h}=r.decode(2,u);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(f)}},hexFromSig(n){const{_tlv:t,_int:e}=_s,r=t.encode(2,e.encode(n.r)),i=t.encode(2,e.encode(n.s)),s=r+i;return t.encode(48,s)}},Ds=BigInt(0),Pn=BigInt(1);BigInt(2);const hA=BigInt(3);BigInt(4);function R9(n){const t=A9(n),{Fp:e}=t,r=up(t.n,t.nBitLength),i=t.toBytes||((k,S,B)=>{const H=S.toAffine();return cc(Uint8Array.from([4]),e.toBytes(H.x),e.toBytes(H.y))}),s=t.fromBytes||(k=>{const S=k.subarray(1),B=e.fromBytes(S.subarray(0,e.BYTES)),H=e.fromBytes(S.subarray(e.BYTES,2*e.BYTES));return{x:B,y:H}});function o(k){const{a:S,b:B}=t,H=e.sqr(k),U=e.mul(H,k);return e.add(e.add(U,e.mul(k,S)),B)}if(!e.eql(e.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function c(k){return cp(k,Pn,t.n)}function u(k){const{allowedPrivateKeyLengths:S,nByteLength:B,wrapPrivateKey:H,n:U}=t;if(S&&typeof k!="bigint"){if(oc(k)&&(k=ac(k)),typeof k!="string"||!S.includes(k.length))throw new Error("invalid private key");k=k.padStart(B*2,"0")}let G;try{G=typeof k=="bigint"?k:Xa(Sn("private key",k,B))}catch{throw new Error("invalid private key, expected hex or "+B+" bytes, got "+typeof k)}return H&&(G=qe(G,U)),ri("private key",G,Pn,U),G}function f(k){if(!(k instanceof A))throw new Error("ProjectivePoint expected")}const h=th((k,S)=>{const{px:B,py:H,pz:U}=k;if(e.eql(U,e.ONE))return{x:B,y:H};const G=k.is0();S==null&&(S=G?e.ONE:e.inv(U));const W=e.mul(B,S),Y=e.mul(H,S),j=e.mul(U,S);if(G)return{x:e.ZERO,y:e.ZERO};if(!e.eql(j,e.ONE))throw new Error("invZ was invalid");return{x:W,y:Y}}),y=th(k=>{if(k.is0()){if(t.allowInfinityPoint&&!e.is0(k.py))return;throw new Error("bad point: ZERO")}const{x:S,y:B}=k.toAffine();if(!e.isValid(S)||!e.isValid(B))throw new Error("bad point: x or y not FE");const H=e.sqr(B),U=o(S);if(!e.eql(H,U))throw new Error("bad point: equation left != right");if(!k.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class A{constructor(S,B,H){if(this.px=S,this.py=B,this.pz=H,S==null||!e.isValid(S))throw new Error("x required");if(B==null||!e.isValid(B))throw new Error("y required");if(H==null||!e.isValid(H))throw new Error("z required");Object.freeze(this)}static fromAffine(S){const{x:B,y:H}=S||{};if(!S||!e.isValid(B)||!e.isValid(H))throw new Error("invalid affine point");if(S instanceof A)throw new Error("projective point not allowed");const U=G=>e.eql(G,e.ZERO);return U(B)&&U(H)?A.ZERO:new A(B,H,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(S){const B=e.invertBatch(S.map(H=>H.pz));return S.map((H,U)=>H.toAffine(B[U])).map(A.fromAffine)}static fromHex(S){const B=A.fromAffine(s(Sn("pointHex",S)));return B.assertValidity(),B}static fromPrivateKey(S){return A.BASE.multiply(u(S))}static msm(S,B){return Dx(A,r,S,B)}_setWindowSize(S){R.setWindowSize(this,S)}assertValidity(){y(this)}hasEvenY(){const{y:S}=this.toAffine();if(e.isOdd)return!e.isOdd(S);throw new Error("Field doesn't support isOdd")}equals(S){f(S);const{px:B,py:H,pz:U}=this,{px:G,py:W,pz:Y}=S,j=e.eql(e.mul(B,Y),e.mul(G,U)),J=e.eql(e.mul(H,Y),e.mul(W,U));return j&&J}negate(){return new A(this.px,e.neg(this.py),this.pz)}double(){const{a:S,b:B}=t,H=e.mul(B,hA),{px:U,py:G,pz:W}=this;let Y=e.ZERO,j=e.ZERO,J=e.ZERO,it=e.mul(U,U),ut=e.mul(G,G),rt=e.mul(W,W),ot=e.mul(U,G);return ot=e.add(ot,ot),J=e.mul(U,W),J=e.add(J,J),Y=e.mul(S,J),j=e.mul(H,rt),j=e.add(Y,j),Y=e.sub(ut,j),j=e.add(ut,j),j=e.mul(Y,j),Y=e.mul(ot,Y),J=e.mul(H,J),rt=e.mul(S,rt),ot=e.sub(it,rt),ot=e.mul(S,ot),ot=e.add(ot,J),J=e.add(it,it),it=e.add(J,it),it=e.add(it,rt),it=e.mul(it,ot),j=e.add(j,it),rt=e.mul(G,W),rt=e.add(rt,rt),it=e.mul(rt,ot),Y=e.sub(Y,it),J=e.mul(rt,ut),J=e.add(J,J),J=e.add(J,J),new A(Y,j,J)}add(S){f(S);const{px:B,py:H,pz:U}=this,{px:G,py:W,pz:Y}=S;let j=e.ZERO,J=e.ZERO,it=e.ZERO;const ut=t.a,rt=e.mul(t.b,hA);let ot=e.mul(B,G),C=e.mul(H,W),p=e.mul(U,Y),m=e.add(B,H),v=e.add(G,W);m=e.mul(m,v),v=e.add(ot,C),m=e.sub(m,v),v=e.add(B,U);let I=e.add(G,Y);return v=e.mul(v,I),I=e.add(ot,p),v=e.sub(v,I),I=e.add(H,U),j=e.add(W,Y),I=e.mul(I,j),j=e.add(C,p),I=e.sub(I,j),it=e.mul(ut,v),j=e.mul(rt,p),it=e.add(j,it),j=e.sub(C,it),it=e.add(C,it),J=e.mul(j,it),C=e.add(ot,ot),C=e.add(C,ot),p=e.mul(ut,p),v=e.mul(rt,v),C=e.add(C,p),p=e.sub(ot,p),p=e.mul(ut,p),v=e.add(v,p),ot=e.mul(C,v),J=e.add(J,ot),ot=e.mul(I,v),j=e.mul(m,j),j=e.sub(j,ot),ot=e.mul(m,C),it=e.mul(I,it),it=e.add(it,ot),new A(j,J,it)}subtract(S){return this.add(S.negate())}is0(){return this.equals(A.ZERO)}wNAF(S){return R.wNAFCached(this,S,A.normalizeZ)}multiplyUnsafe(S){const{endo:B,n:H}=t;ri("scalar",S,Ds,H);const U=A.ZERO;if(S===Ds)return U;if(this.is0()||S===Pn)return this;if(!B||R.hasPrecomputes(this))return R.wNAFCachedUnsafe(this,S,A.normalizeZ);let{k1neg:G,k1:W,k2neg:Y,k2:j}=B.splitScalar(S),J=U,it=U,ut=this;for(;W>Ds||j>Ds;)W&Pn&&(J=J.add(ut)),j&Pn&&(it=it.add(ut)),ut=ut.double(),W>>=Pn,j>>=Pn;return G&&(J=J.negate()),Y&&(it=it.negate()),it=new A(e.mul(it.px,B.beta),it.py,it.pz),J.add(it)}multiply(S){const{endo:B,n:H}=t;ri("scalar",S,Pn,H);let U,G;if(B){const{k1neg:W,k1:Y,k2neg:j,k2:J}=B.splitScalar(S);let{p:it,f:ut}=this.wNAF(Y),{p:rt,f:ot}=this.wNAF(J);it=R.constTimeNegate(W,it),rt=R.constTimeNegate(j,rt),rt=new A(e.mul(rt.px,B.beta),rt.py,rt.pz),U=it.add(rt),G=ut.add(ot)}else{const{p:W,f:Y}=this.wNAF(S);U=W,G=Y}return A.normalizeZ([U,G])[0]}multiplyAndAddUnsafe(S,B,H){const U=A.BASE,G=(Y,j)=>j===Ds||j===Pn||!Y.equals(U)?Y.multiplyUnsafe(j):Y.multiply(j),W=G(this,B).add(G(S,H));return W.is0()?void 0:W}toAffine(S){return h(this,S)}isTorsionFree(){const{h:S,isTorsionFree:B}=t;if(S===Pn)return!0;if(B)return B(A,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:S,clearCofactor:B}=t;return S===Pn?this:B?B(A,this):this.multiplyUnsafe(t.h)}toRawBytes(S=!0){return Gs("isCompressed",S),this.assertValidity(),i(A,this,S)}toHex(S=!0){return Gs("isCompressed",S),ac(this.toRawBytes(S))}}A.BASE=new A(t.Gx,t.Gy,e.ONE),A.ZERO=new A(e.ZERO,e.ONE,e.ZERO);const b=t.nBitLength,R=Ux(A,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:A,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:c}}function S9(n){const t=Qw(n);return Il(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function I9(n){const t=S9(n),{Fp:e,n:r}=t,i=e.BYTES+1,s=2*e.BYTES+1;function o(p){return qe(p,r)}function c(p){return Nm(p,r)}const{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:h,isWithinCurveOrder:y}=R9({...t,toBytes(p,m,v){const I=m.toAffine(),N=e.toBytes(I.x),M=cc;return Gs("isCompressed",v),v?M(Uint8Array.from([m.hasEvenY()?2:3]),N):M(Uint8Array.from([4]),N,e.toBytes(I.y))},fromBytes(p){const m=p.length,v=p[0],I=p.subarray(1);if(m===i&&(v===2||v===3)){const N=Xa(I);if(!cp(N,Pn,e.ORDER))throw new Error("Point is not on curve");const M=h(N);let z;try{z=e.sqrt(M)}catch(F){const ct=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+ct)}const P=(z&Pn)===Pn;return(v&1)===1!==P&&(z=e.neg(z)),{x:N,y:z}}else if(m===s&&v===4){const N=e.fromBytes(I.subarray(0,e.BYTES)),M=e.fromBytes(I.subarray(e.BYTES,2*e.BYTES));return{x:N,y:M}}else{const N=i,M=s;throw new Error("invalid Point, expected length of "+N+", or uncompressed "+M+", got "+m)}}}),A=p=>ac(sl(p,t.nByteLength));function b(p){const m=r>>Pn;return p>m}function R(p){return b(p)?o(-p):p}const k=(p,m,v)=>Xa(p.slice(m,v));class S{constructor(m,v,I){this.r=m,this.s=v,this.recovery=I,this.assertValidity()}static fromCompact(m){const v=t.nByteLength;return m=Sn("compactSignature",m,v*2),new S(k(m,0,v),k(m,v,2*v))}static fromDER(m){const{r:v,s:I}=_s.toSig(Sn("DER",m));return new S(v,I)}assertValidity(){ri("r",this.r,Pn,r),ri("s",this.s,Pn,r)}addRecoveryBit(m){return new S(this.r,this.s,m)}recoverPublicKey(m){const{r:v,s:I,recovery:N}=this,M=Y(Sn("msgHash",m));if(N==null||![0,1,2,3].includes(N))throw new Error("recovery id invalid");const z=N===2||N===3?v+t.n:v;if(z>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const P=N&1?"03":"02",_=u.fromHex(P+A(z)),F=c(z),ct=o(-M*F),ft=o(I*F),mt=u.BASE.multiplyAndAddUnsafe(_,ct,ft);if(!mt)throw new Error("point at infinify");return mt.assertValidity(),mt}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return il(this.toDERHex())}toDERHex(){return _s.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return il(this.toCompactHex())}toCompactHex(){return A(this.r)+A(this.s)}}const B={isValidPrivateKey(p){try{return f(p),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const p=Px(t.n);return LU(t.randomBytes(p),t.n)},precompute(p=8,m=u.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function H(p,m=!0){return u.fromPrivateKey(p).toRawBytes(m)}function U(p){const m=oc(p),v=typeof p=="string",I=(m||v)&&p.length;return m?I===i||I===s:v?I===2*i||I===2*s:p instanceof u}function G(p,m,v=!0){if(U(p))throw new Error("first arg must be private key");if(!U(m))throw new Error("second arg must be public key");return u.fromHex(m).multiply(f(p)).toRawBytes(v)}const W=t.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const m=Xa(p),v=p.length*8-t.nBitLength;return v>0?m>>BigInt(v):m},Y=t.bits2int_modN||function(p){return o(W(p))},j=qw(t.nBitLength);function J(p){return ri("num < 2^"+t.nBitLength,p,Ds,j),sl(p,t.nByteLength)}function it(p,m,v=ut){if(["recovered","canonical"].some(Lt=>Lt in v))throw new Error("sign() legacy options not supported");const{hash:I,randomBytes:N}=t;let{lowS:M,prehash:z,extraEntropy:P}=v;M==null&&(M=!0),p=Sn("msgHash",p),fA(v),z&&(p=Sn("prehashed msgHash",I(p)));const _=Y(p),F=f(m),ct=[J(F),J(_)];if(P!=null&&P!==!1){const Lt=P===!0?N(e.BYTES):P;ct.push(Sn("extraEntropy",Lt))}const ft=cc(...ct),mt=_;function Ht(Lt){const Mt=W(Lt);if(!y(Mt))return;const Ae=c(Mt),Vt=u.BASE.multiply(Mt).toAffine(),Ut=o(Vt.x);if(Ut===Ds)return;const Re=o(Ae*o(mt+Ut*F));if(Re===Ds)return;let Yt=(Vt.x===Ut?0:2)|Number(Vt.y&Pn),ie=Re;return M&&b(Re)&&(ie=R(Re),Yt^=1),new S(Ut,ie,Yt)}return{seed:ft,k2sig:Ht}}const ut={lowS:t.lowS,prehash:!1},rt={lowS:t.lowS,prehash:!1};function ot(p,m,v=ut){const{seed:I,k2sig:N}=it(p,m,v),M=t;return Nx(M.hash.outputLen,M.nByteLength,M.hmac)(I,N)}u.BASE._setWindowSize(8);function C(p,m,v,I=rt){var Yt;const N=p;m=Sn("msgHash",m),v=Sn("publicKey",v);const{lowS:M,prehash:z,format:P}=I;if(fA(I),"strict"in I)throw new Error("options.strict was renamed to lowS");if(P!==void 0&&P!=="compact"&&P!=="der")throw new Error("format must be compact or der");const _=typeof N=="string"||oc(N),F=!_&&!P&&typeof N=="object"&&N!==null&&typeof N.r=="bigint"&&typeof N.s=="bigint";if(!_&&!F)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let ct,ft;try{if(F&&(ct=new S(N.r,N.s)),_){try{P!=="compact"&&(ct=S.fromDER(N))}catch(ie){if(!(ie instanceof _s.Err))throw ie}!ct&&P!=="der"&&(ct=S.fromCompact(N))}ft=u.fromHex(v)}catch{return!1}if(!ct||M&&ct.hasHighS())return!1;z&&(m=t.hash(m));const{r:mt,s:Ht}=ct,Lt=Y(m),Mt=c(Ht),Ae=o(Lt*Mt),Vt=o(mt*Mt),Ut=(Yt=u.BASE.multiplyAndAddUnsafe(ft,Ae,Vt))==null?void 0:Yt.toAffine();return Ut?o(Ut.x)===mt:!1}return{CURVE:t,getPublicKey:H,getSharedSecret:G,sign:ot,verify:C,ProjectivePoint:u,Signature:S,utils:B}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function k9(n){return{hash:n,hmac:(t,...e)=>I2(n,t,WL(...e)),randomBytes:Ex}}function T9(n,t){const e=r=>I9({...n,...k9(r)});return{...e(t),create:e}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const k2=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),dA=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),O9=BigInt(1),Mm=BigInt(2),pA=(n,t)=>(n+t/Mm)/t;function N9(n){const t=k2,e=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),c=BigInt(44),u=BigInt(88),f=n*n*n%t,h=f*f*n%t,y=wn(h,e,t)*h%t,A=wn(y,e,t)*h%t,b=wn(A,Mm,t)*f%t,R=wn(b,i,t)*b%t,k=wn(R,s,t)*R%t,S=wn(k,c,t)*k%t,B=wn(S,u,t)*S%t,H=wn(B,c,t)*k%t,U=wn(H,e,t)*h%t,G=wn(U,o,t)*R%t,W=wn(G,r,t)*f%t,Y=wn(W,Mm,t);if(!Lm.eql(Lm.sqr(Y),n))throw new Error("Cannot find square root");return Y}const Lm=up(k2,void 0,void 0,{sqrt:N9}),yp=T9({a:BigInt(0),b:BigInt(7),Fp:Lm,n:dA,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=dA,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-O9*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,o=BigInt("0x100000000000000000000000000000000"),c=pA(s*n,t),u=pA(-r*n,t);let f=qe(n-c*e-u*i,t),h=qe(-c*r-u*s,t);const y=f>o,A=h>o;if(y&&(f=t-f),A&&(h=t-h),f>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:y,k1:f,k2neg:A,k2:h}}}},Bm);BigInt(0);yp.ProjectivePoint;const C9=kl.utils.randomPrivateKey,gA=()=>{const n=kl.utils.randomPrivateKey(),t=A0(n),e=new Uint8Array(64);return e.set(n),e.set(t,32),{publicKey:t,secretKey:e}},A0=kl.getPublicKey;function yA(n){try{return kl.ExtendedPoint.fromHex(n),!0}catch{return!1}}const l1=(n,t)=>kl.sign(n,t.slice(0,32)),B9=kl.verify,ne=n=>It.isBuffer(n)?n:n instanceof Uint8Array?It.from(n.buffer,n.byteOffset,n.byteLength):It.from(n);let f1=class{constructor(t){Object.assign(this,t)}encode(){return It.from(jx(Nf,this))}static decode(t){return Wx(Nf,this,t)}static decodeUnchecked(t){return Hx(Nf,this,t)}};class P9 extends f1{constructor(t){if(super(t),this.enum="",Object.keys(t).length!==1)throw new Error("Enum can only take single value");Object.keys(t).map(e=>{this.enum=e})}}const Nf=new Map;var T2;const O2=32,Xi=32;function M9(n){return n._bn!==void 0}let mA=1;class pt extends f1{constructor(t){if(super({}),this._bn=void 0,M9(t))this._bn=t._bn;else{if(typeof t=="string"){const e=In.decode(t);if(e.length!=Xi)throw new Error("Invalid public key input");this._bn=new Ls(e)}else this._bn=new Ls(t);if(this._bn.byteLength()>Xi)throw new Error("Invalid public key input")}}static unique(){const t=new pt(mA);return mA+=1,new pt(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return In.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(It);if(t.length===Xi)return t;const e=It.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,r){const i=It.concat([t.toBuffer(),It.from(e),r.toBuffer()]),s=Bm(i);return new pt(s)}static createProgramAddressSync(t,e){let r=It.alloc(0);t.forEach(function(s){if(s.length>O2)throw new TypeError("Max seed length exceeded");r=It.concat([r,ne(s)])}),r=It.concat([r,e.toBuffer(),It.from("ProgramDerivedAddress")]);const i=Bm(r);if(yA(i))throw new Error("Invalid seeds, address must fall off the curve");return new pt(i)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r=255,i;for(;r!=0;){try{const s=t.concat(It.from([r]));i=this.createProgramAddressSync(s,e)}catch(s){if(s instanceof TypeError)throw s;r--;continue}return[i,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){const e=new pt(t);return yA(e.toBytes())}}T2=pt;pt.default=new T2("11111111111111111111111111111111");Nf.set(pt,{kind:"struct",fields:[["_bn","u256"]]});class L9{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=ne(t);if(t.length!==64)throw new Error("bad secret key size");this._publicKey=e.slice(32,64),this._secretKey=e.slice(0,32)}else this._secretKey=ne(C9()),this._publicKey=ne(A0(this._secretKey))}get publicKey(){return new pt(this._publicKey)}get secretKey(){return It.concat([this._secretKey,this._publicKey],64)}}const U9=new pt("BPFLoader1111111111111111111111111111111111"),Ho=1232,mp=127,nh=64;class h1 extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(h1.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class d1 extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(d1.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Qc extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Qc.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class rh{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((s,o)=>{r.set(s.toBase58(),o)});const i=s=>{const o=r.get(s.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(s=>({programIdIndex:i(s.programId),accountKeyIndexes:s.keys.map(o=>i(o.pubkey)),data:s.data}))}}const ae=(n="publicKey")=>Ge(32,n),D9=(n="signature")=>Ge(64,n),_a=(n="string")=>{const t=Ot([Tt("length"),Tt("lengthPadding"),Ge($o(Tt(),-8),"chars")],n),e=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(s,o)=>e(s,o).chars.toString(),i.encode=(s,o,c)=>{const u={chars:It.from(s,"utf8")};return r(u,o,c)},i.alloc=s=>Tt().span+Tt().span+It.from(s,"utf8").length,i},F9=(n="authorized")=>Ot([ae("staker"),ae("withdrawer")],n),$9=(n="lockup")=>Ot([Hr("unixTimestamp"),Hr("epoch"),ae("custodian")],n),H9=(n="voteInit")=>Ot([ae("nodePubkey"),ae("authorizedVoter"),ae("authorizedWithdrawer"),ge("commission")],n),z9=(n="voteAuthorizeWithSeedArgs")=>Ot([Tt("voteAuthorizationType"),ae("currentAuthorityDerivedKeyOwnerPubkey"),_a("currentAuthorityDerivedKeySeed"),ae("newAuthorized")],n);function N2(n,t){const e=i=>{if(i.span>=0)return i.span;if(typeof i.alloc=="function")return i.alloc(t[i.property]);if("count"in i&&"elementLayout"in i){const s=t[i.property];if(Array.isArray(s))return s.length*e(i.elementLayout)}else if("fields"in i)return N2({layout:i},t[i.property]);return 0};let r=0;return n.layout.fields.forEach(i=>{r+=e(i)}),r}function vr(n){let t=0,e=0;for(;;){let r=n.shift();if(t|=(r&127)<<e*7,e+=1,!(r&128))break}return t}function zr(n,t){let e=t;for(;;){let r=e&127;if(e>>=7,e==0){n.push(r);break}else r|=128,n.push(r)}}function be(n,t){if(!n)throw new Error(t||"Assertion failed")}class wp{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const r=new Map,i=o=>{const c=o.toBase58();let u=r.get(c);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(c,u)),u},s=i(e);s.isSigner=!0,s.isWritable=!0;for(const o of t){i(o.programId).isInvoked=!0;for(const c of o.keys){const u=i(c.pubkey);u.isSigner||(u.isSigner=c.isSigner),u.isWritable||(u.isWritable=c.isWritable)}}return new wp(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];be(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,u])=>u.isSigner&&u.isWritable),r=t.filter(([,u])=>u.isSigner&&!u.isWritable),i=t.filter(([,u])=>!u.isSigner&&u.isWritable),s=t.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:s.length};{be(e.length>0,"Expected at least one writable signer key");const[u]=e[0];be(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const c=[...e.map(([u])=>new pt(u)),...r.map(([u])=>new pt(u)),...i.map(([u])=>new pt(u)),...s.map(([u])=>new pt(u))];return[o,c]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,s]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&i.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:i},{writable:r,readonly:s}]}drainKeysFoundInLookupTable(t,e){const r=new Array,i=new Array;for(const[s,o]of this.keyMetaMap.entries())if(e(o)){const c=new pt(s),u=t.findIndex(f=>f.equals(c));u>=0&&(be(u<256,"Max lookup table index exceeded"),r.push(u),i.push(c),this.keyMetaMap.delete(s))}return[r,i]}}const C2="Reached end of buffer unexpectedly";function Vi(n){if(n.length===0)throw new Error(C2);return n.shift()}function xr(n,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>n.length:e>=n.length)throw new Error(C2);return n.splice(...t)}class xi{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new pt(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:In.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new rh(this.staticAccountKeys)}static compile(t){const e=wp.compile(t.instructions,t.payerKey),[r,i]=e.getMessageComponents(),o=new rh(i).compileInstructions(t.instructions).map(c=>({programIdIndex:c.programIdIndex,accounts:c.accountKeyIndexes,data:In.encode(c.data)}));return new xi({header:r,accountKeys:i,recentBlockhash:t.recentBlockhash,instructions:o})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const r=t-e,s=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return r<s}else{const r=e-this.header.numReadonlySignedAccounts;return t<r}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){const t=this.accountKeys.length;let e=[];zr(e,t);const r=this.instructions.map(y=>{const{accounts:A,programIdIndex:b}=y,R=Array.from(In.decode(y.data));let k=[];zr(k,A.length);let S=[];return zr(S,R.length),{programIdIndex:b,keyIndicesCount:It.from(k),keyIndices:A,dataLength:It.from(S),data:R}});let i=[];zr(i,r.length);let s=It.alloc(Ho);It.from(i).copy(s);let o=i.length;r.forEach(y=>{const b=Ot([ge("programIdIndex"),Ge(y.keyIndicesCount.length,"keyIndicesCount"),qn(ge("keyIndex"),y.keyIndices.length,"keyIndices"),Ge(y.dataLength.length,"dataLength"),qn(ge("userdatum"),y.data.length,"data")]).encode(y,s,o);o+=b}),s=s.slice(0,o);const c=Ot([Ge(1,"numRequiredSignatures"),Ge(1,"numReadonlySignedAccounts"),Ge(1,"numReadonlyUnsignedAccounts"),Ge(e.length,"keyCount"),qn(ae("key"),t,"keys"),ae("recentBlockhash")]),u={numRequiredSignatures:It.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:It.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:It.from([this.header.numReadonlyUnsignedAccounts]),keyCount:It.from(e),keys:this.accountKeys.map(y=>ne(y.toBytes())),recentBlockhash:In.decode(this.recentBlockhash)};let f=It.alloc(2048);const h=c.encode(u,f);return s.copy(f,h),f.slice(0,h+s.length)}static from(t){let e=[...t];const r=Vi(e);if(r!==(r&mp))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=Vi(e),s=Vi(e),o=vr(e);let c=[];for(let A=0;A<o;A++){const b=xr(e,0,Xi);c.push(new pt(It.from(b)))}const u=xr(e,0,Xi),f=vr(e);let h=[];for(let A=0;A<f;A++){const b=Vi(e),R=vr(e),k=xr(e,0,R),S=vr(e),B=xr(e,0,S),H=In.encode(It.from(B));h.push({programIdIndex:b,accounts:k,data:H})}const y={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:In.encode(It.from(u)),accountKeys:c,instructions:h};return new xi(y)}}class uc{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new rh(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(t>=r){const i=t-r,s=this.addressTableLookups.reduce((o,c)=>o+c.writableIndexes.length,0);return i<s}else if(t>=this.header.numRequiredSignatures){const i=t-e,o=r-e-this.header.numReadonlyUnsignedAccounts;return i<o}else{const i=e-this.header.numReadonlySignedAccounts;return t<i}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const r of this.addressTableLookups){const i=t.find(s=>s.key.equals(r.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const s of r.writableIndexes)if(s<i.state.addresses.length)e.writable.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`);for(const s of r.readonlyIndexes)if(s<i.state.addresses.length)e.readonly.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`)}return e}static compile(t){const e=wp.compile(t.instructions,t.payerKey),r=new Array,i={writable:new Array,readonly:new Array},s=t.addressLookupTableAccounts||[];for(const h of s){const y=e.extractTableLookup(h);if(y!==void 0){const[A,{writable:b,readonly:R}]=y;r.push(A),i.writable.push(...b),i.readonly.push(...R)}}const[o,c]=e.getMessageComponents(),f=new rh(c,i).compileInstructions(t.instructions);return new uc({header:o,staticAccountKeys:c,recentBlockhash:t.recentBlockhash,compiledInstructions:f,addressTableLookups:r})}serialize(){const t=Array();zr(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),r=Array();zr(r,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),s=Array();zr(s,this.addressTableLookups.length);const o=Ot([ge("prefix"),Ot([ge("numRequiredSignatures"),ge("numReadonlySignedAccounts"),ge("numReadonlyUnsignedAccounts")],"header"),Ge(t.length,"staticAccountKeysLength"),qn(ae(),this.staticAccountKeys.length,"staticAccountKeys"),ae("recentBlockhash"),Ge(r.length,"instructionsLength"),Ge(e.length,"serializedInstructions"),Ge(s.length,"addressTableLookupsLength"),Ge(i.length,"serializedAddressTableLookups")]),c=new Uint8Array(Ho),f=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(h=>h.toBytes()),recentBlockhash:In.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},c);return c.slice(0,f)}serializeInstructions(){let t=0;const e=new Uint8Array(Ho);for(const r of this.compiledInstructions){const i=Array();zr(i,r.accountKeyIndexes.length);const s=Array();zr(s,r.data.length);const o=Ot([ge("programIdIndex"),Ge(i.length,"encodedAccountKeyIndexesLength"),qn(ge(),r.accountKeyIndexes.length,"accountKeyIndexes"),Ge(s.length,"encodedDataLength"),Ge(r.data.length,"data")]);t+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:r.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(Ho);for(const r of this.addressTableLookups){const i=Array();zr(i,r.writableIndexes.length);const s=Array();zr(s,r.readonlyIndexes.length);const o=Ot([ae("accountKey"),Ge(i.length,"encodedWritableIndexesLength"),qn(ge(),r.writableIndexes.length,"writableIndexes"),Ge(s.length,"encodedReadonlyIndexesLength"),qn(ge(),r.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:r.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const r=Vi(e),i=r∓be(r!==i,"Expected versioned message but received legacy message");const s=i;be(s===0,`Expected versioned message with version 0 but found version ${s}`);const o={numRequiredSignatures:Vi(e),numReadonlySignedAccounts:Vi(e),numReadonlyUnsignedAccounts:Vi(e)},c=[],u=vr(e);for(let R=0;R<u;R++)c.push(new pt(xr(e,0,Xi)));const f=In.encode(xr(e,0,Xi)),h=vr(e),y=[];for(let R=0;R<h;R++){const k=Vi(e),S=vr(e),B=xr(e,0,S),H=vr(e),U=new Uint8Array(xr(e,0,H));y.push({programIdIndex:k,accountKeyIndexes:B,data:U})}const A=vr(e),b=[];for(let R=0;R<A;R++){const k=new pt(xr(e,0,Xi)),S=vr(e),B=xr(e,0,S),H=vr(e),U=xr(e,0,H);b.push({accountKey:k,writableIndexes:B,readonlyIndexes:U})}return new uc({header:o,staticAccountKeys:c,recentBlockhash:f,compiledInstructions:y,addressTableLookups:b})}}const p1={deserializeMessageVersion(n){const t=n[0],e=t∓return e===t?"legacy":e},deserialize:n=>{const t=p1.deserializeMessageVersion(n);if(t==="legacy")return xi.from(n);if(t===0)return uc.deserialize(n);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let gs=function(n){return n[n.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",n[n.PROCESSED=1]="PROCESSED",n[n.TIMED_OUT=2]="TIMED_OUT",n[n.NONCE_INVALID=3]="NONCE_INVALID",n}({});const G9=It.alloc(nh).fill(0);class Be{constructor(t){this.keys=void 0,this.programId=void 0,this.data=It.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:r})=>({pubkey:t.toJSON(),isSigner:e,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}let Te=class Um{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:r}=t;this.minNonceContextSlot=e,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:r}=t;this.recentBlockhash=e,this.lastValidBlockHeight=r}else{const{recentBlockhash:e,nonceInfo:r}=t;r&&(this.nonceInfo=r),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new Be(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let k=0;k<e.length;k++)if(e[k].programId===void 0)throw new Error(`Transaction instruction index ${k} has undefined program id`);const i=[],s=[];e.forEach(k=>{k.keys.forEach(B=>{s.push({...B})});const S=k.programId.toString();i.includes(S)||i.push(S)}),i.forEach(k=>{s.push({pubkey:new pt(k),isSigner:!1,isWritable:!1})});const o=[];s.forEach(k=>{const S=k.pubkey.toString(),B=o.findIndex(H=>H.pubkey.toString()===S);B>-1?(o[B].isWritable=o[B].isWritable||k.isWritable,o[B].isSigner=o[B].isSigner||k.isSigner):o.push(k)}),o.sort(function(k,S){if(k.isSigner!==S.isSigner)return k.isSigner?-1:1;if(k.isWritable!==S.isWritable)return k.isWritable?-1:1;const B={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return k.pubkey.toBase58().localeCompare(S.pubkey.toBase58(),"en",B)});const c=o.findIndex(k=>k.pubkey.equals(r));if(c>-1){const[k]=o.splice(c,1);k.isSigner=!0,k.isWritable=!0,o.unshift(k)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const k of this.signatures){const S=o.findIndex(B=>B.pubkey.equals(k.publicKey));if(S>-1)o[S].isSigner||(o[S].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${k.publicKey.toString()}`)}let u=0,f=0,h=0;const y=[],A=[];o.forEach(({pubkey:k,isSigner:S,isWritable:B})=>{S?(y.push(k.toString()),u+=1,B||(f+=1)):(A.push(k.toString()),B||(h+=1))});const b=y.concat(A),R=e.map(k=>{const{data:S,programId:B}=k;return{programIdIndex:b.indexOf(B.toString()),accounts:k.keys.map(H=>b.indexOf(H.pubkey.toString())),data:In.encode(S)}});return R.forEach(k=>{be(k.programIdIndex>=0),k.accounts.forEach(S=>be(S>=0))}),new xi({header:{numRequiredSignatures:u,numReadonlySignedAccounts:f,numReadonlyUnsignedAccounts:h},accountKeys:b,recentBlockhash:t,instructions:R})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((i,s)=>e[s].equals(i.publicKey))||(this.signatures=e.map(r=>({signature:null,publicKey:r}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const e=new Set;this.signatures=t.filter(r=>{const i=r.toString();return e.has(i)?!1:(e.add(i),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const s of t){const o=s.publicKey.toString();e.has(o)||(e.add(o),r.push(s))}this.signatures=r.map(s=>({signature:null,publicKey:s.publicKey}));const i=this._compile();this._partialSign(i,...r)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const s of t){const o=s.publicKey.toString();e.has(o)||(e.add(o),r.push(s))}const i=this._compile();this._partialSign(i,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach(i=>{const s=l1(r,i.secretKey);this._addSignature(i.publicKey,ne(s))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){be(e.length===64);const r=this.signatures.findIndex(i=>t.equals(i.publicKey));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=It.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const r={};for(const{signature:i,publicKey:s}of this.signatures)i===null?e&&(r.missing||(r.missing=[])).push(s):B9(i,t,s.toBytes())||(r.invalid||(r.invalid=[])).push(s);return r.invalid||r.missing?r:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),i=this.serializeMessage();if(r){const s=this._getMessageSignednessErrors(i,e);if(s){let o="Signature verification failed.";throw s.invalid&&(o+=`
|
|
17
|
-
Invalid signature for public key${s.invalid.length===1?"":"(s)"} [\`${s.invalid.map(
|
|
18
|
-
Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(
|
|
19
|
-
${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let
|
|
20
|
-
${r}. `+s+o;break;case"simulate":
|
|
16
|
+
*/(function(n){const t=vp,e=l1,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=h,n.SlowBuffer=W,n.INSPECT_MAX_BYTES=50;const i=2147483647;n.kMaxLength=i;const{Uint8Array:s,ArrayBuffer:o,SharedArrayBuffer:a}=globalThis;h.TYPED_ARRAY_SUPPORT=u(),!h.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{const O=new s(1),b={foo:function(){return 42}};return Object.setPrototypeOf(b,s.prototype),Object.setPrototypeOf(O,b),O.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function f(O){if(O>i)throw new RangeError('The value "'+O+'" is invalid for option "size"');const b=new s(O);return Object.setPrototypeOf(b,h.prototype),b}function h(O,b,E){if(typeof O=="number"){if(typeof b=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return R(O)}return y(O,b,E)}h.poolSize=8192;function y(O,b,E){if(typeof O=="string")return T(O,b);if(o.isView(O))return B(O);if(O==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof O);if(Ye(O,o)||O&&Ye(O.buffer,o)||typeof a<"u"&&(Ye(O,a)||O&&Ye(O.buffer,a)))return H(O,b,E);if(typeof O=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const D=O.valueOf&&O.valueOf();if(D!=null&&D!==O)return h.from(D,b,E);const V=U(O);if(V)return V;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof O[Symbol.toPrimitive]=="function")return h.from(O[Symbol.toPrimitive]("string"),b,E);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof O)}h.from=function(O,b,E){return y(O,b,E)},Object.setPrototypeOf(h.prototype,s.prototype),Object.setPrototypeOf(h,s);function _(O){if(typeof O!="number")throw new TypeError('"size" argument must be of type number');if(O<0)throw new RangeError('The value "'+O+'" is invalid for option "size"')}function w(O,b,E){return _(O),O<=0?f(O):b!==void 0?typeof E=="string"?f(O).fill(b,E):f(O).fill(b):f(O)}h.alloc=function(O,b,E){return w(O,b,E)};function R(O){return _(O),f(O<0?0:G(O)|0)}h.allocUnsafe=function(O){return R(O)},h.allocUnsafeSlow=function(O){return R(O)};function T(O,b){if((typeof b!="string"||b==="")&&(b="utf8"),!h.isEncoding(b))throw new TypeError("Unknown encoding: "+b);const E=X(O,b)|0;let D=f(E);const V=D.write(O,b);return V!==E&&(D=D.slice(0,V)),D}function I(O){const b=O.length<0?0:G(O.length)|0,E=f(b);for(let D=0;D<b;D+=1)E[D]=O[D]&255;return E}function B(O){if(Ye(O,s)){const b=new s(O);return H(b.buffer,b.byteOffset,b.byteLength)}return I(O)}function H(O,b,E){if(b<0||O.byteLength<b)throw new RangeError('"offset" is outside of buffer bounds');if(O.byteLength<b+(E||0))throw new RangeError('"length" is outside of buffer bounds');let D;return b===void 0&&E===void 0?D=new s(O):E===void 0?D=new s(O,b):D=new s(O,b,E),Object.setPrototypeOf(D,h.prototype),D}function U(O){if(h.isBuffer(O)){const b=G(O.length)|0,E=f(b);return E.length===0||O.copy(E,0,0,b),E}if(O.length!==void 0)return typeof O.length!="number"||me(O.length)?f(0):I(O);if(O.type==="Buffer"&&Array.isArray(O.data))return I(O.data)}function G(O){if(O>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return O|0}function W(O){return+O!=O&&(O=0),h.alloc(+O)}h.isBuffer=function(b){return b!=null&&b._isBuffer===!0&&b!==h.prototype},h.compare=function(b,E){if(Ye(b,s)&&(b=h.from(b,b.offset,b.byteLength)),Ye(E,s)&&(E=h.from(E,E.offset,E.byteLength)),!h.isBuffer(b)||!h.isBuffer(E))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(b===E)return 0;let D=b.length,V=E.length;for(let q=0,st=Math.min(D,V);q<st;++q)if(b[q]!==E[q]){D=b[q],V=E[q];break}return D<V?-1:V<D?1:0},h.isEncoding=function(b){switch(String(b).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(b,E){if(!Array.isArray(b))throw new TypeError('"list" argument must be an Array of Buffers');if(b.length===0)return h.alloc(0);let D;if(E===void 0)for(E=0,D=0;D<b.length;++D)E+=b[D].length;const V=h.allocUnsafe(E);let q=0;for(D=0;D<b.length;++D){let st=b[D];if(Ye(st,s))q+st.length>V.length?(h.isBuffer(st)||(st=h.from(st)),st.copy(V,q)):s.prototype.set.call(V,st,q);else if(h.isBuffer(st))st.copy(V,q);else throw new TypeError('"list" argument must be an Array of Buffers');q+=st.length}return V};function X(O,b){if(h.isBuffer(O))return O.length;if(o.isView(O)||Ye(O,o))return O.byteLength;if(typeof O!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof O);const E=O.length,D=arguments.length>2&&arguments[2]===!0;if(!D&&E===0)return 0;let V=!1;for(;;)switch(b){case"ascii":case"latin1":case"binary":return E;case"utf8":case"utf-8":return ve(O).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E*2;case"hex":return E>>>1;case"base64":return ue(O).length;default:if(V)return D?-1:ve(O).length;b=(""+b).toLowerCase(),V=!0}}h.byteLength=X;function j(O,b,E){let D=!1;if((b===void 0||b<0)&&(b=0),b>this.length||((E===void 0||E>this.length)&&(E=this.length),E<=0)||(E>>>=0,b>>>=0,E<=b))return"";for(O||(O="utf8");;)switch(O){case"hex":return A(this,b,E);case"utf8":case"utf-8":return k(this,b,E);case"ascii":return z(this,b,E);case"latin1":case"binary":return P(this,b,E);case"base64":return v(this,b,E);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $(this,b,E);default:if(D)throw new TypeError("Unknown encoding: "+O);O=(O+"").toLowerCase(),D=!0}}h.prototype._isBuffer=!0;function Y(O,b,E){const D=O[b];O[b]=O[E],O[E]=D}h.prototype.swap16=function(){const b=this.length;if(b%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let E=0;E<b;E+=2)Y(this,E,E+1);return this},h.prototype.swap32=function(){const b=this.length;if(b%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let E=0;E<b;E+=4)Y(this,E,E+3),Y(this,E+1,E+2);return this},h.prototype.swap64=function(){const b=this.length;if(b%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let E=0;E<b;E+=8)Y(this,E,E+7),Y(this,E+1,E+6),Y(this,E+2,E+5),Y(this,E+3,E+4);return this},h.prototype.toString=function(){const b=this.length;return b===0?"":arguments.length===0?k(this,0,b):j.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(b){if(!h.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b?!0:h.compare(this,b)===0},h.prototype.inspect=function(){let b="";const E=n.INSPECT_MAX_BYTES;return b=this.toString("hex",0,E).replace(/(.{2})/g,"$1 ").trim(),this.length>E&&(b+=" ... "),"<Buffer "+b+">"},r&&(h.prototype[r]=h.prototype.inspect),h.prototype.compare=function(b,E,D,V,q){if(Ye(b,s)&&(b=h.from(b,b.offset,b.byteLength)),!h.isBuffer(b))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof b);if(E===void 0&&(E=0),D===void 0&&(D=b?b.length:0),V===void 0&&(V=0),q===void 0&&(q=this.length),E<0||D>b.length||V<0||q>this.length)throw new RangeError("out of range index");if(V>=q&&E>=D)return 0;if(V>=q)return-1;if(E>=D)return 1;if(E>>>=0,D>>>=0,V>>>=0,q>>>=0,this===b)return 0;let st=q-V,Wt=D-E;const jt=Math.min(st,Wt),Kt=this.slice(V,q),De=b.slice(E,D);for(let Ft=0;Ft<jt;++Ft)if(Kt[Ft]!==De[Ft]){st=Kt[Ft],Wt=De[Ft];break}return st<Wt?-1:Wt<st?1:0};function it(O,b,E,D,V){if(O.length===0)return-1;if(typeof E=="string"?(D=E,E=0):E>2147483647?E=2147483647:E<-2147483648&&(E=-2147483648),E=+E,me(E)&&(E=V?0:O.length-1),E<0&&(E=O.length+E),E>=O.length){if(V)return-1;E=O.length-1}else if(E<0)if(V)E=0;else return-1;if(typeof b=="string"&&(b=h.from(b,D)),h.isBuffer(b))return b.length===0?-1:ut(O,b,E,D,V);if(typeof b=="number")return b=b&255,typeof s.prototype.indexOf=="function"?V?s.prototype.indexOf.call(O,b,E):s.prototype.lastIndexOf.call(O,b,E):ut(O,[b],E,D,V);throw new TypeError("val must be string, number or Buffer")}function ut(O,b,E,D,V){let q=1,st=O.length,Wt=b.length;if(D!==void 0&&(D=String(D).toLowerCase(),D==="ucs2"||D==="ucs-2"||D==="utf16le"||D==="utf-16le")){if(O.length<2||b.length<2)return-1;q=2,st/=2,Wt/=2,E/=2}function jt(De,Ft){return q===1?De[Ft]:De.readUInt16BE(Ft*q)}let Kt;if(V){let De=-1;for(Kt=E;Kt<st;Kt++)if(jt(O,Kt)===jt(b,De===-1?0:Kt-De)){if(De===-1&&(De=Kt),Kt-De+1===Wt)return De*q}else De!==-1&&(Kt-=Kt-De),De=-1}else for(E+Wt>st&&(E=st-Wt),Kt=E;Kt>=0;Kt--){let De=!0;for(let Ft=0;Ft<Wt;Ft++)if(jt(O,Kt+Ft)!==jt(b,Ft)){De=!1;break}if(De)return Kt}return-1}h.prototype.includes=function(b,E,D){return this.indexOf(b,E,D)!==-1},h.prototype.indexOf=function(b,E,D){return it(this,b,E,D,!0)},h.prototype.lastIndexOf=function(b,E,D){return it(this,b,E,D,!1)};function rt(O,b,E,D){E=Number(E)||0;const V=O.length-E;D?(D=Number(D),D>V&&(D=V)):D=V;const q=b.length;D>q/2&&(D=q/2);let st;for(st=0;st<D;++st){const Wt=parseInt(b.substr(st*2,2),16);if(me(Wt))return st;O[E+st]=Wt}return st}function ot(O,b,E,D){return xe(ve(b,O.length-E),O,E,D)}function C(O,b,E,D){return xe(ke(b),O,E,D)}function p(O,b,E,D){return xe(ue(b),O,E,D)}function m(O,b,E,D){return xe(An(b,O.length-E),O,E,D)}h.prototype.write=function(b,E,D,V){if(E===void 0)V="utf8",D=this.length,E=0;else if(D===void 0&&typeof E=="string")V=E,D=this.length,E=0;else if(isFinite(E))E=E>>>0,isFinite(D)?(D=D>>>0,V===void 0&&(V="utf8")):(V=D,D=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const q=this.length-E;if((D===void 0||D>q)&&(D=q),b.length>0&&(D<0||E<0)||E>this.length)throw new RangeError("Attempt to write outside buffer bounds");V||(V="utf8");let st=!1;for(;;)switch(V){case"hex":return rt(this,b,E,D);case"utf8":case"utf-8":return ot(this,b,E,D);case"ascii":case"latin1":case"binary":return C(this,b,E,D);case"base64":return p(this,b,E,D);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,b,E,D);default:if(st)throw new TypeError("Unknown encoding: "+V);V=(""+V).toLowerCase(),st=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function v(O,b,E){return b===0&&E===O.length?t.fromByteArray(O):t.fromByteArray(O.slice(b,E))}function k(O,b,E){E=Math.min(O.length,E);const D=[];let V=b;for(;V<E;){const q=O[V];let st=null,Wt=q>239?4:q>223?3:q>191?2:1;if(V+Wt<=E){let jt,Kt,De,Ft;switch(Wt){case 1:q<128&&(st=q);break;case 2:jt=O[V+1],(jt&192)===128&&(Ft=(q&31)<<6|jt&63,Ft>127&&(st=Ft));break;case 3:jt=O[V+1],Kt=O[V+2],(jt&192)===128&&(Kt&192)===128&&(Ft=(q&15)<<12|(jt&63)<<6|Kt&63,Ft>2047&&(Ft<55296||Ft>57343)&&(st=Ft));break;case 4:jt=O[V+1],Kt=O[V+2],De=O[V+3],(jt&192)===128&&(Kt&192)===128&&(De&192)===128&&(Ft=(q&15)<<18|(jt&63)<<12|(Kt&63)<<6|De&63,Ft>65535&&Ft<1114112&&(st=Ft))}}st===null?(st=65533,Wt=1):st>65535&&(st-=65536,D.push(st>>>10&1023|55296),st=56320|st&1023),D.push(st),V+=Wt}return M(D)}const N=4096;function M(O){const b=O.length;if(b<=N)return String.fromCharCode.apply(String,O);let E="",D=0;for(;D<b;)E+=String.fromCharCode.apply(String,O.slice(D,D+=N));return E}function z(O,b,E){let D="";E=Math.min(O.length,E);for(let V=b;V<E;++V)D+=String.fromCharCode(O[V]&127);return D}function P(O,b,E){let D="";E=Math.min(O.length,E);for(let V=b;V<E;++V)D+=String.fromCharCode(O[V]);return D}function A(O,b,E){const D=O.length;(!b||b<0)&&(b=0),(!E||E<0||E>D)&&(E=D);let V="";for(let q=b;q<E;++q)V+=Te[O[q]];return V}function $(O,b,E){const D=O.slice(b,E);let V="";for(let q=0;q<D.length-1;q+=2)V+=String.fromCharCode(D[q]+D[q+1]*256);return V}h.prototype.slice=function(b,E){const D=this.length;b=~~b,E=E===void 0?D:~~E,b<0?(b+=D,b<0&&(b=0)):b>D&&(b=D),E<0?(E+=D,E<0&&(E=0)):E>D&&(E=D),E<b&&(E=b);const V=this.subarray(b,E);return Object.setPrototypeOf(V,h.prototype),V};function ct(O,b,E){if(O%1!==0||O<0)throw new RangeError("offset is not uint");if(O+b>E)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(b,E,D){b=b>>>0,E=E>>>0,D||ct(b,E,this.length);let V=this[b],q=1,st=0;for(;++st<E&&(q*=256);)V+=this[b+st]*q;return V},h.prototype.readUintBE=h.prototype.readUIntBE=function(b,E,D){b=b>>>0,E=E>>>0,D||ct(b,E,this.length);let V=this[b+--E],q=1;for(;E>0&&(q*=256);)V+=this[b+--E]*q;return V},h.prototype.readUint8=h.prototype.readUInt8=function(b,E){return b=b>>>0,E||ct(b,1,this.length),this[b]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(b,E){return b=b>>>0,E||ct(b,2,this.length),this[b]|this[b+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(b,E){return b=b>>>0,E||ct(b,2,this.length),this[b]<<8|this[b+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),(this[b]|this[b+1]<<8|this[b+2]<<16)+this[b+3]*16777216},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),this[b]*16777216+(this[b+1]<<16|this[b+2]<<8|this[b+3])},h.prototype.readBigUInt64LE=Yn(function(b){b=b>>>0,Je(b,"offset");const E=this[b],D=this[b+7];(E===void 0||D===void 0)&&ce(b,this.length-8);const V=E+this[++b]*2**8+this[++b]*2**16+this[++b]*2**24,q=this[++b]+this[++b]*2**8+this[++b]*2**16+D*2**24;return BigInt(V)+(BigInt(q)<<BigInt(32))}),h.prototype.readBigUInt64BE=Yn(function(b){b=b>>>0,Je(b,"offset");const E=this[b],D=this[b+7];(E===void 0||D===void 0)&&ce(b,this.length-8);const V=E*2**24+this[++b]*2**16+this[++b]*2**8+this[++b],q=this[++b]*2**24+this[++b]*2**16+this[++b]*2**8+D;return(BigInt(V)<<BigInt(32))+BigInt(q)}),h.prototype.readIntLE=function(b,E,D){b=b>>>0,E=E>>>0,D||ct(b,E,this.length);let V=this[b],q=1,st=0;for(;++st<E&&(q*=256);)V+=this[b+st]*q;return q*=128,V>=q&&(V-=Math.pow(2,8*E)),V},h.prototype.readIntBE=function(b,E,D){b=b>>>0,E=E>>>0,D||ct(b,E,this.length);let V=E,q=1,st=this[b+--V];for(;V>0&&(q*=256);)st+=this[b+--V]*q;return q*=128,st>=q&&(st-=Math.pow(2,8*E)),st},h.prototype.readInt8=function(b,E){return b=b>>>0,E||ct(b,1,this.length),this[b]&128?(255-this[b]+1)*-1:this[b]},h.prototype.readInt16LE=function(b,E){b=b>>>0,E||ct(b,2,this.length);const D=this[b]|this[b+1]<<8;return D&32768?D|4294901760:D},h.prototype.readInt16BE=function(b,E){b=b>>>0,E||ct(b,2,this.length);const D=this[b+1]|this[b]<<8;return D&32768?D|4294901760:D},h.prototype.readInt32LE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),this[b]|this[b+1]<<8|this[b+2]<<16|this[b+3]<<24},h.prototype.readInt32BE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),this[b]<<24|this[b+1]<<16|this[b+2]<<8|this[b+3]},h.prototype.readBigInt64LE=Yn(function(b){b=b>>>0,Je(b,"offset");const E=this[b],D=this[b+7];(E===void 0||D===void 0)&&ce(b,this.length-8);const V=this[b+4]+this[b+5]*2**8+this[b+6]*2**16+(D<<24);return(BigInt(V)<<BigInt(32))+BigInt(E+this[++b]*2**8+this[++b]*2**16+this[++b]*2**24)}),h.prototype.readBigInt64BE=Yn(function(b){b=b>>>0,Je(b,"offset");const E=this[b],D=this[b+7];(E===void 0||D===void 0)&&ce(b,this.length-8);const V=(E<<24)+this[++b]*2**16+this[++b]*2**8+this[++b];return(BigInt(V)<<BigInt(32))+BigInt(this[++b]*2**24+this[++b]*2**16+this[++b]*2**8+D)}),h.prototype.readFloatLE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),e.read(this,b,!0,23,4)},h.prototype.readFloatBE=function(b,E){return b=b>>>0,E||ct(b,4,this.length),e.read(this,b,!1,23,4)},h.prototype.readDoubleLE=function(b,E){return b=b>>>0,E||ct(b,8,this.length),e.read(this,b,!0,52,8)},h.prototype.readDoubleBE=function(b,E){return b=b>>>0,E||ct(b,8,this.length),e.read(this,b,!1,52,8)};function ft(O,b,E,D,V,q){if(!h.isBuffer(O))throw new TypeError('"buffer" argument must be a Buffer instance');if(b>V||b<q)throw new RangeError('"value" argument is out of bounds');if(E+D>O.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(b,E,D,V){if(b=+b,E=E>>>0,D=D>>>0,!V){const Wt=Math.pow(2,8*D)-1;ft(this,b,E,D,Wt,0)}let q=1,st=0;for(this[E]=b&255;++st<D&&(q*=256);)this[E+st]=b/q&255;return E+D},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(b,E,D,V){if(b=+b,E=E>>>0,D=D>>>0,!V){const Wt=Math.pow(2,8*D)-1;ft(this,b,E,D,Wt,0)}let q=D-1,st=1;for(this[E+q]=b&255;--q>=0&&(st*=256);)this[E+q]=b/st&255;return E+D},h.prototype.writeUint8=h.prototype.writeUInt8=function(b,E,D){return b=+b,E=E>>>0,D||ft(this,b,E,1,255,0),this[E]=b&255,E+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(b,E,D){return b=+b,E=E>>>0,D||ft(this,b,E,2,65535,0),this[E]=b&255,this[E+1]=b>>>8,E+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(b,E,D){return b=+b,E=E>>>0,D||ft(this,b,E,2,65535,0),this[E]=b>>>8,this[E+1]=b&255,E+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(b,E,D){return b=+b,E=E>>>0,D||ft(this,b,E,4,4294967295,0),this[E+3]=b>>>24,this[E+2]=b>>>16,this[E+1]=b>>>8,this[E]=b&255,E+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(b,E,D){return b=+b,E=E>>>0,D||ft(this,b,E,4,4294967295,0),this[E]=b>>>24,this[E+1]=b>>>16,this[E+2]=b>>>8,this[E+3]=b&255,E+4};function wt(O,b,E,D,V){ie(b,D,V,O,E,7);let q=Number(b&BigInt(4294967295));O[E++]=q,q=q>>8,O[E++]=q,q=q>>8,O[E++]=q,q=q>>8,O[E++]=q;let st=Number(b>>BigInt(32)&BigInt(4294967295));return O[E++]=st,st=st>>8,O[E++]=st,st=st>>8,O[E++]=st,st=st>>8,O[E++]=st,E}function Ht(O,b,E,D,V){ie(b,D,V,O,E,7);let q=Number(b&BigInt(4294967295));O[E+7]=q,q=q>>8,O[E+6]=q,q=q>>8,O[E+5]=q,q=q>>8,O[E+4]=q;let st=Number(b>>BigInt(32)&BigInt(4294967295));return O[E+3]=st,st=st>>8,O[E+2]=st,st=st>>8,O[E+1]=st,st=st>>8,O[E]=st,E+8}h.prototype.writeBigUInt64LE=Yn(function(b,E=0){return wt(this,b,E,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Yn(function(b,E=0){return Ht(this,b,E,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(b,E,D,V){if(b=+b,E=E>>>0,!V){const jt=Math.pow(2,8*D-1);ft(this,b,E,D,jt-1,-jt)}let q=0,st=1,Wt=0;for(this[E]=b&255;++q<D&&(st*=256);)b<0&&Wt===0&&this[E+q-1]!==0&&(Wt=1),this[E+q]=(b/st>>0)-Wt&255;return E+D},h.prototype.writeIntBE=function(b,E,D,V){if(b=+b,E=E>>>0,!V){const jt=Math.pow(2,8*D-1);ft(this,b,E,D,jt-1,-jt)}let q=D-1,st=1,Wt=0;for(this[E+q]=b&255;--q>=0&&(st*=256);)b<0&&Wt===0&&this[E+q+1]!==0&&(Wt=1),this[E+q]=(b/st>>0)-Wt&255;return E+D},h.prototype.writeInt8=function(b,E,D){return b=+b,E=E>>>0,D||ft(this,b,E,1,127,-128),b<0&&(b=255+b+1),this[E]=b&255,E+1},h.prototype.writeInt16LE=function(b,E,D){return b=+b,E=E>>>0,D||ft(this,b,E,2,32767,-32768),this[E]=b&255,this[E+1]=b>>>8,E+2},h.prototype.writeInt16BE=function(b,E,D){return b=+b,E=E>>>0,D||ft(this,b,E,2,32767,-32768),this[E]=b>>>8,this[E+1]=b&255,E+2},h.prototype.writeInt32LE=function(b,E,D){return b=+b,E=E>>>0,D||ft(this,b,E,4,2147483647,-2147483648),this[E]=b&255,this[E+1]=b>>>8,this[E+2]=b>>>16,this[E+3]=b>>>24,E+4},h.prototype.writeInt32BE=function(b,E,D){return b=+b,E=E>>>0,D||ft(this,b,E,4,2147483647,-2147483648),b<0&&(b=4294967295+b+1),this[E]=b>>>24,this[E+1]=b>>>16,this[E+2]=b>>>8,this[E+3]=b&255,E+4},h.prototype.writeBigInt64LE=Yn(function(b,E=0){return wt(this,b,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Yn(function(b,E=0){return Ht(this,b,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Lt(O,b,E,D,V,q){if(E+D>O.length)throw new RangeError("Index out of range");if(E<0)throw new RangeError("Index out of range")}function Mt(O,b,E,D,V){return b=+b,E=E>>>0,V||Lt(O,b,E,4),e.write(O,b,E,D,23,4),E+4}h.prototype.writeFloatLE=function(b,E,D){return Mt(this,b,E,!0,D)},h.prototype.writeFloatBE=function(b,E,D){return Mt(this,b,E,!1,D)};function Ee(O,b,E,D,V){return b=+b,E=E>>>0,V||Lt(O,b,E,8),e.write(O,b,E,D,52,8),E+8}h.prototype.writeDoubleLE=function(b,E,D){return Ee(this,b,E,!0,D)},h.prototype.writeDoubleBE=function(b,E,D){return Ee(this,b,E,!1,D)},h.prototype.copy=function(b,E,D,V){if(!h.isBuffer(b))throw new TypeError("argument should be a Buffer");if(D||(D=0),!V&&V!==0&&(V=this.length),E>=b.length&&(E=b.length),E||(E=0),V>0&&V<D&&(V=D),V===D||b.length===0||this.length===0)return 0;if(E<0)throw new RangeError("targetStart out of bounds");if(D<0||D>=this.length)throw new RangeError("Index out of range");if(V<0)throw new RangeError("sourceEnd out of bounds");V>this.length&&(V=this.length),b.length-E<V-D&&(V=b.length-E+D);const q=V-D;return this===b&&typeof s.prototype.copyWithin=="function"?this.copyWithin(E,D,V):s.prototype.set.call(b,this.subarray(D,V),E),q},h.prototype.fill=function(b,E,D,V){if(typeof b=="string"){if(typeof E=="string"?(V=E,E=0,D=this.length):typeof D=="string"&&(V=D,D=this.length),V!==void 0&&typeof V!="string")throw new TypeError("encoding must be a string");if(typeof V=="string"&&!h.isEncoding(V))throw new TypeError("Unknown encoding: "+V);if(b.length===1){const st=b.charCodeAt(0);(V==="utf8"&&st<128||V==="latin1")&&(b=st)}}else typeof b=="number"?b=b&255:typeof b=="boolean"&&(b=Number(b));if(E<0||this.length<E||this.length<D)throw new RangeError("Out of range index");if(D<=E)return this;E=E>>>0,D=D===void 0?this.length:D>>>0,b||(b=0);let q;if(typeof b=="number")for(q=E;q<D;++q)this[q]=b;else{const st=h.isBuffer(b)?b:h.from(b,V),Wt=st.length;if(Wt===0)throw new TypeError('The value "'+b+'" is invalid for argument "value"');for(q=0;q<D-E;++q)this[q+E]=st[q%Wt]}return this};const Vt={};function Ut(O,b,E){Vt[O]=class extends E{constructor(){super(),Object.defineProperty(this,"message",{value:b.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${O}]`,this.stack,delete this.name}get code(){return O}set code(V){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:V,writable:!0})}toString(){return`${this.name} [${O}]: ${this.message}`}}}Ut("ERR_BUFFER_OUT_OF_BOUNDS",function(O){return O?`${O} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ut("ERR_INVALID_ARG_TYPE",function(O,b){return`The "${O}" argument must be of type number. Received type ${typeof b}`},TypeError),Ut("ERR_OUT_OF_RANGE",function(O,b,E){let D=`The value of "${O}" is out of range.`,V=E;return Number.isInteger(E)&&Math.abs(E)>2**32?V=Ie(String(E)):typeof E=="bigint"&&(V=String(E),(E>BigInt(2)**BigInt(32)||E<-(BigInt(2)**BigInt(32)))&&(V=Ie(V)),V+="n"),D+=` It must be ${b}. Received ${V}`,D},RangeError);function Ie(O){let b="",E=O.length;const D=O[0]==="-"?1:0;for(;E>=D+4;E-=3)b=`_${O.slice(E-3,E)}${b}`;return`${O.slice(0,E)}${b}`}function Yt(O,b,E){Je(b,"offset"),(O[b]===void 0||O[b+E]===void 0)&&ce(b,O.length-(E+1))}function ie(O,b,E,D,V,q){if(O>E||O<b){const st=typeof b=="bigint"?"n":"";let Wt;throw b===0||b===BigInt(0)?Wt=`>= 0${st} and < 2${st} ** ${(q+1)*8}${st}`:Wt=`>= -(2${st} ** ${(q+1)*8-1}${st}) and < 2 ** ${(q+1)*8-1}${st}`,new Vt.ERR_OUT_OF_RANGE("value",Wt,O)}Yt(D,V,q)}function Je(O,b){if(typeof O!="number")throw new Vt.ERR_INVALID_ARG_TYPE(b,"number",O)}function ce(O,b,E){throw Math.floor(O)!==O?(Je(O,E),new Vt.ERR_OUT_OF_RANGE("offset","an integer",O)):b<0?new Vt.ERR_BUFFER_OUT_OF_BOUNDS:new Vt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${b}`,O)}const Le=/[^+/0-9A-Za-z-_]/g;function oo(O){if(O=O.split("=")[0],O=O.trim().replace(Le,""),O.length<2)return"";for(;O.length%4!==0;)O=O+"=";return O}function ve(O,b){b=b||1/0;let E;const D=O.length;let V=null;const q=[];for(let st=0;st<D;++st){if(E=O.charCodeAt(st),E>55295&&E<57344){if(!V){if(E>56319){(b-=3)>-1&&q.push(239,191,189);continue}else if(st+1===D){(b-=3)>-1&&q.push(239,191,189);continue}V=E;continue}if(E<56320){(b-=3)>-1&&q.push(239,191,189),V=E;continue}E=(V-55296<<10|E-56320)+65536}else V&&(b-=3)>-1&&q.push(239,191,189);if(V=null,E<128){if((b-=1)<0)break;q.push(E)}else if(E<2048){if((b-=2)<0)break;q.push(E>>6|192,E&63|128)}else if(E<65536){if((b-=3)<0)break;q.push(E>>12|224,E>>6&63|128,E&63|128)}else if(E<1114112){if((b-=4)<0)break;q.push(E>>18|240,E>>12&63|128,E>>6&63|128,E&63|128)}else throw new Error("Invalid code point")}return q}function ke(O){const b=[];for(let E=0;E<O.length;++E)b.push(O.charCodeAt(E)&255);return b}function An(O,b){let E,D,V;const q=[];for(let st=0;st<O.length&&!((b-=2)<0);++st)E=O.charCodeAt(st),D=E>>8,V=E%256,q.push(V),q.push(D);return q}function ue(O){return t.toByteArray(oo(O))}function xe(O,b,E,D){let V;for(V=0;V<D&&!(V+E>=b.length||V>=O.length);++V)b[V+E]=O[V];return V}function Ye(O,b){return O instanceof b||O!=null&&O.constructor!=null&&O.constructor.name!=null&&O.constructor.name===b.name}function me(O){return O!==O}const Te=function(){const O="0123456789abcdef",b=new Array(256);for(let E=0;E<16;++E){const D=E*16;for(let V=0;V<16;++V)b[D+V]=O[E]+O[V]}return b}();function Yn(O){return typeof BigInt>"u"?Ue:O}function Ue(){throw new Error("BigInt not supported")}})(u1);const Zt=u1.Buffer,St=u1.Buffer,vU=Object.freeze(Object.defineProperty({__proto__:null,Buffer:St,default:Zt},Symbol.toStringTag,{value:"Module"}));var f1={exports:{}};const h1=gp(vU);f1.exports;(function(n){(function(t,e){function r(C,p){if(!C)throw new Error(p||"Assertion failed")}function i(C,p){C.super_=p;var m=function(){};m.prototype=p.prototype,C.prototype=new m,C.prototype.constructor=C}function s(C,p,m){if(s.isBN(C))return C;this.negative=0,this.words=null,this.length=0,this.red=null,C!==null&&((p==="le"||p==="be")&&(m=p,p=10),this._init(C||0,p||10,m||"be"))}typeof t=="object"?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=h1.Buffer}catch{}s.isBN=function(p){return p instanceof s?!0:p!==null&&typeof p=="object"&&p.constructor.wordSize===s.wordSize&&Array.isArray(p.words)},s.max=function(p,m){return p.cmp(m)>0?p:m},s.min=function(p,m){return p.cmp(m)<0?p:m},s.prototype._init=function(p,m,v){if(typeof p=="number")return this._initNumber(p,m,v);if(typeof p=="object")return this._initArray(p,m,v);m==="hex"&&(m=16),r(m===(m|0)&&m>=2&&m<=36),p=p.toString().replace(/\s+/g,"");var k=0;p[0]==="-"&&(k++,this.negative=1),k<p.length&&(m===16?this._parseHex(p,k,v):(this._parseBase(p,m,k),v==="le"&&this._initArray(this.toArray(),m,v)))},s.prototype._initNumber=function(p,m,v){p<0&&(this.negative=1,p=-p),p<67108864?(this.words=[p&67108863],this.length=1):p<4503599627370496?(this.words=[p&67108863,p/67108864&67108863],this.length=2):(r(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),v==="le"&&this._initArray(this.toArray(),m,v)},s.prototype._initArray=function(p,m,v){if(r(typeof p.length=="number"),p.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(p.length/3),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var N,M,z=0;if(v==="be")for(k=p.length-1,N=0;k>=0;k-=3)M=p[k]|p[k-1]<<8|p[k-2]<<16,this.words[N]|=M<<z&67108863,this.words[N+1]=M>>>26-z&67108863,z+=24,z>=26&&(z-=26,N++);else if(v==="le")for(k=0,N=0;k<p.length;k+=3)M=p[k]|p[k+1]<<8|p[k+2]<<16,this.words[N]|=M<<z&67108863,this.words[N+1]=M>>>26-z&67108863,z+=24,z>=26&&(z-=26,N++);return this._strip()};function a(C,p){var m=C.charCodeAt(p);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;r(!1,"Invalid character in "+C)}function u(C,p,m){var v=a(C,m);return m-1>=p&&(v|=a(C,m-1)<<4),v}s.prototype._parseHex=function(p,m,v){this.length=Math.ceil((p.length-m)/6),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var N=0,M=0,z;if(v==="be")for(k=p.length-1;k>=m;k-=2)z=u(p,m,k)<<N,this.words[M]|=z&67108863,N>=18?(N-=18,M+=1,this.words[M]|=z>>>26):N+=8;else{var P=p.length-m;for(k=P%2===0?m+1:m;k<p.length;k+=2)z=u(p,m,k)<<N,this.words[M]|=z&67108863,N>=18?(N-=18,M+=1,this.words[M]|=z>>>26):N+=8}this._strip()};function f(C,p,m,v){for(var k=0,N=0,M=Math.min(C.length,m),z=p;z<M;z++){var P=C.charCodeAt(z)-48;k*=v,P>=49?N=P-49+10:P>=17?N=P-17+10:N=P,r(P>=0&&N<v,"Invalid character"),k+=N}return k}s.prototype._parseBase=function(p,m,v){this.words=[0],this.length=1;for(var k=0,N=1;N<=67108863;N*=m)k++;k--,N=N/m|0;for(var M=p.length-v,z=M%k,P=Math.min(M,M-z)+v,A=0,$=v;$<P;$+=k)A=f(p,$,$+k,m),this.imuln(N),this.words[0]+A<67108864?this.words[0]+=A:this._iaddn(A);if(z!==0){var ct=1;for(A=f(p,$,p.length,m),$=0;$<z;$++)ct*=m;this.imuln(ct),this.words[0]+A<67108864?this.words[0]+=A:this._iaddn(A)}this._strip()},s.prototype.copy=function(p){p.words=new Array(this.length);for(var m=0;m<this.length;m++)p.words[m]=this.words[m];p.length=this.length,p.negative=this.negative,p.red=this.red};function h(C,p){C.words=p.words,C.length=p.length,C.negative=p.negative,C.red=p.red}if(s.prototype._move=function(p){h(p,this)},s.prototype.clone=function(){var p=new s(null);return this.copy(p),p},s.prototype._expand=function(p){for(;this.length<p;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=y}catch{s.prototype.inspect=y}else s.prototype.inspect=y;function y(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var _=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],w=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],R=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(p,m){p=p||10,m=m|0||1;var v;if(p===16||p==="hex"){v="";for(var k=0,N=0,M=0;M<this.length;M++){var z=this.words[M],P=((z<<k|N)&16777215).toString(16);N=z>>>24-k&16777215,k+=2,k>=26&&(k-=26,M--),N!==0||M!==this.length-1?v=_[6-P.length]+P+v:v=P+v}for(N!==0&&(v=N.toString(16)+v);v.length%m!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(p===(p|0)&&p>=2&&p<=36){var A=w[p],$=R[p];v="";var ct=this.clone();for(ct.negative=0;!ct.isZero();){var ft=ct.modrn($).toString(p);ct=ct.idivn($),ct.isZero()?v=ft+v:v=_[A-ft.length]+ft+v}for(this.isZero()&&(v="0"+v);v.length%m!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}r(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var p=this.words[0];return this.length===2?p+=this.words[1]*67108864:this.length===3&&this.words[2]===1?p+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-p:p},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(p,m){return this.toArrayLike(o,p,m)}),s.prototype.toArray=function(p,m){return this.toArrayLike(Array,p,m)};var T=function(p,m){return p.allocUnsafe?p.allocUnsafe(m):new p(m)};s.prototype.toArrayLike=function(p,m,v){this._strip();var k=this.byteLength(),N=v||Math.max(1,k);r(k<=N,"byte array longer than desired length"),r(N>0,"Requested array length <= 0");var M=T(p,N),z=m==="le"?"LE":"BE";return this["_toArrayLike"+z](M,k),M},s.prototype._toArrayLikeLE=function(p,m){for(var v=0,k=0,N=0,M=0;N<this.length;N++){var z=this.words[N]<<M|k;p[v++]=z&255,v<p.length&&(p[v++]=z>>8&255),v<p.length&&(p[v++]=z>>16&255),M===6?(v<p.length&&(p[v++]=z>>24&255),k=0,M=0):(k=z>>>24,M+=2)}if(v<p.length)for(p[v++]=k;v<p.length;)p[v++]=0},s.prototype._toArrayLikeBE=function(p,m){for(var v=p.length-1,k=0,N=0,M=0;N<this.length;N++){var z=this.words[N]<<M|k;p[v--]=z&255,v>=0&&(p[v--]=z>>8&255),v>=0&&(p[v--]=z>>16&255),M===6?(v>=0&&(p[v--]=z>>24&255),k=0,M=0):(k=z>>>24,M+=2)}if(v>=0)for(p[v--]=k;v>=0;)p[v--]=0},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var m=p,v=0;return m>=4096&&(v+=13,m>>>=13),m>=64&&(v+=7,m>>>=7),m>=8&&(v+=4,m>>>=4),m>=2&&(v+=2,m>>>=2),v+m},s.prototype._zeroBits=function(p){if(p===0)return 26;var m=p,v=0;return m&8191||(v+=13,m>>>=13),m&127||(v+=7,m>>>=7),m&15||(v+=4,m>>>=4),m&3||(v+=2,m>>>=2),m&1||v++,v},s.prototype.bitLength=function(){var p=this.words[this.length-1],m=this._countBits(p);return(this.length-1)*26+m};function I(C){for(var p=new Array(C.bitLength()),m=0;m<p.length;m++){var v=m/26|0,k=m%26;p[m]=C.words[v]>>>k&1}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,m=0;m<this.length;m++){var v=this._zeroBits(this.words[m]);if(p+=v,v!==26)break}return p},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(p){return this.negative!==0?this.abs().inotn(p).iaddn(1):this.clone()},s.prototype.fromTwos=function(p){return this.testn(p-1)?this.notn(p).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(p){for(;this.length<p.length;)this.words[this.length++]=0;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]|p.words[m];return this._strip()},s.prototype.ior=function(p){return r((this.negative|p.negative)===0),this.iuor(p)},s.prototype.or=function(p){return this.length>p.length?this.clone().ior(p):p.clone().ior(this)},s.prototype.uor=function(p){return this.length>p.length?this.clone().iuor(p):p.clone().iuor(this)},s.prototype.iuand=function(p){var m;this.length>p.length?m=p:m=this;for(var v=0;v<m.length;v++)this.words[v]=this.words[v]&p.words[v];return this.length=m.length,this._strip()},s.prototype.iand=function(p){return r((this.negative|p.negative)===0),this.iuand(p)},s.prototype.and=function(p){return this.length>p.length?this.clone().iand(p):p.clone().iand(this)},s.prototype.uand=function(p){return this.length>p.length?this.clone().iuand(p):p.clone().iuand(this)},s.prototype.iuxor=function(p){var m,v;this.length>p.length?(m=this,v=p):(m=p,v=this);for(var k=0;k<v.length;k++)this.words[k]=m.words[k]^v.words[k];if(this!==m)for(;k<m.length;k++)this.words[k]=m.words[k];return this.length=m.length,this._strip()},s.prototype.ixor=function(p){return r((this.negative|p.negative)===0),this.iuxor(p)},s.prototype.xor=function(p){return this.length>p.length?this.clone().ixor(p):p.clone().ixor(this)},s.prototype.uxor=function(p){return this.length>p.length?this.clone().iuxor(p):p.clone().iuxor(this)},s.prototype.inotn=function(p){r(typeof p=="number"&&p>=0);var m=Math.ceil(p/26)|0,v=p%26;this._expand(m),v>0&&m--;for(var k=0;k<m;k++)this.words[k]=~this.words[k]&67108863;return v>0&&(this.words[k]=~this.words[k]&67108863>>26-v),this._strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,m){r(typeof p=="number"&&p>=0);var v=p/26|0,k=p%26;return this._expand(v+1),m?this.words[v]=this.words[v]|1<<k:this.words[v]=this.words[v]&~(1<<k),this._strip()},s.prototype.iadd=function(p){var m;if(this.negative!==0&&p.negative===0)return this.negative=0,m=this.isub(p),this.negative^=1,this._normSign();if(this.negative===0&&p.negative!==0)return p.negative=0,m=this.isub(p),p.negative=1,m._normSign();var v,k;this.length>p.length?(v=this,k=p):(v=p,k=this);for(var N=0,M=0;M<k.length;M++)m=(v.words[M]|0)+(k.words[M]|0)+N,this.words[M]=m&67108863,N=m>>>26;for(;N!==0&&M<v.length;M++)m=(v.words[M]|0)+N,this.words[M]=m&67108863,N=m>>>26;if(this.length=v.length,N!==0)this.words[this.length]=N,this.length++;else if(v!==this)for(;M<v.length;M++)this.words[M]=v.words[M];return this},s.prototype.add=function(p){var m;return p.negative!==0&&this.negative===0?(p.negative=0,m=this.sub(p),p.negative^=1,m):p.negative===0&&this.negative!==0?(this.negative=0,m=p.sub(this),this.negative=1,m):this.length>p.length?this.clone().iadd(p):p.clone().iadd(this)},s.prototype.isub=function(p){if(p.negative!==0){p.negative=0;var m=this.iadd(p);return p.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(p),this.negative=1,this._normSign();var v=this.cmp(p);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var k,N;v>0?(k=this,N=p):(k=p,N=this);for(var M=0,z=0;z<N.length;z++)m=(k.words[z]|0)-(N.words[z]|0)+M,M=m>>26,this.words[z]=m&67108863;for(;M!==0&&z<k.length;z++)m=(k.words[z]|0)+M,M=m>>26,this.words[z]=m&67108863;if(M===0&&z<k.length&&k!==this)for(;z<k.length;z++)this.words[z]=k.words[z];return this.length=Math.max(this.length,z),k!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function B(C,p,m){m.negative=p.negative^C.negative;var v=C.length+p.length|0;m.length=v,v=v-1|0;var k=C.words[0]|0,N=p.words[0]|0,M=k*N,z=M&67108863,P=M/67108864|0;m.words[0]=z;for(var A=1;A<v;A++){for(var $=P>>>26,ct=P&67108863,ft=Math.min(A,p.length-1),wt=Math.max(0,A-C.length+1);wt<=ft;wt++){var Ht=A-wt|0;k=C.words[Ht]|0,N=p.words[wt]|0,M=k*N+ct,$+=M/67108864|0,ct=M&67108863}m.words[A]=ct|0,P=$|0}return P!==0?m.words[A]=P|0:m.length--,m._strip()}var H=function(p,m,v){var k=p.words,N=m.words,M=v.words,z=0,P,A,$,ct=k[0]|0,ft=ct&8191,wt=ct>>>13,Ht=k[1]|0,Lt=Ht&8191,Mt=Ht>>>13,Ee=k[2]|0,Vt=Ee&8191,Ut=Ee>>>13,Ie=k[3]|0,Yt=Ie&8191,ie=Ie>>>13,Je=k[4]|0,ce=Je&8191,Le=Je>>>13,oo=k[5]|0,ve=oo&8191,ke=oo>>>13,An=k[6]|0,ue=An&8191,xe=An>>>13,Ye=k[7]|0,me=Ye&8191,Te=Ye>>>13,Yn=k[8]|0,Ue=Yn&8191,O=Yn>>>13,b=k[9]|0,E=b&8191,D=b>>>13,V=N[0]|0,q=V&8191,st=V>>>13,Wt=N[1]|0,jt=Wt&8191,Kt=Wt>>>13,De=N[2]|0,Ft=De&8191,an=De>>>13,Ad=N[3]|0,cn=Ad&8191,un=Ad>>>13,Ed=N[4]|0,Xe=Ed&8191,ln=Ed>>>13,vd=N[5]|0,tn=vd&8191,fn=vd>>>13,ha=N[6]|0,We=ha&8191,hn=ha>>>13,xd=N[7]|0,dn=xd&8191,pn=xd>>>13,Rd=N[8]|0,gn=Rd&8191,yn=Rd>>>13,da=N[9]|0,mn=da&8191,wn=da>>>13;v.negative=p.negative^m.negative,v.length=19,P=Math.imul(ft,q),A=Math.imul(ft,st),A=A+Math.imul(wt,q)|0,$=Math.imul(wt,st);var Yl=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Yl>>>26)|0,Yl&=67108863,P=Math.imul(Lt,q),A=Math.imul(Lt,st),A=A+Math.imul(Mt,q)|0,$=Math.imul(Mt,st),P=P+Math.imul(ft,jt)|0,A=A+Math.imul(ft,Kt)|0,A=A+Math.imul(wt,jt)|0,$=$+Math.imul(wt,Kt)|0;var Mc=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Mc>>>26)|0,Mc&=67108863,P=Math.imul(Vt,q),A=Math.imul(Vt,st),A=A+Math.imul(Ut,q)|0,$=Math.imul(Ut,st),P=P+Math.imul(Lt,jt)|0,A=A+Math.imul(Lt,Kt)|0,A=A+Math.imul(Mt,jt)|0,$=$+Math.imul(Mt,Kt)|0,P=P+Math.imul(ft,Ft)|0,A=A+Math.imul(ft,an)|0,A=A+Math.imul(wt,Ft)|0,$=$+Math.imul(wt,an)|0;var Xl=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Xl>>>26)|0,Xl&=67108863,P=Math.imul(Yt,q),A=Math.imul(Yt,st),A=A+Math.imul(ie,q)|0,$=Math.imul(ie,st),P=P+Math.imul(Vt,jt)|0,A=A+Math.imul(Vt,Kt)|0,A=A+Math.imul(Ut,jt)|0,$=$+Math.imul(Ut,Kt)|0,P=P+Math.imul(Lt,Ft)|0,A=A+Math.imul(Lt,an)|0,A=A+Math.imul(Mt,Ft)|0,$=$+Math.imul(Mt,an)|0,P=P+Math.imul(ft,cn)|0,A=A+Math.imul(ft,un)|0,A=A+Math.imul(wt,cn)|0,$=$+Math.imul(wt,un)|0;var tf=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(tf>>>26)|0,tf&=67108863,P=Math.imul(ce,q),A=Math.imul(ce,st),A=A+Math.imul(Le,q)|0,$=Math.imul(Le,st),P=P+Math.imul(Yt,jt)|0,A=A+Math.imul(Yt,Kt)|0,A=A+Math.imul(ie,jt)|0,$=$+Math.imul(ie,Kt)|0,P=P+Math.imul(Vt,Ft)|0,A=A+Math.imul(Vt,an)|0,A=A+Math.imul(Ut,Ft)|0,$=$+Math.imul(Ut,an)|0,P=P+Math.imul(Lt,cn)|0,A=A+Math.imul(Lt,un)|0,A=A+Math.imul(Mt,cn)|0,$=$+Math.imul(Mt,un)|0,P=P+Math.imul(ft,Xe)|0,A=A+Math.imul(ft,ln)|0,A=A+Math.imul(wt,Xe)|0,$=$+Math.imul(wt,ln)|0;var ef=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(ef>>>26)|0,ef&=67108863,P=Math.imul(ve,q),A=Math.imul(ve,st),A=A+Math.imul(ke,q)|0,$=Math.imul(ke,st),P=P+Math.imul(ce,jt)|0,A=A+Math.imul(ce,Kt)|0,A=A+Math.imul(Le,jt)|0,$=$+Math.imul(Le,Kt)|0,P=P+Math.imul(Yt,Ft)|0,A=A+Math.imul(Yt,an)|0,A=A+Math.imul(ie,Ft)|0,$=$+Math.imul(ie,an)|0,P=P+Math.imul(Vt,cn)|0,A=A+Math.imul(Vt,un)|0,A=A+Math.imul(Ut,cn)|0,$=$+Math.imul(Ut,un)|0,P=P+Math.imul(Lt,Xe)|0,A=A+Math.imul(Lt,ln)|0,A=A+Math.imul(Mt,Xe)|0,$=$+Math.imul(Mt,ln)|0,P=P+Math.imul(ft,tn)|0,A=A+Math.imul(ft,fn)|0,A=A+Math.imul(wt,tn)|0,$=$+Math.imul(wt,fn)|0;var nf=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(nf>>>26)|0,nf&=67108863,P=Math.imul(ue,q),A=Math.imul(ue,st),A=A+Math.imul(xe,q)|0,$=Math.imul(xe,st),P=P+Math.imul(ve,jt)|0,A=A+Math.imul(ve,Kt)|0,A=A+Math.imul(ke,jt)|0,$=$+Math.imul(ke,Kt)|0,P=P+Math.imul(ce,Ft)|0,A=A+Math.imul(ce,an)|0,A=A+Math.imul(Le,Ft)|0,$=$+Math.imul(Le,an)|0,P=P+Math.imul(Yt,cn)|0,A=A+Math.imul(Yt,un)|0,A=A+Math.imul(ie,cn)|0,$=$+Math.imul(ie,un)|0,P=P+Math.imul(Vt,Xe)|0,A=A+Math.imul(Vt,ln)|0,A=A+Math.imul(Ut,Xe)|0,$=$+Math.imul(Ut,ln)|0,P=P+Math.imul(Lt,tn)|0,A=A+Math.imul(Lt,fn)|0,A=A+Math.imul(Mt,tn)|0,$=$+Math.imul(Mt,fn)|0,P=P+Math.imul(ft,We)|0,A=A+Math.imul(ft,hn)|0,A=A+Math.imul(wt,We)|0,$=$+Math.imul(wt,hn)|0;var Lc=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Lc>>>26)|0,Lc&=67108863,P=Math.imul(me,q),A=Math.imul(me,st),A=A+Math.imul(Te,q)|0,$=Math.imul(Te,st),P=P+Math.imul(ue,jt)|0,A=A+Math.imul(ue,Kt)|0,A=A+Math.imul(xe,jt)|0,$=$+Math.imul(xe,Kt)|0,P=P+Math.imul(ve,Ft)|0,A=A+Math.imul(ve,an)|0,A=A+Math.imul(ke,Ft)|0,$=$+Math.imul(ke,an)|0,P=P+Math.imul(ce,cn)|0,A=A+Math.imul(ce,un)|0,A=A+Math.imul(Le,cn)|0,$=$+Math.imul(Le,un)|0,P=P+Math.imul(Yt,Xe)|0,A=A+Math.imul(Yt,ln)|0,A=A+Math.imul(ie,Xe)|0,$=$+Math.imul(ie,ln)|0,P=P+Math.imul(Vt,tn)|0,A=A+Math.imul(Vt,fn)|0,A=A+Math.imul(Ut,tn)|0,$=$+Math.imul(Ut,fn)|0,P=P+Math.imul(Lt,We)|0,A=A+Math.imul(Lt,hn)|0,A=A+Math.imul(Mt,We)|0,$=$+Math.imul(Mt,hn)|0,P=P+Math.imul(ft,dn)|0,A=A+Math.imul(ft,pn)|0,A=A+Math.imul(wt,dn)|0,$=$+Math.imul(wt,pn)|0;var rf=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(rf>>>26)|0,rf&=67108863,P=Math.imul(Ue,q),A=Math.imul(Ue,st),A=A+Math.imul(O,q)|0,$=Math.imul(O,st),P=P+Math.imul(me,jt)|0,A=A+Math.imul(me,Kt)|0,A=A+Math.imul(Te,jt)|0,$=$+Math.imul(Te,Kt)|0,P=P+Math.imul(ue,Ft)|0,A=A+Math.imul(ue,an)|0,A=A+Math.imul(xe,Ft)|0,$=$+Math.imul(xe,an)|0,P=P+Math.imul(ve,cn)|0,A=A+Math.imul(ve,un)|0,A=A+Math.imul(ke,cn)|0,$=$+Math.imul(ke,un)|0,P=P+Math.imul(ce,Xe)|0,A=A+Math.imul(ce,ln)|0,A=A+Math.imul(Le,Xe)|0,$=$+Math.imul(Le,ln)|0,P=P+Math.imul(Yt,tn)|0,A=A+Math.imul(Yt,fn)|0,A=A+Math.imul(ie,tn)|0,$=$+Math.imul(ie,fn)|0,P=P+Math.imul(Vt,We)|0,A=A+Math.imul(Vt,hn)|0,A=A+Math.imul(Ut,We)|0,$=$+Math.imul(Ut,hn)|0,P=P+Math.imul(Lt,dn)|0,A=A+Math.imul(Lt,pn)|0,A=A+Math.imul(Mt,dn)|0,$=$+Math.imul(Mt,pn)|0,P=P+Math.imul(ft,gn)|0,A=A+Math.imul(ft,yn)|0,A=A+Math.imul(wt,gn)|0,$=$+Math.imul(wt,yn)|0;var gs=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(gs>>>26)|0,gs&=67108863,P=Math.imul(E,q),A=Math.imul(E,st),A=A+Math.imul(D,q)|0,$=Math.imul(D,st),P=P+Math.imul(Ue,jt)|0,A=A+Math.imul(Ue,Kt)|0,A=A+Math.imul(O,jt)|0,$=$+Math.imul(O,Kt)|0,P=P+Math.imul(me,Ft)|0,A=A+Math.imul(me,an)|0,A=A+Math.imul(Te,Ft)|0,$=$+Math.imul(Te,an)|0,P=P+Math.imul(ue,cn)|0,A=A+Math.imul(ue,un)|0,A=A+Math.imul(xe,cn)|0,$=$+Math.imul(xe,un)|0,P=P+Math.imul(ve,Xe)|0,A=A+Math.imul(ve,ln)|0,A=A+Math.imul(ke,Xe)|0,$=$+Math.imul(ke,ln)|0,P=P+Math.imul(ce,tn)|0,A=A+Math.imul(ce,fn)|0,A=A+Math.imul(Le,tn)|0,$=$+Math.imul(Le,fn)|0,P=P+Math.imul(Yt,We)|0,A=A+Math.imul(Yt,hn)|0,A=A+Math.imul(ie,We)|0,$=$+Math.imul(ie,hn)|0,P=P+Math.imul(Vt,dn)|0,A=A+Math.imul(Vt,pn)|0,A=A+Math.imul(Ut,dn)|0,$=$+Math.imul(Ut,pn)|0,P=P+Math.imul(Lt,gn)|0,A=A+Math.imul(Lt,yn)|0,A=A+Math.imul(Mt,gn)|0,$=$+Math.imul(Mt,yn)|0,P=P+Math.imul(ft,mn)|0,A=A+Math.imul(ft,wn)|0,A=A+Math.imul(wt,mn)|0,$=$+Math.imul(wt,wn)|0;var sf=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(sf>>>26)|0,sf&=67108863,P=Math.imul(E,jt),A=Math.imul(E,Kt),A=A+Math.imul(D,jt)|0,$=Math.imul(D,Kt),P=P+Math.imul(Ue,Ft)|0,A=A+Math.imul(Ue,an)|0,A=A+Math.imul(O,Ft)|0,$=$+Math.imul(O,an)|0,P=P+Math.imul(me,cn)|0,A=A+Math.imul(me,un)|0,A=A+Math.imul(Te,cn)|0,$=$+Math.imul(Te,un)|0,P=P+Math.imul(ue,Xe)|0,A=A+Math.imul(ue,ln)|0,A=A+Math.imul(xe,Xe)|0,$=$+Math.imul(xe,ln)|0,P=P+Math.imul(ve,tn)|0,A=A+Math.imul(ve,fn)|0,A=A+Math.imul(ke,tn)|0,$=$+Math.imul(ke,fn)|0,P=P+Math.imul(ce,We)|0,A=A+Math.imul(ce,hn)|0,A=A+Math.imul(Le,We)|0,$=$+Math.imul(Le,hn)|0,P=P+Math.imul(Yt,dn)|0,A=A+Math.imul(Yt,pn)|0,A=A+Math.imul(ie,dn)|0,$=$+Math.imul(ie,pn)|0,P=P+Math.imul(Vt,gn)|0,A=A+Math.imul(Vt,yn)|0,A=A+Math.imul(Ut,gn)|0,$=$+Math.imul(Ut,yn)|0,P=P+Math.imul(Lt,mn)|0,A=A+Math.imul(Lt,wn)|0,A=A+Math.imul(Mt,mn)|0,$=$+Math.imul(Mt,wn)|0;var di=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(di>>>26)|0,di&=67108863,P=Math.imul(E,Ft),A=Math.imul(E,an),A=A+Math.imul(D,Ft)|0,$=Math.imul(D,an),P=P+Math.imul(Ue,cn)|0,A=A+Math.imul(Ue,un)|0,A=A+Math.imul(O,cn)|0,$=$+Math.imul(O,un)|0,P=P+Math.imul(me,Xe)|0,A=A+Math.imul(me,ln)|0,A=A+Math.imul(Te,Xe)|0,$=$+Math.imul(Te,ln)|0,P=P+Math.imul(ue,tn)|0,A=A+Math.imul(ue,fn)|0,A=A+Math.imul(xe,tn)|0,$=$+Math.imul(xe,fn)|0,P=P+Math.imul(ve,We)|0,A=A+Math.imul(ve,hn)|0,A=A+Math.imul(ke,We)|0,$=$+Math.imul(ke,hn)|0,P=P+Math.imul(ce,dn)|0,A=A+Math.imul(ce,pn)|0,A=A+Math.imul(Le,dn)|0,$=$+Math.imul(Le,pn)|0,P=P+Math.imul(Yt,gn)|0,A=A+Math.imul(Yt,yn)|0,A=A+Math.imul(ie,gn)|0,$=$+Math.imul(ie,yn)|0,P=P+Math.imul(Vt,mn)|0,A=A+Math.imul(Vt,wn)|0,A=A+Math.imul(Ut,mn)|0,$=$+Math.imul(Ut,wn)|0;var of=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(of>>>26)|0,of&=67108863,P=Math.imul(E,cn),A=Math.imul(E,un),A=A+Math.imul(D,cn)|0,$=Math.imul(D,un),P=P+Math.imul(Ue,Xe)|0,A=A+Math.imul(Ue,ln)|0,A=A+Math.imul(O,Xe)|0,$=$+Math.imul(O,ln)|0,P=P+Math.imul(me,tn)|0,A=A+Math.imul(me,fn)|0,A=A+Math.imul(Te,tn)|0,$=$+Math.imul(Te,fn)|0,P=P+Math.imul(ue,We)|0,A=A+Math.imul(ue,hn)|0,A=A+Math.imul(xe,We)|0,$=$+Math.imul(xe,hn)|0,P=P+Math.imul(ve,dn)|0,A=A+Math.imul(ve,pn)|0,A=A+Math.imul(ke,dn)|0,$=$+Math.imul(ke,pn)|0,P=P+Math.imul(ce,gn)|0,A=A+Math.imul(ce,yn)|0,A=A+Math.imul(Le,gn)|0,$=$+Math.imul(Le,yn)|0,P=P+Math.imul(Yt,mn)|0,A=A+Math.imul(Yt,wn)|0,A=A+Math.imul(ie,mn)|0,$=$+Math.imul(ie,wn)|0;var af=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(af>>>26)|0,af&=67108863,P=Math.imul(E,Xe),A=Math.imul(E,ln),A=A+Math.imul(D,Xe)|0,$=Math.imul(D,ln),P=P+Math.imul(Ue,tn)|0,A=A+Math.imul(Ue,fn)|0,A=A+Math.imul(O,tn)|0,$=$+Math.imul(O,fn)|0,P=P+Math.imul(me,We)|0,A=A+Math.imul(me,hn)|0,A=A+Math.imul(Te,We)|0,$=$+Math.imul(Te,hn)|0,P=P+Math.imul(ue,dn)|0,A=A+Math.imul(ue,pn)|0,A=A+Math.imul(xe,dn)|0,$=$+Math.imul(xe,pn)|0,P=P+Math.imul(ve,gn)|0,A=A+Math.imul(ve,yn)|0,A=A+Math.imul(ke,gn)|0,$=$+Math.imul(ke,yn)|0,P=P+Math.imul(ce,mn)|0,A=A+Math.imul(ce,wn)|0,A=A+Math.imul(Le,mn)|0,$=$+Math.imul(Le,wn)|0;var Uc=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(Uc>>>26)|0,Uc&=67108863,P=Math.imul(E,tn),A=Math.imul(E,fn),A=A+Math.imul(D,tn)|0,$=Math.imul(D,fn),P=P+Math.imul(Ue,We)|0,A=A+Math.imul(Ue,hn)|0,A=A+Math.imul(O,We)|0,$=$+Math.imul(O,hn)|0,P=P+Math.imul(me,dn)|0,A=A+Math.imul(me,pn)|0,A=A+Math.imul(Te,dn)|0,$=$+Math.imul(Te,pn)|0,P=P+Math.imul(ue,gn)|0,A=A+Math.imul(ue,yn)|0,A=A+Math.imul(xe,gn)|0,$=$+Math.imul(xe,yn)|0,P=P+Math.imul(ve,mn)|0,A=A+Math.imul(ve,wn)|0,A=A+Math.imul(ke,mn)|0,$=$+Math.imul(ke,wn)|0;var cf=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(cf>>>26)|0,cf&=67108863,P=Math.imul(E,We),A=Math.imul(E,hn),A=A+Math.imul(D,We)|0,$=Math.imul(D,hn),P=P+Math.imul(Ue,dn)|0,A=A+Math.imul(Ue,pn)|0,A=A+Math.imul(O,dn)|0,$=$+Math.imul(O,pn)|0,P=P+Math.imul(me,gn)|0,A=A+Math.imul(me,yn)|0,A=A+Math.imul(Te,gn)|0,$=$+Math.imul(Te,yn)|0,P=P+Math.imul(ue,mn)|0,A=A+Math.imul(ue,wn)|0,A=A+Math.imul(xe,mn)|0,$=$+Math.imul(xe,wn)|0;var uf=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(uf>>>26)|0,uf&=67108863,P=Math.imul(E,dn),A=Math.imul(E,pn),A=A+Math.imul(D,dn)|0,$=Math.imul(D,pn),P=P+Math.imul(Ue,gn)|0,A=A+Math.imul(Ue,yn)|0,A=A+Math.imul(O,gn)|0,$=$+Math.imul(O,yn)|0,P=P+Math.imul(me,mn)|0,A=A+Math.imul(me,wn)|0,A=A+Math.imul(Te,mn)|0,$=$+Math.imul(Te,wn)|0;var lf=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(lf>>>26)|0,lf&=67108863,P=Math.imul(E,gn),A=Math.imul(E,yn),A=A+Math.imul(D,gn)|0,$=Math.imul(D,yn),P=P+Math.imul(Ue,mn)|0,A=A+Math.imul(Ue,wn)|0,A=A+Math.imul(O,mn)|0,$=$+Math.imul(O,wn)|0;var ff=(z+P|0)+((A&8191)<<13)|0;z=($+(A>>>13)|0)+(ff>>>26)|0,ff&=67108863,P=Math.imul(E,mn),A=Math.imul(E,wn),A=A+Math.imul(D,mn)|0,$=Math.imul(D,wn);var ao=(z+P|0)+((A&8191)<<13)|0;return z=($+(A>>>13)|0)+(ao>>>26)|0,ao&=67108863,M[0]=Yl,M[1]=Mc,M[2]=Xl,M[3]=tf,M[4]=ef,M[5]=nf,M[6]=Lc,M[7]=rf,M[8]=gs,M[9]=sf,M[10]=di,M[11]=of,M[12]=af,M[13]=Uc,M[14]=cf,M[15]=uf,M[16]=lf,M[17]=ff,M[18]=ao,z!==0&&(M[19]=z,v.length++),v};Math.imul||(H=B);function U(C,p,m){m.negative=p.negative^C.negative,m.length=C.length+p.length;for(var v=0,k=0,N=0;N<m.length-1;N++){var M=k;k=0;for(var z=v&67108863,P=Math.min(N,p.length-1),A=Math.max(0,N-C.length+1);A<=P;A++){var $=N-A,ct=C.words[$]|0,ft=p.words[A]|0,wt=ct*ft,Ht=wt&67108863;M=M+(wt/67108864|0)|0,Ht=Ht+z|0,z=Ht&67108863,M=M+(Ht>>>26)|0,k+=M>>>26,M&=67108863}m.words[N]=z,v=M,M=k}return v!==0?m.words[N]=v:m.length--,m._strip()}function G(C,p,m){return U(C,p,m)}s.prototype.mulTo=function(p,m){var v,k=this.length+p.length;return this.length===10&&p.length===10?v=H(this,p,m):k<63?v=B(this,p,m):k<1024?v=U(this,p,m):v=G(this,p,m),v},s.prototype.mul=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),this.mulTo(p,m)},s.prototype.mulf=function(p){var m=new s(null);return m.words=new Array(this.length+p.length),G(this,p,m)},s.prototype.imul=function(p){return this.clone().mulTo(p,this)},s.prototype.imuln=function(p){var m=p<0;m&&(p=-p),r(typeof p=="number"),r(p<67108864);for(var v=0,k=0;k<this.length;k++){var N=(this.words[k]|0)*p,M=(N&67108863)+(v&67108863);v>>=26,v+=N/67108864|0,v+=M>>>26,this.words[k]=M&67108863}return v!==0&&(this.words[k]=v,this.length++),m?this.ineg():this},s.prototype.muln=function(p){return this.clone().imuln(p)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(p){var m=I(p);if(m.length===0)return new s(1);for(var v=this,k=0;k<m.length&&m[k]===0;k++,v=v.sqr());if(++k<m.length)for(var N=v.sqr();k<m.length;k++,N=N.sqr())m[k]!==0&&(v=v.mul(N));return v},s.prototype.iushln=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26,k=67108863>>>26-m<<26-m,N;if(m!==0){var M=0;for(N=0;N<this.length;N++){var z=this.words[N]&k,P=(this.words[N]|0)-z<<m;this.words[N]=P|M,M=z>>>26-m}M&&(this.words[N]=M,this.length++)}if(v!==0){for(N=this.length-1;N>=0;N--)this.words[N+v]=this.words[N];for(N=0;N<v;N++)this.words[N]=0;this.length+=v}return this._strip()},s.prototype.ishln=function(p){return r(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,m,v){r(typeof p=="number"&&p>=0);var k;m?k=(m-m%26)/26:k=0;var N=p%26,M=Math.min((p-N)/26,this.length),z=67108863^67108863>>>N<<N,P=v;if(k-=M,k=Math.max(0,k),P){for(var A=0;A<M;A++)P.words[A]=this.words[A];P.length=M}if(M!==0)if(this.length>M)for(this.length-=M,A=0;A<this.length;A++)this.words[A]=this.words[A+M];else this.words[0]=0,this.length=1;var $=0;for(A=this.length-1;A>=0&&($!==0||A>=k);A--){var ct=this.words[A]|0;this.words[A]=$<<26-N|ct>>>N,$=ct&z}return P&&$!==0&&(P.words[P.length++]=$),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(p,m,v){return r(this.negative===0),this.iushrn(p,m,v)},s.prototype.shln=function(p){return this.clone().ishln(p)},s.prototype.ushln=function(p){return this.clone().iushln(p)},s.prototype.shrn=function(p){return this.clone().ishrn(p)},s.prototype.ushrn=function(p){return this.clone().iushrn(p)},s.prototype.testn=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26,k=1<<m;if(this.length<=v)return!1;var N=this.words[v];return!!(N&k)},s.prototype.imaskn=function(p){r(typeof p=="number"&&p>=0);var m=p%26,v=(p-m)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(m!==0&&v++,this.length=Math.min(v,this.length),m!==0){var k=67108863^67108863>>>m<<m;this.words[this.length-1]&=k}return this._strip()},s.prototype.maskn=function(p){return this.clone().imaskn(p)},s.prototype.iaddn=function(p){return r(typeof p=="number"),r(p<67108864),p<0?this.isubn(-p):this.negative!==0?this.length===1&&(this.words[0]|0)<=p?(this.words[0]=p-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(p),this.negative=1,this):this._iaddn(p)},s.prototype._iaddn=function(p){this.words[0]+=p;for(var m=0;m<this.length&&this.words[m]>=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},s.prototype.isubn=function(p){if(r(typeof p=="number"),r(p<67108864),p<0)return this.iaddn(-p);if(this.negative!==0)return this.negative=0,this.iaddn(p),this.negative=1,this;if(this.words[0]-=p,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m<this.length&&this.words[m]<0;m++)this.words[m]+=67108864,this.words[m+1]-=1;return this._strip()},s.prototype.addn=function(p){return this.clone().iaddn(p)},s.prototype.subn=function(p){return this.clone().isubn(p)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(p,m,v){var k=p.length+v,N;this._expand(k);var M,z=0;for(N=0;N<p.length;N++){M=(this.words[N+v]|0)+z;var P=(p.words[N]|0)*m;M-=P&67108863,z=(M>>26)-(P/67108864|0),this.words[N+v]=M&67108863}for(;N<this.length-v;N++)M=(this.words[N+v]|0)+z,z=M>>26,this.words[N+v]=M&67108863;if(z===0)return this._strip();for(r(z===-1),z=0,N=0;N<this.length;N++)M=-(this.words[N]|0)+z,z=M>>26,this.words[N]=M&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(p,m){var v=this.length-p.length,k=this.clone(),N=p,M=N.words[N.length-1]|0,z=this._countBits(M);v=26-z,v!==0&&(N=N.ushln(v),k.iushln(v),M=N.words[N.length-1]|0);var P=k.length-N.length,A;if(m!=="mod"){A=new s(null),A.length=P+1,A.words=new Array(A.length);for(var $=0;$<A.length;$++)A.words[$]=0}var ct=k.clone()._ishlnsubmul(N,1,P);ct.negative===0&&(k=ct,A&&(A.words[P]=1));for(var ft=P-1;ft>=0;ft--){var wt=(k.words[N.length+ft]|0)*67108864+(k.words[N.length+ft-1]|0);for(wt=Math.min(wt/M|0,67108863),k._ishlnsubmul(N,wt,ft);k.negative!==0;)wt--,k.negative=0,k._ishlnsubmul(N,1,ft),k.isZero()||(k.negative^=1);A&&(A.words[ft]=wt)}return A&&A._strip(),k._strip(),m!=="div"&&v!==0&&k.iushrn(v),{div:A||null,mod:k}},s.prototype.divmod=function(p,m,v){if(r(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var k,N,M;return this.negative!==0&&p.negative===0?(M=this.neg().divmod(p,m),m!=="mod"&&(k=M.div.neg()),m!=="div"&&(N=M.mod.neg(),v&&N.negative!==0&&N.iadd(p)),{div:k,mod:N}):this.negative===0&&p.negative!==0?(M=this.divmod(p.neg(),m),m!=="mod"&&(k=M.div.neg()),{div:k,mod:M.mod}):this.negative&p.negative?(M=this.neg().divmod(p.neg(),m),m!=="div"&&(N=M.mod.neg(),v&&N.negative!==0&&N.isub(p)),{div:M.div,mod:N}):p.length>this.length||this.cmp(p)<0?{div:new s(0),mod:this}:p.length===1?m==="div"?{div:this.divn(p.words[0]),mod:null}:m==="mod"?{div:null,mod:new s(this.modrn(p.words[0]))}:{div:this.divn(p.words[0]),mod:new s(this.modrn(p.words[0]))}:this._wordDiv(p,m)},s.prototype.div=function(p){return this.divmod(p,"div",!1).div},s.prototype.mod=function(p){return this.divmod(p,"mod",!1).mod},s.prototype.umod=function(p){return this.divmod(p,"mod",!0).mod},s.prototype.divRound=function(p){var m=this.divmod(p);if(m.mod.isZero())return m.div;var v=m.div.negative!==0?m.mod.isub(p):m.mod,k=p.ushrn(1),N=p.andln(1),M=v.cmp(k);return M<0||N===1&&M===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},s.prototype.modrn=function(p){var m=p<0;m&&(p=-p),r(p<=67108863);for(var v=(1<<26)%p,k=0,N=this.length-1;N>=0;N--)k=(v*k+(this.words[N]|0))%p;return m?-k:k},s.prototype.modn=function(p){return this.modrn(p)},s.prototype.idivn=function(p){var m=p<0;m&&(p=-p),r(p<=67108863);for(var v=0,k=this.length-1;k>=0;k--){var N=(this.words[k]|0)+v*67108864;this.words[k]=N/p|0,v=N%p}return this._strip(),m?this.ineg():this},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){r(p.negative===0),r(!p.isZero());var m=this,v=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var k=new s(1),N=new s(0),M=new s(0),z=new s(1),P=0;m.isEven()&&v.isEven();)m.iushrn(1),v.iushrn(1),++P;for(var A=v.clone(),$=m.clone();!m.isZero();){for(var ct=0,ft=1;!(m.words[0]&ft)&&ct<26;++ct,ft<<=1);if(ct>0)for(m.iushrn(ct);ct-- >0;)(k.isOdd()||N.isOdd())&&(k.iadd(A),N.isub($)),k.iushrn(1),N.iushrn(1);for(var wt=0,Ht=1;!(v.words[0]&Ht)&&wt<26;++wt,Ht<<=1);if(wt>0)for(v.iushrn(wt);wt-- >0;)(M.isOdd()||z.isOdd())&&(M.iadd(A),z.isub($)),M.iushrn(1),z.iushrn(1);m.cmp(v)>=0?(m.isub(v),k.isub(M),N.isub(z)):(v.isub(m),M.isub(k),z.isub(N))}return{a:M,b:z,gcd:v.iushln(P)}},s.prototype._invmp=function(p){r(p.negative===0),r(!p.isZero());var m=this,v=p.clone();m.negative!==0?m=m.umod(p):m=m.clone();for(var k=new s(1),N=new s(0),M=v.clone();m.cmpn(1)>0&&v.cmpn(1)>0;){for(var z=0,P=1;!(m.words[0]&P)&&z<26;++z,P<<=1);if(z>0)for(m.iushrn(z);z-- >0;)k.isOdd()&&k.iadd(M),k.iushrn(1);for(var A=0,$=1;!(v.words[0]&$)&&A<26;++A,$<<=1);if(A>0)for(v.iushrn(A);A-- >0;)N.isOdd()&&N.iadd(M),N.iushrn(1);m.cmp(v)>=0?(m.isub(v),k.isub(N)):(v.isub(m),N.isub(k))}var ct;return m.cmpn(1)===0?ct=k:ct=N,ct.cmpn(0)<0&&ct.iadd(p),ct},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var m=this.clone(),v=p.clone();m.negative=0,v.negative=0;for(var k=0;m.isEven()&&v.isEven();k++)m.iushrn(1),v.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;v.isEven();)v.iushrn(1);var N=m.cmp(v);if(N<0){var M=m;m=v,v=M}else if(N===0||v.cmpn(1)===0)break;m.isub(v)}while(!0);return v.iushln(k)},s.prototype.invm=function(p){return this.egcd(p).a.umod(p)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(p){return this.words[0]&p},s.prototype.bincn=function(p){r(typeof p=="number");var m=p%26,v=(p-m)/26,k=1<<m;if(this.length<=v)return this._expand(v+1),this.words[v]|=k,this;for(var N=k,M=v;N!==0&&M<this.length;M++){var z=this.words[M]|0;z+=N,N=z>>>26,z&=67108863,this.words[M]=z}return N!==0&&(this.words[M]=N,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(p){var m=p<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this._strip();var v;if(this.length>1)v=1;else{m&&(p=-p),r(p<=67108863,"Number is too big");var k=this.words[0]|0;v=k===p?0:k<p?-1:1}return this.negative!==0?-v|0:v},s.prototype.cmp=function(p){if(this.negative!==0&&p.negative===0)return-1;if(this.negative===0&&p.negative!==0)return 1;var m=this.ucmp(p);return this.negative!==0?-m|0:m},s.prototype.ucmp=function(p){if(this.length>p.length)return 1;if(this.length<p.length)return-1;for(var m=0,v=this.length-1;v>=0;v--){var k=this.words[v]|0,N=p.words[v]|0;if(k!==N){k<N?m=-1:k>N&&(m=1);break}}return m},s.prototype.gtn=function(p){return this.cmpn(p)===1},s.prototype.gt=function(p){return this.cmp(p)===1},s.prototype.gten=function(p){return this.cmpn(p)>=0},s.prototype.gte=function(p){return this.cmp(p)>=0},s.prototype.ltn=function(p){return this.cmpn(p)===-1},s.prototype.lt=function(p){return this.cmp(p)===-1},s.prototype.lten=function(p){return this.cmpn(p)<=0},s.prototype.lte=function(p){return this.cmp(p)<=0},s.prototype.eqn=function(p){return this.cmpn(p)===0},s.prototype.eq=function(p){return this.cmp(p)===0},s.red=function(p){return new rt(p)},s.prototype.toRed=function(p){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(p){return this.red=p,this},s.prototype.forceRed=function(p){return r(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},s.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(p){return r(this.red&&!p.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,p)};var W={k256:null,p224:null,p192:null,p25519:null};function X(C,p){this.name=C,this.p=new s(p,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}X.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},X.prototype.ireduce=function(p){var m=p,v;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),v=m.bitLength();while(v>this.n);var k=v<this.n?-1:m.ucmp(this.p);return k===0?(m.words[0]=0,m.length=1):k>0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},X.prototype.split=function(p,m){p.iushrn(this.n,0,m)},X.prototype.imulK=function(p){return p.imul(this.k)};function j(){X.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(j,X),j.prototype.split=function(p,m){for(var v=4194303,k=Math.min(p.length,9),N=0;N<k;N++)m.words[N]=p.words[N];if(m.length=k,p.length<=9){p.words[0]=0,p.length=1;return}var M=p.words[9];for(m.words[m.length++]=M&v,N=10;N<p.length;N++){var z=p.words[N]|0;p.words[N-10]=(z&v)<<4|M>>>22,M=z}M>>>=22,p.words[N-10]=M,M===0&&p.length>10?p.length-=10:p.length-=9},j.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var m=0,v=0;v<p.length;v++){var k=p.words[v]|0;m+=k*977,p.words[v]=m&67108863,m=k*64+(m/67108864|0)}return p.words[p.length-1]===0&&(p.length--,p.words[p.length-1]===0&&p.length--),p};function Y(){X.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(Y,X);function it(){X.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(it,X);function ut(){X.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(ut,X),ut.prototype.imulK=function(p){for(var m=0,v=0;v<p.length;v++){var k=(p.words[v]|0)*19+m,N=k&67108863;k>>>=26,p.words[v]=N,m=k}return m!==0&&(p.words[p.length++]=m),p},s._prime=function(p){if(W[p])return W[p];var m;if(p==="k256")m=new j;else if(p==="p224")m=new Y;else if(p==="p192")m=new it;else if(p==="p25519")m=new ut;else throw new Error("Unknown prime "+p);return W[p]=m,m};function rt(C){if(typeof C=="string"){var p=s._prime(C);this.m=p.p,this.prime=p}else r(C.gtn(1),"modulus must be greater than 1"),this.m=C,this.prime=null}rt.prototype._verify1=function(p){r(p.negative===0,"red works only with positives"),r(p.red,"red works only with red numbers")},rt.prototype._verify2=function(p,m){r((p.negative|m.negative)===0,"red works only with positives"),r(p.red&&p.red===m.red,"red works only with red numbers")},rt.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):(h(p,p.umod(this.m)._forceRed(this)),p)},rt.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},rt.prototype.add=function(p,m){this._verify2(p,m);var v=p.add(m);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},rt.prototype.iadd=function(p,m){this._verify2(p,m);var v=p.iadd(m);return v.cmp(this.m)>=0&&v.isub(this.m),v},rt.prototype.sub=function(p,m){this._verify2(p,m);var v=p.sub(m);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},rt.prototype.isub=function(p,m){this._verify2(p,m);var v=p.isub(m);return v.cmpn(0)<0&&v.iadd(this.m),v},rt.prototype.shl=function(p,m){return this._verify1(p),this.imod(p.ushln(m))},rt.prototype.imul=function(p,m){return this._verify2(p,m),this.imod(p.imul(m))},rt.prototype.mul=function(p,m){return this._verify2(p,m),this.imod(p.mul(m))},rt.prototype.isqr=function(p){return this.imul(p,p.clone())},rt.prototype.sqr=function(p){return this.mul(p,p)},rt.prototype.sqrt=function(p){if(p.isZero())return p.clone();var m=this.m.andln(3);if(r(m%2===1),m===3){var v=this.m.add(new s(1)).iushrn(2);return this.pow(p,v)}for(var k=this.m.subn(1),N=0;!k.isZero()&&k.andln(1)===0;)N++,k.iushrn(1);r(!k.isZero());var M=new s(1).toRed(this),z=M.redNeg(),P=this.m.subn(1).iushrn(1),A=this.m.bitLength();for(A=new s(2*A*A).toRed(this);this.pow(A,P).cmp(z)!==0;)A.redIAdd(z);for(var $=this.pow(A,k),ct=this.pow(p,k.addn(1).iushrn(1)),ft=this.pow(p,k),wt=N;ft.cmp(M)!==0;){for(var Ht=ft,Lt=0;Ht.cmp(M)!==0;Lt++)Ht=Ht.redSqr();r(Lt<wt);var Mt=this.pow($,new s(1).iushln(wt-Lt-1));ct=ct.redMul(Mt),$=Mt.redSqr(),ft=ft.redMul($),wt=Lt}return ct},rt.prototype.invm=function(p){var m=p._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},rt.prototype.pow=function(p,m){if(m.isZero())return new s(1).toRed(this);if(m.cmpn(1)===0)return p.clone();var v=4,k=new Array(1<<v);k[0]=new s(1).toRed(this),k[1]=p;for(var N=2;N<k.length;N++)k[N]=this.mul(k[N-1],p);var M=k[0],z=0,P=0,A=m.bitLength()%26;for(A===0&&(A=26),N=m.length-1;N>=0;N--){for(var $=m.words[N],ct=A-1;ct>=0;ct--){var ft=$>>ct&1;if(M!==k[0]&&(M=this.sqr(M)),ft===0&&z===0){P=0;continue}z<<=1,z|=ft,P++,!(P!==v&&(N!==0||ct!==0))&&(M=this.mul(M,k[z]),P=0,z=0)}A=26}return M},rt.prototype.convertTo=function(p){var m=p.umod(this.m);return m===p?m.clone():m},rt.prototype.convertFrom=function(p){var m=p.clone();return m.red=null,m},s.mont=function(p){return new ot(p)};function ot(C){rt.call(this,C),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(ot,rt),ot.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},ot.prototype.convertFrom=function(p){var m=this.imod(p.mul(this.rinv));return m.red=null,m},ot.prototype.imul=function(p,m){if(p.isZero()||m.isZero())return p.words[0]=0,p.length=1,p;var v=p.imul(m),k=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=v.isub(k).iushrn(this.shift),M=N;return N.cmp(this.m)>=0?M=N.isub(this.m):N.cmpn(0)<0&&(M=N.iadd(this.m)),M._forceRed(this)},ot.prototype.mul=function(p,m){if(p.isZero()||m.isZero())return new s(0)._forceRed(this);var v=p.mul(m),k=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),N=v.isub(k).iushrn(this.shift),M=N;return N.cmp(this.m)>=0?M=N.isub(this.m):N.cmpn(0)<0&&(M=N.iadd(this.m)),M._forceRed(this)},ot.prototype.invm=function(p){var m=this.imod(p._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(n,qn)})(f1);var d1=f1.exports;const Gs=ua(d1);function B0(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function xU(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function ed(n,...t){if(!xU(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error("Uint8Array expected of length "+t+", got length="+n.length)}function RU(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");B0(n.outputLen),B0(n.blockLen)}function yl(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function t2(n,t){ed(n);const e=t.outputLen;if(n.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}const Vc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function IU(n){return new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4))}function Uy(n){return new DataView(n.buffer,n.byteOffset,n.byteLength)}function Mi(n,t){return n<<32-t|n>>>t}const EA=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function SU(n){return n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255}function vA(n){for(let t=0;t<n.length;t++)n[t]=SU(n[t])}function kU(n){if(typeof n!="string")throw new Error("utf8ToBytes expected string, got "+typeof n);return new Uint8Array(new TextEncoder().encode(n))}function xp(n){return typeof n=="string"&&(n=kU(n)),ed(n),n}function TU(...n){let t=0;for(let r=0;r<n.length;r++){const i=n[r];ed(i),t+=i.length}const e=new Uint8Array(t);for(let r=0,i=0;r<n.length;r++){const s=n[r];e.set(s,i),i+=s.length}return e}let p1=class{clone(){return this._cloneInto()}};function g1(n){const t=r=>n().update(xp(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function e2(n=32){if(Vc&&typeof Vc.getRandomValues=="function")return Vc.getRandomValues(new Uint8Array(n));if(Vc&&typeof Vc.randomBytes=="function")return Vc.randomBytes(n);throw new Error("crypto.getRandomValues must be defined")}function OU(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),a=Number(e&s),u=r?4:0,f=r?0:4;n.setUint32(t+u,o,r),n.setUint32(t+f,a,r)}function NU(n,t,e){return n&t^~n&e}function CU(n,t,e){return n&t^n&e^t&e}class n2 extends p1{constructor(t,e,r,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Uy(this.buffer)}update(t){yl(this);const{view:e,buffer:r,blockLen:i}=this;t=xp(t);const s=t.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const u=Uy(t);for(;i<=s-o;o+=i)this.process(u,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){yl(this),t2(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let y=o;y<i;y++)e[y]=0;OU(r,i-8,BigInt(this.length*8),s),this.process(r,0);const a=Uy(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<f;y++)a.setUint32(4*y,h[y],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:i,finished:s,destroyed:o,pos:a}=this;return t.length=i,t.pos=a,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(r),t}}const Ud=BigInt(2**32-1),qm=BigInt(32);function r2(n,t=!1){return t?{h:Number(n&Ud),l:Number(n>>qm&Ud)}:{h:Number(n>>qm&Ud)|0,l:Number(n&Ud)|0}}function i2(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let i=0;i<n.length;i++){const{h:s,l:o}=r2(n[i],t);[e[i],r[i]]=[s,o]}return[e,r]}const BU=(n,t)=>BigInt(n>>>0)<<qm|BigInt(t>>>0),PU=(n,t,e)=>n>>>e,MU=(n,t,e)=>n<<32-e|t>>>e,LU=(n,t,e)=>n>>>e|t<<32-e,UU=(n,t,e)=>n<<32-e|t>>>e,DU=(n,t,e)=>n<<64-e|t>>>e-32,FU=(n,t,e)=>n>>>e-32|t<<64-e,$U=(n,t)=>t,HU=(n,t)=>n,s2=(n,t,e)=>n<<e|t>>>32-e,o2=(n,t,e)=>t<<e|n>>>32-e,a2=(n,t,e)=>t<<e-32|n>>>64-e,c2=(n,t,e)=>n<<e-32|t>>>64-e;function zU(n,t,e,r){const i=(t>>>0)+(r>>>0);return{h:n+e+(i/2**32|0)|0,l:i|0}}const GU=(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),VU=(n,t,e,r)=>t+e+r+(n/2**32|0)|0,KU=(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),jU=(n,t,e,r,i)=>t+e+r+i+(n/2**32|0)|0,WU=(n,t,e,r,i)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),ZU=(n,t,e,r,i,s)=>t+e+r+i+s+(n/2**32|0)|0,Xt={fromBig:r2,split:i2,toBig:BU,shrSH:PU,shrSL:MU,rotrSH:LU,rotrSL:UU,rotrBH:DU,rotrBL:FU,rotr32H:$U,rotr32L:HU,rotlSH:s2,rotlSL:o2,rotlBH:a2,rotlBL:c2,add:zU,add3L:GU,add3H:VU,add4L:KU,add4H:jU,add5H:ZU,add5L:WU},[qU,QU]=Xt.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),lo=new Uint32Array(80),fo=new Uint32Array(80);let JU=class extends n2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:i,Ch:s,Cl:o,Dh:a,Dl:u,Eh:f,El:h,Fh:y,Fl:_,Gh:w,Gl:R,Hh:T,Hl:I}=this;return[t,e,r,i,s,o,a,u,f,h,y,_,w,R,T,I]}set(t,e,r,i,s,o,a,u,f,h,y,_,w,R,T,I){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=f|0,this.El=h|0,this.Fh=y|0,this.Fl=_|0,this.Gh=w|0,this.Gl=R|0,this.Hh=T|0,this.Hl=I|0}process(t,e){for(let U=0;U<16;U++,e+=4)lo[U]=t.getUint32(e),fo[U]=t.getUint32(e+=4);for(let U=16;U<80;U++){const G=lo[U-15]|0,W=fo[U-15]|0,X=Xt.rotrSH(G,W,1)^Xt.rotrSH(G,W,8)^Xt.shrSH(G,W,7),j=Xt.rotrSL(G,W,1)^Xt.rotrSL(G,W,8)^Xt.shrSL(G,W,7),Y=lo[U-2]|0,it=fo[U-2]|0,ut=Xt.rotrSH(Y,it,19)^Xt.rotrBH(Y,it,61)^Xt.shrSH(Y,it,6),rt=Xt.rotrSL(Y,it,19)^Xt.rotrBL(Y,it,61)^Xt.shrSL(Y,it,6),ot=Xt.add4L(j,rt,fo[U-7],fo[U-16]),C=Xt.add4H(ot,X,ut,lo[U-7],lo[U-16]);lo[U]=C|0,fo[U]=ot|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:a,Cl:u,Dh:f,Dl:h,Eh:y,El:_,Fh:w,Fl:R,Gh:T,Gl:I,Hh:B,Hl:H}=this;for(let U=0;U<80;U++){const G=Xt.rotrSH(y,_,14)^Xt.rotrSH(y,_,18)^Xt.rotrBH(y,_,41),W=Xt.rotrSL(y,_,14)^Xt.rotrSL(y,_,18)^Xt.rotrBL(y,_,41),X=y&w^~y&T,j=_&R^~_&I,Y=Xt.add5L(H,W,j,QU[U],fo[U]),it=Xt.add5H(Y,B,G,X,qU[U],lo[U]),ut=Y|0,rt=Xt.rotrSH(r,i,28)^Xt.rotrBH(r,i,34)^Xt.rotrBH(r,i,39),ot=Xt.rotrSL(r,i,28)^Xt.rotrBL(r,i,34)^Xt.rotrBL(r,i,39),C=r&s^r&a^s&a,p=i&o^i&u^o&u;B=T|0,H=I|0,T=w|0,I=R|0,w=y|0,R=_|0,{h:y,l:_}=Xt.add(f|0,h|0,it|0,ut|0),f=a|0,h=u|0,a=s|0,u=o|0,s=r|0,o=i|0;const m=Xt.add3L(ut,ot,p);r=Xt.add3H(m,it,rt,C),i=m|0}({h:r,l:i}=Xt.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=Xt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:u}=Xt.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:f,l:h}=Xt.add(this.Dh|0,this.Dl|0,f|0,h|0),{h:y,l:_}=Xt.add(this.Eh|0,this.El|0,y|0,_|0),{h:w,l:R}=Xt.add(this.Fh|0,this.Fl|0,w|0,R|0),{h:T,l:I}=Xt.add(this.Gh|0,this.Gl|0,T|0,I|0),{h:B,l:H}=Xt.add(this.Hh|0,this.Hl|0,B|0,H|0),this.set(r,i,s,o,a,u,f,h,y,_,w,R,T,I,B,H)}roundClean(){lo.fill(0),fo.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const YU=g1(()=>new JU);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Rp=BigInt(0),Ip=BigInt(1),XU=BigInt(2);function pc(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function nd(n){if(!pc(n))throw new Error("Uint8Array expected")}function Qs(n,t){if(typeof t!="boolean")throw new Error(n+" boolean expected, got "+t)}const tD=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function gc(n){nd(n);let t="";for(let e=0;e<n.length;e++)t+=tD[n[e]];return t}function ru(n){const t=n.toString(16);return t.length&1?"0"+t:t}function y1(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return n===""?Rp:BigInt("0x"+n)}const ws={_0:48,_9:57,A:65,F:70,a:97,f:102};function xA(n){if(n>=ws._0&&n<=ws._9)return n-ws._0;if(n>=ws.A&&n<=ws.F)return n-(ws.A-10);if(n>=ws.a&&n<=ws.f)return n-(ws.a-10)}function ml(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const t=n.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(e);for(let i=0,s=0;i<e;i++,s+=2){const o=xA(n.charCodeAt(s)),a=xA(n.charCodeAt(s+1));if(o===void 0||a===void 0){const u=n[s]+n[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}r[i]=o*16+a}return r}function ac(n){return y1(gc(n))}function du(n){return nd(n),y1(gc(Uint8Array.from(n).reverse()))}function wl(n,t){return ml(n.toString(16).padStart(t*2,"0"))}function fh(n,t){return wl(n,t).reverse()}function eD(n){return ml(ru(n))}function Sn(n,t,e){let r;if(typeof t=="string")try{r=ml(t)}catch(s){throw new Error(n+" must be hex string or Uint8Array, cause: "+s)}else if(pc(t))r=Uint8Array.from(t);else throw new Error(n+" must be hex string or Uint8Array");const i=r.length;if(typeof e=="number"&&i!==e)throw new Error(n+" of length "+e+" expected, got "+i);return r}function yc(...n){let t=0;for(let r=0;r<n.length;r++){const i=n[r];nd(i),t+=i.length}const e=new Uint8Array(t);for(let r=0,i=0;r<n.length;r++){const s=n[r];e.set(s,i),i+=s.length}return e}function nD(n,t){if(n.length!==t.length)return!1;let e=0;for(let r=0;r<n.length;r++)e|=n[r]^t[r];return e===0}function rD(n){if(typeof n!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(n))}const Dy=n=>typeof n=="bigint"&&Rp<=n;function Sp(n,t,e){return Dy(n)&&Dy(t)&&Dy(e)&&t<=n&&n<e}function ci(n,t,e,r){if(!Sp(t,e,r))throw new Error("expected valid "+n+": "+e+" <= n < "+r+", got "+t)}function u2(n){let t;for(t=0;n>Rp;n>>=Ip,t+=1);return t}function iD(n,t){return n>>BigInt(t)&Ip}function sD(n,t,e){return n|(e?Ip:Rp)<<BigInt(t)}const m1=n=>(XU<<BigInt(n-1))-Ip,Fy=n=>new Uint8Array(n),RA=n=>Uint8Array.from(n);function l2(n,t,e){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let r=Fy(n),i=Fy(n),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...y)=>e(i,r,...y),u=(y=Fy())=>{i=a(RA([0]),y),r=a(),y.length!==0&&(i=a(RA([1]),y),r=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let y=0;const _=[];for(;y<t;){r=a();const w=r.slice();_.push(w),y+=r.length}return yc(..._)};return(y,_)=>{o(),u(y);let w;for(;!(w=_(f()));)u();return o(),w}}const oD={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||pc(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,t)=>t.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function $l(n,t,e={}){const r=(i,s,o)=>{const a=oD[s];if(typeof a!="function")throw new Error("invalid validator function");const u=n[i];if(!(o&&u===void 0)&&!a(u,n))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+u)};for(const[i,s]of Object.entries(t))r(i,s,!1);for(const[i,s]of Object.entries(e))r(i,s,!0);return n}const aD=()=>{throw new Error("not implemented")};function hh(n){const t=new WeakMap;return(e,...r)=>{const i=t.get(e);if(i!==void 0)return i;const s=n(e,...r);return t.set(e,s),s}}const cD=Object.freeze(Object.defineProperty({__proto__:null,aInRange:ci,abool:Qs,abytes:nd,bitGet:iD,bitLen:u2,bitMask:m1,bitSet:sD,bytesToHex:gc,bytesToNumberBE:ac,bytesToNumberLE:du,concatBytes:yc,createHmacDrbg:l2,ensureBytes:Sn,equalBytes:nD,hexToBytes:ml,hexToNumber:y1,inRange:Sp,isBytes:pc,memoized:hh,notImplemented:aD,numberToBytesBE:wl,numberToBytesLE:fh,numberToHexUnpadded:ru,numberToVarBytesBE:eD,utf8ToBytes:rD,validateObject:$l},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fn=BigInt(0),rn=BigInt(1),_a=BigInt(2),uD=BigInt(3),Qm=BigInt(4),IA=BigInt(5),SA=BigInt(8);function Qe(n,t){const e=n%t;return e>=Fn?e:t+e}function lD(n,t,e){if(t<Fn)throw new Error("invalid exponent, negatives unsupported");if(e<=Fn)throw new Error("invalid modulus");if(e===rn)return Fn;let r=rn;for(;t>Fn;)t&rn&&(r=r*n%e),n=n*n%e,t>>=rn;return r}function bn(n,t,e){let r=n;for(;t-- >Fn;)r*=r,r%=e;return r}function Jm(n,t){if(n===Fn)throw new Error("invert: expected non-zero number");if(t<=Fn)throw new Error("invert: expected positive modulus, got "+t);let e=Qe(n,t),r=t,i=Fn,s=rn;for(;e!==Fn;){const a=r/e,u=r%e,f=i-s*a;r=e,e=u,i=s,s=f}if(r!==rn)throw new Error("invert: does not exist");return Qe(i,t)}function fD(n){const t=(n-rn)/_a;let e,r,i;for(e=n-rn,r=0;e%_a===Fn;e/=_a,r++);for(i=_a;i<n&&lD(i,t,n)!==n-rn;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const o=(n+rn)/Qm;return function(u,f){const h=u.pow(f,o);if(!u.eql(u.sqr(h),f))throw new Error("Cannot find square root");return h}}const s=(e+rn)/_a;return function(a,u){if(a.pow(u,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=r,h=a.pow(a.mul(a.ONE,i),e),y=a.pow(u,s),_=a.pow(u,e);for(;!a.eql(_,a.ONE);){if(a.eql(_,a.ZERO))return a.ZERO;let w=1;for(let T=a.sqr(_);w<f&&!a.eql(T,a.ONE);w++)T=a.sqr(T);const R=a.pow(h,rn<<BigInt(f-w-1));h=a.sqr(R),y=a.mul(y,R),_=a.mul(_,h),f=w}return y}}function hD(n){if(n%Qm===uD){const t=(n+rn)/Qm;return function(r,i){const s=r.pow(i,t);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(n%SA===IA){const t=(n-IA)/SA;return function(r,i){const s=r.mul(i,_a),o=r.pow(s,t),a=r.mul(i,o),u=r.mul(r.mul(a,_a),o),f=r.mul(a,r.sub(u,r.ONE));if(!r.eql(r.sqr(f),i))throw new Error("Cannot find square root");return f}}return fD(n)}const dD=(n,t)=>(Qe(n,t)&rn)===rn,pD=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gD(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=pD.reduce((r,i)=>(r[i]="function",r),t);return $l(n,e)}function yD(n,t,e){if(e<Fn)throw new Error("invalid exponent, negatives unsupported");if(e===Fn)return n.ONE;if(e===rn)return t;let r=n.ONE,i=t;for(;e>Fn;)e&rn&&(r=n.mul(r,i)),i=n.sqr(i),e>>=rn;return r}function mD(n,t){const e=new Array(t.length),r=t.reduce((s,o,a)=>n.is0(o)?s:(e[a]=s,n.mul(s,o)),n.ONE),i=n.inv(r);return t.reduceRight((s,o,a)=>n.is0(o)?s:(e[a]=n.mul(s,e[a]),n.mul(s,o)),i),e}function f2(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function kp(n,t,e=!1,r={}){if(n<=Fn)throw new Error("invalid field: expected ORDER > 0, got "+n);const{nBitLength:i,nByteLength:s}=f2(n,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:n,isLE:e,BITS:i,BYTES:s,MASK:m1(i),ZERO:Fn,ONE:rn,create:u=>Qe(u,n),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return Fn<=u&&u<n},is0:u=>u===Fn,isOdd:u=>(u&rn)===rn,neg:u=>Qe(-u,n),eql:(u,f)=>u===f,sqr:u=>Qe(u*u,n),add:(u,f)=>Qe(u+f,n),sub:(u,f)=>Qe(u-f,n),mul:(u,f)=>Qe(u*f,n),pow:(u,f)=>yD(a,u,f),div:(u,f)=>Qe(u*Jm(f,n),n),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>Jm(u,n),sqrt:r.sqrt||(u=>(o||(o=hD(n)),o(a,u))),invertBatch:u=>mD(a,u),cmov:(u,f,h)=>h?f:u,toBytes:u=>e?fh(u,s):wl(u,s),fromBytes:u=>{if(u.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+u.length);return e?du(u):ac(u)}});return Object.freeze(a)}function h2(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function d2(n){const t=h2(n);return t+Math.ceil(t/2)}function wD(n,t,e=!1){const r=n.length,i=h2(t),s=d2(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const o=e?du(n):ac(n),a=Qe(o,t-rn)+rn;return e?fh(a,i):wl(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const kA=BigInt(0),Dd=BigInt(1);function $y(n,t){const e=t.negate();return n?e:t}function p2(n,t){if(!Number.isSafeInteger(n)||n<=0||n>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+n)}function Hy(n,t){p2(n,t);const e=Math.ceil(t/n)+1,r=2**(n-1);return{windows:e,windowSize:r}}function bD(n,t){if(!Array.isArray(n))throw new Error("array expected");n.forEach((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)})}function _D(n,t){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)})}const zy=new WeakMap,g2=new WeakMap;function Gy(n){return g2.get(n)||1}function y2(n,t){return{constTimeNegate:$y,hasPrecomputes(e){return Gy(e)!==1},unsafeLadder(e,r,i=n.ZERO){let s=e;for(;r>kA;)r&Dd&&(i=i.add(s)),s=s.double(),r>>=Dd;return i},precomputeWindow(e,r){const{windows:i,windowSize:s}=Hy(r,t),o=[];let a=e,u=a;for(let f=0;f<i;f++){u=a,o.push(u);for(let h=1;h<s;h++)u=u.add(a),o.push(u);a=u.double()}return o},wNAF(e,r,i){const{windows:s,windowSize:o}=Hy(e,t);let a=n.ZERO,u=n.BASE;const f=BigInt(2**e-1),h=2**e,y=BigInt(e);for(let _=0;_<s;_++){const w=_*o;let R=Number(i&f);i>>=y,R>o&&(R-=h,i+=Dd);const T=w,I=w+Math.abs(R)-1,B=_%2!==0,H=R<0;R===0?u=u.add($y(B,r[T])):a=a.add($y(H,r[I]))}return{p:a,f:u}},wNAFUnsafe(e,r,i,s=n.ZERO){const{windows:o,windowSize:a}=Hy(e,t),u=BigInt(2**e-1),f=2**e,h=BigInt(e);for(let y=0;y<o;y++){const _=y*a;if(i===kA)break;let w=Number(i&u);if(i>>=h,w>a&&(w-=f,i+=Dd),w===0)continue;let R=r[_+Math.abs(w)-1];w<0&&(R=R.negate()),s=s.add(R)}return s},getPrecomputes(e,r,i){let s=zy.get(r);return s||(s=this.precomputeWindow(r,e),e!==1&&zy.set(r,i(s))),s},wNAFCached(e,r,i){const s=Gy(e);return this.wNAF(s,this.getPrecomputes(s,e,i),r)},wNAFCachedUnsafe(e,r,i,s){const o=Gy(e);return o===1?this.unsafeLadder(e,r,s):this.wNAFUnsafe(o,this.getPrecomputes(o,e,i),r,s)},setWindowSize(e,r){p2(r,t),g2.set(e,r),zy.delete(e)}}}function m2(n,t,e,r){if(bD(e,n),_D(r,t),e.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=n.ZERO,s=u2(BigInt(e.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,u=new Array(a+1).fill(i),f=Math.floor((t.BITS-1)/o)*o;let h=i;for(let y=f;y>=0;y-=o){u.fill(i);for(let w=0;w<r.length;w++){const R=r[w],T=Number(R>>BigInt(y)&BigInt(a));u[T]=u[T].add(e[w])}let _=i;for(let w=u.length-1,R=i;w>0;w--)R=R.add(u[w]),_=_.add(R);if(h=h.add(_),y!==0)for(let w=0;w<o;w++)h=h.double()}return h}function w1(n){return gD(n.Fp),$l(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...f2(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const pi=BigInt(0),Er=BigInt(1),Fd=BigInt(2),AD=BigInt(8),ED={zip215:!0};function vD(n){const t=w1(n);return $l(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function xD(n){const t=vD(n),{Fp:e,n:r,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:u}=t,f=Fd<<BigInt(a*8)-Er,h=e.create,y=kp(t.n,t.nBitLength),_=t.uvRatio||((v,k)=>{try{return{isValid:!0,value:e.sqrt(v*e.inv(k))}}catch{return{isValid:!1,value:pi}}}),w=t.adjustScalarBytes||(v=>v),R=t.domain||((v,k,N)=>{if(Qs("phflag",N),k.length||N)throw new Error("Contexts/pre-hash are not supported");return v});function T(v,k){ci("coordinate "+v,k,pi,f)}function I(v){if(!(v instanceof U))throw new Error("ExtendedPoint expected")}const B=hh((v,k)=>{const{ex:N,ey:M,ez:z}=v,P=v.is0();k==null&&(k=P?AD:e.inv(z));const A=h(N*k),$=h(M*k),ct=h(z*k);if(P)return{x:pi,y:Er};if(ct!==Er)throw new Error("invZ was invalid");return{x:A,y:$}}),H=hh(v=>{const{a:k,d:N}=t;if(v.is0())throw new Error("bad point: ZERO");const{ex:M,ey:z,ez:P,et:A}=v,$=h(M*M),ct=h(z*z),ft=h(P*P),wt=h(ft*ft),Ht=h($*k),Lt=h(ft*h(Ht+ct)),Mt=h(wt+h(N*h($*ct)));if(Lt!==Mt)throw new Error("bad point: equation left != right (1)");const Ee=h(M*z),Vt=h(P*A);if(Ee!==Vt)throw new Error("bad point: equation left != right (2)");return!0});class U{constructor(k,N,M,z){this.ex=k,this.ey=N,this.ez=M,this.et=z,T("x",k),T("y",N),T("z",M),T("t",z),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(k){if(k instanceof U)throw new Error("extended point not allowed");const{x:N,y:M}=k||{};return T("x",N),T("y",M),new U(N,M,Er,h(N*M))}static normalizeZ(k){const N=e.invertBatch(k.map(M=>M.ez));return k.map((M,z)=>M.toAffine(N[z])).map(U.fromAffine)}static msm(k,N){return m2(U,y,k,N)}_setWindowSize(k){X.setWindowSize(this,k)}assertValidity(){H(this)}equals(k){I(k);const{ex:N,ey:M,ez:z}=this,{ex:P,ey:A,ez:$}=k,ct=h(N*$),ft=h(P*z),wt=h(M*$),Ht=h(A*z);return ct===ft&&wt===Ht}is0(){return this.equals(U.ZERO)}negate(){return new U(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:k}=t,{ex:N,ey:M,ez:z}=this,P=h(N*N),A=h(M*M),$=h(Fd*h(z*z)),ct=h(k*P),ft=N+M,wt=h(h(ft*ft)-P-A),Ht=ct+A,Lt=Ht-$,Mt=ct-A,Ee=h(wt*Lt),Vt=h(Ht*Mt),Ut=h(wt*Mt),Ie=h(Lt*Ht);return new U(Ee,Vt,Ie,Ut)}add(k){I(k);const{a:N,d:M}=t,{ex:z,ey:P,ez:A,et:$}=this,{ex:ct,ey:ft,ez:wt,et:Ht}=k;if(N===BigInt(-1)){const ve=h((P-z)*(ft+ct)),ke=h((P+z)*(ft-ct)),An=h(ke-ve);if(An===pi)return this.double();const ue=h(A*Fd*Ht),xe=h($*Fd*wt),Ye=xe+ue,me=ke+ve,Te=xe-ue,Yn=h(Ye*An),Ue=h(me*Te),O=h(Ye*Te),b=h(An*me);return new U(Yn,Ue,b,O)}const Lt=h(z*ct),Mt=h(P*ft),Ee=h($*M*Ht),Vt=h(A*wt),Ut=h((z+P)*(ct+ft)-Lt-Mt),Ie=Vt-Ee,Yt=Vt+Ee,ie=h(Mt-N*Lt),Je=h(Ut*Ie),ce=h(Yt*ie),Le=h(Ut*ie),oo=h(Ie*Yt);return new U(Je,ce,oo,Le)}subtract(k){return this.add(k.negate())}wNAF(k){return X.wNAFCached(this,k,U.normalizeZ)}multiply(k){const N=k;ci("scalar",N,Er,r);const{p:M,f:z}=this.wNAF(N);return U.normalizeZ([M,z])[0]}multiplyUnsafe(k,N=U.ZERO){const M=k;return ci("scalar",M,pi,r),M===pi?W:this.is0()||M===Er?this:X.wNAFCachedUnsafe(this,M,U.normalizeZ,N)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return X.unsafeLadder(this,r).is0()}toAffine(k){return B(this,k)}clearCofactor(){const{h:k}=t;return k===Er?this:this.multiplyUnsafe(k)}static fromHex(k,N=!1){const{d:M,a:z}=t,P=e.BYTES;k=Sn("pointHex",k,P),Qs("zip215",N);const A=k.slice(),$=k[P-1];A[P-1]=$&-129;const ct=du(A),ft=N?f:e.ORDER;ci("pointHex.y",ct,pi,ft);const wt=h(ct*ct),Ht=h(wt-Er),Lt=h(M*wt-z);let{isValid:Mt,value:Ee}=_(Ht,Lt);if(!Mt)throw new Error("Point.fromHex: invalid y coordinate");const Vt=(Ee&Er)===Er,Ut=($&128)!==0;if(!N&&Ee===pi&&Ut)throw new Error("Point.fromHex: x=0 and x_0=1");return Ut!==Vt&&(Ee=h(-Ee)),U.fromAffine({x:Ee,y:ct})}static fromPrivateKey(k){return it(k).point}toRawBytes(){const{x:k,y:N}=this.toAffine(),M=fh(N,e.BYTES);return M[M.length-1]|=k&Er?128:0,M}toHex(){return gc(this.toRawBytes())}}U.BASE=new U(t.Gx,t.Gy,Er,h(t.Gx*t.Gy)),U.ZERO=new U(pi,Er,Er,pi);const{BASE:G,ZERO:W}=U,X=y2(U,a*8);function j(v){return Qe(v,r)}function Y(v){return j(du(v))}function it(v){const k=e.BYTES;v=Sn("private key",v,k);const N=Sn("hashed private key",s(v),2*k),M=w(N.slice(0,k)),z=N.slice(k,2*k),P=Y(M),A=G.multiply(P),$=A.toRawBytes();return{head:M,prefix:z,scalar:P,point:A,pointBytes:$}}function ut(v){return it(v).pointBytes}function rt(v=new Uint8Array,...k){const N=yc(...k);return Y(s(R(N,Sn("context",v),!!i)))}function ot(v,k,N={}){v=Sn("message",v),i&&(v=i(v));const{prefix:M,scalar:z,pointBytes:P}=it(k),A=rt(N.context,M,v),$=G.multiply(A).toRawBytes(),ct=rt(N.context,$,P,v),ft=j(A+ct*z);ci("signature.s",ft,pi,r);const wt=yc($,fh(ft,e.BYTES));return Sn("result",wt,e.BYTES*2)}const C=ED;function p(v,k,N,M=C){const{context:z,zip215:P}=M,A=e.BYTES;v=Sn("signature",v,2*A),k=Sn("message",k),N=Sn("publicKey",N,A),P!==void 0&&Qs("zip215",P),i&&(k=i(k));const $=du(v.slice(A,2*A));let ct,ft,wt;try{ct=U.fromHex(N,P),ft=U.fromHex(v.slice(0,A),P),wt=G.multiplyUnsafe($)}catch{return!1}if(!P&&ct.isSmallOrder())return!1;const Ht=rt(z,ft.toRawBytes(),ct.toRawBytes(),k);return ft.add(ct.multiplyUnsafe(Ht)).subtract(wt).clearCofactor().equals(U.ZERO)}return G._setWindowSize(8),{CURVE:t,getPublicKey:ut,sign:ot,verify:p,ExtendedPoint:U,utils:{getExtendedPublicKey:it,randomPrivateKey:()=>o(e.BYTES),precompute(v=8,k=U.BASE){return k._setWindowSize(v),k.multiply(BigInt(3)),k}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const b1=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),TA=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const RD=BigInt(1),OA=BigInt(2);BigInt(3);const ID=BigInt(5),SD=BigInt(8);function kD(n){const t=BigInt(10),e=BigInt(20),r=BigInt(40),i=BigInt(80),s=b1,a=n*n%s*n%s,u=bn(a,OA,s)*a%s,f=bn(u,RD,s)*n%s,h=bn(f,ID,s)*f%s,y=bn(h,t,s)*h%s,_=bn(y,e,s)*y%s,w=bn(_,r,s)*_%s,R=bn(w,i,s)*w%s,T=bn(R,i,s)*w%s,I=bn(T,t,s)*h%s;return{pow_p_5_8:bn(I,OA,s)*n%s,b2:a}}function TD(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function OD(n,t){const e=b1,r=Qe(t*t*t,e),i=Qe(r*r*t,e),s=kD(n*i).pow_p_5_8;let o=Qe(n*r*s,e);const a=Qe(t*o*o,e),u=o,f=Qe(o*TA,e),h=a===n,y=a===Qe(-n,e),_=a===Qe(-n*TA,e);return h&&(o=u),(y||_)&&(o=f),dD(o,e)&&(o=Qe(-o,e)),{isValid:h||y,value:o}}const ND=kp(b1,void 0,!0),CD={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ND,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:SD,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:YU,randomBytes:e2,adjustScalarBytes:TD,uvRatio:OD},Hl=xD(CD);var Ym={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,t){var e=h1,r=e.Buffer;function i(o,a){for(var u in o)a[u]=o[u]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(i(e,t),t.Buffer=s);function s(o,a,u){return r(o,a,u)}s.prototype=Object.create(r.prototype),i(r,s),s.from=function(o,a,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,u)},s.alloc=function(o,a,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var f=r(o);return a!==void 0?typeof u=="string"?f.fill(a,u):f.fill(a):f.fill(0),f},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(Ym,Ym.exports);var BD=Ym.exports,$d=BD.Buffer;function PD(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),e=0;e<t.length;e++)t[e]=255;for(var r=0;r<n.length;r++){var i=n.charAt(r),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=r}var o=n.length,a=n.charAt(0),u=Math.log(o)/Math.log(256),f=Math.log(256)/Math.log(o);function h(w){if((Array.isArray(w)||w instanceof Uint8Array)&&(w=$d.from(w)),!$d.isBuffer(w))throw new TypeError("Expected Buffer");if(w.length===0)return"";for(var R=0,T=0,I=0,B=w.length;I!==B&&w[I]===0;)I++,R++;for(var H=(B-I)*f+1>>>0,U=new Uint8Array(H);I!==B;){for(var G=w[I],W=0,X=H-1;(G!==0||W<T)&&X!==-1;X--,W++)G+=256*U[X]>>>0,U[X]=G%o>>>0,G=G/o>>>0;if(G!==0)throw new Error("Non-zero carry");T=W,I++}for(var j=H-T;j!==H&&U[j]===0;)j++;for(var Y=a.repeat(R);j<H;++j)Y+=n.charAt(U[j]);return Y}function y(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return $d.alloc(0);for(var R=0,T=0,I=0;w[R]===a;)T++,R++;for(var B=(w.length-R)*u+1>>>0,H=new Uint8Array(B);R<w.length;){var U=w.charCodeAt(R);if(U>255)return;var G=t[U];if(G===255)return;for(var W=0,X=B-1;(G!==0||W<I)&&X!==-1;X--,W++)G+=o*H[X]>>>0,H[X]=G%256>>>0,G=G/256>>>0;if(G!==0)throw new Error("Non-zero carry");I=W,R++}for(var j=B-I;j!==B&&H[j]===0;)j++;var Y=$d.allocUnsafe(T+(B-j));Y.fill(0,0,T);for(var it=T;j!==B;)Y[it++]=H[j++];return Y}function _(w){var R=y(w);if(R)return R;throw new Error("Non-base"+o+" character")}return{encode:h,decodeUnsafe:y,decode:_}}var MD=PD,LD=MD,UD="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",w2=LD(UD);const kn=ua(w2),DD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ho=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),po=new Uint32Array(64);let FD=class extends n2{constructor(){super(64,32,8,!1),this.A=ho[0]|0,this.B=ho[1]|0,this.C=ho[2]|0,this.D=ho[3]|0,this.E=ho[4]|0,this.F=ho[5]|0,this.G=ho[6]|0,this.H=ho[7]|0}get(){const{A:t,B:e,C:r,D:i,E:s,F:o,G:a,H:u}=this;return[t,e,r,i,s,o,a,u]}set(t,e,r,i,s,o,a,u){this.A=t|0,this.B=e|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=u|0}process(t,e){for(let y=0;y<16;y++,e+=4)po[y]=t.getUint32(e,!1);for(let y=16;y<64;y++){const _=po[y-15],w=po[y-2],R=Mi(_,7)^Mi(_,18)^_>>>3,T=Mi(w,17)^Mi(w,19)^w>>>10;po[y]=T+po[y-7]+R+po[y-16]|0}let{A:r,B:i,C:s,D:o,E:a,F:u,G:f,H:h}=this;for(let y=0;y<64;y++){const _=Mi(a,6)^Mi(a,11)^Mi(a,25),w=h+_+NU(a,u,f)+DD[y]+po[y]|0,T=(Mi(r,2)^Mi(r,13)^Mi(r,22))+CU(r,i,s)|0;h=f,f=u,u=a,a=o+w|0,o=s,s=i,i=r,r=w+T|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(r,i,s,o,a,u,f,h)}roundClean(){po.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Xm=g1(()=>new FD);var jn={};function Vs(n,t,e){return t<=n&&n<=e}function Tp(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function $D(n){for(var t=String(n),e=t.length,r=0,i=[];r<e;){var s=t.charCodeAt(r);if(s<55296||s>57343)i.push(s);else if(56320<=s&&s<=57343)i.push(65533);else if(55296<=s&&s<=56319)if(r===e-1)i.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=s&1023,u=o&1023;i.push(65536+(a<<10)+u),r+=1}else i.push(65533)}r+=1}return i}function HD(n){for(var t="",e=0;e<n.length;++e){var r=n[e];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}var P0=-1;function _1(n){this.tokens=[].slice.call(n)}_1.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():P0},prepend:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.push(t.shift());else this.tokens.push(n)}};var bl=-1;function Vy(n,t){if(n)throw TypeError("Decoder error");return t||65533}var M0="utf-8";function L0(n,t){if(!(this instanceof L0))return new L0(n,t);if(n=n!==void 0?String(n).toLowerCase():M0,n!==M0)throw new Error("Encoding not supported. Only utf-8 is supported");t=Tp(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}L0.prototype={decode:function(t,e){var r;typeof t=="object"&&t instanceof ArrayBuffer?r=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):r=new Uint8Array(0),e=Tp(e),this._streaming||(this._decoder=new zD({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var i=new _1(r),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==bl);)o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o));if(!this._streaming){do{if(o=this._decoder.handler(i,i.read()),o===bl)break;o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o))}while(!i.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),HD(s)}};function U0(n,t){if(!(this instanceof U0))return new U0(n,t);if(n=n!==void 0?String(n).toLowerCase():M0,n!==M0)throw new Error("Encoding not supported. Only utf-8 is supported");t=Tp(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}U0.prototype={encode:function(t,e){t=t?String(t):"",e=Tp(e),this._streaming||(this._encoder=new GD(this._options)),this._streaming=!!e.stream;for(var r=[],i=new _1($D(t)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==bl);)Array.isArray(s)?r.push.apply(r,s):r.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==bl;)Array.isArray(s)?r.push.apply(r,s):r.push(s);this._encoder=null}return new Uint8Array(r)}};function zD(n){var t=n.fatal,e=0,r=0,i=0,s=128,o=191;this.handler=function(a,u){if(u===P0&&i!==0)return i=0,Vy(t);if(u===P0)return bl;if(i===0){if(Vs(u,0,127))return u;if(Vs(u,194,223))i=1,e=u-192;else if(Vs(u,224,239))u===224&&(s=160),u===237&&(o=159),i=2,e=u-224;else if(Vs(u,240,244))u===240&&(s=144),u===244&&(o=143),i=3,e=u-240;else return Vy(t);return e=e<<6*i,null}if(!Vs(u,s,o))return e=i=r=0,s=128,o=191,a.prepend(u),Vy(t);if(s=128,o=191,r+=1,e+=u-128<<6*(i-r),r!==i)return null;var f=e;return e=i=r=0,f}}function GD(n){n.fatal,this.handler=function(t,e){if(e===P0)return bl;if(Vs(e,0,127))return e;var r,i;Vs(e,128,2047)?(r=1,i=192):Vs(e,2048,65535)?(r=2,i=224):Vs(e,65536,1114111)&&(r=3,i=240);for(var s=[(e>>6*r)+i];r>0;){var o=e>>6*(r-1);s.push(128|o&63),r-=1}return s}}const VD=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:L0,TextEncoder:U0},Symbol.toStringTag,{value:"Module"})),KD=gp(VD);var jD=qn&&qn.__createBinding||(Object.create?function(n,t,e,r){r===void 0&&(r=e),Object.defineProperty(n,r,{enumerable:!0,get:function(){return t[e]}})}:function(n,t,e,r){r===void 0&&(r=e),n[r]=t[e]}),WD=qn&&qn.__setModuleDefault||(Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t}),fs=qn&&qn.__decorate||function(n,t,e,r){var i=arguments.length,s=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(s=(i<3?o(s):i>3?o(t,e,s):o(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s},ZD=qn&&qn.__importStar||function(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e in n)e!=="default"&&Object.hasOwnProperty.call(n,e)&&jD(t,n,e);return WD(t,n),t},b2=qn&&qn.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(jn,"__esModule",{value:!0});var _2=jn.deserializeUnchecked=I2=jn.deserialize=R2=jn.serialize=jn.BinaryReader=jn.BinaryWriter=jn.BorshError=jn.baseDecode=jn.baseEncode=void 0;const Ko=b2(d1),A2=b2(w2),qD=ZD(KD),QD=typeof TextDecoder!="function"?qD.TextDecoder:TextDecoder,JD=new QD("utf-8",{fatal:!0});function YD(n){return typeof n=="string"&&(n=Zt.from(n,"utf8")),A2.default.encode(Zt.from(n))}jn.baseEncode=YD;function XD(n){return Zt.from(A2.default.decode(n))}jn.baseDecode=XD;const Ky=1024;class pr extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}jn.BorshError=pr;class E2{constructor(){this.buf=Zt.alloc(Ky),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Zt.concat([this.buf,Zt.alloc(Ky)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Zt.from(new Ko.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Zt.from(new Ko.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Zt.from(new Ko.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Zt.from(new Ko.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Zt.concat([Zt.from(this.buf.subarray(0,this.length)),t,Zt.alloc(Ky)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Zt.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Zt.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}jn.BinaryWriter=E2;function hs(n,t,e){const r=e.value;e.value=function(...i){try{return r.apply(this,i)}catch(s){if(s instanceof RangeError){const o=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new pr("Reached the end of buffer when deserializing")}throw s}}}class Wr{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new Ko.default(t,"le")}readU128(){const t=this.readBuffer(16);return new Ko.default(t,"le")}readU256(){const t=this.readBuffer(32);return new Ko.default(t,"le")}readU512(){const t=this.readBuffer(64);return new Ko.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new pr(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return JD.decode(e)}catch(r){throw new pr(`Error decoding UTF-8 string: ${r}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let i=0;i<e;++i)r.push(t());return r}}fs([hs],Wr.prototype,"readU8",null);fs([hs],Wr.prototype,"readU16",null);fs([hs],Wr.prototype,"readU32",null);fs([hs],Wr.prototype,"readU64",null);fs([hs],Wr.prototype,"readU128",null);fs([hs],Wr.prototype,"readU256",null);fs([hs],Wr.prototype,"readU512",null);fs([hs],Wr.prototype,"readString",null);fs([hs],Wr.prototype,"readFixedArray",null);fs([hs],Wr.prototype,"readArray",null);jn.BinaryReader=Wr;function v2(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Aa(n,t,e,r,i){try{if(typeof r=="string")i[`write${v2(r)}`](e);else if(r instanceof Array)if(typeof r[0]=="number"){if(e.length!==r[0])throw new pr(`Expecting byte array of length ${r[0]}, but got ${e.length} bytes`);i.writeFixedArray(e)}else if(r.length===2&&typeof r[1]=="number"){if(e.length!==r[1])throw new pr(`Expecting byte array of length ${r[1]}, but got ${e.length} bytes`);for(let s=0;s<r[1];s++)Aa(n,null,e[s],r[0],i)}else i.writeArray(e,s=>{Aa(n,t,s,r[0],i)});else if(r.kind!==void 0)switch(r.kind){case"option":{e==null?i.writeU8(0):(i.writeU8(1),Aa(n,t,e,r.type,i));break}case"map":{i.writeU32(e.size),e.forEach((s,o)=>{Aa(n,t,o,r.key,i),Aa(n,t,s,r.value,i)});break}default:throw new pr(`FieldType ${r} unrecognized`)}else x2(n,e,i)}catch(s){throw s instanceof pr&&s.addToFieldPath(t),s}}function x2(n,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const r=n.get(t.constructor);if(!r)throw new pr(`Class ${t.constructor.name} is missing in schema`);if(r.kind==="struct")r.fields.map(([i,s])=>{Aa(n,i,t[i],s,e)});else if(r.kind==="enum"){const i=t[r.field];for(let s=0;s<r.values.length;++s){const[o,a]=r.values[s];if(o===i){e.writeU8(s),Aa(n,o,t[o],a,e);break}}}else throw new pr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function t9(n,t,e=E2){const r=new e;return x2(n,t,r),r.toArray()}var R2=jn.serialize=t9;function Ea(n,t,e,r){try{if(typeof e=="string")return r[`read${v2(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return r.readFixedArray(e[0]);if(typeof e[1]=="number"){const i=[];for(let s=0;s<e[1];s++)i.push(Ea(n,null,e[0],r));return i}else return r.readArray(()=>Ea(n,t,e[0],r))}if(e.kind==="option")return r.readU8()?Ea(n,t,e.type,r):void 0;if(e.kind==="map"){let i=new Map;const s=r.readU32();for(let o=0;o<s;o++){const a=Ea(n,t,e.key,r),u=Ea(n,t,e.value,r);i.set(a,u)}return i}return A1(n,e,r)}catch(i){throw i instanceof pr&&i.addToFieldPath(t),i}}function A1(n,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const r=n.get(t);if(!r)throw new pr(`Class ${t.name} is missing in schema`);if(r.kind==="struct"){const i={};for(const[s,o]of n.get(t).fields)i[s]=Ea(n,s,o,e);return new t(i)}if(r.kind==="enum"){const i=e.readU8();if(i>=r.values.length)throw new pr(`Enum index: ${i} is out of range`);const[s,o]=r.values[i],a=Ea(n,s,o,e);return new t({[s]:a})}throw new pr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function e9(n,t,e,r=Wr){const i=new r(e),s=A1(n,t,i);if(i.offset<e.length)throw new pr(`Unexpected ${e.length-i.offset} bytes after deserialized data`);return s}var I2=jn.deserialize=e9;function n9(n,t,e,r=Wr){const i=new r(e);return A1(n,t,i)}_2=jn.deserializeUnchecked=n9;var nt={};Object.defineProperty(nt,"__esModule",{value:!0});nt.s16=nt.s8=nt.nu64be=nt.u48be=nt.u40be=nt.u32be=nt.u24be=nt.u16be=Gn=nt.nu64=nt.u48=nt.u40=Tt=nt.u32=nt.u24=ai=nt.u16=ge=nt.u8=Zo=nt.offset=nt.greedy=nt.Constant=nt.UTF8=nt.CString=nt.Blob=nt.Boolean=nt.BitField=nt.BitStructure=nt.VariantLayout=nt.Union=nt.UnionLayoutDiscriminator=nt.UnionDiscriminator=nt.Structure=nt.Sequence=nt.DoubleBE=nt.Double=nt.FloatBE=nt.Float=nt.NearInt64BE=nt.NearInt64=nt.NearUInt64BE=nt.NearUInt64=nt.IntBE=nt.Int=nt.UIntBE=nt.UInt=nt.OffsetLayout=nt.GreedyCount=nt.ExternalLayout=nt.bindConstructorLayout=nt.nameWithProperty=nt.Layout=nt.uint8ArrayToBuffer=nt.checkUint8Array=void 0;nt.constant=nt.utf8=nt.cstr=Ve=nt.blob=nt.unionLayoutDiscriminator=nt.union=Qn=nt.seq=nt.bits=Ot=nt.struct=nt.f64be=nt.f64=nt.f32be=nt.f32=nt.ns64be=nt.s48be=nt.s40be=nt.s32be=nt.s24be=nt.s16be=Gr=nt.ns64=nt.s48=nt.s40=nt.s32=nt.s24=void 0;const E1=h1;function zl(n){if(!(n instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}nt.checkUint8Array=zl;function _e(n){return zl(n),E1.Buffer.from(n.buffer,n.byteOffset,n.length)}nt.uint8ArrayToBuffer=_e;let Ne=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};nt.Layout=Ne;function v1(n,t){return t.property?n+"["+t.property+"]":n}nt.nameWithProperty=v1;function r9(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(n,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Ne))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(n,"decode",{value(e,r){return t.decode(e,r)},writable:!0})}nt.bindConstructorLayout=r9;let Tr=class extends Ne{isCount(){throw new Error("ExternalLayout is abstract")}};nt.ExternalLayout=Tr;let S2=class extends Tr{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){zl(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}};nt.GreedyCount=S2;let x1=class extends Tr{constructor(t,e=0,r){if(!(t instanceof Ne))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof li||this.layout instanceof Ii}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,r=0){return this.layout.encode(t,e,r+this.offset)}};nt.OffsetLayout=x1;let li=class extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return _e(t).readUIntLE(e,this.span)}encode(t,e,r=0){return _e(e).writeUIntLE(t,r,this.span),this.span}};nt.UInt=li;let Ii=class extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return _e(t).readUIntBE(e,this.span)}encode(t,e,r=0){return _e(e).writeUIntBE(t,r,this.span),this.span}};nt.UIntBE=Ii;let kc=class extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return _e(t).readIntLE(e,this.span)}encode(t,e,r=0){return _e(e).writeIntLE(t,r,this.span),this.span}};nt.Int=kc;let Gl=class extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return _e(t).readIntBE(e,this.span)}encode(t,e,r=0){return _e(e).writeIntBE(t,r,this.span),this.span}};nt.IntBE=Gl;const tw=Math.pow(2,32);function Op(n){const t=Math.floor(n/tw),e=n-t*tw;return{hi32:t,lo32:e}}function Np(n,t){return n*tw+t}let k2=class extends Ne{constructor(t){super(8,t)}decode(t,e=0){const r=_e(t),i=r.readUInt32LE(e),s=r.readUInt32LE(e+4);return Np(s,i)}encode(t,e,r=0){const i=Op(t),s=_e(e);return s.writeUInt32LE(i.lo32,r),s.writeUInt32LE(i.hi32,r+4),8}};nt.NearUInt64=k2;let T2=class extends Ne{constructor(t){super(8,t)}decode(t,e=0){const r=_e(t),i=r.readUInt32BE(e),s=r.readUInt32BE(e+4);return Np(i,s)}encode(t,e,r=0){const i=Op(t),s=_e(e);return s.writeUInt32BE(i.hi32,r),s.writeUInt32BE(i.lo32,r+4),8}};nt.NearUInt64BE=T2;let O2=class extends Ne{constructor(t){super(8,t)}decode(t,e=0){const r=_e(t),i=r.readUInt32LE(e),s=r.readInt32LE(e+4);return Np(s,i)}encode(t,e,r=0){const i=Op(t),s=_e(e);return s.writeUInt32LE(i.lo32,r),s.writeInt32LE(i.hi32,r+4),8}};nt.NearInt64=O2;let N2=class extends Ne{constructor(t){super(8,t)}decode(t,e=0){const r=_e(t),i=r.readInt32BE(e),s=r.readUInt32BE(e+4);return Np(i,s)}encode(t,e,r=0){const i=Op(t),s=_e(e);return s.writeInt32BE(i.hi32,r),s.writeUInt32BE(i.lo32,r+4),8}};nt.NearInt64BE=N2;let C2=class extends Ne{constructor(t){super(4,t)}decode(t,e=0){return _e(t).readFloatLE(e)}encode(t,e,r=0){return _e(e).writeFloatLE(t,r),4}};nt.Float=C2;let B2=class extends Ne{constructor(t){super(4,t)}decode(t,e=0){return _e(t).readFloatBE(e)}encode(t,e,r=0){return _e(e).writeFloatBE(t,r),4}};nt.FloatBE=B2;let P2=class extends Ne{constructor(t){super(8,t)}decode(t,e=0){return _e(t).readDoubleLE(e)}encode(t,e,r=0){return _e(e).writeDoubleLE(t,r),8}};nt.Double=P2;let M2=class extends Ne{constructor(t){super(8,t)}decode(t,e=0){return _e(t).readDoubleBE(e)}encode(t,e,r=0){return _e(e).writeDoubleBE(t,r),8}};nt.DoubleBE=M2;let L2=class extends Ne{constructor(t,e,r){if(!(t instanceof Ne))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Tr&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(e instanceof Tr)&&0<t.span&&(i=e*t.span),super(i,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,i=this.count;if(i instanceof Tr&&(i=i.decode(t,e)),0<this.elementLayout.span)r=i*this.elementLayout.span;else{let s=0;for(;s<i;)r+=this.elementLayout.getSpan(t,e+r),++s}return r}decode(t,e=0){const r=[];let i=0,s=this.count;for(s instanceof Tr&&(s=s.decode(t,e));i<s;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),i+=1;return r}encode(t,e,r=0){const i=this.elementLayout,s=t.reduce((o,a)=>o+i.encode(a,e,r+o),0);return this.count instanceof Tr&&this.count.encode(t.length,e,r),s}};nt.Sequence=L2;let U2=class extends Ne{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Ne,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e=0){zl(t);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const i=r;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const f=t[a.property];f!==void 0&&(o=a.encode(f,e,r),0>u&&(u=a.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}};nt.Structure=U2;let R1=class{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}};nt.UnionDiscriminator=R1;let D0=class extends R1{constructor(t,e){if(!(t instanceof Tr&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}};nt.UnionLayoutDiscriminator=D0;let I1=class extends Ne{constructor(t,e,r){let i;if(t instanceof li||t instanceof Ii)i=new D0(new x1(t));else if(t instanceof Tr&&t.isCount())i=new D0(t);else if(t instanceof R1)i=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Ne))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&(t instanceof li||t instanceof Ii)&&(s+=i.layout.span)),super(s,r),this.discriminator=i,this.usesPrefixDiscriminator=t instanceof li||t instanceof Ii,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const i=this.discriminator,s=i.decode(t,e),o=this.registry[s];if(o===void 0){const a=this.defaultLayout;let u=0;this.usesPrefixDiscriminator&&(u=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[a.property]=a.decode(t,e+u)}else r=o.decode(t,e);return r}encode(t,e,r=0){const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(t[s.property],e,r),a+o.encode(t[o.property],e,r+a)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new D2(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e=0){let r;return t instanceof Uint8Array?r=this.discriminator.decode(t,e):r=t,this.registry[r]}};nt.Union=I1;let D2=class extends Ne{constructor(t,e,r,i){if(!(t instanceof I1))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Ne))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(t,e+r)),r+i}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};nt.VariantLayout=D2;function Jc(n){return 0>n&&(n+=4294967296),n}let S1=class extends Ne{constructor(t,e,r){if(!(t instanceof li||t instanceof Ii))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&r===void 0&&(r=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let i=0;this._packedSetValue=function(s){return i=Jc(s),this},this._packedGetValue=function(){return i}}decode(t,e=0){const r=this.makeDestinationObject(),i=this.word.decode(t,e);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(r[s.property]=s.decode(t));return r}encode(t,e,r=0){const i=this.word.decode(e,r);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=t[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new k1(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new F2(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}};nt.BitStructure=S1;let k1=class{constructor(t,e,r){if(!(t instanceof S1))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const i=8*t.span,s=t.fields.reduce((o,a)=>o+a.bits,0);if(e+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-e),this.wordMask=Jc(this.valueMask<<this.start),this.property=r}decode(t,e){const r=this.container._packedGetValue();return Jc(r&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==Jc(t&this.valueMask))throw new TypeError(v1("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=Jc(t<<this.start);this.container._packedSetValue(Jc(e&~this.wordMask)|r)}};nt.BitField=k1;let F2=class extends k1{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){typeof t=="boolean"&&(t=+t),super.encode(t)}};nt.Boolean=F2;let $2=class extends Ne{constructor(t,e){if(!(t instanceof Tr&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Tr||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),_e(t).slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof Tr&&(i=t.length),!(t instanceof Uint8Array&&i===t.length))throw new TypeError(v1("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(r+i>e.length)throw new RangeError("encoding overruns Uint8Array");const s=_e(t);return _e(e).write(s.toString("hex"),r,i,"hex"),this.length instanceof Tr&&this.length.encode(i,e,r),i}};nt.Blob=$2;let H2=class extends Ne{constructor(t){super(-1,t)}getSpan(t,e=0){zl(t);let r=e;for(;r<t.length&&t[r]!==0;)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return _e(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const i=E1.Buffer.from(t,"utf8"),s=i.length;if(r+s>e.length)throw new RangeError("encoding overruns Buffer");const o=_e(e);return i.copy(o,r),o[r+s]=0,s+1}};nt.CString=H2;let z2=class extends Ne{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return zl(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return _e(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const i=E1.Buffer.from(t,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(_e(e),r),s}};nt.UTF8=z2;let G2=class extends Ne{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}};nt.Constant=G2;nt.greedy=(n,t)=>new S2(n,t);var Zo=nt.offset=(n,t,e)=>new x1(n,t,e),ge=nt.u8=n=>new li(1,n),ai=nt.u16=n=>new li(2,n);nt.u24=n=>new li(3,n);var Tt=nt.u32=n=>new li(4,n);nt.u40=n=>new li(5,n);nt.u48=n=>new li(6,n);var Gn=nt.nu64=n=>new k2(n);nt.u16be=n=>new Ii(2,n);nt.u24be=n=>new Ii(3,n);nt.u32be=n=>new Ii(4,n);nt.u40be=n=>new Ii(5,n);nt.u48be=n=>new Ii(6,n);nt.nu64be=n=>new T2(n);nt.s8=n=>new kc(1,n);nt.s16=n=>new kc(2,n);nt.s24=n=>new kc(3,n);nt.s32=n=>new kc(4,n);nt.s40=n=>new kc(5,n);nt.s48=n=>new kc(6,n);var Gr=nt.ns64=n=>new O2(n);nt.s16be=n=>new Gl(2,n);nt.s24be=n=>new Gl(3,n);nt.s32be=n=>new Gl(4,n);nt.s40be=n=>new Gl(5,n);nt.s48be=n=>new Gl(6,n);nt.ns64be=n=>new N2(n);nt.f32=n=>new C2(n);nt.f32be=n=>new B2(n);nt.f64=n=>new P2(n);nt.f64be=n=>new M2(n);var Ot=nt.struct=(n,t,e)=>new U2(n,t,e);nt.bits=(n,t,e)=>new S1(n,t,e);var Qn=nt.seq=(n,t,e)=>new L2(n,t,e);nt.union=(n,t,e)=>new I1(n,t,e);nt.unionLayoutDiscriminator=(n,t)=>new D0(n,t);var Ve=nt.blob=(n,t)=>new $2(n,t);nt.cstr=n=>new H2(n);nt.utf8=(n,t)=>new z2(n,t);nt.constant=(n,t)=>new G2(n,t);var rd={};Object.defineProperty(rd,"__esModule",{value:!0});function i9(n){{const t=Zt.from(n);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var s9=rd.toBigIntLE=i9;function o9(n){{const t=n.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}rd.toBigIntBE=o9;function a9(n,t){{const e=n.toString(16),r=Zt.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return r.reverse(),r}}var V2=rd.toBufferLE=a9;function c9(n,t){{const e=n.toString(16);return Zt.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}rd.toBufferBE=c9;let u9=class extends TypeError{constructor(t,e){let r;const{message:i,explanation:s,...o}=t,{path:a}=t,u=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??u),s!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}};function l9(n){return id(n)&&typeof n[Symbol.iterator]=="function"}function id(n){return typeof n=="object"&&n!=null}function F0(n){return id(n)&&!Array.isArray(n)}function ki(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function f9(n){const{done:t,value:e}=n.next();return t?void 0:e}function h9(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:i,branch:s}=t,{type:o}=e,{refinement:a,message:u=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${ki(r)}\``}=n;return{value:r,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...n,message:u}}function*NA(n,t,e,r){l9(n)||(n=[n]);for(const i of n){const s=h9(i,t,e,r);s&&(yield s)}}function*T1(n,t,e={}){const{path:r=[],branch:i=[n],coerce:s=!1,mask:o=!1}=e,a={path:r,branch:i,mask:o};s&&(n=t.coercer(n,a));let u="valid";for(const f of t.validator(n,a))f.explanation=e.message,u="not_valid",yield[f,void 0];for(let[f,h,y]of t.entries(n,a)){const _=T1(h,y,{path:f===void 0?r:[...r,f],branch:f===void 0?i:[...i,h],coerce:s,mask:o,message:e.message});for(const w of _)w[0]?(u=w[0].refinement!=null?"not_refined":"not_valid",yield[w[0],void 0]):s&&(h=w[1],f===void 0?n=h:n instanceof Map?n.set(f,h):n instanceof Set?n.add(h):id(n)&&(h!==void 0||f in n)&&(n[f]=h))}if(u!=="not_valid")for(const f of t.refiner(n,a))f.explanation=e.message,u="not_refined",yield[f,void 0];u==="valid"&&(yield[void 0,n])}let ds=class{constructor(t){const{type:e,schema:r,validator:i,refiner:s,coercer:o=u=>u,entries:a=function*(){}}=t;this.type=e,this.schema=r,this.entries=a,this.coercer=o,i?this.validator=(u,f)=>{const h=i(u,f);return NA(h,f,this,u)}:this.validator=()=>[],s?this.refiner=(u,f)=>{const h=s(u,f);return NA(h,f,this,u)}:this.refiner=()=>[]}assert(t,e){return K2(t,this,e)}create(t,e){return bt(t,this,e)}is(t){return j2(t,this)}mask(t,e){return d9(t,this,e)}validate(t,e={}){return sd(t,this,e)}};function K2(n,t,e){const r=sd(n,t,{message:e});if(r[0])throw r[0]}function bt(n,t,e){const r=sd(n,t,{coerce:!0,message:e});if(r[0])throw r[0];return r[1]}function d9(n,t,e){const r=sd(n,t,{coerce:!0,mask:!0,message:e});if(r[0])throw r[0];return r[1]}function j2(n,t){return!sd(n,t)[0]}function sd(n,t,e={}){const r=T1(n,t,e),i=f9(r);return i[0]?[new u9(i[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function Tc(n,t){return new ds({type:n,schema:null,validator:t})}function p9(){return Tc("any",()=>!0)}function Et(n){return new ds({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[e,r]of t.entries())yield[e,r,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${ki(t)}`}})}function ls(){return Tc("boolean",n=>typeof n=="boolean")}function O1(n){return Tc("instance",t=>t instanceof n||`Expected a \`${n.name}\` instance, but received: ${ki(t)}`)}function nn(n){const t=ki(n),e=typeof n;return new ds({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${t}\`, but received: ${ki(r)}`}})}function g9(){return Tc("never",()=>!1)}function vt(n){return new ds({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function tt(){return Tc("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${ki(n)}`)}function Dt(n){return new ds({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function W2(n,t){return new ds({type:"record",schema:null,*entries(e){if(id(e))for(const r in e){const i=e[r];yield[r,r,n],yield[r,i,t]}},validator(e){return F0(e)||`Expected an object, but received: ${ki(e)}`},coercer(e){return F0(e)?{...e}:e}})}function mt(){return Tc("string",n=>typeof n=="string"||`Expected a string, but received: ${ki(n)}`)}function N1(n){const t=g9();return new ds({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const r=Math.max(n.length,e.length);for(let i=0;i<r;i++)yield[i,e[i],n[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${ki(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function dt(n){const t=Object.keys(n);return new ds({type:"type",schema:n,*entries(e){if(id(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return F0(e)||`Expected an object, but received: ${ki(e)}`},coercer(e){return F0(e)?{...e}:e}})}function Ar(n){const t=n.map(e=>e.type).join(" | ");return new ds({type:"union",schema:null,coercer(e,r){for(const i of n){const[s,o]=i.validate(e,{coerce:!0,mask:r.mask});if(!s)return o}return e},validator(e,r){const i=[];for(const s of n){const[...o]=T1(e,s,r),[a]=o;if(a[0])for(const[u]of o)u&&i.push(u);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${ki(e)}`,...i]}})}function Vl(){return Tc("unknown",()=>!0)}function od(n,t,e){return new ds({...n,coercer:(r,i)=>j2(r,t)?n.coercer(e(r,i),i):n.coercer(r,i)})}var Hd,y9=new Uint8Array(16);function Z2(){if(!Hd&&(Hd=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Hd))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Hd(y9)}const m9=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Cp(n){return typeof n=="string"&&m9.test(n)}var zn=[];for(var jy=0;jy<256;++jy)zn.push((jy+256).toString(16).substr(1));function Bp(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(zn[n[t+0]]+zn[n[t+1]]+zn[n[t+2]]+zn[n[t+3]]+"-"+zn[n[t+4]]+zn[n[t+5]]+"-"+zn[n[t+6]]+zn[n[t+7]]+"-"+zn[n[t+8]]+zn[n[t+9]]+"-"+zn[n[t+10]]+zn[n[t+11]]+zn[n[t+12]]+zn[n[t+13]]+zn[n[t+14]]+zn[n[t+15]]).toLowerCase();if(!Cp(e))throw TypeError("Stringified UUID is invalid");return e}var CA,Wy,Zy=0,qy=0;function w9(n,t,e){var r=t&&e||0,i=t||new Array(16);n=n||{};var s=n.node||CA,o=n.clockseq!==void 0?n.clockseq:Wy;if(s==null||o==null){var a=n.random||(n.rng||Z2)();s==null&&(s=CA=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=Wy=(a[6]<<8|a[7])&16383)}var u=n.msecs!==void 0?n.msecs:Date.now(),f=n.nsecs!==void 0?n.nsecs:qy+1,h=u-Zy+(f-qy)/1e4;if(h<0&&n.clockseq===void 0&&(o=o+1&16383),(h<0||u>Zy)&&n.nsecs===void 0&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Zy=u,qy=f,Wy=o,u+=122192928e5;var y=((u&268435455)*1e4+f)%4294967296;i[r++]=y>>>24&255,i[r++]=y>>>16&255,i[r++]=y>>>8&255,i[r++]=y&255;var _=u/4294967296*1e4&268435455;i[r++]=_>>>8&255,i[r++]=_&255,i[r++]=_>>>24&15|16,i[r++]=_>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var w=0;w<6;++w)i[r+w]=s[w];return t||Bp(i)}function q2(n){if(!Cp(n))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(n.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(n.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(n.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(n.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(n.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function b9(n){n=unescape(encodeURIComponent(n));for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var _9="6ba7b810-9dad-11d1-80b4-00c04fd430c8",A9="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Q2(n,t,e){function r(i,s,o,a){if(typeof i=="string"&&(i=b9(i)),typeof s=="string"&&(s=q2(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+i.length);if(u.set(s),u.set(i,s.length),u=e(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,o){a=a||0;for(var f=0;f<16;++f)o[a+f]=u[f];return o}return Bp(u)}try{r.name=n}catch{}return r.DNS=_9,r.URL=A9,r}function E9(n){if(typeof n=="string"){var t=unescape(encodeURIComponent(n));n=new Uint8Array(t.length);for(var e=0;e<t.length;++e)n[e]=t.charCodeAt(e)}return v9(x9(R9(n),n.length*8))}function v9(n){for(var t=[],e=n.length*32,r="0123456789abcdef",i=0;i<e;i+=8){var s=n[i>>5]>>>i%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);t.push(o)}return t}function J2(n){return(n+64>>>9<<4)+14+1}function x9(n,t){n[t>>5]|=128<<t%32,n[J2(t)-1]=t;for(var e=1732584193,r=-271733879,i=-1732584194,s=271733878,o=0;o<n.length;o+=16){var a=e,u=r,f=i,h=s;e=tr(e,r,i,s,n[o],7,-680876936),s=tr(s,e,r,i,n[o+1],12,-389564586),i=tr(i,s,e,r,n[o+2],17,606105819),r=tr(r,i,s,e,n[o+3],22,-1044525330),e=tr(e,r,i,s,n[o+4],7,-176418897),s=tr(s,e,r,i,n[o+5],12,1200080426),i=tr(i,s,e,r,n[o+6],17,-1473231341),r=tr(r,i,s,e,n[o+7],22,-45705983),e=tr(e,r,i,s,n[o+8],7,1770035416),s=tr(s,e,r,i,n[o+9],12,-1958414417),i=tr(i,s,e,r,n[o+10],17,-42063),r=tr(r,i,s,e,n[o+11],22,-1990404162),e=tr(e,r,i,s,n[o+12],7,1804603682),s=tr(s,e,r,i,n[o+13],12,-40341101),i=tr(i,s,e,r,n[o+14],17,-1502002290),r=tr(r,i,s,e,n[o+15],22,1236535329),e=er(e,r,i,s,n[o+1],5,-165796510),s=er(s,e,r,i,n[o+6],9,-1069501632),i=er(i,s,e,r,n[o+11],14,643717713),r=er(r,i,s,e,n[o],20,-373897302),e=er(e,r,i,s,n[o+5],5,-701558691),s=er(s,e,r,i,n[o+10],9,38016083),i=er(i,s,e,r,n[o+15],14,-660478335),r=er(r,i,s,e,n[o+4],20,-405537848),e=er(e,r,i,s,n[o+9],5,568446438),s=er(s,e,r,i,n[o+14],9,-1019803690),i=er(i,s,e,r,n[o+3],14,-187363961),r=er(r,i,s,e,n[o+8],20,1163531501),e=er(e,r,i,s,n[o+13],5,-1444681467),s=er(s,e,r,i,n[o+2],9,-51403784),i=er(i,s,e,r,n[o+7],14,1735328473),r=er(r,i,s,e,n[o+12],20,-1926607734),e=nr(e,r,i,s,n[o+5],4,-378558),s=nr(s,e,r,i,n[o+8],11,-2022574463),i=nr(i,s,e,r,n[o+11],16,1839030562),r=nr(r,i,s,e,n[o+14],23,-35309556),e=nr(e,r,i,s,n[o+1],4,-1530992060),s=nr(s,e,r,i,n[o+4],11,1272893353),i=nr(i,s,e,r,n[o+7],16,-155497632),r=nr(r,i,s,e,n[o+10],23,-1094730640),e=nr(e,r,i,s,n[o+13],4,681279174),s=nr(s,e,r,i,n[o],11,-358537222),i=nr(i,s,e,r,n[o+3],16,-722521979),r=nr(r,i,s,e,n[o+6],23,76029189),e=nr(e,r,i,s,n[o+9],4,-640364487),s=nr(s,e,r,i,n[o+12],11,-421815835),i=nr(i,s,e,r,n[o+15],16,530742520),r=nr(r,i,s,e,n[o+2],23,-995338651),e=rr(e,r,i,s,n[o],6,-198630844),s=rr(s,e,r,i,n[o+7],10,1126891415),i=rr(i,s,e,r,n[o+14],15,-1416354905),r=rr(r,i,s,e,n[o+5],21,-57434055),e=rr(e,r,i,s,n[o+12],6,1700485571),s=rr(s,e,r,i,n[o+3],10,-1894986606),i=rr(i,s,e,r,n[o+10],15,-1051523),r=rr(r,i,s,e,n[o+1],21,-2054922799),e=rr(e,r,i,s,n[o+8],6,1873313359),s=rr(s,e,r,i,n[o+15],10,-30611744),i=rr(i,s,e,r,n[o+6],15,-1560198380),r=rr(r,i,s,e,n[o+13],21,1309151649),e=rr(e,r,i,s,n[o+4],6,-145523070),s=rr(s,e,r,i,n[o+11],10,-1120210379),i=rr(i,s,e,r,n[o+2],15,718787259),r=rr(r,i,s,e,n[o+9],21,-343485551),e=jo(e,a),r=jo(r,u),i=jo(i,f),s=jo(s,h)}return[e,r,i,s]}function R9(n){if(n.length===0)return[];for(var t=n.length*8,e=new Uint32Array(J2(t)),r=0;r<t;r+=8)e[r>>5]|=(n[r/8]&255)<<r%32;return e}function jo(n,t){var e=(n&65535)+(t&65535),r=(n>>16)+(t>>16)+(e>>16);return r<<16|e&65535}function I9(n,t){return n<<t|n>>>32-t}function Pp(n,t,e,r,i,s){return jo(I9(jo(jo(t,n),jo(r,s)),i),e)}function tr(n,t,e,r,i,s,o){return Pp(t&e|~t&r,n,t,i,s,o)}function er(n,t,e,r,i,s,o){return Pp(t&r|e&~r,n,t,i,s,o)}function nr(n,t,e,r,i,s,o){return Pp(t^e^r,n,t,i,s,o)}function rr(n,t,e,r,i,s,o){return Pp(e^(t|~r),n,t,i,s,o)}var S9=Q2("v3",48,E9);function k9(n,t,e){n=n||{};var r=n.random||(n.rng||Z2)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){e=e||0;for(var i=0;i<16;++i)t[e+i]=r[i];return t}return Bp(r)}function T9(n,t,e,r){switch(n){case 0:return t&e^~t&r;case 1:return t^e^r;case 2:return t&e^t&r^e&r;case 3:return t^e^r}}function Qy(n,t){return n<<t|n>>>32-t}function O9(n){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var r=unescape(encodeURIComponent(n));n=[];for(var i=0;i<r.length;++i)n.push(r.charCodeAt(i))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var s=n.length/4+2,o=Math.ceil(s/16),a=new Array(o),u=0;u<o;++u){for(var f=new Uint32Array(16),h=0;h<16;++h)f[h]=n[u*64+h*4]<<24|n[u*64+h*4+1]<<16|n[u*64+h*4+2]<<8|n[u*64+h*4+3];a[u]=f}a[o-1][14]=(n.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(n.length-1)*8&4294967295;for(var y=0;y<o;++y){for(var _=new Uint32Array(80),w=0;w<16;++w)_[w]=a[y][w];for(var R=16;R<80;++R)_[R]=Qy(_[R-3]^_[R-8]^_[R-14]^_[R-16],1);for(var T=e[0],I=e[1],B=e[2],H=e[3],U=e[4],G=0;G<80;++G){var W=Math.floor(G/20),X=Qy(T,5)+T9(W,I,B,H)+U+t[W]+_[G]>>>0;U=H,H=B,B=Qy(I,30)>>>0,I=T,T=X}e[0]=e[0]+T>>>0,e[1]=e[1]+I>>>0,e[2]=e[2]+B>>>0,e[3]=e[3]+H>>>0,e[4]=e[4]+U>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var N9=Q2("v5",80,O9);const C9="00000000-0000-0000-0000-000000000000";function B9(n){if(!Cp(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const P9=Object.freeze(Object.defineProperty({__proto__:null,NIL:C9,parse:q2,stringify:Bp,v1:w9,v3:S9,v4:k9,v5:N9,validate:Cp,version:B9},Symbol.toStringTag,{value:"Module"})),Y2=gp(P9),M9=Y2.v4,L9=function(n,t,e,r){if(typeof n!="string")throw new TypeError(n+" must be a string");r=r||{};const i=typeof r.version=="number"?r.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const s={method:n};if(i===2&&(s.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");s.params=t}if(typeof e>"u"){const o=typeof r.generator=="function"?r.generator:function(){return M9()};s.id=o(s,r)}else i===2&&e===null?r.notificationIdNull&&(s.id=null):s.id=e;return s};var U9=L9;const D9=Y2.v4,F9=U9,dh=function(n,t){if(!(this instanceof dh))return new dh(n,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return D9()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=n};var $9=dh;dh.prototype.request=function(n,t,e,r){const i=this;let s=null;const o=Array.isArray(n)&&typeof t=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&n&&typeof n=="object"&&typeof t=="function")r=t,s=n;else{typeof e=="function"&&(r=e,e=void 0);const f=typeof r=="function";try{s=F9(n,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(h){if(f)return r(h);throw h}if(!f)return s}let u;try{u=JSON.stringify(s,this.options.replacer)}catch(f){return r(f)}return this.callServer(u,function(f,h){i._parseResponse(f,h,r)}),s};dh.prototype._parseResponse=function(n,t,e){if(n){e(n);return}if(!t)return e();let r;try{r=JSON.parse(t,this.options.reviver)}catch(i){return e(i)}if(e.length===3)if(Array.isArray(r)){const i=function(o){return typeof o.error<"u"},s=function(o){return!i(o)};return e(null,r.filter(i),r.filter(s))}else return e(null,r.error,r.result);e(null,r)};const H9=ua($9);var z9=class extends s1{constructor(t,e,r){super();Z(this,"socket");this.socket=new window.WebSocket(t,r),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=i=>this.emit("message",i.data),this.socket.onerror=i=>this.emit("error",i),this.socket.onclose=i=>{this.emit("close",i.code,i.reason)}}send(t,e,r){const i=r||e;try{this.socket.send(t),i()}catch(s){i(s)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,r){this.socket.addEventListener(t,e,r)}};function G9(n,t){return new z9(n,t)}var V9=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},K9=class extends s1{constructor(t,e="ws://localhost:8080",{autoconnect:r=!0,reconnect:i=!0,reconnect_interval:s=1e3,max_reconnects:o=5,...a}={},u,f){super();Z(this,"address");Z(this,"rpc_id");Z(this,"queue");Z(this,"options");Z(this,"autoconnect");Z(this,"ready");Z(this,"reconnect");Z(this,"reconnect_timer_id");Z(this,"reconnect_interval");Z(this,"max_reconnects");Z(this,"rest_options");Z(this,"current_reconnects");Z(this,"generate_request_id");Z(this,"socket");Z(this,"webSocketFactory");Z(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=r,this.ready=!1,this.reconnect=i,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=u||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),f?this.dataPack=f:this.dataPack=new V9,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(t,e,r,i){return!i&&typeof r=="object"&&(i=r,r=null),new Promise((s,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(t,e),u={jsonrpc:"2.0",method:t,params:e||void 0,id:a};this.socket.send(this.dataPack.encode(u),i,f=>{if(f)return o(f);this.queue[a]={promise:[s,o]},r&&(this.queue[a].timeout=setTimeout(()=>{delete this.queue[a],o(new Error("reply timeout"))},r))})})}async login(t){const e=await this.call("rpc.login",t);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(t,e){return new Promise((r,i)=>{if(!this.ready)return i(new Error("socket not ready"));const s={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(s),o=>{if(o)return i(o);r()})})}async subscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.on",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed subscribing to an event '"+t+"' with: "+e[t]);return e}async unsubscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.off",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(t,e){this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}_connect(t,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:r})=>{r instanceof ArrayBuffer&&(r=St.from(r).toString());try{r=this.dataPack.decode(r)}catch{return}if(r.notification&&this.listeners(r.notification).length){if(!Object.keys(r.params).length)return this.emit(r.notification);const i=[r.notification];if(r.params.constructor===Object)i.push(r.params);else for(let s=0;s<r.params.length;s++)i.push(r.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,i)})}if(!this.queue[r.id])return r.method?Promise.resolve().then(()=>{this.emit(r.method,r==null?void 0:r.params)}):void 0;"error"in r=="result"in r&&this.queue[r.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[r.id].timeout&&clearTimeout(this.queue[r.id].timeout),r.error?this.queue[r.id].promise[1](r.error):this.queue[r.id].promise[0](r.result),delete this.queue[r.id]}),this.socket.addEventListener("error",r=>this.emit("error",r)),this.socket.addEventListener("close",({code:r,reason:i})=>{this.ready&&setTimeout(()=>this.emit("close",r,i),0),this.ready=!1,this.socket=void 0,r!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(t,e),this.reconnect_interval)))})}};const X2=[],tR=[],eR=[],j9=BigInt(0),Sf=BigInt(1),W9=BigInt(2),Z9=BigInt(7),q9=BigInt(256),Q9=BigInt(113);for(let n=0,t=Sf,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],X2.push(2*(5*r+e)),tR.push((n+1)*(n+2)/2%64);let i=j9;for(let s=0;s<7;s++)t=(t<<Sf^(t>>Z9)*Q9)%q9,t&W9&&(i^=Sf<<(Sf<<BigInt(s))-Sf);eR.push(i)}const[J9,Y9]=i2(eR,!0),BA=(n,t,e)=>e>32?a2(n,t,e):s2(n,t,e),PA=(n,t,e)=>e>32?c2(n,t,e):o2(n,t,e);function X9(n,t=24){const e=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)e[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,f=e[u],h=e[u+1],y=BA(f,h,1)^e[a],_=PA(f,h,1)^e[a+1];for(let w=0;w<50;w+=10)n[o+w]^=y,n[o+w+1]^=_}let i=n[2],s=n[3];for(let o=0;o<24;o++){const a=tR[o],u=BA(i,s,a),f=PA(i,s,a),h=X2[o];i=n[h],s=n[h+1],n[h]=u,n[h+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)e[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~e[(a+2)%10]&e[(a+4)%10]}n[0]^=J9[r],n[1]^=Y9[r]}e.fill(0)}let tF=class nR extends p1{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,B0(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=IU(this.state)}keccak(){EA||vA(this.state32),X9(this.state32,this.rounds),EA||vA(this.state32),this.posOut=0,this.pos=0}update(t){yl(this);const{blockLen:e,state:r}=this;t=xp(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(e-this.pos,i-s);for(let a=0;a<o;a++)r[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:i}=this;t[r]^=e,e&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){yl(this,!1),ed(t),this.finish();const e=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(e.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return B0(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(t2(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new nR(e,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}};const eF=(n,t,e)=>g1(()=>new tF(t,n,e)),MA=eF(1,136,256/8);let rR=class extends p1{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,RU(t);const r=xp(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=t.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(t){return yl(this),this.iHash.update(t),this}digestInto(t){yl(this),ed(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:i,destroyed:s,blockLen:o,outputLen:a}=this;return t=t,t.finished=i,t.destroyed=s,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const iR=(n,t,e)=>new rR(n,t).update(e).digest();iR.create=(n,t)=>new rR(n,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function LA(n){n.lowS!==void 0&&Qs("lowS",n.lowS),n.prehash!==void 0&&Qs("prehash",n.prehash)}function nF(n){const t=w1(n);$l(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:i}=t;if(e){if(!r.eql(i,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:rF,hexToBytes:iF}=cD;class sF extends Error{constructor(t=""){super(t)}}const Is={Err:sF,_tlv:{encode:(n,t)=>{const{Err:e}=Is;if(n<0||n>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");const r=t.length/2,i=ru(r);if(i.length/2&128)throw new e("tlv.encode: long form length too big");const s=r>127?ru(i.length/2|128):"";return ru(n)+s+i+t},decode(n,t){const{Err:e}=Is;let r=0;if(n<0||n>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[r++]!==n)throw new e("tlv.decode: wrong tlv");const i=t[r++],s=!!(i&128);let o=0;if(!s)o=i;else{const u=i&127;if(!u)throw new e("tlv.decode(long): indefinite length not supported");if(u>4)throw new e("tlv.decode(long): byte length is too big");const f=t.subarray(r,r+u);if(f.length!==u)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(const h of f)o=o<<8|h;if(r+=u,o<128)throw new e("tlv.decode(long): not minimal encoding")}const a=t.subarray(r,r+o);if(a.length!==o)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(r+o)}}},_int:{encode(n){const{Err:t}=Is;if(n<Ks)throw new t("integer: negative integers are not allowed");let e=ru(n);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(n){const{Err:t}=Is;if(n[0]&128)throw new t("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return rF(n)}},toSig(n){const{Err:t,_int:e,_tlv:r}=Is,i=typeof n=="string"?iF(n):n;nd(i);const{v:s,l:o}=r.decode(48,i);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:u}=r.decode(2,s),{v:f,l:h}=r.decode(2,u);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(f)}},hexFromSig(n){const{_tlv:t,_int:e}=Is,r=t.encode(2,e.encode(n.r)),i=t.encode(2,e.encode(n.s)),s=r+i;return t.encode(48,s)}},Ks=BigInt(0),Mn=BigInt(1);BigInt(2);const UA=BigInt(3);BigInt(4);function oF(n){const t=nF(n),{Fp:e}=t,r=kp(t.n,t.nBitLength),i=t.toBytes||((T,I,B)=>{const H=I.toAffine();return yc(Uint8Array.from([4]),e.toBytes(H.x),e.toBytes(H.y))}),s=t.fromBytes||(T=>{const I=T.subarray(1),B=e.fromBytes(I.subarray(0,e.BYTES)),H=e.fromBytes(I.subarray(e.BYTES,2*e.BYTES));return{x:B,y:H}});function o(T){const{a:I,b:B}=t,H=e.sqr(T),U=e.mul(H,T);return e.add(e.add(U,e.mul(T,I)),B)}if(!e.eql(e.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function a(T){return Sp(T,Mn,t.n)}function u(T){const{allowedPrivateKeyLengths:I,nByteLength:B,wrapPrivateKey:H,n:U}=t;if(I&&typeof T!="bigint"){if(pc(T)&&(T=gc(T)),typeof T!="string"||!I.includes(T.length))throw new Error("invalid private key");T=T.padStart(B*2,"0")}let G;try{G=typeof T=="bigint"?T:ac(Sn("private key",T,B))}catch{throw new Error("invalid private key, expected hex or "+B+" bytes, got "+typeof T)}return H&&(G=Qe(G,U)),ci("private key",G,Mn,U),G}function f(T){if(!(T instanceof _))throw new Error("ProjectivePoint expected")}const h=hh((T,I)=>{const{px:B,py:H,pz:U}=T;if(e.eql(U,e.ONE))return{x:B,y:H};const G=T.is0();I==null&&(I=G?e.ONE:e.inv(U));const W=e.mul(B,I),X=e.mul(H,I),j=e.mul(U,I);if(G)return{x:e.ZERO,y:e.ZERO};if(!e.eql(j,e.ONE))throw new Error("invZ was invalid");return{x:W,y:X}}),y=hh(T=>{if(T.is0()){if(t.allowInfinityPoint&&!e.is0(T.py))return;throw new Error("bad point: ZERO")}const{x:I,y:B}=T.toAffine();if(!e.isValid(I)||!e.isValid(B))throw new Error("bad point: x or y not FE");const H=e.sqr(B),U=o(I);if(!e.eql(H,U))throw new Error("bad point: equation left != right");if(!T.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class _{constructor(I,B,H){if(this.px=I,this.py=B,this.pz=H,I==null||!e.isValid(I))throw new Error("x required");if(B==null||!e.isValid(B))throw new Error("y required");if(H==null||!e.isValid(H))throw new Error("z required");Object.freeze(this)}static fromAffine(I){const{x:B,y:H}=I||{};if(!I||!e.isValid(B)||!e.isValid(H))throw new Error("invalid affine point");if(I instanceof _)throw new Error("projective point not allowed");const U=G=>e.eql(G,e.ZERO);return U(B)&&U(H)?_.ZERO:new _(B,H,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(I){const B=e.invertBatch(I.map(H=>H.pz));return I.map((H,U)=>H.toAffine(B[U])).map(_.fromAffine)}static fromHex(I){const B=_.fromAffine(s(Sn("pointHex",I)));return B.assertValidity(),B}static fromPrivateKey(I){return _.BASE.multiply(u(I))}static msm(I,B){return m2(_,r,I,B)}_setWindowSize(I){R.setWindowSize(this,I)}assertValidity(){y(this)}hasEvenY(){const{y:I}=this.toAffine();if(e.isOdd)return!e.isOdd(I);throw new Error("Field doesn't support isOdd")}equals(I){f(I);const{px:B,py:H,pz:U}=this,{px:G,py:W,pz:X}=I,j=e.eql(e.mul(B,X),e.mul(G,U)),Y=e.eql(e.mul(H,X),e.mul(W,U));return j&&Y}negate(){return new _(this.px,e.neg(this.py),this.pz)}double(){const{a:I,b:B}=t,H=e.mul(B,UA),{px:U,py:G,pz:W}=this;let X=e.ZERO,j=e.ZERO,Y=e.ZERO,it=e.mul(U,U),ut=e.mul(G,G),rt=e.mul(W,W),ot=e.mul(U,G);return ot=e.add(ot,ot),Y=e.mul(U,W),Y=e.add(Y,Y),X=e.mul(I,Y),j=e.mul(H,rt),j=e.add(X,j),X=e.sub(ut,j),j=e.add(ut,j),j=e.mul(X,j),X=e.mul(ot,X),Y=e.mul(H,Y),rt=e.mul(I,rt),ot=e.sub(it,rt),ot=e.mul(I,ot),ot=e.add(ot,Y),Y=e.add(it,it),it=e.add(Y,it),it=e.add(it,rt),it=e.mul(it,ot),j=e.add(j,it),rt=e.mul(G,W),rt=e.add(rt,rt),it=e.mul(rt,ot),X=e.sub(X,it),Y=e.mul(rt,ut),Y=e.add(Y,Y),Y=e.add(Y,Y),new _(X,j,Y)}add(I){f(I);const{px:B,py:H,pz:U}=this,{px:G,py:W,pz:X}=I;let j=e.ZERO,Y=e.ZERO,it=e.ZERO;const ut=t.a,rt=e.mul(t.b,UA);let ot=e.mul(B,G),C=e.mul(H,W),p=e.mul(U,X),m=e.add(B,H),v=e.add(G,W);m=e.mul(m,v),v=e.add(ot,C),m=e.sub(m,v),v=e.add(B,U);let k=e.add(G,X);return v=e.mul(v,k),k=e.add(ot,p),v=e.sub(v,k),k=e.add(H,U),j=e.add(W,X),k=e.mul(k,j),j=e.add(C,p),k=e.sub(k,j),it=e.mul(ut,v),j=e.mul(rt,p),it=e.add(j,it),j=e.sub(C,it),it=e.add(C,it),Y=e.mul(j,it),C=e.add(ot,ot),C=e.add(C,ot),p=e.mul(ut,p),v=e.mul(rt,v),C=e.add(C,p),p=e.sub(ot,p),p=e.mul(ut,p),v=e.add(v,p),ot=e.mul(C,v),Y=e.add(Y,ot),ot=e.mul(k,v),j=e.mul(m,j),j=e.sub(j,ot),ot=e.mul(m,C),it=e.mul(k,it),it=e.add(it,ot),new _(j,Y,it)}subtract(I){return this.add(I.negate())}is0(){return this.equals(_.ZERO)}wNAF(I){return R.wNAFCached(this,I,_.normalizeZ)}multiplyUnsafe(I){const{endo:B,n:H}=t;ci("scalar",I,Ks,H);const U=_.ZERO;if(I===Ks)return U;if(this.is0()||I===Mn)return this;if(!B||R.hasPrecomputes(this))return R.wNAFCachedUnsafe(this,I,_.normalizeZ);let{k1neg:G,k1:W,k2neg:X,k2:j}=B.splitScalar(I),Y=U,it=U,ut=this;for(;W>Ks||j>Ks;)W&Mn&&(Y=Y.add(ut)),j&Mn&&(it=it.add(ut)),ut=ut.double(),W>>=Mn,j>>=Mn;return G&&(Y=Y.negate()),X&&(it=it.negate()),it=new _(e.mul(it.px,B.beta),it.py,it.pz),Y.add(it)}multiply(I){const{endo:B,n:H}=t;ci("scalar",I,Mn,H);let U,G;if(B){const{k1neg:W,k1:X,k2neg:j,k2:Y}=B.splitScalar(I);let{p:it,f:ut}=this.wNAF(X),{p:rt,f:ot}=this.wNAF(Y);it=R.constTimeNegate(W,it),rt=R.constTimeNegate(j,rt),rt=new _(e.mul(rt.px,B.beta),rt.py,rt.pz),U=it.add(rt),G=ut.add(ot)}else{const{p:W,f:X}=this.wNAF(I);U=W,G=X}return _.normalizeZ([U,G])[0]}multiplyAndAddUnsafe(I,B,H){const U=_.BASE,G=(X,j)=>j===Ks||j===Mn||!X.equals(U)?X.multiplyUnsafe(j):X.multiply(j),W=G(this,B).add(G(I,H));return W.is0()?void 0:W}toAffine(I){return h(this,I)}isTorsionFree(){const{h:I,isTorsionFree:B}=t;if(I===Mn)return!0;if(B)return B(_,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:I,clearCofactor:B}=t;return I===Mn?this:B?B(_,this):this.multiplyUnsafe(t.h)}toRawBytes(I=!0){return Qs("isCompressed",I),this.assertValidity(),i(_,this,I)}toHex(I=!0){return Qs("isCompressed",I),gc(this.toRawBytes(I))}}_.BASE=new _(t.Gx,t.Gy,e.ONE),_.ZERO=new _(e.ZERO,e.ONE,e.ZERO);const w=t.nBitLength,R=y2(_,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:_,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:a}}function aF(n){const t=w1(n);return $l(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function cF(n){const t=aF(n),{Fp:e,n:r}=t,i=e.BYTES+1,s=2*e.BYTES+1;function o(p){return Qe(p,r)}function a(p){return Jm(p,r)}const{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:h,isWithinCurveOrder:y}=oF({...t,toBytes(p,m,v){const k=m.toAffine(),N=e.toBytes(k.x),M=yc;return Qs("isCompressed",v),v?M(Uint8Array.from([m.hasEvenY()?2:3]),N):M(Uint8Array.from([4]),N,e.toBytes(k.y))},fromBytes(p){const m=p.length,v=p[0],k=p.subarray(1);if(m===i&&(v===2||v===3)){const N=ac(k);if(!Sp(N,Mn,e.ORDER))throw new Error("Point is not on curve");const M=h(N);let z;try{z=e.sqrt(M)}catch($){const ct=$ instanceof Error?": "+$.message:"";throw new Error("Point is not on curve"+ct)}const P=(z&Mn)===Mn;return(v&1)===1!==P&&(z=e.neg(z)),{x:N,y:z}}else if(m===s&&v===4){const N=e.fromBytes(k.subarray(0,e.BYTES)),M=e.fromBytes(k.subarray(e.BYTES,2*e.BYTES));return{x:N,y:M}}else{const N=i,M=s;throw new Error("invalid Point, expected length of "+N+", or uncompressed "+M+", got "+m)}}}),_=p=>gc(wl(p,t.nByteLength));function w(p){const m=r>>Mn;return p>m}function R(p){return w(p)?o(-p):p}const T=(p,m,v)=>ac(p.slice(m,v));class I{constructor(m,v,k){this.r=m,this.s=v,this.recovery=k,this.assertValidity()}static fromCompact(m){const v=t.nByteLength;return m=Sn("compactSignature",m,v*2),new I(T(m,0,v),T(m,v,2*v))}static fromDER(m){const{r:v,s:k}=Is.toSig(Sn("DER",m));return new I(v,k)}assertValidity(){ci("r",this.r,Mn,r),ci("s",this.s,Mn,r)}addRecoveryBit(m){return new I(this.r,this.s,m)}recoverPublicKey(m){const{r:v,s:k,recovery:N}=this,M=X(Sn("msgHash",m));if(N==null||![0,1,2,3].includes(N))throw new Error("recovery id invalid");const z=N===2||N===3?v+t.n:v;if(z>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const P=N&1?"03":"02",A=u.fromHex(P+_(z)),$=a(z),ct=o(-M*$),ft=o(k*$),wt=u.BASE.multiplyAndAddUnsafe(A,ct,ft);if(!wt)throw new Error("point at infinify");return wt.assertValidity(),wt}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new I(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return ml(this.toDERHex())}toDERHex(){return Is.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ml(this.toCompactHex())}toCompactHex(){return _(this.r)+_(this.s)}}const B={isValidPrivateKey(p){try{return f(p),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const p=d2(t.n);return wD(t.randomBytes(p),t.n)},precompute(p=8,m=u.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function H(p,m=!0){return u.fromPrivateKey(p).toRawBytes(m)}function U(p){const m=pc(p),v=typeof p=="string",k=(m||v)&&p.length;return m?k===i||k===s:v?k===2*i||k===2*s:p instanceof u}function G(p,m,v=!0){if(U(p))throw new Error("first arg must be private key");if(!U(m))throw new Error("second arg must be public key");return u.fromHex(m).multiply(f(p)).toRawBytes(v)}const W=t.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const m=ac(p),v=p.length*8-t.nBitLength;return v>0?m>>BigInt(v):m},X=t.bits2int_modN||function(p){return o(W(p))},j=m1(t.nBitLength);function Y(p){return ci("num < 2^"+t.nBitLength,p,Ks,j),wl(p,t.nByteLength)}function it(p,m,v=ut){if(["recovered","canonical"].some(Lt=>Lt in v))throw new Error("sign() legacy options not supported");const{hash:k,randomBytes:N}=t;let{lowS:M,prehash:z,extraEntropy:P}=v;M==null&&(M=!0),p=Sn("msgHash",p),LA(v),z&&(p=Sn("prehashed msgHash",k(p)));const A=X(p),$=f(m),ct=[Y($),Y(A)];if(P!=null&&P!==!1){const Lt=P===!0?N(e.BYTES):P;ct.push(Sn("extraEntropy",Lt))}const ft=yc(...ct),wt=A;function Ht(Lt){const Mt=W(Lt);if(!y(Mt))return;const Ee=a(Mt),Vt=u.BASE.multiply(Mt).toAffine(),Ut=o(Vt.x);if(Ut===Ks)return;const Ie=o(Ee*o(wt+Ut*$));if(Ie===Ks)return;let Yt=(Vt.x===Ut?0:2)|Number(Vt.y&Mn),ie=Ie;return M&&w(Ie)&&(ie=R(Ie),Yt^=1),new I(Ut,ie,Yt)}return{seed:ft,k2sig:Ht}}const ut={lowS:t.lowS,prehash:!1},rt={lowS:t.lowS,prehash:!1};function ot(p,m,v=ut){const{seed:k,k2sig:N}=it(p,m,v),M=t;return l2(M.hash.outputLen,M.nByteLength,M.hmac)(k,N)}u.BASE._setWindowSize(8);function C(p,m,v,k=rt){var Yt;const N=p;m=Sn("msgHash",m),v=Sn("publicKey",v);const{lowS:M,prehash:z,format:P}=k;if(LA(k),"strict"in k)throw new Error("options.strict was renamed to lowS");if(P!==void 0&&P!=="compact"&&P!=="der")throw new Error("format must be compact or der");const A=typeof N=="string"||pc(N),$=!A&&!P&&typeof N=="object"&&N!==null&&typeof N.r=="bigint"&&typeof N.s=="bigint";if(!A&&!$)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let ct,ft;try{if($&&(ct=new I(N.r,N.s)),A){try{P!=="compact"&&(ct=I.fromDER(N))}catch(ie){if(!(ie instanceof Is.Err))throw ie}!ct&&P!=="der"&&(ct=I.fromCompact(N))}ft=u.fromHex(v)}catch{return!1}if(!ct||M&&ct.hasHighS())return!1;z&&(m=t.hash(m));const{r:wt,s:Ht}=ct,Lt=X(m),Mt=a(Ht),Ee=o(Lt*Mt),Vt=o(wt*Mt),Ut=(Yt=u.BASE.multiplyAndAddUnsafe(ft,Ee,Vt))==null?void 0:Yt.toAffine();return Ut?o(Ut.x)===wt:!1}return{CURVE:t,getPublicKey:H,getSharedSecret:G,sign:ot,verify:C,ProjectivePoint:u,Signature:I,utils:B}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function uF(n){return{hash:n,hmac:(t,...e)=>iR(n,t,TU(...e)),randomBytes:e2}}function lF(n,t){const e=r=>cF({...n,...uF(r)});return{...e(t),create:e}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const sR=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),DA=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),fF=BigInt(1),ew=BigInt(2),FA=(n,t)=>(n+t/ew)/t;function hF(n){const t=sR,e=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),f=n*n*n%t,h=f*f*n%t,y=bn(h,e,t)*h%t,_=bn(y,e,t)*h%t,w=bn(_,ew,t)*f%t,R=bn(w,i,t)*w%t,T=bn(R,s,t)*R%t,I=bn(T,a,t)*T%t,B=bn(I,u,t)*I%t,H=bn(B,a,t)*T%t,U=bn(H,e,t)*h%t,G=bn(U,o,t)*R%t,W=bn(G,r,t)*f%t,X=bn(W,ew,t);if(!nw.eql(nw.sqr(X),n))throw new Error("Cannot find square root");return X}const nw=kp(sR,void 0,void 0,{sqrt:hF}),Mp=lF({a:BigInt(0),b:BigInt(7),Fp:nw,n:DA,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=DA,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-fF*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,o=BigInt("0x100000000000000000000000000000000"),a=FA(s*n,t),u=FA(-r*n,t);let f=Qe(n-a*e-u*i,t),h=Qe(-a*r-u*s,t);const y=f>o,_=h>o;if(y&&(f=t-f),_&&(h=t-h),f>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:y,k1:f,k2neg:_,k2:h}}}},Xm);BigInt(0);Mp.ProjectivePoint;const dF=Hl.utils.randomPrivateKey,$A=()=>{const n=Hl.utils.randomPrivateKey(),t=$0(n),e=new Uint8Array(64);return e.set(n),e.set(t,32),{publicKey:t,secretKey:e}},$0=Hl.getPublicKey;function HA(n){try{return Hl.ExtendedPoint.fromHex(n),!0}catch{return!1}}const C1=(n,t)=>Hl.sign(n,t.slice(0,32)),pF=Hl.verify,ne=n=>St.isBuffer(n)?n:n instanceof Uint8Array?St.from(n.buffer,n.byteOffset,n.byteLength):St.from(n);let B1=class{constructor(t){Object.assign(this,t)}encode(){return St.from(R2(Gf,this))}static decode(t){return I2(Gf,this,t)}static decodeUnchecked(t){return _2(Gf,this,t)}};class gF extends B1{constructor(t){if(super(t),this.enum="",Object.keys(t).length!==1)throw new Error("Enum can only take single value");Object.keys(t).map(e=>{this.enum=e})}}const Gf=new Map;var oR;const aR=32,is=32;function yF(n){return n._bn!==void 0}let zA=1;class pt extends B1{constructor(t){if(super({}),this._bn=void 0,yF(t))this._bn=t._bn;else{if(typeof t=="string"){const e=kn.decode(t);if(e.length!=is)throw new Error("Invalid public key input");this._bn=new Gs(e)}else this._bn=new Gs(t);if(this._bn.byteLength()>is)throw new Error("Invalid public key input")}}static unique(){const t=new pt(zA);return zA+=1,new pt(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return kn.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(St);if(t.length===is)return t;const e=St.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,r){const i=St.concat([t.toBuffer(),St.from(e),r.toBuffer()]),s=Xm(i);return new pt(s)}static createProgramAddressSync(t,e){let r=St.alloc(0);t.forEach(function(s){if(s.length>aR)throw new TypeError("Max seed length exceeded");r=St.concat([r,ne(s)])}),r=St.concat([r,e.toBuffer(),St.from("ProgramDerivedAddress")]);const i=Xm(r);if(HA(i))throw new Error("Invalid seeds, address must fall off the curve");return new pt(i)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r=255,i;for(;r!=0;){try{const s=t.concat(St.from([r]));i=this.createProgramAddressSync(s,e)}catch(s){if(s instanceof TypeError)throw s;r--;continue}return[i,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){const e=new pt(t);return HA(e.toBytes())}}oR=pt;pt.default=new oR("11111111111111111111111111111111");Gf.set(pt,{kind:"struct",fields:[["_bn","u256"]]});class mF{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=ne(t);if(t.length!==64)throw new Error("bad secret key size");this._publicKey=e.slice(32,64),this._secretKey=e.slice(0,32)}else this._secretKey=ne(dF()),this._publicKey=ne($0(this._secretKey))}get publicKey(){return new pt(this._publicKey)}get secretKey(){return St.concat([this._secretKey,this._publicKey],64)}}const wF=new pt("BPFLoader1111111111111111111111111111111111"),qo=1232,Lp=127,ph=64;class P1 extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(P1.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class M1 extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(M1.prototype,"name",{value:"TransactionExpiredTimeoutError"});class iu extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(iu.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class gh{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((s,o)=>{r.set(s.toBase58(),o)});const i=s=>{const o=r.get(s.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(s=>({programIdIndex:i(s.programId),accountKeyIndexes:s.keys.map(o=>i(o.pubkey)),data:s.data}))}}const ae=(n="publicKey")=>Ve(32,n),bF=(n="signature")=>Ve(64,n),ka=(n="string")=>{const t=Ot([Tt("length"),Tt("lengthPadding"),Ve(Zo(Tt(),-8),"chars")],n),e=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(s,o)=>e(s,o).chars.toString(),i.encode=(s,o,a)=>{const u={chars:St.from(s,"utf8")};return r(u,o,a)},i.alloc=s=>Tt().span+Tt().span+St.from(s,"utf8").length,i},_F=(n="authorized")=>Ot([ae("staker"),ae("withdrawer")],n),AF=(n="lockup")=>Ot([Gr("unixTimestamp"),Gr("epoch"),ae("custodian")],n),EF=(n="voteInit")=>Ot([ae("nodePubkey"),ae("authorizedVoter"),ae("authorizedWithdrawer"),ge("commission")],n),vF=(n="voteAuthorizeWithSeedArgs")=>Ot([Tt("voteAuthorizationType"),ae("currentAuthorityDerivedKeyOwnerPubkey"),ka("currentAuthorityDerivedKeySeed"),ae("newAuthorized")],n);function cR(n,t){const e=i=>{if(i.span>=0)return i.span;if(typeof i.alloc=="function")return i.alloc(t[i.property]);if("count"in i&&"elementLayout"in i){const s=t[i.property];if(Array.isArray(s))return s.length*e(i.elementLayout)}else if("fields"in i)return cR({layout:i},t[i.property]);return 0};let r=0;return n.layout.fields.forEach(i=>{r+=e(i)}),r}function Rr(n){let t=0,e=0;for(;;){let r=n.shift();if(t|=(r&127)<<e*7,e+=1,!(r&128))break}return t}function Vr(n,t){let e=t;for(;;){let r=e&127;if(e>>=7,e==0){n.push(r);break}else r|=128,n.push(r)}}function be(n,t){if(!n)throw new Error(t||"Assertion failed")}class Up{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const r=new Map,i=o=>{const a=o.toBase58();let u=r.get(a);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,u)),u},s=i(e);s.isSigner=!0,s.isWritable=!0;for(const o of t){i(o.programId).isInvoked=!0;for(const a of o.keys){const u=i(a.pubkey);u.isSigner||(u.isSigner=a.isSigner),u.isWritable||(u.isWritable=a.isWritable)}}return new Up(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];be(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,u])=>u.isSigner&&u.isWritable),r=t.filter(([,u])=>u.isSigner&&!u.isWritable),i=t.filter(([,u])=>!u.isSigner&&u.isWritable),s=t.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:s.length};{be(e.length>0,"Expected at least one writable signer key");const[u]=e[0];be(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...e.map(([u])=>new pt(u)),...r.map(([u])=>new pt(u)),...i.map(([u])=>new pt(u)),...s.map(([u])=>new pt(u))];return[o,a]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,s]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&i.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:i},{writable:r,readonly:s}]}drainKeysFoundInLookupTable(t,e){const r=new Array,i=new Array;for(const[s,o]of this.keyMetaMap.entries())if(e(o)){const a=new pt(s),u=t.findIndex(f=>f.equals(a));u>=0&&(be(u<256,"Max lookup table index exceeded"),r.push(u),i.push(a),this.keyMetaMap.delete(s))}return[r,i]}}const uR="Reached end of buffer unexpectedly";function qi(n){if(n.length===0)throw new Error(uR);return n.shift()}function Ir(n,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>n.length:e>=n.length)throw new Error(uR);return n.splice(...t)}class Ti{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new pt(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:kn.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new gh(this.staticAccountKeys)}static compile(t){const e=Up.compile(t.instructions,t.payerKey),[r,i]=e.getMessageComponents(),o=new gh(i).compileInstructions(t.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:kn.encode(a.data)}));return new Ti({header:r,accountKeys:i,recentBlockhash:t.recentBlockhash,instructions:o})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const r=t-e,s=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return r<s}else{const r=e-this.header.numReadonlySignedAccounts;return t<r}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){const t=this.accountKeys.length;let e=[];Vr(e,t);const r=this.instructions.map(y=>{const{accounts:_,programIdIndex:w}=y,R=Array.from(kn.decode(y.data));let T=[];Vr(T,_.length);let I=[];return Vr(I,R.length),{programIdIndex:w,keyIndicesCount:St.from(T),keyIndices:_,dataLength:St.from(I),data:R}});let i=[];Vr(i,r.length);let s=St.alloc(qo);St.from(i).copy(s);let o=i.length;r.forEach(y=>{const w=Ot([ge("programIdIndex"),Ve(y.keyIndicesCount.length,"keyIndicesCount"),Qn(ge("keyIndex"),y.keyIndices.length,"keyIndices"),Ve(y.dataLength.length,"dataLength"),Qn(ge("userdatum"),y.data.length,"data")]).encode(y,s,o);o+=w}),s=s.slice(0,o);const a=Ot([Ve(1,"numRequiredSignatures"),Ve(1,"numReadonlySignedAccounts"),Ve(1,"numReadonlyUnsignedAccounts"),Ve(e.length,"keyCount"),Qn(ae("key"),t,"keys"),ae("recentBlockhash")]),u={numRequiredSignatures:St.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:St.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:St.from([this.header.numReadonlyUnsignedAccounts]),keyCount:St.from(e),keys:this.accountKeys.map(y=>ne(y.toBytes())),recentBlockhash:kn.decode(this.recentBlockhash)};let f=St.alloc(2048);const h=a.encode(u,f);return s.copy(f,h),f.slice(0,h+s.length)}static from(t){let e=[...t];const r=qi(e);if(r!==(r&Lp))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=qi(e),s=qi(e),o=Rr(e);let a=[];for(let _=0;_<o;_++){const w=Ir(e,0,is);a.push(new pt(St.from(w)))}const u=Ir(e,0,is),f=Rr(e);let h=[];for(let _=0;_<f;_++){const w=qi(e),R=Rr(e),T=Ir(e,0,R),I=Rr(e),B=Ir(e,0,I),H=kn.encode(St.from(B));h.push({programIdIndex:w,accounts:T,data:H})}const y={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:kn.encode(St.from(u)),accountKeys:a,instructions:h};return new Ti(y)}}class mc{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new gh(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(t>=r){const i=t-r,s=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return i<s}else if(t>=this.header.numRequiredSignatures){const i=t-e,o=r-e-this.header.numReadonlyUnsignedAccounts;return i<o}else{const i=e-this.header.numReadonlySignedAccounts;return t<i}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const r of this.addressTableLookups){const i=t.find(s=>s.key.equals(r.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const s of r.writableIndexes)if(s<i.state.addresses.length)e.writable.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`);for(const s of r.readonlyIndexes)if(s<i.state.addresses.length)e.readonly.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`)}return e}static compile(t){const e=Up.compile(t.instructions,t.payerKey),r=new Array,i={writable:new Array,readonly:new Array},s=t.addressLookupTableAccounts||[];for(const h of s){const y=e.extractTableLookup(h);if(y!==void 0){const[_,{writable:w,readonly:R}]=y;r.push(_),i.writable.push(...w),i.readonly.push(...R)}}const[o,a]=e.getMessageComponents(),f=new gh(a,i).compileInstructions(t.instructions);return new mc({header:o,staticAccountKeys:a,recentBlockhash:t.recentBlockhash,compiledInstructions:f,addressTableLookups:r})}serialize(){const t=Array();Vr(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),r=Array();Vr(r,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),s=Array();Vr(s,this.addressTableLookups.length);const o=Ot([ge("prefix"),Ot([ge("numRequiredSignatures"),ge("numReadonlySignedAccounts"),ge("numReadonlyUnsignedAccounts")],"header"),Ve(t.length,"staticAccountKeysLength"),Qn(ae(),this.staticAccountKeys.length,"staticAccountKeys"),ae("recentBlockhash"),Ve(r.length,"instructionsLength"),Ve(e.length,"serializedInstructions"),Ve(s.length,"addressTableLookupsLength"),Ve(i.length,"serializedAddressTableLookups")]),a=new Uint8Array(qo),f=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(h=>h.toBytes()),recentBlockhash:kn.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},a);return a.slice(0,f)}serializeInstructions(){let t=0;const e=new Uint8Array(qo);for(const r of this.compiledInstructions){const i=Array();Vr(i,r.accountKeyIndexes.length);const s=Array();Vr(s,r.data.length);const o=Ot([ge("programIdIndex"),Ve(i.length,"encodedAccountKeyIndexesLength"),Qn(ge(),r.accountKeyIndexes.length,"accountKeyIndexes"),Ve(s.length,"encodedDataLength"),Ve(r.data.length,"data")]);t+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:r.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(qo);for(const r of this.addressTableLookups){const i=Array();Vr(i,r.writableIndexes.length);const s=Array();Vr(s,r.readonlyIndexes.length);const o=Ot([ae("accountKey"),Ve(i.length,"encodedWritableIndexesLength"),Qn(ge(),r.writableIndexes.length,"writableIndexes"),Ve(s.length,"encodedReadonlyIndexesLength"),Qn(ge(),r.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:r.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const r=qi(e),i=r&Lp;be(r!==i,"Expected versioned message but received legacy message");const s=i;be(s===0,`Expected versioned message with version 0 but found version ${s}`);const o={numRequiredSignatures:qi(e),numReadonlySignedAccounts:qi(e),numReadonlyUnsignedAccounts:qi(e)},a=[],u=Rr(e);for(let R=0;R<u;R++)a.push(new pt(Ir(e,0,is)));const f=kn.encode(Ir(e,0,is)),h=Rr(e),y=[];for(let R=0;R<h;R++){const T=qi(e),I=Rr(e),B=Ir(e,0,I),H=Rr(e),U=new Uint8Array(Ir(e,0,H));y.push({programIdIndex:T,accountKeyIndexes:B,data:U})}const _=Rr(e),w=[];for(let R=0;R<_;R++){const T=new pt(Ir(e,0,is)),I=Rr(e),B=Ir(e,0,I),H=Rr(e),U=Ir(e,0,H);w.push({accountKey:T,writableIndexes:B,readonlyIndexes:U})}return new mc({header:o,staticAccountKeys:a,recentBlockhash:f,compiledInstructions:y,addressTableLookups:w})}}const L1={deserializeMessageVersion(n){const t=n[0],e=t&Lp;return e===t?"legacy":e},deserialize:n=>{const t=L1.deserializeMessageVersion(n);if(t==="legacy")return Ti.from(n);if(t===0)return mc.deserialize(n);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let As=function(n){return n[n.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",n[n.PROCESSED=1]="PROCESSED",n[n.TIMED_OUT=2]="TIMED_OUT",n[n.NONCE_INVALID=3]="NONCE_INVALID",n}({});const xF=St.alloc(ph).fill(0);class Pe{constructor(t){this.keys=void 0,this.programId=void 0,this.data=St.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:r})=>({pubkey:t.toJSON(),isSigner:e,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}let Oe=class rw{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:r}=t;this.minNonceContextSlot=e,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:r}=t;this.recentBlockhash=e,this.lastValidBlockHeight=r}else{const{recentBlockhash:e,nonceInfo:r}=t;r&&(this.nonceInfo=r),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new Pe(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let T=0;T<e.length;T++)if(e[T].programId===void 0)throw new Error(`Transaction instruction index ${T} has undefined program id`);const i=[],s=[];e.forEach(T=>{T.keys.forEach(B=>{s.push({...B})});const I=T.programId.toString();i.includes(I)||i.push(I)}),i.forEach(T=>{s.push({pubkey:new pt(T),isSigner:!1,isWritable:!1})});const o=[];s.forEach(T=>{const I=T.pubkey.toString(),B=o.findIndex(H=>H.pubkey.toString()===I);B>-1?(o[B].isWritable=o[B].isWritable||T.isWritable,o[B].isSigner=o[B].isSigner||T.isSigner):o.push(T)}),o.sort(function(T,I){if(T.isSigner!==I.isSigner)return T.isSigner?-1:1;if(T.isWritable!==I.isWritable)return T.isWritable?-1:1;const B={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return T.pubkey.toBase58().localeCompare(I.pubkey.toBase58(),"en",B)});const a=o.findIndex(T=>T.pubkey.equals(r));if(a>-1){const[T]=o.splice(a,1);T.isSigner=!0,T.isWritable=!0,o.unshift(T)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const T of this.signatures){const I=o.findIndex(B=>B.pubkey.equals(T.publicKey));if(I>-1)o[I].isSigner||(o[I].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${T.publicKey.toString()}`)}let u=0,f=0,h=0;const y=[],_=[];o.forEach(({pubkey:T,isSigner:I,isWritable:B})=>{I?(y.push(T.toString()),u+=1,B||(f+=1)):(_.push(T.toString()),B||(h+=1))});const w=y.concat(_),R=e.map(T=>{const{data:I,programId:B}=T;return{programIdIndex:w.indexOf(B.toString()),accounts:T.keys.map(H=>w.indexOf(H.pubkey.toString())),data:kn.encode(I)}});return R.forEach(T=>{be(T.programIdIndex>=0),T.accounts.forEach(I=>be(I>=0))}),new Ti({header:{numRequiredSignatures:u,numReadonlySignedAccounts:f,numReadonlyUnsignedAccounts:h},accountKeys:w,recentBlockhash:t,instructions:R})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((i,s)=>e[s].equals(i.publicKey))||(this.signatures=e.map(r=>({signature:null,publicKey:r}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const e=new Set;this.signatures=t.filter(r=>{const i=r.toString();return e.has(i)?!1:(e.add(i),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const s of t){const o=s.publicKey.toString();e.has(o)||(e.add(o),r.push(s))}this.signatures=r.map(s=>({signature:null,publicKey:s.publicKey}));const i=this._compile();this._partialSign(i,...r)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const s of t){const o=s.publicKey.toString();e.has(o)||(e.add(o),r.push(s))}const i=this._compile();this._partialSign(i,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach(i=>{const s=C1(r,i.secretKey);this._addSignature(i.publicKey,ne(s))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){be(e.length===64);const r=this.signatures.findIndex(i=>t.equals(i.publicKey));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=St.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const r={};for(const{signature:i,publicKey:s}of this.signatures)i===null?e&&(r.missing||(r.missing=[])).push(s):pF(i,t,s.toBytes())||(r.invalid||(r.invalid=[])).push(s);return r.invalid||r.missing?r:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),i=this.serializeMessage();if(r){const s=this._getMessageSignednessErrors(i,e);if(s){let o="Signature verification failed.";throw s.invalid&&(o+=`
|
|
17
|
+
Invalid signature for public key${s.invalid.length===1?"":"(s)"} [\`${s.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),s.missing&&(o+=`
|
|
18
|
+
Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(i)}_serialize(t){const{signatures:e}=this,r=[];Vr(r,e.length);const i=r.length+e.length*64+t.length,s=St.alloc(i);return be(e.length<256),St.from(r).copy(s,0),e.forEach(({signature:o},a)=>{o!==null&&(be(o.length===64,"signature has invalid length"),St.from(o).copy(s,r.length+a*64))}),t.copy(s,r.length+e.length*64),be(s.length<=qo,`Transaction too large: ${s.length} > ${qo}`),s}get keys(){return be(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return be(this.instructions.length===1),this.instructions[0].programId}get data(){return be(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const r=Rr(e);let i=[];for(let s=0;s<r;s++){const o=Ir(e,0,ph);i.push(kn.encode(St.from(o)))}return rw.populate(Ti.from(e),i)}static populate(t,e=[]){const r=new rw;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach((i,s)=>{const o={signature:i==kn.encode(xF)?null:kn.decode(i),publicKey:t.accountKeys[s]};r.signatures.push(o)}),t.instructions.forEach(i=>{const s=i.accounts.map(o=>{const a=t.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(u=>u.publicKey.toString()===a.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});r.instructions.push(new Pe({keys:s,programId:t.accountKeys[i.programIdIndex],data:kn.decode(i.data)}))}),r._message=t,r._json=r.toJSON(),r}};class U1{constructor(t){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=t.payerKey,this.instructions=t.instructions,this.recentBlockhash=t.recentBlockhash}static decompile(t,e){const{header:r,compiledInstructions:i,recentBlockhash:s}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:u}=r,f=o-a;be(f>0,"Message header is invalid");const h=t.staticAccountKeys.length-o-u;be(h>=0,"Message header is invalid");const y=t.getAccountKeys(e),_=y.get(0);if(_===void 0)throw new Error("Failed to decompile message because no account keys were found");const w=[];for(const R of i){const T=[];for(const B of R.accountKeyIndexes){const H=y.get(B);if(H===void 0)throw new Error(`Failed to find key for account key index ${B}`);const U=B<o;let G;U?G=B<f:B<y.staticAccountKeys.length?G=B-o<h:G=B-y.staticAccountKeys.length<y.accountKeysFromLookups.writable.length,T.push({pubkey:H,isSigner:B<r.numRequiredSignatures,isWritable:G})}const I=y.get(R.programIdIndex);if(I===void 0)throw new Error(`Failed to find program id for program id index ${R.programIdIndex}`);w.push(new Pe({programId:I,data:ne(R.data),keys:T}))}return new U1({payerKey:_,instructions:w,recentBlockhash:s})}compileToLegacyMessage(){return Ti.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return mc.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class D1{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)be(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const r=[];for(let i=0;i<t.header.numRequiredSignatures;i++)r.push(new Uint8Array(ph));this.signatures=r}this.message=t}serialize(){const t=this.message.serialize(),e=Array();Vr(e,this.signatures.length);const r=Ot([Ve(e.length,"encodedSignaturesLength"),Qn(bF(),this.signatures.length,"signatures"),Ve(t.length,"serializedMessage")]),i=new Uint8Array(2048),s=r.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},i);return i.slice(0,s)}static deserialize(t){let e=[...t];const r=[],i=Rr(e);for(let o=0;o<i;o++)r.push(new Uint8Array(Ir(e,0,ph)));const s=L1.deserialize(new Uint8Array(e));return new D1(s,r)}sign(t){const e=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const i of t){const s=r.findIndex(o=>o.equals(i.publicKey));be(s>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[s]=C1(e,i.secretKey)}}addSignature(t,e){be(e.byteLength===64,"Signature must be 64 bytes long");const i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(t));be(i>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=e}}const RF=160,IF=64,SF=RF/IF,lR=1e3/SF,Wi=new pt("SysvarC1ock11111111111111111111111111111111"),kF=new pt("SysvarEpochSchedu1e111111111111111111111111"),TF=new pt("Sysvar1nstructions1111111111111111111111111"),c0=new pt("SysvarRecentB1ockHashes11111111111111111111"),_l=new pt("SysvarRent111111111111111111111111111111111"),OF=new pt("SysvarRewards111111111111111111111111111111"),NF=new pt("SysvarS1otHashes111111111111111111111111111"),CF=new pt("SysvarS1otHistory11111111111111111111111111"),u0=new pt("SysvarStakeHistory1111111111111111111111111");class sa extends Error{constructor({action:t,signature:e,transactionMessage:r,logs:i}){const s=i?`Logs:
|
|
19
|
+
${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(t){case"send":a=`Transaction ${e} resulted in an error.
|
|
20
|
+
${r}. `+s+o;break;case"simulate":a=`Simulation failed.
|
|
21
21
|
Message: ${r}.
|
|
22
|
-
`+s+o;break;default:c=`Unknown action '${(u=>u)(t)}'`}super(c),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=r,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}async getLogs(t){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((e,r)=>{t.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){const s=i.meta.logMessages;this.transactionLogs=s,e(s)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const Y9={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class Pt extends Error{constructor({code:t,message:e,data:r},i){super(i!=null?`${i}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=r,this.name="SolanaJSONRPCError"}}async function Dm(n,t,e,r){const i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},s=await n.sendTransaction(t,e,i);let o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,signature:s,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:c}=t.nonceInfo,u=c.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:t.nonceInfo.nonce,signature:s},r&&r.commitment)).value}else(r==null?void 0:r.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await n.confirmTransaction(s,r&&r.commitment)).value;if(o.err)throw s!=null?new Jo({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(o)})`);return s}function ga(n){return new Promise(t=>setTimeout(t,n))}function de(n,t){const e=n.layout.span>=0?n.layout.span:N2(n,t),r=It.alloc(e),i=Object.assign({instruction:n.index},t);return n.layout.encode(i,r),r}function Se(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${e.instruction} != ${n.index}`);return e}const P2=zn("lamportsPerSignature"),M2=Ot([Tt("version"),Tt("state"),ae("authorizedPubkey"),ae("nonce"),Ot([P2],"feeCalculator")]),Fm=M2.span;class bp{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=M2.decode(ne(t),0);return new bp({authorizedPubkey:new pt(e.authorizedPubkey),nonce:new pt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const X9=n=>{const t=n.decode.bind(n),e=n.encode.bind(n);return{decode:t,encode:e}},tF=n=>t=>{const e=Ge(n,t),{encode:r,decode:i}=X9(e),s=e;return s.decode=(o,c)=>{const u=i(o,c);return vD(It.from(u))},s.encode=(o,c,u)=>{const f=f2(o,n);return r(f,c,u)},s},cl=tF(8);class eF{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Tt("instruction").decode(t.data);let i;for(const[s,o]of Object.entries($e))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a SystemInstruction");return i}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:r,programId:i}=Se($e.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:r,programId:new pt(i)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Se($e.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:r,programId:i}=Se($e.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:r,programId:new pt(i)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Se($e.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,space:i,programId:s}=Se($e.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new pt(e),seed:r,space:i,programId:new pt(s)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Se($e.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new pt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,programId:i}=Se($e.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new pt(e),seed:r,programId:new pt(i)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:r,lamports:i,space:s,programId:o}=Se($e.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new pt(e),seed:r,lamports:i,space:s,programId:new pt(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Se($e.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new pt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Se($e.AdvanceNonceAccount,t.data),{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static decodeNonceWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Se($e.WithdrawNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e}}static decodeNonceAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e}=Se($e.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new pt(e)}}static checkProgramId(t){if(!t.equals(Tn.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const $e=Object.freeze({Create:{index:0,layout:Ot([Tt("instruction"),Hr("lamports"),Hr("space"),ae("programId")])},Assign:{index:1,layout:Ot([Tt("instruction"),ae("programId")])},Transfer:{index:2,layout:Ot([Tt("instruction"),cl("lamports")])},CreateWithSeed:{index:3,layout:Ot([Tt("instruction"),ae("base"),_a("seed"),Hr("lamports"),Hr("space"),ae("programId")])},AdvanceNonceAccount:{index:4,layout:Ot([Tt("instruction")])},WithdrawNonceAccount:{index:5,layout:Ot([Tt("instruction"),Hr("lamports")])},InitializeNonceAccount:{index:6,layout:Ot([Tt("instruction"),ae("authorized")])},AuthorizeNonceAccount:{index:7,layout:Ot([Tt("instruction"),ae("authorized")])},Allocate:{index:8,layout:Ot([Tt("instruction"),Hr("space")])},AllocateWithSeed:{index:9,layout:Ot([Tt("instruction"),ae("base"),_a("seed"),Hr("space"),ae("programId")])},AssignWithSeed:{index:10,layout:Ot([Tt("instruction"),ae("base"),_a("seed"),ae("programId")])},TransferWithSeed:{index:11,layout:Ot([Tt("instruction"),cl("lamports"),_a("seed"),ae("programId")])},UpgradeNonceAccount:{index:12,layout:Ot([Tt("instruction")])}});class Tn{constructor(){}static createAccount(t){const e=$e.Create,r=de(e,{lamports:t.lamports,space:t.space,programId:ne(t.programId.toBuffer())});return new Be({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(t){let e,r;if("basePubkey"in t){const i=$e.TransferWithSeed;e=de(i,{lamports:BigInt(t.lamports),seed:t.seed,programId:ne(t.programId.toBuffer())}),r=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const i=$e.Transfer;e=de(i,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Be({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;if("basePubkey"in t){const i=$e.AssignWithSeed;e=de(i,{base:ne(t.basePubkey.toBuffer()),seed:t.seed,programId:ne(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=$e.Assign;e=de(i,{programId:ne(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Be({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=$e.CreateWithSeed,r=de(e,{base:ne(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:ne(t.programId.toBuffer())});let i=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||i.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Be({keys:i,programId:this.programId,data:r})}static createNonceAccount(t){const e=new Te;"basePubkey"in t&&"seed"in t?e.add(Tn.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:Fm,programId:this.programId})):e.add(Tn.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:Fm,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=$e.InitializeNonceAccount,r=de(e,{authorized:ne(t.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Gd,isSigner:!1,isWritable:!1},{pubkey:al,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Be(i)}static nonceAdvance(t){const e=$e.AdvanceNonceAccount,r=de(e),i={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Gd,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Be(i)}static nonceWithdraw(t){const e=$e.WithdrawNonceAccount,r=de(e,{lamports:t.lamports});return new Be({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Gd,isSigner:!1,isWritable:!1},{pubkey:al,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(t){const e=$e.AuthorizeNonceAccount,r=de(e,{authorized:ne(t.newAuthorizedPubkey.toBuffer())});return new Be({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(t){let e,r;if("basePubkey"in t){const i=$e.AllocateWithSeed;e=de(i,{base:ne(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:ne(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=$e.Allocate;e=de(i,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Be({keys:r,programId:this.programId,data:e})}}Tn.programId=new pt("11111111111111111111111111111111");const nF=Ho-300;class lc{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/lc.chunkSize)+1+1)}static async load(t,e,r,i,s){{const y=await t.getMinimumBalanceForRentExemption(s.length),A=await t.getAccountInfo(r.publicKey,"confirmed");let b=null;if(A!==null){if(A.executable)return console.error("Program load failed, account is already executable"),!1;A.data.length!==s.length&&(b=b||new Te,b.add(Tn.allocate({accountPubkey:r.publicKey,space:s.length}))),A.owner.equals(i)||(b=b||new Te,b.add(Tn.assign({accountPubkey:r.publicKey,programId:i}))),A.lamports<y&&(b=b||new Te,b.add(Tn.transfer({fromPubkey:e.publicKey,toPubkey:r.publicKey,lamports:y-A.lamports})))}else b=new Te().add(Tn.createAccount({fromPubkey:e.publicKey,newAccountPubkey:r.publicKey,lamports:y>0?y:1,space:s.length,programId:i}));b!==null&&await Dm(t,b,[e,r],{commitment:"confirmed"})}const o=Ot([Tt("instruction"),Tt("offset"),Tt("bytesLength"),Tt("bytesLengthPadding"),qn(ge("byte"),$o(Tt(),-8),"bytes")]),c=lc.chunkSize;let u=0,f=s,h=[];for(;f.length>0;){const y=f.slice(0,c),A=It.alloc(c+16);o.encode({instruction:0,offset:u,bytes:y,bytesLength:0,bytesLengthPadding:0},A);const b=new Te().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:A});h.push(Dm(t,b,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await ga(1e3/4),u+=c,f=f.slice(c)}await Promise.all(h);{const y=Ot([Tt("instruction")]),A=It.alloc(y.span);y.encode({instruction:1},A);const b=new Te().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:al,isSigner:!1,isWritable:!1}],programId:i,data:A}),R="processed",k=await t.sendTransaction(b,[e,r],{preflightCommitment:R}),{context:S,value:B}=await t.confirmTransaction({signature:k,lastValidBlockHeight:b.lastValidBlockHeight,blockhash:b.recentBlockhash},R);if(B.err)throw new Error(`Transaction ${k} failed (${JSON.stringify(B)})`);for(;;){try{if(await t.getSlot({commitment:R})>S.slot)break}catch{}await new Promise(H=>setTimeout(H,Math.round(B2/2)))}}return!0}}lc.chunkSize=nF;const rF=new pt("BPFLoader2111111111111111111111111111111111");class iF{static getMinNumSignatures(t){return lc.getMinNumSignatures(t)}static load(t,e,r,i,s){return lc.load(t,e,r,s,i)}}function sF(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Cy,wA;function oF(){if(wA)return Cy;wA=1;var n=Object.prototype.toString,t=Object.keys||function(r){var i=[];for(var s in r)i.push(s);return i};function e(r,i){var s,o,c,u,f,h,y;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return e(r.toJSON(),i);if(y=n.call(r),y==="[object Array]"){for(c="[",o=r.length-1,s=0;s<o;s++)c+=e(r[s],!0)+",";return o>-1&&(c+=e(r[s],!0)),c+"]"}else if(y==="[object Object]"){for(u=t(r).sort(),o=u.length,c="",s=0;s<o;)f=u[s],h=e(r[f],!1),h!==void 0&&(c&&(c+=","),c+=JSON.stringify(f)+":"+h),s++;return"{"+c+"}"}else return JSON.stringify(r);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return Cy=function(r){var i=e(r,!1);if(i!==void 0)return""+i},Cy}var aF=oF(),bA=sF(aF);const yf=32;function By(n){let t=0;for(;n>1;)n/=2,t++;return t}function cF(n){return n===0?1:(n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n|=n>>32,n+1)}class L2{constructor(t,e,r,i,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=r,this.firstNormalEpoch=i,this.firstNormalSlot=s}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=By(cF(t+yf+1))-By(yf)-1,r=this.getSlotsInEpoch(e),i=t-(r-yf);return[e,i]}else{const e=t-this.firstNormalSlot,r=Math.floor(e/this.slotsPerEpoch),i=this.firstNormalEpoch+r,s=e%this.slotsPerEpoch;return[i,s]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*yf:(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+By(yf)):this.slotsPerEpoch}}var uF=globalThis.fetch;class lF extends l9{constructor(t,e,r){const i=s=>{const o=c9(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,t,e,r),this.underlyingSocket=void 0}call(...t){var r;const e=(r=this.underlyingSocket)==null?void 0:r.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var r;const e=(r=this.underlyingSocket)==null?void 0:r.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}function fF(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${n.index}`);return e}const _A=56;class $m{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=fF(hF,t),r=t.length-_A;be(r>=0,"lookup table is invalid"),be(r%32===0,"lookup table is invalid");const i=r/32,{addresses:s}=Ot([qn(ae(),i,"addresses")]).decode(t.slice(_A));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new pt(e.authority[0]):void 0,addresses:s.map(o=>new pt(o))}}}const hF={index:1,layout:Ot([Tt("typeIndex"),cl("deactivationSlot"),zn("lastExtendedSlot"),ge("lastExtendedStartIndex"),ge(),qn(ae(),$o(ge(),-1),"authority")])},dF=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function pF(n){const t=n.match(dF);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[e,r,i,s]=t,o=n.startsWith("https:")?"wss:":"ws:",c=i==null?null:parseInt(i.slice(1),10),u=c==null?"":`:${c+1}`;return`${o}//${r}${u}${s}`}const sn=Vh(c1(pt),yt(),n=>new pt(n)),U2=u1([yt(),en("base64")]),m1=Vh(c1(It),U2,n=>It.from(n[0],"base64")),D2=30*1e3;function gF(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function Fe(n){let t,e;if(typeof n=="string")t=n;else if(n){const{commitment:r,...i}=n;t=r,e=i}return{commitment:t,config:e}}function AA(n){return n.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function F2(n){return br([dt({jsonrpc:en("2.0"),id:yt(),result:n}),dt({jsonrpc:en("2.0"),id:yt(),error:dt({code:Nl(),message:yt(),data:Dt(CD())})})])}const yF=F2(Nl());function ee(n){return Vh(F2(n),yF,t=>"error"in t?t:{...t,result:wt(t.result,n)})}function An(n){return ee(dt({context:dt({slot:X()}),value:n}))}function _p(n){return dt({context:dt({slot:X()}),value:n})}function Py(n,t){return n===0?new uc({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new pt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:In.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new xi(t)}const mF=dt({foundation:X(),foundationTerm:X(),initial:X(),taper:X(),terminal:X()}),wF=ee(Et(vt(dt({epoch:X(),effectiveSlot:X(),amount:X(),postBalance:X(),commission:Dt(vt(X()))})))),bF=Et(dt({slot:X(),prioritizationFee:X()})),_F=dt({total:X(),validator:X(),foundation:X(),epoch:X()}),AF=dt({epoch:X(),slotIndex:X(),slotsInEpoch:X(),absoluteSlot:X(),blockHeight:Dt(X()),transactionCount:Dt(X())}),EF=dt({slotsPerEpoch:X(),leaderScheduleSlotOffset:X(),warmup:ss(),firstNormalEpoch:X(),firstNormalSlot:X()}),vF=p2(yt(),Et(X())),Ec=vt(br([dt({}),yt()])),xF=dt({err:Ec}),RF=en("receivedSignature"),SF=dt({"solana-core":yt(),"feature-set":Dt(X())}),IF=dt({program:yt(),programId:sn,parsed:Nl()}),kF=dt({programId:sn,accounts:Et(sn),data:yt()}),EA=An(dt({err:vt(br([dt({}),yt()])),logs:vt(Et(yt())),accounts:Dt(vt(Et(vt(dt({executable:ss(),owner:yt(),lamports:X(),data:Et(yt()),rentEpoch:Dt(X())}))))),unitsConsumed:Dt(X()),returnData:Dt(vt(dt({programId:yt(),data:u1([yt(),en("base64")])}))),innerInstructions:Dt(vt(Et(dt({index:X(),instructions:Et(br([IF,kF]))}))))})),TF=An(dt({byIdentity:p2(yt(),Et(X())),range:dt({firstSlot:X(),lastSlot:X()})}));function OF(n,t,e,r,i,s){const o=e||uF;let c;s!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return r&&(u=async(h,y)=>{const A=await new Promise((b,R)=>{try{r(h,y,(k,S)=>b([k,S]))}catch(k){R(k)}});return await o(...A)}),new s9(async(h,y)=>{const A={method:"POST",body:h,agent:c,headers:Object.assign({"Content-Type":"application/json"},t||{},O7)};try{let b=5,R,k=500;for(;u?R=await u(n,A):R=await o(n,A),!(R.status!==429||i===!0||(b-=1,b===0));)console.error(`Server responded with ${R.status} ${R.statusText}. Retrying after ${k}ms delay...`),await ga(k),k*=2;const S=await R.text();R.ok?y(null,S):y(new Error(`${R.status} ${R.statusText}: ${S}`))}catch(b){b instanceof Error&&y(b)}},{})}function NF(n){return(t,e)=>new Promise((r,i)=>{n.request(t,e,(s,o)=>{if(s){i(s);return}r(o)})})}function CF(n){return t=>new Promise((e,r)=>{t.length===0&&e([]);const i=t.map(s=>n.request(s.methodName,s.args));n.request(i,(s,o)=>{if(s){r(s);return}e(o)})})}const BF=ee(mF),PF=ee(_F),MF=ee(bF),LF=ee(AF),UF=ee(EF),DF=ee(vF),FF=ee(X()),$F=An(dt({total:X(),circulating:X(),nonCirculating:X(),nonCirculatingAccounts:Et(sn)})),Hm=dt({amount:yt(),uiAmount:vt(X()),decimals:X(),uiAmountString:Dt(yt())}),HF=An(Et(dt({address:sn,amount:yt(),uiAmount:vt(X()),decimals:X(),uiAmountString:Dt(yt())}))),zF=An(Et(dt({pubkey:sn,account:dt({executable:ss(),owner:sn,lamports:X(),data:m1,rentEpoch:X()})}))),zm=dt({program:yt(),parsed:Nl(),space:X()}),GF=An(Et(dt({pubkey:sn,account:dt({executable:ss(),owner:sn,lamports:X(),data:zm,rentEpoch:X()})}))),VF=An(Et(dt({lamports:X(),address:sn}))),ih=dt({executable:ss(),owner:sn,lamports:X(),data:m1,rentEpoch:X()}),KF=dt({pubkey:sn,account:ih}),jF=Vh(br([c1(It),zm]),br([U2,zm]),n=>Array.isArray(n)?wt(n,m1):n),Gm=dt({executable:ss(),owner:sn,lamports:X(),data:jF,rentEpoch:X()}),WF=dt({pubkey:sn,account:Gm}),ZF=dt({state:br([en("active"),en("inactive"),en("activating"),en("deactivating")]),active:X(),inactive:X()}),qF=ee(Et(dt({signature:yt(),slot:X(),err:Ec,memo:vt(yt()),blockTime:Dt(vt(X()))}))),QF=ee(Et(dt({signature:yt(),slot:X(),err:Ec,memo:vt(yt()),blockTime:Dt(vt(X()))}))),JF=dt({subscription:X(),result:_p(ih)}),YF=dt({pubkey:sn,account:ih}),XF=dt({subscription:X(),result:_p(YF)}),t7=dt({parent:X(),slot:X(),root:X()}),e7=dt({subscription:X(),result:t7}),n7=br([dt({type:br([en("firstShredReceived"),en("completed"),en("optimisticConfirmation"),en("root")]),slot:X(),timestamp:X()}),dt({type:en("createdBank"),parent:X(),slot:X(),timestamp:X()}),dt({type:en("frozen"),slot:X(),timestamp:X(),stats:dt({numTransactionEntries:X(),numSuccessfulTransactions:X(),numFailedTransactions:X(),maxTransactionsPerEntry:X()})}),dt({type:en("dead"),slot:X(),timestamp:X(),err:yt()})]),r7=dt({subscription:X(),result:n7}),i7=dt({subscription:X(),result:_p(br([xF,RF]))}),s7=dt({subscription:X(),result:X()}),o7=dt({pubkey:yt(),gossip:vt(yt()),tpu:vt(yt()),rpc:vt(yt()),version:vt(yt())}),vA=dt({votePubkey:yt(),nodePubkey:yt(),activatedStake:X(),epochVoteAccount:ss(),epochCredits:Et(u1([X(),X(),X()])),commission:X(),lastVote:X(),rootSlot:vt(X())}),a7=ee(dt({current:Et(vA),delinquent:Et(vA)})),c7=br([en("processed"),en("confirmed"),en("finalized")]),u7=dt({slot:X(),confirmations:vt(X()),err:Ec,confirmationStatus:Dt(c7)}),l7=An(Et(vt(u7))),f7=ee(X()),$2=dt({accountKey:sn,writableIndexes:Et(X()),readonlyIndexes:Et(X())}),w1=dt({signatures:Et(yt()),message:dt({accountKeys:Et(yt()),header:dt({numRequiredSignatures:X(),numReadonlySignedAccounts:X(),numReadonlyUnsignedAccounts:X()}),instructions:Et(dt({accounts:Et(X()),data:yt(),programIdIndex:X()})),recentBlockhash:yt(),addressTableLookups:Dt(Et($2))})}),H2=dt({pubkey:sn,signer:ss(),writable:ss(),source:Dt(br([en("transaction"),en("lookupTable")]))}),z2=dt({accountKeys:Et(H2),signatures:Et(yt())}),G2=dt({parsed:Nl(),program:yt(),programId:sn}),V2=dt({accounts:Et(sn),data:yt(),programId:sn}),h7=br([V2,G2]),d7=br([dt({parsed:Nl(),program:yt(),programId:yt()}),dt({accounts:Et(yt()),data:yt(),programId:yt()})]),K2=Vh(h7,d7,n=>"accounts"in n?wt(n,V2):wt(n,G2)),j2=dt({signatures:Et(yt()),message:dt({accountKeys:Et(H2),instructions:Et(K2),recentBlockhash:yt(),addressTableLookups:Dt(vt(Et($2)))})}),E0=dt({accountIndex:X(),mint:yt(),owner:Dt(yt()),programId:Dt(yt()),uiTokenAmount:Hm}),W2=dt({writable:Et(sn),readonly:Et(sn)}),Ap=dt({err:Ec,fee:X(),innerInstructions:Dt(vt(Et(dt({index:X(),instructions:Et(dt({accounts:Et(X()),data:yt(),programIdIndex:X()}))})))),preBalances:Et(X()),postBalances:Et(X()),logMessages:Dt(vt(Et(yt()))),preTokenBalances:Dt(vt(Et(E0))),postTokenBalances:Dt(vt(Et(E0))),loadedAddresses:Dt(W2),computeUnitsConsumed:Dt(X())}),b1=dt({err:Ec,fee:X(),innerInstructions:Dt(vt(Et(dt({index:X(),instructions:Et(K2)})))),preBalances:Et(X()),postBalances:Et(X()),logMessages:Dt(vt(Et(yt()))),preTokenBalances:Dt(vt(Et(E0))),postTokenBalances:Dt(vt(Et(E0))),loadedAddresses:Dt(W2),computeUnitsConsumed:Dt(X())}),Cl=br([en(0),en("legacy")]),vc=dt({pubkey:yt(),lamports:X(),postBalance:vt(X()),rewardType:vt(yt()),commission:Dt(vt(X()))}),p7=ee(vt(dt({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),transactions:Et(dt({transaction:w1,meta:vt(Ap),version:Dt(Cl)})),rewards:Dt(Et(vc)),blockTime:vt(X()),blockHeight:vt(X())}))),g7=ee(vt(dt({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),rewards:Dt(Et(vc)),blockTime:vt(X()),blockHeight:vt(X())}))),y7=ee(vt(dt({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),transactions:Et(dt({transaction:z2,meta:vt(Ap),version:Dt(Cl)})),rewards:Dt(Et(vc)),blockTime:vt(X()),blockHeight:vt(X())}))),m7=ee(vt(dt({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),transactions:Et(dt({transaction:j2,meta:vt(b1),version:Dt(Cl)})),rewards:Dt(Et(vc)),blockTime:vt(X()),blockHeight:vt(X())}))),w7=ee(vt(dt({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),transactions:Et(dt({transaction:z2,meta:vt(b1),version:Dt(Cl)})),rewards:Dt(Et(vc)),blockTime:vt(X()),blockHeight:vt(X())}))),b7=ee(vt(dt({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),rewards:Dt(Et(vc)),blockTime:vt(X()),blockHeight:vt(X())}))),_7=ee(vt(dt({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),transactions:Et(dt({transaction:w1,meta:vt(Ap)})),rewards:Dt(Et(vc)),blockTime:vt(X())}))),xA=ee(vt(dt({blockhash:yt(),previousBlockhash:yt(),parentSlot:X(),signatures:Et(yt()),blockTime:vt(X())}))),My=ee(vt(dt({slot:X(),meta:vt(Ap),blockTime:Dt(vt(X())),transaction:w1,version:Dt(Cl)}))),Sd=ee(vt(dt({slot:X(),transaction:j2,meta:vt(b1),blockTime:Dt(vt(X())),version:Dt(Cl)}))),A7=An(dt({blockhash:yt(),lastValidBlockHeight:X()})),E7=An(ss()),v7=dt({slot:X(),numTransactions:X(),numSlots:X(),samplePeriodSecs:X()}),x7=ee(Et(v7)),R7=An(vt(dt({feeCalculator:dt({lamportsPerSignature:X()})}))),S7=ee(yt()),I7=ee(yt()),k7=dt({err:Ec,logs:Et(yt()),signature:yt()}),T7=dt({result:_p(k7),subscription:X()}),O7={"solana-client":"js/1.0.0-maintenance"};class Z2{constructor(t,e){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const f={};return async h=>{const{commitment:y,config:A}=Fe(h),b=this._buildArgs([],y,void 0,A),R=bA(b);return f[R]=f[R]??(async()=>{try{const k=await this._rpcRequest("getBlockHeight",b),S=wt(k,ee(X()));if("error"in S)throw new Pt(S.error,"failed to get block height information");return S.result}finally{delete f[R]}})(),await f[R]}})();let r,i,s,o,c,u;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,r=e.wsEndpoint,i=e.httpHeaders,s=e.fetch,o=e.fetchMiddleware,c=e.disableRetryOnRateLimit,u=e.httpAgent),this._rpcEndpoint=gF(t),this._rpcWsEndpoint=r||pF(t),this._rpcClient=OF(t,i,s,o,c,u),this._rpcRequest=NF(this._rpcClient),this._rpcBatchRequest=CF(this._rpcClient),this._rpcWebSocket=new lF(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(t,e){const{commitment:r,config:i}=Fe(e),s=this._buildArgs([t.toBase58()],r,void 0,i),o=await this._rpcRequest("getBalance",s),c=wt(o,An(X()));if("error"in c)throw new Pt(c.error,`failed to get balance for ${t.toBase58()}`);return c.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+r)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),r=wt(e,ee(vt(X())));if("error"in r)throw new Pt(r.error,`failed to get block time for slot ${t}`);return r.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=wt(t,ee(X()));if("error"in e)throw new Pt(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=wt(t,FF);if("error"in e)throw new Pt(e.error,"failed to get first available block");return e.result}async getSupply(t){let e={};typeof t=="string"?e={commitment:t}:t?e={...t,commitment:t&&t.commitment||this.commitment}:e={commitment:this.commitment};const r=await this._rpcRequest("getSupply",[e]),i=wt(r,$F);if("error"in i)throw new Pt(i.error,"failed to get supply");return i.result}async getTokenSupply(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenSupply",r),s=wt(i,An(Hm));if("error"in s)throw new Pt(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenAccountBalance",r),s=wt(i,An(Hm));if("error"in s)throw new Pt(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(t,e,r){const{commitment:i,config:s}=Fe(r);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const c=this._buildArgs(o,i,"base64",s),u=await this._rpcRequest("getTokenAccountsByOwner",c),f=wt(u,zF);if("error"in f)throw new Pt(f.error,`failed to get token accounts owned by account ${t.toBase58()}`);return f.result}async getParsedTokenAccountsByOwner(t,e,r){let i=[t.toBase58()];"mint"in e?i.push({mint:e.mint.toBase58()}):i.push({programId:e.programId.toBase58()});const s=this._buildArgs(i,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",s),c=wt(o,GF);if("error"in c)throw new Pt(c.error,`failed to get token accounts owned by account ${t.toBase58()}`);return c.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},r=e.filter||e.commitment?[e]:[],i=await this._rpcRequest("getLargestAccounts",r),s=wt(i,VF);if("error"in s)throw new Pt(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenLargestAccounts",r),s=wt(i,HF);if("error"in s)throw new Pt(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(t,e){const{commitment:r,config:i}=Fe(e),s=this._buildArgs([t.toBase58()],r,"base64",i),o=await this._rpcRequest("getAccountInfo",s),c=wt(o,An(vt(ih)));if("error"in c)throw new Pt(c.error,`failed to get info about account ${t.toBase58()}`);return c.result}async getParsedAccountInfo(t,e){const{commitment:r,config:i}=Fe(e),s=this._buildArgs([t.toBase58()],r,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",s),c=wt(o,An(vt(Gm)));if("error"in c)throw new Pt(c.error,`failed to get info about account ${t.toBase58()}`);return c.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(r){throw new Error("failed to get info about account "+t.toBase58()+": "+r)}}async getMultipleParsedAccounts(t,e){const{commitment:r,config:i}=Fe(e),s=t.map(f=>f.toBase58()),o=this._buildArgs([s],r,"jsonParsed",i),c=await this._rpcRequest("getMultipleAccounts",o),u=wt(c,An(Et(vt(Gm))));if("error"in u)throw new Pt(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:r,config:i}=Fe(e),s=t.map(f=>f.toBase58()),o=this._buildArgs([s],r,"base64",i),c=await this._rpcRequest("getMultipleAccounts",o),u=wt(c,An(Et(vt(ih))));if("error"in u)throw new Pt(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,r){const{commitment:i,config:s}=Fe(e),o=this._buildArgs([t.toBase58()],i,void 0,{...s,epoch:r??(s==null?void 0:s.epoch)}),c=await this._rpcRequest("getStakeActivation",o),u=wt(c,ee(ZF));if("error"in u)throw new Pt(u.error,`failed to get Stake Activation ${t.toBase58()}`);return u.result}async getProgramAccounts(t,e){const{commitment:r,config:i}=Fe(e),{encoding:s,...o}=i||{},c=this._buildArgs([t.toBase58()],r,s||"base64",{...o,...o.filters?{filters:AA(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",c),f=Et(KF),h=o.withContext===!0?wt(u,An(f)):wt(u,ee(f));if("error"in h)throw new Pt(h.error,`failed to get accounts owned by program ${t.toBase58()}`);return h.result}async getParsedProgramAccounts(t,e){const{commitment:r,config:i}=Fe(e),s=this._buildArgs([t.toBase58()],r,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",s),c=wt(o,ee(Et(WF)));if("error"in c)throw new Pt(c.error,`failed to get accounts owned by program ${t.toBase58()}`);return c.result}async confirmTransaction(t,e){var s;let r;if(typeof t=="string")r=t;else{const o=t;if((s=o.abortSignal)!=null&&s.aborted)return Promise.reject(o.abortSignal.reason);r=o.signature}let i;try{i=In.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return be(i.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:r}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise((e,r)=>{t!=null&&(t.aborted?r(t.reason):t.addEventListener("abort",()=>{r(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let r,i,s=!1;const o=new Promise((u,f)=>{try{r=this.onSignature(e,(y,A)=>{r=void 0;const b={context:A,value:y};u({__type:gs.PROCESSED,response:b})},t);const h=new Promise(y=>{r==null?y():i=this._onSubscriptionStateChange(r,A=>{A==="subscribed"&&y()})});(async()=>{if(await h,s)return;const y=await this.getSignatureStatus(e);if(s||y==null)return;const{context:A,value:b}=y;if(b!=null)if(b!=null&&b.err)f(b.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(b.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(b.confirmationStatus==="processed"||b.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,u({__type:gs.PROCESSED,response:{context:A,value:b}})}})()}catch(h){f(h)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:r,signature:i}}){let s=!1;const o=new Promise(y=>{const A=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let b=await A();if(!s){for(;b<=r;)if(await ga(1e3),s||(b=await A(),s))return;y({__type:gs.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:t,signature:i}),f=this.getCancellationPromise(e);let h;try{const y=await Promise.race([f,u,o]);if(y.__type===gs.PROCESSED)h=y.response;else throw new h1(i)}finally{s=!0,c()}return h}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:i,nonceValue:s,signature:o}}){let c=!1;const u=new Promise(b=>{let R=s,k=null;const S=async()=>{try{const{context:B,value:H}=await this.getNonceAndContext(i,{commitment:t,minContextSlot:r});return k=B.slot,H==null?void 0:H.nonce}catch{return R}};(async()=>{if(R=await S(),!c)for(;;){if(s!==R){b({__type:gs.NONCE_INVALID,slotInWhichNonceDidAdvance:k});return}if(await ga(2e3),c||(R=await S(),c))return}})()}),{abortConfirmation:f,confirmationPromise:h}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),y=this.getCancellationPromise(e);let A;try{const b=await Promise.race([y,h,u]);if(b.__type===gs.PROCESSED)A=b.response;else{let R;for(;;){const k=await this.getSignatureStatus(o);if(k==null)break;if(k.context.slot<(b.slotInWhichNonceDidAdvance??r)){await ga(400);continue}R=k;break}if(R!=null&&R.value){const k=t||"finalized",{confirmationStatus:S}=R.value;switch(k){case"processed":case"recent":if(S!=="processed"&&S!=="confirmed"&&S!=="finalized")throw new Qc(o);break;case"confirmed":case"single":case"singleGossip":if(S!=="confirmed"&&S!=="finalized")throw new Qc(o);break;case"finalized":case"max":case"root":if(S!=="finalized")throw new Qc(o);break;default:}A={context:R.context,value:{err:R.value.err}}}else throw new Qc(o)}}finally{c=!0,f()}return A}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const i=new Promise(u=>{let f=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{f=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>u({__type:gs.TIMED_OUT,timeoutMs:f}),f)}),{abortConfirmation:s,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let c;try{const u=await Promise.race([o,i]);if(u.__type===gs.PROCESSED)c=u.response;else throw new d1(e,u.timeoutMs/1e3)}finally{clearTimeout(r),s()}return c}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=wt(t,ee(Et(o7)));if("error"in e)throw new Pt(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getVoteAccounts",e),i=wt(r,a7);if("error"in i)throw new Pt(i.error,"failed to get vote accounts");return i.result}async getSlot(t){const{commitment:e,config:r}=Fe(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getSlot",i),o=wt(s,ee(X()));if("error"in o)throw new Pt(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:r}=Fe(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getSlotLeader",i),o=wt(s,ee(yt()));if("error"in o)throw new Pt(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const r=[t,e],i=await this._rpcRequest("getSlotLeaders",r),s=wt(i,ee(Et(sn)));if("error"in s)throw new Pt(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(t,e){const{context:r,value:i}=await this.getSignatureStatuses([t],e);be(i.length===1);const s=i[0];return{context:r,value:s}}async getSignatureStatuses(t,e){const r=[t];e&&r.push(e);const i=await this._rpcRequest("getSignatureStatuses",r),s=wt(i,l7);if("error"in s)throw new Pt(s.error,"failed to get signature status");return s.result}async getTransactionCount(t){const{commitment:e,config:r}=Fe(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getTransactionCount",i),o=wt(s,ee(X()));if("error"in o)throw new Pt(o.error,"failed to get transaction count");return o.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getInflationGovernor",e),i=wt(r,BF);if("error"in i)throw new Pt(i.error,"failed to get inflation");return i.result}async getInflationReward(t,e,r){const{commitment:i,config:s}=Fe(r),o=this._buildArgs([t.map(f=>f.toBase58())],i,void 0,{...s,epoch:e??(s==null?void 0:s.epoch)}),c=await this._rpcRequest("getInflationReward",o),u=wt(c,wF);if("error"in u)throw new Pt(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=wt(t,PF);if("error"in e)throw new Pt(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:r}=Fe(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getEpochInfo",i),o=wt(s,LF);if("error"in o)throw new Pt(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=wt(t,UF);if("error"in e)throw new Pt(e.error,"failed to get epoch schedule");const r=e.result;return new L2(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=wt(t,DF);if("error"in e)throw new Pt(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const r=this._buildArgs([t],e),i=await this._rpcRequest("getMinimumBalanceForRentExemption",r),s=wt(i,f7);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(t){const{context:e,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),r=wt(e,x7);if("error"in r)throw new Pt(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(t,e){const r=this._buildArgs([t],e),i=await this._rpcRequest("getFeeCalculatorForBlockhash",r),s=wt(i,R7);if("error"in s)throw new Pt(s.error,"failed to get fee calculator");const{context:o,value:c}=s.result;return{context:o,value:c!==null?c.feeCalculator:null}}async getFeeForMessage(t,e){const r=ne(t.serialize()).toString("base64"),i=this._buildArgs([r],e),s=await this._rpcRequest("getFeeForMessage",i),o=wt(s,An(vt(X())));if("error"in o)throw new Pt(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(t){var o;const e=(o=t==null?void 0:t.lockedWritableAccounts)==null?void 0:o.map(c=>c.toBase58()),r=e!=null&&e.length?[e]:[],i=await this._rpcRequest("getRecentPrioritizationFees",r),s=wt(i,MF);if("error"in s)throw new Pt(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:r}=Fe(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getLatestBlockhash",i),o=wt(s,A7);if("error"in o)throw new Pt(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:r,config:i}=Fe(e),s=this._buildArgs([t],r,void 0,i),o=await this._rpcRequest("isBlockhashValid",s),c=wt(o,E7);if("error"in c)throw new Pt(c.error,"failed to determine if the blockhash `"+t+"`is valid");return c.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=wt(t,ee(SF));if("error"in e)throw new Pt(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=wt(t,ee(yt()));if("error"in e)throw new Pt(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:r,config:i}=Fe(e),s=this._buildArgsAtLeastConfirmed([t],r,void 0,i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const c=wt(o,y7);if("error"in c)throw c.error;return c.result}case"none":{const c=wt(o,g7);if("error"in c)throw c.error;return c.result}default:{const c=wt(o,p7);if("error"in c)throw c.error;const{result:u}=c;return u?{...u,transactions:u.transactions.map(({transaction:f,meta:h,version:y})=>({meta:h,transaction:{...f,message:Py(y,f.message)},version:y}))}:null}}}catch(c){throw new Pt(c,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:r,config:i}=Fe(e),s=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const c=wt(o,w7);if("error"in c)throw c.error;return c.result}case"none":{const c=wt(o,b7);if("error"in c)throw c.error;return c.result}default:{const c=wt(o,m7);if("error"in c)throw c.error;return c.result}}}catch(c){throw new Pt(c,"failed to get block")}}async getBlockProduction(t){let e,r;if(typeof t=="string")r=t;else if(t){const{commitment:c,...u}=t;r=c,e=u}const i=this._buildArgs([],r,"base64",e),s=await this._rpcRequest("getBlockProduction",i),o=wt(s,TF);if("error"in o)throw new Pt(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:r,config:i}=Fe(e),s=this._buildArgsAtLeastConfirmed([t],r,void 0,i),o=await this._rpcRequest("getTransaction",s),c=wt(o,My);if("error"in c)throw new Pt(c.error,"failed to get transaction");const u=c.result;return u&&{...u,transaction:{...u.transaction,message:Py(u.version,u.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:r,config:i}=Fe(e),s=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",i),o=await this._rpcRequest("getTransaction",s),c=wt(o,Sd);if("error"in c)throw new Pt(c.error,"failed to get transaction");return c.result}async getParsedTransactions(t,e){const{commitment:r,config:i}=Fe(e),s=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],r,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(u=>{const f=wt(u,Sd);if("error"in f)throw new Pt(f.error,"failed to get transactions");return f.result})}async getTransactions(t,e){const{commitment:r,config:i}=Fe(e),s=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],r,void 0,i)}));return(await this._rpcBatchRequest(s)).map(u=>{const f=wt(u,My);if("error"in f)throw new Pt(f.error,"failed to get transactions");const h=f.result;return h&&{...h,transaction:{...h.transaction,message:Py(h.version,h.transaction.message)}}})}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getBlock",r),s=wt(i,_7);if("error"in s)throw new Pt(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+t+" not found");const c={...o,transactions:o.transactions.map(({transaction:u,meta:f})=>{const h=new xi(u.message);return{meta:f,transaction:{...u,message:h}}})};return{...c,transactions:c.transactions.map(({transaction:u,meta:f})=>({meta:f,transaction:Te.populate(u.message,u.signatures)}))}}async getBlocks(t,e,r){const i=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],r),s=await this._rpcRequest("getBlocks",i),o=wt(s,ee(Et(X())));if("error"in o)throw new Pt(o.error,"failed to get blocks");return o.result}async getBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=wt(i,xA);if("error"in s)throw new Pt(s.error,"failed to get block");const o=s.result;if(!o)throw new Error("Block "+t+" not found");return o}async getConfirmedBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=wt(i,xA);if("error"in s)throw new Pt(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getTransaction",r),s=wt(i,My);if("error"in s)throw new Pt(s.error,"failed to get transaction");const o=s.result;if(!o)return o;const c=new xi(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:Te.populate(c,u)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),i=await this._rpcRequest("getTransaction",r),s=wt(i,Sd);if("error"in s)throw new Pt(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(t,e){const r=t.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const c=wt(o,Sd);if("error"in c)throw new Pt(c.error,"failed to get confirmed transactions");return c.result})}async getConfirmedSignaturesForAddress(t,e,r){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&(e--,!(e<=0||e<s));)try{const u=await this.getConfirmedBlockSignatures(e,"finalized");u.signatures.length>0&&(i.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let o=await this.getSlot("finalized");for(;!("before"in i)&&(r++,!(r>o));)try{const u=await this.getConfirmedBlockSignatures(r);u.signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(t,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(t,e,r){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=wt(s,qF);if("error"in o)throw new Pt(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,r){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),s=await this._rpcRequest("getSignaturesForAddress",i),o=wt(s,QF);if("error"in o)throw new Pt(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:r,value:i}=await this.getAccountInfoAndContext(t,e);let s=null;return i!==null&&(s=new $m({key:t,state:$m.deserialize(i.data)})),{context:r,value:s}}async getNonceAndContext(t,e){const{context:r,value:i}=await this.getAccountInfoAndContext(t,e);let s=null;return i!==null&&(s=bp.fromAccountData(i.data)),{context:r,value:s}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+r)})}async requestAirdrop(t,e){const r=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),i=wt(r,S7);if("error"in i)throw new Pt(i.error,`airdrop to ${t.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await ga(100);const r=Date.now()-this._blockhashInfo.lastFetch>=D2;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,r=e?e.blockhash:null;for(let i=0;i<50;i++){const s=await this.getLatestBlockhash("finalized");if(r!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await ga(B2/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:r}=Fe(t),i=this._buildArgs([],e,"base64",r),s=await this._rpcRequest("getStakeMinimumDelegation",i),o=wt(s,An(X()));if("error"in o)throw new Pt(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,r){if("message"in t){const k=t.serialize(),S=It.from(k).toString("base64");if(Array.isArray(e)||r!==void 0)throw new Error("Invalid arguments");const B=e||{};B.encoding="base64","commitment"in B||(B.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(B.innerInstructions=e.innerInstructions);const H=[S,B],U=await this._rpcRequest("simulateTransaction",H),G=wt(U,EA);if("error"in G)throw new Error("failed to simulate transaction: "+G.error.message);return G.result}let i;if(t instanceof Te){let R=t;i=new Te,i.feePayer=R.feePayer,i.instructions=t.instructions,i.nonceInfo=R.nonceInfo,i.signatures=R.signatures}else i=Te.populate(t),i._message=i._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(i.nonceInfo&&s)i.sign(...s);else{let R=this._disableBlockhashCaching;for(;;){const k=await this._blockhashWithExpiryBlockHeight(R);if(i.lastValidBlockHeight=k.lastValidBlockHeight,i.recentBlockhash=k.blockhash,!s)break;if(i.sign(...s),!i.signature)throw new Error("!signature");const S=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(S)&&!this._blockhashInfo.transactionSignatures.includes(S)){this._blockhashInfo.simulatedSignatures.push(S);break}else R=!0}}const o=i._compile(),c=o.serialize(),f=i._serialize(c).toString("base64"),h={encoding:"base64",commitment:this.commitment};if(r){const R=(Array.isArray(r)?r:o.nonProgramIds()).map(k=>k.toBase58());h.accounts={encoding:"base64",addresses:R}}s&&(h.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(h.innerInstructions=e.innerInstructions);const y=[f,h],A=await this._rpcRequest("simulateTransaction",y),b=wt(A,EA);if("error"in b){let R;if("data"in b.error&&(R=b.error.data.logs,R&&Array.isArray(R))){const k=`
|
|
23
|
-
`,S=k+R.join(k);console.error(b.error.message,S)}throw new Jo({action:"simulate",signature:"",transactionMessage:b.error.message,logs:R})}return b.result}async sendTransaction(t,e,r){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const o=t.serialize();return await this.sendRawTransaction(o,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(t.nonceInfo)t.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){const c=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=c.lastValidBlockHeight,t.recentBlockhash=c.blockhash,t.sign(...i),!t.signature)throw new Error("!signature");const u=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const s=t.serialize();return await this.sendRawTransaction(s,r)}async sendRawTransaction(t,e){const r=ne(t).toString("base64");return await this.sendEncodedTransaction(r,e)}async sendEncodedTransaction(t,e){const r={encoding:"base64"},i=e&&e.skipPreflight,s=i===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(r.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(r.minContextSlot=e.minContextSlot),i&&(r.skipPreflight=i),s&&(r.preflightCommitment=s);const o=[t,r],c=await this._rpcRequest("sendTransaction",o),u=wt(c,I7);if("error"in u){let f;throw"data"in u.error&&(f=u.error.data.logs),new Jo({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:f})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,r])=>{this._setSubscription(e,{...r,state:"pending"})})}_setSubscription(t,e){var i;const r=(i=this._subscriptionsByHash[t])==null?void 0:i.state;if(this._subscriptionsByHash[t]=e,r!==e.state){const s=this._subscriptionStateChangeCallbacksByHash[t];s&&s.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var s;const r=this._subscriptionHashByClientSubscriptionId[t];if(r==null)return()=>{};const i=(s=this._subscriptionStateChangeCallbacksByHash)[r]||(s[r]=new Set);return i.add(e),()=>{i.delete(e),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{const i=this._subscriptionsByHash[r];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[r],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:s,method:o}=i;try{this._setSubscription(r,{...i,state:"subscribing"});const c=await this._rpcWebSocket.call(o,s);this._setSubscription(r,{...i,serverSubscriptionId:c,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[c]=i.callbacks,await this._updateSubscriptions()}catch(c){if(console.error(`Received ${c instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:s,error:c}),!e())return;this._setSubscription(r,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:s,unsubscribeMethod:o}=i;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(r,{...i,state:"unsubscribing"}),this._setSubscription(r,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[s])}catch(c){if(c instanceof Error&&console.error(`${o} error:`,c.message),!e())return;this._setSubscription(r,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const r=this._subscriptionCallbacksByServerSubscriptionId[t];r!==void 0&&r.forEach(i=>{try{i(...e)}catch(s){console.error(s)}})}_wsOnAccountNotification(t){const{result:e,subscription:r}=wt(t,JF);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,i=bA([t.method,e]),s=this._subscriptionsByHash[i];return s===void 0?this._subscriptionsByHash[i]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:s.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[i];be(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),o.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(t,e,r){const{commitment:i,config:s}=Fe(r),o=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:r}=wt(t,XF);this._handleServerNotification(r,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,r,i){const{commitment:s,config:o}=Fe(r),c=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",o||(i?{filters:AA(i)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},c)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,r){const i=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],r||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:r}=wt(t,T7);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=wt(t,e7);this._handleServerNotification(r,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:r}=wt(t,r7);this._handleServerNotification(r,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,r,i){const s=e||this._commitment;if(s||r||i){let o={};r&&(o.encoding=r),s&&(o.commitment=s),i&&(o=Object.assign(o,i)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,r,i){const s=e||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,r,i)}_wsOnSignatureNotification(t){const{result:e,subscription:r}=wt(t,i7);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,r){const i=this._buildArgs([t],r||this._commitment||"finalized"),s=this._makeSubscription({callback:(o,c)=>{if(o.type==="status"){e(o.result,c);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}onSignatureWithOptions(t,e,r){const{commitment:i,...s}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([t],i,void 0,s),c=this._makeSubscription({callback:(u,f)=>{e(u,f);try{this.removeSignatureListener(c)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return c}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:r}=wt(t,s7);this._handleServerNotification(r,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class tc{constructor(t){this._keypair=void 0,this._keypair=t??gA()}static generate(){return new tc(gA())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const r=t.slice(32,64);if(!e||!e.skipValidation){const i=t.slice(0,32),s=A0(i);for(let o=0;o<32;o++)if(r[o]!==s[o])throw new Error("provided secretKey is invalid")}return new tc({publicKey:r,secretKey:t})}static fromSeed(t){const e=A0(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),new tc({publicKey:e,secretKey:r})}get publicKey(){return new pt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const Fs=Object.freeze({CreateLookupTable:{index:0,layout:Ot([Tt("instruction"),cl("recentSlot"),ge("bumpSeed")])},FreezeLookupTable:{index:1,layout:Ot([Tt("instruction")])},ExtendLookupTable:{index:2,layout:Ot([Tt("instruction"),cl(),qn(ae(),$o(Tt(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Ot([Tt("instruction")])},CloseLookupTable:{index:4,layout:Ot([Tt("instruction")])}});class N7{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Tt("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Fs))if(o.index==r){i=s;break}if(!i)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return i}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Se(Fs.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=Se(Fs.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map(r=>new pt(r))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(_1.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}class _1{constructor(){}static createLookupTable(t){const[e,r]=pt.findProgramAddressSync([t.authority.toBuffer(),f2(BigInt(t.recentSlot),8)],this.programId),i=Fs.CreateLookupTable,s=de(i,{recentSlot:BigInt(t.recentSlot),bumpSeed:r}),o=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Tn.programId,isSigner:!1,isWritable:!1}];return[new Be({programId:this.programId,keys:o,data:s}),e]}static freezeLookupTable(t){const e=Fs.FreezeLookupTable,r=de(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Be({programId:this.programId,keys:i,data:r})}static extendLookupTable(t){const e=Fs.ExtendLookupTable,r=de(e,{addresses:t.addresses.map(s=>s.toBytes())}),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&i.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Tn.programId,isSigner:!1,isWritable:!1}),new Be({programId:this.programId,keys:i,data:r})}static deactivateLookupTable(t){const e=Fs.DeactivateLookupTable,r=de(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Be({programId:this.programId,keys:i,data:r})}static closeLookupTable(t){const e=Fs.CloseLookupTable,r=de(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Be({programId:this.programId,keys:i,data:r})}}_1.programId=new pt("AddressLookupTab1e1111111111111111111111111");class C7{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=ge("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Ki))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return i}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:r}=Se(Ki.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Se(Ki.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Se(Ki.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Se(Ki.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(A1.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Ki=Object.freeze({RequestUnits:{index:0,layout:Ot([ge("instruction"),Tt("units"),Tt("additionalFee")])},RequestHeapFrame:{index:1,layout:Ot([ge("instruction"),Tt("bytes")])},SetComputeUnitLimit:{index:2,layout:Ot([ge("instruction"),Tt("units")])},SetComputeUnitPrice:{index:3,layout:Ot([ge("instruction"),cl("microLamports")])}});class A1{constructor(){}static requestUnits(t){const e=Ki.RequestUnits,r=de(e,t);return new Be({keys:[],programId:this.programId,data:r})}static requestHeapFrame(t){const e=Ki.RequestHeapFrame,r=de(e,t);return new Be({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(t){const e=Ki.SetComputeUnitLimit,r=de(e,t);return new Be({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(t){const e=Ki.SetComputeUnitPrice,r=de(e,{microLamports:BigInt(t.microLamports)});return new Be({keys:[],programId:this.programId,data:r})}}A1.programId=new pt("ComputeBudget111111111111111111111111111111");const RA=64,SA=32,IA=64,kA=Ot([ge("numSignatures"),ge("padding"),ni("signatureOffset"),ni("signatureInstructionIndex"),ni("publicKeyOffset"),ni("publicKeyInstructionIndex"),ni("messageDataOffset"),ni("messageDataSize"),ni("messageInstructionIndex")]);class Ep{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:i,instructionIndex:s}=t;be(e.length===SA,`Public Key must be ${SA} bytes but received ${e.length} bytes`),be(i.length===IA,`Signature must be ${IA} bytes but received ${i.length} bytes`);const o=kA.span,c=o+e.length,u=c+i.length,f=1,h=It.alloc(u+r.length),y=s??65535;return kA.encode({numSignatures:f,padding:0,signatureOffset:c,signatureInstructionIndex:y,publicKeyOffset:o,publicKeyInstructionIndex:y,messageDataOffset:u,messageDataSize:r.length,messageInstructionIndex:y},h),h.fill(e,o),h.fill(i,c),h.fill(r,u),new Be({keys:[],programId:Ep.programId,data:h})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:i}=t;be(e.length===RA,`Private key must be ${RA} bytes but received ${e.length} bytes`);try{const s=tc.fromSecretKey(e),o=s.publicKey.toBytes(),c=l1(r,s.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:c,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}Ep.programId=new pt("Ed25519SigVerify111111111111111111111111111");const B7=(n,t)=>{const e=yp.sign(n,t);return[e.toCompactRawBytes(),e.recovery]};yp.utils.isValidPrivateKey;const P7=yp.getPublicKey,TA=32,Ly=20,OA=64,M7=11,Uy=Ot([ge("numSignatures"),ni("signatureOffset"),ge("signatureInstructionIndex"),ni("ethAddressOffset"),ge("ethAddressInstructionIndex"),ni("messageDataOffset"),ni("messageDataSize"),ge("messageInstructionIndex"),Ge(20,"ethAddress"),Ge(64,"signature"),ge("recoveryId")]);class ou{constructor(){}static publicKeyToEthAddress(t){be(t.length===OA,`Public key must be ${OA} bytes but received ${t.length} bytes`);try{return It.from(lA(ne(t))).slice(-Ly)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:i,recoveryId:s,instructionIndex:o}=t;return ou.createInstructionWithEthAddress({ethAddress:ou.publicKeyToEthAddress(e),message:r,signature:i,recoveryId:s,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:r,signature:i,recoveryId:s,instructionIndex:o=0}=t;let c;typeof e=="string"?e.startsWith("0x")?c=It.from(e.substr(2),"hex"):c=It.from(e,"hex"):c=e,be(c.length===Ly,`Address must be ${Ly} bytes but received ${c.length} bytes`);const u=1+M7,f=u,h=u+c.length,y=h+i.length+1,A=1,b=It.alloc(Uy.span+r.length);return Uy.encode({numSignatures:A,signatureOffset:h,signatureInstructionIndex:o,ethAddressOffset:f,ethAddressInstructionIndex:o,messageDataOffset:y,messageDataSize:r.length,messageInstructionIndex:o,signature:ne(i),ethAddress:ne(c),recoveryId:s},b),b.fill(ne(r),Uy.span),new Be({keys:[],programId:ou.programId,data:b})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:i}=t;be(e.length===TA,`Private key must be ${TA} bytes but received ${e.length} bytes`);try{const s=ne(e),o=P7(s,!1).slice(1),c=It.from(lA(ne(r))),[u,f]=B7(c,s);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:u,recoveryId:f,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}ou.programId=new pt("KeccakSecp256k11111111111111111111111111111");var q2;const Q2=new pt("StakeConfig11111111111111111111111111111111");class J2{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class Kh{constructor(t,e,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=r}}q2=Kh;Kh.default=new q2(0,0,pt.default);class L7{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Tt("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Ln))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a StakeInstruction");return i}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:r}=Se(Ln.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new J2(new pt(e.staker),new pt(e.withdrawer)),lockup:new Kh(r.unixTimestamp,r.epoch,new pt(r.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Se(Ln.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:r}=Se(Ln.Authorize,t.data),i={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new pt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(i.custodianPubkey=t.keys[3].pubkey),i}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:r,authoritySeed:i,authorityOwner:s}=Se(Ln.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:i,authorityOwner:new pt(s),newAuthorizedPubkey:new pt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(o.custodianPubkey=t.keys[3].pubkey),o}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Se(Ln.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Se(Ln.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Se(Ln.Withdraw,t.data),r={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(r.custodianPubkey=t.keys[5].pubkey),r}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Se(Ln.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(vp.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const Ln=Object.freeze({Initialize:{index:0,layout:Ot([Tt("instruction"),F9(),$9()])},Authorize:{index:1,layout:Ot([Tt("instruction"),ae("newAuthorized"),Tt("stakeAuthorizationType")])},Delegate:{index:2,layout:Ot([Tt("instruction")])},Split:{index:3,layout:Ot([Tt("instruction"),Hr("lamports")])},Withdraw:{index:4,layout:Ot([Tt("instruction"),Hr("lamports")])},Deactivate:{index:5,layout:Ot([Tt("instruction")])},Merge:{index:7,layout:Ot([Tt("instruction")])},AuthorizeWithSeed:{index:8,layout:Ot([Tt("instruction"),ae("newAuthorized"),Tt("stakeAuthorizationType"),_a("authoritySeed"),ae("authorityOwner")])}}),U7=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class vp{constructor(){}static initialize(t){const{stakePubkey:e,authorized:r,lockup:i}=t,s=i||Kh.default,o=Ln.Initialize,c=de(o,{authorized:{staker:ne(r.staker.toBuffer()),withdrawer:ne(r.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:ne(s.custodian.toBuffer())}}),u={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:al,isSigner:!1,isWritable:!1}],programId:this.programId,data:c};return new Be(u)}static createAccountWithSeed(t){const e=new Te;e.add(Tn.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:i,lockup:s}=t;return e.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static createAccount(t){const e=new Te;e.add(Tn.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:i,lockup:s}=t;return e.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:r,votePubkey:i}=t,s=Ln.Delegate,o=de(s);return new Te().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:Vd,isSigner:!1,isWritable:!1},{pubkey:Q2,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(t){const{stakePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:o}=t,c=Ln.Authorize,u=de(c,{newAuthorized:ne(i.toBuffer()),stakeAuthorizationType:s.index}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&f.push({pubkey:o,isSigner:!0,isWritable:!1}),new Te().add({keys:f,programId:this.programId,data:u})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:o,stakeAuthorizationType:c,custodianPubkey:u}=t,f=Ln.AuthorizeWithSeed,h=de(f,{newAuthorized:ne(o.toBuffer()),stakeAuthorizationType:c.index,authoritySeed:i,authorityOwner:ne(s.toBuffer())}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:zi,isSigner:!1,isWritable:!1}];return u&&y.push({pubkey:u,isSigner:!0,isWritable:!1}),new Te().add({keys:y,programId:this.programId,data:h})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:i,lamports:s}=t,o=Ln.Split,c=de(o,{lamports:s});return new Be({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:c})}static split(t,e){const r=new Te;return r.add(Tn.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),r.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,basePubkey:o,seed:c,lamports:u}=t,f=new Te;return f.add(Tn.allocate({accountPubkey:s,basePubkey:o,seed:c,space:this.space,programId:this.programId})),e&&e>0&&f.add(Tn.transfer({fromPubkey:t.authorizedPubkey,toPubkey:s,lamports:e})),f.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,lamports:u}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:r,authorizedPubkey:i}=t,s=Ln.Merge,o=de(s);return new Te().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:Vd,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:r,toPubkey:i,lamports:s,custodianPubkey:o}=t,c=Ln.Withdraw,u=de(c,{lamports:s}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:Vd,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&f.push({pubkey:o,isSigner:!0,isWritable:!1}),new Te().add({keys:f,programId:this.programId,data:u})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:r}=t,i=Ln.Deactivate,s=de(i);return new Te().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}vp.programId=new pt("Stake11111111111111111111111111111111111111");vp.space=200;class Y2{constructor(t,e,r,i){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=r,this.commission=i}}class D7{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Tt("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(ji))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a VoteInstruction");return i}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Se(ji.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new Y2(new pt(e.nodePubkey),new pt(e.authorizedVoter),new pt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:r}=Se(ji.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new pt(e),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:r,newAuthorized:i,voteAuthorizationType:s}}=Se(ji.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new pt(e),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new pt(i),voteAuthorizationType:{index:s},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Se(ji.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(Bl.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const ji=Object.freeze({InitializeAccount:{index:0,layout:Ot([Tt("instruction"),H9()])},Authorize:{index:1,layout:Ot([Tt("instruction"),ae("newAuthorized"),Tt("voteAuthorizationType")])},Withdraw:{index:3,layout:Ot([Tt("instruction"),Hr("lamports")])},UpdateValidatorIdentity:{index:4,layout:Ot([Tt("instruction")])},AuthorizeWithSeed:{index:10,layout:Ot([Tt("instruction"),z9()])}}),F7=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Bl{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:i}=t,s=ji.InitializeAccount,o=de(s,{voteInit:{nodePubkey:ne(i.nodePubkey.toBuffer()),authorizedVoter:ne(i.authorizedVoter.toBuffer()),authorizedWithdrawer:ne(i.authorizedWithdrawer.toBuffer()),commission:i.commission}}),c={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:al,isSigner:!1,isWritable:!1},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Be(c)}static createAccount(t){const e=new Te;return e.add(Tn.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:i,voteAuthorizationType:s}=t,o=ji.Authorize,c=de(o,{newAuthorized:ne(i.toBuffer()),voteAuthorizationType:s.index}),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Te().add({keys:u,programId:this.programId,data:c})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:o,votePubkey:c}=t,u=ji.AuthorizeWithSeed,f=de(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:ne(r.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:ne(s.toBuffer()),voteAuthorizationType:o.index}}),h=[{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:zi,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new Te().add({keys:h,programId:this.programId,data:f})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,lamports:i,toPubkey:s}=t,o=ji.Withdraw,c=de(o,{lamports:i}),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Te().add({keys:u,programId:this.programId,data:c})}static safeWithdraw(t,e,r){if(t.lamports>e-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return Bl.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,nodePubkey:i}=t,s=ji.UpdateValidatorIdentity,o=de(s),c=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Te().add({keys:c,programId:this.programId,data:o})}}Bl.programId=new pt("Vote111111111111111111111111111111111111111");Bl.space=3762;const X2=new pt("Va1idator1nfo111111111111111111111111111111"),$7=dt({name:yt(),website:Dt(yt()),details:Dt(yt()),iconUrl:Dt(yt()),keybaseUsername:Dt(yt())});class E1{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(vr(e)!==2)return null;const i=[];for(let s=0;s<2;s++){const o=new pt(xr(e,0,Xi)),c=Vi(e)===1;i.push({publicKey:o,isSigner:c})}if(i[0].publicKey.equals(X2)&&i[1].isSigner){const s=_a().decode(It.from(e)),o=JSON.parse(s);return h2(o,$7),new E1(i[1].publicKey,o)}return null}}const H7=new pt("Vote111111111111111111111111111111111111111"),z7=Ot([ae("nodePubkey"),ae("authorizedWithdrawer"),ge("commission"),zn(),qn(Ot([zn("slot"),Tt("confirmationCount")]),$o(Tt(),-8),"votes"),ge("rootSlotValid"),zn("rootSlot"),zn(),qn(Ot([zn("epoch"),ae("authorizedVoter")]),$o(Tt(),-8),"authorizedVoters"),Ot([qn(Ot([ae("authorizedPubkey"),zn("epochOfLastAuthorizedSwitch"),zn("targetEpoch")]),32,"buf"),zn("idx"),ge("isEmpty")],"priorVoters"),zn(),qn(Ot([zn("epoch"),zn("credits"),zn("prevCredits")]),$o(Tt(),-8),"epochCredits"),Ot([zn("slot"),zn("timestamp")],"lastTimestamp")]);class v1{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const r=z7.decode(ne(t),4);let i=r.rootSlot;return r.rootSlotValid||(i=null),new v1({nodePubkey:new pt(r.nodePubkey),authorizedWithdrawer:new pt(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:i,authorizedVoters:r.authorizedVoters.map(G7),priorVoters:V7(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function G7({authorizedVoter:n,epoch:t}){return{epoch:t,authorizedVoter:new pt(n)}}function NA({authorizedPubkey:n,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new pt(n),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function V7({buf:n,idx:t,isEmpty:e}){return e?[]:[...n.slice(t+1).map(NA),...n.slice(0,t).map(NA)]}const CA={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function K7(n,t){const e=t===!1?"http":"https";if(!n)return CA[e].devnet;const r=CA[e][n];if(!r)throw new Error(`Unknown ${e} cluster: ${n}`);return r}async function j7(n,t,e,r){let i,s;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(i=e,s=r):s=e;const o=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},c=await n.sendRawTransaction(t,o),u=s&&s.commitment,h=(await(i?n.confirmTransaction(i,u):n.confirmTransaction(c,u))).value;if(h.err)throw c!=null?new Jo({action:o!=null&&o.skipPreflight?"send":"simulate",signature:c,transactionMessage:`Status: (${JSON.stringify(h)})`}):new Error(`Raw transaction ${c} failed (${JSON.stringify(h)})`);return c}const W7=1e9,Z7=Object.freeze(Object.defineProperty({__proto__:null,Account:L9,AddressLookupTableAccount:$m,AddressLookupTableInstruction:N7,AddressLookupTableProgram:_1,Authorized:J2,BLOCKHASH_CACHE_TIMEOUT_MS:D2,BPF_LOADER_DEPRECATED_PROGRAM_ID:U9,BPF_LOADER_PROGRAM_ID:rF,BpfLoader:iF,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Ki,ComputeBudgetInstruction:C7,ComputeBudgetProgram:A1,Connection:Z2,Ed25519Program:Ep,Enum:P9,EpochSchedule:L2,FeeCalculatorLayout:P2,Keypair:tc,LAMPORTS_PER_SOL:W7,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Fs,Loader:lc,Lockup:Kh,MAX_SEED_LENGTH:O2,Message:xi,MessageAccountKeys:rh,MessageV0:uc,NONCE_ACCOUNT_LENGTH:Fm,NonceAccount:bp,PACKET_DATA_SIZE:Ho,PUBLIC_KEY_LENGTH:Xi,PublicKey:pt,SIGNATURE_LENGTH_IN_BYTES:nh,SOLANA_SCHEMA:Nf,STAKE_CONFIG_ID:Q2,STAKE_INSTRUCTION_LAYOUTS:Ln,SYSTEM_INSTRUCTION_LAYOUTS:$e,SYSVAR_CLOCK_PUBKEY:zi,SYSVAR_EPOCH_SCHEDULE_PUBKEY:W9,SYSVAR_INSTRUCTIONS_PUBKEY:Z9,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:Gd,SYSVAR_RENT_PUBKEY:al,SYSVAR_REWARDS_PUBKEY:q9,SYSVAR_SLOT_HASHES_PUBKEY:Q9,SYSVAR_SLOT_HISTORY_PUBKEY:J9,SYSVAR_STAKE_HISTORY_PUBKEY:Vd,Secp256k1Program:ou,SendTransactionError:Jo,SolanaJSONRPCError:Pt,SolanaJSONRPCErrorCode:Y9,StakeAuthorizationLayout:U7,StakeInstruction:L7,StakeProgram:vp,Struct:f1,SystemInstruction:eF,SystemProgram:Tn,Transaction:Te,TransactionExpiredBlockheightExceededError:h1,TransactionExpiredNonceInvalidError:Qc,TransactionExpiredTimeoutError:d1,TransactionInstruction:Be,TransactionMessage:g1,TransactionStatus:gs,VALIDATOR_INFO_KEY:X2,VERSION_PREFIX_MASK:mp,VOTE_PROGRAM_ID:H7,ValidatorInfo:E1,VersionedMessage:p1,VersionedTransaction:y1,VoteAccount:v1,VoteAuthorizationLayout:F7,VoteInit:Y2,VoteInstruction:D7,VoteProgram:Bl,clusterApiUrl:K7,sendAndConfirmRawTransaction:j7,sendAndConfirmTransaction:Dm},Symbol.toStringTag,{value:"Module"}));var x1={exports:{}};const q7=/[\p{Lu}]/u,Q7=/[\p{Ll}]/u,BA=/^[\p{Lu}](?![\p{Lu}])/gu,tR=/([\p{Alpha}\p{N}_]|$)/u,eR=/[_.\- ]+/,J7=new RegExp("^"+eR.source),PA=new RegExp(eR.source+tR.source,"gu"),MA=new RegExp("\\d+"+tR.source,"gu"),Y7=(n,t,e)=>{let r=!1,i=!1,s=!1;for(let o=0;o<n.length;o++){const c=n[o];r&&q7.test(c)?(n=n.slice(0,o)+"-"+n.slice(o),r=!1,s=i,i=!0,o++):i&&s&&Q7.test(c)?(n=n.slice(0,o-1)+"-"+n.slice(o-1),s=i,i=!1,r=!0):(r=t(c)===c&&e(c)!==c,s=i,i=e(c)===c&&t(c)!==c)}return n},X7=(n,t)=>(BA.lastIndex=0,n.replace(BA,e=>t(e))),t$=(n,t)=>(PA.lastIndex=0,MA.lastIndex=0,n.replace(PA,(e,r)=>t(r)).replace(MA,e=>t(e))),nR=(n,t)=>{if(!(typeof n=="string"||Array.isArray(n)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(n)?n=n.map(s=>s.trim()).filter(s=>s.length).join("-"):n=n.trim(),n.length===0)return"";const e=t.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(t.locale),r=t.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(t.locale);return n.length===1?t.pascalCase?r(n):e(n):(n!==e(n)&&(n=Y7(n,e,r)),n=n.replace(J7,""),t.preserveConsecutiveUppercase?n=X7(n,e):n=e(n),t.pascalCase&&(n=r(n.charAt(0))+n.slice(1)),t$(n,r))};x1.exports=nR;x1.exports.default=nR;var e$=x1.exports;const n$=ea(e$);var qt={},xt={};let Ne=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};xt.Layout=Ne;function R1(n,t){return t.property?n+"["+t.property+"]":n}xt.nameWithProperty=R1;function r$(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(n.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Ne))throw new TypeError("layout must be a Layout");if(t.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value:function(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(n,"decode",{value:function(e,r){return t.decode(e,r)},writable:!0})}xt.bindConstructorLayout=r$;let kr=class extends Ne{isCount(){throw new Error("ExternalLayout is abstract")}};class rR extends kr{constructor(t,e){if(t===void 0&&(t=1),!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e){e===void 0&&(e=0);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}let S1=class extends kr{constructor(t,e,r){if(!(t instanceof Ne))throw new TypeError("layout must be a Layout");if(e===void 0)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof us||this.layout instanceof Js}decode(t,e){return e===void 0&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return r===void 0&&(r=0),this.layout.encode(t,e,r+this.offset)}},us=class extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntLE(t,r,this.span),this.span}},Js=class extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntBE(t,r,this.span),this.span}};class xc extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeIntLE(t,r,this.span),this.span}}class Pl extends Ne{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeIntBE(t,r,this.span),this.span}}const Vm=Math.pow(2,32);function xp(n){const t=Math.floor(n/Vm),e=n-t*Vm;return{hi32:t,lo32:e}}function Rp(n,t){return n*Vm+t}let i$=class extends Ne{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readUInt32LE(e+4);return Rp(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=xp(t);return e.writeUInt32LE(i.lo32,r),e.writeUInt32LE(i.hi32,r+4),8}};class s$ extends Ne{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32BE(e),i=t.readUInt32BE(e+4);return Rp(r,i)}encode(t,e,r){r===void 0&&(r=0);const i=xp(t);return e.writeUInt32BE(i.hi32,r),e.writeUInt32BE(i.lo32,r+4),8}}let o$=class extends Ne{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readInt32LE(e+4);return Rp(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=xp(t);return e.writeUInt32LE(i.lo32,r),e.writeInt32LE(i.hi32,r+4),8}};class a$ extends Ne{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readInt32BE(e),i=t.readUInt32BE(e+4);return Rp(r,i)}encode(t,e,r){r===void 0&&(r=0);const i=xp(t);return e.writeInt32BE(i.hi32,r),e.writeUInt32BE(i.lo32,r+4),8}}class iR extends Ne{constructor(t){super(4,t)}decode(t,e){return e===void 0&&(e=0),t.readFloatLE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeFloatLE(t,r),4}}class sR extends Ne{constructor(t){super(4,t)}decode(t,e){return e===void 0&&(e=0),t.readFloatBE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeFloatBE(t,r),4}}class oR extends Ne{constructor(t){super(8,t)}decode(t,e){return e===void 0&&(e=0),t.readDoubleLE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeDoubleLE(t,r),8}}class aR extends Ne{constructor(t){super(8,t)}decode(t,e){return e===void 0&&(e=0),t.readDoubleBE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeDoubleBE(t,r),8}}class cR extends Ne{constructor(t,e,r){if(!(t instanceof Ne))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof kr&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(e instanceof kr)&&0<t.span&&(i=e*t.span),super(i,r),this.elementLayout=t,this.count=e}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0,i=this.count;if(i instanceof kr&&(i=i.decode(t,e)),0<this.elementLayout.span)r=i*this.elementLayout.span;else{let s=0;for(;s<i;)r+=this.elementLayout.getSpan(t,e+r),++s}return r}decode(t,e){e===void 0&&(e=0);const r=[];let i=0,s=this.count;for(s instanceof kr&&(s=s.decode(t,e));i<s;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),i+=1;return r}encode(t,e,r){r===void 0&&(r=0);const i=this.elementLayout,s=t.reduce((o,c)=>o+i.encode(c,e,r+o),0);return this.count instanceof kr&&this.count.encode(t.length,e,r),s}}let uR=class extends Ne{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Ne,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e){e===void 0&&(e=0);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){r===void 0&&(r=0);const i=r;let s=0,o=0;for(const c of this.fields){let u=c.span;if(o=0<u?u:0,c.property!==void 0){const f=t[c.property];f!==void 0&&(o=c.encode(f,e,r),0>u&&(u=c.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}},I1=class{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}},v0=class extends I1{constructor(t,e){if(!(t instanceof kr&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}},k1=class extends Ne{constructor(t,e,r){const i=t instanceof us||t instanceof Js;if(i)t=new v0(new S1(t));else if(t instanceof kr&&t.isCount())t=new v0(t);else if(!(t instanceof I1))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Ne))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&i&&(s+=t.layout.span)),super(s,r),this.discriminator=t,this.usesPrefixDiscriminator=i,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(c){return o(c)},this.configGetSourceVariant=function(c){o=c.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){e===void 0&&(e=0);let r;const i=this.discriminator,s=i.decode(t,e);let o=this.registry[s];if(o===void 0){let c=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(c=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[o.property]=this.defaultLayout.decode(t,e+c)}else r=o.decode(t,e);return r}encode(t,e,r){r===void 0&&(r=0);const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let c=0;return this.usesPrefixDiscriminator&&(c=s.layout.span),s.encode(t[s.property],e,r),c+o.encode(t[o.property],e,r+c)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new lR(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e){let r=t;return Zt.isBuffer(t)&&(e===void 0&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}},lR=class extends Ne{constructor(t,e,r,i){if(!(t instanceof k1))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Ne))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(e===void 0&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){r===void 0&&(r=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};function Vc(n){return 0>n&&(n+=4294967296),n}class T1 extends Ne{constructor(t,e,r){if(!(t instanceof us||t instanceof Js))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&r===void 0&&(r=e,e=void 0),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let i=0;this._packedSetValue=function(s){return i=Vc(s),this},this._packedGetValue=function(){return i}}decode(t,e){const r=this.makeDestinationObject();e===void 0&&(e=0);const i=this.word.decode(t,e);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(r[s.property]=s.decode(i));return r}encode(t,e,r){r===void 0&&(r=0);const i=this.word.decode(e,r);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=t[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new Cf(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new fR(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}class Cf{constructor(t,e,r){if(!(t instanceof T1))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const i=8*t.span,s=t.fields.reduce((o,c)=>o+c.bits,0);if(e+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-e),this.wordMask=Vc(this.valueMask<<this.start),this.property=r}decode(){const t=this.container._packedGetValue();return Vc(t&this.wordMask)>>>this.start}encode(t){if(!Number.isInteger(t)||t!==Vc(t&this.valueMask))throw new TypeError(R1("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=Vc(t<<this.start);this.container._packedSetValue(Vc(e&~this.wordMask)|r)}}let fR=class extends Cf{constructor(t,e){super(t,1,e)}decode(t,e){return!!Cf.prototype.decode.call(this,t,e)}encode(t){return typeof t=="boolean"&&(t=+t),Cf.prototype.encode.call(this,t)}},hR=class extends Ne{constructor(t,e){if(!(t instanceof kr&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof kr||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){e===void 0&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof kr&&(i=t.length),!(Zt.isBuffer(t)&&i===t.length))throw new TypeError(R1("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,i,"hex"),this.length instanceof kr&&this.length.encode(i,e,r),i}};class dR extends Ne{constructor(t){super(-1,t)}getSpan(t,e){if(!Zt.isBuffer(t))throw new TypeError("b must be a Buffer");e===void 0&&(e=0);let r=e;for(;r<t.length&&t[r]!==0;)r+=1;return 1+r-e}decode(t,e,r){e===void 0&&(e=0);let i=this.getSpan(t,e);return t.slice(e,e+i-1).toString("utf-8")}encode(t,e,r){r===void 0&&(r=0),typeof t!="string"&&(t=t.toString());const i=new Zt(t,"utf8"),s=i.length;if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(e,r),e[r+s]=0,s+1}}class pR extends Ne{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e){if(!Zt.isBuffer(t))throw new TypeError("b must be a Buffer");return e===void 0&&(e=0),t.length-e}decode(t,e,r){e===void 0&&(e=0);let i=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");return t.slice(e,e+i).toString("utf-8")}encode(t,e,r){r===void 0&&(r=0),typeof t!="string"&&(t=t.toString());const i=new Zt(t,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(e,r),s}}class gR extends Ne{constructor(t,e){super(0,e),this.value=t}decode(t,e,r){return this.value}encode(t,e,r){return 0}}xt.ExternalLayout=kr;xt.GreedyCount=rR;xt.OffsetLayout=S1;xt.UInt=us;xt.UIntBE=Js;xt.Int=xc;xt.IntBE=Pl;xt.Float=iR;xt.FloatBE=sR;xt.Double=oR;xt.DoubleBE=aR;xt.Sequence=cR;xt.Structure=uR;xt.UnionDiscriminator=I1;xt.UnionLayoutDiscriminator=v0;xt.Union=k1;xt.VariantLayout=lR;xt.BitStructure=T1;xt.BitField=Cf;xt.Boolean=fR;xt.Blob=hR;xt.CString=dR;xt.UTF8=pR;xt.Constant=gR;xt.greedy=(n,t)=>new rR(n,t);xt.offset=(n,t,e)=>new S1(n,t,e);xt.u8=n=>new us(1,n);xt.u16=n=>new us(2,n);xt.u24=n=>new us(3,n);xt.u32=n=>new us(4,n);xt.u40=n=>new us(5,n);xt.u48=n=>new us(6,n);xt.nu64=n=>new i$(n);xt.u16be=n=>new Js(2,n);xt.u24be=n=>new Js(3,n);xt.u32be=n=>new Js(4,n);xt.u40be=n=>new Js(5,n);xt.u48be=n=>new Js(6,n);xt.nu64be=n=>new s$(n);xt.s8=n=>new xc(1,n);xt.s16=n=>new xc(2,n);xt.s24=n=>new xc(3,n);xt.s32=n=>new xc(4,n);xt.s40=n=>new xc(5,n);xt.s48=n=>new xc(6,n);xt.ns64=n=>new o$(n);xt.s16be=n=>new Pl(2,n);xt.s24be=n=>new Pl(3,n);xt.s32be=n=>new Pl(4,n);xt.s40be=n=>new Pl(5,n);xt.s48be=n=>new Pl(6,n);xt.ns64be=n=>new a$(n);xt.f32=n=>new iR(n);xt.f32be=n=>new sR(n);xt.f64=n=>new oR(n);xt.f64be=n=>new aR(n);xt.struct=(n,t,e)=>new uR(n,t,e);xt.bits=(n,t,e)=>new T1(n,t,e);xt.seq=(n,t,e)=>new cR(n,t,e);xt.union=(n,t,e)=>new k1(n,t,e);xt.unionLayoutDiscriminator=(n,t)=>new v0(n,t);xt.blob=(n,t)=>new hR(n,t);xt.cstr=n=>new dR(n);xt.utf8=(n,t)=>new pR(n,t);xt.const=(n,t)=>new gR(n,t);const c$=q0(Z7);(function(n){var t=Zn&&Zn.__importDefault||function(ot){return ot&&ot.__esModule?ot:{default:ot}};Object.defineProperty(n,"__esModule",{value:!0}),n.struct=n.f64=n.f32=n.i32=n.u32=n.i16=n.u16=n.i8=n.u8=void 0,n.u64=c,n.i64=u,n.u128=f,n.i128=h,n.u256=y,n.i256=A,n.publicKey=R,n.option=S,n.bool=B,n.vec=G,n.tagged=W,n.vecU8=Y,n.str=j,n.rustEnum=J,n.array=it,n.map=rt;const e=xt,r=c$,i=t(Kw);var s=xt;Object.defineProperty(n,"u8",{enumerable:!0,get:function(){return s.u8}}),Object.defineProperty(n,"i8",{enumerable:!0,get:function(){return s.s8}}),Object.defineProperty(n,"u16",{enumerable:!0,get:function(){return s.u16}}),Object.defineProperty(n,"i16",{enumerable:!0,get:function(){return s.s16}}),Object.defineProperty(n,"u32",{enumerable:!0,get:function(){return s.u32}}),Object.defineProperty(n,"i32",{enumerable:!0,get:function(){return s.s32}}),Object.defineProperty(n,"f32",{enumerable:!0,get:function(){return s.f32}}),Object.defineProperty(n,"f64",{enumerable:!0,get:function(){return s.f64}}),Object.defineProperty(n,"struct",{enumerable:!0,get:function(){return s.struct}});class o extends e.Layout{constructor(C,p,m){super(C,m),this.blob=(0,e.blob)(C),this.signed=p}decode(C,p=0){const m=new i.default(this.blob.decode(C,p),10,"le");return this.signed?m.fromTwos(this.span*8).clone():m}encode(C,p,m=0){return this.signed&&(C=C.toTwos(this.span*8)),this.blob.encode(C.toArrayLike(Zt,"le",this.span),p,m)}}function c(ot){return new o(8,!1,ot)}function u(ot){return new o(8,!0,ot)}function f(ot){return new o(16,!1,ot)}function h(ot){return new o(16,!0,ot)}function y(ot){return new o(32,!1,ot)}function A(ot){return new o(32,!0,ot)}class b extends e.Layout{constructor(C,p,m,v){super(C.span,v),this.layout=C,this.decoder=p,this.encoder=m}decode(C,p){return this.decoder(this.layout.decode(C,p))}encode(C,p,m){return this.layout.encode(this.encoder(C),p,m)}getSpan(C,p){return this.layout.getSpan(C,p)}}function R(ot){return new b((0,e.blob)(32),C=>new r.PublicKey(C),C=>C.toBuffer(),ot)}class k extends e.Layout{constructor(C,p){super(-1,p),this.layout=C,this.discriminator=(0,e.u8)()}encode(C,p,m=0){return C==null?this.discriminator.encode(0,p,m):(this.discriminator.encode(1,p,m),this.layout.encode(C,p,m+1)+1)}decode(C,p=0){const m=this.discriminator.decode(C,p);if(m===0)return null;if(m===1)return this.layout.decode(C,p+1);throw new Error("Invalid option "+this.property)}getSpan(C,p=0){const m=this.discriminator.decode(C,p);if(m===0)return 1;if(m===1)return this.layout.getSpan(C,p+1)+1;throw new Error("Invalid option "+this.property)}}function S(ot,C){return new k(ot,C)}function B(ot){return new b((0,e.u8)(),H,U,ot)}function H(ot){if(ot===0)return!1;if(ot===1)return!0;throw new Error("Invalid bool: "+ot)}function U(ot){return ot?1:0}function G(ot,C){const p=(0,e.u32)("length"),m=(0,e.struct)([p,(0,e.seq)(ot,(0,e.offset)(p,-p.span),"values")]);return new b(m,({values:v})=>v,v=>({values:v}),C)}function W(ot,C,p){const m=(0,e.struct)([c("tag"),C.replicate("data")]);function v({tag:I,data:N}){if(!I.eq(ot))throw new Error("Invalid tag, expected: "+ot.toString("hex")+", got: "+I.toString("hex"));return N}return new b(m,v,I=>({tag:ot,data:I}),p)}function Y(ot){const C=(0,e.u32)("length"),p=(0,e.struct)([C,(0,e.blob)((0,e.offset)(C,-C.span),"data")]);return new b(p,({data:m})=>m,m=>({data:m}),ot)}function j(ot){return new b(Y(),C=>C.toString("utf-8"),C=>Zt.from(C,"utf-8"),ot)}function J(ot,C,p){const m=(0,e.union)(p??(0,e.u8)(),C);return ot.forEach((v,I)=>m.addVariant(I,v,v.property)),m}function it(ot,C,p){const m=(0,e.struct)([(0,e.seq)(ot,C,"values")]);return new b(m,({values:v})=>v,v=>({values:v}),p)}class ut extends e.Layout{constructor(C,p,m){super(C.span+p.span,m),this.keyLayout=C,this.valueLayout=p}decode(C,p){p=p||0;const m=this.keyLayout.decode(C,p),v=this.valueLayout.decode(C,p+this.keyLayout.getSpan(C,p));return[m,v]}encode(C,p,m){m=m||0;const v=this.keyLayout.encode(C[0],p,m),I=this.valueLayout.encode(C[1],p,m+v);return v+I}getSpan(C,p){return this.keyLayout.getSpan(C,p)+this.valueLayout.getSpan(C,p)}}function rt(ot,C,p){const m=(0,e.u32)("length"),v=(0,e.struct)([m,(0,e.seq)(new ut(ot,C),(0,e.offset)(m,-m.span),"values")]);return new b(v,({values:I})=>new Map(I),I=>({values:Array.from(I.entries())}),p)}})(qt);/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const u$=4,LA=0,UA=1,l$=2;function Ml(n){let t=n.length;for(;--t>=0;)n[t]=0}const f$=0,yR=1,h$=2,d$=3,p$=258,O1=29,jh=256,sh=jh+1+O1,au=30,N1=19,mR=2*sh+1,Aa=15,Dy=16,g$=7,C1=256,wR=16,bR=17,_R=18,Km=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]),Kd=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]),y$=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),AR=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),m$=512,As=new Array((sh+2)*2);Ml(As);const Bf=new Array(au*2);Ml(Bf);const oh=new Array(m$);Ml(oh);const ah=new Array(p$-d$+1);Ml(ah);const B1=new Array(O1);Ml(B1);const x0=new Array(au);Ml(x0);function Fy(n,t,e,r,i){this.static_tree=n,this.extra_bits=t,this.extra_base=e,this.elems=r,this.max_length=i,this.has_stree=n&&n.length}let ER,vR,xR;function $y(n,t){this.dyn_tree=n,this.max_code=0,this.stat_desc=t}const RR=n=>n<256?oh[n]:oh[256+(n>>>7)],ch=(n,t)=>{n.pending_buf[n.pending++]=t&255,n.pending_buf[n.pending++]=t>>>8&255},Tr=(n,t,e)=>{n.bi_valid>Dy-e?(n.bi_buf|=t<<n.bi_valid&65535,ch(n,n.bi_buf),n.bi_buf=t>>Dy-n.bi_valid,n.bi_valid+=e-Dy):(n.bi_buf|=t<<n.bi_valid&65535,n.bi_valid+=e)},Wi=(n,t,e)=>{Tr(n,e[t*2],e[t*2+1])},SR=(n,t)=>{let e=0;do e|=n&1,n>>>=1,e<<=1;while(--t>0);return e>>>1},w$=n=>{n.bi_valid===16?(ch(n,n.bi_buf),n.bi_buf=0,n.bi_valid=0):n.bi_valid>=8&&(n.pending_buf[n.pending++]=n.bi_buf&255,n.bi_buf>>=8,n.bi_valid-=8)},b$=(n,t)=>{const e=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,c=t.stat_desc.extra_base,u=t.stat_desc.max_length;let f,h,y,A,b,R,k=0;for(A=0;A<=Aa;A++)n.bl_count[A]=0;for(e[n.heap[n.heap_max]*2+1]=0,f=n.heap_max+1;f<mR;f++)h=n.heap[f],A=e[e[h*2+1]*2+1]+1,A>u&&(A=u,k++),e[h*2+1]=A,!(h>r)&&(n.bl_count[A]++,b=0,h>=c&&(b=o[h-c]),R=e[h*2],n.opt_len+=R*(A+b),s&&(n.static_len+=R*(i[h*2+1]+b)));if(k!==0){do{for(A=u-1;n.bl_count[A]===0;)A--;n.bl_count[A]--,n.bl_count[A+1]+=2,n.bl_count[u]--,k-=2}while(k>0);for(A=u;A!==0;A--)for(h=n.bl_count[A];h!==0;)y=n.heap[--f],!(y>r)&&(e[y*2+1]!==A&&(n.opt_len+=(A-e[y*2+1])*e[y*2],e[y*2+1]=A),h--)}},IR=(n,t,e)=>{const r=new Array(Aa+1);let i=0,s,o;for(s=1;s<=Aa;s++)i=i+e[s-1]<<1,r[s]=i;for(o=0;o<=t;o++){let c=n[o*2+1];c!==0&&(n[o*2]=SR(r[c]++,c))}},_$=()=>{let n,t,e,r,i;const s=new Array(Aa+1);for(e=0,r=0;r<O1-1;r++)for(B1[r]=e,n=0;n<1<<Km[r];n++)ah[e++]=r;for(ah[e-1]=r,i=0,r=0;r<16;r++)for(x0[r]=i,n=0;n<1<<Kd[r];n++)oh[i++]=r;for(i>>=7;r<au;r++)for(x0[r]=i<<7,n=0;n<1<<Kd[r]-7;n++)oh[256+i++]=r;for(t=0;t<=Aa;t++)s[t]=0;for(n=0;n<=143;)As[n*2+1]=8,n++,s[8]++;for(;n<=255;)As[n*2+1]=9,n++,s[9]++;for(;n<=279;)As[n*2+1]=7,n++,s[7]++;for(;n<=287;)As[n*2+1]=8,n++,s[8]++;for(IR(As,sh+1,s),n=0;n<au;n++)Bf[n*2+1]=5,Bf[n*2]=SR(n,5);ER=new Fy(As,Km,jh+1,sh,Aa),vR=new Fy(Bf,Kd,0,au,Aa),xR=new Fy(new Array(0),y$,0,N1,g$)},kR=n=>{let t;for(t=0;t<sh;t++)n.dyn_ltree[t*2]=0;for(t=0;t<au;t++)n.dyn_dtree[t*2]=0;for(t=0;t<N1;t++)n.bl_tree[t*2]=0;n.dyn_ltree[C1*2]=1,n.opt_len=n.static_len=0,n.sym_next=n.matches=0},TR=n=>{n.bi_valid>8?ch(n,n.bi_buf):n.bi_valid>0&&(n.pending_buf[n.pending++]=n.bi_buf),n.bi_buf=0,n.bi_valid=0},DA=(n,t,e,r)=>{const i=t*2,s=e*2;return n[i]<n[s]||n[i]===n[s]&&r[t]<=r[e]},Hy=(n,t,e)=>{const r=n.heap[e];let i=e<<1;for(;i<=n.heap_len&&(i<n.heap_len&&DA(t,n.heap[i+1],n.heap[i],n.depth)&&i++,!DA(t,r,n.heap[i],n.depth));)n.heap[e]=n.heap[i],e=i,i<<=1;n.heap[e]=r},FA=(n,t,e)=>{let r,i,s=0,o,c;if(n.sym_next!==0)do r=n.pending_buf[n.sym_buf+s++]&255,r+=(n.pending_buf[n.sym_buf+s++]&255)<<8,i=n.pending_buf[n.sym_buf+s++],r===0?Wi(n,i,t):(o=ah[i],Wi(n,o+jh+1,t),c=Km[o],c!==0&&(i-=B1[o],Tr(n,i,c)),r--,o=RR(r),Wi(n,o,e),c=Kd[o],c!==0&&(r-=x0[o],Tr(n,r,c)));while(s<n.sym_next);Wi(n,C1,t)},jm=(n,t)=>{const e=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,c,u=-1,f;for(n.heap_len=0,n.heap_max=mR,o=0;o<s;o++)e[o*2]!==0?(n.heap[++n.heap_len]=u=o,n.depth[o]=0):e[o*2+1]=0;for(;n.heap_len<2;)f=n.heap[++n.heap_len]=u<2?++u:0,e[f*2]=1,n.depth[f]=0,n.opt_len--,i&&(n.static_len-=r[f*2+1]);for(t.max_code=u,o=n.heap_len>>1;o>=1;o--)Hy(n,e,o);f=s;do o=n.heap[1],n.heap[1]=n.heap[n.heap_len--],Hy(n,e,1),c=n.heap[1],n.heap[--n.heap_max]=o,n.heap[--n.heap_max]=c,e[f*2]=e[o*2]+e[c*2],n.depth[f]=(n.depth[o]>=n.depth[c]?n.depth[o]:n.depth[c])+1,e[o*2+1]=e[c*2+1]=f,n.heap[1]=f++,Hy(n,e,1);while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],b$(n,t),IR(e,u,n.bl_count)},$A=(n,t,e)=>{let r,i=-1,s,o=t[0*2+1],c=0,u=7,f=4;for(o===0&&(u=138,f=3),t[(e+1)*2+1]=65535,r=0;r<=e;r++)s=o,o=t[(r+1)*2+1],!(++c<u&&s===o)&&(c<f?n.bl_tree[s*2]+=c:s!==0?(s!==i&&n.bl_tree[s*2]++,n.bl_tree[wR*2]++):c<=10?n.bl_tree[bR*2]++:n.bl_tree[_R*2]++,c=0,i=s,o===0?(u=138,f=3):s===o?(u=6,f=3):(u=7,f=4))},HA=(n,t,e)=>{let r,i=-1,s,o=t[0*2+1],c=0,u=7,f=4;for(o===0&&(u=138,f=3),r=0;r<=e;r++)if(s=o,o=t[(r+1)*2+1],!(++c<u&&s===o)){if(c<f)do Wi(n,s,n.bl_tree);while(--c!==0);else s!==0?(s!==i&&(Wi(n,s,n.bl_tree),c--),Wi(n,wR,n.bl_tree),Tr(n,c-3,2)):c<=10?(Wi(n,bR,n.bl_tree),Tr(n,c-3,3)):(Wi(n,_R,n.bl_tree),Tr(n,c-11,7));c=0,i=s,o===0?(u=138,f=3):s===o?(u=6,f=3):(u=7,f=4)}},A$=n=>{let t;for($A(n,n.dyn_ltree,n.l_desc.max_code),$A(n,n.dyn_dtree,n.d_desc.max_code),jm(n,n.bl_desc),t=N1-1;t>=3&&n.bl_tree[AR[t]*2+1]===0;t--);return n.opt_len+=3*(t+1)+5+5+4,t},E$=(n,t,e,r)=>{let i;for(Tr(n,t-257,5),Tr(n,e-1,5),Tr(n,r-4,4),i=0;i<r;i++)Tr(n,n.bl_tree[AR[i]*2+1],3);HA(n,n.dyn_ltree,t-1),HA(n,n.dyn_dtree,e-1)},v$=n=>{let t=4093624447,e;for(e=0;e<=31;e++,t>>>=1)if(t&1&&n.dyn_ltree[e*2]!==0)return LA;if(n.dyn_ltree[9*2]!==0||n.dyn_ltree[10*2]!==0||n.dyn_ltree[13*2]!==0)return UA;for(e=32;e<jh;e++)if(n.dyn_ltree[e*2]!==0)return UA;return LA};let zA=!1;const x$=n=>{zA||(_$(),zA=!0),n.l_desc=new $y(n.dyn_ltree,ER),n.d_desc=new $y(n.dyn_dtree,vR),n.bl_desc=new $y(n.bl_tree,xR),n.bi_buf=0,n.bi_valid=0,kR(n)},OR=(n,t,e,r)=>{Tr(n,(f$<<1)+(r?1:0),3),TR(n),ch(n,e),ch(n,~e),e&&n.pending_buf.set(n.window.subarray(t,t+e),n.pending),n.pending+=e},R$=n=>{Tr(n,yR<<1,3),Wi(n,C1,As),w$(n)},S$=(n,t,e,r)=>{let i,s,o=0;n.level>0?(n.strm.data_type===l$&&(n.strm.data_type=v$(n)),jm(n,n.l_desc),jm(n,n.d_desc),o=A$(n),i=n.opt_len+3+7>>>3,s=n.static_len+3+7>>>3,s<=i&&(i=s)):i=s=e+5,e+4<=i&&t!==-1?OR(n,t,e,r):n.strategy===u$||s===i?(Tr(n,(yR<<1)+(r?1:0),3),FA(n,As,Bf)):(Tr(n,(h$<<1)+(r?1:0),3),E$(n,n.l_desc.max_code+1,n.d_desc.max_code+1,o+1),FA(n,n.dyn_ltree,n.dyn_dtree)),kR(n),r&&TR(n)},I$=(n,t,e)=>(n.pending_buf[n.sym_buf+n.sym_next++]=t,n.pending_buf[n.sym_buf+n.sym_next++]=t>>8,n.pending_buf[n.sym_buf+n.sym_next++]=e,t===0?n.dyn_ltree[e*2]++:(n.matches++,t--,n.dyn_ltree[(ah[e]+jh+1)*2]++,n.dyn_dtree[RR(t)*2]++),n.sym_next===n.sym_end);var k$=x$,T$=OR,O$=S$,N$=I$,C$=R$,B$={_tr_init:k$,_tr_stored_block:T$,_tr_flush_block:O$,_tr_tally:N$,_tr_align:C$};const P$=(n,t,e,r)=>{let i=n&65535|0,s=n>>>16&65535|0,o=0;for(;e!==0;){o=e>2e3?2e3:e,e-=o;do i=i+t[r++]|0,s=s+i|0;while(--o);i%=65521,s%=65521}return i|s<<16|0};var uh=P$;const M$=()=>{let n,t=[];for(var e=0;e<256;e++){n=e;for(var r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n}return t},L$=new Uint32Array(M$()),U$=(n,t,e,r)=>{const i=L$,s=r+e;n^=-1;for(let o=r;o<s;o++)n=n>>>8^i[(n^t[o])&255];return n^-1};var Mn=U$,ul={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"},Wh={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:D$,_tr_stored_block:Wm,_tr_flush_block:F$,_tr_tally:zo,_tr_align:$$}=B$,{Z_NO_FLUSH:Go,Z_PARTIAL_FLUSH:H$,Z_FULL_FLUSH:z$,Z_FINISH:ii,Z_BLOCK:GA,Z_OK:Vn,Z_STREAM_END:VA,Z_STREAM_ERROR:ts,Z_DATA_ERROR:G$,Z_BUF_ERROR:zy,Z_DEFAULT_COMPRESSION:V$,Z_FILTERED:K$,Z_HUFFMAN_ONLY:Id,Z_RLE:j$,Z_FIXED:W$,Z_DEFAULT_STRATEGY:Z$,Z_UNKNOWN:q$,Z_DEFLATED:Sp}=Wh,Q$=9,J$=15,Y$=8,X$=29,tH=256,Zm=tH+1+X$,eH=30,nH=19,rH=2*Zm+1,iH=15,le=3,Fo=258,es=Fo+le+1,sH=32,ll=42,P1=57,qm=69,Qm=73,Jm=91,Ym=103,Ea=113,vf=666,dr=1,Ll=2,fc=3,Ul=4,oH=3,va=(n,t)=>(n.msg=ul[t],t),KA=n=>n*2-(n>4?9:0),yo=n=>{let t=n.length;for(;--t>=0;)n[t]=0},aH=n=>{let t,e,r,i=n.w_size;t=n.hash_size,r=t;do e=n.head[--r],n.head[r]=e>=i?e-i:0;while(--t);t=i,r=t;do e=n.prev[--r],n.prev[r]=e>=i?e-i:0;while(--t)};let cH=(n,t,e)=>(t<<n.hash_shift^e)&n.hash_mask,Vo=cH;const Mr=n=>{const t=n.state;let e=t.pending;e>n.avail_out&&(e=n.avail_out),e!==0&&(n.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+e),n.next_out),n.next_out+=e,t.pending_out+=e,n.total_out+=e,n.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))},Gr=(n,t)=>{F$(n,n.block_start>=0?n.block_start:-1,n.strstart-n.block_start,t),n.block_start=n.strstart,Mr(n.strm)},xe=(n,t)=>{n.pending_buf[n.pending++]=t},mf=(n,t)=>{n.pending_buf[n.pending++]=t>>>8&255,n.pending_buf[n.pending++]=t&255},Xm=(n,t,e,r)=>{let i=n.avail_in;return i>r&&(i=r),i===0?0:(n.avail_in-=i,t.set(n.input.subarray(n.next_in,n.next_in+i),e),n.state.wrap===1?n.adler=uh(n.adler,t,i,e):n.state.wrap===2&&(n.adler=Mn(n.adler,t,i,e)),n.next_in+=i,n.total_in+=i,i)},NR=(n,t)=>{let e=n.max_chain_length,r=n.strstart,i,s,o=n.prev_length,c=n.nice_match;const u=n.strstart>n.w_size-es?n.strstart-(n.w_size-es):0,f=n.window,h=n.w_mask,y=n.prev,A=n.strstart+Fo;let b=f[r+o-1],R=f[r+o];n.prev_length>=n.good_match&&(e>>=2),c>n.lookahead&&(c=n.lookahead);do if(i=t,!(f[i+o]!==R||f[i+o-1]!==b||f[i]!==f[r]||f[++i]!==f[r+1])){r+=2,i++;do;while(f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&r<A);if(s=Fo-(A-r),r=A-Fo,s>o){if(n.match_start=t,o=s,s>=c)break;b=f[r+o-1],R=f[r+o]}}while((t=y[t&h])>u&&--e!==0);return o<=n.lookahead?o:n.lookahead},fl=n=>{const t=n.w_size;let e,r,i;do{if(r=n.window_size-n.lookahead-n.strstart,n.strstart>=t+(t-es)&&(n.window.set(n.window.subarray(t,t+t-r),0),n.match_start-=t,n.strstart-=t,n.block_start-=t,n.insert>n.strstart&&(n.insert=n.strstart),aH(n),r+=t),n.strm.avail_in===0)break;if(e=Xm(n.strm,n.window,n.strstart+n.lookahead,r),n.lookahead+=e,n.lookahead+n.insert>=le)for(i=n.strstart-n.insert,n.ins_h=n.window[i],n.ins_h=Vo(n,n.ins_h,n.window[i+1]);n.insert&&(n.ins_h=Vo(n,n.ins_h,n.window[i+le-1]),n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++,n.insert--,!(n.lookahead+n.insert<le)););}while(n.lookahead<es&&n.strm.avail_in!==0)},CR=(n,t)=>{let e=n.pending_buf_size-5>n.w_size?n.w_size:n.pending_buf_size-5,r,i,s,o=0,c=n.strm.avail_in;do{if(r=65535,s=n.bi_valid+42>>3,n.strm.avail_out<s||(s=n.strm.avail_out-s,i=n.strstart-n.block_start,r>i+n.strm.avail_in&&(r=i+n.strm.avail_in),r>s&&(r=s),r<e&&(r===0&&t!==ii||t===Go||r!==i+n.strm.avail_in)))break;o=t===ii&&r===i+n.strm.avail_in?1:0,Wm(n,0,0,o),n.pending_buf[n.pending-4]=r,n.pending_buf[n.pending-3]=r>>8,n.pending_buf[n.pending-2]=~r,n.pending_buf[n.pending-1]=~r>>8,Mr(n.strm),i&&(i>r&&(i=r),n.strm.output.set(n.window.subarray(n.block_start,n.block_start+i),n.strm.next_out),n.strm.next_out+=i,n.strm.avail_out-=i,n.strm.total_out+=i,n.block_start+=i,r-=i),r&&(Xm(n.strm,n.strm.output,n.strm.next_out,r),n.strm.next_out+=r,n.strm.avail_out-=r,n.strm.total_out+=r)}while(o===0);return c-=n.strm.avail_in,c&&(c>=n.w_size?(n.matches=2,n.window.set(n.strm.input.subarray(n.strm.next_in-n.w_size,n.strm.next_in),0),n.strstart=n.w_size,n.insert=n.strstart):(n.window_size-n.strstart<=c&&(n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,n.insert>n.strstart&&(n.insert=n.strstart)),n.window.set(n.strm.input.subarray(n.strm.next_in-c,n.strm.next_in),n.strstart),n.strstart+=c,n.insert+=c>n.w_size-n.insert?n.w_size-n.insert:c),n.block_start=n.strstart),n.high_water<n.strstart&&(n.high_water=n.strstart),o?Ul:t!==Go&&t!==ii&&n.strm.avail_in===0&&n.strstart===n.block_start?Ll:(s=n.window_size-n.strstart,n.strm.avail_in>s&&n.block_start>=n.w_size&&(n.block_start-=n.w_size,n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,s+=n.w_size,n.insert>n.strstart&&(n.insert=n.strstart)),s>n.strm.avail_in&&(s=n.strm.avail_in),s&&(Xm(n.strm,n.window,n.strstart,s),n.strstart+=s,n.insert+=s>n.w_size-n.insert?n.w_size-n.insert:s),n.high_water<n.strstart&&(n.high_water=n.strstart),s=n.bi_valid+42>>3,s=n.pending_buf_size-s>65535?65535:n.pending_buf_size-s,e=s>n.w_size?n.w_size:s,i=n.strstart-n.block_start,(i>=e||(i||t===ii)&&t!==Go&&n.strm.avail_in===0&&i<=s)&&(r=i>s?s:i,o=t===ii&&n.strm.avail_in===0&&r===i?1:0,Wm(n,n.block_start,r,o),n.block_start+=r,Mr(n.strm)),o?fc:dr)},Gy=(n,t)=>{let e,r;for(;;){if(n.lookahead<es){if(fl(n),n.lookahead<es&&t===Go)return dr;if(n.lookahead===0)break}if(e=0,n.lookahead>=le&&(n.ins_h=Vo(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),e!==0&&n.strstart-e<=n.w_size-es&&(n.match_length=NR(n,e)),n.match_length>=le)if(r=zo(n,n.strstart-n.match_start,n.match_length-le),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=le){n.match_length--;do n.strstart++,n.ins_h=Vo(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart;while(--n.match_length!==0);n.strstart++}else n.strstart+=n.match_length,n.match_length=0,n.ins_h=n.window[n.strstart],n.ins_h=Vo(n,n.ins_h,n.window[n.strstart+1]);else r=zo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++;if(r&&(Gr(n,!1),n.strm.avail_out===0))return dr}return n.insert=n.strstart<le-1?n.strstart:le-1,t===ii?(Gr(n,!0),n.strm.avail_out===0?fc:Ul):n.sym_next&&(Gr(n,!1),n.strm.avail_out===0)?dr:Ll},Uc=(n,t)=>{let e,r,i;for(;;){if(n.lookahead<es){if(fl(n),n.lookahead<es&&t===Go)return dr;if(n.lookahead===0)break}if(e=0,n.lookahead>=le&&(n.ins_h=Vo(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),n.prev_length=n.match_length,n.prev_match=n.match_start,n.match_length=le-1,e!==0&&n.prev_length<n.max_lazy_match&&n.strstart-e<=n.w_size-es&&(n.match_length=NR(n,e),n.match_length<=5&&(n.strategy===K$||n.match_length===le&&n.strstart-n.match_start>4096)&&(n.match_length=le-1)),n.prev_length>=le&&n.match_length<=n.prev_length){i=n.strstart+n.lookahead-le,r=zo(n,n.strstart-1-n.prev_match,n.prev_length-le),n.lookahead-=n.prev_length-1,n.prev_length-=2;do++n.strstart<=i&&(n.ins_h=Vo(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart);while(--n.prev_length!==0);if(n.match_available=0,n.match_length=le-1,n.strstart++,r&&(Gr(n,!1),n.strm.avail_out===0))return dr}else if(n.match_available){if(r=zo(n,0,n.window[n.strstart-1]),r&&Gr(n,!1),n.strstart++,n.lookahead--,n.strm.avail_out===0)return dr}else n.match_available=1,n.strstart++,n.lookahead--}return n.match_available&&(r=zo(n,0,n.window[n.strstart-1]),n.match_available=0),n.insert=n.strstart<le-1?n.strstart:le-1,t===ii?(Gr(n,!0),n.strm.avail_out===0?fc:Ul):n.sym_next&&(Gr(n,!1),n.strm.avail_out===0)?dr:Ll},uH=(n,t)=>{let e,r,i,s;const o=n.window;for(;;){if(n.lookahead<=Fo){if(fl(n),n.lookahead<=Fo&&t===Go)return dr;if(n.lookahead===0)break}if(n.match_length=0,n.lookahead>=le&&n.strstart>0&&(i=n.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){s=n.strstart+Fo;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<s);n.match_length=Fo-(s-i),n.match_length>n.lookahead&&(n.match_length=n.lookahead)}if(n.match_length>=le?(e=zo(n,1,n.match_length-le),n.lookahead-=n.match_length,n.strstart+=n.match_length,n.match_length=0):(e=zo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++),e&&(Gr(n,!1),n.strm.avail_out===0))return dr}return n.insert=0,t===ii?(Gr(n,!0),n.strm.avail_out===0?fc:Ul):n.sym_next&&(Gr(n,!1),n.strm.avail_out===0)?dr:Ll},lH=(n,t)=>{let e;for(;;){if(n.lookahead===0&&(fl(n),n.lookahead===0)){if(t===Go)return dr;break}if(n.match_length=0,e=zo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++,e&&(Gr(n,!1),n.strm.avail_out===0))return dr}return n.insert=0,t===ii?(Gr(n,!0),n.strm.avail_out===0?fc:Ul):n.sym_next&&(Gr(n,!1),n.strm.avail_out===0)?dr:Ll};function Ni(n,t,e,r,i){this.good_length=n,this.max_lazy=t,this.nice_length=e,this.max_chain=r,this.func=i}const xf=[new Ni(0,0,0,0,CR),new Ni(4,4,8,4,Gy),new Ni(4,5,16,8,Gy),new Ni(4,6,32,32,Gy),new Ni(4,4,16,16,Uc),new Ni(8,16,32,32,Uc),new Ni(8,16,128,128,Uc),new Ni(8,32,128,256,Uc),new Ni(32,128,258,1024,Uc),new Ni(32,258,258,4096,Uc)],fH=n=>{n.window_size=2*n.w_size,yo(n.head),n.max_lazy_match=xf[n.level].max_lazy,n.good_match=xf[n.level].good_length,n.nice_match=xf[n.level].nice_length,n.max_chain_length=xf[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=le-1,n.match_available=0,n.ins_h=0};function hH(){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=Sp,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(rH*2),this.dyn_dtree=new Uint16Array((2*eH+1)*2),this.bl_tree=new Uint16Array((2*nH+1)*2),yo(this.dyn_ltree),yo(this.dyn_dtree),yo(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(iH+1),this.heap=new Uint16Array(2*Zm+1),yo(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Zm+1),yo(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 Zh=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.status!==ll&&t.status!==P1&&t.status!==qm&&t.status!==Qm&&t.status!==Jm&&t.status!==Ym&&t.status!==Ea&&t.status!==vf?1:0},BR=n=>{if(Zh(n))return va(n,ts);n.total_in=n.total_out=0,n.data_type=q$;const t=n.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?P1:t.wrap?ll:Ea,n.adler=t.wrap===2?0:1,t.last_flush=-2,D$(t),Vn},PR=n=>{const t=BR(n);return t===Vn&&fH(n.state),t},dH=(n,t)=>Zh(n)||n.state.wrap!==2?ts:(n.state.gzhead=t,Vn),MR=(n,t,e,r,i,s)=>{if(!n)return ts;let o=1;if(t===V$&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>Q$||e!==Sp||r<8||r>15||t<0||t>9||s<0||s>W$||r===8&&o!==1)return va(n,ts);r===8&&(r=9);const c=new hH;return n.state=c,c.strm=n,c.status=ll,c.wrap=o,c.gzhead=null,c.w_bits=r,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=i+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+le-1)/le),c.window=new Uint8Array(c.w_size*2),c.head=new Uint16Array(c.hash_size),c.prev=new Uint16Array(c.w_size),c.lit_bufsize=1<<i+6,c.pending_buf_size=c.lit_bufsize*4,c.pending_buf=new Uint8Array(c.pending_buf_size),c.sym_buf=c.lit_bufsize,c.sym_end=(c.lit_bufsize-1)*3,c.level=t,c.strategy=s,c.method=e,PR(n)},pH=(n,t)=>MR(n,t,Sp,J$,Y$,Z$),gH=(n,t)=>{if(Zh(n)||t>GA||t<0)return n?va(n,ts):ts;const e=n.state;if(!n.output||n.avail_in!==0&&!n.input||e.status===vf&&t!==ii)return va(n,n.avail_out===0?zy:ts);const r=e.last_flush;if(e.last_flush=t,e.pending!==0){if(Mr(n),n.avail_out===0)return e.last_flush=-1,Vn}else if(n.avail_in===0&&KA(t)<=KA(r)&&t!==ii)return va(n,zy);if(e.status===vf&&n.avail_in!==0)return va(n,zy);if(e.status===ll&&e.wrap===0&&(e.status=Ea),e.status===ll){let i=Sp+(e.w_bits-8<<4)<<8,s=-1;if(e.strategy>=Id||e.level<2?s=0:e.level<6?s=1:e.level===6?s=2:s=3,i|=s<<6,e.strstart!==0&&(i|=sH),i+=31-i%31,mf(e,i),e.strstart!==0&&(mf(e,n.adler>>>16),mf(e,n.adler&65535)),n.adler=1,e.status=Ea,Mr(n),e.pending!==0)return e.last_flush=-1,Vn}if(e.status===P1){if(n.adler=0,xe(e,31),xe(e,139),xe(e,8),e.gzhead)xe(e,(e.gzhead.text?1:0)+(e.gzhead.hcrc?2:0)+(e.gzhead.extra?4:0)+(e.gzhead.name?8:0)+(e.gzhead.comment?16:0)),xe(e,e.gzhead.time&255),xe(e,e.gzhead.time>>8&255),xe(e,e.gzhead.time>>16&255),xe(e,e.gzhead.time>>24&255),xe(e,e.level===9?2:e.strategy>=Id||e.level<2?4:0),xe(e,e.gzhead.os&255),e.gzhead.extra&&e.gzhead.extra.length&&(xe(e,e.gzhead.extra.length&255),xe(e,e.gzhead.extra.length>>8&255)),e.gzhead.hcrc&&(n.adler=Mn(n.adler,e.pending_buf,e.pending,0)),e.gzindex=0,e.status=qm;else if(xe(e,0),xe(e,0),xe(e,0),xe(e,0),xe(e,0),xe(e,e.level===9?2:e.strategy>=Id||e.level<2?4:0),xe(e,oH),e.status=Ea,Mr(n),e.pending!==0)return e.last_flush=-1,Vn}if(e.status===qm){if(e.gzhead.extra){let i=e.pending,s=(e.gzhead.extra.length&65535)-e.gzindex;for(;e.pending+s>e.pending_buf_size;){let c=e.pending_buf_size-e.pending;if(e.pending_buf.set(e.gzhead.extra.subarray(e.gzindex,e.gzindex+c),e.pending),e.pending=e.pending_buf_size,e.gzhead.hcrc&&e.pending>i&&(n.adler=Mn(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex+=c,Mr(n),e.pending!==0)return e.last_flush=-1,Vn;i=0,s-=c}let o=new Uint8Array(e.gzhead.extra);e.pending_buf.set(o.subarray(e.gzindex,e.gzindex+s),e.pending),e.pending+=s,e.gzhead.hcrc&&e.pending>i&&(n.adler=Mn(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex=0}e.status=Qm}if(e.status===Qm){if(e.gzhead.name){let i=e.pending,s;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>i&&(n.adler=Mn(n.adler,e.pending_buf,e.pending-i,i)),Mr(n),e.pending!==0)return e.last_flush=-1,Vn;i=0}e.gzindex<e.gzhead.name.length?s=e.gzhead.name.charCodeAt(e.gzindex++)&255:s=0,xe(e,s)}while(s!==0);e.gzhead.hcrc&&e.pending>i&&(n.adler=Mn(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex=0}e.status=Jm}if(e.status===Jm){if(e.gzhead.comment){let i=e.pending,s;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>i&&(n.adler=Mn(n.adler,e.pending_buf,e.pending-i,i)),Mr(n),e.pending!==0)return e.last_flush=-1,Vn;i=0}e.gzindex<e.gzhead.comment.length?s=e.gzhead.comment.charCodeAt(e.gzindex++)&255:s=0,xe(e,s)}while(s!==0);e.gzhead.hcrc&&e.pending>i&&(n.adler=Mn(n.adler,e.pending_buf,e.pending-i,i))}e.status=Ym}if(e.status===Ym){if(e.gzhead.hcrc){if(e.pending+2>e.pending_buf_size&&(Mr(n),e.pending!==0))return e.last_flush=-1,Vn;xe(e,n.adler&255),xe(e,n.adler>>8&255),n.adler=0}if(e.status=Ea,Mr(n),e.pending!==0)return e.last_flush=-1,Vn}if(n.avail_in!==0||e.lookahead!==0||t!==Go&&e.status!==vf){let i=e.level===0?CR(e,t):e.strategy===Id?lH(e,t):e.strategy===j$?uH(e,t):xf[e.level].func(e,t);if((i===fc||i===Ul)&&(e.status=vf),i===dr||i===fc)return n.avail_out===0&&(e.last_flush=-1),Vn;if(i===Ll&&(t===H$?$$(e):t!==GA&&(Wm(e,0,0,!1),t===z$&&(yo(e.head),e.lookahead===0&&(e.strstart=0,e.block_start=0,e.insert=0))),Mr(n),n.avail_out===0))return e.last_flush=-1,Vn}return t!==ii?Vn:e.wrap<=0?VA:(e.wrap===2?(xe(e,n.adler&255),xe(e,n.adler>>8&255),xe(e,n.adler>>16&255),xe(e,n.adler>>24&255),xe(e,n.total_in&255),xe(e,n.total_in>>8&255),xe(e,n.total_in>>16&255),xe(e,n.total_in>>24&255)):(mf(e,n.adler>>>16),mf(e,n.adler&65535)),Mr(n),e.wrap>0&&(e.wrap=-e.wrap),e.pending!==0?Vn:VA)},yH=n=>{if(Zh(n))return ts;const t=n.state.status;return n.state=null,t===Ea?va(n,G$):Vn},mH=(n,t)=>{let e=t.length;if(Zh(n))return ts;const r=n.state,i=r.wrap;if(i===2||i===1&&r.status!==ll||r.lookahead)return ts;if(i===1&&(n.adler=uh(n.adler,t,e,0)),r.wrap=0,e>=r.w_size){i===0&&(yo(r.head),r.strstart=0,r.block_start=0,r.insert=0);let u=new Uint8Array(r.w_size);u.set(t.subarray(e-r.w_size,e),0),t=u,e=r.w_size}const s=n.avail_in,o=n.next_in,c=n.input;for(n.avail_in=e,n.next_in=0,n.input=t,fl(r);r.lookahead>=le;){let u=r.strstart,f=r.lookahead-(le-1);do r.ins_h=Vo(r,r.ins_h,r.window[u+le-1]),r.prev[u&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=u,u++;while(--f);r.strstart=u,r.lookahead=le-1,fl(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=le-1,r.match_available=0,n.next_in=o,n.input=c,n.avail_in=s,r.wrap=i,Vn};var wH=pH,bH=MR,_H=PR,AH=BR,EH=dH,vH=gH,xH=yH,RH=mH,SH="pako deflate (from Nodeca project)",Pf={deflateInit:wH,deflateInit2:bH,deflateReset:_H,deflateResetKeep:AH,deflateSetHeader:EH,deflate:vH,deflateEnd:xH,deflateSetDictionary:RH,deflateInfo:SH};const IH=(n,t)=>Object.prototype.hasOwnProperty.call(n,t);var kH=function(n){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const e=t.shift();if(e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(const r in e)IH(e,r)&&(n[r]=e[r])}}return n},TH=n=>{let t=0;for(let r=0,i=n.length;r<i;r++)t+=n[r].length;const e=new Uint8Array(t);for(let r=0,i=0,s=n.length;r<s;r++){let o=n[r];e.set(o,i),i+=o.length}return e},Ip={assign:kH,flattenChunks:TH};let LR=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{LR=!1}const lh=new Uint8Array(256);for(let n=0;n<256;n++)lh[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;lh[254]=lh[254]=1;var OH=n=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(n);let t,e,r,i,s,o=n.length,c=0;for(i=0;i<o;i++)e=n.charCodeAt(i),(e&64512)===55296&&i+1<o&&(r=n.charCodeAt(i+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),i++)),c+=e<128?1:e<2048?2:e<65536?3:4;for(t=new Uint8Array(c),s=0,i=0;s<c;i++)e=n.charCodeAt(i),(e&64512)===55296&&i+1<o&&(r=n.charCodeAt(i+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),i++)),e<128?t[s++]=e:e<2048?(t[s++]=192|e>>>6,t[s++]=128|e&63):e<65536?(t[s++]=224|e>>>12,t[s++]=128|e>>>6&63,t[s++]=128|e&63):(t[s++]=240|e>>>18,t[s++]=128|e>>>12&63,t[s++]=128|e>>>6&63,t[s++]=128|e&63);return t};const NH=(n,t)=>{if(t<65534&&n.subarray&&LR)return String.fromCharCode.apply(null,n.length===t?n:n.subarray(0,t));let e="";for(let r=0;r<t;r++)e+=String.fromCharCode(n[r]);return e};var CH=(n,t)=>{const e=t||n.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(n.subarray(0,t));let r,i;const s=new Array(e*2);for(i=0,r=0;r<e;){let o=n[r++];if(o<128){s[i++]=o;continue}let c=lh[o];if(c>4){s[i++]=65533,r+=c-1;continue}for(o&=c===2?31:c===3?15:7;c>1&&r<e;)o=o<<6|n[r++]&63,c--;if(c>1){s[i++]=65533;continue}o<65536?s[i++]=o:(o-=65536,s[i++]=55296|o>>10&1023,s[i++]=56320|o&1023)}return NH(s,i)},BH=(n,t)=>{t=t||n.length,t>n.length&&(t=n.length);let e=t-1;for(;e>=0&&(n[e]&192)===128;)e--;return e<0||e===0?t:e+lh[n[e]]>t?e:t},fh={string2buf:OH,buf2string:CH,utf8border:BH};function PH(){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}var UR=PH;const DR=Object.prototype.toString,{Z_NO_FLUSH:MH,Z_SYNC_FLUSH:LH,Z_FULL_FLUSH:UH,Z_FINISH:DH,Z_OK:R0,Z_STREAM_END:FH,Z_DEFAULT_COMPRESSION:$H,Z_DEFAULT_STRATEGY:HH,Z_DEFLATED:zH}=Wh;function M1(n){this.options=Ip.assign({level:$H,method:zH,chunkSize:16384,windowBits:15,memLevel:8,strategy:HH},n||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new UR,this.strm.avail_out=0;let e=Pf.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==R0)throw new Error(ul[e]);if(t.header&&Pf.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=fh.string2buf(t.dictionary):DR.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,e=Pf.deflateSetDictionary(this.strm,r),e!==R0)throw new Error(ul[e]);this._dict_set=!0}}M1.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize;let i,s;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?DH:MH,typeof n=="string"?e.input=fh.string2buf(n):DR.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){if(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),(s===LH||s===UH)&&e.avail_out<=6){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(i=Pf.deflate(e,s),i===FH)return e.next_out>0&&this.onData(e.output.subarray(0,e.next_out)),i=Pf.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===R0;if(e.avail_out===0){this.onData(e.output);continue}if(s>0&&e.next_out>0){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(e.avail_in===0)break}return!0};M1.prototype.onData=function(n){this.chunks.push(n)};M1.prototype.onEnd=function(n){n===R0&&(this.result=Ip.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};const kd=16209,GH=16191;var VH=function(t,e){let r,i,s,o,c,u,f,h,y,A,b,R,k,S,B,H,U,G,W,Y,j,J,it,ut;const rt=t.state;r=t.next_in,it=t.input,i=r+(t.avail_in-5),s=t.next_out,ut=t.output,o=s-(e-t.avail_out),c=s+(t.avail_out-257),u=rt.dmax,f=rt.wsize,h=rt.whave,y=rt.wnext,A=rt.window,b=rt.hold,R=rt.bits,k=rt.lencode,S=rt.distcode,B=(1<<rt.lenbits)-1,H=(1<<rt.distbits)-1;t:do{R<15&&(b+=it[r++]<<R,R+=8,b+=it[r++]<<R,R+=8),U=k[b&B];e:for(;;){if(G=U>>>24,b>>>=G,R-=G,G=U>>>16&255,G===0)ut[s++]=U&65535;else if(G&16){W=U&65535,G&=15,G&&(R<G&&(b+=it[r++]<<R,R+=8),W+=b&(1<<G)-1,b>>>=G,R-=G),R<15&&(b+=it[r++]<<R,R+=8,b+=it[r++]<<R,R+=8),U=S[b&H];n:for(;;){if(G=U>>>24,b>>>=G,R-=G,G=U>>>16&255,G&16){if(Y=U&65535,G&=15,R<G&&(b+=it[r++]<<R,R+=8,R<G&&(b+=it[r++]<<R,R+=8)),Y+=b&(1<<G)-1,Y>u){t.msg="invalid distance too far back",rt.mode=kd;break t}if(b>>>=G,R-=G,G=s-o,Y>G){if(G=Y-G,G>h&&rt.sane){t.msg="invalid distance too far back",rt.mode=kd;break t}if(j=0,J=A,y===0){if(j+=f-G,G<W){W-=G;do ut[s++]=A[j++];while(--G);j=s-Y,J=ut}}else if(y<G){if(j+=f+y-G,G-=y,G<W){W-=G;do ut[s++]=A[j++];while(--G);if(j=0,y<W){G=y,W-=G;do ut[s++]=A[j++];while(--G);j=s-Y,J=ut}}}else if(j+=y-G,G<W){W-=G;do ut[s++]=A[j++];while(--G);j=s-Y,J=ut}for(;W>2;)ut[s++]=J[j++],ut[s++]=J[j++],ut[s++]=J[j++],W-=3;W&&(ut[s++]=J[j++],W>1&&(ut[s++]=J[j++]))}else{j=s-Y;do ut[s++]=ut[j++],ut[s++]=ut[j++],ut[s++]=ut[j++],W-=3;while(W>2);W&&(ut[s++]=ut[j++],W>1&&(ut[s++]=ut[j++]))}}else if(G&64){t.msg="invalid distance code",rt.mode=kd;break t}else{U=S[(U&65535)+(b&(1<<G)-1)];continue n}break}}else if(G&64)if(G&32){rt.mode=GH;break t}else{t.msg="invalid literal/length code",rt.mode=kd;break t}else{U=k[(U&65535)+(b&(1<<G)-1)];continue e}break}}while(r<i&&s<c);W=R>>3,r-=W,R-=W<<3,b&=(1<<R)-1,t.next_in=r,t.next_out=s,t.avail_in=r<i?5+(i-r):5-(r-i),t.avail_out=s<c?257+(c-s):257-(s-c),rt.hold=b,rt.bits=R};const Dc=15,jA=852,WA=592,ZA=0,Vy=1,qA=2,KH=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]),jH=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]),WH=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]),ZH=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]),qH=(n,t,e,r,i,s,o,c)=>{const u=c.bits;let f=0,h=0,y=0,A=0,b=0,R=0,k=0,S=0,B=0,H=0,U,G,W,Y,j,J=null,it;const ut=new Uint16Array(Dc+1),rt=new Uint16Array(Dc+1);let ot=null,C,p,m;for(f=0;f<=Dc;f++)ut[f]=0;for(h=0;h<r;h++)ut[t[e+h]]++;for(b=u,A=Dc;A>=1&&ut[A]===0;A--);if(b>A&&(b=A),A===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,c.bits=1,0;for(y=1;y<A&&ut[y]===0;y++);for(b<y&&(b=y),S=1,f=1;f<=Dc;f++)if(S<<=1,S-=ut[f],S<0)return-1;if(S>0&&(n===ZA||A!==1))return-1;for(rt[1]=0,f=1;f<Dc;f++)rt[f+1]=rt[f]+ut[f];for(h=0;h<r;h++)t[e+h]!==0&&(o[rt[t[e+h]]++]=h);if(n===ZA?(J=ot=o,it=20):n===Vy?(J=KH,ot=jH,it=257):(J=WH,ot=ZH,it=0),H=0,h=0,f=y,j=s,R=b,k=0,W=-1,B=1<<b,Y=B-1,n===Vy&&B>jA||n===qA&&B>WA)return 1;for(;;){C=f-k,o[h]+1<it?(p=0,m=o[h]):o[h]>=it?(p=ot[o[h]-it],m=J[o[h]-it]):(p=96,m=0),U=1<<f-k,G=1<<R,y=G;do G-=U,i[j+(H>>k)+G]=C<<24|p<<16|m|0;while(G!==0);for(U=1<<f-1;H&U;)U>>=1;if(U!==0?(H&=U-1,H+=U):H=0,h++,--ut[f]===0){if(f===A)break;f=t[e+o[h]]}if(f>b&&(H&Y)!==W){for(k===0&&(k=b),j+=y,R=f-k,S=1<<R;R+k<A&&(S-=ut[R+k],!(S<=0));)R++,S<<=1;if(B+=1<<R,n===Vy&&B>jA||n===qA&&B>WA)return 1;W=H&Y,i[W]=b<<24|R<<16|j-s|0}}return H!==0&&(i[j+H]=f-k<<24|64<<16|0),c.bits=b,0};var Mf=qH;const QH=0,FR=1,$R=2,{Z_FINISH:QA,Z_BLOCK:JH,Z_TREES:Td,Z_OK:hc,Z_STREAM_END:YH,Z_NEED_DICT:XH,Z_STREAM_ERROR:oi,Z_DATA_ERROR:HR,Z_MEM_ERROR:zR,Z_BUF_ERROR:tz,Z_DEFLATED:JA}=Wh,kp=16180,YA=16181,XA=16182,tE=16183,eE=16184,nE=16185,rE=16186,iE=16187,sE=16188,oE=16189,S0=16190,ds=16191,Ky=16192,aE=16193,jy=16194,cE=16195,uE=16196,lE=16197,fE=16198,Od=16199,Nd=16200,hE=16201,dE=16202,pE=16203,gE=16204,yE=16205,Wy=16206,mE=16207,wE=16208,We=16209,GR=16210,VR=16211,ez=852,nz=592,rz=15,iz=rz,bE=n=>(n>>>24&255)+(n>>>8&65280)+((n&65280)<<8)+((n&255)<<24);function sz(){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 Rc=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.mode<kp||t.mode>VR?1:0},KR=n=>{if(Rc(n))return oi;const t=n.state;return n.total_in=n.total_out=t.total=0,n.msg="",t.wrap&&(n.adler=t.wrap&1),t.mode=kp,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(ez),t.distcode=t.distdyn=new Int32Array(nz),t.sane=1,t.back=-1,hc},jR=n=>{if(Rc(n))return oi;const t=n.state;return t.wsize=0,t.whave=0,t.wnext=0,KR(n)},WR=(n,t)=>{let e;if(Rc(n))return oi;const r=n.state;return t<0?(e=0,t=-t):(e=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?oi:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=e,r.wbits=t,jR(n))},ZR=(n,t)=>{if(!n)return oi;const e=new sz;n.state=e,e.strm=n,e.window=null,e.mode=kp;const r=WR(n,t);return r!==hc&&(n.state=null),r},oz=n=>ZR(n,iz);let _E=!0,Zy,qy;const az=n=>{if(_E){Zy=new Int32Array(512),qy=new Int32Array(32);let t=0;for(;t<144;)n.lens[t++]=8;for(;t<256;)n.lens[t++]=9;for(;t<280;)n.lens[t++]=7;for(;t<288;)n.lens[t++]=8;for(Mf(FR,n.lens,0,288,Zy,0,n.work,{bits:9}),t=0;t<32;)n.lens[t++]=5;Mf($R,n.lens,0,32,qy,0,n.work,{bits:5}),_E=!1}n.lencode=Zy,n.lenbits=9,n.distcode=qy,n.distbits=5},qR=(n,t,e,r)=>{let i;const s=n.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(e-s.wsize,e),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),s.window.set(t.subarray(e-r,e-r+i),s.wnext),r-=i,r?(s.window.set(t.subarray(e-r,e),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0},cz=(n,t)=>{let e,r,i,s,o,c,u,f,h,y,A,b,R,k,S=0,B,H,U,G,W,Y,j,J;const it=new Uint8Array(4);let ut,rt;const ot=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Rc(n)||!n.output||!n.input&&n.avail_in!==0)return oi;e=n.state,e.mode===ds&&(e.mode=Ky),o=n.next_out,i=n.output,u=n.avail_out,s=n.next_in,r=n.input,c=n.avail_in,f=e.hold,h=e.bits,y=c,A=u,J=hc;t:for(;;)switch(e.mode){case kp:if(e.wrap===0){e.mode=Ky;break}for(;h<16;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(e.wrap&2&&f===35615){e.wbits===0&&(e.wbits=15),e.check=0,it[0]=f&255,it[1]=f>>>8&255,e.check=Mn(e.check,it,2,0),f=0,h=0,e.mode=YA;break}if(e.head&&(e.head.done=!1),!(e.wrap&1)||(((f&255)<<8)+(f>>8))%31){n.msg="incorrect header check",e.mode=We;break}if((f&15)!==JA){n.msg="unknown compression method",e.mode=We;break}if(f>>>=4,h-=4,j=(f&15)+8,e.wbits===0&&(e.wbits=j),j>15||j>e.wbits){n.msg="invalid window size",e.mode=We;break}e.dmax=1<<e.wbits,e.flags=0,n.adler=e.check=1,e.mode=f&512?oE:ds,f=0,h=0;break;case YA:for(;h<16;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(e.flags=f,(e.flags&255)!==JA){n.msg="unknown compression method",e.mode=We;break}if(e.flags&57344){n.msg="unknown header flags set",e.mode=We;break}e.head&&(e.head.text=f>>8&1),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Mn(e.check,it,2,0)),f=0,h=0,e.mode=XA;case XA:for(;h<32;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.head&&(e.head.time=f),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,it[2]=f>>>16&255,it[3]=f>>>24&255,e.check=Mn(e.check,it,4,0)),f=0,h=0,e.mode=tE;case tE:for(;h<16;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.head&&(e.head.xflags=f&255,e.head.os=f>>8),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Mn(e.check,it,2,0)),f=0,h=0,e.mode=eE;case eE:if(e.flags&1024){for(;h<16;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.length=f,e.head&&(e.head.extra_len=f),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Mn(e.check,it,2,0)),f=0,h=0}else e.head&&(e.head.extra=null);e.mode=nE;case nE:if(e.flags&1024&&(b=e.length,b>c&&(b=c),b&&(e.head&&(j=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(r.subarray(s,s+b),j)),e.flags&512&&e.wrap&4&&(e.check=Mn(e.check,r,b,s)),c-=b,s+=b,e.length-=b),e.length))break t;e.length=0,e.mode=rE;case rE:if(e.flags&2048){if(c===0)break t;b=0;do j=r[s+b++],e.head&&j&&e.length<65536&&(e.head.name+=String.fromCharCode(j));while(j&&b<c);if(e.flags&512&&e.wrap&4&&(e.check=Mn(e.check,r,b,s)),c-=b,s+=b,j)break t}else e.head&&(e.head.name=null);e.length=0,e.mode=iE;case iE:if(e.flags&4096){if(c===0)break t;b=0;do j=r[s+b++],e.head&&j&&e.length<65536&&(e.head.comment+=String.fromCharCode(j));while(j&&b<c);if(e.flags&512&&e.wrap&4&&(e.check=Mn(e.check,r,b,s)),c-=b,s+=b,j)break t}else e.head&&(e.head.comment=null);e.mode=sE;case sE:if(e.flags&512){for(;h<16;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(e.wrap&4&&f!==(e.check&65535)){n.msg="header crc mismatch",e.mode=We;break}f=0,h=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),n.adler=e.check=0,e.mode=ds;break;case oE:for(;h<32;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}n.adler=e.check=bE(f),f=0,h=0,e.mode=S0;case S0:if(e.havedict===0)return n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=c,e.hold=f,e.bits=h,XH;n.adler=e.check=1,e.mode=ds;case ds:if(t===JH||t===Td)break t;case Ky:if(e.last){f>>>=h&7,h-=h&7,e.mode=Wy;break}for(;h<3;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}switch(e.last=f&1,f>>>=1,h-=1,f&3){case 0:e.mode=aE;break;case 1:if(az(e),e.mode=Od,t===Td){f>>>=2,h-=2;break t}break;case 2:e.mode=uE;break;case 3:n.msg="invalid block type",e.mode=We}f>>>=2,h-=2;break;case aE:for(f>>>=h&7,h-=h&7;h<32;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if((f&65535)!==(f>>>16^65535)){n.msg="invalid stored block lengths",e.mode=We;break}if(e.length=f&65535,f=0,h=0,e.mode=jy,t===Td)break t;case jy:e.mode=cE;case cE:if(b=e.length,b){if(b>c&&(b=c),b>u&&(b=u),b===0)break t;i.set(r.subarray(s,s+b),o),c-=b,s+=b,u-=b,o+=b,e.length-=b;break}e.mode=ds;break;case uE:for(;h<14;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(e.nlen=(f&31)+257,f>>>=5,h-=5,e.ndist=(f&31)+1,f>>>=5,h-=5,e.ncode=(f&15)+4,f>>>=4,h-=4,e.nlen>286||e.ndist>30){n.msg="too many length or distance symbols",e.mode=We;break}e.have=0,e.mode=lE;case lE:for(;e.have<e.ncode;){for(;h<3;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.lens[ot[e.have++]]=f&7,f>>>=3,h-=3}for(;e.have<19;)e.lens[ot[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,ut={bits:e.lenbits},J=Mf(QH,e.lens,0,19,e.lencode,0,e.work,ut),e.lenbits=ut.bits,J){n.msg="invalid code lengths set",e.mode=We;break}e.have=0,e.mode=fE;case fE:for(;e.have<e.nlen+e.ndist;){for(;S=e.lencode[f&(1<<e.lenbits)-1],B=S>>>24,H=S>>>16&255,U=S&65535,!(B<=h);){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(U<16)f>>>=B,h-=B,e.lens[e.have++]=U;else{if(U===16){for(rt=B+2;h<rt;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(f>>>=B,h-=B,e.have===0){n.msg="invalid bit length repeat",e.mode=We;break}j=e.lens[e.have-1],b=3+(f&3),f>>>=2,h-=2}else if(U===17){for(rt=B+3;h<rt;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}f>>>=B,h-=B,j=0,b=3+(f&7),f>>>=3,h-=3}else{for(rt=B+7;h<rt;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}f>>>=B,h-=B,j=0,b=11+(f&127),f>>>=7,h-=7}if(e.have+b>e.nlen+e.ndist){n.msg="invalid bit length repeat",e.mode=We;break}for(;b--;)e.lens[e.have++]=j}}if(e.mode===We)break;if(e.lens[256]===0){n.msg="invalid code -- missing end-of-block",e.mode=We;break}if(e.lenbits=9,ut={bits:e.lenbits},J=Mf(FR,e.lens,0,e.nlen,e.lencode,0,e.work,ut),e.lenbits=ut.bits,J){n.msg="invalid literal/lengths set",e.mode=We;break}if(e.distbits=6,e.distcode=e.distdyn,ut={bits:e.distbits},J=Mf($R,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,ut),e.distbits=ut.bits,J){n.msg="invalid distances set",e.mode=We;break}if(e.mode=Od,t===Td)break t;case Od:e.mode=Nd;case Nd:if(c>=6&&u>=258){n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=c,e.hold=f,e.bits=h,VH(n,A),o=n.next_out,i=n.output,u=n.avail_out,s=n.next_in,r=n.input,c=n.avail_in,f=e.hold,h=e.bits,e.mode===ds&&(e.back=-1);break}for(e.back=0;S=e.lencode[f&(1<<e.lenbits)-1],B=S>>>24,H=S>>>16&255,U=S&65535,!(B<=h);){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(H&&!(H&240)){for(G=B,W=H,Y=U;S=e.lencode[Y+((f&(1<<G+W)-1)>>G)],B=S>>>24,H=S>>>16&255,U=S&65535,!(G+B<=h);){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}f>>>=G,h-=G,e.back+=G}if(f>>>=B,h-=B,e.back+=B,e.length=U,H===0){e.mode=yE;break}if(H&32){e.back=-1,e.mode=ds;break}if(H&64){n.msg="invalid literal/length code",e.mode=We;break}e.extra=H&15,e.mode=hE;case hE:if(e.extra){for(rt=e.extra;h<rt;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.length+=f&(1<<e.extra)-1,f>>>=e.extra,h-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=dE;case dE:for(;S=e.distcode[f&(1<<e.distbits)-1],B=S>>>24,H=S>>>16&255,U=S&65535,!(B<=h);){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(!(H&240)){for(G=B,W=H,Y=U;S=e.distcode[Y+((f&(1<<G+W)-1)>>G)],B=S>>>24,H=S>>>16&255,U=S&65535,!(G+B<=h);){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}f>>>=G,h-=G,e.back+=G}if(f>>>=B,h-=B,e.back+=B,H&64){n.msg="invalid distance code",e.mode=We;break}e.offset=U,e.extra=H&15,e.mode=pE;case pE:if(e.extra){for(rt=e.extra;h<rt;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}e.offset+=f&(1<<e.extra)-1,f>>>=e.extra,h-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){n.msg="invalid distance too far back",e.mode=We;break}e.mode=gE;case gE:if(u===0)break t;if(b=A-u,e.offset>b){if(b=e.offset-b,b>e.whave&&e.sane){n.msg="invalid distance too far back",e.mode=We;break}b>e.wnext?(b-=e.wnext,R=e.wsize-b):R=e.wnext-b,b>e.length&&(b=e.length),k=e.window}else k=i,R=o-e.offset,b=e.length;b>u&&(b=u),u-=b,e.length-=b;do i[o++]=k[R++];while(--b);e.length===0&&(e.mode=Nd);break;case yE:if(u===0)break t;i[o++]=e.length,u--,e.mode=Nd;break;case Wy:if(e.wrap){for(;h<32;){if(c===0)break t;c--,f|=r[s++]<<h,h+=8}if(A-=u,n.total_out+=A,e.total+=A,e.wrap&4&&A&&(n.adler=e.check=e.flags?Mn(e.check,i,A,o-A):uh(e.check,i,A,o-A)),A=u,e.wrap&4&&(e.flags?f:bE(f))!==e.check){n.msg="incorrect data check",e.mode=We;break}f=0,h=0}e.mode=mE;case mE:if(e.wrap&&e.flags){for(;h<32;){if(c===0)break t;c--,f+=r[s++]<<h,h+=8}if(e.wrap&4&&f!==(e.total&4294967295)){n.msg="incorrect length check",e.mode=We;break}f=0,h=0}e.mode=wE;case wE:J=YH;break t;case We:J=HR;break t;case GR:return zR;case VR:default:return oi}return n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=c,e.hold=f,e.bits=h,(e.wsize||A!==n.avail_out&&e.mode<We&&(e.mode<Wy||t!==QA))&&qR(n,n.output,n.next_out,A-n.avail_out),y-=n.avail_in,A-=n.avail_out,n.total_in+=y,n.total_out+=A,e.total+=A,e.wrap&4&&A&&(n.adler=e.check=e.flags?Mn(e.check,i,A,n.next_out-A):uh(e.check,i,A,n.next_out-A)),n.data_type=e.bits+(e.last?64:0)+(e.mode===ds?128:0)+(e.mode===Od||e.mode===jy?256:0),(y===0&&A===0||t===QA)&&J===hc&&(J=tz),J},uz=n=>{if(Rc(n))return oi;let t=n.state;return t.window&&(t.window=null),n.state=null,hc},lz=(n,t)=>{if(Rc(n))return oi;const e=n.state;return e.wrap&2?(e.head=t,t.done=!1,hc):oi},fz=(n,t)=>{const e=t.length;let r,i,s;return Rc(n)||(r=n.state,r.wrap!==0&&r.mode!==S0)?oi:r.mode===S0&&(i=1,i=uh(i,t,e,0),i!==r.check)?HR:(s=qR(n,t,e,e),s?(r.mode=GR,zR):(r.havedict=1,hc))};var hz=jR,dz=WR,pz=KR,gz=oz,yz=ZR,mz=cz,wz=uz,bz=lz,_z=fz,Az="pako inflate (from Nodeca project)",Es={inflateReset:hz,inflateReset2:dz,inflateResetKeep:pz,inflateInit:gz,inflateInit2:yz,inflate:mz,inflateEnd:wz,inflateGetHeader:bz,inflateSetDictionary:_z,inflateInfo:Az};function Ez(){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}var vz=Ez;const QR=Object.prototype.toString,{Z_NO_FLUSH:xz,Z_FINISH:Rz,Z_OK:hh,Z_STREAM_END:Qy,Z_NEED_DICT:Jy,Z_STREAM_ERROR:Sz,Z_DATA_ERROR:AE,Z_MEM_ERROR:Iz}=Wh;function qh(n){this.options=Ip.assign({chunkSize:1024*64,windowBits:15,to:""},n||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(n&&n.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new UR,this.strm.avail_out=0;let e=Es.inflateInit2(this.strm,t.windowBits);if(e!==hh)throw new Error(ul[e]);if(this.header=new vz,Es.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=fh.string2buf(t.dictionary):QR.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=Es.inflateSetDictionary(this.strm,t.dictionary),e!==hh)))throw new Error(ul[e])}qh.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let s,o,c;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?Rz:xz,QR.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),s=Es.inflate(e,o),s===Jy&&i&&(s=Es.inflateSetDictionary(e,i),s===hh?s=Es.inflate(e,o):s===AE&&(s=Jy));e.avail_in>0&&s===Qy&&e.state.wrap>0&&n[e.next_in]!==0;)Es.inflateReset(e),s=Es.inflate(e,o);switch(s){case Sz:case AE:case Jy:case Iz:return this.onEnd(s),this.ended=!0,!1}if(c=e.avail_out,e.next_out&&(e.avail_out===0||s===Qy))if(this.options.to==="string"){let u=fh.utf8border(e.output,e.next_out),f=e.next_out-u,h=fh.buf2string(e.output,u);e.next_out=f,e.avail_out=r-f,f&&e.output.set(e.output.subarray(u,u+f),0),this.onData(h)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(s===hh&&c===0)){if(s===Qy)return s=Es.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(e.avail_in===0)break}}return!0};qh.prototype.onData=function(n){this.chunks.push(n)};qh.prototype.onEnd=function(n){n===hh&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ip.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function L1(n,t){const e=new qh(t);if(e.push(n),e.err)throw e.msg||ul[e.err];return e.result}function kz(n,t){return t=t||{},t.raw=!0,L1(n,t)}var Tz=qh,Oz=L1,Nz=kz,Cz=L1,Bz=Wh,Pz={Inflate:Tz,inflate:Oz,inflateRaw:Nz,ungzip:Cz,constants:Bz};const{Inflate:nQ,inflate:Mz,inflateRaw:rQ,ungzip:iQ}=Pz;var Lz=Mz,JR={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function i(u,f,h){this.fn=u,this.context=f,this.once=h||!1}function s(u,f,h,y,A){if(typeof h!="function")throw new TypeError("The listener must be a function");var b=new i(h,y||u,A),R=e?e+f:f;return u._events[R]?u._events[R].fn?u._events[R]=[u._events[R],b]:u._events[R].push(b):(u._events[R]=b,u._eventsCount++),u}function o(u,f){--u._eventsCount===0?u._events=new r:delete u._events[f]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var f=[],h,y;if(this._eventsCount===0)return f;for(y in h=this._events)t.call(h,y)&&f.push(e?y.slice(1):y);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},c.prototype.listeners=function(f){var h=e?e+f:f,y=this._events[h];if(!y)return[];if(y.fn)return[y.fn];for(var A=0,b=y.length,R=new Array(b);A<b;A++)R[A]=y[A].fn;return R},c.prototype.listenerCount=function(f){var h=e?e+f:f,y=this._events[h];return y?y.fn?1:y.length:0},c.prototype.emit=function(f,h,y,A,b,R){var k=e?e+f:f;if(!this._events[k])return!1;var S=this._events[k],B=arguments.length,H,U;if(S.fn){switch(S.once&&this.removeListener(f,S.fn,void 0,!0),B){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,h),!0;case 3:return S.fn.call(S.context,h,y),!0;case 4:return S.fn.call(S.context,h,y,A),!0;case 5:return S.fn.call(S.context,h,y,A,b),!0;case 6:return S.fn.call(S.context,h,y,A,b,R),!0}for(U=1,H=new Array(B-1);U<B;U++)H[U-1]=arguments[U];S.fn.apply(S.context,H)}else{var G=S.length,W;for(U=0;U<G;U++)switch(S[U].once&&this.removeListener(f,S[U].fn,void 0,!0),B){case 1:S[U].fn.call(S[U].context);break;case 2:S[U].fn.call(S[U].context,h);break;case 3:S[U].fn.call(S[U].context,h,y);break;case 4:S[U].fn.call(S[U].context,h,y,A);break;default:if(!H)for(W=1,H=new Array(B-1);W<B;W++)H[W-1]=arguments[W];S[U].fn.apply(S[U].context,H)}}return!0},c.prototype.on=function(f,h,y){return s(this,f,h,y,!1)},c.prototype.once=function(f,h,y){return s(this,f,h,y,!0)},c.prototype.removeListener=function(f,h,y,A){var b=e?e+f:f;if(!this._events[b])return this;if(!h)return o(this,b),this;var R=this._events[b];if(R.fn)R.fn===h&&(!A||R.once)&&(!y||R.context===y)&&o(this,b);else{for(var k=0,S=[],B=R.length;k<B;k++)(R[k].fn!==h||A&&!R[k].once||y&&R[k].context!==y)&&S.push(R[k]);S.length?this._events[b]=S.length===1?S[0]:S:o(this,b)}return this},c.prototype.removeAllListeners=function(f){var h;return f?(h=e?e+f:f,this._events[h]&&o(this,h)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=e,c.EventEmitter=c,n.exports=c})(JR);var Uz=JR.exports;const Dz=ea(Uz);function Fz(n,t){return Array.apply(0,new Array(Math.ceil(n.length/t))).map((e,r)=>n.slice(r*t,(r+1)*t))}const ua=n=>"version"in n;function $z(n){return new TextDecoder("utf-8").decode(n)}function EE(n){return In.encode(n)}function YR(n){return It.from(n,"base64")}function go(n){return"accounts"in n}async function Hz(n){const t=(await pt.findProgramAddress([],n))[0];return await pt.createWithSeed(t,zz(),n)}function zz(){return"anchor:idl"}const Gz=qt.struct([qt.publicKey("authority"),qt.vecU8("data")]);function Vz(n){return Gz.decode(n)}function Kz(n){const t=["name","path","account","relations","generic"],e=s=>s.split(".").map(n$).join("."),r=s=>{for(const o in s){const c=s[o];t.includes(o)?s[o]=Array.isArray(c)?c.map(e):e(c):typeof c=="object"&&r(c)}},i=structuredClone(n);return r(i),i}function Jc(n,t,e,r){return n!=null&&n.length?n[0].name?e(n):r(n):t()}function jz(n){const t=new Map;return n.errors&&n.errors.forEach(e=>{var r;let i=(r=e.msg)!==null&&r!==void 0?r:e.name;t.set(e.code,i)}),t}function Wz(n,...t){if(n.args.length!=t.length)throw new Error("Invalid argument length");const e={};let r=0;return n.args.forEach(i=>{e[i.name]=t[r],r+=1}),e}function XR(n,t={}){n.forEach(e=>{if(go(e))XR(e.accounts,t[e.name]);else if(!t[e.name])throw new Error(`Account \`${e.name}\` not provided.`)})}function bi(n){return n instanceof pt?n:new pt(n)}class Zz extends TypeError{constructor(t,e){let r;const{message:i,...s}=t,{path:o}=t,c=o.length===0?i:"At path: "+o.join(".")+" -- "+i;super(c),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,s),this.name=this.constructor.name,this.failures=()=>{var u;return(u=r)!=null?u:r=[t,...e()]}}}function qz(n){return cu(n)&&typeof n[Symbol.iterator]=="function"}function cu(n){return typeof n=="object"&&n!=null}function Yo(n){return typeof n=="string"?JSON.stringify(n):""+n}function Qz(n){const{done:t,value:e}=n.next();return t?void 0:e}function Jz(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:i,branch:s}=t,{type:o}=e,{refinement:c,message:u="Expected a value of type `"+o+"`"+(c?" with refinement `"+c+"`":"")+", but received: `"+Yo(r)+"`"}=n;return{value:r,type:o,refinement:c,key:i[i.length-1],path:i,branch:s,...n,message:u}}function*vE(n,t,e,r){qz(n)||(n=[n]);for(const i of n){const s=Jz(i,t,e,r);s&&(yield s)}}function*U1(n,t,e){e===void 0&&(e={});const{path:r=[],branch:i=[n],coerce:s=!1,mask:o=!1}=e,c={path:r,branch:i};if(s&&(n=t.coercer(n,c),o&&t.type!=="type"&&cu(t.schema)&&cu(n)&&!Array.isArray(n)))for(const f in n)t.schema[f]===void 0&&delete n[f];let u=!0;for(const f of t.validator(n,c))u=!1,yield[f,void 0];for(let[f,h,y]of t.entries(n,c)){const A=U1(h,y,{path:f===void 0?r:[...r,f],branch:f===void 0?i:[...i,h],coerce:s,mask:o});for(const b of A)b[0]?(u=!1,yield[b[0],void 0]):s&&(h=b[1],f===void 0?n=h:n instanceof Map?n.set(f,h):n instanceof Set?n.add(h):cu(n)&&(n[f]=h))}if(u)for(const f of t.refiner(n,c))u=!1,yield[f,void 0];u&&(yield[void 0,n])}class na{constructor(t){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:e,schema:r,validator:i,refiner:s,coercer:o=u=>u,entries:c=function*(){}}=t;this.type=e,this.schema=r,this.entries=c,this.coercer=o,i?this.validator=(u,f)=>{const h=i(u,f);return vE(h,f,this,u)}:this.validator=()=>[],s?this.refiner=(u,f)=>{const h=s(u,f);return vE(h,f,this,u)}:this.refiner=()=>[]}assert(t){return Yz(t,this)}create(t){return D1(t,this)}is(t){return tS(t,this)}mask(t){return Xz(t,this)}validate(t,e){return e===void 0&&(e={}),Qh(t,this,e)}}function Yz(n,t){const e=Qh(n,t);if(e[0])throw e[0]}function D1(n,t){const e=Qh(n,t,{coerce:!0});if(e[0])throw e[0];return e[1]}function Xz(n,t){const e=Qh(n,t,{coerce:!0,mask:!0});if(e[0])throw e[0];return e[1]}function tS(n,t){return!Qh(n,t)[0]}function Qh(n,t,e){e===void 0&&(e={});const r=U1(n,t,e),i=Qz(r);return i[0]?[new Zz(i[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function Jh(n,t){return new na({type:n,schema:null,validator:t})}function tG(){return Jh("any",()=>!0)}function Yy(n){return new na({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[e,r]of t.entries())yield[e,r,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||"Expected an array value, but received: "+Yo(t)}})}function eG(){return Jh("boolean",n=>typeof n=="boolean")}function xE(n){const t=Yo(n);return new na({type:"literal",schema:n,validator(e){return e===n||"Expected the literal `"+t+"`, but received: "+Yo(e)}})}function Cd(n){return new na({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function jd(){return Jh("number",n=>typeof n=="number"&&!isNaN(n)||"Expected a number, but received: "+Yo(n))}function Wd(n){return new na({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function xa(){return Jh("string",n=>typeof n=="string"||"Expected a string, but received: "+Yo(n))}function Ko(n){const t=Object.keys(n);return new na({type:"type",schema:n,*entries(e){if(cu(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return cu(e)||"Expected an object, but received: "+Yo(e)}})}function eS(n){const t=n.map(e=>e.type).join(" | ");return new na({type:"union",schema:null,coercer(e,r){return(n.find(s=>{const[o]=s.validate(e,{coerce:!0});return!o})||F1()).coercer(e,r)},validator(e,r){const i=[];for(const s of n){const[...o]=U1(e,s,r),[c]=o;if(c[0])for(const[u]of o)u&&i.push(u);else return[]}return["Expected the value to satisfy a union of `"+t+"`, but received: "+Yo(e),...i]}})}function F1(){return Jh("unknown",()=>!0)}function nG(n,t,e){return new na({...n,coercer:(r,i)=>tS(r,t)?n.coercer(e(r,i),i):n.coercer(r,i)})}const RE=99;async function rG(n,t,e){if(t.length<=RE)return await SE(n,t,e);{const r=Fz(t,RE);return(await Promise.all(r.map(s=>SE(n,s,e)))).flat()}}async function SE(n,t,e){const r=e??n.commitment,{value:i,context:s}=await n.getMultipleAccountsInfoAndContext(t,r);return i.map((c,u)=>c===null?null:{publicKey:t[u],account:c,context:s})}async function iG(n,t,e,r,i){var s;e&&e.length>0&&t.sign(...e);const o=t._compile(),c=o.serialize(),f=t._serialize(c).toString("base64"),h={encoding:"base64",commitment:r??n.commitment};if(i){const R=(Array.isArray(i)?i:o.nonProgramIds()).map(k=>k.toBase58());h.accounts={encoding:"base64",addresses:R}}e&&e.length>0&&(h.sigVerify=!0);const y=[f,h],A=await n._rpcRequest("simulateTransaction",y),b=D1(A,cG);if("error"in b){let R;if("data"in b.error&&(R=(s=b.error.data)===null||s===void 0?void 0:s.logs,R&&Array.isArray(R))){const k=`
|
|
24
|
-
`,S=k+R.join(k);console.error(b.error.message,S)}throw new Jo("failed to simulate transaction: "+b.error.message,R)}return b.result}function sG(n){return nG(nS(n),oG,t=>"error"in t?t:{...t,result:D1(t.result,n)})}const oG=nS(F1());function nS(n){return eS([Ko({jsonrpc:xE("2.0"),id:xa(),result:n}),Ko({jsonrpc:xE("2.0"),id:xa(),error:Ko({code:F1(),message:xa(),data:Wd(tG())})})])}function aG(n){return sG(Ko({context:Ko({slot:jd()}),value:n}))}const cG=aG(Ko({err:Cd(eS([Ko({}),xa()])),logs:Cd(Yy(xa())),accounts:Wd(Cd(Yy(Cd(Ko({executable:eG(),owner:xa(),lamports:jd(),data:Yy(xa()),rentEpoch:Wd(jd())}))))),unitsConsumed:Wd(jd())}));class dh{constructor(t,e,r=dh.defaultOptions()){this.connection=t,this.wallet=e,this.opts=r,this.publicKey=e==null?void 0:e.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(t,e=dh.defaultOptions()){throw new Error("Provider local is not available on browser.")}static env(){throw new Error("Provider env is not available on browser.")}async sendAndConfirm(t,e,r){var i,s,o,c;if(r===void 0&&(r=this.opts),ua(t))e&&t.sign(e);else if(t.feePayer=(i=t.feePayer)!==null&&i!==void 0?i:this.wallet.publicKey,t.recentBlockhash=(await this.connection.getLatestBlockhash(r.preflightCommitment)).blockhash,e)for(const f of e)t.partialSign(f);t=await this.wallet.signTransaction(t);const u=t.serialize();try{return await IE(this.connection,u,r)}catch(f){if(f instanceof tw){const h=EE(ua(t)?((s=t.signatures)===null||s===void 0?void 0:s[0])||new Uint8Array:(o=t.signature)!==null&&o!==void 0?o:new Uint8Array),y=ua(t)?0:void 0,A=await this.connection.getTransaction(h,{commitment:"confirmed",maxSupportedTransactionVersion:y});if(A){const b=(c=A.meta)===null||c===void 0?void 0:c.logMessages;throw b?new Jo(f.message,b):f}else throw f}else throw f}}async sendAll(t,e){var r,i,s;e===void 0&&(e=this.opts);const o=(await this.connection.getLatestBlockhash(e.preflightCommitment)).blockhash;let c=t.map(h=>{var y,A;if(ua(h.tx)){let b=h.tx;return h.signers&&b.sign(h.signers),b}else{let b=h.tx,R=(y=h.signers)!==null&&y!==void 0?y:[];return b.feePayer=(A=b.feePayer)!==null&&A!==void 0?A:this.wallet.publicKey,b.recentBlockhash=o,R.forEach(k=>{b.partialSign(k)}),b}});const u=await this.wallet.signAllTransactions(c),f=[];for(let h=0;h<c.length;h+=1){const y=u[h],A=y.serialize();try{f.push(await IE(this.connection,A,e))}catch(b){if(b instanceof tw){const R=EE(ua(y)?((r=y.signatures)===null||r===void 0?void 0:r[0])||new Uint8Array:(i=y.signature)!==null&&i!==void 0?i:new Uint8Array),k=ua(y)?0:void 0,S=await this.connection.getTransaction(R,{commitment:"confirmed",maxSupportedTransactionVersion:k});if(S){const B=(s=S.meta)===null||s===void 0?void 0:s.logMessages;throw B?new Jo(b.message,B):b}else throw b}else throw b}}return f}async simulate(t,e,r,i){let s=(await this.connection.getLatestBlockhash(r??this.connection.commitment)).blockhash,o;if(ua(t)?(e&&e.length>0&&(t.sign(e),t=await this.wallet.signTransaction(t)),o=await this.connection.simulateTransaction(t,{commitment:r})):(t.feePayer=t.feePayer||this.wallet.publicKey,t.recentBlockhash=s,e&&e.length>0&&(t=await this.wallet.signTransaction(t)),o=await iG(this.connection,t,e,r,i)),o.value.err)throw new uG(o.value);return o.value}}class uG extends Error{constructor(t,e){super(e),this.simulationResponse=t}}async function IE(n,t,e){const r=e?{skipPreflight:e.skipPreflight,preflightCommitment:e.preflightCommitment||e.commitment,maxRetries:e.maxRetries,minContextSlot:e.minContextSlot}:{};let i;const s=Date.now();for(;Date.now()-s<6e4;)try{const o=await n.sendRawTransaction(t,r);if(e!=null&&e.blockhash)if(r.maxRetries===0){const c=AbortSignal.timeout(15e3);i=(await n.confirmTransaction({abortSignal:c,signature:o,...e.blockhash},e&&e.commitment)).value}else i=(await n.confirmTransaction({signature:o,...e.blockhash},e&&e.commitment)).value;else i=(await n.confirmTransaction(o,e&&e.commitment)).value;if(i.err)throw new tw(`Raw transaction ${o} failed (${JSON.stringify(i)})`);return o}catch(o){if(o.name==="TimeoutError")continue;throw o}throw Error("Transaction failed to confirm in 60s")}class tw extends Error{constructor(t){super(t)}}function ew(){return dh.local()}var lG=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof nl<"u"?nl:typeof self<"u"?self:{},tt={};Object.defineProperty(tt,"__esModule",{value:!0});var rS=tt.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=XS=tt.ANCHOR_ERROR__REQUIRE_VIOLATED=YS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=JS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=QS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=qS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=ZS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=WS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=jS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=KS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=VS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=GS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=zS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=HS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=$S=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=FS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=DS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=US=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=LS=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=MS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=PS=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=BS=tt.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=CS=tt.ANCHOR_ERROR__CONSTRAINT_SPACE=NS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=OS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=TS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=kS=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=IS=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=SS=tt.ANCHOR_ERROR__CONSTRAINT_ZERO=RS=tt.ANCHOR_ERROR__CONSTRAINT_ADDRESS=xS=tt.ANCHOR_ERROR__CONSTRAINT_CLOSE=vS=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=ES=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=AS=tt.ANCHOR_ERROR__CONSTRAINT_STATE=_S=tt.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=bS=tt.ANCHOR_ERROR__CONSTRAINT_SEEDS=wS=tt.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=mS=tt.ANCHOR_ERROR__CONSTRAINT_OWNER=yS=tt.ANCHOR_ERROR__CONSTRAINT_RAW=gS=tt.ANCHOR_ERROR__CONSTRAINT_SIGNER=pS=tt.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=dS=tt.ANCHOR_ERROR__CONSTRAINT_MUT=hS=tt.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=fS=tt.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=lS=tt.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=uS=tt.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=cS=tt.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=aS=tt.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=oS=tt.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=sS=tt.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0,iS=tt.ANCHOR_ERROR__DEPRECATED=RI=tt.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=xI=tt.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=vI=tt.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=EI=tt.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=AI=tt.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=_I=tt.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=bI=tt.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=wI=tt.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=mI=tt.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=yI=tt.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=gI=tt.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=pI=tt.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=dI=tt.ANCHOR_ERROR__INVALID_PROGRAM_ID=hI=tt.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=fI=tt.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=lI=tt.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=uI=tt.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=cI=tt.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=aI=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=oI=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=sI=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=iI=tt.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=rI=tt.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=nI=tt.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=eI=tt.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=tI=tt.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0,sS=tt.ANCHOR_ERROR__INSTRUCTION_MISSING=100,oS=tt.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101,aS=tt.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102,cS=tt.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103,uS=tt.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3,lS=tt.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=1001,fS=tt.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002,hS=tt.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500,dS=tt.ANCHOR_ERROR__CONSTRAINT_MUT=2e3,pS=tt.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001,gS=tt.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002,yS=tt.ANCHOR_ERROR__CONSTRAINT_RAW=2003,mS=tt.ANCHOR_ERROR__CONSTRAINT_OWNER=2004,wS=tt.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005,bS=tt.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006,_S=tt.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007,AS=tt.ANCHOR_ERROR__CONSTRAINT_STATE=2008,ES=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009,vS=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010,xS=tt.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011,RS=tt.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012,SS=tt.ANCHOR_ERROR__CONSTRAINT_ZERO=2013,IS=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014,kS=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015,TS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016,OS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017,NS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018,CS=tt.ANCHOR_ERROR__CONSTRAINT_SPACE=2019,BS=tt.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020,PS=tt.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021,MS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022,LS=tt.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023,US=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024,DS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025,FS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026,$S=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027,HS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028,zS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029,GS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030,VS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031,KS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032,jS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033,WS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034,ZS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035,qS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036,QS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037,JS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038,YS=tt.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039,XS=tt.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;rS=tt.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;var tI=tt.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502,eI=tt.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503,nI=tt.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504,rI=tt.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505,iI=tt.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506,sI=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3,oI=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001,aI=tt.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002,cI=tt.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003,uI=tt.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004,lI=tt.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005,fI=tt.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006,hI=tt.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007,dI=tt.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008,pI=tt.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009,gI=tt.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010,yI=tt.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011,mI=tt.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012,wI=tt.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013,bI=tt.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014,_I=tt.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015,AI=tt.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016,EI=tt.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017,vI=tt.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100,xI=tt.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101,RI=tt.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;iS=tt.ANCHOR_ERROR__DEPRECATED=5e3;const fG=new Map;function SI(n){return fG.get(n)!==void 0}class fo extends Error{constructor(t){super(t),this.name="IdlError"}}class Yh{constructor(t){this.stack=t}static parse(t){var e;const r=/^Program (\w*) invoke/,i=/^Program \w* success/,s=[];for(let o=0;o<t.length;o++){if(i.exec(t[o])){s.pop();continue}const c=(e=r.exec(t[o]))===null||e===void 0?void 0:e[1];c&&s.push(new pt(c))}return new Yh(s)}}class Lf extends Error{constructor(t,e,r,i,s,o){super(r.join(`
|
|
25
|
-
`).replace("Program log: ","")),this.errorLogs=r,this.logs=i,this.error={errorCode:t,errorMessage:e,comparedValues:o,origin:s},this._programErrorStack=Yh.parse(i)}static parse(t){if(!t)return null;const e=t.findIndex(A=>A.startsWith("Program log: AnchorError"));if(e===-1)return null;const r=t[e],i=[r];let s;if(e+1<t.length){if(t[e+1]==="Program log: Left:"){const A=/^Program log: (.*)$/,b=A.exec(t[e+2])[1],R=A.exec(t[e+4])[1];s=[new pt(b),new pt(R)],i.push(...t.slice(e+1,e+5))}else if(t[e+1].startsWith("Program log: Left:")){const A=/^Program log: (Left|Right): (.*)$/,b=A.exec(t[e+1])[2],R=A.exec(t[e+2])[2];i.push(...t.slice(e+1,e+3)),s=[b,R]}}const c=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),f=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),y=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r);if(c){const[A,b,R]=c.slice(1,4),k={code:A,number:parseInt(b)};return new Lf(k,R,i,t,void 0,s)}else if(f){const[A,b,R,k,S]=f.slice(1,6),B={code:R,number:parseInt(k)},H={file:A,line:parseInt(b)};return new Lf(B,S,i,t,H,s)}else if(y){const[A,b,R,k]=y.slice(1,5),S=A,B={code:b,number:parseInt(R)};return new Lf(B,k,i,t,S,s)}else return null}get program(){return this._programErrorStack.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){return this._programErrorStack.stack}toString(){return this.message}}class I0 extends Error{constructor(t,e,r){super(),this.code=t,this.msg=e,this.logs=r,r&&(this._programErrorStack=Yh.parse(r))}static parse(t,e){const r=t.toString();let i;if(r.includes("custom program error:")){let c=r.split("custom program error: ");if(c.length!==2)return null;i=c[1]}else{const c=r.match(/"Custom":([0-9]+)}/g);if(!c||c.length>1)return null;i=c[0].match(/([0-9]+)/g)[0]}let s;try{s=parseInt(i)}catch{return null}let o=e.get(s);return o!==void 0?new I0(s,o,t.logs):(o=hG.get(s),o!==void 0?new I0(s,o,t.logs):null)}get program(){var t;return(t=this._programErrorStack)===null||t===void 0?void 0:t.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var t;return(t=this._programErrorStack)===null||t===void 0?void 0:t.stack}toString(){return this.msg}}function II(n,t){SI("debug-logs")&&console.log("Translating error:",n);const e=Lf.parse(n.logs);if(e)return e;const r=I0.parse(n,t);if(r)return r;if(n.logs){const i={get:function(s,o){return o==="programErrorStack"?s.programErrorStack.stack:o==="program"?s.programErrorStack.stack[n.programErrorStack.stack.length-1]:Reflect.get(...arguments)}};return n.programErrorStack=Yh.parse(n.logs),new Proxy(n,i)}return n}const bt={InstructionMissing:sS,InstructionFallbackNotFound:oS,InstructionDidNotDeserialize:aS,InstructionDidNotSerialize:cS,IdlInstructionStub:uS,IdlInstructionInvalidProgram:lS,IdlAccountNotEmpty:fS,EventInstructionStub:hS,ConstraintMut:dS,ConstraintHasOne:pS,ConstraintSigner:gS,ConstraintRaw:yS,ConstraintOwner:mS,ConstraintRentExempt:wS,ConstraintSeeds:bS,ConstraintExecutable:_S,ConstraintState:AS,ConstraintAssociated:ES,ConstraintAssociatedInit:vS,ConstraintClose:xS,ConstraintAddress:RS,ConstraintZero:SS,ConstraintTokenMint:IS,ConstraintTokenOwner:kS,ConstraintMintMintAuthority:TS,ConstraintMintFreezeAuthority:OS,ConstraintMintDecimals:NS,ConstraintSpace:CS,ConstraintAccountIsNone:BS,ConstraintTokenTokenProgram:PS,ConstraintMintTokenProgram:MS,ConstraintAssociatedTokenTokenProgram:LS,ConstraintMintGroupPointerExtension:US,ConstraintMintGroupPointerExtensionAuthority:DS,ConstraintMintGroupPointerExtensionGroupAddress:FS,ConstraintMintGroupMemberPointerExtension:$S,ConstraintMintGroupMemberPointerExtensionAuthority:HS,ConstraintMintGroupMemberPointerExtensionMemberAddress:zS,ConstraintMintMetadataPointerExtension:GS,ConstraintMintMetadataPointerExtensionAuthority:VS,ConstraintMintMetadataPointerExtensionMetadataAddress:KS,ConstraintMintCloseAuthorityExtension:jS,ConstraintMintCloseAuthorityExtensionAuthority:WS,ConstraintMintPermanentDelegateExtension:ZS,ConstraintMintPermanentDelegateExtensionDelegate:qS,ConstraintMintTransferHookExtension:QS,ConstraintMintTransferHookExtensionAuthority:JS,ConstraintMintTransferHookExtensionProgramId:YS,RequireViolated:XS,RequireEqViolated:rS,RequireKeysEqViolated:tI,RequireNeqViolated:eI,RequireKeysNeqViolated:nI,RequireGtViolated:rI,RequireGteViolated:iI,AccountDiscriminatorAlreadySet:sI,AccountDiscriminatorNotFound:oI,AccountDiscriminatorMismatch:aI,AccountDidNotDeserialize:cI,AccountDidNotSerialize:uI,AccountNotEnoughKeys:lI,AccountNotMutable:fI,AccountOwnedByWrongProgram:hI,InvalidProgramId:dI,InvalidProgramExecutable:pI,AccountNotSigner:gI,AccountNotSystemOwned:yI,AccountNotInitialized:mI,AccountNotProgramData:wI,AccountNotAssociatedTokenAccount:bI,AccountSysvarMismatch:_I,AccountReallocExceedsLimit:AI,AccountDuplicateReallocs:EI,DeclaredProgramIdMismatch:vI,TryingToInitPayerAsProgramAccount:xI,InvalidNumericConversion:RI,Deprecated:iS},hG=new Map([[bt.InstructionMissing,"Instruction discriminator not provided"],[bt.InstructionFallbackNotFound,"Fallback functions are not supported"],[bt.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[bt.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[bt.IdlInstructionStub,"The program was compiled without idl instructions"],[bt.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[bt.IdlAccountNotEmpty,"IDL account must be empty in order to resize, try closing first"],[bt.EventInstructionStub,"The program was compiled without `event-cpi` feature"],[bt.ConstraintMut,"A mut constraint was violated"],[bt.ConstraintHasOne,"A has one constraint was violated"],[bt.ConstraintSigner,"A signer constraint was violated"],[bt.ConstraintRaw,"A raw constraint was violated"],[bt.ConstraintOwner,"An owner constraint was violated"],[bt.ConstraintRentExempt,"A rent exemption constraint was violated"],[bt.ConstraintSeeds,"A seeds constraint was violated"],[bt.ConstraintExecutable,"An executable constraint was violated"],[bt.ConstraintState,"Deprecated Error, feel free to replace with something else"],[bt.ConstraintAssociated,"An associated constraint was violated"],[bt.ConstraintAssociatedInit,"An associated init constraint was violated"],[bt.ConstraintClose,"A close constraint was violated"],[bt.ConstraintAddress,"An address constraint was violated"],[bt.ConstraintZero,"Expected zero account discriminant"],[bt.ConstraintTokenMint,"A token mint constraint was violated"],[bt.ConstraintTokenOwner,"A token owner constraint was violated"],[bt.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[bt.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[bt.ConstraintMintDecimals,"A mint decimals constraint was violated"],[bt.ConstraintSpace,"A space constraint was violated"],[bt.ConstraintAccountIsNone,"A required account for the constraint is None"],[bt.ConstraintTokenTokenProgram,"A token account token program constraint was violated"],[bt.ConstraintMintTokenProgram,"A mint token program constraint was violated"],[bt.ConstraintAssociatedTokenTokenProgram,"An associated token account token program constraint was violated"],[bt.ConstraintMintGroupPointerExtension,"A group pointer extension constraint was violated"],[bt.ConstraintMintGroupPointerExtensionAuthority,"A group pointer extension authority constraint was violated"],[bt.ConstraintMintGroupPointerExtensionGroupAddress,"A group pointer extension group address constraint was violated"],[bt.ConstraintMintGroupMemberPointerExtension,"A group member pointer extension constraint was violated"],[bt.ConstraintMintGroupMemberPointerExtensionAuthority,"A group member pointer extension authority constraint was violated"],[bt.ConstraintMintGroupMemberPointerExtensionMemberAddress,"A group member pointer extension group address constraint was violated"],[bt.ConstraintMintMetadataPointerExtension,"A metadata pointer extension constraint was violated"],[bt.ConstraintMintMetadataPointerExtensionAuthority,"A metadata pointer extension authority constraint was violated"],[bt.ConstraintMintMetadataPointerExtensionMetadataAddress,"A metadata pointer extension metadata address constraint was violated"],[bt.ConstraintMintCloseAuthorityExtension,"A close authority constraint was violated"],[bt.ConstraintMintCloseAuthorityExtensionAuthority,"A close authority extension authority constraint was violated"],[bt.ConstraintMintPermanentDelegateExtension,"A permanent delegate extension constraint was violated"],[bt.ConstraintMintPermanentDelegateExtensionDelegate,"A permanent delegate extension delegate constraint was violated"],[bt.ConstraintMintTransferHookExtension,"A transfer hook extension constraint was violated"],[bt.ConstraintMintTransferHookExtensionAuthority,"A transfer hook extension authority constraint was violated"],[bt.ConstraintMintTransferHookExtensionProgramId,"A transfer hook extension transfer hook program id constraint was violated"],[bt.RequireViolated,"A require expression was violated"],[bt.RequireEqViolated,"A require_eq expression was violated"],[bt.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[bt.RequireNeqViolated,"A require_neq expression was violated"],[bt.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[bt.RequireGtViolated,"A require_gt expression was violated"],[bt.RequireGteViolated,"A require_gte expression was violated"],[bt.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[bt.AccountDiscriminatorNotFound,"No discriminator was found on the account"],[bt.AccountDiscriminatorMismatch,"Account discriminator did not match what was expected"],[bt.AccountDidNotDeserialize,"Failed to deserialize the account"],[bt.AccountDidNotSerialize,"Failed to serialize the account"],[bt.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[bt.AccountNotMutable,"The given account is not mutable"],[bt.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[bt.InvalidProgramId,"Program ID was not as expected"],[bt.InvalidProgramExecutable,"Program account is not executable"],[bt.AccountNotSigner,"The given account did not sign"],[bt.AccountNotSystemOwned,"The given account is not owned by the system program"],[bt.AccountNotInitialized,"The program expected this account to be already initialized"],[bt.AccountNotProgramData,"The given account is not a program data account"],[bt.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[bt.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[bt.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[bt.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[bt.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[bt.TryingToInitPayerAsProgramAccount,"You cannot/should not initialize the payer account as a program account"],[bt.InvalidNumericConversion,"The program could not perform the numeric conversion, out of range integral type conversion attempted"],[bt.Deprecated,"The API being used is deprecated and should no longer be used"]]);class fe{static fieldLayout(t,e=[],r){const i=t.name;switch(t.type){case"bool":return qt.bool(i);case"u8":return qt.u8(i);case"i8":return qt.i8(i);case"u16":return qt.u16(i);case"i16":return qt.i16(i);case"u32":return qt.u32(i);case"i32":return qt.i32(i);case"f32":return qt.f32(i);case"u64":return qt.u64(i);case"i64":return qt.i64(i);case"f64":return qt.f64(i);case"u128":return qt.u128(i);case"i128":return qt.i128(i);case"u256":return qt.u256(i);case"i256":return qt.i256(i);case"bytes":return qt.vecU8(i);case"string":return qt.str(i);case"pubkey":return qt.publicKey(i);default:{if("option"in t.type)return qt.option(fe.fieldLayout({type:t.type.option},e,r),i);if("vec"in t.type)return qt.vec(fe.fieldLayout({type:t.type.vec},e,r),i);if("array"in t.type){let[s,o]=t.type.array;return o=fe.resolveArrayLen(o,r),qt.array(fe.fieldLayout({type:s},e,r),o,i)}if("defined"in t.type){if(!e)throw new fo("User defined types not provided");const s=t.type.defined.name,o=e.find(c=>c.name===s);if(!o)throw new fo(`Type not found: ${t.name}`);return fe.typeDefLayout({typeDef:o,types:e,genericArgs:r??t.type.defined.generics,name:i})}if("generic"in t.type){const s=r==null?void 0:r.at(0);if((s==null?void 0:s.kind)!=="type")throw new fo(`Invalid generic field: ${t.name}`);return fe.fieldLayout({...t,type:s.type},e)}throw new fo(`Not yet implemented: ${JSON.stringify(t.type)}`)}}}static typeDefLayout({typeDef:t,types:e,name:r,genericArgs:i}){switch(t.type.kind){case"struct":{const s=Jc(t.type.fields,()=>[],o=>o.map(c=>{const u=i&&fe.resolveGenericArgs({type:c.type,typeDef:t,genericArgs:i});return fe.fieldLayout(c,e,u)}),o=>o.map((c,u)=>{const f=i&&fe.resolveGenericArgs({type:c,typeDef:t,genericArgs:i});return fe.fieldLayout({name:u.toString(),type:c},e,f)}));return qt.struct(s,r)}case"enum":{const s=t.type.variants.map(o=>{const c=Jc(o.fields,()=>[],u=>u.map(f=>{const h=i&&fe.resolveGenericArgs({type:f.type,typeDef:t,genericArgs:i});return fe.fieldLayout(f,e,h)}),u=>u.map((f,h)=>{const y=i&&fe.resolveGenericArgs({type:f,typeDef:t,genericArgs:i});return fe.fieldLayout({name:h.toString(),type:f},e,y)}));return qt.struct(c,o.name)});return r!==void 0?qt.rustEnum(s).replicate(r):qt.rustEnum(s,r)}case"type":return fe.fieldLayout({type:t.type.alias,name:r},e)}}static typeSize(t,e,r){var i;switch(t){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"pubkey":return 32;default:if("option"in t)return 1+fe.typeSize(t.option,e,r);if("coption"in t)return 4+fe.typeSize(t.coption,e,r);if("vec"in t)return 1;if("array"in t){let[s,o]=t.array;return o=fe.resolveArrayLen(o,r),fe.typeSize(s,e,r)*o}if("defined"in t){const s=(i=e.types)===null||i===void 0?void 0:i.find(c=>c.name===t.defined.name);if(!s)throw new fo(`Type not found: ${JSON.stringify(t)}`);const o=c=>{const u=r??t.defined.generics,f=u&&fe.resolveGenericArgs({type:c,typeDef:s,genericArgs:u});return fe.typeSize(c,e,f)};switch(s.type.kind){case"struct":return Jc(s.type.fields,()=>[0],c=>c.map(u=>o(u.type)),c=>c.map(u=>o(u))).reduce((c,u)=>c+u,0);case"enum":{const c=s.type.variants.map(u=>Jc(u.fields,()=>[0],f=>f.map(h=>o(h.type)),f=>f.map(h=>o(h))).reduce((f,h)=>f+h,0));return Math.max(...c)+1}case"type":return fe.typeSize(s.type.alias,e,r)}}if("generic"in t){const s=r==null?void 0:r.at(0);if((s==null?void 0:s.kind)!=="type")throw new fo(`Invalid generic: ${t.generic}`);return fe.typeSize(s.type,e,r)}throw new Error(`Invalid type ${JSON.stringify(t)}`)}}static resolveArrayLen(t,e){if(typeof t=="number")return t;if(e){const r=e.find(i=>i.kind==="const");(r==null?void 0:r.kind)==="const"&&(t=+r.value)}if(typeof t!="number")throw new fo("Generic array length did not resolve");return t}static resolveGenericArgs({type:t,typeDef:e,genericArgs:r,isDefined:i}){if(typeof t!="object")return null;for(const s in e.generics){const o=e.generics[s];if("generic"in t&&o.name===t.generic)return[r[s]];if("option"in t){const c=fe.resolveGenericArgs({type:t.option,typeDef:e,genericArgs:r,isDefined:i});if(!c||!i)return c;if(c[0].kind==="type")return[{kind:"type",type:{option:c[0].type}}]}if("vec"in t){const c=fe.resolveGenericArgs({type:t.vec,typeDef:e,genericArgs:r,isDefined:i});if(!c||!i)return c;if(c[0].kind==="type")return[{kind:"type",type:{vec:c[0].type}}]}if("array"in t){const[c,u]=t.array,f=typeof u=="object",h=fe.resolveGenericArgs({type:c,typeDef:e,genericArgs:r,isDefined:i});if(h){for(const y in e.generics.slice(+s)){const A=+s+ +y;f&&e.generics[A].name===u.generic&&h.push(r[A])}if(!i)return h;if(h[0].kind==="type"&&h[1].kind==="const")return[{kind:"type",type:{array:[h[0].type,+h[1].value]}}]}if(f&&o.name===u.generic){const y=r[s];return i?[{kind:"type",type:{array:[c,+y.value]}}]:[y]}return null}if("defined"in t)return t.defined.generics?t.defined.generics.flatMap(c=>{switch(c.kind){case"type":return fe.resolveGenericArgs({type:c.type,typeDef:e,genericArgs:r,isDefined:!0});case"const":return[c]}}).filter(c=>c!==null):null}return null}}class dG{constructor(t){this.idl=t;const e=t.instructions.map(r=>{const i=r.name,s=r.args.map(c=>fe.fieldLayout(c,t.types)),o=qt.struct(s,i);return[i,{discriminator:r.discriminator,layout:o}]});this.ixLayouts=new Map(e)}encode(t,e){const r=It.alloc(1e3),i=this.ixLayouts.get(t);if(!i)throw new Error(`Unknown method: ${t}`);const s=i.layout.encode(e,r),o=r.slice(0,s);return It.concat([It.from(i.discriminator),o])}decode(t,e="hex"){typeof t=="string"&&(t=e==="hex"?It.from(t,"hex"):In.decode(t));for(const[r,i]of this.ixLayouts){const s=t.subarray(0,i.discriminator.length);if(s.equals(It.from(i.discriminator)))return{name:r,data:i.layout.decode(t.subarray(s.length))}}return null}format(t,e){return Pr.format(t,e,this.idl)}}class Pr{static format(t,e,r){const i=r.instructions.find(u=>t.name===u.name);if(!i)return console.error("Invalid instruction given"),null;const s=i.args.map(u=>({name:u.name,type:Pr.formatIdlType(u.type),data:Pr.formatIdlData(u,t.data[u.name],r.types)})),o=Pr.flattenIdlAccounts(i.accounts),c=e.map((u,f)=>f<o.length?{name:o[f].name,...u}:{name:void 0,...u});return{args:s,accounts:c}}static formatIdlType(t){if(typeof t=="string")return t;if("option"in t)return`Option<${this.formatIdlType(t.option)}>`;if("coption"in t)return`COption<${this.formatIdlType(t.coption)}>`;if("vec"in t)return`Vec<${this.formatIdlType(t.vec)}>`;if("array"in t)return`Array<${t.array[0]}; ${t.array[1]}>`;if("defined"in t){const e=t.defined.name;if(t.defined.generics){const r=t.defined.generics.map(i=>{switch(i.kind){case"type":return Pr.formatIdlType(i.type);case"const":return i.value}}).join(", ");return`${e}<${r}>`}return e}throw new Error(`Unknown IDL type: ${t}`)}static formatIdlData(t,e,r){if(typeof t.type=="string")return e.toString();if("vec"in t.type)return"["+e.map(i=>this.formatIdlData({name:"",type:t.type.vec},i,r)).join(", ")+"]";if("option"in t.type)return e===null?"null":this.formatIdlData({name:"",type:t.type.option},e,r);if("defined"in t.type){if(!r)throw new Error("User defined types not provided");const i=t.type.defined.name,s=r.find(o=>o.name===i);if(!s)throw new Error(`Type not found: ${i}`);return Pr.formatIdlDataDefined(s,e,r)}return"unknown"}static formatIdlDataDefined(t,e,r){switch(t.type.kind){case"struct":return"{ "+Jc(t.type.fields,()=>"",i=>Object.entries(e).map(([s,o])=>{const c=i.find(u=>u.name===s);if(!c)throw new Error(`Field not found: ${s}`);return s+": "+Pr.formatIdlData(c,o,r)}).join(", "),i=>Object.entries(e).map(([s,o])=>s+": "+Pr.formatIdlData({name:"",type:i[s]},o,r)).join(", "))+" }";case"enum":{const i=Object.keys(e)[0],s=t.type.variants.find(c=>c.name===i);if(!s)throw new Error(`Unable to find variant: ${i}`);const o=e[i];return Jc(s.fields,()=>i,c=>{const u=Object.keys(o).map(f=>{const h=o[f],y=c.find(A=>A.name===f);if(!y)throw new Error(`Field not found: ${f}`);return f+": "+Pr.formatIdlData(y,h,r)}).join(", ");return`${i} { ${u} }`},c=>{const u=Object.entries(o).map(([f,h])=>f+": "+Pr.formatIdlData({name:"",type:c[f]},h,r)).join(", ");return`${i} { ${u} }`})}case"type":return Pr.formatIdlType(t.type.alias)}}static flattenIdlAccounts(t,e){return t.map(r=>{const i=pG(r.name);if(r.hasOwnProperty("accounts")){const s=e?`${e} > ${i}`:i;return Pr.flattenIdlAccounts(r.accounts,s)}else return{...r,name:e?`${e} > ${i}`:i}}).flat()}}function pG(n){const t=n.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)}class gG{constructor(t){if(this.idl=t,!t.accounts){this.accountLayouts=new Map;return}const e=t.types;if(!e)throw new Error("Accounts require `idl.types`");const r=t.accounts.map(i=>{const s=e.find(o=>o.name===i.name);if(!s)throw new Error(`Account not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:fe.typeDefLayout({typeDef:s,types:e})}]});this.accountLayouts=new Map(r)}async encode(t,e){const r=It.alloc(1e3),i=this.accountLayouts.get(t);if(!i)throw new Error(`Unknown account: ${t}`);const s=i.layout.encode(e,r),o=r.slice(0,s),c=this.accountDiscriminator(t);return It.concat([c,o])}decode(t,e){const r=this.accountDiscriminator(t);if(r.compare(e.slice(0,r.length)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(t,e)}decodeAny(t){for(const[e,r]of this.accountLayouts)if(t.subarray(0,r.discriminator.length).equals(It.from(r.discriminator)))return this.decodeUnchecked(e,t);throw new Error("Account not found")}decodeUnchecked(t,e){const r=this.accountDiscriminator(t),i=e.subarray(r.length),s=this.accountLayouts.get(t);if(!s)throw new Error(`Unknown account: ${t}`);return s.layout.decode(i)}memcmp(t,e){const r=this.accountDiscriminator(t);return{offset:0,bytes:In.encode(e?It.concat([r,e]):r)}}size(t){return this.accountDiscriminator(t).length+fe.typeSize({defined:{name:t}},this.idl)}accountDiscriminator(t){var e;const r=(e=this.idl.accounts)===null||e===void 0?void 0:e.find(i=>i.name===t);if(!r)throw new Error(`Account not found: ${t}`);return It.from(r.discriminator)}}class yG{constructor(t){if(!t.events){this.layouts=new Map;return}const e=t.types;if(!e)throw new Error("Events require `idl.types`");const r=t.events.map(i=>{const s=e.find(o=>o.name===i.name);if(!s)throw new Error(`Event not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:fe.typeDefLayout({typeDef:s,types:e})}]});this.layouts=new Map(r)}decode(t){let e;try{e=YR(t)}catch{return null}for(const[r,i]of this.layouts){const s=e.subarray(0,i.discriminator.length);if(s.equals(It.from(i.discriminator)))return{name:r,data:i.layout.decode(e.subarray(s.length))}}return null}}class mG{constructor(t){const e=t.types;if(!e){this.typeLayouts=new Map;return}const r=e.filter(i=>!i.generics).map(i=>[i.name,fe.typeDefLayout({typeDef:i,types:e})]);this.typeLayouts=new Map(r)}encode(t,e){const r=It.alloc(1e3),i=this.typeLayouts.get(t);if(!i)throw new Error(`Unknown type: ${t}`);const s=i.encode(e,r);return r.slice(0,s)}decode(t,e){const r=this.typeLayouts.get(t);if(!r)throw new Error(`Unknown type: ${t}`);return r.decode(e)}}class kI{constructor(t){this.instruction=new dG(t),this.accounts=new gG(t),this.events=new yG(t),this.types=new mG(t)}}class Or{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}var Tp=Or;function wG(n,t){return t.property?n+"["+t.property+"]":n}class Ra extends Or{isCount(){throw new Error("ExternalLayout is abstract")}}class TI extends Ra{constructor(t,e,r){if(!(t instanceof Or))throw new TypeError("layout must be a Layout");if(e===void 0)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Op||this.layout instanceof OI}decode(t,e){return e===void 0&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return r===void 0&&(r=0),this.layout.encode(t,e,r+this.offset)}}class Op extends Or{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class OI extends Or{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}const nw=Math.pow(2,32);function NI(n){const t=Math.floor(n/nw),e=n-t*nw;return{hi32:t,lo32:e}}function CI(n,t){return n*nw+t}class bG extends Or{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readUInt32LE(e+4);return CI(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=NI(t);return e.writeUInt32LE(i.lo32,r),e.writeUInt32LE(i.hi32,r+4),8}}class _G extends Or{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readInt32LE(e+4);return CI(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=NI(t);return e.writeUInt32LE(i.lo32,r),e.writeInt32LE(i.hi32,r+4),8}}class AG extends Or{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Or,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e){e===void 0&&(e=0);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){r===void 0&&(r=0);const i=r;let s=0,o=0;for(const c of this.fields){let u=c.span;if(o=0<u?u:0,c.property!==void 0){const f=t[c.property];f!==void 0&&(o=c.encode(f,e,r),0>u&&(u=c.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class BI{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class kE extends BI{constructor(t,e){if(!(t instanceof Ra&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class PI extends Or{constructor(t,e,r){const i=t instanceof Op||t instanceof OI;if(i)t=new kE(new TI(t));else if(t instanceof Ra&&t.isCount())t=new kE(t);else if(!(t instanceof BI))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Or))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&i&&(s+=t.layout.span)),super(s,r),this.discriminator=t,this.usesPrefixDiscriminator=i,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(c){return o(c)},this.configGetSourceVariant=function(c){o=c.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){e===void 0&&(e=0);let r;const i=this.discriminator,s=i.decode(t,e);let o=this.registry[s];if(o===void 0){let c=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(c=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[o.property]=this.defaultLayout.decode(t,e+c)}else r=o.decode(t,e);return r}encode(t,e,r){r===void 0&&(r=0);const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let c=0;return this.usesPrefixDiscriminator&&(c=s.layout.span),s.encode(t[s.property],e,r),c+o.encode(t[o.property],e,r+c)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new EG(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e){let r=t;return Zt.isBuffer(t)&&(e===void 0&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class EG extends Or{constructor(t,e,r,i){if(!(t instanceof PI))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Or))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(e===void 0&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){r===void 0&&(r=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}class vG extends Or{constructor(t,e){if(!(t instanceof Ra&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Ra||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){e===void 0&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof Ra&&(i=t.length),!(Zt.isBuffer(t)&&i===t.length))throw new TypeError(wG("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,i,"hex"),this.length instanceof Ra&&this.length.encode(i,e,r),i}}var xG=(n,t,e)=>new TI(n,t,e),RG=n=>new Op(1,n),$s=n=>new Op(4,n),SG=n=>new bG(n),Ws=n=>new _G(n),On=(n,t,e)=>new AG(n,t,e),MI=(n,t,e)=>new PI(n,t,e),Xh=(n,t)=>new vG(n,t);class IG extends Tp{constructor(t){super(-1,t),this.property=t,this.layout=On([$s("length"),$s("lengthPadding"),Xh(xG($s(),-8),"chars")],this.property)}encode(t,e,r=0){if(t==null)return this.layout.span;const i={chars:Zt.from(t,"utf8")};return this.layout.encode(i,e,r)}decode(t,e=0){return this.layout.decode(t,e).chars.toString()}getSpan(t,e=0){return $s().span+$s().span+new Ls(new Uint8Array(t).slice(e,e+4),10,"le").toNumber()}}function Np(n){return new IG(n)}function ai(n){return Xh(32,n)}const jr=MI($s("instruction"));jr.addVariant(0,On([Ws("lamports"),Ws("space"),ai("owner")]),"createAccount");jr.addVariant(1,On([ai("owner")]),"assign");jr.addVariant(2,On([Ws("lamports")]),"transfer");jr.addVariant(3,On([ai("base"),Np("seed"),Ws("lamports"),Ws("space"),ai("owner")]),"createAccountWithSeed");jr.addVariant(4,On([ai("authorized")]),"advanceNonceAccount");jr.addVariant(5,On([Ws("lamports")]),"withdrawNonceAccount");jr.addVariant(6,On([ai("authorized")]),"initializeNonceAccount");jr.addVariant(7,On([ai("authorized")]),"authorizeNonceAccount");jr.addVariant(8,On([Ws("space")]),"allocate");jr.addVariant(9,On([ai("base"),Np("seed"),Ws("space"),ai("owner")]),"allocateWithSeed");jr.addVariant(10,On([ai("base"),Np("seed"),ai("owner")]),"assignWithSeed");jr.addVariant(11,On([Ws("lamports"),Np("seed"),ai("owner")]),"transferWithSeed");Math.max(...Object.values(jr.registry).map(n=>n.span));class kG extends Tp{constructor(t,e,r,i){super(t.span,i),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}function TE(n){return new kG(Xh(32),t=>new pt(t),t=>t.toBuffer(),n)}On([$s("version"),$s("state"),TE("authorizedPubkey"),TE("nonce"),On([SG("lamportsPerSignature")],"feeCalculator")]);new pt("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new pt("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var OE={exports:{}};(function(n,t){var e=typeof self<"u"?self:lG,r=function(){function s(){this.fetch=!1,this.DOMException=e.DOMException}return s.prototype=e,new s}();(function(s){(function(o){var c={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function u(p){return p&&DataView.prototype.isPrototypeOf(p)}if(c.arrayBuffer)var f=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(p){return p&&f.indexOf(Object.prototype.toString.call(p))>-1};function y(p){if(typeof p!="string"&&(p=String(p)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(p))throw new TypeError("Invalid character in header field name");return p.toLowerCase()}function A(p){return typeof p!="string"&&(p=String(p)),p}function b(p){var m={next:function(){var v=p.shift();return{done:v===void 0,value:v}}};return c.iterable&&(m[Symbol.iterator]=function(){return m}),m}function R(p){this.map={},p instanceof R?p.forEach(function(m,v){this.append(v,m)},this):Array.isArray(p)?p.forEach(function(m){this.append(m[0],m[1])},this):p&&Object.getOwnPropertyNames(p).forEach(function(m){this.append(m,p[m])},this)}R.prototype.append=function(p,m){p=y(p),m=A(m);var v=this.map[p];this.map[p]=v?v+", "+m:m},R.prototype.delete=function(p){delete this.map[y(p)]},R.prototype.get=function(p){return p=y(p),this.has(p)?this.map[p]:null},R.prototype.has=function(p){return this.map.hasOwnProperty(y(p))},R.prototype.set=function(p,m){this.map[y(p)]=A(m)},R.prototype.forEach=function(p,m){for(var v in this.map)this.map.hasOwnProperty(v)&&p.call(m,this.map[v],v,this)},R.prototype.keys=function(){var p=[];return this.forEach(function(m,v){p.push(v)}),b(p)},R.prototype.values=function(){var p=[];return this.forEach(function(m){p.push(m)}),b(p)},R.prototype.entries=function(){var p=[];return this.forEach(function(m,v){p.push([v,m])}),b(p)},c.iterable&&(R.prototype[Symbol.iterator]=R.prototype.entries);function k(p){if(p.bodyUsed)return Promise.reject(new TypeError("Already read"));p.bodyUsed=!0}function S(p){return new Promise(function(m,v){p.onload=function(){m(p.result)},p.onerror=function(){v(p.error)}})}function B(p){var m=new FileReader,v=S(m);return m.readAsArrayBuffer(p),v}function H(p){var m=new FileReader,v=S(m);return m.readAsText(p),v}function U(p){for(var m=new Uint8Array(p),v=new Array(m.length),I=0;I<m.length;I++)v[I]=String.fromCharCode(m[I]);return v.join("")}function G(p){if(p.slice)return p.slice(0);var m=new Uint8Array(p.byteLength);return m.set(new Uint8Array(p)),m.buffer}function W(){return this.bodyUsed=!1,this._initBody=function(p){this._bodyInit=p,p?typeof p=="string"?this._bodyText=p:c.blob&&Blob.prototype.isPrototypeOf(p)?this._bodyBlob=p:c.formData&&FormData.prototype.isPrototypeOf(p)?this._bodyFormData=p:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)?this._bodyText=p.toString():c.arrayBuffer&&c.blob&&u(p)?(this._bodyArrayBuffer=G(p.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(p)||h(p))?this._bodyArrayBuffer=G(p):this._bodyText=p=Object.prototype.toString.call(p):this._bodyText="",this.headers.get("content-type")||(typeof p=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var p=k(this);if(p)return p;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(){return this._bodyArrayBuffer?k(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var p=k(this);if(p)return p;if(this._bodyBlob)return H(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(U(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(it)}),this.json=function(){return this.text().then(JSON.parse)},this}var Y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function j(p){var m=p.toUpperCase();return Y.indexOf(m)>-1?m:p}function J(p,m){m=m||{};var v=m.body;if(p instanceof J){if(p.bodyUsed)throw new TypeError("Already read");this.url=p.url,this.credentials=p.credentials,m.headers||(this.headers=new R(p.headers)),this.method=p.method,this.mode=p.mode,this.signal=p.signal,!v&&p._bodyInit!=null&&(v=p._bodyInit,p.bodyUsed=!0)}else this.url=String(p);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new R(m.headers)),this.method=j(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&v)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(v)}J.prototype.clone=function(){return new J(this,{body:this._bodyInit})};function it(p){var m=new FormData;return p.trim().split("&").forEach(function(v){if(v){var I=v.split("="),N=I.shift().replace(/\+/g," "),M=I.join("=").replace(/\+/g," ");m.append(decodeURIComponent(N),decodeURIComponent(M))}}),m}function ut(p){var m=new R,v=p.replace(/\r?\n[\t ]+/g," ");return v.split(/\r?\n/).forEach(function(I){var N=I.split(":"),M=N.shift().trim();if(M){var z=N.join(":").trim();m.append(M,z)}}),m}W.call(J.prototype);function rt(p,m){m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in m?m.statusText:"OK",this.headers=new R(m.headers),this.url=m.url||"",this._initBody(p)}W.call(rt.prototype),rt.prototype.clone=function(){return new rt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new R(this.headers),url:this.url})},rt.error=function(){var p=new rt(null,{status:0,statusText:""});return p.type="error",p};var ot=[301,302,303,307,308];rt.redirect=function(p,m){if(ot.indexOf(m)===-1)throw new RangeError("Invalid status code");return new rt(null,{status:m,headers:{location:p}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,v){this.message=m,this.name=v;var I=Error(m);this.stack=I.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function C(p,m){return new Promise(function(v,I){var N=new J(p,m);if(N.signal&&N.signal.aborted)return I(new o.DOMException("Aborted","AbortError"));var M=new XMLHttpRequest;function z(){M.abort()}M.onload=function(){var P={status:M.status,statusText:M.statusText,headers:ut(M.getAllResponseHeaders()||"")};P.url="responseURL"in M?M.responseURL:P.headers.get("X-Request-URL");var _="response"in M?M.response:M.responseText;v(new rt(_,P))},M.onerror=function(){I(new TypeError("Network request failed"))},M.ontimeout=function(){I(new TypeError("Network request failed"))},M.onabort=function(){I(new o.DOMException("Aborted","AbortError"))},M.open(N.method,N.url,!0),N.credentials==="include"?M.withCredentials=!0:N.credentials==="omit"&&(M.withCredentials=!1),"responseType"in M&&c.blob&&(M.responseType="blob"),N.headers.forEach(function(P,_){M.setRequestHeader(_,P)}),N.signal&&(N.signal.addEventListener("abort",z),M.onreadystatechange=function(){M.readyState===4&&N.signal.removeEventListener("abort",z)}),M.send(typeof N._bodyInit>"u"?null:N._bodyInit)})}return C.polyfill=!0,s.fetch||(s.fetch=C,s.Headers=R,s.Request=J,s.Response=rt),o.Headers=R,o.Request=J,o.Response=rt,o.fetch=C,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var i=r;t=i.fetch,t.default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,n.exports=t})(OE,OE.exports);qt.rustEnum([qt.struct([],"uninitialized"),qt.struct([qt.option(qt.publicKey(),"authorityAddress")],"buffer"),qt.struct([qt.publicKey("programdataAddress")],"program"),qt.struct([qt.u64("slot"),qt.option(qt.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,qt.u32());const rw="Program log: ",LI="Program data: ",TG=rw.length,OG=LI.length;class NG{constructor(t,e,r){this._programId=t,this._provider=e,this._eventParser=new UI(t,r),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(t,e,r){var i;let s=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(t)||this._eventListeners.set(t,[]),this._eventListeners.set(t,((i=this._eventListeners.get(t))!==null&&i!==void 0?i:[]).concat(s)),this._eventCallbacks.set(s,[t,e]),this._onLogsSubscriptionId!==void 0||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,(o,c)=>{if(!o.err)for(const u of this._eventParser.parseLogs(o.logs)){const f=this._eventListeners.get(u.name);f&&f.forEach(h=>{const y=this._eventCallbacks.get(h);if(y){const[,A]=y;A(u.data,c.slot,o.signature)}})}},r)),s}async removeEventListener(t){const e=this._eventCallbacks.get(t);if(!e)throw new Error(`Event listener ${t} doesn't exist!`);const[r]=e;let i=this._eventListeners.get(r);if(!i)throw new Error(`Event listeners don't exist for ${r}!`);if(this._eventCallbacks.delete(t),i=i.filter(s=>s!==t),this._eventListeners.set(r,i),i.length===0&&this._eventListeners.delete(r),this._eventCallbacks.size===0){if(this._eventListeners.size!==0)throw new Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);this._onLogsSubscriptionId!==void 0&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}}class UI{constructor(t,e){this.coder=e,this.programId=t}*parseLogs(t,e=!1){const r=new BG(t),i=new CG;let s=r.next();for(;s!==null;){let[o,c,u]=this.handleLog(i,s,e);o&&(yield o),c&&i.push(c),u&&i.pop(),s=r.next()}}handleLog(t,e,r){return t.stack.length>0&&t.program()===this.programId.toString()?this.handleProgramLog(e,r):[null,...this.handleSystemLog(e)]}handleProgramLog(t,e){if(t.startsWith(rw)||t.startsWith(LI)){const r=t.startsWith(rw)?t.slice(TG):t.slice(OG),i=this.coder.events.decode(r);if(e&&i===null)throw new Error(`Unable to decode event ${r}`);return[i,null,!1]}else return[null,...this.handleSystemLog(t)]}handleSystemLog(t){const e=t.split(":")[0];return e.match(/^Program (.*) success/g)!==null?[null,!0]:e.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:e.includes("invoke")?["cpi",!1]:[null,!1]}}class CG{constructor(){this.stack=[]}program(){if(!this.stack.length)throw new Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(t){this.stack.push(t)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}}class BG{constructor(t){this.logs=t}next(){if(this.logs.length===0)return null;let t=this.logs[0];return this.logs=this.logs.slice(1),t}}function Cp(n,t){var e,r;let i={};const s=n.args?n.args.length:0;if(t.length>s){if(t.length!==s+1)throw new Error(`provided too many arguments ${t} to instruction ${n==null?void 0:n.name} expecting: ${(r=(e=n.args)===null||e===void 0?void 0:e.map(o=>o.name))!==null&&r!==void 0?r:[]}`);i=t.pop()}return[t,i]}class k0{static build(t,e,r){if(t.name==="_inner")throw new fo("the _inner name is reserved");const i=(...s)=>{const[o,c]=Cp(t,[...s]);XR(t.accounts,c.accounts),PG(t,...s);const u=i.accounts(c.accounts);return c.remainingAccounts!==void 0&&u.push(...c.remainingAccounts),SI("debug-logs")&&console.log("Outgoing account metas:",u),new Be({keys:u,programId:r,data:e(t.name,Wz(t,...o))})};return i.accounts=s=>k0.accountsArray(s,t.accounts,r,t.name),i}static accountsArray(t,e,r,i){return t?e.map(s=>{if(go(s)){const h=t[s.name];return k0.accountsArray(h,s.accounts,r,i).flat()}let o;try{o=bi(t[s.name])}catch{throw new Error(`Wrong input type for account "${s.name}" in the instruction accounts object${i!==void 0?' for instruction "'+i+'"':""}. Expected PublicKey or string.`)}const c=s.optional&&o.equals(r),u=!!(s.writable&&!c),f=!!(s.signer&&!c);return{pubkey:o,isWritable:u,isSigner:f}}).flat():[]}}function PG(n,...t){}class MG{static build(t,e){return(...i)=>{var s,o,c;const[,u]=Cp(t,[...i]),f=new Te;if(u.preInstructions&&u.instructions)throw new Error("instructions is deprecated, use preInstructions");return(s=u.preInstructions)===null||s===void 0||s.forEach(h=>f.add(h)),(o=u.instructions)===null||o===void 0||o.forEach(h=>f.add(h)),f.add(e(...i)),(c=u.postInstructions)===null||c===void 0||c.forEach(h=>f.add(h)),f}}}class LG{static build(t,e,r,i){return async(...o)=>{var c;const u=e(...o),[,f]=Cp(t,[...o]);if(i.sendAndConfirm===void 0)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await i.sendAndConfirm(u,(c=f.signers)!==null&&c!==void 0?c:[],f.options)}catch(h){throw II(h,r)}}}}class UG{static build(t,e,r,i){var s;return((s=t.accounts)!==null&&s!==void 0?s:[]).reduce((o,c)=>(o[c.name]=new DG(t,c,r,i,e),o),{})}}class DG{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}constructor(t,e,r,i,s){this._idlAccount=e,this._programId=r,this._provider=i??ew(),this._coder=s??new kI(t),this._size=this._coder.accounts.size(e.name)}async fetchNullable(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);return r}async fetchNullableAndContext(t,e){const r=await this.getAccountInfoAndContext(t,e),{value:i,context:s}=r;return{data:i&&i.data.length!==0?this._coder.accounts.decode(this._idlAccount.name,i.data):null,context:s}}async fetch(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);if(r===null)throw new Error(`Account does not exist or has no data ${t.toString()}`);return r}async fetchAndContext(t,e){const{data:r,context:i}=await this.fetchNullableAndContext(t,e);if(r===null)throw new Error(`Account does not exist ${t.toString()}`);return{data:r,context:i}}async fetchMultiple(t,e){return(await this.fetchMultipleAndContext(t,e)).map(i=>i?i.data:null)}async fetchMultipleAndContext(t,e){return(await rG(this._provider.connection,t.map(i=>bi(i)),e)).map(i=>{if(i==null)return null;const{account:s,context:o}=i;return{data:this._coder.accounts.decode(this._idlAccount.name,s.data),context:o}})}async all(t){const e=this.coder.accounts.memcmp(this._idlAccount.name,t instanceof Zt?t:void 0),r=[];return(e==null?void 0:e.offset)!=null&&(e==null?void 0:e.bytes)!=null&&r.push({memcmp:{offset:e.offset,bytes:e.bytes}}),(e==null?void 0:e.dataSize)!=null&&r.push({dataSize:e.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...r,...Array.isArray(t)?t:[]]})).map(({pubkey:s,account:o})=>({publicKey:s,account:this._coder.accounts.decode(this._idlAccount.name,o.data)}))}subscribe(t,e){const r=wf.get(t.toString());if(r)return r.ee;const i=new Dz;t=bi(t);const s=this._provider.connection.onAccountChange(t,o=>{const c=this._coder.accounts.decode(this._idlAccount.name,o.data);i.emit("change",c)},e);return wf.set(t.toString(),{ee:i,listener:s}),i}async unsubscribe(t){let e=wf.get(t.toString());if(!e){console.warn("Address is not subscribed");return}wf&&await this._provider.connection.removeAccountChangeListener(e.listener).then(()=>{wf.delete(t.toString())}).catch(console.error)}async createInstruction(t,e){const r=this.size;if(this._provider.publicKey===void 0)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return Tn.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:t.publicKey,space:e??r,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(e??r),programId:this._programId})}async getAccountInfo(t,e){return await this._provider.connection.getAccountInfo(bi(t),e)}async getAccountInfoAndContext(t,e){return await this._provider.connection.getAccountInfoAndContext(bi(t),e)}}const wf=new Map;class FG{static build(t,e,r,i,s,o,c){return async(...f)=>{var h;const y=e(...f),[,A]=Cp(t,[...f]);let b;if(i.simulate===void 0)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{b=await i.simulate(y,A.signers,(h=A.options)===null||h===void 0?void 0:h.commitment)}catch(S){throw II(S,r)}if(b===void 0)throw new Error("Unable to simulate transaction");const R=b.logs;if(!R)throw new Error("Simulated logs not found");const k=[];if(c.events){let S=new UI(o,s);for(const B of S.parseLogs(R))k.push(B)}return{events:k,raw:R}}}}function Xy(n){return new DI(Xh(8),t=>HG.fromBuffer(t),t=>t.toBuffer(),n)}function Bd(n){return new DI(Xh(32),t=>new pt(t),t=>t.toBuffer(),n)}function tm(n,t){return new $G(n,t)}class DI extends Tp{constructor(t,e,r,i){super(t.span,i),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}class $G extends Tp{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=$s()}encode(t,e,r=0){return t==null?this.layout.span+this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+4)+4)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(r===0)return null;if(r===1)return this.layout.decode(t,e+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(t,e=0){return this.layout.getSpan(t,e+4)+4}}let HG=class FI extends Ls{toBuffer(){const t=super.toArray().reverse(),e=Zt.from(t);if(e.length===8)return e;if(e.length>=8)throw new Error("u64 too large");const r=Zt.alloc(8);return e.copy(r),r}static fromBuffer(t){if(t.length!==8)throw new Error(`Invalid buffer length: ${t.length}`);return new FI([...t].reverse().map(e=>`00${e.toString(16)}`.slice(-2)).join(""),16)}};const zG=On([Bd("mint"),Bd("owner"),Xy("amount"),tm(Bd(),"delegate"),(n=>{const t=MI(RG("discriminator"),null,n);return t.addVariant(0,On([]),"uninitialized"),t.addVariant(1,On([]),"initialized"),t.addVariant(2,On([]),"frozen"),t})("state"),tm(Xy(),"isNative"),Xy("delegatedAmount"),tm(Bd(),"closeAuthority")]);function GG(n){return zG.decode(n)}class VG{constructor(t,e,r,i,s,o,c,u){this._args=t,this._accounts=e,this._provider=r,this._programId=i,this._idlIx=s,this._idlTypes=c,this._customResolver=u,this._accountStore=new KG(r,o,i)}args(t){this._args=t}async resolve(){this.resolveEventCpi(this._idlIx.accounts),this.resolveConst(this._idlIx.accounts);let t=0;for(;await this.resolvePdasAndRelations(this._idlIx.accounts)+await this.resolveCustom()>0;)if(t++,t===16){const e=o=>go(o)?o.accounts.some(e):!!(o.address||o.pda||o.relations),r=(o,c=[],u=[])=>{for(const f of o)go(f)?u.push(...r(f.accounts,[...c,f.name])):u.push([...c,f.name]);return u},i=this._idlIx.accounts.filter(e),s=r(i).filter(o=>!this.get(o)).map(o=>o.reduce((c,u)=>c+"."+u)).map(o=>`\`${o}\``).join(", ");throw new Error(["Reached maximum depth for account resolution.",`Unresolved accounts: ${s}`].join(" "))}}resolveOptionals(t){Object.assign(this._accounts,this.resolveOptionalsHelper(t,this._idlIx.accounts))}get(t){const e=t.reduce((r,i)=>r&&r[i],this._accounts);if(e&&e.toBase58)return e}set(t,e){let r=this._accounts;t.forEach((i,s)=>{var o;s===t.length-1&&(r[i]=e),r[i]=(o=r[i])!==null&&o!==void 0?o:{},r=r[i]})}resolveOptionalsHelper(t,e){const r={};for(const i of e){const s=i.name,o=t[s];o!==void 0&&($I(o)?go(i)?r[s]=this.resolveOptionalsHelper(o,i.accounts):r[s]=HI(o):o!==null?r[s]=bi(o):i.optional&&(r[s]=this._programId))}return r}async resolveCustom(){if(this._customResolver){const{accounts:t,resolved:e}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=t,e}return 0}resolveEventCpi(t,e=[]){for(const r in t){const i=t[r];go(i)&&this.resolveEventCpi(i.accounts,[...e,i.name]);const s=+r+1;if(s===t.length)return;const o=t[r].name,c=t[s].name;if(o==="eventAuthority"&&c==="program"){const u=[...e,o],f=[...e,c];this.get(u)||this.set(u,pt.findProgramAddressSync([Zt.from("__event_authority")],this._programId)[0]),this.get(f)||this.set(f,this._programId);return}}}resolveConst(t,e=[]){for(const r of t){const i=r.name;if(go(r))this.resolveConst(r.accounts,[...e,i]);else{const s=r;if((s.signer||s.address)&&!this.get([...e,i])){if(s.signer){if(!this._provider.wallet)throw new Error("This function requires the `Provider` interface implementor to have a `wallet` field.");this.set([...e,i],this._provider.wallet.publicKey)}s.address&&this.set([...e,i],bi(s.address))}}}}async resolvePdasAndRelations(t,e=[]){let r=0;for(const i of t){const s=i.name;if(go(i))r+=await this.resolvePdasAndRelations(i.accounts,[...e,s]);else{const o=i;if((o.pda||o.relations)&&!this.get([...e,s])){r++;try{if(o.pda){const c=await Promise.all(o.pda.seeds.map(h=>this.toBuffer(h,e)));if(c.some(h=>!h))continue;const u=await this.parseProgramId(o,e),[f]=pt.findProgramAddressSync(c,u);this.set([...e,s],f)}}catch{}try{if(o.relations){const c=this.get([...e,o.relations[0]]);if(c){const u=await this._accountStore.fetchAccount({publicKey:c});this.set([...e,s],u[s])}}}catch{}}}}return r}async parseProgramId(t,e=[]){var r;if(!(!((r=t.pda)===null||r===void 0)&&r.program))return this._programId;const i=await this.toBuffer(t.pda.program,e);if(!i)throw new Error(`Program seed not resolved: ${t.name}`);return new pt(i)}async toBuffer(t,e=[]){switch(t.kind){case"const":return this.toBufferConst(t);case"arg":return await this.toBufferArg(t);case"account":return await this.toBufferAccount(t,e);default:throw new Error(`Unexpected seed: ${t}`)}}toBufferConst(t){return this.toBufferValue("bytes",t.value)}async toBufferArg(t){const[e,...r]=t.path.split("."),i=this._idlIx.args.findIndex(c=>c.name===e);if(i===-1)throw new Error(`Unable to find argument for seed: ${e}`);const s=r.reduce((c,u)=>(c??{})[u],this._args[i]);if(s===void 0)return;const o=this.getType(this._idlIx.args[i].type,r);return this.toBufferValue(o,s)}async toBufferAccount(t,e=[]){const[r,...i]=t.path.split("."),s=this.get([...e,r]);if(!s)return;if(!i.length)return this.toBufferValue("pubkey",s);if(!t.account)throw new Error(`Seed account is required in order to resolve type: ${t.path}`);let c=await this._accountStore.fetchAccount({publicKey:s,name:t.account}),u=i;for(;u.length>0;)c=c[u[0]],u=u.slice(1);if(c===void 0)return;const f=this.getType({defined:{name:t.account}},i);return this.toBufferValue(f,c)}toBufferValue(t,e){switch(t){case"u8":case"i8":return Zt.from([e]);case"u16":case"i16":return new Ls(e).toArrayLike(Zt,"le",2);case"u32":case"i32":return new Ls(e).toArrayLike(Zt,"le",4);case"u64":case"i64":return new Ls(e).toArrayLike(Zt,"le",8);case"u128":case"i128":return new Ls(e).toArrayLike(Zt,"le",16);case"u256":case"i256":return new Ls(e).toArrayLike(Zt,"le",32);case"string":return Zt.from(e);case"pubkey":return e.toBuffer();case"bytes":return Zt.from(e);default:if(t!=null&&t.array)return Zt.from(e);throw new Error(`Unexpected seed type: ${t}`)}}getType(t,e=[]){var r;const i=(r=t==null?void 0:t.defined)===null||r===void 0?void 0:r.name;if(i){if(i==="tokenAccount")switch(e.at(0)){case"mint":case"owner":return"pubkey";case"amount":case"delagatedAmount":return"u64";default:throw new Error(`Unknown token account path: ${e}`)}const s=this._idlTypes.find(h=>h.name===i);if(!s)throw new Error(`Type not found: ${i}`);const[o,...c]=e,f=s.type.fields.find(h=>h.name===o);if(!f)throw new Error(`Field not found: ${o}`);return this.getType(f.type,c)}return t}}class KG{constructor(t,e,r){this._provider=t,this._cache=new Map,this._idls={},this._idls[r.toBase58()]=e}async fetchAccount({publicKey:t,name:e}){const r=t.toBase58();if(!this._cache.has(r)){const i=await this._provider.connection.getAccountInfo(t);if(i===null)throw new Error(`Account not found: ${r}`);if(e==="tokenAccount"){const s=GG(i.data);this._cache.set(r,s)}else{const s=await this.getAccountsNs(i.owner);if(s){const o=Object.values(s)[0];if(o){const c=o.coder.accounts.decodeAny(i.data);this._cache.set(r,c)}}}}return this._cache.get(r)}async getAccountsNs(t){const e=t.toBase58();if(!this._idls[e]){const r=await hl.fetchIdl(t,this._provider);if(r){const i=new hl(r,this._provider);this._idls[e]=i.account}}return this._idls[e]}}class jG{static build(t,e,r,i,s,o,c,u,f,h,y){return(...A)=>new WG(A,i,s,o,c,u,t,e,r,f,h,y)}}function $I(n){return typeof n=="object"&&n!==null&&!("_bn"in n)}function HI(n,t){const e={};for(const r in n){const i=n[r];if(i===null)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!");e[r]=$I(i)?HI(i):bi(i)}return e}class WG{constructor(t,e,r,i,s,o,c,u,f,h,y,A){this._args=t,this._ixFn=e,this._txFn=r,this._rpcFn=i,this._simulateFn=s,this._viewFn=o,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._resolveAccounts=!0,this._accountsResolver=new VG(t,this._accounts,c,u,f,h,y,A)}args(t){this._args=t,this._accountsResolver.args(t)}accounts(t){return this.accountsPartial(t)}accountsPartial(t){return this._resolveAccounts=!0,this._accountsResolver.resolveOptionals(t),this}accountsStrict(t){return this._resolveAccounts=!1,this._accountsResolver.resolveOptionals(t),this}signers(t){return this._signers=this._signers.concat(t),this}remainingAccounts(t){return this._remainingAccounts=this._remainingAccounts.concat(t),this}preInstructions(t,e=!1){return e?this._preInstructions=t.concat(this._preInstructions):this._preInstructions=this._preInstructions.concat(t),this}postInstructions(t){return this._postInstructions=this._postInstructions.concat(t),this}async pubkeys(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._accounts}async instruction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async transaction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async simulate(t){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async view(t){if(this._resolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw new Error(["Method does not support views.","The instruction should return a value, and its accounts must be read-only"].join(" "));return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpc(t){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpcAndKeys(t){return{signature:await this.rpc(t),pubkeys:await this.pubkeys()}}async prepare(){return{instruction:await this.instruction(),signers:this._signers,pubkeys:await this.pubkeys()}}}class ZG{static build(t,e,r,i){const s=e.accounts.find(u=>u.writable),o=!!e.returns;return s||!o?void 0:async(...u)=>{let f=await r(...u);const h=`Program return: ${t} `;let y=f.raw.find(k=>k.startsWith(h));if(!y)throw new Error("View expected return log");let A=YR(y.slice(h.length)),b=e.returns;if(!b)throw new Error("View expected return type");return fe.fieldLayout({type:b},i.types).decode(A)}}}class qG{static build(t,e,r,i,s){const o={},c={},u={},f={},h={},y={},A=jz(t),b=t.accounts?UG.build(t,e,r,i):{};return t.instructions.forEach(R=>{const k=k0.build(R,(Y,j)=>e.instruction.encode(Y,j),r),S=MG.build(R,k),B=LG.build(R,S,A,i),H=FG.build(R,S,A,i,e,r,t),U=ZG.build(r,R,H,t),G=jG.build(i,r,R,k,S,B,H,U,b,t.types||[],s==null?void 0:s(R)),W=R.name;c[W]=k,u[W]=S,o[W]=B,f[W]=H,h[W]=G,U&&(y[W]=U)}),[o,c,u,b,f,h,y]}}class hl{get programId(){return this._programId}get idl(){return this._idl}get rawIdl(){return this._rawIdl}get coder(){return this._coder}get provider(){return this._provider}constructor(t,e=ew(),r,i){this._idl=Kz(t),this._rawIdl=t,this._provider=e,this._programId=bi(t.address),this._coder=r??new kI(this._idl),this._events=new NG(this._programId,e,this._coder);const[s,o,c,u,f,h,y]=qG.build(this._idl,this._coder,this._programId,e,i);this.rpc=s,this.instruction=o,this.transaction=c,this.account=u,this.simulate=f,this.methods=h,this.views=y}static async at(t,e){const r=bi(t),i=await hl.fetchIdl(r,e);if(!i)throw new Error(`IDL not found for program: ${t.toString()}`);return new hl(i,e)}static async fetchIdl(t,e){e=e??ew();const r=bi(t),i=await Hz(r),s=await e.connection.getAccountInfo(i);if(!s)return null;let o=Vz(s.data.slice(8));const c=Lz(o.data);return JSON.parse($z(c))}addEventListener(t,e,r){return this._events.addEventListener(t,e,r)}async removeEventListener(t){return await this._events.removeEventListener(t)}}new pt("11111111111111111111111111111111");const QG="6.13.5";function JG(n,t,e){const r=t.split("|").map(s=>s.trim());for(let s=0;s<r.length;s++)switch(t){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===t)return}const i=new Error(`invalid value for type ${t}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${e}`,i.value=n,i}async function lr(n){const t=Object.keys(n);return(await Promise.all(t.map(r=>Promise.resolve(n[r])))).reduce((r,i,s)=>(r[t[s]]=i,r),{})}function $t(n,t,e){for(let r in t){let i=t[r];const s=e?e[r]:null;s&&JG(i,s,r),Object.defineProperty(n,r,{enumerable:!0,value:i,writable:!1})}}function Yc(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Yc).join(", ")+" ]";if(n instanceof Uint8Array){const t="0123456789abcdef";let e="0x";for(let r=0;r<n.length;r++)e+=t[n[r]>>4],e+=t[n[r]&15];return e}if(typeof n=="object"&&typeof n.toJSON=="function")return Yc(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const t=Object.keys(n);return t.sort(),"{ "+t.map(e=>`${Yc(e)}: ${Yc(n[e])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Wn(n,t){return n&&n.code===t}function $1(n){return Wn(n,"CALL_EXCEPTION")}function Ze(n,t,e){let r=n;{const s=[];if(e){if("message"in e||"code"in e||"name"in e)throw new Error(`value will overwrite populated values: ${Yc(e)}`);for(const o in e){if(o==="shortMessage")continue;const c=e[o];s.push(o+"="+Yc(c))}}s.push(`code=${t}`),s.push(`version=${QG}`),s.length&&(n+=" ("+s.join(", ")+")")}let i;switch(t){case"INVALID_ARGUMENT":i=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(n);break;default:i=new Error(n)}return $t(i,{code:t}),e&&Object.assign(i,e),i.shortMessage==null&&$t(i,{shortMessage:r}),i}function ht(n,t,e,r){if(!n)throw Ze(t,e,r)}function K(n,t,e,r){ht(n,t,"INVALID_ARGUMENT",{argument:e,value:r})}function zI(n,t,e){e==null&&(e=""),e&&(e=": "+e),ht(n>=t,"missing argument"+e,"MISSING_ARGUMENT",{count:n,expectedCount:t}),ht(n<=t,"too many arguments"+e,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:t})}["NFD","NFC","NFKD","NFKC"].reduce((n,t)=>{try{if("test".normalize(t)!=="test")throw new Error("bad");if(t==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");n.push(t)}catch{}return n},[]);function Bp(n,t,e){if(e==null&&(e=""),n!==t){let r=e,i="new";e&&(r+=".",i+=" "+e),ht(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function GI(n,t,e){if(n instanceof Uint8Array)return e?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let i=2;for(let s=0;s<r.length;s++)r[s]=parseInt(n.substring(i,i+2),16),i+=2;return r}K(!1,"invalid BytesLike value",t||"value",n)}function ye(n,t){return GI(n,t,!1)}function fr(n,t){return GI(n,t,!0)}function He(n,t){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof t=="number"&&n.length!==2+2*t||t===!0&&n.length%2!==0)}function H1(n){return He(n,!0)||n instanceof Uint8Array}const NE="0123456789abcdef";function kt(n){const t=ye(n);let e="0x";for(let r=0;r<t.length;r++){const i=t[r];e+=NE[(i&240)>>4]+NE[i&15]}return e}function Rn(n){return"0x"+n.map(t=>kt(t).substring(2)).join("")}function uu(n){return He(n,!0)?(n.length-2)/2:ye(n).length}function bn(n,t,e){const r=ye(n);return e!=null&&e>r.length&&ht(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:e}),kt(r.slice(t??0,e??r.length))}function VI(n,t,e){const r=ye(n);ht(t>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:t,offset:t+1});const i=new Uint8Array(t);return i.fill(0),e?i.set(r,t-r.length):i.set(r,0),kt(i)}function dc(n,t){return VI(n,t,!0)}function YG(n,t){return VI(n,t,!1)}const Pp=BigInt(0),mi=BigInt(1),Xc=9007199254740991;function XG(n,t){const e=Mp(n,"value"),r=BigInt(oe(t,"width"));if(ht(e>>r===Pp,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),e>>r-mi){const i=(mi<<r)-mi;return-((~e&i)+mi)}return e}function KI(n,t){let e=Nt(n,"value");const r=BigInt(oe(t,"width")),i=mi<<r-mi;if(e<Pp){e=-e,ht(e<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const s=(mi<<r)-mi;return(~e&s)+mi}else ht(e<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return e}function Rf(n,t){const e=Mp(n,"value"),r=BigInt(oe(t,"bits"));return e&(mi<<r)-mi}function Nt(n,t){switch(typeof n){case"bigint":return n;case"number":return K(Number.isInteger(n),"underflow",t||"value",n),K(n>=-Xc&&n<=Xc,"overflow",t||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(e){K(!1,`invalid BigNumberish string: ${e.message}`,t||"value",n)}}K(!1,"invalid BigNumberish value",t||"value",n)}function Mp(n,t){const e=Nt(n,t);return ht(e>=Pp,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),e}const CE="0123456789abcdef";function z1(n){if(n instanceof Uint8Array){let t="0x0";for(const e of n)t+=CE[e>>4],t+=CE[e&15];return BigInt(t)}return Nt(n)}function oe(n,t){switch(typeof n){case"bigint":return K(n>=-Xc&&n<=Xc,"overflow",t||"value",n),Number(n);case"number":return K(Number.isInteger(n),"underflow",t||"value",n),K(n>=-Xc&&n<=Xc,"overflow",t||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return oe(BigInt(n),t)}catch(e){K(!1,`invalid numeric string: ${e.message}`,t||"value",n)}}K(!1,"invalid numeric value",t||"value",n)}function tV(n){return oe(z1(n))}function Xo(n,t){let r=Mp(n,"value").toString(16);if(t==null)r.length%2&&(r="0"+r);else{const i=oe(t,"width");for(ht(i*2>=r.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<i*2;)r="0"+r}return"0x"+r}function pr(n){const t=Mp(n,"value");if(t===Pp)return new Uint8Array([]);let e=t.toString(16);e.length%2&&(e="0"+e);const r=new Uint8Array(e.length/2);for(let i=0;i<r.length;i++){const s=i*2;r[i]=parseInt(e.substring(s,s+2),16)}return r}function tu(n){let t=kt(H1(n)?n:pr(n)).substring(2);for(;t.startsWith("0");)t=t.substring(1);return t===""&&(t="0"),"0x"+t}const BE="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const PE=BigInt(58);function eV(n){const t=ye(n);let e=z1(t),r="";for(;e;)r=BE[Number(e%PE)]+r,e/=PE;for(let i=0;i<t.length&&!t[i];i++)r=BE[0]+r;return r}function nV(n){n=atob(n);const t=new Uint8Array(n.length);for(let e=0;e<n.length;e++)t[e]=n.charCodeAt(e);return ye(t)}function rV(n){const t=ye(n);let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}var du;class jI{constructor(t,e,r){Z(this,"filter");Z(this,"emitter");nt(this,du);$(this,du,e),$t(this,{emitter:t,filter:r})}async removeListener(){T(this,du)!=null&&await this.emitter.off(this.filter,T(this,du))}}du=new WeakMap;function iV(n,t,e,r,i){K(!1,`invalid codepoint at offset ${t}; ${n}`,"bytes",e)}function WI(n,t,e,r,i){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let s=0;for(let o=t+1;o<e.length&&e[o]>>6===2;o++)s++;return s}return n==="OVERRUN"?e.length-t-1:0}function sV(n,t,e,r,i){return n==="OVERLONG"?(K(typeof i=="number","invalid bad code point for replacement","badCodepoint",i),r.push(i),0):(r.push(65533),WI(n,t,e))}const oV=Object.freeze({error:iV,ignore:WI,replace:sV});function aV(n,t){t==null&&(t=oV.error);const e=ye(n,"bytes"),r=[];let i=0;for(;i<e.length;){const s=e[i++];if(!(s>>7)){r.push(s);continue}let o=null,c=null;if((s&224)===192)o=1,c=127;else if((s&240)===224)o=2,c=2047;else if((s&248)===240)o=3,c=65535;else{(s&192)===128?i+=t("UNEXPECTED_CONTINUE",i-1,e,r):i+=t("BAD_PREFIX",i-1,e,r);continue}if(i-1+o>=e.length){i+=t("OVERRUN",i-1,e,r);continue}let u=s&(1<<8-o-1)-1;for(let f=0;f<o;f++){let h=e[i];if((h&192)!=128){i+=t("MISSING_CONTINUE",i,e,r),u=null;break}u=u<<6|h&63,i++}if(u!==null){if(u>1114111){i+=t("OUT_OF_RANGE",i-1-o,e,r,u);continue}if(u>=55296&&u<=57343){i+=t("UTF16_SURROGATE",i-1-o,e,r,u);continue}if(u<=c){i+=t("OVERLONG",i-1-o,e,r,u);continue}r.push(u)}}return r}function Vs(n,t){K(typeof n=="string","invalid string value","str",n);let e=[];for(let r=0;r<n.length;r++){const i=n.charCodeAt(r);if(i<128)e.push(i);else if(i<2048)e.push(i>>6|192),e.push(i&63|128);else if((i&64512)==55296){r++;const s=n.charCodeAt(r);K(r<n.length&&(s&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((i&1023)<<10)+(s&1023);e.push(o>>18|240),e.push(o>>12&63|128),e.push(o>>6&63|128),e.push(o&63|128)}else e.push(i>>12|224),e.push(i>>6&63|128),e.push(i&63|128)}return new Uint8Array(e)}function cV(n){return n.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function T0(n,t){return cV(aV(n,t))}function ZI(n){async function t(e,r){ht(r==null||!r.cancelled,"request cancelled before sending","CANCELLED");const i=e.url.split(":")[0].toLowerCase();ht(i==="http"||i==="https",`unsupported protocol ${i}`,"UNSUPPORTED_OPERATION",{info:{protocol:i},operation:"request"}),ht(i==="https"||!e.credentials||e.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let s=null;const o=new AbortController,c=setTimeout(()=>{s=Ze("request timeout","TIMEOUT"),o.abort()},e.timeout);r&&r.addListener(()=>{s=Ze("request cancelled","CANCELLED"),o.abort()});const u={method:e.method,headers:new Headers(Array.from(e)),body:e.body||void 0,signal:o.signal};let f;try{f=await fetch(e.url,u)}catch(b){throw clearTimeout(c),s||b}clearTimeout(c);const h={};f.headers.forEach((b,R)=>{h[R.toLowerCase()]=b});const y=await f.arrayBuffer(),A=y==null?null:new Uint8Array(y);return{statusCode:f.status,statusMessage:f.statusText,headers:h,body:A}}return t}const uV=12,lV=250;let ME=ZI();const fV=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),hV=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let em=!1;async function qI(n,t){try{const e=n.match(fV);if(!e)throw new Error("invalid data");return new jo(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?nV(e[3]):pV(e[3]))}catch{return new jo(599,"BAD REQUEST (invalid data: URI)",{},null,new Zs(n))}}function QI(n){async function t(e,r){try{const i=e.match(hV);if(!i)throw new Error("invalid link");return new Zs(`${n}${i[2]}`)}catch{return new jo(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Zs(e))}}return t}const Pd={data:qI,ipfs:QI("https://gateway.ipfs.io/ipfs/")},JI=new WeakMap;var Ta,mo;class dV{constructor(t){nt(this,Ta);nt(this,mo);$(this,Ta,[]),$(this,mo,!1),JI.set(t,()=>{if(!T(this,mo)){$(this,mo,!0);for(const e of T(this,Ta))setTimeout(()=>{e()},0);$(this,Ta,[])}})}addListener(t){ht(!T(this,mo),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),T(this,Ta).push(t)}get cancelled(){return T(this,mo)}checkSignal(){ht(!this.cancelled,"cancelled","CANCELLED",{})}}Ta=new WeakMap,mo=new WeakMap;function Md(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}var pu,gu,hi,xs,yu,mu,Bn,Ur,Rs,Oa,Na,Ca,Bi,di,wo,Ba,Sf;const z0=class z0{constructor(t){nt(this,Ba);nt(this,pu);nt(this,gu);nt(this,hi);nt(this,xs);nt(this,yu);nt(this,mu);nt(this,Bn);nt(this,Ur);nt(this,Rs);nt(this,Oa);nt(this,Na);nt(this,Ca);nt(this,Bi);nt(this,di);nt(this,wo);$(this,mu,String(t)),$(this,pu,!1),$(this,gu,!0),$(this,hi,{}),$(this,xs,""),$(this,yu,3e5),$(this,di,{slotInterval:lV,maxAttempts:uV}),$(this,wo,null)}get url(){return T(this,mu)}set url(t){$(this,mu,String(t))}get body(){return T(this,Bn)==null?null:new Uint8Array(T(this,Bn))}set body(t){if(t==null)$(this,Bn,void 0),$(this,Ur,void 0);else if(typeof t=="string")$(this,Bn,Vs(t)),$(this,Ur,"text/plain");else if(t instanceof Uint8Array)$(this,Bn,t),$(this,Ur,"application/octet-stream");else if(typeof t=="object")$(this,Bn,Vs(JSON.stringify(t))),$(this,Ur,"application/json");else throw new Error("invalid body")}hasBody(){return T(this,Bn)!=null}get method(){return T(this,xs)?T(this,xs):this.hasBody()?"POST":"GET"}set method(t){t==null&&(t=""),$(this,xs,String(t).toUpperCase())}get headers(){const t=Object.assign({},T(this,hi));return T(this,Rs)&&(t.authorization=`Basic ${rV(Vs(T(this,Rs)))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),t["content-type"]==null&&T(this,Ur)&&(t["content-type"]=T(this,Ur)),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){T(this,hi)[String(t).toLowerCase()]=String(e)}clearHeaders(){$(this,hi,{})}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const i=e[r++];return{value:[i,t[i]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return T(this,Rs)||null}setCredentials(t,e){K(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),$(this,Rs,`${t}:${e}`)}get allowGzip(){return T(this,gu)}set allowGzip(t){$(this,gu,!!t)}get allowInsecureAuthentication(){return!!T(this,pu)}set allowInsecureAuthentication(t){$(this,pu,!!t)}get timeout(){return T(this,yu)}set timeout(t){K(t>=0,"timeout must be non-zero","timeout",t),$(this,yu,t)}get preflightFunc(){return T(this,Oa)||null}set preflightFunc(t){$(this,Oa,t)}get processFunc(){return T(this,Na)||null}set processFunc(t){$(this,Na,t)}get retryFunc(){return T(this,Ca)||null}set retryFunc(t){$(this,Ca,t)}get getUrlFunc(){return T(this,wo)||ME}set getUrlFunc(t){$(this,wo,t)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${T(this,Bn)?kt(T(this,Bn)):"null"}>`}setThrottleParams(t){t.slotInterval!=null&&(T(this,di).slotInterval=t.slotInterval),t.maxAttempts!=null&&(T(this,di).maxAttempts=t.maxAttempts)}send(){return ht(T(this,Bi)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),$(this,Bi,new dV(this)),_t(this,Ba,Sf).call(this,0,LE()+this.timeout,0,this,new jo(0,"",{},null,this))}cancel(){ht(T(this,Bi)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=JI.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(t){const e=this.url.split(":")[0].toLowerCase(),r=t.split(":")[0].toLowerCase();ht(this.method==="GET"&&(e!=="https"||r!=="http")&&t.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});const i=new z0(t);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,$(i,hi,Object.assign({},T(this,hi))),T(this,Bn)&&$(i,Bn,new Uint8Array(T(this,Bn))),$(i,Ur,T(this,Ur)),i}clone(){const t=new z0(this.url);return $(t,xs,T(this,xs)),T(this,Bn)&&$(t,Bn,T(this,Bn)),$(t,Ur,T(this,Ur)),$(t,hi,Object.assign({},T(this,hi))),$(t,Rs,T(this,Rs)),this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),$(t,Oa,T(this,Oa)),$(t,Na,T(this,Na)),$(t,Ca,T(this,Ca)),$(t,di,Object.assign({},T(this,di))),$(t,wo,T(this,wo)),t}static lockConfig(){em=!0}static getGateway(t){return Pd[t.toLowerCase()]||null}static registerGateway(t,e){if(t=t.toLowerCase(),t==="http"||t==="https")throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(em)throw new Error("gateways locked");Pd[t]=e}static registerGetUrl(t){if(em)throw new Error("gateways locked");ME=t}static createGetUrlFunc(t){return ZI()}static createDataGateway(){return qI}static createIpfsGatewayFunc(t){return QI(t)}};pu=new WeakMap,gu=new WeakMap,hi=new WeakMap,xs=new WeakMap,yu=new WeakMap,mu=new WeakMap,Bn=new WeakMap,Ur=new WeakMap,Rs=new WeakMap,Oa=new WeakMap,Na=new WeakMap,Ca=new WeakMap,Bi=new WeakMap,di=new WeakMap,wo=new WeakMap,Ba=new WeakSet,Sf=async function(t,e,r,i,s){var h,y,A;if(t>=T(this,di).maxAttempts)return s.makeServerError("exceeded maximum retry limit");ht(LE()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:i}),r>0&&await gV(r);let o=this.clone();const c=(o.url.split(":")[0]||"").toLowerCase();if(c in Pd){const b=await Pd[c](o.url,Md(T(i,Bi)));if(b instanceof jo){let R=b;if(this.processFunc){Md(T(i,Bi));try{R=await this.processFunc(o,R)}catch(k){(k.throttle==null||typeof k.stall!="number")&&R.makeServerError("error in post-processing function",k).assertOk()}}return R}o=b}this.preflightFunc&&(o=await this.preflightFunc(o));const u=await this.getUrlFunc(o,Md(T(i,Bi)));let f=new jo(u.statusCode,u.statusMessage,u.headers,u.body,i);if(f.statusCode===301||f.statusCode===302){try{const b=f.headers.location||"";return _t(h=o.redirect(b),Ba,Sf).call(h,t+1,e,0,i,f)}catch{}return f}else if(f.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,f,t))){const b=f.headers["retry-after"];let R=T(this,di).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return typeof b=="string"&&b.match(/^[1-9][0-9]*$/)&&(R=parseInt(b)),_t(y=o.clone(),Ba,Sf).call(y,t+1,e,R,i,f)}if(this.processFunc){Md(T(i,Bi));try{f=await this.processFunc(o,f)}catch(b){(b.throttle==null||typeof b.stall!="number")&&f.makeServerError("error in post-processing function",b).assertOk();let R=T(this,di).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return b.stall>=0&&(R=b.stall),_t(A=o.clone(),Ba,Sf).call(A,t+1,e,R,i,f)}}return f};let Zs=z0;var xh,Rh,Sh,Dr,wu,Pa;const lb=class lb{constructor(t,e,r,i,s){nt(this,xh);nt(this,Rh);nt(this,Sh);nt(this,Dr);nt(this,wu);nt(this,Pa);$(this,xh,t),$(this,Rh,e),$(this,Sh,Object.keys(r).reduce((o,c)=>(o[c.toLowerCase()]=String(r[c]),o),{})),$(this,Dr,i==null?null:new Uint8Array(i)),$(this,wu,s||null),$(this,Pa,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${T(this,Dr)?kt(T(this,Dr)):"null"}>`}get statusCode(){return T(this,xh)}get statusMessage(){return T(this,Rh)}get headers(){return Object.assign({},T(this,Sh))}get body(){return T(this,Dr)==null?null:new Uint8Array(T(this,Dr))}get bodyText(){try{return T(this,Dr)==null?"":T0(T(this,Dr))}catch{ht(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{ht(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const i=e[r++];return{value:[i,t[i]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(t,e){let r;t?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:(t=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${t})`);const i=new lb(599,r,this.headers,this.body,T(this,wu)||void 0);return $(i,Pa,{message:t,error:e}),i}throwThrottleError(t,e){e==null?e=-1:K(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const r=new Error(t||"throttling requests");throw $t(r,{stall:e,throttle:!0}),r}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return T(this,Dr)!=null}get request(){return T(this,wu)}ok(){return T(this,Pa).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=T(this,Pa);t===""&&(t=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let i=null;try{T(this,Dr)&&(i=T0(T(this,Dr)))}catch{}ht(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:i,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};xh=new WeakMap,Rh=new WeakMap,Sh=new WeakMap,Dr=new WeakMap,wu=new WeakMap,Pa=new WeakMap;let jo=lb;function LE(){return new Date().getTime()}function pV(n){return Vs(n.replace(/%([0-9a-f][0-9a-f])/gi,(t,e)=>String.fromCharCode(parseInt(e,16))))}function gV(n){return new Promise(t=>setTimeout(t,n))}function yV(n){let t=n.toString(16);for(;t.length<2;)t="0"+t;return"0x"+t}function UE(n,t,e){let r=0;for(let i=0;i<e;i++)r=r*256+n[t+i];return r}function DE(n,t,e,r){const i=[];for(;e<t+1+r;){const s=YI(n,e);i.push(s.result),e+=s.consumed,ht(e<=t+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:t})}return{consumed:1+r,result:i}}function YI(n,t){ht(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});const e=r=>{ht(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r})};if(n[t]>=248){const r=n[t]-247;e(t+1+r);const i=UE(n,t+1,r);return e(t+1+r+i),DE(n,t,t+1+r,r+i)}else if(n[t]>=192){const r=n[t]-192;return e(t+1+r),DE(n,t,t+1,r)}else if(n[t]>=184){const r=n[t]-183;e(t+1+r);const i=UE(n,t+1,r);e(t+1+r+i);const s=kt(n.slice(t+1+r,t+1+r+i));return{consumed:1+r+i,result:s}}else if(n[t]>=128){const r=n[t]-128;e(t+1+r);const i=kt(n.slice(t+1,t+1+r));return{consumed:1+r,result:i}}return{consumed:1,result:yV(n[t])}}function Lp(n){const t=ye(n,"data"),e=YI(t,0);return K(e.consumed===t.length,"unexpected junk after rlp payload","data",n),e.result}function FE(n){const t=[];for(;n;)t.unshift(n&255),n>>=8;return t}function XI(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(s){r=r.concat(XI(s))}),r.length<=55)return r.unshift(192+r.length),r;const i=FE(r.length);return i.unshift(247+i.length),i.concat(r)}const t=Array.prototype.slice.call(ye(n,"object"));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const e=FE(t.length);return e.unshift(183+e.length),e.concat(t)}const $E="0123456789abcdef";function pc(n){let t="0x";for(const e of XI(n))t+=$E[e>>4],t+=$E[e&15];return t}const gr=32,iw=new Uint8Array(gr),mV=["then"],Ld={},tk=new WeakMap;function ya(n){return tk.get(n)}function HE(n,t){tk.set(n,t)}function bf(n,t){const e=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw e.error=t,e}function sw(n,t,e){return n.indexOf(null)>=0?t.map((r,i)=>r instanceof dl?sw(ya(r),r,e):r):n.reduce((r,i,s)=>{let o=t.getValue(i);return i in r||(e&&o instanceof dl&&(o=sw(ya(o),o,e)),r[i]=o),r},{})}var bu;const eu=class eu extends Array{constructor(...e){const r=e[0];let i=e[1],s=(e[2]||[]).slice(),o=!0;r!==Ld&&(i=e,s=[],o=!1);super(i.length);nt(this,bu);i.forEach((f,h)=>{this[h]=f});const c=s.reduce((f,h)=>(typeof h=="string"&&f.set(h,(f.get(h)||0)+1),f),new Map);if(HE(this,Object.freeze(i.map((f,h)=>{const y=s[h];return y!=null&&c.get(y)===1?y:null}))),$(this,bu,[]),T(this,bu)==null&&T(this,bu),!o)return;Object.freeze(this);const u=new Proxy(this,{get:(f,h,y)=>{if(typeof h=="string"){if(h.match(/^[0-9]+$/)){const b=oe(h,"%index");if(b<0||b>=this.length)throw new RangeError("out of result range");const R=f[b];return R instanceof Error&&bf(`index ${b}`,R),R}if(mV.indexOf(h)>=0)return Reflect.get(f,h,y);const A=f[h];if(A instanceof Function)return function(...b){return A.apply(this===y?f:this,b)};if(!(h in f))return f.getValue.apply(this===y?f:this,[h])}return Reflect.get(f,h,y)}});return HE(u,ya(this)),u}toArray(e){const r=[];return this.forEach((i,s)=>{i instanceof Error&&bf(`index ${s}`,i),e&&i instanceof eu&&(i=i.toArray(e)),r.push(i)}),r}toObject(e){const r=ya(this);return r.reduce((i,s,o)=>(ht(s!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),sw(r,this,e)),{})}slice(e,r){e==null&&(e=0),e<0&&(e+=this.length,e<0&&(e=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const i=ya(this),s=[],o=[];for(let c=e;c<r;c++)s.push(this[c]),o.push(i[c]);return new eu(Ld,s,o)}filter(e,r){const i=ya(this),s=[],o=[];for(let c=0;c<this.length;c++){const u=this[c];u instanceof Error&&bf(`index ${c}`,u),e.call(r,u,c,this)&&(s.push(u),o.push(i[c]))}return new eu(Ld,s,o)}map(e,r){const i=[];for(let s=0;s<this.length;s++){const o=this[s];o instanceof Error&&bf(`index ${s}`,o),i.push(e.call(r,o,s,this))}return i}getValue(e){const r=ya(this).indexOf(e);if(r===-1)return;const i=this[r];return i instanceof Error&&bf(`property ${JSON.stringify(e)}`,i.error),i}static fromItems(e,r){return new eu(Ld,e,r)}};bu=new WeakMap;let dl=eu;function zE(n){let t=pr(n);return ht(t.length<=gr,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:gr,offset:t.length}),t.length!==gr&&(t=fr(Rn([iw.slice(t.length%gr),t]))),t}class Ys{constructor(t,e,r,i){Z(this,"name");Z(this,"type");Z(this,"localName");Z(this,"dynamic");$t(this,{name:t,type:e,localName:r,dynamic:i},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){K(!1,t,this.localName,e)}}var Ss,Ma,_u,Zd;class ow{constructor(){nt(this,_u);nt(this,Ss);nt(this,Ma);$(this,Ss,[]),$(this,Ma,0)}get data(){return Rn(T(this,Ss))}get length(){return T(this,Ma)}appendWriter(t){return _t(this,_u,Zd).call(this,fr(t.data))}writeBytes(t){let e=fr(t);const r=e.length%gr;return r&&(e=fr(Rn([e,iw.slice(r)]))),_t(this,_u,Zd).call(this,e)}writeValue(t){return _t(this,_u,Zd).call(this,zE(t))}writeUpdatableValue(){const t=T(this,Ss).length;return T(this,Ss).push(iw),$(this,Ma,T(this,Ma)+gr),e=>{T(this,Ss)[t]=zE(e)}}}Ss=new WeakMap,Ma=new WeakMap,_u=new WeakSet,Zd=function(t){return T(this,Ss).push(t),$(this,Ma,T(this,Ma)+t.length),t.length};var Ar,Fr,La,Ua,bo,bc,cw,ek;const fb=class fb{constructor(t,e,r){nt(this,bc);Z(this,"allowLoose");nt(this,Ar);nt(this,Fr);nt(this,La);nt(this,Ua);nt(this,bo);$t(this,{allowLoose:!!e}),$(this,Ar,fr(t)),$(this,La,0),$(this,Ua,null),$(this,bo,r??1024),$(this,Fr,0)}get data(){return kt(T(this,Ar))}get dataLength(){return T(this,Ar).length}get consumed(){return T(this,Fr)}get bytes(){return new Uint8Array(T(this,Ar))}subReader(t){const e=new fb(T(this,Ar).slice(T(this,Fr)+t),this.allowLoose,T(this,bo));return $(e,Ua,this),e}readBytes(t,e){let r=_t(this,bc,ek).call(this,0,t,!!e);return _t(this,bc,cw).call(this,t),$(this,Fr,T(this,Fr)+r.length),r.slice(0,t)}readValue(){return z1(this.readBytes(gr))}readIndex(){return tV(this.readBytes(gr))}};Ar=new WeakMap,Fr=new WeakMap,La=new WeakMap,Ua=new WeakMap,bo=new WeakMap,bc=new WeakSet,cw=function(t){var e;if(T(this,Ua))return _t(e=T(this,Ua),bc,cw).call(e,t);$(this,La,T(this,La)+t),ht(T(this,bo)<1||T(this,La)<=T(this,bo)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${T(this,bo)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:fr(T(this,Ar)),offset:T(this,Fr),length:t,info:{bytesRead:T(this,La),dataLength:this.dataLength}})},ek=function(t,e,r){let i=Math.ceil(e/gr)*gr;return T(this,Fr)+i>T(this,Ar).length&&(this.allowLoose&&r&&T(this,Fr)+e<=T(this,Ar).length?i=e:ht(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:fr(T(this,Ar)),length:T(this,Ar).length,offset:T(this,Fr)+i})),T(this,Ar).slice(T(this,Fr),T(this,Fr)+i)};let aw=fb;function O0(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function G1(n,...t){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(n.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${n.length}`)}function wV(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");O0(n.outputLen),O0(n.blockLen)}function pl(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function nk(n,t){G1(n);const e=t.outputLen;if(n.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const nm=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rk=n=>n instanceof Uint8Array,bV=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),rm=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Ci=(n,t)=>n<<32-t|n>>>t,_V=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!_V)throw new Error("Non little-endian hardware is not supported");function AV(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Up(n){if(typeof n=="string"&&(n=AV(n)),!rk(n))throw new Error(`expected Uint8Array, got ${typeof n}`);return n}function EV(...n){const t=new Uint8Array(n.reduce((r,i)=>r+i.length,0));let e=0;return n.forEach(r=>{if(!rk(r))throw new Error("Uint8Array expected");t.set(r,e),e+=r.length}),t}class V1{clone(){return this._cloneInto()}}function K1(n){const t=r=>n().update(Up(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function vV(n=32){if(nm&&typeof nm.getRandomValues=="function")return nm.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}class ik extends V1{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,wV(t);const r=Up(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=t.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(t){return pl(this),this.iHash.update(t),this}digestInto(t){pl(this),G1(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:i,destroyed:s,blockLen:o,outputLen:c}=this;return t=t,t.finished=i,t.destroyed=s,t.blockLen=o,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const sk=(n,t,e)=>new ik(n,t).update(e).digest();sk.create=(n,t)=>new ik(n,t);function xV(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),c=Number(e&s),u=r?4:0,f=r?0:4;n.setUint32(t+u,o,r),n.setUint32(t+f,c,r)}class ok extends V1{constructor(t,e,r,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=rm(this.buffer)}update(t){pl(this);const{view:e,buffer:r,blockLen:i}=this;t=Up(t);const s=t.length;for(let o=0;o<s;){const c=Math.min(i-this.pos,s-o);if(c===i){const u=rm(t);for(;i<=s-o;o+=i)this.process(u,o);continue}r.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){pl(this),nk(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let y=o;y<i;y++)e[y]=0;xV(r,i-8,BigInt(this.length*8),s),this.process(r,0);const c=rm(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<f;y++)c.setUint32(4*y,h[y],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:i,finished:s,destroyed:o,pos:c}=this;return t.length=i,t.pos=c,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(r),t}}const RV=(n,t,e)=>n&t^~n&e,SV=(n,t,e)=>n&t^n&e^t&e,IV=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ao=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),co=new Uint32Array(64);class kV extends ok{constructor(){super(64,32,8,!1),this.A=ao[0]|0,this.B=ao[1]|0,this.C=ao[2]|0,this.D=ao[3]|0,this.E=ao[4]|0,this.F=ao[5]|0,this.G=ao[6]|0,this.H=ao[7]|0}get(){const{A:t,B:e,C:r,D:i,E:s,F:o,G:c,H:u}=this;return[t,e,r,i,s,o,c,u]}set(t,e,r,i,s,o,c,u){this.A=t|0,this.B=e|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(t,e){for(let y=0;y<16;y++,e+=4)co[y]=t.getUint32(e,!1);for(let y=16;y<64;y++){const A=co[y-15],b=co[y-2],R=Ci(A,7)^Ci(A,18)^A>>>3,k=Ci(b,17)^Ci(b,19)^b>>>10;co[y]=k+co[y-7]+R+co[y-16]|0}let{A:r,B:i,C:s,D:o,E:c,F:u,G:f,H:h}=this;for(let y=0;y<64;y++){const A=Ci(c,6)^Ci(c,11)^Ci(c,25),b=h+A+RV(c,u,f)+IV[y]+co[y]|0,k=(Ci(r,2)^Ci(r,13)^Ci(r,22))+SV(r,i,s)|0;h=f,f=u,u=c,c=o+b|0,o=s,s=i,i=r,r=b+k|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(r,i,s,o,c,u,f,h)}roundClean(){co.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ak=K1(()=>new kV),Ud=BigInt(2**32-1),uw=BigInt(32);function ck(n,t=!1){return t?{h:Number(n&Ud),l:Number(n>>uw&Ud)}:{h:Number(n>>uw&Ud)|0,l:Number(n&Ud)|0}}function uk(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let i=0;i<n.length;i++){const{h:s,l:o}=ck(n[i],t);[e[i],r[i]]=[s,o]}return[e,r]}const TV=(n,t)=>BigInt(n>>>0)<<uw|BigInt(t>>>0),OV=(n,t,e)=>n>>>e,NV=(n,t,e)=>n<<32-e|t>>>e,CV=(n,t,e)=>n>>>e|t<<32-e,BV=(n,t,e)=>n<<32-e|t>>>e,PV=(n,t,e)=>n<<64-e|t>>>e-32,MV=(n,t,e)=>n>>>e-32|t<<64-e,LV=(n,t)=>t,UV=(n,t)=>n,lk=(n,t,e)=>n<<e|t>>>32-e,fk=(n,t,e)=>t<<e|n>>>32-e,hk=(n,t,e)=>t<<e-32|n>>>64-e,dk=(n,t,e)=>n<<e-32|t>>>64-e;function DV(n,t,e,r){const i=(t>>>0)+(r>>>0);return{h:n+e+(i/2**32|0)|0,l:i|0}}const FV=(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),$V=(n,t,e,r)=>t+e+r+(n/2**32|0)|0,HV=(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),zV=(n,t,e,r,i)=>t+e+r+i+(n/2**32|0)|0,GV=(n,t,e,r,i)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),VV=(n,t,e,r,i,s)=>t+e+r+i+s+(n/2**32|0)|0,te={fromBig:ck,split:uk,toBig:TV,shrSH:OV,shrSL:NV,rotrSH:CV,rotrSL:BV,rotrBH:PV,rotrBL:MV,rotr32H:LV,rotr32L:UV,rotlSH:lk,rotlSL:fk,rotlBH:hk,rotlBL:dk,add:DV,add3L:FV,add3H:$V,add4L:HV,add4H:zV,add5H:VV,add5L:GV},[KV,jV]=te.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),uo=new Uint32Array(80),lo=new Uint32Array(80);class WV extends ok{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:f,El:h,Fh:y,Fl:A,Gh:b,Gl:R,Hh:k,Hl:S}=this;return[t,e,r,i,s,o,c,u,f,h,y,A,b,R,k,S]}set(t,e,r,i,s,o,c,u,f,h,y,A,b,R,k,S){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=f|0,this.El=h|0,this.Fh=y|0,this.Fl=A|0,this.Gh=b|0,this.Gl=R|0,this.Hh=k|0,this.Hl=S|0}process(t,e){for(let U=0;U<16;U++,e+=4)uo[U]=t.getUint32(e),lo[U]=t.getUint32(e+=4);for(let U=16;U<80;U++){const G=uo[U-15]|0,W=lo[U-15]|0,Y=te.rotrSH(G,W,1)^te.rotrSH(G,W,8)^te.shrSH(G,W,7),j=te.rotrSL(G,W,1)^te.rotrSL(G,W,8)^te.shrSL(G,W,7),J=uo[U-2]|0,it=lo[U-2]|0,ut=te.rotrSH(J,it,19)^te.rotrBH(J,it,61)^te.shrSH(J,it,6),rt=te.rotrSL(J,it,19)^te.rotrBL(J,it,61)^te.shrSL(J,it,6),ot=te.add4L(j,rt,lo[U-7],lo[U-16]),C=te.add4H(ot,Y,ut,uo[U-7],uo[U-16]);uo[U]=C|0,lo[U]=ot|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:f,Dl:h,Eh:y,El:A,Fh:b,Fl:R,Gh:k,Gl:S,Hh:B,Hl:H}=this;for(let U=0;U<80;U++){const G=te.rotrSH(y,A,14)^te.rotrSH(y,A,18)^te.rotrBH(y,A,41),W=te.rotrSL(y,A,14)^te.rotrSL(y,A,18)^te.rotrBL(y,A,41),Y=y&b^~y&k,j=A&R^~A&S,J=te.add5L(H,W,j,jV[U],lo[U]),it=te.add5H(J,B,G,Y,KV[U],uo[U]),ut=J|0,rt=te.rotrSH(r,i,28)^te.rotrBH(r,i,34)^te.rotrBH(r,i,39),ot=te.rotrSL(r,i,28)^te.rotrBL(r,i,34)^te.rotrBL(r,i,39),C=r&s^r&c^s&c,p=i&o^i&u^o&u;B=k|0,H=S|0,k=b|0,S=R|0,b=y|0,R=A|0,{h:y,l:A}=te.add(f|0,h|0,it|0,ut|0),f=c|0,h=u|0,c=s|0,u=o|0,s=r|0,o=i|0;const m=te.add3L(ut,ot,p);r=te.add3H(m,it,rt,C),i=m|0}({h:r,l:i}=te.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=te.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=te.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:f,l:h}=te.add(this.Dh|0,this.Dl|0,f|0,h|0),{h:y,l:A}=te.add(this.Eh|0,this.El|0,y|0,A|0),{h:b,l:R}=te.add(this.Fh|0,this.Fl|0,b|0,R|0),{h:k,l:S}=te.add(this.Gh|0,this.Gl|0,k|0,S|0),{h:B,l:H}=te.add(this.Hh|0,this.Hl|0,B|0,H|0),this.set(r,i,s,o,c,u,f,h,y,A,b,R,k,S,B,H)}roundClean(){uo.fill(0),lo.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ZV=K1(()=>new WV);function qV(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof nl<"u")return nl;throw new Error("unable to locate global object")}const GE=qV();GE.crypto||GE.msCrypto;function QV(n){switch(n){case"sha256":return ak.create();case"sha512":return ZV.create()}K(!1,"invalid hashing algorithm name","algorithm",n)}const[pk,gk,yk]=[[],[],[]],JV=BigInt(0),_f=BigInt(1),YV=BigInt(2),XV=BigInt(7),tK=BigInt(256),eK=BigInt(113);for(let n=0,t=_f,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],pk.push(2*(5*r+e)),gk.push((n+1)*(n+2)/2%64);let i=JV;for(let s=0;s<7;s++)t=(t<<_f^(t>>XV)*eK)%tK,t&YV&&(i^=_f<<(_f<<BigInt(s))-_f);yk.push(i)}const[nK,rK]=uk(yk,!0),VE=(n,t,e)=>e>32?hk(n,t,e):lk(n,t,e),KE=(n,t,e)=>e>32?dk(n,t,e):fk(n,t,e);function iK(n,t=24){const e=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)e[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const c=(o+8)%10,u=(o+2)%10,f=e[u],h=e[u+1],y=VE(f,h,1)^e[c],A=KE(f,h,1)^e[c+1];for(let b=0;b<50;b+=10)n[o+b]^=y,n[o+b+1]^=A}let i=n[2],s=n[3];for(let o=0;o<24;o++){const c=gk[o],u=VE(i,s,c),f=KE(i,s,c),h=pk[o];i=n[h],s=n[h+1],n[h]=u,n[h+1]=f}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)e[c]=n[o+c];for(let c=0;c<10;c++)n[o+c]^=~e[(c+2)%10]&e[(c+4)%10]}n[0]^=nK[r],n[1]^=rK[r]}e.fill(0)}class j1 extends V1{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,O0(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=bV(this.state)}keccak(){iK(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){pl(this);const{blockLen:e,state:r}=this;t=Up(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(e-this.pos,i-s);for(let c=0;c<o;c++)r[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:i}=this;t[r]^=e,e&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){pl(this,!1),G1(t),this.finish();const e=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(e.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return O0(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(nk(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new j1(e,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const sK=(n,t,e)=>K1(()=>new j1(t,n,e)),oK=sK(1,136,256/8);let mk=!1;const wk=function(n){return oK(n)};let bk=wk;function kn(n){const t=ye(n,"data");return kt(bk(t))}kn._=wk;kn.lock=function(){mk=!0};kn.register=function(n){if(mk)throw new TypeError("keccak256 is locked");bk=n};Object.freeze(kn);const _k=function(n){return QV("sha256").update(n).digest()};let Ak=_k,Ek=!1;function Dl(n){const t=ye(n,"data");return kt(Ak(t))}Dl._=_k;Dl.lock=function(){Ek=!0};Dl.register=function(n){if(Ek)throw new Error("sha256 is locked");Ak=n};Object.freeze(Dl);Object.freeze(Dl);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vk=BigInt(0),Dp=BigInt(1),aK=BigInt(2),Fp=n=>n instanceof Uint8Array,cK=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function gl(n){if(!Fp(n))throw new Error("Uint8Array expected");let t="";for(let e=0;e<n.length;e++)t+=cK[n[e]];return t}function xk(n){const t=n.toString(16);return t.length&1?`0${t}`:t}function W1(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}function yl(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const t=n.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const e=new Uint8Array(t/2);for(let r=0;r<e.length;r++){const i=r*2,s=n.slice(i,i+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function ec(n){return W1(gl(n))}function Z1(n){if(!Fp(n))throw new Error("Uint8Array expected");return W1(gl(Uint8Array.from(n).reverse()))}function ml(n,t){return yl(n.toString(16).padStart(t*2,"0"))}function q1(n,t){return ml(n,t).reverse()}function uK(n){return yl(xk(n))}function fi(n,t,e){let r;if(typeof t=="string")try{r=yl(t)}catch(s){throw new Error(`${n} must be valid hex string, got "${t}". Cause: ${s}`)}else if(Fp(t))r=Uint8Array.from(t);else throw new Error(`${n} must be hex string or Uint8Array`);const i=r.length;if(typeof e=="number"&&i!==e)throw new Error(`${n} expected ${e} bytes, got ${i}`);return r}function ph(...n){const t=new Uint8Array(n.reduce((r,i)=>r+i.length,0));let e=0;return n.forEach(r=>{if(!Fp(r))throw new Error("Uint8Array expected");t.set(r,e),e+=r.length}),t}function lK(n,t){if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==t[e])return!1;return!0}function fK(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function hK(n){let t;for(t=0;n>vk;n>>=Dp,t+=1);return t}function dK(n,t){return n>>BigInt(t)&Dp}const pK=(n,t,e)=>n|(e?Dp:vk)<<BigInt(t),Q1=n=>(aK<<BigInt(n-1))-Dp,im=n=>new Uint8Array(n),jE=n=>Uint8Array.from(n);function Rk(n,t,e){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let r=im(n),i=im(n),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},c=(...y)=>e(i,r,...y),u=(y=im())=>{i=c(jE([0]),y),r=c(),y.length!==0&&(i=c(jE([1]),y),r=c())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let y=0;const A=[];for(;y<t;){r=c();const b=r.slice();A.push(b),y+=r.length}return ph(...A)};return(y,A)=>{o(),u(y);let b;for(;!(b=A(f()));)u();return o(),b}}const gK={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||n instanceof Uint8Array,isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,t)=>t.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function td(n,t,e={}){const r=(i,s,o)=>{const c=gK[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);const u=n[i];if(!(o&&u===void 0)&&!c(u,n))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(const[i,s]of Object.entries(t))r(i,s,!1);for(const[i,s]of Object.entries(e))r(i,s,!0);return n}const yK=Object.freeze(Object.defineProperty({__proto__:null,bitGet:dK,bitLen:hK,bitMask:Q1,bitSet:pK,bytesToHex:gl,bytesToNumberBE:ec,bytesToNumberLE:Z1,concatBytes:ph,createHmacDrbg:Rk,ensureBytes:fi,equalBytes:lK,hexToBytes:yl,hexToNumber:W1,numberToBytesBE:ml,numberToBytesLE:q1,numberToHexUnpadded:xk,numberToVarBytesBE:uK,utf8ToBytes:fK,validateObject:td},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fn=BigInt(0),vn=BigInt(1),ma=BigInt(2),mK=BigInt(3),lw=BigInt(4),WE=BigInt(5),ZE=BigInt(8);BigInt(9);BigInt(16);function Rr(n,t){const e=n%t;return e>=Fn?e:t+e}function wK(n,t,e){if(e<=Fn||t<Fn)throw new Error("Expected power/modulo > 0");if(e===vn)return Fn;let r=vn;for(;t>Fn;)t&vn&&(r=r*n%e),n=n*n%e,t>>=vn;return r}function Wr(n,t,e){let r=n;for(;t-- >Fn;)r*=r,r%=e;return r}function fw(n,t){if(n===Fn||t<=Fn)throw new Error(`invert: expected positive integers, got n=${n} mod=${t}`);let e=Rr(n,t),r=t,i=Fn,s=vn;for(;e!==Fn;){const c=r/e,u=r%e,f=i-s*c;r=e,e=u,i=s,s=f}if(r!==vn)throw new Error("invert: does not exist");return Rr(i,t)}function bK(n){const t=(n-vn)/ma;let e,r,i;for(e=n-vn,r=0;e%ma===Fn;e/=ma,r++);for(i=ma;i<n&&wK(i,t,n)!==n-vn;i++);if(r===1){const o=(n+vn)/lw;return function(u,f){const h=u.pow(f,o);if(!u.eql(u.sqr(h),f))throw new Error("Cannot find square root");return h}}const s=(e+vn)/ma;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=r,h=c.pow(c.mul(c.ONE,i),e),y=c.pow(u,s),A=c.pow(u,e);for(;!c.eql(A,c.ONE);){if(c.eql(A,c.ZERO))return c.ZERO;let b=1;for(let k=c.sqr(A);b<f&&!c.eql(k,c.ONE);b++)k=c.sqr(k);const R=c.pow(h,vn<<BigInt(f-b-1));h=c.sqr(R),y=c.mul(y,R),A=c.mul(A,h),f=b}return y}}function _K(n){if(n%lw===mK){const t=(n+vn)/lw;return function(r,i){const s=r.pow(i,t);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(n%ZE===WE){const t=(n-WE)/ZE;return function(r,i){const s=r.mul(i,ma),o=r.pow(s,t),c=r.mul(i,o),u=r.mul(r.mul(c,ma),o),f=r.mul(c,r.sub(u,r.ONE));if(!r.eql(r.sqr(f),i))throw new Error("Cannot find square root");return f}}return bK(n)}const AK=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function EK(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=AK.reduce((r,i)=>(r[i]="function",r),t);return td(n,e)}function vK(n,t,e){if(e<Fn)throw new Error("Expected power > 0");if(e===Fn)return n.ONE;if(e===vn)return t;let r=n.ONE,i=t;for(;e>Fn;)e&vn&&(r=n.mul(r,i)),i=n.sqr(i),e>>=vn;return r}function xK(n,t){const e=new Array(t.length),r=t.reduce((s,o,c)=>n.is0(o)?s:(e[c]=s,n.mul(s,o)),n.ONE),i=n.inv(r);return t.reduceRight((s,o,c)=>n.is0(o)?s:(e[c]=n.mul(s,e[c]),n.mul(s,o)),i),e}function Sk(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function RK(n,t,e=!1,r={}){if(n<=Fn)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:i,nByteLength:s}=Sk(n,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=_K(n),c=Object.freeze({ORDER:n,BITS:i,BYTES:s,MASK:Q1(i),ZERO:Fn,ONE:vn,create:u=>Rr(u,n),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Fn<=u&&u<n},is0:u=>u===Fn,isOdd:u=>(u&vn)===vn,neg:u=>Rr(-u,n),eql:(u,f)=>u===f,sqr:u=>Rr(u*u,n),add:(u,f)=>Rr(u+f,n),sub:(u,f)=>Rr(u-f,n),mul:(u,f)=>Rr(u*f,n),pow:(u,f)=>vK(c,u,f),div:(u,f)=>Rr(u*fw(f,n),n),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>fw(u,n),sqrt:r.sqrt||(u=>o(c,u)),invertBatch:u=>xK(c,u),cmov:(u,f,h)=>h?f:u,toBytes:u=>e?q1(u,s):ml(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return e?Z1(u):ec(u)}});return Object.freeze(c)}function Ik(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function kk(n){const t=Ik(n);return t+Math.ceil(t/2)}function SK(n,t,e=!1){const r=n.length,i=Ik(t),s=kk(t);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=e?ec(n):Z1(n),c=Rr(o,t-vn)+vn;return e?q1(c,i):ml(c,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const IK=BigInt(0),sm=BigInt(1);function kK(n,t){const e=(i,s)=>{const o=s.negate();return i?o:s},r=i=>{const s=Math.ceil(t/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:e,unsafeLadder(i,s){let o=n.ZERO,c=i;for(;s>IK;)s&sm&&(o=o.add(c)),c=c.double(),s>>=sm;return o},precomputeWindow(i,s){const{windows:o,windowSize:c}=r(s),u=[];let f=i,h=f;for(let y=0;y<o;y++){h=f,u.push(h);for(let A=1;A<c;A++)h=h.add(f),u.push(h);f=h.double()}return u},wNAF(i,s,o){const{windows:c,windowSize:u}=r(i);let f=n.ZERO,h=n.BASE;const y=BigInt(2**i-1),A=2**i,b=BigInt(i);for(let R=0;R<c;R++){const k=R*u;let S=Number(o&y);o>>=b,S>u&&(S-=A,o+=sm);const B=k,H=k+Math.abs(S)-1,U=R%2!==0,G=S<0;S===0?h=h.add(e(U,s[B])):f=f.add(e(G,s[H]))}return{p:f,f:h}},wNAFCached(i,s,o,c){const u=i._WINDOW_SIZE||1;let f=s.get(i);return f||(f=this.precomputeWindow(i,u),u!==1&&s.set(i,c(f))),this.wNAF(u,f,o)}}}function Tk(n){return EK(n.Fp),td(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Sk(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function TK(n){const t=Tk(n);td(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:i}=t;if(e){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:OK,hexToBytes:NK}=yK,Sa={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(n){const{Err:t}=Sa;if(n.length<2||n[0]!==2)throw new t("Invalid signature integer tag");const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:OK(r),l:n.subarray(e+2)}},toSig(n){const{Err:t}=Sa,e=typeof n=="string"?NK(n):n;if(!(e instanceof Uint8Array))throw new Error("ui8a expected");let r=e.length;if(r<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:i,l:s}=Sa._parseInt(e.subarray(2)),{d:o,l:c}=Sa._parseInt(s);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(n){const t=f=>Number.parseInt(f[0],16)&8?"00"+f:f,e=f=>{const h=f.toString(16);return h.length&1?`0${h}`:h},r=t(e(n.s)),i=t(e(n.r)),s=r.length/2,o=i.length/2,c=e(s),u=e(o);return`30${e(o+s+4)}02${u}${i}02${c}${r}`}},Hs=BigInt(0),ei=BigInt(1);BigInt(2);const qE=BigInt(3);BigInt(4);function CK(n){const t=TK(n),{Fp:e}=t,r=t.toBytes||((R,k,S)=>{const B=k.toAffine();return ph(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),i=t.fromBytes||(R=>{const k=R.subarray(1),S=e.fromBytes(k.subarray(0,e.BYTES)),B=e.fromBytes(k.subarray(e.BYTES,2*e.BYTES));return{x:S,y:B}});function s(R){const{a:k,b:S}=t,B=e.sqr(R),H=e.mul(B,R);return e.add(e.add(H,e.mul(R,k)),S)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(R){return typeof R=="bigint"&&Hs<R&&R<t.n}function c(R){if(!o(R))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(R){const{allowedPrivateKeyLengths:k,nByteLength:S,wrapPrivateKey:B,n:H}=t;if(k&&typeof R!="bigint"){if(R instanceof Uint8Array&&(R=gl(R)),typeof R!="string"||!k.includes(R.length))throw new Error("Invalid key");R=R.padStart(S*2,"0")}let U;try{U=typeof R=="bigint"?R:ec(fi("private key",R,S))}catch{throw new Error(`private key must be ${S} bytes, hex or bigint, not ${typeof R}`)}return B&&(U=Rr(U,H)),c(U),U}const f=new Map;function h(R){if(!(R instanceof y))throw new Error("ProjectivePoint expected")}class y{constructor(k,S,B){if(this.px=k,this.py=S,this.pz=B,k==null||!e.isValid(k))throw new Error("x required");if(S==null||!e.isValid(S))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required")}static fromAffine(k){const{x:S,y:B}=k||{};if(!k||!e.isValid(S)||!e.isValid(B))throw new Error("invalid affine point");if(k instanceof y)throw new Error("projective point not allowed");const H=U=>e.eql(U,e.ZERO);return H(S)&&H(B)?y.ZERO:new y(S,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(k){const S=e.invertBatch(k.map(B=>B.pz));return k.map((B,H)=>B.toAffine(S[H])).map(y.fromAffine)}static fromHex(k){const S=y.fromAffine(i(fi("pointHex",k)));return S.assertValidity(),S}static fromPrivateKey(k){return y.BASE.multiply(u(k))}_setWindowSize(k){this._WINDOW_SIZE=k,f.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:k,y:S}=this.toAffine();if(!e.isValid(k)||!e.isValid(S))throw new Error("bad point: x or y not FE");const B=e.sqr(S),H=s(k);if(!e.eql(B,H))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:k}=this.toAffine();if(e.isOdd)return!e.isOdd(k);throw new Error("Field doesn't support isOdd")}equals(k){h(k);const{px:S,py:B,pz:H}=this,{px:U,py:G,pz:W}=k,Y=e.eql(e.mul(S,W),e.mul(U,H)),j=e.eql(e.mul(B,W),e.mul(G,H));return Y&&j}negate(){return new y(this.px,e.neg(this.py),this.pz)}double(){const{a:k,b:S}=t,B=e.mul(S,qE),{px:H,py:U,pz:G}=this;let W=e.ZERO,Y=e.ZERO,j=e.ZERO,J=e.mul(H,H),it=e.mul(U,U),ut=e.mul(G,G),rt=e.mul(H,U);return rt=e.add(rt,rt),j=e.mul(H,G),j=e.add(j,j),W=e.mul(k,j),Y=e.mul(B,ut),Y=e.add(W,Y),W=e.sub(it,Y),Y=e.add(it,Y),Y=e.mul(W,Y),W=e.mul(rt,W),j=e.mul(B,j),ut=e.mul(k,ut),rt=e.sub(J,ut),rt=e.mul(k,rt),rt=e.add(rt,j),j=e.add(J,J),J=e.add(j,J),J=e.add(J,ut),J=e.mul(J,rt),Y=e.add(Y,J),ut=e.mul(U,G),ut=e.add(ut,ut),J=e.mul(ut,rt),W=e.sub(W,J),j=e.mul(ut,it),j=e.add(j,j),j=e.add(j,j),new y(W,Y,j)}add(k){h(k);const{px:S,py:B,pz:H}=this,{px:U,py:G,pz:W}=k;let Y=e.ZERO,j=e.ZERO,J=e.ZERO;const it=t.a,ut=e.mul(t.b,qE);let rt=e.mul(S,U),ot=e.mul(B,G),C=e.mul(H,W),p=e.add(S,B),m=e.add(U,G);p=e.mul(p,m),m=e.add(rt,ot),p=e.sub(p,m),m=e.add(S,H);let v=e.add(U,W);return m=e.mul(m,v),v=e.add(rt,C),m=e.sub(m,v),v=e.add(B,H),Y=e.add(G,W),v=e.mul(v,Y),Y=e.add(ot,C),v=e.sub(v,Y),J=e.mul(it,m),Y=e.mul(ut,C),J=e.add(Y,J),Y=e.sub(ot,J),J=e.add(ot,J),j=e.mul(Y,J),ot=e.add(rt,rt),ot=e.add(ot,rt),C=e.mul(it,C),m=e.mul(ut,m),ot=e.add(ot,C),C=e.sub(rt,C),C=e.mul(it,C),m=e.add(m,C),rt=e.mul(ot,m),j=e.add(j,rt),rt=e.mul(v,m),Y=e.mul(p,Y),Y=e.sub(Y,rt),rt=e.mul(p,ot),J=e.mul(v,J),J=e.add(J,rt),new y(Y,j,J)}subtract(k){return this.add(k.negate())}is0(){return this.equals(y.ZERO)}wNAF(k){return b.wNAFCached(this,f,k,S=>{const B=e.invertBatch(S.map(H=>H.pz));return S.map((H,U)=>H.toAffine(B[U])).map(y.fromAffine)})}multiplyUnsafe(k){const S=y.ZERO;if(k===Hs)return S;if(c(k),k===ei)return this;const{endo:B}=t;if(!B)return b.unsafeLadder(this,k);let{k1neg:H,k1:U,k2neg:G,k2:W}=B.splitScalar(k),Y=S,j=S,J=this;for(;U>Hs||W>Hs;)U&ei&&(Y=Y.add(J)),W&ei&&(j=j.add(J)),J=J.double(),U>>=ei,W>>=ei;return H&&(Y=Y.negate()),G&&(j=j.negate()),j=new y(e.mul(j.px,B.beta),j.py,j.pz),Y.add(j)}multiply(k){c(k);let S=k,B,H;const{endo:U}=t;if(U){const{k1neg:G,k1:W,k2neg:Y,k2:j}=U.splitScalar(S);let{p:J,f:it}=this.wNAF(W),{p:ut,f:rt}=this.wNAF(j);J=b.constTimeNegate(G,J),ut=b.constTimeNegate(Y,ut),ut=new y(e.mul(ut.px,U.beta),ut.py,ut.pz),B=J.add(ut),H=it.add(rt)}else{const{p:G,f:W}=this.wNAF(S);B=G,H=W}return y.normalizeZ([B,H])[0]}multiplyAndAddUnsafe(k,S,B){const H=y.BASE,U=(W,Y)=>Y===Hs||Y===ei||!W.equals(H)?W.multiplyUnsafe(Y):W.multiply(Y),G=U(this,S).add(U(k,B));return G.is0()?void 0:G}toAffine(k){const{px:S,py:B,pz:H}=this,U=this.is0();k==null&&(k=U?e.ONE:e.inv(H));const G=e.mul(S,k),W=e.mul(B,k),Y=e.mul(H,k);if(U)return{x:e.ZERO,y:e.ZERO};if(!e.eql(Y,e.ONE))throw new Error("invZ was invalid");return{x:G,y:W}}isTorsionFree(){const{h:k,isTorsionFree:S}=t;if(k===ei)return!0;if(S)return S(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:k,clearCofactor:S}=t;return k===ei?this:S?S(y,this):this.multiplyUnsafe(t.h)}toRawBytes(k=!0){return this.assertValidity(),r(y,this,k)}toHex(k=!0){return gl(this.toRawBytes(k))}}y.BASE=new y(t.Gx,t.Gy,e.ONE),y.ZERO=new y(e.ZERO,e.ONE,e.ZERO);const A=t.nBitLength,b=kK(y,t.endo?Math.ceil(A/2):A);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:u,weierstrassEquation:s,isWithinCurveOrder:o}}function BK(n){const t=Tk(n);return td(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function PK(n){const t=BK(n),{Fp:e,n:r}=t,i=e.BYTES+1,s=2*e.BYTES+1;function o(m){return Hs<m&&m<e.ORDER}function c(m){return Rr(m,r)}function u(m){return fw(m,r)}const{ProjectivePoint:f,normPrivateKeyToScalar:h,weierstrassEquation:y,isWithinCurveOrder:A}=CK({...t,toBytes(m,v,I){const N=v.toAffine(),M=e.toBytes(N.x),z=ph;return I?z(Uint8Array.from([v.hasEvenY()?2:3]),M):z(Uint8Array.from([4]),M,e.toBytes(N.y))},fromBytes(m){const v=m.length,I=m[0],N=m.subarray(1);if(v===i&&(I===2||I===3)){const M=ec(N);if(!o(M))throw new Error("Point is not on curve");const z=y(M);let P=e.sqrt(z);const _=(P&ei)===ei;return(I&1)===1!==_&&(P=e.neg(P)),{x:M,y:P}}else if(v===s&&I===4){const M=e.fromBytes(N.subarray(0,e.BYTES)),z=e.fromBytes(N.subarray(e.BYTES,2*e.BYTES));return{x:M,y:z}}else throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),b=m=>gl(ml(m,t.nByteLength));function R(m){const v=r>>ei;return m>v}function k(m){return R(m)?c(-m):m}const S=(m,v,I)=>ec(m.slice(v,I));class B{constructor(v,I,N){this.r=v,this.s=I,this.recovery=N,this.assertValidity()}static fromCompact(v){const I=t.nByteLength;return v=fi("compactSignature",v,I*2),new B(S(v,0,I),S(v,I,2*I))}static fromDER(v){const{r:I,s:N}=Sa.toSig(fi("DER",v));return new B(I,N)}assertValidity(){if(!A(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!A(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(v){return new B(this.r,this.s,v)}recoverPublicKey(v){const{r:I,s:N,recovery:M}=this,z=j(fi("msgHash",v));if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");const P=M===2||M===3?I+t.n:I;if(P>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const _=M&1?"03":"02",F=f.fromHex(_+b(P)),ct=u(P),ft=c(-z*ct),mt=c(N*ct),Ht=f.BASE.multiplyAndAddUnsafe(F,ft,mt);if(!Ht)throw new Error("point at infinify");return Ht.assertValidity(),Ht}hasHighS(){return R(this.s)}normalizeS(){return this.hasHighS()?new B(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return yl(this.toDERHex())}toDERHex(){return Sa.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return yl(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}const H={isValidPrivateKey(m){try{return h(m),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const m=kk(t.n);return SK(t.randomBytes(m),t.n)},precompute(m=8,v=f.BASE){return v._setWindowSize(m),v.multiply(BigInt(3)),v}};function U(m,v=!0){return f.fromPrivateKey(m).toRawBytes(v)}function G(m){const v=m instanceof Uint8Array,I=typeof m=="string",N=(v||I)&&m.length;return v?N===i||N===s:I?N===2*i||N===2*s:m instanceof f}function W(m,v,I=!0){if(G(m))throw new Error("first arg must be private key");if(!G(v))throw new Error("second arg must be public key");return f.fromHex(v).multiply(h(m)).toRawBytes(I)}const Y=t.bits2int||function(m){const v=ec(m),I=m.length*8-t.nBitLength;return I>0?v>>BigInt(I):v},j=t.bits2int_modN||function(m){return c(Y(m))},J=Q1(t.nBitLength);function it(m){if(typeof m!="bigint")throw new Error("bigint expected");if(!(Hs<=m&&m<J))throw new Error(`bigint expected < 2^${t.nBitLength}`);return ml(m,t.nByteLength)}function ut(m,v,I=rt){if(["recovered","canonical"].some(Mt=>Mt in I))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:M}=t;let{lowS:z,prehash:P,extraEntropy:_}=I;z==null&&(z=!0),m=fi("msgHash",m),P&&(m=fi("prehashed msgHash",N(m)));const F=j(m),ct=h(v),ft=[it(ct),it(F)];if(_!=null){const Mt=_===!0?M(e.BYTES):_;ft.push(fi("extraEntropy",Mt))}const mt=ph(...ft),Ht=F;function Lt(Mt){const Ae=Y(Mt);if(!A(Ae))return;const Vt=u(Ae),Ut=f.BASE.multiply(Ae).toAffine(),Re=c(Ut.x);if(Re===Hs)return;const Yt=c(Vt*c(Ht+Re*ct));if(Yt===Hs)return;let ie=(Ut.x===Re?0:2)|Number(Ut.y&ei),Qe=Yt;return z&&R(Yt)&&(Qe=k(Yt),ie^=1),new B(Re,Qe,ie)}return{seed:mt,k2sig:Lt}}const rt={lowS:t.lowS,prehash:!1},ot={lowS:t.lowS,prehash:!1};function C(m,v,I=rt){const{seed:N,k2sig:M}=ut(m,v,I),z=t;return Rk(z.hash.outputLen,z.nByteLength,z.hmac)(N,M)}f.BASE._setWindowSize(8);function p(m,v,I,N=ot){var Ut;const M=m;if(v=fi("msgHash",v),I=fi("publicKey",I),"strict"in N)throw new Error("options.strict was renamed to lowS");const{lowS:z,prehash:P}=N;let _,F;try{if(typeof M=="string"||M instanceof Uint8Array)try{_=B.fromDER(M)}catch(Re){if(!(Re instanceof Sa.Err))throw Re;_=B.fromCompact(M)}else if(typeof M=="object"&&typeof M.r=="bigint"&&typeof M.s=="bigint"){const{r:Re,s:Yt}=M;_=new B(Re,Yt)}else throw new Error("PARSE");F=f.fromHex(I)}catch(Re){if(Re.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(z&&_.hasHighS())return!1;P&&(v=t.hash(v));const{r:ct,s:ft}=_,mt=j(v),Ht=u(ft),Lt=c(mt*Ht),Mt=c(ct*Ht),Ae=(Ut=f.BASE.multiplyAndAddUnsafe(F,Lt,Mt))==null?void 0:Ut.toAffine();return Ae?c(Ae.x)===ct:!1}return{CURVE:t,getPublicKey:U,getSharedSecret:W,sign:C,verify:p,ProjectivePoint:f,Signature:B,utils:H}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function MK(n){return{hash:n,hmac:(t,...e)=>sk(n,t,EV(...e)),randomBytes:vV}}function LK(n,t){const e=r=>PK({...n,...MK(r)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ok=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),QE=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),UK=BigInt(1),hw=BigInt(2),JE=(n,t)=>(n+t/hw)/t;function DK(n){const t=Ok,e=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),c=BigInt(44),u=BigInt(88),f=n*n*n%t,h=f*f*n%t,y=Wr(h,e,t)*h%t,A=Wr(y,e,t)*h%t,b=Wr(A,hw,t)*f%t,R=Wr(b,i,t)*b%t,k=Wr(R,s,t)*R%t,S=Wr(k,c,t)*k%t,B=Wr(S,u,t)*S%t,H=Wr(B,c,t)*k%t,U=Wr(H,e,t)*h%t,G=Wr(U,o,t)*R%t,W=Wr(G,r,t)*f%t,Y=Wr(W,hw,t);if(!dw.eql(dw.sqr(Y),n))throw new Error("Cannot find square root");return Y}const dw=RK(Ok,void 0,void 0,{sqrt:DK}),ho=LK({a:BigInt(0),b:BigInt(7),Fp:dw,n:QE,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=QE,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-UK*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,o=BigInt("0x100000000000000000000000000000000"),c=JE(s*n,t),u=JE(-r*n,t);let f=Rr(n-c*e-u*i,t),h=Rr(-c*r-u*s,t);const y=f>o,A=h>o;if(y&&(f=t-f),A&&(h=t-h),f>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:y,k1:f,k2neg:A,k2:h}}}},ak);BigInt(0);ho.ProjectivePoint;const gh="0x0000000000000000000000000000000000000000",YE="0x0000000000000000000000000000000000000000000000000000000000000000",XE=BigInt(0),tv=BigInt(1),ev=BigInt(2),nv=BigInt(27),rv=BigInt(28),Dd=BigInt(35),Fc={};function iv(n){return dc(pr(n),32)}var Au,Eu,vu,Da;const li=class li{constructor(t,e,r,i){nt(this,Au);nt(this,Eu);nt(this,vu);nt(this,Da);Bp(t,Fc,"Signature"),$(this,Au,e),$(this,Eu,r),$(this,vu,i),$(this,Da,null)}get r(){return T(this,Au)}set r(t){K(uu(t)===32,"invalid r","value",t),$(this,Au,kt(t))}get s(){return T(this,Eu)}set s(t){K(uu(t)===32,"invalid s","value",t);const e=kt(t);K(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),$(this,Eu,e)}get v(){return T(this,vu)}set v(t){const e=oe(t,"value");K(e===27||e===28,"invalid v","v",t),$(this,vu,e)}get networkV(){return T(this,Da)}get legacyChainId(){const t=this.networkV;return t==null?null:li.getChainId(t)}get yParity(){return this.v===27?0:1}get yParityAndS(){const t=ye(this.s);return this.yParity&&(t[0]|=128),kt(t)}get compactSerialized(){return Rn([this.r,this.yParityAndS])}get serialized(){return Rn([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const t=new li(Fc,this.r,this.s,this.v);return this.networkV&&$(t,Da,this.networkV),t}toJSON(){const t=this.networkV;return{_type:"signature",networkV:t!=null?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=Nt(t,"v");return e==nv||e==rv?XE:(K(e>=Dd,"invalid EIP-155 v","v",t),(e-Dd)/ev)}static getChainIdV(t,e){return Nt(t)*ev+BigInt(35+e-27)}static getNormalizedV(t){const e=Nt(t);return e===XE||e===nv?27:e===tv||e===rv?28:(K(e>=Dd,"invalid v","v",t),e&tv?27:28)}static from(t){function e(f,h){K(f,h,"signature",t)}if(t==null)return new li(Fc,YE,YE,27);if(typeof t=="string"){const f=ye(t,"signature");if(f.length===64){const h=kt(f.slice(0,32)),y=f.slice(32,64),A=y[0]&128?28:27;return y[0]&=127,new li(Fc,h,kt(y),A)}if(f.length===65){const h=kt(f.slice(0,32)),y=f.slice(32,64);e((y[0]&128)===0,"non-canonical s");const A=li.getNormalizedV(f[64]);return new li(Fc,h,kt(y),A)}e(!1,"invalid raw signature length")}if(t instanceof li)return t.clone();const r=t.r;e(r!=null,"missing r");const i=iv(r),s=function(f,h){if(f!=null)return iv(f);if(h!=null){e(He(h,32),"invalid yParityAndS");const y=ye(h);return y[0]&=127,kt(y)}e(!1,"missing s")}(t.s,t.yParityAndS);e((ye(s)[0]&128)==0,"non-canonical s");const{networkV:o,v:c}=function(f,h,y){if(f!=null){const A=Nt(f);return{networkV:A>=Dd?A:void 0,v:li.getNormalizedV(A)}}if(h!=null)return e(He(h,32),"invalid yParityAndS"),{v:ye(h)[0]&128?28:27};if(y!=null){switch(oe(y,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}e(!1,"invalid yParity")}e(!1,"missing v")}(t.v,t.yParityAndS,t.yParity),u=new li(Fc,i,s,c);return o&&$(u,Da,o),e(t.yParity==null||oe(t.yParity,"sig.yParity")===u.yParity,"yParity mismatch"),e(t.yParityAndS==null||t.yParityAndS===u.yParityAndS,"yParityAndS mismatch"),u}};Au=new WeakMap,Eu=new WeakMap,vu=new WeakMap,Da=new WeakMap;let Ri=li;var Is;const wa=class wa{constructor(t){nt(this,Is);K(uu(t)===32,"invalid private key","privateKey","[REDACTED]"),$(this,Is,kt(t))}get privateKey(){return T(this,Is)}get publicKey(){return wa.computePublicKey(T(this,Is))}get compressedPublicKey(){return wa.computePublicKey(T(this,Is),!0)}sign(t){K(uu(t)===32,"invalid digest length","digest",t);const e=ho.sign(fr(t),fr(T(this,Is)),{lowS:!0});return Ri.from({r:Xo(e.r,32),s:Xo(e.s,32),v:e.recovery?28:27})}computeSharedSecret(t){const e=wa.computePublicKey(t);return kt(ho.getSharedSecret(fr(T(this,Is)),ye(e),!1))}static computePublicKey(t,e){let r=ye(t,"key");if(r.length===32){const s=ho.getPublicKey(r,!!e);return kt(s)}if(r.length===64){const s=new Uint8Array(65);s[0]=4,s.set(r,1),r=s}const i=ho.ProjectivePoint.fromHex(r);return kt(i.toRawBytes(e))}static recoverPublicKey(t,e){K(uu(t)===32,"invalid digest length","digest",t);const r=Ri.from(e);let i=ho.Signature.fromCompact(fr(Rn([r.r,r.s])));i=i.addRecoveryBit(r.yParity);const s=i.recoverPublicKey(fr(t));return K(s!=null,"invalid signautre for digest","signature",e),"0x"+s.toHex(!1)}static addPoints(t,e,r){const i=ho.ProjectivePoint.fromHex(wa.computePublicKey(t).substring(2)),s=ho.ProjectivePoint.fromHex(wa.computePublicKey(e).substring(2));return"0x"+i.add(s).toHex(!!r)}};Is=new WeakMap;let yh=wa;const FK=BigInt(0),$K=BigInt(36);function sv(n){n=n.toLowerCase();const t=n.substring(2).split(""),e=new Uint8Array(40);for(let i=0;i<40;i++)e[i]=t[i].charCodeAt(0);const r=ye(kn(e));for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(r[i>>1]&15)>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}const J1={};for(let n=0;n<10;n++)J1[String(n)]=String(n);for(let n=0;n<26;n++)J1[String.fromCharCode(65+n)]=String(10+n);const ov=15;function HK(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let t=n.split("").map(r=>J1[r]).join("");for(;t.length>=ov;){let r=t.substring(0,ov);t=parseInt(r,10)%97+t.substring(r.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}const zK=function(){const n={};for(let t=0;t<36;t++){const e="0123456789abcdefghijklmnopqrstuvwxyz"[t];n[e]=BigInt(t)}return n}();function GK(n){n=n.toLowerCase();let t=FK;for(let e=0;e<n.length;e++)t=t*$K+zK[n[e]];return t}function Pe(n){if(K(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const t=sv(n);return K(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===n,"bad address checksum","address",n),t}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){K(n.substring(2,4)===HK(n),"bad icap checksum","address",n);let t=GK(n.substring(4)).toString(16);for(;t.length<40;)t="0"+t;return sv("0x"+t)}K(!1,"invalid address","address",n)}function VK(n){const t=Pe(n.from);let r=Nt(n.nonce,"tx.nonce").toString(16);return r==="0"?r="0x":r.length%2?r="0x0"+r:r="0x"+r,Pe(bn(kn(pc([t,r])),12))}function Nk(n){return n&&typeof n.getAddress=="function"}async function om(n,t){const e=await t;return(e==null||e==="0x0000000000000000000000000000000000000000")&&(ht(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),K(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),Pe(e)}function yr(n,t){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?Pe(n):(ht(t!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),om(n,t.resolveName(n)));if(Nk(n))return om(n,n.getAddress());if(n&&typeof n.then=="function")return om(n,n);K(!1,"unsupported addressable value","target",n)}const ys={};function St(n,t){let e=!1;return t<0&&(e=!0,t*=-1),new ar(ys,`${e?"":"u"}int${t}`,n,{signed:e,width:t})}function we(n,t){return new ar(ys,`bytes${t||""}`,n,{size:t})}const av=Symbol.for("_ethers_typed");var Fa;const ms=class ms{constructor(t,e,r,i){Z(this,"type");Z(this,"value");nt(this,Fa);Z(this,"_typedSymbol");i==null&&(i=null),Bp(ys,t,"Typed"),$t(this,{_typedSymbol:av,type:e,value:r}),$(this,Fa,i),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(t=>t.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return T(this,Fa)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return T(this,Fa)===!0?-1:T(this,Fa)===!1?this.value.length:null}static from(t,e){return new ms(ys,t,e)}static uint8(t){return St(t,8)}static uint16(t){return St(t,16)}static uint24(t){return St(t,24)}static uint32(t){return St(t,32)}static uint40(t){return St(t,40)}static uint48(t){return St(t,48)}static uint56(t){return St(t,56)}static uint64(t){return St(t,64)}static uint72(t){return St(t,72)}static uint80(t){return St(t,80)}static uint88(t){return St(t,88)}static uint96(t){return St(t,96)}static uint104(t){return St(t,104)}static uint112(t){return St(t,112)}static uint120(t){return St(t,120)}static uint128(t){return St(t,128)}static uint136(t){return St(t,136)}static uint144(t){return St(t,144)}static uint152(t){return St(t,152)}static uint160(t){return St(t,160)}static uint168(t){return St(t,168)}static uint176(t){return St(t,176)}static uint184(t){return St(t,184)}static uint192(t){return St(t,192)}static uint200(t){return St(t,200)}static uint208(t){return St(t,208)}static uint216(t){return St(t,216)}static uint224(t){return St(t,224)}static uint232(t){return St(t,232)}static uint240(t){return St(t,240)}static uint248(t){return St(t,248)}static uint256(t){return St(t,256)}static uint(t){return St(t,256)}static int8(t){return St(t,-8)}static int16(t){return St(t,-16)}static int24(t){return St(t,-24)}static int32(t){return St(t,-32)}static int40(t){return St(t,-40)}static int48(t){return St(t,-48)}static int56(t){return St(t,-56)}static int64(t){return St(t,-64)}static int72(t){return St(t,-72)}static int80(t){return St(t,-80)}static int88(t){return St(t,-88)}static int96(t){return St(t,-96)}static int104(t){return St(t,-104)}static int112(t){return St(t,-112)}static int120(t){return St(t,-120)}static int128(t){return St(t,-128)}static int136(t){return St(t,-136)}static int144(t){return St(t,-144)}static int152(t){return St(t,-152)}static int160(t){return St(t,-160)}static int168(t){return St(t,-168)}static int176(t){return St(t,-176)}static int184(t){return St(t,-184)}static int192(t){return St(t,-192)}static int200(t){return St(t,-200)}static int208(t){return St(t,-208)}static int216(t){return St(t,-216)}static int224(t){return St(t,-224)}static int232(t){return St(t,-232)}static int240(t){return St(t,-240)}static int248(t){return St(t,-248)}static int256(t){return St(t,-256)}static int(t){return St(t,-256)}static bytes1(t){return we(t,1)}static bytes2(t){return we(t,2)}static bytes3(t){return we(t,3)}static bytes4(t){return we(t,4)}static bytes5(t){return we(t,5)}static bytes6(t){return we(t,6)}static bytes7(t){return we(t,7)}static bytes8(t){return we(t,8)}static bytes9(t){return we(t,9)}static bytes10(t){return we(t,10)}static bytes11(t){return we(t,11)}static bytes12(t){return we(t,12)}static bytes13(t){return we(t,13)}static bytes14(t){return we(t,14)}static bytes15(t){return we(t,15)}static bytes16(t){return we(t,16)}static bytes17(t){return we(t,17)}static bytes18(t){return we(t,18)}static bytes19(t){return we(t,19)}static bytes20(t){return we(t,20)}static bytes21(t){return we(t,21)}static bytes22(t){return we(t,22)}static bytes23(t){return we(t,23)}static bytes24(t){return we(t,24)}static bytes25(t){return we(t,25)}static bytes26(t){return we(t,26)}static bytes27(t){return we(t,27)}static bytes28(t){return we(t,28)}static bytes29(t){return we(t,29)}static bytes30(t){return we(t,30)}static bytes31(t){return we(t,31)}static bytes32(t){return we(t,32)}static address(t){return new ms(ys,"address",t)}static bool(t){return new ms(ys,"bool",!!t)}static bytes(t){return new ms(ys,"bytes",t)}static string(t){return new ms(ys,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new ms(ys,"overrides",Object.assign({},t))}static isTyped(t){return t&&typeof t=="object"&&"_typedSymbol"in t&&t._typedSymbol===av}static dereference(t,e){if(ms.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}};Fa=new WeakMap;let ar=ms;class KK extends Ys{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=ar.dereference(e,"string");try{r=Pe(r)}catch(i){return this._throwError(i.message,e)}return t.writeValue(r)}decode(t){return Pe(Xo(t.readValue(),20))}}class jK extends Ys{constructor(e){super(e.name,e.type,"_",e.dynamic);Z(this,"coder");this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,r){return this.coder.encode(e,r)}decode(e){return this.coder.decode(e)}}function Ck(n,t,e){let r=[];if(Array.isArray(e))r=e;else if(e&&typeof e=="object"){let u={};r=t.map(f=>{const h=f.localName;return ht(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:f},value:e}),ht(!u[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:f},value:e}),u[h]=!0,e[h]})}else K(!1,"invalid tuple value","tuple",e);K(t.length===r.length,"types/value length mismatch","tuple",e);let i=new ow,s=new ow,o=[];t.forEach((u,f)=>{let h=r[f];if(u.dynamic){let y=s.length;u.encode(s,h);let A=i.writeUpdatableValue();o.push(b=>{A(b+y)})}else u.encode(i,h)}),o.forEach(u=>{u(i.length)});let c=n.appendWriter(i);return c+=n.appendWriter(s),c}function Bk(n,t){let e=[],r=[],i=n.subReader(0);return t.forEach(s=>{let o=null;if(s.dynamic){let c=n.readIndex(),u=i.subReader(c);try{o=s.decode(u)}catch(f){if(Wn(f,"BUFFER_OVERRUN"))throw f;o=f,o.baseType=s.name,o.name=s.localName,o.type=s.type}}else try{o=s.decode(n)}catch(c){if(Wn(c,"BUFFER_OVERRUN"))throw c;o=c,o.baseType=s.name,o.name=s.localName,o.type=s.type}if(o==null)throw new Error("investigate");e.push(o),r.push(s.localName||null)}),dl.fromItems(e,r)}class WK extends Ys{constructor(e,r,i){const s=e.type+"["+(r>=0?r:"")+"]",o=r===-1||e.dynamic;super("array",s,i,o);Z(this,"coder");Z(this,"length");$t(this,{coder:e,length:r})}defaultValue(){const e=this.coder.defaultValue(),r=[];for(let i=0;i<this.length;i++)r.push(e);return r}encode(e,r){const i=ar.dereference(r,"array");Array.isArray(i)||this._throwError("expected array value",i);let s=this.length;s===-1&&(s=i.length,e.writeValue(i.length)),zI(i.length,s,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let c=0;c<i.length;c++)o.push(this.coder);return Ck(e,o,i)}decode(e){let r=this.length;r===-1&&(r=e.readIndex(),ht(r*gr<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:r*gr,length:e.dataLength}));let i=[];for(let s=0;s<r;s++)i.push(new jK(this.coder));return Bk(e,i)}}class ZK extends Ys{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=ar.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class Pk extends Ys{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=fr(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class qK extends Pk{constructor(t){super("bytes",t)}decode(t){return kt(super.decode(t))}}class QK extends Ys{constructor(e,r){let i="bytes"+String(e);super(i,i,r,!1);Z(this,"size");$t(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,r){let i=fr(ar.dereference(r,this.type));return i.length!==this.size&&this._throwError("incorrect data length",r),e.writeBytes(i)}decode(e){return kt(e.readBytes(this.size))}}const JK=new Uint8Array([]);class YK extends Ys{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return e!=null&&this._throwError("not null",e),t.writeBytes(JK)}decode(t){return t.readBytes(0),null}}const XK=BigInt(0),tj=BigInt(1),ej=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class nj extends Ys{constructor(e,r,i){const s=(r?"int":"uint")+e*8;super(s,s,i,!1);Z(this,"size");Z(this,"signed");$t(this,{size:e,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,r){let i=Nt(ar.dereference(r,this.type)),s=Rf(ej,gr*8);if(this.signed){let o=Rf(s,this.size*8-1);(i>o||i<-(o+tj))&&this._throwError("value out-of-bounds",r),i=KI(i,8*gr)}else(i<XK||i>Rf(s,this.size*8))&&this._throwError("value out-of-bounds",r);return e.writeValue(i)}decode(e){let r=Rf(e.readValue(),this.size*8);return this.signed&&(r=XG(r,this.size*8)),r}}class rj extends Pk{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,Vs(ar.dereference(e,"string")))}decode(t){return T0(super.decode(t))}}class Fd extends Ys{constructor(e,r){let i=!1;const s=[];e.forEach(c=>{c.dynamic&&(i=!0),s.push(c.type)});const o="tuple("+s.join(",")+")";super("tuple",o,r,i);Z(this,"coders");$t(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach(i=>{e.push(i.defaultValue())});const r=this.coders.reduce((i,s)=>{const o=s.localName;return o&&(i[o]||(i[o]=0),i[o]++),i},{});return this.coders.forEach((i,s)=>{let o=i.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),e[o]==null&&(e[o]=e[s]))}),Object.freeze(e)}encode(e,r){const i=ar.dereference(r,"tuple");return Ck(e,this.coders,i)}decode(e){return Bk(e,this.coders)}}function gc(n){return kn(Vs(n))}var ij="AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3YQZtAm0A+VEfAzEJDQBRSQCzAQBlAHsAM70GD/v3IZWHBwARKQAxALsjTwHZAeMPEzmXgIHwABIAGQA8AEUAQDt3gdvIEGcQZAkGTRFMdEIVEwK0D64L7REdDNkq09PgADSxB/MDWwfzA1sDWwfzB/MDWwfzA1sDWwNbA1scEvAi28gQZw9QBHUFlgWTBN4IiyZREYkHMAjaVBV0JhxPA00BBCMtSSQ7mzMTJUpMFE0LCAQ2SmyvfUADTzGzVP2QqgPTMlc5dAkGHnkSqAAyD3skNb1OhnpPcagKU0+2tYdJak5vAsY6sEAACikJm2/Dd1YGRRAfJ6kQ+ww3AbkBPw3xS9wE9QY/BM0fgRkdD9GVoAipLeEM8SbnLqWAXiP5KocF8Uv4POELUVFsD10LaQnnOmeBUgMlAREijwrhDT0IcRD3Cs1vDekRSQc9A9lJngCpBwULFR05FbkmFGKwCw05ewb/GvoLkyazEy17AAXXGiUGUQEtGwMA0y7rhbRaNVwgT2MGBwspI8sUrFAkDSlAu3hMGh8HGSWtApVDdEqLUToelyH6PEENai4XUYAH+TwJGVMLhTyiRq9FEhHWPpE9TCJNTDAEOYMsMyePCdMPiQy9fHYBXQklCbUMdRM1ERs3yQg9Bx0xlygnGQglRplgngT7owP3E9UDDwVDCUUHFwO5HDETMhUtBRGBKNsC9zbZLrcCk1aEARsFzw8pH+MQVEfkDu0InwJpA4cl7wAxFSUAGyKfCEdnAGOP3FMJLs8Iy2pwI3gDaxTrZRF3B5UOWwerHDcVwxzlcMxeD4YMKKezCV8BeQmdAWME5wgNNV+MpCBFZ1eLXBifIGVBQ14AAjUMaRWjRMGHfAKPD28SHwE5AXcHPQ0FAnsR8RFvEJkI74YINbkz/DopBFMhhyAVCisDU2zSCysm/Qz8bQGnEmYDEDRBd/Jnr2C6KBgBBx0yyUFkIfULlk/RDKAaxRhGVDIZ6AfDA/ca9yfuQVsGAwOnBxc6UTPyBMELbQiPCUMATQ6nGwfbGG4KdYzUATWPAbudA1uVhwJzkwY7Bw8Aaw+LBX3pACECqwinAAkA0wNbAD0CsQehAB0AiUUBQQMrMwEl6QKTA5cINc8BmTMB9y0EH8cMGQD7O25OAsO1AoBuZqYF4VwCkgJNOQFRKQQJUktVA7N15QDfAE8GF+NLARmvTs8e50cB43MvAMsA/wAJOQcJRQHRAfdxALsBYws1Caa3uQFR7S0AhwAZbwHbAo0A4QA5AIP1AVcAUQVd/QXXAlNNARU1HC9bZQG/AyMBNwERAH0Gz5GpzQsjBHEH1wIQHxXlAu8yB7kFAyLjE9FCyQK94lkAMhoKPAqrCqpgX2Q3CjV2PVQAEh+sPss/UgVVO1c7XDtXO1w7VztcO1c7XDtXO1wDm8Pmw+YKcF9JYe8Mqg3YRMw6TRPfYFVgNhPMLbsUxRXSJVoZQRrAJwkl6FUNDwgt12Y0CDA0eRfAAEMpbINFY4oeNApPHOtTlVT8LR8AtUumM7MNsBsZREQFS3XxYi4WEgomAmSFAmJGX1GzAV83JAKh+wJonAJmDQKfiDgfDwJmPwJmKgRyBIMDfxcDfpY5Cjl7GzmGOicnAmwhAjI6OA4CbcsCbbLzjgM3a0kvAWsA4gDlAE4JB5wMkQECD8YAEbkCdzMCdqZDAnlPRwJ4viFg30WyRvcCfEMCeswCfQ0CfPRIBEiBZygALxlJXEpfGRtK0ALRBQLQ0EsrA4hTA4fqRMmRNgLypV0HAwOyS9JMMSkH001QTbMCi0MCitzFHwshR2sJuwKOOwKOYESbhQKO3QKOYHxRuFM5AQ5S2FSJApP/ApMQAO0AIFUiVbNV1AosHymZijLleGpFPz0Cl6MC77ZYJawAXSkClpMCloCgAK1ZsFoNhVEAPwKWuQKWUlxIXNUCmc8CmWhczl0LHQKcnznGOqECnBoCn58CnryOACETNS4TAp31Ap6WALlBYThh8wKe1wKgcgGtAp6jIwKeUqljzGQrKS8CJ7MCJoICoP8CoFDbAqYzAqXSAqgDAIECp/ZogGi1AAdNaiBq1QKs5wKssgKtawKtBgJXIQJV4AKx5dsDH1JsmwKywRECsuwbbORtZ21MYwMl0QK2YD9DbpQDKUkCuGICuUsZArkue3A6cOUCvR0DLbYDMhUCvoxyBgMzdQK+HnMmc1MCw88CwwhzhnRPOUl05AM8qwEDPJ4DPcMCxYACxksCxhSNAshtVQLISALJUwLJMgJkoQLd1nh9ZXiyeSlL1AMYp2cGAmH4GfeVKHsPXpZevxUCz28Cz3AzT1fW9xejAMqxAs93AS3uA04Wfk8JAtwrAtuOAtJTA1JgA1NjAQUDVZCAjUMEzxrxZEl5A4LSg5EC2ssC2eKEFIRNp0ADhqkAMwNkEoZ1Xf0AWQLfaQLevHd7AuIz7RgB8zQrAfSfAfLWiwLr9wLpdH0DAur9AuroAP1LAb0C7o0C66CWrpcHAu5DA4XkmH1w5HGlAvMHAG0DjhqZlwL3FwORcgOSiwL3nAL53QL4apogmq+/O5siA52HAv7+AR8APZ8gAZ+3AwWRA6ZuA6bdANXJAwZuoYyiCQ0DDE0BEwEjB3EGZb1rCQC/BG/DFY8etxEAG3k9ACcDNxJRA42DAWcrJQCM8wAlAOanC6OVCLsGI6fJBgCvBRnDBvElRUYFFoAFcD9GSDNCKUK8X3kZX8QAls0FOgCQVCGbwTsuYDoZutcONxjOGJHJ/gVfBWAFXwVgBWsFYAVfBWAFXwVgBV8FYAVfBWBOHQjfjW8KCgoKbF7xMwTRA7kGN8PDAMMEr8MA70gxFroFTj5xPnhCR0K+X30/X/AAWBkzswCNBsxzzASm70aCRS4rDDMeLz49fnXfcsH5GcoscQFz13Y4HwVnBXLJycnACNdRYwgICAqEXoWTxgA7P4kACxbZBu21Kw0AjMsTAwkVAOVtJUUsJ1JCuULESUArXy9gPi9AKwnJRQYKTD9LPoA+iT54PnkCkULEUUpDX9NWV3JVEjQAc1w3A3IBE3YnX+g7QiMJb6MKaiszRCUuQrNCxDPMCcwEX9EWJzYREBEEBwIHKn6l33JCNVIfybPJtAltydPUCmhBZw/tEKsZAJOVJU1CLRuxbUHOQAo7P0s+eEJHHA8SJVRPdGM0NVrpvBoKhfUlM0JHHGUQUhEWO1xLSj8MO0ucNAqJIzVCRxv9EFsqKyA4OQgNj2nwZgp5ZNFgE2A1K3YHS2AhQQojJmC7DgpzGG1WYFUZCQYHZO9gHWCdYIVgu2BTYJlwFh8GvRbcXbG8YgtDHrMBwzPVyQonHQgkCyYBgQJ0Ajc4nVqIAwGSCsBPIgDsK3SWEtIVBa5N8gGjAo+kVwVIZwD/AEUSCDweX4ITrRQsJ8K3TwBXFDwEAB0TvzVcAtoTS20RIwDgVgZ9BBImYgA5AL4Coi8LFnezOkCnIQFjAY4KBAPh9RcGsgZSBsEAJctdsWIRu2kTkQstRw7DAcMBKgpPBGIGMDAwKCYnKTQaLg4AKRSVAFwCdl+YUZ0JdicFD3lPAdt1F9ZZKCGxuE3yBxkFVGcA/wBFEgiCBwAOLHQSjxOtQDg1z7deFRMAZ8QTAGtKb1ApIiPHADkAvgKiLy1DFtYCmBiDAlDDWNB0eo7fpaMO/aEVRRv0ATEQZBIODyMEAc8JQhCbDRgzFD4TAEMAu9YBCgCsAOkAm5I3ABwAYxvONnR+MhXJAxgKQyxL2+kkJhMbhQKDBMkSsvF0AD9BNQ6uQC7WqSQHwxEAEEIu1hkhAH2z4iQPwyJPHNWpdyYBRSpnJALzoBAEVPPsH20MxA0CCEQKRgAFyAtFAlMNwwjEDUQJRArELtapMg7DDZgJIw+TGukEIwvDFkMAqAtDEMMMBhioe+QAO3MMRAACrgnEBSPY9Q0FDnbSBoMAB8MSYxkSxAEJAPIJAAB8FWMOFtMc/HcXwxhDAC7DAvOowwAewwJdKDKHAAHDAALrFUQVwwAbwyvzpWMWv8wA/ABpAy++bcYDUKPD0KhDCwKmJ1MAAmMA5+UZwxAagwipBRL/eADfw6fDGOMCGsOjk3l6BwOpo4sAEsMOGxMAA5sAbcMOAAvDp0MJGkMDwgipnNIPAwfIqUMGAOGDAAPzABXDAAcDAAnDAGmTABrDAA7DChjDjnEWAwABYwAOcwAuUyYABsMAF8MIKQANUgC6wy4AA8MADqMq8wCyYgAcIwAB8wqpAAXOCx0V4wAHowBCwwEKAGnDAAuDAB3DAAjDCakABdIAbqcZ3QCZCCkABdIAAAFDAAfjAB2jCCkABqIACYMAGzMAbSMA5sOIAAhjAAhDABTDBAkpAAbSAOOTAAlDC6kOzPtnAAdDAG6kQFAATwAKwwwAA0MACbUDPwAHIwAZgwACE6cDAAojAApDAAoDp/MGwwAJIwADEwAQQwgAFEMAEXMAD5MADfMADcMAGRMOFiMAFUMAbqMWuwHDAMIAE0MLAGkzEgDhUwACQwAEWgAXgwUjAAbYABjDBSYBgzBaAEFNALcQBxUMegAwMngBrA0IZgJ0KxQHBREPd1N0ZzKRJwaIHAZqNT4DqQq8BwngAB4DAwt2AX56T1ocKQNXAh1GATQGC3tOxYNagkgAMQA5CQADAQEAWxLjAIOYNAEzAH7tFRk6TglSAF8NAAlYAQ+S1ACAQwQorQBiAN4dAJ1wPyeTANVzuQDX3AIeEMp9eyMgXiUAEdkBkJizKltbVVAaRMqRAAEAhyQ/SDEz6BmfVwB6ATEsOClKIRcDOF0E/832AFNt5AByAnkCRxGCOs94NjXdAwINGBonDBwPALW2AwICAgAAAAAAAAYDBQMDARrUAwAtAAAAAgEGBgYGBgYFBQUFBQUEBQYHCAkEBQUFBQQAAAICAAAAIgCNAJAAlT0A6gC7ANwApEQAwgCyAK0AqADuAKYA2gCjAOcBCAEDAMcAgQBiANIA1AEDAN4A8gCQAKkBMQDqAN8A3AsBCQ8yO9ra2tq8xuLT1tRJOB0BUgFcNU0BWgFpAWgBWwFMUUlLbhMBUxsNEAs6PhMOACcUKy0vMj5AQENDQ0RFFEYGJFdXV1dZWVhZL1pbXVxcI2NnZ2ZoZypsbnZ1eHh4eHh4enp6enp6enp6enp8fH18e2IARPIASQCaAHgAMgBm+ACOAFcAVwA3AnbvAIsABfj4AGQAk/IAnwBPAGIAZP//sACFAIUAaQBWALEAJAC2AIMCQAJDAPwA5wD+AP4A6AD/AOkA6QDoAOYALwJ7AVEBQAE+AVQBPgE+AT4BOQE4ATgBOAEcAVgXADEQCAEAUx8SHgsdHhYAjgCWAKYAUQBqIAIxAHYAbwCXAxUDJzIDIUlGTzEAkQJPAMcCVwKkAMAClgKWApYClgKWApYCiwKWApYClgKWApYClgKVApUCmAKgApcClgKWApQClAKUApQCkgKVAnUB1AKXAp8ClgKWApUeAIETBQD+DQOfAmECOh8BVBg9AuIZEjMbAU4/G1WZAXusRAFpYQEFA0FPAQYAmTEeIJdyADFoAHEANgCRA5zMk/C2jGINwjMWygIZCaXdfDILBCs5dAE7YnQBugDlhoiHhoiGiYqKhouOjIaNkI6Ij4qQipGGkoaThpSSlYaWhpeKmIaZhpqGm4aci52QnoqfhuIC4XTpAt90AIp0LHSoAIsAdHQEQwRABEIERQRDBEkERgRBBEcESQRIBEQERgRJAJ5udACrA490ALxuAQ10ANFZdHQA13QCFHQA/mJ0AP4BIQD+APwA/AD9APwDhGZ03ASMK23HAP4A/AD8AP0A/CR0dACRYnQA/gCRASEA/gCRAvQA/gCRA4RmdNwEjCttxyR0AP9idAEhAP4A/gD8APwA/QD8AP8A/AD8AP0A/AOEZnTcBIwrbcckdHQAkWJ0ASEA/gCRAP4AkQL0AP4AkQOEZnTcBIwrbcckdAJLAT50AlIBQXQCU8l0dAJfdHQDpgL0A6YDpgOnA6cDpwOnA4RmdNwEjCttxyR0dACRYnQBIQOmAJEDpgCRAvQDpgCRA4RmdNwEjCttxyR0BDh0AJEEOQCRDpU5dSgCADR03gV2CwArdAEFAM5iCnR0AF1iAAYcOgp0dACRCnQAXAEIwWZ0CnRmdHQAkWZ0CnRmdEXgAFF03gp0dEY0tlT2u3SOAQTwscwhjZZKrhYcBSfFp9XNbKiVDOD2b+cpe4/Z17mQnbtzzhaeQtE2GGj0IDNTjRUSyTxxw/RPHW/+vS7d1NfRt9z9QPZg4X7QFfhCnkvgNPIItOsC2eV6hPannZNHlZ9xrwZXIMOlu3jSoQSq78WEjwLjw1ELSlF1aBvfzwk5ZX7AUvQzjPQKbDuQ+sm4wNOp4A6AdVuRS0t1y/DZpg4R6m7FNjM9HgvW7Bi88zaMjOo6lM8wtBBdj8LP4ylv3zCXPhebMKJc066o9sF71oFW/8JXu86HJbwDID5lzw5GWLR/LhT0Qqnp2JQxNZNfcbLIzPy+YypqRm/lBmGmex+82+PisxUumSeJkALIT6rJezxMH+CTJmQtt5uwTVbL3ptmjDUQzlSIvWi8Tl7ng1NpuRn1Ng4n14Qc+3Iil7OwkvNWogLSPkn3pihIFytyIGmMhOe3n1tWsuMy9BdKyqF4Z3v2SgggTL9KVvMXPnCbRe+oOuFFP3HejBG/w9gvmfNYvg6JuWia2lcSSN1uIjBktzoIazOHPJZ7kKHPz8mRWVdW3lA8WGF9dQF6Bm673boov3BUWDU2JNcahR23GtfHKLOz/viZ+rYnZFaIznXO67CYEJ1fXuTRpZhYZkKe54xeoagkNGLs+NTZHE0rX45/XvQ2RGADX6vcAvdxIUBV27wxGm2zjZo4X3ILgAlrOFheuZ6wtsvaIj4yLY7qqawlliaIcrz2G+c3vscAnCkCuMzMmZvMfu9lLwTvfX+3cVSyPdN9ZwgDZhfjRgNJcLiJ67b9xx8JHswprbiE3v9UphotAPIgnXVIN5KmMc0piXhc6cChPnN+MRhG9adtdttQTTwSIpl8I4/j//d3sz1326qTBTpPRM/Hgh3kzqEXs8ZAk4ErQhNO8hzrQ0DLkWMA/N+91tn2MdOJnWC2FCZehkQrwzwbKOjhvZsbM95QoeL9skYyMf4srVPVJSgg7pOLUtr/n9eT99oe9nLtFRpjA9okV2Kj8h9k5HaC0oivRD8VyXkJ81tcd4fHNXPCfloIQasxsuO18/46dR2jgul/UIet2G0kRvnyONMKhHs6J26FEoqSqd+rfYjeEGwHWVDpX1fh1jBBcKGMqRepju9Y00mDVHC+Xdij/j44rKfvfjGinNs1jO/0F3jB83XCDINN/HB84axlP+3E/klktRo+vl3U/aiyMJbIodE1XSsDn6UAzIoMtUObY2+k/4gY/l+AkZJ5Sj2vQrkyLm3FoxjhDX+31UXBFf9XrAH31fFqoBmDEZvhvvpnZ87N+oZEu7U9O/nnk+QWj3x8uyoRbEnf+O5UMr9i0nHP38IF5AvzrBW8YWBUR0mIAzIvndQq9N3v/Jto3aPjPXUPl8ASdPPyAp7jENf8bk7VMM9ol9XGmlBmeDMuGqt+WzuL6CXAxXjIhCPM5vACchgMJ/8XBGLO/D1isVvGhwwHHr1DLaI5mn2Jr/b1pUD90uciDaS8cXNDzCWvNmT/PhQe5e8nTnnnkt8Ds/SIjibcum/fqDhKopxAY8AkSrPn+IGDEKOO+U3XOP6djFs2H5N9+orhOahiQk5KnEUWa+CzkVzhp8bMHRbg81qhjjXuIKbHjSLSIBKWqockGtKinY+z4/RdBUF6pcc3JmnlxVcNgrI4SEzKUZSwcD2QCyxzKve+gAmg6ZuSRkpPFa6mfThu7LJNu3H5K42uCpNvPAsoedolKV/LHe/eJ+BbaG5MG0NaSGVPRUmNFMFFSSpXEcXwbVh7UETOZZtoVNRGOIbbkig3McEtR68cG0RZAoJevWYo7Dg/lZ1CQzblWeUvVHmr8fY4Nqd9JJiH/zEX24mJviH60fAyFr0A3c4bC1j3yZU60VgJxXn8JgJXLUIsiBnmKmMYz+7yBQFBvqb2eYnuW59joZBf56/wXvWIR4R8wTmV80i1mZy+S4+BUES+hzjk0uXpC///z/IlqHZ1monzlXp8aCfhGKMti73FI1KbL1q6IKO4fuBuZ59gagjn5xU79muMpHXg6S+e+gDM/U9BKLHbl9l6o8czQKl4RUkJJiqftQG2i3BMg/TQlUYFkJDYBOOvAugYuzYSDnZbDDd/aSd9x0Oe6F+bJcHfl9+gp6L5/TgA+BdFFovbfCrQ40s5vMPw8866pNX8zyFGeFWdxIpPVp9Rg1UPOVFbFZrvaFq/YAzHQgqMWpahMYfqHpmwXfHL1/kpYmGuHFwT55mQu0dylfNuq2Oq0hTMCPwqfxnuBIPLXfci4Y1ANy+1CUipQxld/izVh16WyG2Q0CQQ9NqtAnx1HCHwDj7sYxOSB0wopZSnOzxQOcExmxrVTF2BkOthVpGfuhaGECfCJpJKpjnihY+xOT2QJxN61+9K6QSqtv2Shr82I3jgJrqBg0wELFZPjvHpvzTtaJnLK6Vb97Yn933koO/saN7fsjwNKzp4l2lJVx2orjCGzC/4ZL4zCver6aQYtC5sdoychuFE6ufOiog+VWi5UDkbmvmtah/3aArEBIi39s5ILUnlFLgilcGuz9CQshEY7fw2ouoILAYPVT/gyAIq3TFAIwVsl+ktkRz/qGfnCDGrm5gsl/l9QdvCWGsjPz3dU7XuqKfdUrr/6XIgjp4rey6AJBmCmUJMjITHVdFb5m1p+dLMCL8t55zD42cmftmLEJC0Da04YiRCVUBLLa8D071/N5UBNBXDh0LFsmhV/5B5ExOB4j3WVG/S3lfK5o+V6ELHvy6RR9n4ac+VsK4VE4yphPvV+kG9FegTBH4ZRXL2HytUHCduJazB/KykjfetYxOXTLws267aGOd+I+JhKP//+VnXmS90OD/jvLcVu0asyqcuYN1mSb6XTlCkqv1vigZPIYwNF/zpWcT1GR/6aEIRjkh0yhg4LXJfaGobYJTY4JI58KiAKgmmgAKWdl5nYCeLqavRJGQNuYuZtZFGx+IkI4w4NS2xwbetNMunOjBu/hmKCI/w7tfiiyUd//4rbTeWt4izBY8YvGIN6vyKYmP/8X8wHKCeN+WRcKM70+tXKNGyevU9H2Dg5BsljnTf8YbsJ1TmMs74Ce2XlHisleguhyeg44rQOHZuw/6HTkhnnurK2d62q6yS7210SsAIaR+jXMQA+svkrLpsUY+F30Uw89uOdGAR6vo4FIME0EfVVeHTu6eKicfhSqOeXJhbftcd08sWEnNUL1C9fnprTgd83IMut8onVUF0hvqzZfHduPjbjwEXIcoYmy+P6tcJZHmeOv6VrvEdkHDJecjHuHeWANe79VG662qTjA/HCvumVv3qL+LrOcpqGps2ZGwQdFJ7PU4iuyRlBrwfO+xnPyr47s2cXVbWzAyznDiBGjCM3ksxjjqM62GE9C8f5U38kB3VjtabKp/nRdvMESPGDG90bWRLAt1Qk5DyLuazRR1YzdC1c+hZXvAWV8xA72S4A8B67vjVhbba3MMop293FeEXpe7zItMWrJG/LOH9ByOXmYnNJfjmfuX9KbrpgLOba4nZ+fl8Gbdv/ihv+6wFGKHCYrVwmhFC0J3V2bn2tIB1wCc1CST3d3X2OyxhguXcs4sm679UngzofuSeBewMFJboIQHbUh/m2JhW2hG9DIvG2t7yZIzKBTz9wBtnNC+2pCRYhSIuQ1j8xsz5VvqnyUIthvuoyyu7fNIrg/KQUVmGQaqkqZk/Vx5b33/gsEs8yX7SC1J+NV4icz6bvIE7C5G6McBaI8rVg56q5QBJWxn/87Q1sPK4+sQa8fLU5gXo4paaq4cOcQ4wR0VBHPGjKh+UlPCbA1nLXyEUX45qZ8J7/Ln4FPJE2TdzD0Z8MLSNQiykMMmSyOCiFfy84Rq60emYB2vD09KjYwsoIpeDcBDTElBbXxND72yhd9pC/1CMid/5HUMvAL27OtcIJDzNKpRPNqPOpyt2aPGz9QWIs9hQ9LiX5s8m9hjTUu/f7MyIatjjd+tSfQ3ufZxPpmJhTaBtZtKLUcfOCUqADuO+QoH8B9v6U+P0HV1GLQmtoNFTb3s74ivZgjES0qfK+8RdGgBbcCMSy8eBvh98+et1KIFqSe1KQPyXULBMTsIYnysIwiZBJYdI20vseV+wuJkcqGemehKjaAb9L57xZm3g2zX0bZ2xk/fU+bCo7TlnbW7JuF1YdURo/2Gw7VclDG1W7LOtas2LX4upifZ/23rzpsnY/ALfRgrcWP5hYmV9VxVOQA1fZvp9F2UNU+7d7xRyVm5wiLp3/0dlV7vdw1PMiZrbDAYzIVqEjRY2YU03sJhPnlwIPcZUG5ltL6S8XCxU1eYS5cjr34veBmXAvy7yN4ZjArIG0dfD/5UpBNlX1ZPoxJOwyqRi3wQWtOzd4oNKh0LkoTm8cwqgIfKhqqGOhwo71I+zXnMemTv2B2AUzABWyFztGgGULjDDzWYwJUVBTjKCn5K2QGMK1CQT7SzziOjo+BhAmqBjzuc3xYym2eedGeOIRJVyTwDw37iCMe4g5Vbnsb5ZBdxOAnMT7HU4DHpxWGuQ7GeiY30Cpbvzss55+5Km1YsbD5ea3NI9QNYIXol5apgSu9dZ8f8xS5dtHpido5BclDuLWY4lhik0tbJa07yJhH0BOyEut/GRbYTS6RfiTYWGMCkNpfSHi7HvdiTglEVHKZXaVhezH4kkXiIvKopYAlPusftpE4a5IZwvw1x/eLvoDIh/zpo9FiQInsTb2SAkKHV42XYBjpJDg4374XiVb3ws4qM0s9eSQ5HzsMU4OZJKuopFjBM+dAZEl8RUMx5uU2N486Kr141tVsGQfGjORYMCJAMsxELeNT4RmWjRcpdTGBwcx6XN9drWqPmJzcrGrH4+DRc7+n1w3kPZwu0BkNr6hQrqgo7JTB9A5kdJ/H7P4cWBMwsmuixAzJB3yrQpnGIq90lxAXLzDCdn1LPibsRt7rHNjgQBklRgPZ8vTbjXdgXrTWQsK5MdrXXQVPp0Rinq3frzZKJ0qD6Qhc40VzAraUXlob1gvkhK3vpmHgI6FRlQZNx6eRqkp0zy4AQlX813fAPtL3jMRaitGFFjo0zmErloC+h+YYdVQ6k4F/epxAoF0BmqEoKNTt6j4vQZNQ2BoqF9Vj53TOIoNmDiu9Xp15RkIgQIGcoLpfoIbenzpGUAtqFJp5W+LLnx38jHeECTJ/navKY1NWfN0sY1T8/pB8kIH3DU3DX+u6W3YwpypBMYOhbSxGjq84RZ84fWJow8pyHqn4S/9J15EcCMsXqrfwyd9mhiu3+rEo9pPpoJkdZqHjra4NvzFwuThNKy6hao/SlLw3ZADUcUp3w3SRVfW2rhl80zOgTYnKE0Hs2qp1J6H3xqPqIkvUDRMFDYyRbsFI3M9MEyovPk8rlw7/0a81cDVLmBsR2ze2pBuKb23fbeZC0uXoIvDppfTwIDxk1Oq2dGesGc+oJXWJLGkOha3CX+DUnzgAp9HGH9RsPZN63Hn4RMA5eSVhPHO+9RcRb/IOgtW31V1Q5IPGtoxPjC+MEJbVlIMYADd9aHYWUIQKopuPOHmoqSkubnAKnzgKHqgIOfW5RdAgotN6BN+O2ZYHkuemLnvQ8U9THVrS1RtLmKbcC7PeeDsYznvqzeg6VCNwmr0Yyx1wnLjyT84BZz3EJyCptD3yeueAyDWIs0L2qs/VQ3HUyqfrja0V1LdDzqAikeWuV4sc7RLIB69jEIBjCkyZedoUHqCrOvShVzyd73OdrJW0hPOuQv2qOoHDc9xVb6Yu6uq3Xqp2ZaH46A7lzevbxQEmfrzvAYSJuZ4WDk1Hz3QX1LVdiUK0EvlAGAYlG3Md30r7dcPN63yqBCIj25prpvZP0nI4+EgWoFG95V596CurXpKRBGRjQlHCvy5Ib/iW8nZJWwrET3mgd6mEhfP4KCuaLjopWs7h+MdXFdIv8dHQJgg1xi1eYqB0uDYjxwVmri0Sv5XKut/onqapC+FQiC2C1lvYJ9MVco6yDYsS3AANUfMtvtbYI2hfwZatiSsnoUeMZd34GVjkMMKA+XnjJpXgRW2SHTZplVowPmJsvXy6w3cfO1AK2dvtZEKTkC/TY9LFiKHCG0DnrMQdGm2lzlBHM9iEYynH2UcVMhUEjsc0oDBTgo2ZSQ1gzkAHeWeBXYFjYLuuf8yzTCy7/RFR81WDjXMbq2BOH5dURnxo6oivmxL3cKzKInlZkD31nvpHB9Kk7GfcfE1t+1V64b9LtgeJGlpRFxQCAqWJ5DoY77ski8gsOEOr2uywZaoO/NGa0X0y1pNQHBi3b2SUGNpcZxDT7rLbBf1FSnQ8guxGW3W+36BW0gBje4DOz6Ba6SVk0xiKgt+q2JOFyr4SYfnu+Ic1QZYIuwHBrgzr6UvOcSCzPTOo7D6IC4ISeS7zkl4h+2VoeHpnG/uWR3+ysNgPcOIXQbv0n4mr3BwQcdKJxgPSeyuP/z1Jjg4e9nUvoXegqQVIE30EHx5GHv+FAVUNTowYDJgyFhf5IvlYmEqRif6+WN1MkEJmDcQITx9FX23a4mxy1AQRsOHO/+eImX9l8EMJI3oPWzVXxSOeHU1dUWYr2uAA7AMb+vAEZSbU3qob9ibCyXeypEMpZ6863o6QPqlqGHZkuWABSTVNd4cOh9hv3qEpSx2Zy/DJMP6cItEmiBJ5PFqQnDEIt3NrA3COlOSgz43D7gpNFNJ5MBh4oFzhDPiglC2ypsNU4ISywY2erkyb1NC3Qh/IfWj0eDgZI4/ln8WPfBsT3meTjq1Uqt1E7Zl/qftqkx6aM9KueMCekSnMrcHj1CqTWWzEzPsZGcDe3Ue4Ws+XFYVxNbOFF8ezkvQGR6ZOtOLU2lQEnMBStx47vE6Pb7AYMBRj2OOfZXfisjJnpTfSNjo6sZ6qSvNxZNmDeS7Gk3yYyCk1HtKN2UnhMIjOXUzAqDv90lx9O/q/AT1ZMnit5XQe9wmQxnE/WSH0CqZ9/2Hy+Sfmpeg8RwsHI5Z8kC8H293m/LHVVM/BA7HaTJYg5Enk7M/xWpq0192ACfBai2LA/qrCjCr6Dh1BIMzMXINBmX96MJ5Hn2nxln/RXPFhwHxUmSV0EV2V0jm86/dxxuYSU1W7sVkEbN9EzkG0QFwPhyHKyb3t+Fj5WoUUTErcazE/N6EW6Lvp0d//SDPj7EV9UdJN+Amnf3Wwk3A0SlJ9Z00yvXZ7n3z70G47Hfsow8Wq1JXcfwnA+Yxa5mFsgV464KKP4T31wqIgzFPd3eCe3j5ory5fBF2hgCFyVFrLzI9eetNXvM7oQqyFgDo4CTp/hDV9NMX9JDHQ/nyHTLvZLNLF6ftn2OxjGm8+PqOwhxnPHWipkE/8wbtyri80Sr7pMNkQGMfo4ZYK9OcCC4ESVFFbLMIvlxSoRqWie0wxqnLfcLSXMSpMMQEJYDVObYsXIQNv4TGNwjq1kvT1UOkicTrG3IaBZ3XdScS3u8sgeZPVpOLkbiF940FjbCeNRINNvDbd01EPBrTCPpm12m43ze1bBB59Ia6Ovhnur/Nvx3IxwSWol+3H2qfCJR8df6aQf4v6WiONxkK+IqT4pKQrZK/LplgDI/PJZbOep8dtbV7oCr6CgfpWa8NczOkPx81iSHbsNhVSJBOtrLIMrL31LK9TqHqAbAHe0RLmmV806kRLDLNEhUEJfm9u0sxpkL93Zgd6rw+tqBfTMi59xqXHLXSHwSbSBl0EK0+loECOPtrl+/nsaFe197di4yUgoe4jKoAJDXc6DGDjrQOoFDWZJ9HXwt8xDrQP+7aRwWKWI1GF8s8O4KzxWBBcwnl3vnl1Oez3oh6Ea1vjR7/z7DDTrFtqU2W/KAEzAuXDNZ7MY73MF216dzdSbWmUp4lcm7keJfWaMHgut9x5C9mj66Z0lJ+yhsjVvyiWrfk1lzPOTdhG15Y7gQlXtacvI7qv/XNSscDwqkgwHT/gUsD5yB7LdRRvJxQGYINn9hTpodKFVSTPrtGvyQw+HlRFXIkodErAGu9Iy1YpfSPc3jkFh5CX3lPxv7aqjE/JAfTIpEjGb/H7MO0e2vsViSW1qa/Lmi4/n4DEI3g7lYrcanspDfEpKkdV1OjSLOy0BCUqVoECaB55vs06rXl4jqmLsPsFM/7vYJ0vrBhDCm/00A/H81l1uekJ/6Lml3Hb9+NKiLqATJmDpyzfYZFHumEjC662L0Bwkxi7E9U4cQA0XMVDuMYAIeLMPgQaMVOd8fmt5SflFIfuBoszeAw7ow5gXPE2Y/yBc/7jExARUf/BxIHQBF5Sn3i61w4z5xJdCyO1F1X3+3ax+JSvMeZ7S6QSKp1Fp/sjYz6Z+VgCZzibGeEoujryfMulH7Rai5kAft9ebcW50DyJr2uo2z97mTWIu45YsSnNSMrrNUuG1XsYBtD9TDYzQffKB87vWbkM4EbPAFgoBV4GQS+vtFDUqOFAoi1nTtmIOvg38N4hT2Sn8r8clmBCXspBlMBYTnrqFJGBT3wZOzAyJDre9dHH7+x7qaaKDOB4UQALD5ecS0DE4obubQEiuJZ0EpBVpLuYcce8Aa4PYd/V4DLDAJBYKQPCWTcrEaZ5HYbJi11Gd6hjGom1ii18VHYnG28NKpkz2UKVPxlhYSp8uZr367iOmoy7zsxehW9wzcy2zG0a80PBMCRQMb32hnaHeOR8fnNDzZhaNYhkOdDsBUZ3loDMa1YP0uS0cjUP3b/6DBlqmZOeNABDsLl5BI5QJups8uxAuWJdkUB/pO6Zax6tsg7fN5mjjDgMGngO+DPcKqiHIDbFIGudxtPTIyDi9SFMKBDcfdGQRv41q1AqmxgkVfJMnP8w/Bc7N9/TR6C7mGObFqFkIEom8sKi2xYqJLTCHK7cxzaZvqODo22c3wisBCP4HeAgcRbNPAsBkNRhSmD48dHupdBRw4mIvtS5oeF6zeT1KMCyhMnmhpkFAGWnGscoNkwvQ8ZM5lE/vgTHFYL99OuNxdFBxTEDd5v2qLR8y9WkXsWgG6kZNndFG+pO/UAkOCipqIhL3hq7cRSdrCq7YhUsTocEcnaFa6nVkhnSeRYUA1YO0z5itF9Sly3VlxYDw239TJJH6f3EUfYO5lb7bcFcz8Bp7Oo8QmnsUHOz/fagVUBtKEw1iT88j+aKkv8cscKNkMxjYr8344D1kFoZ7/td1W6LCNYN594301tUGRmFjAzeRg5vyoM1F6+bJZ/Q54jN/k8SFd3DxPTYaAUsivsBfgTn7Mx8H2SpPt4GOdYRnEJOH6jHM2p6SgB0gzIRq6fHxGMmSmqaPCmlfwxiuloaVIitLGN8wie2CDWhkzLoCJcODh7KIOAqbHEvXdUxaS4TTTs07Clzj/6GmVs9kiZDerMxEnhUB6QQPlcfqkG9882RqHoLiHGBoHfQuXIsAG8GTAtao2KVwRnvvam8jo1e312GQAKWEa4sUVEAMG4G6ckcONDwRcg1e2D3+ohXgY4UAWF8wHKQMrSnzCgfFpsxh+aHXMGtPQroQasRY4U6UdG0rz1Vjbka0MekOGRZQEvqQFlxseFor8zWFgHek3v29+WqN6gaK5gZOTOMZzpQIC1201LkMCXild3vWXSc5UX9xcFYfbRPzGFa1FDcPfPB/jUEq/FeGt419CI3YmBlVoHsa4KdcwQP5ZSwHHhFJ7/Ph/Rap/4vmG91eDwPP0lDfCDRCLszTqfzM71xpmiKi2HwS4WlqvGNwtvwF5Dqpn6KTq8ax00UMPkxDcZrEEEsIvHiUXXEphdb4GB4FymlPwBz4Gperqq5pW7TQ6/yNRhW8VT5NhuP0udlxo4gILq5ZxAZk8ZGh3g4CqxJlPKY7AQxupfUcVpWT5VItp1+30UqoyP4wWsRo3olRRgkWZZ2ZN6VC3OZFeXB8NbnUrSdikNptD1QiGuKkr8EmSR/AK9Rw+FF3s5uwuPbvHGiPeFOViltMK7AUaOsq9+x9cndk3iJEE5LKZRlWJbKOZweROzmPNVPkjE3K/TyA57Rs68TkZ3MR8akKpm7cFjnjPd/DdkWjgYoKHSr5Wu5ssoBYU4acRs5g2DHxUmdq8VXOXRbunD8QN0LhgkssgahcdoYsNvuXGUK/KXD/7oFb+VGdhqIn02veuM5bLudJOc2Ky0GMaG4W/xWBxIJcL7yliJOXOpx0AkBqUgzlDczmLT4iILXDxxtRR1oZa2JWFgiAb43obrJnG/TZC2KSK2wqOzRZTXavZZFMb1f3bXvVaNaK828w9TO610gk8JNf3gMfETzXXsbcvRGCG9JWQZ6+cDPqc4466Yo2RcKH+PILeKOqtnlbInR3MmBeGG3FH10yzkybuqEC2HSQwpA0An7d9+73BkDUTm30bZmoP/RGbgFN+GrCOfADgqr0WbI1a1okpFms8iHYw9hm0zUvlEMivBRxModrbJJ+9/p3jUdQQ9BCtQdxnOGrT5dzRUmw0593/mbRSdBg0nRvRZM5/E16m7ZHmDEtWhwvfdZCZ8J8M12W0yRMszXamWfQTwIZ4ayYktrnscQuWr8idp3PjT2eF/jmtdhIfcpMnb+IfZY2FebW6UY/AK3jP4u3Tu4zE4qlnQgLFbM19EBIsNf7KhjdbqQ/D6yiDb+NlEi2SKD+ivXVUK8ib0oBo366gXkR8ZxGjpJIDcEgZPa9TcYe0TIbiPl/rPUQDu3XBJ9X/GNq3FAUsKsll57DzaGMrjcT+gctp+9MLYXCq+sqP81eVQ0r9lt+gcQfZbACRbEjvlMskztZG8gbC8Qn9tt26Q7y7nDrbZq/LEz7kR6Jc6pg3N9rVX8Y5MJrGlML9p9lU4jbTkKqCveeZUJjHB03m2KRKR2TytoFkTXOLg7keU1s1lrPMQJpoOKLuAAC+y1HlJucU6ysB5hsXhvSPPLq5J7JtnqHKZ4vYjC4Vy8153QY+6780xDuGARsGbOs1WqzH0QS765rnSKEbbKlkO8oI/VDwUd0is13tKpqILu1mDJFNy/iJAWcvDgjxvusIT+PGz3ST/J9r9Mtfd0jpaGeiLYIqXc7DiHSS8TcjFVksi66PEkxW1z6ujbLLUGNNYnzOWpH8BZGK4bCK7iR+MbIv8ncDAz1u4StN3vTTzewr9IQjk9wxFxn+6N1ddKs0vffJiS08N3a4G1SVrlZ97Q/M+8G9fe5AP6d9/Qq4WRnORVhofPIKEdCr3llspUfE0oKIIYoByBRPh+bX1HLS3JWGJRhIvE1aW4NTd8ePi4Z+kXb+Z8snYfSNcqijhAgVsx4RCM54cXUiYkjeBmmC4ajOHrChoELscJJC7+9jjMjw5BagZKlgRMiSNYz7h7vvZIoQqbtQmspc0cUk1G/73iXtSpROl5wtLgQi0mW2Ex8i3WULhcggx6E1LMVHUsdc9GHI1PH3U2Ko0PyGdn9KdVOLm7FPBui0i9a0HpA60MsewVE4z8CAt5d401Gv6zXlIT5Ybit1VIA0FCs7wtvYreru1fUyW3oLAZ/+aTnZrOcYRNVA8spoRtlRoWflsRClFcgzkqiHOrf0/SVw+EpVaFlJ0g4Kxq1MMOmiQdpMNpte8lMMQqm6cIFXlnGbfJllysKDi+0JJMotkqgIxOSQgU9dn/lWkeVf8nUm3iwX2Nl3WDw9i6AUK3vBAbZZrcJpDQ/N64AVwjT07Jef30GSSmtNu2WlW7YoyW2FlWfZFQUwk867EdLYKk9VG6JgEnBiBxkY7LMo4YLQJJlAo9l/oTvJkSARDF/XtyAzM8O2t3eT/iXa6wDN3WewNmQHdPfsxChU/KtLG2Mn8i4ZqKdSlIaBZadxJmRzVS/o4yA65RTSViq60oa395Lqw0pzY4SipwE0SXXsKV+GZraGSkr/RW08wPRvqvSUkYBMA9lPx4m24az+IHmCbXA+0faxTRE9wuGeO06DIXa6QlKJ3puIyiuAVfPr736vzo2pBirS+Vxel3TMm3JKhz9o2ZoRvaFVpIkykb0Hcm4oHFBMcNSNj7/4GJt43ogonY2Vg4nsDQIWxAcorpXACzgBqQPjYsE/VUpXpwNManEru4NwMCFPkXvMoqvoeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const cv=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),uv=4;function sj(n){let t=0;function e(){return n[t++]<<8|n[t++]}let r=e(),i=1,s=[0,1];for(let W=1;W<r;W++)s.push(i+=e());let o=e(),c=t;t+=o;let u=0,f=0;function h(){return u==0&&(f=f<<8|n[t++],u=8),f>>--u&1}const y=31,A=2**y,b=A>>>1,R=b>>1,k=A-1;let S=0;for(let W=0;W<y;W++)S=S<<1|h();let B=[],H=0,U=A;for(;;){let W=Math.floor(((S-H+1)*i-1)/U),Y=0,j=r;for(;j-Y>1;){let ut=Y+j>>>1;W<s[ut]?j=ut:Y=ut}if(Y==0)break;B.push(Y);let J=H+Math.floor(U*s[Y]/i),it=H+Math.floor(U*s[Y+1]/i)-1;for(;!((J^it)&b);)S=S<<1&k|h(),J=J<<1&k,it=it<<1&k|1;for(;J&~it&R;)S=S&b|S<<1&k>>>1|h(),J=J<<1^b,it=(it^b)<<1|b|1;H=J,U=1+it-J}let G=r-4;return B.map(W=>{switch(W-G){case 3:return G+65792+(n[c++]<<16|n[c++]<<8|n[c++]);case 2:return G+256+(n[c++]<<8|n[c++]);case 1:return G+n[c++];default:return W-1}})}function oj(n){let t=0;return()=>n[t++]}function Mk(n){return oj(sj(aj(n)))}function aj(n){let t=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((i,s)=>t[i.charCodeAt(0)]=s);let e=n.length,r=new Uint8Array(6*e>>3);for(let i=0,s=0,o=0,c=0;i<e;i++)c=c<<6|t[n.charCodeAt(i)],o+=6,o>=8&&(r[s++]=c>>(o-=8));return r}function cj(n){return n&1?~n>>1:n>>1}function uj(n,t){let e=Array(n);for(let r=0,i=0;r<n;r++)e[r]=i+=cj(t());return e}function mh(n,t=0){let e=[];for(;;){let r=n(),i=n();if(!i)break;t+=r;for(let s=0;s<i;s++)e.push(t+s);t+=i+1}return e}function Lk(n){return wh(()=>{let t=mh(n);if(t.length)return t})}function Uk(n){let t=[];for(;;){let e=n();if(e==0)break;t.push(lj(e,n))}for(;;){let e=n()-1;if(e<0)break;t.push(fj(e,n))}return t.flat()}function wh(n){let t=[];for(;;){let e=n(t.length);if(!e)break;t.push(e)}return t}function Dk(n,t,e){let r=Array(n).fill().map(()=>[]);for(let i=0;i<t;i++)uj(n,e).forEach((s,o)=>r[o].push(s));return r}function lj(n,t){let e=1+t(),r=t(),i=wh(t);return Dk(i.length,1+n,t).flatMap((o,c)=>{let[u,...f]=o;return Array(i[c]).fill().map((h,y)=>{let A=y*r;return[u+y*e,f.map(b=>b+A)]})})}function fj(n,t){let e=1+t();return Dk(e,1+n,t).map(i=>[i[0],i.slice(1)])}function hj(n){let t=[],e=mh(n);return i(r([]),[]),t;function r(s){let o=n(),c=wh(()=>{let u=mh(n).map(f=>e[f]);if(u.length)return r(u)});return{S:o,B:c,Q:s}}function i({S:s,B:o},c,u){if(!(s&4&&u===c[c.length-1])){s&2&&(u=c[c.length-1]),s&1&&t.push(c);for(let f of o)for(let h of f.Q)i(f,[...c,h],u)}}}function dj(n){return n.toString(16).toUpperCase().padStart(2,"0")}function Fk(n){return`{${dj(n)}}`}function pj(n){let t=[];for(let e=0,r=n.length;e<r;){let i=n.codePointAt(e);e+=i<65536?1:2,t.push(i)}return t}function wl(n){let e=n.length;if(e<4096)return String.fromCodePoint(...n);let r=[];for(let i=0;i<e;)r.push(String.fromCodePoint(...n.slice(i,i+=4096)));return r.join("")}function gj(n,t){let e=n.length,r=e-t.length;for(let i=0;r==0&&i<e;i++)r=n[i]-t[i];return r}var yj="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30ZGQ/NlZwIpS3dDO0m4y6hgFoj9SqDBe1L9DzdC01RaA9ZC2UJ4zpjgU4DIQENIosK3Q05CG0Q8wrJaw3lEUUHOQPVSZoApQcBCxEdNRW1JhBirAsJOXcG+xr2C48mrxMpevwF0xohBk0BKRr/AM8u54WwWjFcHE9fBgMLJSPHFKhQIA0lQLd4SBobBxUlqQKRQ3BKh1E2HpMh9jw9DWYuE1F8B/U8BRlPC4E8nkarRQ4R0j6NPUgiSUwsBDV/LC8niwnPD4UMuXxyAVkJIQmxDHETMREXN8UIOQcZLZckJxUIIUaVYJoE958D8xPRAwsFPwlBBxMDtRwtEy4VKQUNgSTXAvM21S6zAo9WgAEXBcsPJR/fEFBH4A7pCJsCZQODJesALRUhABcimwhDYwBfj9hTBS7LCMdqbCN0A2cU52ERcweRDlcHpxwzFb8c4XDIXguGCCijrwlbAXUJmQFfBOMICTVbjKAgQWdTi1gYmyBhQT9d/AIxDGUVn0S9h3gCiw9rEhsBNQFzBzkNAQJ3Ee0RaxCVCOuGBDW1M/g6JQRPIYMgEQonA09szgsnJvkM+GkBoxJiAww0PXfuZ6tgtiQX/QcZMsVBYCHxC5JPzQycGsEYQlQuGeQHvwPzGvMn6kFXBf8DowMTOk0z7gS9C2kIiwk/AEkOoxcH1xhqCnGM0AExiwG3mQNXkYMCb48GNwcLAGcLhwV55QAdAqcIowAFAM8DVwA5Aq0HnQAZAIVBAT0DJy8BIeUCjwOTCDHLAZUvAfMpBBvDDBUA9zduSgLDsQKAamaiBd1YAo4CSTUBTSUEBU5HUQOvceEA2wBLBhPfRwEVq0rLGuNDAd9vKwDHAPsABTUHBUEBzQHzbQC3AV8LMQmis7UBTekpAIMAFWsB1wKJAN0ANQB/8QFTAE0FWfkF0wJPSQERMRgrV2EBuwMfATMBDQB5BsuNpckHHwRtB9MCEBsV4QLvLge1AQMi3xPNQsUCvd5VoWACZIECYkJbTa9bNyACofcCaJgCZgkCn4Q4GwsCZjsCZiYEbgR/A38TA36SOQY5dxc5gjojIwJsHQIyNjgKAm3HAm2u74ozZ0UrAWcA3gDhAEoFB5gMjQD+C8IADbUCdy8CdqI/AnlLQwJ4uh1c20WuRtcCfD8CesgCfQkCfPAFWQUgSABIfWMkAoFtAoAAAoAFAn+uSVhKWxUXSswC0QEC0MxLJwOITwOH5kTFkTIC8qFdAwMDrkvOTC0lA89NTE2vAos/AorYwRsHHUNnBbcCjjcCjlxAl4ECjtkCjlx4UbRTNQpS1FSFApP7ApMMAOkAHFUeVa9V0AYsGymVhjLheGZFOzkCl58C77JYIagAWSUClo8ClnycAKlZrFoJgU0AOwKWtQKWTlxEXNECmcsCmWRcyl0HGQKcmznCOp0CnBYCn5sCnriKAB0PMSoPAp3xAp6SALU9YTRh7wKe0wKgbgGpAp6fHwKeTqVjyGQnJSsCJ68CJn4CoPsCoEwCot0CocQCpi8Cpc4Cp/8AfQKn8mh8aLEAA0lqHGrRAqzjAqyuAq1nAq0CAlcdAlXcArHh1wMfTmyXArK9DQKy6Bds4G1jbUhfAyXNArZcOz9ukAMpRQK4XgK5RxUCuSp3cDZw4QK9GQK72nCWAzIRAr6IcgIDM3ECvhpzInNPAsPLAsMEc4J0SzVFdOADPKcDPJoDPb8CxXwCxkcCxhCJAshpUQLIRALJTwLJLgJknQLd0nh5YXiueSVL0AMYo2cCAmH0GfOVJHsLXpJeuxECz2sCz2wvS1PS8xOfAMatAs9zASnqA04SfksFAtwnAtuKAtJPA1JcA1NfAQEDVYyAiT8AyxbtYEWCHILTgs6DjQLaxwLZ3oQQhEmnPAOGpQAvA2QOhnFZ+QBVAt9lAt64c3cC4i/tFAHzMCcB9JsB8tKHAuvzAulweQLq+QLq5AD5RwG5Au6JAuuclqqXAwLuPwOF4Jh5cOBxoQLzAwBpA44WmZMC9xMDkW4DkocC95gC+dkC+GaaHJqruzebHgOdgwL++gEbADmfHJ+zAwWNA6ZqA6bZANHFAwZqoYiiBQkDDEkCwAA/AwDhQRdTARHzA2sHl2cFAJMtK7evvdsBiZkUfxEEOQH7KQUhDp0JnwCS/SlXxQL3AZ0AtwW5AG8LbUEuFCaNLgFDAYD8AbUmAHUDDgRtACwCFgyhAAAKAj0CagPdA34EkQEgRQUhfAoABQBEABMANhICdwEABdUDa+8KxQIA9wqfJ7+xt+UBkSFBQgHpFH8RNMCJAAQAGwBaAkUChIsABjpTOpSNbQC4Oo860ACNOME63AClAOgAywE6gTo7Ofw5+Tt2iTpbO56JOm85GAFWATMBbAUvNV01njWtNWY1dTW2NcU1gjWRNdI14TWeNa017jX9NbI1wTYCNhE1xjXVNhY2JzXeNe02LjY9Ni41LSE2OjY9Njw2yTcIBJA8VzY4Nt03IDcPNsogN4k3MAoEsDxnNiQ3GTdsOo03IULUQwdC4EMLHA8PCZsobShRVQYA6X8A6bABFCnXAukBowC9BbcAbwNzBL8MDAMMAQgDAAkKCwsLCQoGBAVVBI/DvwDz9b29kaUCb0QtsRTNLt4eGBcSHAMZFhYZEhYEARAEBUEcQRxBHEEcQRxBHEEaQRxBHEFCSTxBPElISUhBNkM2QTYbNklISVmBVIgBFLWZAu0BhQCjBcEAbykBvwGJAaQcEZ0ePCklMAAhMvAIMAL54gC7Bm8EescjzQMpARQpKgDUABavAj626xQAJP0A3etzuf4NNRA7efy2Z9NQrCnC0OSyANz5BBIbJ5IFDR6miIavYS6tprjjmuKebxm5C74Q225X1pkaYYPb6f1DK4k3xMEBb9S2WMjEibTNWhsRJIA+vwNVEiXTE5iXs/wezV66oFLfp9NZGYW+Gk19J2+bCT6Ye2w6LDYdgzKMUabk595eLBCXANz9HUpWbATq9vqXVx9XDg+Pc9Xp4+bsS005SVM/BJBM4687WUuf+Uj9dEi8aDNaPxtpbDxcG1THTImUMZq4UCaaNYpsVqraNyKLJXDYsFZ/5jl7bLRtO88t7P3xZaAxhb5OdPMXqsSkp1WCieG8jXm1U99+blvLlXzPCS+M93VnJCiK+09LfaSaBAVBomyDgJua8dfUzR7ga34IvR2Nvj+A9heJ6lsl1KG4NkI1032Cnff1m1wof2B9oHJK4bi6JkEdSqeNeiuo6QoZZincoc73/TH9SXF8sCE7XyuYyW8WSgbGFCjPV0ihLKhdPs08Tx82fYAkLLc4I2wdl4apY7GU5lHRFzRWJep7Ww3wbeA3qmd59/86P4xuNaqDpygXt6M85glSBHOCGgJDnt+pN9bK7HApMguX6+06RZNjzVmcZJ+wcUrJ9//bpRNxNuKpNl9uFds+S9tdx7LaM5ZkIrPj6nIU9mnbFtVbs9s/uLgl8MVczAwet+iOEzzBlYW7RCMgE6gyNLeq6+1tIx4dpgZnd0DksJS5f+JNDpwwcPNXaaVspq1fbQajOrJgK0ofKtJ1Ne90L6VO4MOl5S886p7u6xo7OLjG8TGL+HU1JXGJgppg4nNbNJ5nlzSpuPYy21JUEcUA94PoFiZfjZue+QnyQ80ekOuZVkxx4g+cvhJfHgNl4hy1/a6+RKcKlar/J29y//EztlbVPHVUeQ1zX86eQVAjR/M3dA9w4W8LfaXp4EgM85wOWasli837PzVMOnsLzR+k3o75/lRPAJSE1xAKQzEi5v10ke+VBvRt1cwQRMd+U5mLCTGVd6XiZtgBG5cDi0w22GKcVNvHiu5LQbZEDVtz0onn7k5+heuKXVsZtSzilkLRAUmjMXEMB3J9YC50XBxPiz53SC+EhnPl9WsKCv92SM/OFFIMJZYfl0WW8tIO3UxYcwdMAj7FSmgrsZ2aAZO03BOhP1bNNZItyXYQFTpC3SG1VuPDqH9GkiCDmE+JwxyIVSO5siDErAOpEXFgjy6PQtOVDj+s6e1r8heWVvmZnTciuf4EiNZzCAd7SOMhXERIOlsHIMG399i9aLTy3m2hRLZjJVDNLS53iGIK11dPqQt0zBDyg6qc7YqkDm2M5Ve6dCWCaCbTXX2rToaIgz6+zh4lYUi/+6nqcFMAkQJKHYLK0wYk5N9szV6xihDbDDFr45lN1K4aCXBq/FitPSud9gLt5ZVn+ZqGX7cwm2z5EGMgfFpIFyhGGuDPmso6TItTMwny+7uPnLCf4W6goFQFV0oQSsc9VfMmVLcLr6ZetDZbaSFTLqnSO/bIPjA3/zAUoqgGFAEQS4IhuMzEp2I3jJzbzkk/IEmyax+rhZTwd6f+CGtwPixu8IvzACquPWPREu9ZvGkUzpRwvRRuaNN6cr0W1wWits9ICdYJ7ltbgMiSL3sTPeufgNcVqMVWFkCPDH4jG2jA0XcVgQj62Cb29v9f/z/+2KbYvIv/zzjpQAPkliaVDzNrW57TZ/ZOyZD0nlfMmAIBIAGAI0D3k/mdN4xr9v85ZbZbbqfH2jGd5hUqNZWwl5SPfoGmfElmazUIeNL1j/mkF7VNAzTq4jNt8JoQ11NQOcmhprXoxSxfRGJ9LDEOAQ+dmxAQH90iti9e2u/MoeuaGcDTHoC+xsmEeWmxEKefQuIzHbpw5Tc5cEocboAD09oipWQhtTO1wivf/O+DRe2rpl/E9wlrzBorjJsOeG1B/XPW4EaJEFdNlECEZga5ZoGRHXgYouGRuVkm8tDESiEyFNo+3s5M5puSdTyUL2llnINVHEt91XUNW4ewdMgJ4boJfEyt/iY5WXqbA+A2Fkt5Z0lutiWhe9nZIyIUjyXDC3UsaG1t+eNx6z4W/OYoTB7A6x+dNSTOi9AInctbESqm5gvOLww7OWXPrmHwVZasrl4eD113pm+JtT7JVOvnCXqdzzdTRHgJ0PiGTFYW5Gvt9R9LD6Lzfs0v/TZZHSmyVNq7viIHE6DBK7Qp07Iz55EM8SYtQvZf/obBniTWi5C2/ovHfw4VndkE5XYdjOhCMRjDeOEfXeN/CwfGduiUIfsoFeUxXeQXba7c7972XNv8w+dTjjUM0QeNAReW+J014dKAD/McQYXT7c0GQPIkn3Ll6R7gGjuiQoZD0TEeEqQpKoZ15g/0OPQI17QiSv9AUROa/V/TQN3dvLArec3RrsYlvBm1b8LWzltdugsC50lNKYLEp2a+ZZYqPejULRlOJh5zj/LVMyTDvwKhMxxwuDkxJ1QpoNI0OTWLom4Z71SNzI9TV1iXJrIu9Wcnd+MCaAw8o1jSXd94YU/1gnkrC9BUEOtQvEIQ7g0i6h+KL2JKk8Ydl7HruvgWMSAmNe+LshGhV4qnWHhO9/RIPQzY1tHRj2VqOyNsDpK0cww+56AdDC4gsWwY0XxoucIWIqs/GcwnWqlaT0KPr8mbK5U94/301i1WLt4YINTVvCFBrFZbIbY8eycOdeJ2teD5IfPLCRg7jjcFTwlMFNl9zdh/o3E/hHPwj7BWg0MU09pPrBLbrCgm54A6H+I6v27+jL5gkjWg/iYdks9jbfVP5y/n0dlgWEMlKasl7JvFZd56LfybW1eeaVO0gxTfXZwD8G4SI116yx7UKVRgui6Ya1YpixqXeNLc8IxtAwCU5IhwQgn+NqHnRaDv61CxKhOq4pOX7M6pkA+Pmpd4j1vn6ACUALoLLc4vpXci8VidLxzm7qFBe7s+quuJs6ETYmnpgS3LwSZxPIltgBDXz8M1k/W2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g";const bh=44032,N0=4352,C0=4449,B0=4519,$k=19,Hk=21,bl=28,P0=Hk*bl,mj=$k*P0,wj=bh+mj,bj=N0+$k,_j=C0+Hk,Aj=B0+bl;function If(n){return n>>24&255}function zk(n){return n&16777215}let pw,lv,gw,qd;function Ej(){let n=Mk(yj);pw=new Map(Lk(n).flatMap((t,e)=>t.map(r=>[r,e+1<<24]))),lv=new Set(mh(n)),gw=new Map,qd=new Map;for(let[t,e]of Uk(n)){if(!lv.has(t)&&e.length==2){let[r,i]=e,s=qd.get(r);s||(s=new Map,qd.set(r,s)),s.set(i,t)}gw.set(t,e.reverse())}}function Gk(n){return n>=bh&&n<wj}function vj(n,t){if(n>=N0&&n<bj&&t>=C0&&t<_j)return bh+(n-N0)*P0+(t-C0)*bl;if(Gk(n)&&t>B0&&t<Aj&&(n-bh)%bl==0)return n+(t-B0);{let e=qd.get(n);return e&&(e=e.get(t),e)?e:-1}}function Vk(n){pw||Ej();let t=[],e=[],r=!1;function i(s){let o=pw.get(s);o&&(r=!0,s|=o),t.push(s)}for(let s of n)for(;;){if(s<128)t.push(s);else if(Gk(s)){let o=s-bh,c=o/P0|0,u=o%P0/bl|0,f=o%bl;i(N0+c),i(C0+u),f>0&&i(B0+f)}else{let o=gw.get(s);o?e.push(...o):i(s)}if(!e.length)break;s=e.pop()}if(r&&t.length>1){let s=If(t[0]);for(let o=1;o<t.length;o++){let c=If(t[o]);if(c==0||s<=c){s=c;continue}let u=o-1;for(;;){let f=t[u+1];if(t[u+1]=t[u],t[u]=f,!u||(s=If(t[--u]),s<=c))break}s=If(t[o])}}return t}function xj(n){let t=[],e=[],r=-1,i=0;for(let s of n){let o=If(s),c=zk(s);if(r==-1)o==0?r=c:t.push(c);else if(i>0&&i>=o)o==0?(t.push(r,...e),e.length=0,r=c):e.push(c),i=o;else{let u=vj(r,c);u>=0?r=u:i==0&&o==0?(t.push(r),r=c):(e.push(c),i=o)}}return r>=0&&t.push(r,...e),t}function Kk(n){return Vk(n).map(zk)}function Rj(n){return xj(Vk(n))}const fv=45,jk=".",Wk=65039,Zk=1,M0=n=>Array.from(n);function _h(n,t){return n.P.has(t)||n.Q.has(t)}class Sj extends Array{get is_emoji(){return!0}}let yw,qk,Ia,mw,Qk,lu,am,Kc,fa,hv,ww;function Y1(){if(yw)return;let n=Mk(ij);const t=()=>mh(n),e=()=>new Set(t()),r=(h,y)=>y.forEach(A=>h.add(A));yw=new Map(Uk(n)),qk=e(),Ia=t(),mw=new Set(t().map(h=>Ia[h])),Ia=new Set(Ia),Qk=e(),e();let i=Lk(n),s=n();const o=()=>{let h=new Set;return t().forEach(y=>r(h,i[y])),r(h,t()),h};lu=wh(h=>{let y=wh(n).map(A=>A+96);if(y.length){let A=h>=s;y[0]-=32,y=wl(y),A&&(y=`Restricted[${y}]`);let b=o(),R=o(),k=!n();return{N:y,P:b,Q:R,M:k,R:A}}}),am=e(),Kc=new Map;let c=t().concat(M0(am)).sort((h,y)=>h-y);c.forEach((h,y)=>{let A=n(),b=c[y]=A?c[y-A]:{V:[],M:new Map};b.V.push(h),am.has(h)||Kc.set(h,b)});for(let{V:h,M:y}of new Set(Kc.values())){let A=[];for(let R of h){let k=lu.filter(B=>_h(B,R)),S=A.find(({G:B})=>k.some(H=>B.has(H)));S||(S={G:new Set,V:[]},A.push(S)),S.V.push(R),r(S.G,k)}let b=A.flatMap(R=>M0(R.G));for(let{G:R,V:k}of A){let S=new Set(b.filter(B=>!R.has(B)));for(let B of k)y.set(B,S)}}fa=new Set;let u=new Set;const f=h=>fa.has(h)?u.add(h):fa.add(h);for(let h of lu){for(let y of h.P)f(y);for(let y of h.Q)f(y)}for(let h of fa)!Kc.has(h)&&!u.has(h)&&Kc.set(h,Zk);r(fa,Kk(fa)),hv=hj(n).map(h=>Sj.from(h)).sort(gj),ww=new Map;for(let h of hv){let y=[ww];for(let A of h){let b=y.map(R=>{let k=R.get(A);return k||(k=new Map,R.set(A,k)),k});A===Wk?y.push(...b):y=b}for(let A of y)A.V=h}}function X1(n){return(Jk(n)?"":`${tb($p([n]))} `)+Fk(n)}function tb(n){return`"${n}"`}function Ij(n){if(n.length>=4&&n[2]==fv&&n[3]==fv)throw new Error(`invalid label extension: "${wl(n.slice(0,4))}"`)}function kj(n){for(let e=n.lastIndexOf(95);e>0;)if(n[--e]!==95)throw new Error("underscore allowed only at start")}function Tj(n){let t=n[0],e=cv.get(t);if(e)throw Uf(`leading ${e}`);let r=n.length,i=-1;for(let s=1;s<r;s++){t=n[s];let o=cv.get(t);if(o){if(i==s)throw Uf(`${e} + ${o}`);i=s+1,e=o}}if(i==r)throw Uf(`trailing ${e}`)}function $p(n,t=1/0,e=Fk){let r=[];Oj(n[0])&&r.push("◌"),n.length>t&&(t>>=1,n=[...n.slice(0,t),8230,...n.slice(-t)]);let i=0,s=n.length;for(let o=0;o<s;o++){let c=n[o];Jk(c)&&(r.push(wl(n.slice(i,o))),r.push(e(c)),i=o+1)}return r.push(wl(n.slice(i,s))),r.join("")}function Oj(n){return Y1(),Ia.has(n)}function Jk(n){return Y1(),Qk.has(n)}function Nj(n){return Mj(Cj(n,Rj,Dj))}function Cj(n,t,e){if(!n)return[];Y1();let r=0;return n.split(jk).map(i=>{let s=pj(i),o={input:s,offset:r};r+=s.length+1;try{let c=o.tokens=Uj(s,t,e),u=c.length,f;if(!u)throw new Error("empty label");let h=o.output=c.flat();if(kj(h),!(o.emoji=u>1||c[0].is_emoji)&&h.every(A=>A<128))Ij(h),f="ASCII";else{let A=c.flatMap(b=>b.is_emoji?[]:b);if(!A.length)f="Emoji";else{if(Ia.has(h[0]))throw Uf("leading combining mark");for(let k=1;k<u;k++){let S=c[k];if(!S.is_emoji&&Ia.has(S[0]))throw Uf(`emoji + combining mark: "${wl(c[k-1])} + ${$p([S[0]])}"`)}Tj(h);let b=M0(new Set(A)),[R]=Pj(b);Lj(R,A),Bj(R,b),f=R.N}}o.type=f}catch(c){o.error=c}return o})}function Bj(n,t){let e,r=[];for(let i of t){let s=Kc.get(i);if(s===Zk)return;if(s){let o=s.M.get(i);if(e=e?e.filter(c=>o.has(c)):M0(o),!e.length)return}else r.push(i)}if(e){for(let i of e)if(r.every(s=>_h(i,s)))throw new Error(`whole-script confusable: ${n.N}/${i.N}`)}}function Pj(n){let t=lu;for(let e of n){let r=t.filter(i=>_h(i,e));if(!r.length)throw lu.some(i=>_h(i,e))?Xk(t[0],e):Yk(e);if(t=r,r.length==1)break}return t}function Mj(n){return n.map(({input:t,error:e,output:r})=>{if(e){let i=e.message;throw new Error(n.length==1?i:`Invalid label ${tb($p(t,63))}: ${i}`)}return wl(r)}).join(jk)}function Yk(n){return new Error(`disallowed character: ${X1(n)}`)}function Xk(n,t){let e=X1(t),r=lu.find(i=>i.P.has(t));return r&&(e=`${r.N} ${e}`),new Error(`illegal mixture: ${n.N} + ${e}`)}function Uf(n){return new Error(`illegal placement: ${n}`)}function Lj(n,t){for(let e of t)if(!_h(n,e))throw Xk(n,e);if(n.M){let e=Kk(t);for(let r=1,i=e.length;r<i;r++)if(mw.has(e[r])){let s=r+1;for(let o;s<i&&mw.has(o=e[s]);s++)for(let c=r;c<s;c++)if(e[c]==o)throw new Error(`duplicate non-spacing marks: ${X1(o)}`);if(s-r>uv)throw new Error(`excessive non-spacing marks: ${tb($p(e.slice(r-1,s)))} (${s-r}/${uv})`);r=s}}}function Uj(n,t,e){let r=[],i=[];for(n=n.slice().reverse();n.length;){let s=Fj(n);if(s)i.length&&(r.push(t(i)),i=[]),r.push(e(s));else{let o=n.pop();if(fa.has(o))i.push(o);else{let c=yw.get(o);if(c)i.push(...c);else if(!qk.has(o))throw Yk(o)}}}return i.length&&r.push(t(i)),r}function Dj(n){return n.filter(t=>t!=Wk)}function Fj(n,t){let e=ww,r,i=n.length;for(;i&&(e=e.get(n[--i]),!!e);){let{V:s}=e;s&&(r=s,n.length=i)}return r}const tT=new Uint8Array(32);tT.fill(0);function dv(n){return K(n.length!==0,"invalid ENS name; empty component","comp",n),n}function eT(n){const t=Vs($j(n)),e=[];if(n.length===0)return e;let r=0;for(let i=0;i<t.length;i++)t[i]===46&&(e.push(dv(t.slice(r,i))),r=i+1);return K(r<t.length,"invalid ENS name; empty component","name",n),e.push(dv(t.slice(r))),e}function $j(n){try{if(n.length===0)throw new Error("empty label");return Nj(n)}catch(t){K(!1,`invalid ENS name (${t.message})`,"name",n)}}function bw(n){K(typeof n=="string","invalid ENS name; not a string","name",n),K(n.length,"invalid ENS name (empty label)","name",n);let t=tT;const e=eT(n);for(;e.length;)t=kn(Rn([t,kn(e.pop())]));return kt(t)}function Hj(n,t){const e=t;return K(e<=255,"DNS encoded label cannot exceed 255","length",e),kt(Rn(eT(n).map(r=>{K(r.length<=e,`label ${JSON.stringify(n)} exceeds ${e} bytes`,"name",n);const i=new Uint8Array(r.length+1);return i.set(r,1),i[0]=i.length-1,i})))+"00"}function cm(n,t){return{address:Pe(n),storageKeys:t.map((e,r)=>(K(He(e,32),"invalid slot",`storageKeys[${r}]`,e),e.toLowerCase()))}}function Sc(n){if(Array.isArray(n))return n.map((e,r)=>Array.isArray(e)?(K(e.length===2,"invalid slot set",`value[${r}]`,e),cm(e[0],e[1])):(K(e!=null&&typeof e=="object","invalid address-slot set","value",n),cm(e.address,e.storageKeys)));K(n!=null&&typeof n=="object","invalid access list","value",n);const t=Object.keys(n).map(e=>{const r=n[e].reduce((i,s)=>(i[s]=!0,i),{});return cm(e,Object.keys(r).sort())});return t.sort((e,r)=>e.address.localeCompare(r.address)),t}function zj(n){let t;return typeof n=="string"?t=yh.computePublicKey(n,!1):t=n.publicKey,Pe(kn("0x"+t.substring(4)).substring(26))}function Gj(n,t){return zj(yh.recoverPublicKey(n,t))}const Un=BigInt(0),Vj=BigInt(2),Kj=BigInt(27),jj=BigInt(28),Wj=BigInt(35),Zj=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),um=4096*32;function pv(n,t){let e=n.toString(16);for(;e.length<2;)e="0"+e;return e+=Dl(t).substring(4),"0x"+e}function Hp(n){return n==="0x"?null:Pe(n)}function eb(n,t){try{return Sc(n)}catch(e){K(!1,e.message,t,n)}}function ed(n,t){return n==="0x"?0:oe(n,t)}function xn(n,t){if(n==="0x")return Un;const e=Nt(n,t);return K(e<=Zj,"value exceeds uint size",t,e),e}function Ve(n,t){const e=Nt(n,"value"),r=pr(e);return K(r.length<=32,"value too large",`tx.${t}`,e),r}function nb(n){return Sc(n).map(t=>[t.address,t.storageKeys])}function qj(n,t){K(Array.isArray(n),`invalid ${t}`,"value",n);for(let e=0;e<n.length;e++)K(He(n[e],32),"invalid ${ param } hash",`value[${e}]`,n[e]);return n}function Qj(n){const t=Lp(n);K(Array.isArray(t)&&(t.length===9||t.length===6),"invalid field count for legacy transaction","data",n);const e={type:0,nonce:ed(t[0],"nonce"),gasPrice:xn(t[1],"gasPrice"),gasLimit:xn(t[2],"gasLimit"),to:Hp(t[3]),value:xn(t[4],"value"),data:kt(t[5]),chainId:Un};if(t.length===6)return e;const r=xn(t[6],"v"),i=xn(t[7],"r"),s=xn(t[8],"s");if(i===Un&&s===Un)e.chainId=r;else{let o=(r-Wj)/Vj;o<Un&&(o=Un),e.chainId=o,K(o!==Un||r===Kj||r===jj,"non-canonical legacy v","v",t[6]),e.signature=Ri.from({r:dc(t[7],32),s:dc(t[8],32),v:r})}return e}function Jj(n,t){const e=[Ve(n.nonce,"nonce"),Ve(n.gasPrice||0,"gasPrice"),Ve(n.gasLimit,"gasLimit"),n.to||"0x",Ve(n.value,"value"),n.data];let r=Un;if(n.chainId!=Un)r=Nt(n.chainId,"tx.chainId"),K(!t||t.networkV==null||t.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",t);else if(n.signature){const s=n.signature.legacyChainId;s!=null&&(r=s)}if(!t)return r!==Un&&(e.push(pr(r)),e.push("0x"),e.push("0x")),pc(e);let i=BigInt(27+t.yParity);return r!==Un?i=Ri.getChainIdV(r,t.v):BigInt(t.v)!==i&&K(!1,"tx.chainId/sig.v mismatch","sig",t),e.push(pr(i)),e.push(pr(t.r)),e.push(pr(t.s)),pc(e)}function rb(n,t){let e;try{if(e=ed(t[0],"yParity"),e!==0&&e!==1)throw new Error("bad yParity")}catch{K(!1,"invalid yParity","yParity",t[0])}const r=dc(t[1],32),i=dc(t[2],32),s=Ri.from({r,s:i,yParity:e});n.signature=s}function Yj(n){const t=Lp(ye(n).slice(1));K(Array.isArray(t)&&(t.length===9||t.length===12),"invalid field count for transaction type: 2","data",kt(n));const e={type:2,chainId:xn(t[0],"chainId"),nonce:ed(t[1],"nonce"),maxPriorityFeePerGas:xn(t[2],"maxPriorityFeePerGas"),maxFeePerGas:xn(t[3],"maxFeePerGas"),gasPrice:null,gasLimit:xn(t[4],"gasLimit"),to:Hp(t[5]),value:xn(t[6],"value"),data:kt(t[7]),accessList:eb(t[8],"accessList")};return t.length===9||rb(e,t.slice(9)),e}function Xj(n,t){const e=[Ve(n.chainId,"chainId"),Ve(n.nonce,"nonce"),Ve(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ve(n.maxFeePerGas||0,"maxFeePerGas"),Ve(n.gasLimit,"gasLimit"),n.to||"0x",Ve(n.value,"value"),n.data,nb(n.accessList||[])];return t&&(e.push(Ve(t.yParity,"yParity")),e.push(pr(t.r)),e.push(pr(t.s))),Rn(["0x02",pc(e)])}function tW(n){const t=Lp(ye(n).slice(1));K(Array.isArray(t)&&(t.length===8||t.length===11),"invalid field count for transaction type: 1","data",kt(n));const e={type:1,chainId:xn(t[0],"chainId"),nonce:ed(t[1],"nonce"),gasPrice:xn(t[2],"gasPrice"),gasLimit:xn(t[3],"gasLimit"),to:Hp(t[4]),value:xn(t[5],"value"),data:kt(t[6]),accessList:eb(t[7],"accessList")};return t.length===8||rb(e,t.slice(8)),e}function eW(n,t){const e=[Ve(n.chainId,"chainId"),Ve(n.nonce,"nonce"),Ve(n.gasPrice||0,"gasPrice"),Ve(n.gasLimit,"gasLimit"),n.to||"0x",Ve(n.value,"value"),n.data,nb(n.accessList||[])];return t&&(e.push(Ve(t.yParity,"recoveryParam")),e.push(pr(t.r)),e.push(pr(t.s))),Rn(["0x01",pc(e)])}function nW(n){let t=Lp(ye(n).slice(1)),e="3",r=null;if(t.length===4&&Array.isArray(t[0])){e="3 (network format)";const s=t[1],o=t[2],c=t[3];K(Array.isArray(s),"invalid network format: blobs not an array","fields[1]",s),K(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),K(Array.isArray(c),"invalid network format: proofs not an array","fields[3]",c),K(s.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",t),K(s.length===c.length,"invalid network format: blobs/proofs length mismatch","fields",t),r=[];for(let u=0;u<t[1].length;u++)r.push({data:s[u],commitment:o[u],proof:c[u]});t=t[0]}K(Array.isArray(t)&&(t.length===11||t.length===14),`invalid field count for transaction type: ${e}`,"data",kt(n));const i={type:3,chainId:xn(t[0],"chainId"),nonce:ed(t[1],"nonce"),maxPriorityFeePerGas:xn(t[2],"maxPriorityFeePerGas"),maxFeePerGas:xn(t[3],"maxFeePerGas"),gasPrice:null,gasLimit:xn(t[4],"gasLimit"),to:Hp(t[5]),value:xn(t[6],"value"),data:kt(t[7]),accessList:eb(t[8],"accessList"),maxFeePerBlobGas:xn(t[9],"maxFeePerBlobGas"),blobVersionedHashes:t[10]};r&&(i.blobs=r),K(i.to!=null,`invalid address for transaction type: ${e}`,"data",n),K(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",n);for(let s=0;s<i.blobVersionedHashes.length;s++)K(He(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",n);return t.length===11||rb(i,t.slice(11)),i}function rW(n,t,e){const r=[Ve(n.chainId,"chainId"),Ve(n.nonce,"nonce"),Ve(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ve(n.maxFeePerGas||0,"maxFeePerGas"),Ve(n.gasLimit,"gasLimit"),n.to||gh,Ve(n.value,"value"),n.data,nb(n.accessList||[]),Ve(n.maxFeePerBlobGas||0,"maxFeePerBlobGas"),qj(n.blobVersionedHashes||[],"blobVersionedHashes")];return t&&(r.push(Ve(t.yParity,"yParity")),r.push(pr(t.r)),r.push(pr(t.s)),e)?Rn(["0x03",pc([r,e.map(i=>i.data),e.map(i=>i.commitment),e.map(i=>i.proof)])]):Rn(["0x03",pc(r)])}var Pi,xu,Ru,Su,Iu,ku,Tu,Ou,Nu,Cu,Bu,Pu,$a,_o,ks,Ao,Mu,Qd;const ws=class ws{constructor(){nt(this,Mu);nt(this,Pi);nt(this,xu);nt(this,Ru);nt(this,Su);nt(this,Iu);nt(this,ku);nt(this,Tu);nt(this,Ou);nt(this,Nu);nt(this,Cu);nt(this,Bu);nt(this,Pu);nt(this,$a);nt(this,_o);nt(this,ks);nt(this,Ao);$(this,Pi,null),$(this,xu,null),$(this,Su,0),$(this,Iu,Un),$(this,ku,null),$(this,Tu,null),$(this,Ou,null),$(this,Ru,"0x"),$(this,Nu,Un),$(this,Cu,Un),$(this,Bu,null),$(this,Pu,null),$(this,$a,null),$(this,_o,null),$(this,Ao,null),$(this,ks,null)}get type(){return T(this,Pi)}set type(t){switch(t){case null:$(this,Pi,null);break;case 0:case"legacy":$(this,Pi,0);break;case 1:case"berlin":case"eip-2930":$(this,Pi,1);break;case 2:case"london":case"eip-1559":$(this,Pi,2);break;case 3:case"cancun":case"eip-4844":$(this,Pi,3);break;default:K(!1,"unsupported transaction type","type",t)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const t=T(this,xu);return t==null&&this.type===3?gh:t}set to(t){$(this,xu,t==null?null:Pe(t))}get nonce(){return T(this,Su)}set nonce(t){$(this,Su,oe(t,"value"))}get gasLimit(){return T(this,Iu)}set gasLimit(t){$(this,Iu,Nt(t))}get gasPrice(){const t=T(this,ku);return t==null&&(this.type===0||this.type===1)?Un:t}set gasPrice(t){$(this,ku,t==null?null:Nt(t,"gasPrice"))}get maxPriorityFeePerGas(){const t=T(this,Tu);return t??(this.type===2||this.type===3?Un:null)}set maxPriorityFeePerGas(t){$(this,Tu,t==null?null:Nt(t,"maxPriorityFeePerGas"))}get maxFeePerGas(){const t=T(this,Ou);return t??(this.type===2||this.type===3?Un:null)}set maxFeePerGas(t){$(this,Ou,t==null?null:Nt(t,"maxFeePerGas"))}get data(){return T(this,Ru)}set data(t){$(this,Ru,kt(t))}get value(){return T(this,Nu)}set value(t){$(this,Nu,Nt(t,"value"))}get chainId(){return T(this,Cu)}set chainId(t){$(this,Cu,Nt(t))}get signature(){return T(this,Bu)||null}set signature(t){$(this,Bu,t==null?null:Ri.from(t))}get accessList(){const t=T(this,Pu)||null;return t??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(t){$(this,Pu,t==null?null:Sc(t))}get maxFeePerBlobGas(){const t=T(this,$a);return t==null&&this.type===3?Un:t}set maxFeePerBlobGas(t){$(this,$a,t==null?null:Nt(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=T(this,_o);return t==null&&this.type===3?[]:t}set blobVersionedHashes(t){if(t!=null){K(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)K(He(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}$(this,_o,t)}get blobs(){return T(this,Ao)==null?null:T(this,Ao).map(t=>Object.assign({},t))}set blobs(t){if(t==null){$(this,Ao,null);return}const e=[],r=[];for(let i=0;i<t.length;i++){const s=t[i];if(H1(s)){ht(T(this,ks),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=ye(s);if(K(o.length<=um,"blob is too large",`blobs[${i}]`,s),o.length!==um){const f=new Uint8Array(um);f.set(o),o=f}const c=T(this,ks).blobToKzgCommitment(o),u=kt(T(this,ks).computeBlobKzgProof(o,c));e.push({data:kt(o),commitment:kt(c),proof:u}),r.push(pv(1,c))}else{const o=kt(s.commitment);e.push({data:kt(s.data),commitment:o,proof:kt(s.proof)}),r.push(pv(1,o))}}$(this,Ao,e),$(this,_o,r)}get kzg(){return T(this,ks)}set kzg(t){$(this,ks,t)}get hash(){return this.signature==null?null:kn(_t(this,Mu,Qd).call(this,!0,!1))}get unsignedHash(){return kn(this.unsignedSerialized)}get from(){return this.signature==null?null:Gj(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:yh.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return _t(this,Mu,Qd).call(this,!0,!0)}get unsignedSerialized(){return _t(this,Mu,Qd).call(this,!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=this.gasPrice!=null,e=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,i=T(this,$a)!=null||T(this,_o);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&ht(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ht(!e||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ht(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const s=[];return this.type!=null?s.push(this.type):e?s.push(2):t?(s.push(1),r||s.push(0)):r?(s.push(1),s.push(2)):(i&&this.to||(s.push(0),s.push(1),s.push(2)),s.push(3)),s.sort(),s}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return ws.from(this)}toJSON(){const t=e=>e==null?null:e.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(t){if(t==null)return new ws;if(typeof t=="string"){const r=ye(t);if(r[0]>=127)return ws.from(Qj(r));switch(r[0]){case 1:return ws.from(tW(r));case 2:return ws.from(Yj(r));case 3:return ws.from(nW(r))}ht(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const e=new ws;return t.type!=null&&(e.type=t.type),t.to!=null&&(e.to=t.to),t.nonce!=null&&(e.nonce=t.nonce),t.gasLimit!=null&&(e.gasLimit=t.gasLimit),t.gasPrice!=null&&(e.gasPrice=t.gasPrice),t.maxPriorityFeePerGas!=null&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas),t.maxFeePerGas!=null&&(e.maxFeePerGas=t.maxFeePerGas),t.maxFeePerBlobGas!=null&&(e.maxFeePerBlobGas=t.maxFeePerBlobGas),t.data!=null&&(e.data=t.data),t.value!=null&&(e.value=t.value),t.chainId!=null&&(e.chainId=t.chainId),t.signature!=null&&(e.signature=Ri.from(t.signature)),t.accessList!=null&&(e.accessList=t.accessList),t.blobVersionedHashes!=null&&(e.blobVersionedHashes=t.blobVersionedHashes),t.kzg!=null&&(e.kzg=t.kzg),t.blobs!=null&&(e.blobs=t.blobs),t.hash!=null&&(K(e.isSigned(),"unsigned transaction cannot define '.hash'","tx",t),K(e.hash===t.hash,"hash mismatch","tx",t)),t.from!=null&&(K(e.isSigned(),"unsigned transaction cannot define '.from'","tx",t),K(e.from.toLowerCase()===(t.from||"").toLowerCase(),"from mismatch","tx",t)),e}};Pi=new WeakMap,xu=new WeakMap,Ru=new WeakMap,Su=new WeakMap,Iu=new WeakMap,ku=new WeakMap,Tu=new WeakMap,Ou=new WeakMap,Nu=new WeakMap,Cu=new WeakMap,Bu=new WeakMap,Pu=new WeakMap,$a=new WeakMap,_o=new WeakMap,ks=new WeakMap,Ao=new WeakMap,Mu=new WeakSet,Qd=function(t,e){ht(!t||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return Jj(this,r);case 1:return eW(this,r);case 2:return Xj(this,r);case 3:return rW(this,r,e?this.blobs:null)}ht(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let L0=ws;const nT=new Uint8Array(32);nT.fill(0);const iW=BigInt(-1),rT=BigInt(0),iT=BigInt(1),sW=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function oW(n){const t=ye(n),e=t.length%32;return e?Rn([t,nT.slice(e)]):kt(t)}const aW=Xo(iT,32),cW=Xo(rT,32),gv={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},lm=["name","version","chainId","verifyingContract","salt"];function yv(n){return function(t){return K(typeof t=="string",`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,t),t}}const uW={name:yv("name"),version:yv("version"),chainId:function(n){const t=Nt(n,"domain.chainId");return K(t>=0,"invalid chain ID","domain.chainId",n),Number.isSafeInteger(t)?Number(t):tu(t)},verifyingContract:function(n){try{return Pe(n).toLowerCase()}catch{}K(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){const t=ye(n,"domain.salt");return K(t.length===32,'invalid domain value "salt"',"domain.salt",n),kt(t)}};function fm(n){{const t=n.match(/^(u?)int(\d+)$/);if(t){const e=t[1]==="",r=parseInt(t[2]);K(r%8===0&&r!==0&&r<=256&&t[2]===String(r),"invalid numeric width","type",n);const i=Rf(sW,e?r-1:r),s=e?(i+iT)*iW:rT;return function(o){const c=Nt(o,"value");return K(c>=s&&c<=i,`value out-of-bounds for ${n}`,"value",c),Xo(e?KI(c,256):c,32)}}}{const t=n.match(/^bytes(\d+)$/);if(t){const e=parseInt(t[1]);return K(e!==0&&e<=32&&t[1]===String(e),"invalid bytes width","type",n),function(r){const i=ye(r);return K(i.length===e,`invalid length for ${n}`,"value",r),oW(r)}}}switch(n){case"address":return function(t){return dc(Pe(t),32)};case"bool":return function(t){return t?aW:cW};case"bytes":return function(t){return kn(t)};case"string":return function(t){return gc(t)}}return null}function mv(n,t){return`${n}(${t.map(({name:e,type:r})=>r+" "+e).join(",")})`}function $d(n){const t=n.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return t?{base:t[1],index:t[2]+t[4],array:{base:t[1],prefix:t[1]+t[2],count:t[5]?parseInt(t[5]):-1}}:{base:n}}var Ih,Ts,Lu,G0,sT;const Zr=class Zr{constructor(t){nt(this,G0);Z(this,"primaryType");nt(this,Ih);nt(this,Ts);nt(this,Lu);$(this,Ts,new Map),$(this,Lu,new Map);const e=new Map,r=new Map,i=new Map,s={};Object.keys(t).forEach(u=>{s[u]=t[u].map(({name:f,type:h})=>{let{base:y,index:A}=$d(h);return y==="int"&&!t.int&&(y="int256"),y==="uint"&&!t.uint&&(y="uint256"),{name:f,type:y+(A||"")}}),e.set(u,new Set),r.set(u,[]),i.set(u,new Set)}),$(this,Ih,JSON.stringify(s));for(const u in s){const f=new Set;for(const h of s[u]){K(!f.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(u)}`,"types",t),f.add(h.name);const y=$d(h.type).base;K(y!==u,`circular type reference to ${JSON.stringify(y)}`,"types",t),!fm(y)&&(K(r.has(y),`unknown type ${JSON.stringify(y)}`,"types",t),r.get(y).push(u),e.get(u).add(y))}}const o=Array.from(r.keys()).filter(u=>r.get(u).length===0);K(o.length!==0,"missing primary type","types",t),K(o.length===1,`ambiguous primary types or unused types: ${o.map(u=>JSON.stringify(u)).join(", ")}`,"types",t),$t(this,{primaryType:o[0]});function c(u,f){K(!f.has(u),`circular type reference to ${JSON.stringify(u)}`,"types",t),f.add(u);for(const h of e.get(u))if(r.has(h)){c(h,f);for(const y of f)i.get(y).add(h)}f.delete(u)}c(this.primaryType,new Set);for(const[u,f]of i){const h=Array.from(f);h.sort(),T(this,Ts).set(u,mv(u,s[u])+h.map(y=>mv(y,s[y])).join(""))}}get types(){return JSON.parse(T(this,Ih))}getEncoder(t){let e=T(this,Lu).get(t);return e||(e=_t(this,G0,sT).call(this,t),T(this,Lu).set(t,e)),e}encodeType(t){const e=T(this,Ts).get(t);return K(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return kn(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(fm(t))return r(t,e);const i=$d(t).array;if(i)return K(i.count===-1||i.count===e.length,`array length mismatch; expected length ${i.count}`,"value",e),e.map(o=>this._visit(i.prefix,o,r));const s=this.types[t];if(s)return s.reduce((o,{name:c,type:u})=>(o[c]=this._visit(u,e[c],r),o),{});K(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new Zr(t)}static getPrimaryType(t){return Zr.from(t).primaryType}static hashStruct(t,e,r){return Zr.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){if(t[r]==null)continue;const i=gv[r];K(i,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:i})}return e.sort((r,i)=>lm.indexOf(r.name)-lm.indexOf(i.name)),Zr.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return Rn(["0x1901",Zr.hashDomain(t),Zr.from(e).hash(r)])}static hash(t,e,r){return kn(Zr.encode(t,e,r))}static async resolveNames(t,e,r,i){t=Object.assign({},t);for(const c in t)t[c]==null&&delete t[c];const s={};t.verifyingContract&&!He(t.verifyingContract,20)&&(s[t.verifyingContract]="0x");const o=Zr.from(e);o.visit(r,(c,u)=>(c==="address"&&!He(u,20)&&(s[u]="0x"),u));for(const c in s)s[c]=await i(c);return t.verifyingContract&&s[t.verifyingContract]&&(t.verifyingContract=s[t.verifyingContract]),r=o.visit(r,(c,u)=>c==="address"&&s[u]?s[u]:u),{domain:t,value:r}}static getPayload(t,e,r){Zr.hashDomain(t);const i={},s=[];lm.forEach(u=>{const f=t[u];f!=null&&(i[u]=uW[u](f),s.push({name:u,type:gv[u]}))});const o=Zr.from(e);e=o.types;const c=Object.assign({},e);return K(c.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",e),c.EIP712Domain=s,o.encode(r),{types:c,domain:i,primaryType:o.primaryType,message:o.visit(r,(u,f)=>{if(u.match(/^bytes(\d*)/))return kt(ye(f));if(u.match(/^u?int/))return Nt(f).toString();switch(u){case"address":return f.toLowerCase();case"bool":return!!f;case"string":return K(typeof f=="string","invalid string","value",f),f}K(!1,"unsupported type","type",u)})}}};Ih=new WeakMap,Ts=new WeakMap,Lu=new WeakMap,G0=new WeakSet,sT=function(t){{const i=fm(t);if(i)return i}const e=$d(t).array;if(e){const i=e.prefix,s=this.getEncoder(i);return o=>{K(e.count===-1||e.count===o.length,`array length mismatch; expected length ${e.count}`,"value",o);let c=o.map(s);return T(this,Ts).has(i)&&(c=c.map(kn)),kn(Rn(c))}}const r=this.types[t];if(r){const i=gc(T(this,Ts).get(t));return s=>{const o=r.map(({name:c,type:u})=>{const f=this.getEncoder(u)(s[c]);return T(this,Ts).has(u)?kn(f):f});return o.unshift(i),Rn(o)}}K(!1,`unknown type: ${t}`,"type",t)};let U0=Zr;function mr(n){const t=new Set;return n.forEach(e=>t.add(e)),Object.freeze(t)}const lW="external public payable override",fW=mr(lW.split(" ")),oT="constant external internal payable private public pure view override",hW=mr(oT.split(" ")),aT="constructor error event fallback function receive struct",cT=mr(aT.split(" ")),uT="calldata memory storage payable indexed",dW=mr(uT.split(" ")),pW="tuple returns",gW=[aT,uT,pW,oT].join(" "),yW=mr(gW.split(" ")),mW={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},wW=new RegExp("^(\\s*)"),bW=new RegExp("^([0-9]+)"),_W=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),lT=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),fT=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");var Gn,pi,kh,_w;const V0=class V0{constructor(t){nt(this,kh);nt(this,Gn);nt(this,pi);$(this,Gn,0),$(this,pi,t.slice())}get offset(){return T(this,Gn)}get length(){return T(this,pi).length-T(this,Gn)}clone(){return new V0(T(this,pi))}reset(){$(this,Gn,0)}popKeyword(t){const e=this.peek();if(e.type!=="KEYWORD"||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=_t(this,kh,_w).call(this,T(this,Gn)+1,t.match+1);return $(this,Gn,t.match+1),e}popParams(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=[];for(;T(this,Gn)<t.match-1;){const r=this.peek().linkNext;e.push(_t(this,kh,_w).call(this,T(this,Gn)+1,r)),$(this,Gn,r)}return $(this,Gn,t.match+1),e}peek(){if(T(this,Gn)>=T(this,pi).length)throw new Error("out-of-bounds");return T(this,pi)[T(this,Gn)]}peekKeyword(t){const e=this.peekType("KEYWORD");return e!=null&&t.has(e)?e:null}peekType(t){if(this.length===0)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return df(this,Gn)._++,t}toString(){const t=[];for(let e=T(this,Gn);e<T(this,pi).length;e++){const r=T(this,pi)[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}};Gn=new WeakMap,pi=new WeakMap,kh=new WeakSet,_w=function(t=0,e=0){return new V0(T(this,pi).slice(t,e).map(r=>Object.freeze(Object.assign({},r,{match:r.match-t,linkBack:r.linkBack-t,linkNext:r.linkNext-t}))))};let Si=V0;function ra(n){const t=[],e=o=>{const c=s<n.length?JSON.stringify(n[s]):"$EOI";throw new Error(`invalid token ${c} at ${s}: ${o}`)};let r=[],i=[],s=0;for(;s<n.length;){let o=n.substring(s),c=o.match(wW);c&&(s+=c[1].length,o=n.substring(s));const u={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};t.push(u);let f=mW[o[0]]||"";if(f){if(u.type=f,u.text=o[0],s++,f==="OPEN_PAREN")r.push(t.length-1),i.push(t.length-1);else if(f=="CLOSE_PAREN")r.length===0&&e("no matching open bracket"),u.match=r.pop(),t[u.match].match=t.length-1,u.depth--,u.linkBack=i.pop(),t[u.linkBack].linkNext=t.length-1;else if(f==="COMMA")u.linkBack=i.pop(),t[u.linkBack].linkNext=t.length-1,i.push(t.length-1);else if(f==="OPEN_BRACKET")u.type="BRACKET";else if(f==="CLOSE_BRACKET"){let h=t.pop().text;if(t.length>0&&t[t.length-1].type==="NUMBER"){const y=t.pop().text;h=y+h,t[t.length-1].value=oe(y)}if(t.length===0||t[t.length-1].type!=="BRACKET")throw new Error("missing opening bracket");t[t.length-1].text+=h}continue}if(c=o.match(_W),c){if(u.text=c[1],s+=u.text.length,yW.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(fT)){u.type="TYPE";continue}u.type="ID";continue}if(c=o.match(bW),c){u.text=c[1],u.type="NUMBER",s+=u.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${s}`)}return new Si(t.map(o=>Object.freeze(o)))}function wv(n,t){let e=[];for(const r in t.keys())n.has(r)&&e.push(r);if(e.length>1)throw new Error(`conflicting types: ${e.join(", ")}`)}function zp(n,t){if(t.peekKeyword(cT)){const e=t.pop().text;if(e!==n)throw new Error(`expected ${n}, got ${e}`)}return t.popType("ID")}function qs(n,t){const e=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||t&&!t.has(r))break;if(n.pop(),e.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);e.add(r)}return Object.freeze(e)}function hT(n){let t=qs(n,hW);return wv(t,mr("constant payable nonpayable".split(" "))),wv(t,mr("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function Ks(n,t){return n.popParams().map(e=>Qn.from(e,t))}function dT(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return Nt(n.pop().text);throw new Error("invalid gas")}return null}function yc(n){if(n.length)throw new Error(`unexpected tokens at offset ${n.offset}: ${n.toString()}`)}const AW=new RegExp(/^(.*)\[([0-9]*)\]$/);function bv(n){const t=n.match(fT);if(K(t,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(t[2]){const e=parseInt(t[2]);K(e!==0&&e<=32,"invalid bytes length","type",n)}else if(t[3]){const e=parseInt(t[3]);K(e!==0&&e<=256&&e%8===0,"invalid numeric width","type",n)}return n}const rn={},Nr=Symbol.for("_ethers_internal"),_v="_ParamTypeInternal",Av="_ErrorInternal",Ev="_EventInternal",vv="_ConstructorInternal",xv="_FallbackInternal",Rv="_FunctionInternal",Sv="_StructInternal";var Uu,Jd;const qr=class qr{constructor(t,e,r,i,s,o,c,u){nt(this,Uu);Z(this,"name");Z(this,"type");Z(this,"baseType");Z(this,"indexed");Z(this,"components");Z(this,"arrayLength");Z(this,"arrayChildren");if(Bp(t,rn,"ParamType"),Object.defineProperty(this,Nr,{value:_v}),o&&(o=Object.freeze(o.slice())),i==="array"){if(c==null||u==null)throw new Error("")}else if(c!=null||u!=null)throw new Error("");if(i==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");$t(this,{name:e,type:r,baseType:i,indexed:s,components:o,arrayLength:c,arrayChildren:u})}format(t){if(t==null&&(t="sighash"),t==="json"){const r=this.name||"";if(this.isArray()){const s=JSON.parse(this.arrayChildren.format("json"));return s.name=r,s.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(s)}const i={type:this.baseType==="tuple"?"tuple":this.type,name:r};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.isTuple()&&(i.components=this.components.map(s=>JSON.parse(s.format(t)))),JSON.stringify(i)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map(r=>r.format(t)).join(t==="full"?", ":",")+")":e+=this.type,t!=="sighash"&&(this.indexed===!0&&(e+=" indexed"),t==="full"&&this.name&&(e+=" "+this.name)),e}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return t.map(i=>r.arrayChildren.walk(i,e))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const r=this;return t.map((i,s)=>r.components[s].walk(i,e))}return e(this.type,t)}async walkAsync(t,e){const r=[],i=[t];return _t(this,Uu,Jd).call(this,r,t,e,s=>{i[0]=s}),r.length&&await Promise.all(r),i[0]}static from(t,e){if(qr.isParamType(t))return t;if(typeof t=="string")try{return qr.from(ra(t),e)}catch{K(!1,"invalid param type","obj",t)}else if(t instanceof Si){let c="",u="",f=null;qs(t,mr(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(u="tuple",f=t.popParams().map(k=>qr.from(k)),c=`tuple(${f.map(k=>k.format()).join(",")})`):(c=bv(t.popType("TYPE")),u=c);let h=null,y=null;for(;t.length&&t.peekType("BRACKET");){const k=t.pop();h=new qr(rn,"",c,u,null,f,y,h),y=k.value,c+=k.text,u="array",f=null}let A=null;if(qs(t,dW).has("indexed")){if(!e)throw new Error("");A=!0}const R=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new qr(rn,R,c,u,A,f,y,h)}const r=t.name;K(!r||typeof r=="string"&&r.match(lT),"invalid name","obj.name",r);let i=t.indexed;i!=null&&(K(e,"parameter cannot be indexed","obj.indexed",t.indexed),i=!!i);let s=t.type,o=s.match(AW);if(o){const c=parseInt(o[2]||"-1"),u=qr.from({type:o[1],components:t.components});return new qr(rn,r||"",s,"array",i,null,c,u)}if(s==="tuple"||s.startsWith("tuple(")||s.startsWith("(")){const c=t.components!=null?t.components.map(f=>qr.from(f)):null;return new qr(rn,r||"",s,"tuple",i,c,null,null)}return s=bv(t.type),new qr(rn,r||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[Nr]===_v}};Uu=new WeakSet,Jd=function(t,e,r,i){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,c=e.slice();c.forEach((u,f)=>{var h;_t(h=o,Uu,Jd).call(h,t,u,r,y=>{c[f]=y})}),i(c);return}if(this.isTuple()){const o=this.components;let c;if(Array.isArray(e))c=e.slice();else{if(e==null||typeof e!="object")throw new Error("invalid tuple value");c=o.map(u=>{if(!u.name)throw new Error("cannot use object value with unnamed components");if(!(u.name in e))throw new Error(`missing value for component ${u.name}`);return e[u.name]})}if(c.length!==this.components.length)throw new Error("array is wrong length");c.forEach((u,f)=>{var h;_t(h=o[f],Uu,Jd).call(h,t,u,r,y=>{c[f]=y})}),i(c);return}const s=r(this.type,e);s.then?t.push(async function(){i(await s)}()):i(s)};let Qn=qr;class mc{constructor(t,e,r){Z(this,"type");Z(this,"inputs");Bp(t,rn,"Fragment"),r=Object.freeze(r.slice()),$t(this,{type:e,inputs:r})}static from(t){if(typeof t=="string"){try{mc.from(JSON.parse(t))}catch{}return mc.from(ra(t))}if(t instanceof Si)switch(t.peekKeyword(cT)){case"constructor":return zs.from(t);case"error":return Sr.from(t);case"event":return Zi.from(t);case"fallback":case"receive":return vs.from(t);case"function":return qi.from(t);case"struct":return nc.from(t)}else if(typeof t=="object"){switch(t.type){case"constructor":return zs.from(t);case"error":return Sr.from(t);case"event":return Zi.from(t);case"fallback":case"receive":return vs.from(t);case"function":return qi.from(t);case"struct":return nc.from(t)}ht(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}K(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return zs.isFragment(t)}static isError(t){return Sr.isFragment(t)}static isEvent(t){return Zi.isFragment(t)}static isFunction(t){return qi.isFragment(t)}static isStruct(t){return nc.isFragment(t)}}class Gp extends mc{constructor(e,r,i,s){super(e,r,s);Z(this,"name");K(typeof i=="string"&&i.match(lT),"invalid identifier","name",i),s=Object.freeze(s.slice()),$t(this,{name:i})}}function Ah(n,t){return"("+t.map(e=>e.format(n)).join(n==="full"?", ":",")+")"}class Sr extends Gp{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Nr,{value:Av})}get selector(){return gc(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(t)))});const e=[];return t!=="sighash"&&e.push("error"),e.push(this.name+Ah(t,this.inputs)),e.join(" ")}static from(t){if(Sr.isFragment(t))return t;if(typeof t=="string")return Sr.from(ra(t));if(t instanceof Si){const e=zp("error",t),r=Ks(t);return yc(t),new Sr(rn,e,r)}return new Sr(rn,t.name,t.inputs?t.inputs.map(Qn.from):[])}static isFragment(t){return t&&t[Nr]===Av}}class Zi extends Gp{constructor(e,r,i,s){super(e,"event",r,i);Z(this,"anonymous");Object.defineProperty(this,Nr,{value:Ev}),$t(this,{anonymous:s})}get topicHash(){return gc(this.format("sighash"))}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});const r=[];return e!=="sighash"&&r.push("event"),r.push(this.name+Ah(e,this.inputs)),e!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(e,r){return r=(r||[]).map(s=>Qn.from(s)),new Zi(rn,e,r,!1).topicHash}static from(e){if(Zi.isFragment(e))return e;if(typeof e=="string")try{return Zi.from(ra(e))}catch{K(!1,"invalid event fragment","obj",e)}else if(e instanceof Si){const r=zp("event",e),i=Ks(e,!0),s=!!qs(e,mr(["anonymous"])).has("anonymous");return yc(e),new Zi(rn,r,i,s)}return new Zi(rn,e.name,e.inputs?e.inputs.map(r=>Qn.from(r,!0)):[],!!e.anonymous)}static isFragment(e){return e&&e[Nr]===Ev}}class zs extends mc{constructor(e,r,i,s,o){super(e,r,i);Z(this,"payable");Z(this,"gas");Object.defineProperty(this,Nr,{value:vv}),$t(this,{payable:s,gas:o})}format(e){if(ht(e!=null&&e!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),e==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});const r=[`constructor${Ah(e,this.inputs)}`];return this.payable&&r.push("payable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(e){if(zs.isFragment(e))return e;if(typeof e=="string")try{return zs.from(ra(e))}catch{K(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof Si){qs(e,mr(["constructor"]));const r=Ks(e),i=!!qs(e,fW).has("payable"),s=dT(e);return yc(e),new zs(rn,"constructor",r,i,s)}return new zs(rn,"constructor",e.inputs?e.inputs.map(Qn.from):[],!!e.payable,e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[Nr]===vv}}class vs extends mc{constructor(e,r,i){super(e,"fallback",r);Z(this,"payable");Object.defineProperty(this,Nr,{value:xv}),$t(this,{payable:i})}format(e){const r=this.inputs.length===0?"receive":"fallback";if(e==="json"){const i=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:i})}return`${r}()${this.payable?" payable":""}`}static from(e){if(vs.isFragment(e))return e;if(typeof e=="string")try{return vs.from(ra(e))}catch{K(!1,"invalid fallback fragment","obj",e)}else if(e instanceof Si){const r=e.toString(),i=e.peekKeyword(mr(["fallback","receive"]));if(K(i,"type must be fallback or receive","obj",r),e.popKeyword(mr(["fallback","receive"]))==="receive"){const u=Ks(e);return K(u.length===0,"receive cannot have arguments","obj.inputs",u),qs(e,mr(["payable"])),yc(e),new vs(rn,[],!0)}let o=Ks(e);o.length?K(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(u=>u.format("minimal")).join(", ")):o=[Qn.from("bytes")];const c=hT(e);if(K(c==="nonpayable"||c==="payable","fallback cannot be constants","obj.stateMutability",c),qs(e,mr(["returns"])).has("returns")){const u=Ks(e);K(u.length===1&&u[0].type==="bytes","invalid fallback outputs","obj.outputs",u.map(f=>f.format("minimal")).join(", "))}return yc(e),new vs(rn,o,c==="payable")}if(e.type==="receive")return new vs(rn,[],!0);if(e.type==="fallback"){const r=[Qn.from("bytes")],i=e.stateMutability==="payable";return new vs(rn,r,i)}K(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[Nr]===xv}}class qi extends Gp{constructor(e,r,i,s,o,c){super(e,"function",r,s);Z(this,"constant");Z(this,"outputs");Z(this,"stateMutability");Z(this,"payable");Z(this,"gas");Object.defineProperty(this,Nr,{value:Rv}),o=Object.freeze(o.slice()),$t(this,{constant:i==="view"||i==="pure",gas:c,outputs:o,payable:i==="payable",stateMutability:i})}get selector(){return gc(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(e))),outputs:this.outputs.map(i=>JSON.parse(i.format(e)))});const r=[];return e!=="sighash"&&r.push("function"),r.push(this.name+Ah(e,this.inputs)),e!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(Ah(e,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(e,r){return r=(r||[]).map(s=>Qn.from(s)),new qi(rn,e,"view",r,[],null).selector}static from(e){if(qi.isFragment(e))return e;if(typeof e=="string")try{return qi.from(ra(e))}catch{K(!1,"invalid function fragment","obj",e)}else if(e instanceof Si){const i=zp("function",e),s=Ks(e),o=hT(e);let c=[];qs(e,mr(["returns"])).has("returns")&&(c=Ks(e));const u=dT(e);return yc(e),new qi(rn,i,o,s,c,u)}let r=e.stateMutability;return r==null&&(r="payable",typeof e.constant=="boolean"?(r="view",e.constant||(r="payable",typeof e.payable=="boolean"&&!e.payable&&(r="nonpayable"))):typeof e.payable=="boolean"&&!e.payable&&(r="nonpayable")),new qi(rn,e.name,r,e.inputs?e.inputs.map(Qn.from):[],e.outputs?e.outputs.map(Qn.from):[],e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[Nr]===Rv}}class nc extends Gp{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Nr,{value:Sv})}format(){throw new Error("@TODO")}static from(t){if(typeof t=="string")try{return nc.from(ra(t))}catch{K(!1,"invalid struct fragment","obj",t)}else if(t instanceof Si){const e=zp("struct",t),r=Ks(t);return yc(t),new nc(rn,e,r)}return new nc(rn,t.name,t.inputs?t.inputs.map(Qn.from):[])}static isFragment(t){return t&&t[Nr]===Sv}}const Ii=new Map;Ii.set(0,"GENERIC_PANIC");Ii.set(1,"ASSERT_FALSE");Ii.set(17,"OVERFLOW");Ii.set(18,"DIVIDE_BY_ZERO");Ii.set(33,"ENUM_RANGE_ERROR");Ii.set(34,"BAD_STORAGE_DATA");Ii.set(49,"STACK_UNDERFLOW");Ii.set(50,"ARRAY_RANGE_ERROR");Ii.set(65,"OUT_OF_MEMORY");Ii.set(81,"UNINITIALIZED_FUNCTION_CALL");const EW=new RegExp(/^bytes([0-9]*)$/),vW=new RegExp(/^(u?int)([0-9]*)$/);let hm=null,Iv=1024;function xW(n,t,e,r){let i="missing revert data",s=null;const o=null;let c=null;if(e){i="execution reverted";const f=ye(e);if(e=kt(e),f.length===0)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(f.length%32!==4)i+=" (could not decode reason; invalid data length)";else if(kt(f.slice(0,4))==="0x08c379a0")try{s=r.decode(["string"],f.slice(4))[0],c={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch{i+=" (could not decode reason; invalid string data)"}else if(kt(f.slice(0,4))==="0x4e487b71")try{const h=Number(r.decode(["uint256"],f.slice(4))[0]);c={signature:"Panic(uint256)",name:"Panic",args:[h]},s=`Panic due to ${Ii.get(h)||"UNKNOWN"}(${h})`,i+=`: ${s}`}catch{i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const u={to:t.to?Pe(t.to):null,data:t.data||"0x"};return t.from&&(u.from=Pe(t.from)),Ze(i,"CALL_EXCEPTION",{action:n,data:e,reason:s,transaction:u,invocation:o,revert:c})}var Eo,jc;const K0=class K0{constructor(){nt(this,Eo)}getDefaultValue(t){const e=t.map(i=>_t(this,Eo,jc).call(this,Qn.from(i)));return new Fd(e,"_").defaultValue()}encode(t,e){zI(e.length,t.length,"types/values length mismatch");const r=t.map(o=>_t(this,Eo,jc).call(this,Qn.from(o))),i=new Fd(r,"_"),s=new ow;return i.encode(s,e),s.data}decode(t,e,r){const i=t.map(o=>_t(this,Eo,jc).call(this,Qn.from(o)));return new Fd(i,"_").decode(new aw(e,r,Iv))}static _setDefaultMaxInflation(t){K(typeof t=="number"&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),Iv=t}static defaultAbiCoder(){return hm==null&&(hm=new K0),hm}static getBuiltinCallException(t,e,r){return xW(t,e,r,K0.defaultAbiCoder())}};Eo=new WeakSet,jc=function(t){if(t.isArray())return new WK(_t(this,Eo,jc).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new Fd(t.components.map(r=>_t(this,Eo,jc).call(this,r)),t.name);switch(t.baseType){case"address":return new KK(t.name);case"bool":return new ZK(t.name);case"string":return new rj(t.name);case"bytes":return new qK(t.name);case"":return new YK(t.name)}let e=t.type.match(vW);if(e){let r=parseInt(e[2]||"256");return K(r!==0&&r<=256&&r%8===0,"invalid "+e[1]+" bit length","param",t),new nj(r/8,e[1]==="int",t.name)}if(e=t.type.match(EW),e){let r=parseInt(e[1]);return K(r!==0&&r<=32,"invalid bytes length","param",t),new QK(r,t.name)}K(!1,"invalid type","type",t.type)};let Eh=K0;class RW{constructor(t,e,r){Z(this,"fragment");Z(this,"name");Z(this,"signature");Z(this,"topic");Z(this,"args");const i=t.name,s=t.format();$t(this,{fragment:t,name:i,signature:s,topic:e,args:r})}}class SW{constructor(t,e,r,i){Z(this,"fragment");Z(this,"name");Z(this,"args");Z(this,"signature");Z(this,"selector");Z(this,"value");const s=t.name,o=t.format();$t(this,{fragment:t,name:s,args:r,signature:o,selector:e,value:i})}}class IW{constructor(t,e,r){Z(this,"fragment");Z(this,"name");Z(this,"args");Z(this,"signature");Z(this,"selector");const i=t.name,s=t.format();$t(this,{fragment:t,name:i,args:r,signature:s,selector:e})}}class kv{constructor(t){Z(this,"hash");Z(this,"_isIndexed");$t(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!!(t&&t._isIndexed)}}const Tv={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},Ov={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let t="unknown panic code";return n>=0&&n<=255&&Tv[n.toString()]&&(t=Tv[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${t})`}}};var Mi,Li,Ui,rr,ns,Yd,Xd;const ba=class ba{constructor(t){nt(this,ns);Z(this,"fragments");Z(this,"deploy");Z(this,"fallback");Z(this,"receive");nt(this,Mi);nt(this,Li);nt(this,Ui);nt(this,rr);let e=[];typeof t=="string"?e=JSON.parse(t):e=t,$(this,Ui,new Map),$(this,Mi,new Map),$(this,Li,new Map);const r=[];for(const o of e)try{r.push(mc.from(o))}catch(c){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,c.message)}$t(this,{fragments:Object.freeze(r)});let i=null,s=!1;$(this,rr,this.getAbiCoder()),this.fragments.forEach((o,c)=>{let u;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}$t(this,{deploy:o});return;case"fallback":o.inputs.length===0?s=!0:(K(!i||o.payable!==i.payable,"conflicting fallback fragments",`fragments[${c}]`,o),i=o,s=i.payable);return;case"function":u=T(this,Ui);break;case"event":u=T(this,Li);break;case"error":u=T(this,Mi);break;default:return}const f=o.format();u.has(f)||u.set(f,o)}),this.deploy||$t(this,{deploy:zs.from("constructor()")}),$t(this,{fallback:i,receive:s})}format(t){const e=t?"minimal":"full";return this.fragments.map(i=>i.format(e))}formatJson(){const t=this.fragments.map(e=>e.format("json"));return JSON.stringify(t.map(e=>JSON.parse(e)))}getAbiCoder(){return Eh.defaultAbiCoder()}getFunctionName(t){const e=_t(this,ns,Yd).call(this,t,null,!1);return K(e,"no matching function","key",t),e.name}hasFunction(t){return!!_t(this,ns,Yd).call(this,t,null,!1)}getFunction(t,e){return _t(this,ns,Yd).call(this,t,e||null,!0)}forEachFunction(t){const e=Array.from(T(this,Ui).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(T(this,Ui).get(i),r)}}getEventName(t){const e=_t(this,ns,Xd).call(this,t,null,!1);return K(e,"no matching event","key",t),e.name}hasEvent(t){return!!_t(this,ns,Xd).call(this,t,null,!1)}getEvent(t,e){return _t(this,ns,Xd).call(this,t,e||null,!0)}forEachEvent(t){const e=Array.from(T(this,Li).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(T(this,Li).get(i),r)}}getError(t,e){if(He(t)){const i=t.toLowerCase();if(Ov[i])return Sr.from(Ov[i].signature);for(const s of T(this,Mi).values())if(i===s.selector)return s;return null}if(t.indexOf("(")===-1){const i=[];for(const[s,o]of T(this,Mi))s.split("(")[0]===t&&i.push(o);if(i.length===0)return t==="Error"?Sr.from("error Error(string)"):t==="Panic"?Sr.from("error Panic(uint256)"):null;if(i.length>1){const s=i.map(o=>JSON.stringify(o.format())).join(", ");K(!1,`ambiguous error description (i.e. ${s})`,"name",t)}return i[0]}if(t=Sr.from(t).format(),t==="Error(string)")return Sr.from("error Error(string)");if(t==="Panic(uint256)")return Sr.from("error Panic(uint256)");const r=T(this,Mi).get(t);return r||null}forEachError(t){const e=Array.from(T(this,Mi).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(T(this,Mi).get(i),r)}}_decodeParams(t,e){return T(this,rr).decode(t,e)}_encodeParams(t,e){return T(this,rr).encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if(typeof t=="string"){const r=this.getError(t);K(r,"unknown error","fragment",t),t=r}return K(bn(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,bn(e,4))}encodeErrorResult(t,e){if(typeof t=="string"){const r=this.getError(t);K(r,"unknown error","fragment",t),t=r}return Rn([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return K(bn(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,bn(e,4))}encodeFunctionData(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return Rn([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if(typeof t=="string"){const s=this.getFunction(t);K(s,"unknown function","fragment",t),t=s}let r="invalid length for result data";const i=fr(e);if(i.length%32===0)try{return T(this,rr).decode(t.outputs,i)}catch{r="could not decode result data"}ht(!1,r,"BAD_DATA",{value:kt(i),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=ye(t,"data"),i=Eh.getBuiltinCallException("call",e,r);if(i.message.startsWith("execution reverted (unknown custom error)")){const c=kt(r.slice(0,4)),u=this.getError(c);if(u)try{const f=T(this,rr).decode(u.inputs,r.slice(4));i.revert={name:u.name,signature:u.format(),args:f},i.reason=i.revert.signature,i.message=`execution reverted: ${i.reason}`}catch{i.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(e);return o&&(i.invocation={method:o.name,signature:o.signature,args:o.args}),i}encodeFunctionResult(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return kt(T(this,rr).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if(typeof t=="string"){const s=this.getEvent(t);K(s,"unknown event","eventFragment",t),t=s}ht(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const i=(s,o)=>s.type==="string"?gc(o):s.type==="bytes"?kn(kt(o)):(s.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":s.type.match(/^u?int/)?o=Xo(o):s.type.match(/^bytes/)?o=YG(o,32):s.type==="address"&&T(this,rr).encode(["address"],[o]),dc(kt(o),32));for(e.forEach((s,o)=>{const c=t.inputs[o];if(!c.indexed){K(s==null,"cannot filter non-indexed parameters; must be null","contract."+c.name,s);return}s==null?r.push(null):c.baseType==="array"||c.baseType==="tuple"?K(!1,"filtering with tuples or arrays not supported","contract."+c.name,s):Array.isArray(s)?r.push(s.map(u=>i(c,u))):r.push(i(c,s))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(t,e){if(typeof t=="string"){const o=this.getEvent(t);K(o,"unknown event","eventFragment",t),t=o}const r=[],i=[],s=[];return t.anonymous||r.push(t.topicHash),K(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach((o,c)=>{const u=e[c];if(o.indexed)if(o.type==="string")r.push(gc(u));else if(o.type==="bytes")r.push(kn(u));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(T(this,rr).encode([o.type],[u]))}else i.push(o),s.push(u)}),{data:T(this,rr).encode(i,s),topics:r}}decodeEventLog(t,e,r){if(typeof t=="string"){const b=this.getEvent(t);K(b,"unknown event","eventFragment",t),t=b}if(r!=null&&!t.anonymous){const b=t.topicHash;K(He(r[0],32)&&r[0].toLowerCase()===b,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const i=[],s=[],o=[];t.inputs.forEach((b,R)=>{b.indexed?b.type==="string"||b.type==="bytes"||b.baseType==="tuple"||b.baseType==="array"?(i.push(Qn.from({type:"bytes32",name:b.name})),o.push(!0)):(i.push(b),o.push(!1)):(s.push(b),o.push(!1))});const c=r!=null?T(this,rr).decode(i,Rn(r)):null,u=T(this,rr).decode(s,e,!0),f=[],h=[];let y=0,A=0;return t.inputs.forEach((b,R)=>{let k=null;if(b.indexed)if(c==null)k=new kv(null);else if(o[R])k=new kv(c[A++]);else try{k=c[A++]}catch(S){k=S}else try{k=u[y++]}catch(S){k=S}f.push(k),h.push(b.name||null)}),dl.fromItems(f,h)}parseTransaction(t){const e=ye(t.data,"tx.data"),r=Nt(t.value!=null?t.value:0,"tx.value"),i=this.getFunction(kt(e.slice(0,4)));if(!i)return null;const s=T(this,rr).decode(i.inputs,e.slice(4));return new SW(i,i.selector,s,r)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new RW(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=kt(t),r=this.getError(bn(e,0,4));if(!r)return null;const i=T(this,rr).decode(r.inputs,bn(e,4));return new IW(r,r.selector,i)}static from(t){return t instanceof ba?t:typeof t=="string"?new ba(JSON.parse(t)):typeof t.formatJson=="function"?new ba(t.formatJson()):typeof t.format=="function"?new ba(t.format("json")):new ba(t)}};Mi=new WeakMap,Li=new WeakMap,Ui=new WeakMap,rr=new WeakMap,ns=new WeakSet,Yd=function(t,e,r){if(He(t)){const s=t.toLowerCase();for(const o of T(this,Ui).values())if(s===o.selector)return o;return null}if(t.indexOf("(")===-1){const s=[];for(const[o,c]of T(this,Ui))o.split("(")[0]===t&&s.push(c);if(e){const o=e.length>0?e[e.length-1]:null;let c=e.length,u=!0;ar.isTyped(o)&&o.type==="overrides"&&(u=!1,c--);for(let f=s.length-1;f>=0;f--){const h=s[f].inputs.length;h!==c&&(!u||h!==c-1)&&s.splice(f,1)}for(let f=s.length-1;f>=0;f--){const h=s[f].inputs;for(let y=0;y<e.length;y++)if(ar.isTyped(e[y])){if(y>=h.length){if(e[y].type==="overrides")continue;s.splice(f,1);break}if(e[y].type!==h[y].baseType){s.splice(f,1);break}}}}if(s.length===1&&e&&e.length!==s[0].inputs.length){const o=e[e.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&s.splice(0,1)}if(s.length===0)return null;if(s.length>1&&r){const o=s.map(c=>JSON.stringify(c.format())).join(", ");K(!1,`ambiguous function description (i.e. matches ${o})`,"key",t)}return s[0]}const i=T(this,Ui).get(qi.from(t).format());return i||null},Xd=function(t,e,r){if(He(t)){const s=t.toLowerCase();for(const o of T(this,Li).values())if(s===o.topicHash)return o;return null}if(t.indexOf("(")===-1){const s=[];for(const[o,c]of T(this,Li))o.split("(")[0]===t&&s.push(c);if(e){for(let o=s.length-1;o>=0;o--)s[o].inputs.length<e.length&&s.splice(o,1);for(let o=s.length-1;o>=0;o--){const c=s[o].inputs;for(let u=0;u<e.length;u++)if(ar.isTyped(e[u])&&e[u].type!==c[u].baseType){s.splice(o,1);break}}}if(s.length===0)return null;if(s.length>1&&r){const o=s.map(c=>JSON.stringify(c.format())).join(", ");K(!1,`ambiguous event description (i.e. matches ${o})`,"key",t)}return s[0]}const i=T(this,Li).get(Zi.from(t).format());return i||null};let Aw=ba;const pT=BigInt(0);function fu(n){return n??null}function En(n){return n==null?null:n.toString()}class Nv{constructor(t,e,r){Z(this,"gasPrice");Z(this,"maxFeePerGas");Z(this,"maxPriorityFeePerGas");$t(this,{gasPrice:fu(t),maxFeePerGas:fu(e),maxPriorityFeePerGas:fu(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:En(t),maxFeePerGas:En(e),maxPriorityFeePerGas:En(r)}}}function D0(n){const t={};n.to&&(t.to=n.to),n.from&&(t.from=n.from),n.data&&(t.data=kt(n.data));const e="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of e)!(i in n)||n[i]==null||(t[i]=Nt(n[i],`request.${i}`));const r="type,nonce".split(/,/);for(const i of r)!(i in n)||n[i]==null||(t[i]=oe(n[i],`request.${i}`));return n.accessList&&(t.accessList=Sc(n.accessList)),"blockTag"in n&&(t.blockTag=n.blockTag),"enableCcipRead"in n&&(t.enableCcipRead=!!n.enableCcipRead),"customData"in n&&(t.customData=n.customData),"blobVersionedHashes"in n&&n.blobVersionedHashes&&(t.blobVersionedHashes=n.blobVersionedHashes.slice()),"kzg"in n&&(t.kzg=n.kzg),"blobs"in n&&n.blobs&&(t.blobs=n.blobs.map(i=>H1(i)?kt(i):Object.assign({},i))),t}var Os;class kW{constructor(t,e){Z(this,"provider");Z(this,"number");Z(this,"hash");Z(this,"timestamp");Z(this,"parentHash");Z(this,"parentBeaconBlockRoot");Z(this,"nonce");Z(this,"difficulty");Z(this,"gasLimit");Z(this,"gasUsed");Z(this,"stateRoot");Z(this,"receiptsRoot");Z(this,"blobGasUsed");Z(this,"excessBlobGas");Z(this,"miner");Z(this,"prevRandao");Z(this,"extraData");Z(this,"baseFeePerGas");nt(this,Os);$(this,Os,t.transactions.map(r=>typeof r!="string"?new vh(r,e):r)),$t(this,{provider:e,hash:fu(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:fu(t.prevRandao),extraData:t.extraData,baseFeePerGas:fu(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return T(this,Os).map(t=>typeof t=="string"?t:t.hash)}get prefetchedTransactions(){const t=T(this,Os).slice();return t.length===0?[]:(ht(typeof t[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:i,gasUsed:s,hash:o,miner:c,prevRandao:u,nonce:f,number:h,parentHash:y,parentBeaconBlockRoot:A,stateRoot:b,receiptsRoot:R,timestamp:k,transactions:S}=this;return{_type:"Block",baseFeePerGas:En(t),difficulty:En(e),extraData:r,gasLimit:En(i),gasUsed:En(s),blobGasUsed:En(this.blobGasUsed),excessBlobGas:En(this.excessBlobGas),hash:o,miner:c,prevRandao:u,nonce:f,number:h,parentHash:y,timestamp:k,parentBeaconBlockRoot:A,stateRoot:b,receiptsRoot:R,transactions:S}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return T(this,Os).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(t){let e;if(typeof t=="number")e=T(this,Os)[t];else{const r=t.toLowerCase();for(const i of T(this,Os))if(typeof i=="string"){if(i!==r)continue;e=i;break}else{if(i.hash!==r)continue;e=i;break}}if(e==null)throw new Error("no such tx");return typeof e=="string"?await this.provider.getTransaction(e):e}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if(typeof t=="number")return e[t];t=t.toLowerCase();for(const r of e)if(r.hash===t)return r;K(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return TW(this)}}Os=new WeakMap;class nd{constructor(t,e){Z(this,"provider");Z(this,"transactionHash");Z(this,"blockHash");Z(this,"blockNumber");Z(this,"removed");Z(this,"address");Z(this,"data");Z(this,"topics");Z(this,"index");Z(this,"transactionIndex");this.provider=e;const r=Object.freeze(t.topics.slice());$t(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:i,index:s,removed:o,topics:c,transactionHash:u,transactionIndex:f}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:i,index:s,removed:o,topics:c,transactionHash:u,transactionIndex:f}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return ht(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return ht(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return ht(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return OW(this)}}var Th;class gT{constructor(t,e){Z(this,"provider");Z(this,"to");Z(this,"from");Z(this,"contractAddress");Z(this,"hash");Z(this,"index");Z(this,"blockHash");Z(this,"blockNumber");Z(this,"logsBloom");Z(this,"gasUsed");Z(this,"blobGasUsed");Z(this,"cumulativeGasUsed");Z(this,"gasPrice");Z(this,"blobGasPrice");Z(this,"type");Z(this,"status");Z(this,"root");nt(this,Th);$(this,Th,Object.freeze(t.logs.map(i=>new nd(i,e))));let r=pT;t.effectiveGasPrice!=null?r=t.effectiveGasPrice:t.gasPrice!=null&&(r=t.gasPrice),$t(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return T(this,Th)}toJSON(){const{to:t,from:e,contractAddress:r,hash:i,index:s,blockHash:o,blockNumber:c,logsBloom:u,logs:f,status:h,root:y}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:c,contractAddress:r,cumulativeGasUsed:En(this.cumulativeGasUsed),from:e,gasPrice:En(this.gasPrice),blobGasUsed:En(this.blobGasUsed),blobGasPrice:En(this.blobGasPrice),gasUsed:En(this.gasUsed),hash:i,index:s,logs:f,logsBloom:u,root:y,status:h,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(t==null)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(t==null)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return mT(this)}reorderedEvent(t){return ht(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),yT(this,t)}}Th=new WeakMap;var vo;const hb=class hb{constructor(t,e){Z(this,"provider");Z(this,"blockNumber");Z(this,"blockHash");Z(this,"index");Z(this,"hash");Z(this,"type");Z(this,"to");Z(this,"from");Z(this,"nonce");Z(this,"gasLimit");Z(this,"gasPrice");Z(this,"maxPriorityFeePerGas");Z(this,"maxFeePerGas");Z(this,"maxFeePerBlobGas");Z(this,"data");Z(this,"value");Z(this,"chainId");Z(this,"signature");Z(this,"accessList");Z(this,"blobVersionedHashes");nt(this,vo);this.provider=e,this.blockNumber=t.blockNumber!=null?t.blockNumber:null,this.blockHash=t.blockHash!=null?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=t.maxPriorityFeePerGas!=null?t.maxPriorityFeePerGas:null,this.maxFeePerGas=t.maxFeePerGas!=null?t.maxFeePerGas:null,this.maxFeePerBlobGas=t.maxFeePerBlobGas!=null?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=t.accessList!=null?t.accessList:null,this.blobVersionedHashes=t.blobVersionedHashes!=null?t.blobVersionedHashes:null,$(this,vo,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:i,type:s,to:o,from:c,nonce:u,data:f,signature:h,accessList:y,blobVersionedHashes:A}=this;return{_type:"TransactionResponse",accessList:y,blockNumber:t,blockHash:e,blobVersionedHashes:A,chainId:En(this.chainId),data:f,from:c,gasLimit:En(this.gasLimit),gasPrice:En(this.gasPrice),hash:i,maxFeePerGas:En(this.maxFeePerGas),maxPriorityFeePerGas:En(this.maxPriorityFeePerGas),maxFeePerBlobGas:En(this.maxFeePerBlobGas),nonce:u,signature:h,to:o,index:r,type:s,value:En(this.value)}}async getBlock(){let t=this.blockNumber;if(t==null){const r=await this.getTransaction();r&&(t=r.blockNumber)}if(t==null)return null;const e=this.provider.getBlock(t);if(e==null)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:e,blockNumber:r}=await lr({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return e==null||e.blockNumber==null?0:r-e.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const r=t??1,i=e??0;let s=T(this,vo),o=-1,c=s===-1;const u=async()=>{if(c)return null;const{blockNumber:A,nonce:b}=await lr({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(b<this.nonce){s=A;return}if(c)return null;const R=await this.getTransaction();if(!(R&&R.blockNumber!=null))for(o===-1&&(o=s-3,o<T(this,vo)&&(o=T(this,vo)));o<=A;){if(c)return null;const k=await this.provider.getBlock(o,!0);if(k==null)return;for(const S of k)if(S===this.hash)return;for(let S=0;S<k.length;S++){const B=await k.getTransaction(S);if(B.from===this.from&&B.nonce===this.nonce){if(c)return null;const H=await this.provider.getTransactionReceipt(B.hash);if(H==null||A-H.blockNumber+1<r)return;let U="replaced";B.data===this.data&&B.to===this.to&&B.value===this.value?U="repriced":B.data==="0x"&&B.from===B.to&&B.value===pT&&(U="cancelled"),ht(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:U==="replaced"||U==="cancelled",reason:U,replacement:B.replaceableTransaction(s),hash:B.hash,receipt:H})}}o++}},f=A=>{if(A==null||A.status!==0)return A;ht(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:A.to,from:A.from,data:""},receipt:A})},h=await this.provider.getTransactionReceipt(this.hash);if(r===0)return f(h);if(h){if(await h.confirmations()>=r)return f(h)}else if(await u(),r===0)return null;return await new Promise((A,b)=>{const R=[],k=()=>{R.forEach(B=>B())};if(R.push(()=>{c=!0}),i>0){const B=setTimeout(()=>{k(),b(Ze("wait for transaction timeout","TIMEOUT"))},i);R.push(()=>{clearTimeout(B)})}const S=async B=>{if(await B.confirmations()>=r){k();try{A(f(B))}catch(H){b(H)}}};if(R.push(()=>{this.provider.off(this.hash,S)}),this.provider.on(this.hash,S),s>=0){const B=async()=>{try{await u()}catch(H){if(Wn(H,"TRANSACTION_REPLACED")){k(),b(H);return}}c||this.provider.once("block",B)};R.push(()=>{this.provider.off("block",B)}),this.provider.once("block",B)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return ht(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),mT(this)}reorderedEvent(t){return ht(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ht(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),yT(this,t)}replaceableTransaction(t){K(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new hb(this,this.provider);return $(e,vo,t),e}};vo=new WeakMap;let vh=hb;function TW(n){return{orphan:"drop-block",hash:n.hash,number:n.number}}function yT(n,t){return{orphan:"reorder-transaction",tx:n,other:t}}function mT(n){return{orphan:"drop-transaction",tx:n}}function OW(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class ib extends nd{constructor(e,r,i){super(e,e.provider);Z(this,"interface");Z(this,"fragment");Z(this,"args");const s=r.decodeEventLog(i,e.data,e.topics);$t(this,{args:s,fragment:i,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class wT extends nd{constructor(e,r){super(e,e.provider);Z(this,"error");$t(this,{error:r})}}var Du;class NW extends gT{constructor(e,r,i){super(i,r);nt(this,Du);$(this,Du,e)}get logs(){return super.logs.map(e=>{const r=e.topics.length?T(this,Du).getEvent(e.topics[0]):null;if(r)try{return new ib(e,T(this,Du),r)}catch(i){return new wT(e,i)}return e})}}Du=new WeakMap;var Oh;class sb extends vh{constructor(e,r,i){super(i,r);nt(this,Oh);$(this,Oh,e)}async wait(e,r){const i=await super.wait(e,r);return i==null?null:new NW(T(this,Oh),this.provider,i)}}Oh=new WeakMap;class bT extends jI{constructor(e,r,i,s){super(e,r,i);Z(this,"log");$t(this,{log:s})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class CW extends bT{constructor(t,e,r,i,s){super(t,e,r,new ib(s,t.interface,i));const o=t.interface.decodeEventLog(i,this.log.data,this.log.topics);$t(this,{args:o,fragment:i})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Cv=BigInt(0);function _T(n){return n&&typeof n.call=="function"}function AT(n){return n&&typeof n.estimateGas=="function"}function Vp(n){return n&&typeof n.resolveName=="function"}function ET(n){return n&&typeof n.sendTransaction=="function"}function vT(n){if(n!=null){if(Vp(n))return n;if(n.provider)return n.provider}}var Nh;class BW{constructor(t,e,r){nt(this,Nh);Z(this,"fragment");if($t(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const i=wc(t.runner,"resolveName"),s=Vp(i)?i:null;$(this,Nh,async function(){const o=await Promise.all(e.inputs.map((c,u)=>r[u]==null?null:c.walkAsync(r[u],(h,y)=>h==="address"?Array.isArray(y)?Promise.all(y.map(A=>yr(A,s))):yr(y,s):y)));return t.interface.encodeFilterTopics(e,o)}())}getTopicFilter(){return T(this,Nh)}}Nh=new WeakMap;function wc(n,t){return n==null?null:typeof n[t]=="function"?n:n.provider&&typeof n.provider[t]=="function"?n.provider:null}function ka(n){return n==null?null:n.provider||null}async function xT(n,t){const e=ar.dereference(n,"overrides");K(typeof e=="object","invalid overrides parameter","overrides",n);const r=D0(e);return K(r.to==null||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),K(r.data==null||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}async function PW(n,t,e){const r=wc(n,"resolveName"),i=Vp(r)?r:null;return await Promise.all(t.map((s,o)=>s.walkAsync(e[o],(c,u)=>(u=ar.dereference(u,c),c==="address"?yr(u,i):u))))}function MW(n){const t=async function(o){const c=await xT(o,["data"]);c.to=await n.getAddress(),c.from&&(c.from=await yr(c.from,vT(n.runner)));const u=n.interface,f=Nt(c.value||Cv,"overrides.value")===Cv,h=(c.data||"0x")==="0x";u.fallback&&!u.fallback.payable&&u.receive&&!h&&!f&&K(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),K(u.fallback||h,"cannot send data to receive-only contract","overrides.data",c.data);const y=u.receive||u.fallback&&u.fallback.payable;return K(y||f,"cannot send value to non-payable fallback","overrides.value",c.value),K(u.fallback||h,"cannot send data to receive-only contract","overrides.data",c.data),c},e=async function(o){const c=wc(n.runner,"call");ht(_T(c),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await t(o);try{return await c.call(u)}catch(f){throw $1(f)&&f.data?n.interface.makeError(f.data,u):f}},r=async function(o){const c=n.runner;ht(ET(c),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await c.sendTransaction(await t(o)),f=ka(n.runner);return new sb(n.interface,f,u)},i=async function(o){const c=wc(n.runner,"estimateGas");return ht(AT(c),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await c.estimateGas(await t(o))},s=async o=>await r(o);return $t(s,{_contract:n,estimateGas:i,populateTransaction:t,send:r,staticCall:e}),s}function LW(n,t){const e=function(...f){const h=n.interface.getFunction(t,f);return ht(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:f}}),h},r=async function(...f){const h=e(...f);let y={};if(h.inputs.length+1===f.length&&(y=await xT(f.pop()),y.from&&(y.from=await yr(y.from,vT(n.runner)))),h.inputs.length!==f.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const A=await PW(n.runner,h.inputs,f);return Object.assign({},y,await lr({to:n.getAddress(),data:n.interface.encodeFunctionData(h,A)}))},i=async function(...f){const h=await c(...f);return h.length===1?h[0]:h},s=async function(...f){const h=n.runner;ht(ET(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const y=await h.sendTransaction(await r(...f)),A=ka(n.runner);return new sb(n.interface,A,y)},o=async function(...f){const h=wc(n.runner,"estimateGas");return ht(AT(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await r(...f))},c=async function(...f){const h=wc(n.runner,"call");ht(_T(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const y=await r(...f);let A="0x";try{A=await h.call(y)}catch(R){throw $1(R)&&R.data?n.interface.makeError(R.data,y):R}const b=e(...f);return n.interface.decodeFunctionResult(b,A)},u=async(...f)=>e(...f).constant?await i(...f):await s(...f);return $t(u,{name:n.interface.getFunctionName(t),_contract:n,_key:t,getFragment:e,estimateGas:o,populateTransaction:r,send:s,staticCall:i,staticCallResult:c}),Object.defineProperty(u,"fragment",{configurable:!1,enumerable:!0,get:()=>{const f=n.interface.getFunction(t);return ht(f,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),f}}),u}function UW(n,t){const e=function(...i){const s=n.interface.getEvent(t,i);return ht(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:i}}),s},r=function(...i){return new BW(n,e(...i),i)};return $t(r,{name:n.interface.getEventName(t),_contract:n,_key:t,getFragment:e}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const i=n.interface.getEvent(t);return ht(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),i}}),r}const F0=Symbol.for("_ethersInternal_contract"),RT=new WeakMap;function DW(n,t){RT.set(n[F0],t)}function Lr(n){return RT.get(n[F0])}function FW(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function ob(n,t){let e,r=null;if(Array.isArray(t)){const s=function(o){if(He(o,32))return o;const c=n.interface.getEvent(o);return K(c,"unknown fragment","name",o),c.topicHash};e=t.map(o=>o==null?null:Array.isArray(o)?o.map(s):s(o))}else t==="*"?e=[null]:typeof t=="string"?He(t,32)?e=[t]:(r=n.interface.getEvent(t),K(r,"unknown fragment","event",t),e=[r.topicHash]):FW(t)?e=await t.getTopicFilter():"fragment"in t?(r=t.fragment,e=[r.topicHash]):K(!1,"unknown event name","event",t);e=e.map(s=>{if(s==null)return null;if(Array.isArray(s)){const o=Array.from(new Set(s.map(c=>c.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return s.toLowerCase()});const i=e.map(s=>s==null?"null":Array.isArray(s)?s.join("|"):s).join("&");return{fragment:r,tag:i,topics:e}}async function kf(n,t){const{subs:e}=Lr(n);return e.get((await ob(n,t)).tag)||null}async function Bv(n,t,e){const r=ka(n.runner);ht(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:i,tag:s,topics:o}=await ob(n,e),{addr:c,subs:u}=Lr(n);let f=u.get(s);if(!f){const y={address:c||n,topics:o},A=S=>{let B=i;if(B==null)try{B=n.interface.getEvent(S.topics[0])}catch{}if(B){const H=B,U=i?n.interface.decodeEventLog(i,S.data,S.topics):[];vw(n,e,U,G=>new CW(n,G,e,H,S))}else vw(n,e,[],H=>new bT(n,H,e,S))};let b=[];f={tag:s,listeners:[],start:()=>{b.length||b.push(r.on(y,A))},stop:async()=>{if(b.length==0)return;let S=b;b=[],await Promise.all(S),r.off(y,A)}},u.set(s,f)}return f}let Ew=Promise.resolve();async function $W(n,t,e,r){await Ew;const i=await kf(n,t);if(!i)return!1;const s=i.listeners.length;return i.listeners=i.listeners.filter(({listener:o,once:c})=>{const u=Array.from(e);r&&u.push(r(c?null:o));try{o.call(n,...u)}catch{}return!c}),i.listeners.length===0&&(i.stop(),Lr(n).subs.delete(i.tag)),s>0}async function vw(n,t,e,r){try{await Ew}catch{}const i=$W(n,t,e,r);return Ew=i,await i}const Hd=["then"];var Wv;Wv=F0;const Df=class Df{constructor(t,e,r,i){Z(this,"target");Z(this,"interface");Z(this,"runner");Z(this,"filters");Z(this,Wv);Z(this,"fallback");K(typeof t=="string"||Nk(t),"invalid value for Contract target","target",t),r==null&&(r=null);const s=Aw.from(e);$t(this,{target:t,runner:r,interface:s}),Object.defineProperty(this,F0,{value:{}});let o,c=null,u=null;if(i){const y=ka(r);u=new sb(this.interface,y,i)}let f=new Map;if(typeof t=="string")if(He(t))c=t,o=Promise.resolve(t);else{const y=wc(r,"resolveName");if(!Vp(y))throw Ze("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=y.resolveName(t).then(A=>{if(A==null)throw Ze("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Lr(this).addr=A,A})}else o=t.getAddress().then(y=>{if(y==null)throw new Error("TODO");return Lr(this).addr=y,y});DW(this,{addrPromise:o,addr:c,deployTx:u,subs:f});const h=new Proxy({},{get:(y,A,b)=>{if(typeof A=="symbol"||Hd.indexOf(A)>=0)return Reflect.get(y,A,b);try{return this.getEvent(A)}catch(R){if(!Wn(R,"INVALID_ARGUMENT")||R.argument!=="key")throw R}},has:(y,A)=>Hd.indexOf(A)>=0?Reflect.has(y,A):Reflect.has(y,A)||this.interface.hasEvent(String(A))});return $t(this,{filters:h}),$t(this,{fallback:s.receive||s.fallback?MW(this):null}),new Proxy(this,{get:(y,A,b)=>{if(typeof A=="symbol"||A in y||Hd.indexOf(A)>=0)return Reflect.get(y,A,b);try{return y.getFunction(A)}catch(R){if(!Wn(R,"INVALID_ARGUMENT")||R.argument!=="key")throw R}},has:(y,A)=>typeof A=="symbol"||A in y||Hd.indexOf(A)>=0?Reflect.has(y,A):y.interface.hasFunction(A)})}connect(t){return new Df(this.target,this.interface,t)}attach(t){return new Df(t,this.interface,this.runner)}async getAddress(){return await Lr(this).addrPromise}async getDeployedCode(){const t=ka(this.runner);ht(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return e==="0x"?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=ka(this.runner);return ht(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((i,s)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return i(this);r.once("block",o)}catch(c){s(c)}};o()})}deploymentTransaction(){return Lr(this).deployTx}getFunction(t){return typeof t!="string"&&(t=t.format()),LW(this,t)}getEvent(t){return typeof t!="string"&&(t=t.format()),UW(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,r){e==null&&(e=0),r==null&&(r="latest");const{addr:i,addrPromise:s}=Lr(this),o=i||await s,{fragment:c,topics:u}=await ob(this,t),f={address:o,topics:u,fromBlock:e,toBlock:r},h=ka(this.runner);return ht(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(f)).map(y=>{let A=c;if(A==null)try{A=this.interface.getEvent(y.topics[0])}catch{}if(A)try{return new ib(y,this.interface,A)}catch(b){return new wT(y,b)}return new nd(y,h)})}async on(t,e){const r=await Bv(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}async once(t,e){const r=await Bv(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.start(),this}async emit(t,...e){return await vw(this,t,e,null)}async listenerCount(t){if(t){const i=await kf(this,t);return i?i.listeners.length:0}const{subs:e}=Lr(this);let r=0;for(const{listeners:i}of e.values())r+=i.length;return r}async listeners(t){if(t){const i=await kf(this,t);return i?i.listeners.map(({listener:s})=>s):[]}const{subs:e}=Lr(this);let r=[];for(const{listeners:i}of e.values())r=r.concat(i.map(({listener:s})=>s));return r}async off(t,e){const r=await kf(this,t);if(!r)return this;if(e){const i=r.listeners.map(({listener:s})=>s).indexOf(e);i>=0&&r.listeners.splice(i,1)}return(e==null||r.listeners.length===0)&&(r.stop(),Lr(this).subs.delete(r.tag)),this}async removeAllListeners(t){if(t){const e=await kf(this,t);if(!e)return this;e.stop(),Lr(this).subs.delete(e.tag)}else{const{subs:e}=Lr(this);for(const{tag:r,stop:i}of e.values())i(),e.delete(r)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){class e extends Df{constructor(i,s=null){super(i,t,s)}}return e}static from(t,e,r){return r==null&&(r=null),new this(t,e,r)}};let xw=Df;function HW(){return xw}class hu extends HW(){}function dm(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):K(!1,"unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}class zW{constructor(t){Z(this,"name");$t(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}async encodeAddress(t,e){throw new Error("unsupported coin")}async decodeAddress(t,e){throw new Error("unsupported coin")}}const ST=new RegExp("^(ipfs)://(.*)$","i"),Pv=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),ST,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];var xo,Ha,Ro,Wc,j0,IT;const nu=class nu{constructor(t,e,r){nt(this,Ro);Z(this,"provider");Z(this,"address");Z(this,"name");nt(this,xo);nt(this,Ha);$t(this,{provider:t,address:e,name:r}),$(this,xo,null),$(this,Ha,new hu(e,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],t))}async supportsWildcard(){return T(this,xo)==null&&$(this,xo,(async()=>{try{return await T(this,Ha).supportsInterface("0x9061b923")}catch(t){if(Wn(t,"CALL_EXCEPTION"))return!1;throw $(this,xo,null),t}})()),await T(this,xo)}async getAddress(t){if(t==null&&(t=60),t===60)try{const s=await _t(this,Ro,Wc).call(this,"addr(bytes32)");return s==null||s===gh?null:s}catch(s){if(Wn(s,"CALL_EXCEPTION"))return null;throw s}if(t>=0&&t<2147483648){let s=t+2147483648;const o=await _t(this,Ro,Wc).call(this,"addr(bytes32,uint)",[s]);if(He(o,20))return Pe(o)}let e=null;for(const s of this.provider.plugins)if(s instanceof zW&&s.supportsCoinType(t)){e=s;break}if(e==null)return null;const r=await _t(this,Ro,Wc).call(this,"addr(bytes32,uint)",[t]);if(r==null||r==="0x")return null;const i=await e.decodeAddress(t,r);if(i!=null)return i;ht(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}async getText(t){const e=await _t(this,Ro,Wc).call(this,"text(bytes32,string)",[t]);return e==null||e==="0x"?null:e}async getContentHash(){const t=await _t(this,Ro,Wc).call(this,"contenthash(bytes32)");if(t==null||t==="0x")return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const i=e[1]==="e3010170"?"ipfs":"ipns",s=parseInt(e[4],16);if(e[5].length===s*2)return`${i}://${eV("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&r[1].length===64)return`bzz://${r[1]}`;ht(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const t=[{type:"name",value:this.name}];try{const e=await this.getText("avatar");if(e==null)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:e});for(let r=0;r<Pv.length;r++){const i=e.match(Pv[r]);if(i==null)continue;const s=i[1].toLowerCase();switch(s){case"https":case"data":return t.push({type:"url",value:e}),{linkage:t,url:e};case"ipfs":{const o=dm(e);return t.push({type:"ipfs",value:e}),t.push({type:"url",value:o}),{linkage:t,url:o}}case"erc721":case"erc1155":{const o=s==="erc721"?"tokenURI(uint256)":"uri(uint256)";t.push({type:s,value:e});const c=await this.getAddress();if(c==null)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const u=(i[2]||"").split("/");if(u.length!==2)return t.push({type:`!${s}caip`,value:i[2]||""}),{url:null,linkage:t};const f=u[1],h=new hu(u[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(s==="erc721"){const k=await h.ownerOf(f);if(c!==k)return t.push({type:"!owner",value:k}),{url:null,linkage:t};t.push({type:"owner",value:k})}else if(s==="erc1155"){const k=await h.balanceOf(c,f);if(!k)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:k.toString()})}let y=await h[o](f);if(y==null||y==="0x")return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:y}),s==="erc1155"&&(y=y.replace("{id}",Xo(f,32).substring(2)),t.push({type:"metadata-url-expanded",value:y})),y.match(/^ipfs:/i)&&(y=dm(y)),t.push({type:"metadata-url",value:y});let A={};const b=await new Zs(y).send();b.assertOk();try{A=b.bodyJson}catch{try{t.push({type:"!metadata",value:b.bodyText})}catch{const B=b.body;return B&&t.push({type:"!metadata",value:kt(B)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!A)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(A)});let R=A.image;if(typeof R!="string")return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(!R.match(/^(https:\/\/|data:)/i)){if(R.match(ST)==null)return t.push({type:"!imageUrl-ipfs",value:R}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:R}),R=dm(R)}return t.push({type:"url",value:R}),{linkage:t,url:R}}}}}catch{}return{linkage:t,url:null}}static async getEnsAddress(t){const e=await t.getNetwork(),r=e.getPlugin("org.ethers.plugins.network.Ens");return ht(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}static async fromName(t,e){var i;let r=e;for(;;){if(r===""||r==="."||e!=="eth"&&r==="eth")return null;const s=await _t(i=nu,j0,IT).call(i,t,r);if(s!=null){const o=new nu(t,s,e);return r!==e&&!await o.supportsWildcard()?null:o}r=r.split(".").slice(1).join(".")}}};xo=new WeakMap,Ha=new WeakMap,Ro=new WeakSet,Wc=async function(t,e){e=(e||[]).slice();const r=T(this,Ha).interface;e.unshift(bw(this.name));let i=null;await this.supportsWildcard()&&(i=r.getFunction(t),ht(i,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[Hj(this.name,255),r.encodeFunctionData(i,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const s=await T(this,Ha)[t](...e);return i?r.decodeFunctionResult(i,s)[0]:s}catch(s){if(!Wn(s,"CALL_EXCEPTION"))throw s}return null},j0=new WeakSet,IT=async function(t,e){const r=await nu.getEnsAddress(t);try{const s=await new hu(r,["function resolver(bytes32) view returns (address)"],t).resolver(bw(e),{enableCcipRead:!0});return s===gh?null:s}catch(i){throw i}return null},nt(nu,j0);let $0=nu;const Mv=BigInt(0);function he(n,t){return function(e){return e==null?t:n(e)}}function Kp(n,t){return e=>{if(t&&e==null)return null;if(!Array.isArray(e))throw new Error("not an array");return e.map(r=>n(r))}}function rd(n,t){return e=>{const r={};for(const i in n){let s=i;if(t&&i in t&&!(s in e)){for(const o of t[i])if(o in e){s=o;break}}try{const o=n[i](e[s]);o!==void 0&&(r[i]=o)}catch(o){const c=o instanceof Error?o.message:"not-an-error";ht(!1,`invalid value for value.${i} (${c})`,"BAD_DATA",{value:e})}}return r}}function GW(n){switch(n){case!0:case"true":return!0;case!1:case"false":return!1}K(!1,`invalid boolean; ${JSON.stringify(n)}`,"value",n)}function _l(n){return K(He(n,!0),"invalid data","value",n),n}function jn(n){return K(He(n,32),"invalid hash","value",n),n}const VW=rd({address:Pe,blockHash:jn,blockNumber:oe,data:_l,index:oe,removed:he(GW,!1),topics:Kp(jn),transactionHash:jn,transactionIndex:oe},{index:["logIndex"]});function KW(n){return VW(n)}const jW=rd({hash:he(jn),parentHash:jn,parentBeaconBlockRoot:he(jn,null),number:oe,timestamp:oe,nonce:he(_l),difficulty:Nt,gasLimit:Nt,gasUsed:Nt,stateRoot:he(jn,null),receiptsRoot:he(jn,null),blobGasUsed:he(Nt,null),excessBlobGas:he(Nt,null),miner:he(Pe),prevRandao:he(jn,null),extraData:_l,baseFeePerGas:he(Nt)},{prevRandao:["mixHash"]});function WW(n){const t=jW(n);return t.transactions=n.transactions.map(e=>typeof e=="string"?e:kT(e)),t}const ZW=rd({transactionIndex:oe,blockNumber:oe,transactionHash:jn,address:Pe,topics:Kp(jn),data:_l,index:oe,blockHash:jn},{index:["logIndex"]});function qW(n){return ZW(n)}const QW=rd({to:he(Pe,null),from:he(Pe,null),contractAddress:he(Pe,null),index:oe,root:he(kt),gasUsed:Nt,blobGasUsed:he(Nt,null),logsBloom:he(_l),blockHash:jn,hash:jn,logs:Kp(qW),blockNumber:oe,cumulativeGasUsed:Nt,effectiveGasPrice:he(Nt),blobGasPrice:he(Nt,null),status:he(oe),type:he(oe,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function JW(n){return QW(n)}function kT(n){n.to&&Nt(n.to)===Mv&&(n.to="0x0000000000000000000000000000000000000000");const t=rd({hash:jn,index:he(oe,void 0),type:e=>e==="0x"||e==null?0:oe(e),accessList:he(Sc,null),blobVersionedHashes:he(Kp(jn,!0),null),blockHash:he(jn,null),blockNumber:he(oe,null),transactionIndex:he(oe,null),from:Pe,gasPrice:he(Nt),maxPriorityFeePerGas:he(Nt),maxFeePerGas:he(Nt),maxFeePerBlobGas:he(Nt,null),gasLimit:Nt,to:he(Pe,null),value:Nt,nonce:oe,data:_l,creates:he(Pe,null),chainId:he(Nt,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(n);if(t.to==null&&t.creates==null&&(t.creates=VK(t)),(n.type===1||n.type===2)&&n.accessList==null&&(t.accessList=[]),n.signature?t.signature=Ri.from(n.signature):t.signature=Ri.from(n),t.chainId==null){const e=t.signature.legacyChainId;e!=null&&(t.chainId=e)}return t.blockHash&&Nt(t.blockHash)===Mv&&(t.blockHash=null),t}const YW="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class id{constructor(t){Z(this,"name");$t(this,{name:t})}clone(){return new id(this.name)}}class jp extends id{constructor(e,r){e==null&&(e=0);super(`org.ethers.network.plugins.GasCost#${e||0}`);Z(this,"effectiveBlock");Z(this,"txBase");Z(this,"txCreate");Z(this,"txDataZero");Z(this,"txDataNonzero");Z(this,"txAccessListStorageKey");Z(this,"txAccessListAddress");const i={effectiveBlock:e};function s(o,c){let u=(r||{})[o];u==null&&(u=c),K(typeof u=="number",`invalud value for ${o}`,"costs",r),i[o]=u}s("txBase",21e3),s("txCreate",32e3),s("txDataZero",4),s("txDataNonzero",16),s("txAccessListStorageKey",1900),s("txAccessListAddress",2400),$t(this,i)}clone(){return new jp(this.effectiveBlock,this)}}class Wp extends id{constructor(e,r){super("org.ethers.plugins.network.Ens");Z(this,"address");Z(this,"targetNetwork");$t(this,{address:e||YW,targetNetwork:r??1})}clone(){return new Wp(this.address,this.targetNetwork)}}var Ch,Bh;class XW extends id{constructor(e,r){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");nt(this,Ch);nt(this,Bh);$(this,Ch,e),$(this,Bh,r)}get url(){return T(this,Ch)}get processFunc(){return T(this,Bh)}clone(){return this}}Ch=new WeakMap,Bh=new WeakMap;const pm=new Map;var Fu,$u,So;const ru=class ru{constructor(t,e){nt(this,Fu);nt(this,$u);nt(this,So);$(this,Fu,t),$(this,$u,Nt(e)),$(this,So,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return T(this,Fu)}set name(t){$(this,Fu,t)}get chainId(){return T(this,$u)}set chainId(t){$(this,$u,Nt(t,"chainId"))}matches(t){if(t==null)return!1;if(typeof t=="string"){try{return this.chainId===Nt(t)}catch{}return this.name===t}if(typeof t=="number"||typeof t=="bigint"){try{return this.chainId===Nt(t)}catch{}return!1}if(typeof t=="object"){if(t.chainId!=null){try{return this.chainId===Nt(t.chainId)}catch{}return!1}return t.name!=null?this.name===t.name:!1}return!1}get plugins(){return Array.from(T(this,So).values())}attachPlugin(t){if(T(this,So).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return T(this,So).set(t.name,t.clone()),this}getPlugin(t){return T(this,So).get(t)||null}getPlugins(t){return this.plugins.filter(e=>e.name.split("#")[0]===t)}clone(){const t=new ru(this.name,this.chainId);return this.plugins.forEach(e=>{t.attachPlugin(e.clone())}),t}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new jp;let r=e.txBase;if(t.to==null&&(r+=e.txCreate),t.data)for(let i=2;i<t.data.length;i+=2)t.data.substring(i,i+2)==="00"?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const i=Sc(t.accessList);for(const s in i)r+=e.txAccessListAddress+e.txAccessListStorageKey*i[s].storageKeys.length}return r}static from(t){if(tZ(),t==null)return ru.from("mainnet");if(typeof t=="number"&&(t=BigInt(t)),typeof t=="string"||typeof t=="bigint"){const e=pm.get(t);if(e)return e();if(typeof t=="bigint")return new ru("unknown",t);K(!1,"unknown network","network",t)}if(typeof t.clone=="function")return t.clone();if(typeof t=="object"){K(typeof t.name=="string"&&typeof t.chainId=="number","invalid network object name or chainId","network",t);const e=new ru(t.name,t.chainId);return(t.ensAddress||t.ensNetwork!=null)&&e.attachPlugin(new Wp(t.ensAddress,t.ensNetwork)),e}K(!1,"invalid network","network",t)}static register(t,e){typeof t=="number"&&(t=BigInt(t));const r=pm.get(t);r&&K(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),pm.set(t,e)}};Fu=new WeakMap,$u=new WeakMap,So=new WeakMap;let Ji=ru;function Lv(n,t){const e=String(n);if(!e.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${n}`);const r=e.split(".");if(r.length===1&&r.push(""),r.length!==2)throw new Error(`invalid gwei value: ${n}`);for(;r[1].length<t;)r[1]+="0";if(r[1].length>9){let i=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||i++,r[1]=i.toString()}return BigInt(r[0]+r[1])}function Uv(n){return new XW(n,async(t,e,r)=>{r.setHeader("User-Agent","ethers");let i;try{const[s,o]=await Promise.all([r.send(),t()]);i=s;const c=i.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:Lv(c.maxFee,9),maxPriorityFeePerGas:Lv(c.maxPriorityFee,9)}}catch(s){ht(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:i,error:s})}})}let Dv=!1;function tZ(){if(Dv)return;Dv=!0;function n(t,e,r){const i=function(){const s=new Ji(t,e);return r.ensNetwork!=null&&s.attachPlugin(new Wp(null,r.ensNetwork)),s.attachPlugin(new jp),(r.plugins||[]).forEach(o=>{s.attachPlugin(o)}),s};Ji.register(t,i),Ji.register(e,i),r.altNames&&r.altNames.forEach(s=>{Ji.register(s,i)})}n("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),n("ropsten",3,{ensNetwork:3}),n("rinkeby",4,{ensNetwork:4}),n("goerli",5,{ensNetwork:5}),n("kovan",42,{ensNetwork:42}),n("sepolia",11155111,{ensNetwork:11155111}),n("holesky",17e3,{ensNetwork:17e3}),n("classic",61,{}),n("classicKotti",6,{}),n("arbitrum",42161,{ensNetwork:1}),n("arbitrum-goerli",421613,{}),n("arbitrum-sepolia",421614,{}),n("base",8453,{ensNetwork:1}),n("base-goerli",84531,{}),n("base-sepolia",84532,{}),n("bnb",56,{ensNetwork:1}),n("bnbt",97,{}),n("linea",59144,{ensNetwork:1}),n("linea-goerli",59140,{}),n("linea-sepolia",59141,{}),n("matic",137,{ensNetwork:1,plugins:[Uv("https://gasstation.polygon.technology/v2")]}),n("matic-amoy",80002,{}),n("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[Uv("https://gasstation-testnet.polygon.technology/v2")]}),n("optimism",10,{ensNetwork:1,plugins:[]}),n("optimism-goerli",420,{}),n("optimism-sepolia",11155420,{}),n("xdai",100,{ensNetwork:1})}function Rw(n){return JSON.parse(JSON.stringify(n))}var Ns,Jr,Io,Di,Hu,t0;class eZ{constructor(t){nt(this,Hu);nt(this,Ns);nt(this,Jr);nt(this,Io);nt(this,Di);$(this,Ns,t),$(this,Jr,null),$(this,Io,4e3),$(this,Di,-2)}get pollingInterval(){return T(this,Io)}set pollingInterval(t){$(this,Io,t)}start(){T(this,Jr)||($(this,Jr,T(this,Ns)._setTimeout(_t(this,Hu,t0).bind(this),T(this,Io))),_t(this,Hu,t0).call(this))}stop(){T(this,Jr)&&(T(this,Ns)._clearTimeout(T(this,Jr)),$(this,Jr,null))}pause(t){this.stop(),t&&$(this,Di,-2)}resume(){this.start()}}Ns=new WeakMap,Jr=new WeakMap,Io=new WeakMap,Di=new WeakMap,Hu=new WeakSet,t0=async function(){try{const t=await T(this,Ns).getBlockNumber();if(T(this,Di)===-2){$(this,Di,t);return}if(t!==T(this,Di)){for(let e=T(this,Di)+1;e<=t;e++){if(T(this,Jr)==null)return;await T(this,Ns).emit("block",e)}$(this,Di,t)}}catch{}T(this,Jr)!=null&&$(this,Jr,T(this,Ns)._setTimeout(_t(this,Hu,t0).bind(this),T(this,Io)))};var za,Ga,ko;class ab{constructor(t){nt(this,za);nt(this,Ga);nt(this,ko);$(this,za,t),$(this,ko,!1),$(this,Ga,e=>{this._poll(e,T(this,za))})}async _poll(t,e){throw new Error("sub-classes must override this")}start(){T(this,ko)||($(this,ko,!0),T(this,Ga).call(this,-2),T(this,za).on("block",T(this,Ga)))}stop(){T(this,ko)&&($(this,ko,!1),T(this,za).off("block",T(this,Ga)))}pause(t){this.stop()}resume(){this.start()}}za=new WeakMap,Ga=new WeakMap,ko=new WeakMap;var zu,Cs;class nZ extends ab{constructor(e,r){super(e);nt(this,zu);nt(this,Cs);$(this,zu,r),$(this,Cs,-2)}pause(e){e&&$(this,Cs,-2),super.pause(e)}async _poll(e,r){const i=await r.getBlock(T(this,zu));i!=null&&(T(this,Cs)===-2?$(this,Cs,i.number):i.number>T(this,Cs)&&(r.emit(T(this,zu),i.number),$(this,Cs,i.number)))}}zu=new WeakMap,Cs=new WeakMap;var W0;class rZ extends ab{constructor(e,r){super(e);nt(this,W0);$(this,W0,Rw(r))}async _poll(e,r){throw new Error("@TODO")}}W0=new WeakMap;var Gu;class iZ extends ab{constructor(e,r){super(e);nt(this,Gu);$(this,Gu,r)}async _poll(e,r){const i=await r.getTransactionReceipt(T(this,Gu));i&&r.emit(T(this,Gu),i)}}Gu=new WeakMap;var Bs,Vu,Ku,To,Yr,Z0,TT;class cb{constructor(t,e){nt(this,Z0);nt(this,Bs);nt(this,Vu);nt(this,Ku);nt(this,To);nt(this,Yr);$(this,Bs,t),$(this,Vu,Rw(e)),$(this,Ku,_t(this,Z0,TT).bind(this)),$(this,To,!1),$(this,Yr,-2)}start(){T(this,To)||($(this,To,!0),T(this,Yr)===-2&&T(this,Bs).getBlockNumber().then(t=>{$(this,Yr,t)}),T(this,Bs).on("block",T(this,Ku)))}stop(){T(this,To)&&($(this,To,!1),T(this,Bs).off("block",T(this,Ku)))}pause(t){this.stop(),t&&$(this,Yr,-2)}resume(){this.start()}}Bs=new WeakMap,Vu=new WeakMap,Ku=new WeakMap,To=new WeakMap,Yr=new WeakMap,Z0=new WeakSet,TT=async function(t){if(T(this,Yr)===-2)return;const e=Rw(T(this,Vu));e.fromBlock=T(this,Yr)+1,e.toBlock=t;const r=await T(this,Bs).getLogs(e);if(r.length===0){T(this,Yr)<t-60&&$(this,Yr,t-60);return}for(const i of r)T(this,Bs).emit(T(this,Vu),i),$(this,Yr,i.blockNumber)};const sZ=BigInt(2),oZ=10;function zd(n){return n&&typeof n.then=="function"}function e0(n,t){return n+":"+JSON.stringify(t,(e,r)=>{if(r==null)return"null";if(typeof r=="bigint")return`bigint:${r.toString()}`;if(typeof r=="string")return r.toLowerCase();if(typeof r=="object"&&!Array.isArray(r)){const i=Object.keys(r);return i.sort(),i.reduce((s,o)=>(s[o]=r[o],s),{})}return r})}class H0{constructor(t){Z(this,"name");$t(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function aZ(n){return JSON.parse(JSON.stringify(n))}function Sw(n){return n=Array.from(new Set(n).values()),n.sort(),n}async function gm(n,t){if(n==null)throw new Error("invalid event");if(Array.isArray(n)&&(n={topics:n}),typeof n=="string")switch(n){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:n,tag:n}}if(He(n,32)){const e=n.toLowerCase();return{type:"transaction",tag:e0("tx",{hash:e}),hash:e}}if(n.orphan){const e=n;return{type:"orphan",tag:e0("orphan",e),filter:aZ(e)}}if(n.address||n.topics){const e=n,r={topics:(e.topics||[]).map(i=>i==null?null:Array.isArray(i)?Sw(i.map(s=>s.toLowerCase())):i.toLowerCase())};if(e.address){const i=[],s=[],o=c=>{He(c)?i.push(c):s.push((async()=>{i.push(await yr(c,t))})())};Array.isArray(e.address)?e.address.forEach(o):o(e.address),s.length&&await Promise.all(s),r.address=Sw(i.map(c=>c.toLowerCase()))}return{filter:r,tag:e0("event",r),type:"event"}}K(!1,"unknown ProviderEvent","event",n)}function ym(){return new Date().getTime()}const cZ={cacheTimeout:250,pollingInterval:4e3};var ir,Oo,sr,ju,$r,Va,No,Ps,Ph,Xr,Wu,Zu,se,Cr,Iw,kw,Tf,Tw,Of,n0;class uZ{constructor(t,e){nt(this,se);nt(this,ir);nt(this,Oo);nt(this,sr);nt(this,ju);nt(this,$r);nt(this,Va);nt(this,No);nt(this,Ps);nt(this,Ph);nt(this,Xr);nt(this,Wu);nt(this,Zu);if($(this,Zu,Object.assign({},cZ,e||{})),t==="any")$(this,Va,!0),$(this,$r,null);else if(t){const r=Ji.from(t);$(this,Va,!1),$(this,$r,Promise.resolve(r)),setTimeout(()=>{this.emit("network",r,null)},0)}else $(this,Va,!1),$(this,$r,null);$(this,Ps,-1),$(this,No,new Map),$(this,ir,new Map),$(this,Oo,new Map),$(this,sr,null),$(this,ju,!1),$(this,Ph,1),$(this,Xr,new Map),$(this,Wu,!1)}get pollingInterval(){return T(this,Zu).pollingInterval}get provider(){return this}get plugins(){return Array.from(T(this,Oo).values())}attachPlugin(t){if(T(this,Oo).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return T(this,Oo).set(t.name,t.connect(this)),this}getPlugin(t){return T(this,Oo).get(t)||null}get disableCcipRead(){return T(this,Wu)}set disableCcipRead(t){$(this,Wu,!!t)}async ccipReadFetch(t,e,r){if(this.disableCcipRead||r.length===0||t.to==null)return null;const i=t.to.toLowerCase(),s=e.toLowerCase(),o=[];for(let c=0;c<r.length;c++){const u=r[c],f=u.replace("{sender}",i).replace("{data}",s),h=new Zs(f);u.indexOf("{data}")===-1&&(h.body={data:s,sender:i}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:c,urls:r});let y="unknown error",A;try{A=await h.send()}catch(b){o.push(b.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:{error:b}});continue}try{const b=A.bodyJson;if(b.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:b}),b.data;b.message&&(y=b.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:b})}catch{}ht(A.statusCode<400||A.statusCode>=500,`response not found during CCIP fetch: ${y}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:u,errorMessage:y}}),o.push(y)}ht(!1,`error encountered during CCIP fetch: ${o.map(c=>JSON.stringify(c)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,errorMessages:o}})}_wrapBlock(t,e){return new kW(WW(t),this)}_wrapLog(t,e){return new nd(KW(t),this)}_wrapTransactionReceipt(t,e){return new gT(JW(t),this)}_wrapTransactionResponse(t,e){return new vh(kT(t),this)}_detectNetwork(){ht(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(t){ht(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}async getBlockNumber(){const t=oe(await _t(this,se,Cr).call(this,{method:"getBlockNumber"}),"%response");return T(this,Ps)>=0&&$(this,Ps,t),t}_getAddress(t){return yr(t,this)}_getBlockTag(t){if(t==null)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}if(He(t))return He(t,32)?t:tu(t);if(typeof t=="bigint"&&(t=oe(t,"blockTag")),typeof t=="number")return t>=0?tu(t):T(this,Ps)>=0?tu(T(this,Ps)+t):this.getBlockNumber().then(e=>tu(e+t));K(!1,"invalid blockTag","blockTag",t)}_getFilter(t){const e=(t.topics||[]).map(u=>u==null?null:Array.isArray(u)?Sw(u.map(f=>f.toLowerCase())):u.toLowerCase()),r="blockHash"in t?t.blockHash:void 0,i=(u,f,h)=>{let y;switch(u.length){case 0:break;case 1:y=u[0];break;default:u.sort(),y=u}if(r&&(f!=null||h!=null))throw new Error("invalid filter");const A={};return y&&(A.address=y),e.length&&(A.topics=e),f&&(A.fromBlock=f),h&&(A.toBlock=h),r&&(A.blockHash=r),A};let s=[];if(t.address)if(Array.isArray(t.address))for(const u of t.address)s.push(this._getAddress(u));else s.push(this._getAddress(t.address));let o;"fromBlock"in t&&(o=this._getBlockTag(t.fromBlock));let c;return"toBlock"in t&&(c=this._getBlockTag(t.toBlock)),s.filter(u=>typeof u!="string").length||o!=null&&typeof o!="string"||c!=null&&typeof c!="string"?Promise.all([Promise.all(s),o,c]).then(u=>i(u[0],u[1],u[2])):i(s,o,c)}_getTransactionRequest(t){const e=D0(t),r=[];if(["to","from"].forEach(i=>{if(e[i]==null)return;const s=yr(e[i],this);zd(s)?r.push(async function(){e[i]=await s}()):e[i]=s}),e.blockTag!=null){const i=this._getBlockTag(e.blockTag);zd(i)?r.push(async function(){e.blockTag=await i}()):e.blockTag=i}return r.length?async function(){return await Promise.all(r),e}():e}async getNetwork(){if(T(this,$r)==null){const i=(async()=>{try{const s=await this._detectNetwork();return this.emit("network",s,null),s}catch(s){throw T(this,$r)===i&&$(this,$r,null),s}})();return $(this,$r,i),(await i).clone()}const t=T(this,$r),[e,r]=await Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(T(this,Va)?(this.emit("network",r,e),T(this,$r)===t&&$(this,$r,Promise.resolve(r))):ht(!1,`network changed: ${e.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}async getFeeData(){const t=await this.getNetwork(),e=async()=>{const{_block:i,gasPrice:s,priorityFee:o}=await lr({_block:_t(this,se,Tw).call(this,"latest",!1),gasPrice:(async()=>{try{const h=await _t(this,se,Cr).call(this,{method:"getGasPrice"});return Nt(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await _t(this,se,Cr).call(this,{method:"getPriorityFee"});return Nt(h,"%response")}catch{}return null})()});let c=null,u=null;const f=this._wrapBlock(i,t);return f&&f.baseFeePerGas&&(u=o??BigInt("1000000000"),c=f.baseFeePerGas*sZ+u),new Nv(s,c,u)},r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const i=new Zs(r.url),s=await r.processFunc(e,this,i);return new Nv(s.gasPrice,s.maxFeePerGas,s.maxPriorityFeePerGas)}return await e()}async estimateGas(t){let e=this._getTransactionRequest(t);return zd(e)&&(e=await e),Nt(await _t(this,se,Cr).call(this,{method:"estimateGas",transaction:e}),"%response")}async call(t){const{tx:e,blockTag:r}=await lr({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return await _t(this,se,kw).call(this,_t(this,se,Iw).call(this,e,r,t.enableCcipRead?0:-1))}async getBalance(t,e){return Nt(await _t(this,se,Tf).call(this,{method:"getBalance"},t,e),"%response")}async getTransactionCount(t,e){return oe(await _t(this,se,Tf).call(this,{method:"getTransactionCount"},t,e),"%response")}async getCode(t,e){return kt(await _t(this,se,Tf).call(this,{method:"getCode"},t,e))}async getStorage(t,e,r){const i=Nt(e,"position");return kt(await _t(this,se,Tf).call(this,{method:"getStorage",position:i},t,r))}async broadcastTransaction(t){const{blockNumber:e,hash:r,network:i}=await lr({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),s=L0.from(t);if(s.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(s,i).replaceableTransaction(e)}async getBlock(t,e){const{network:r,params:i}=await lr({network:this.getNetwork(),params:_t(this,se,Tw).call(this,t,!!e)});return i==null?null:this._wrapBlock(i,r)}async getTransaction(t){const{network:e,params:r}=await lr({network:this.getNetwork(),params:_t(this,se,Cr).call(this,{method:"getTransaction",hash:t})});return r==null?null:this._wrapTransactionResponse(r,e)}async getTransactionReceipt(t){const{network:e,params:r}=await lr({network:this.getNetwork(),params:_t(this,se,Cr).call(this,{method:"getTransactionReceipt",hash:t})});if(r==null)return null;if(r.gasPrice==null&&r.effectiveGasPrice==null){const i=await _t(this,se,Cr).call(this,{method:"getTransaction",hash:t});if(i==null)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=i.gasPrice}return this._wrapTransactionReceipt(r,e)}async getTransactionResult(t){const{result:e}=await lr({network:this.getNetwork(),result:_t(this,se,Cr).call(this,{method:"getTransactionResult",hash:t})});return e==null?null:kt(e)}async getLogs(t){let e=this._getFilter(t);zd(e)&&(e=await e);const{network:r,params:i}=await lr({network:this.getNetwork(),params:_t(this,se,Cr).call(this,{method:"getLogs",filter:e})});return i.map(s=>this._wrapLog(s,r))}_getProvider(t){ht(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(t){return await $0.fromName(this,t)}async getAvatar(t){const e=await this.getResolver(t);return e?await e.getAvatar():null}async resolveName(t){const e=await this.getResolver(t);return e?await e.getAddress():null}async lookupAddress(t){t=Pe(t);const e=bw(t.substring(2).toLowerCase()+".addr.reverse");try{const r=await $0.getEnsAddress(this),s=await new hu(r,["function resolver(bytes32) view returns (address)"],this).resolver(e);if(s==null||s===gh)return null;const c=await new hu(s,["function name(bytes32) view returns (string)"],this).name(e);return await this.resolveName(c)!==t?null:c}catch(r){if(Wn(r,"BAD_DATA")&&r.value==="0x"||Wn(r,"CALL_EXCEPTION"))return null;throw r}return null}async waitForTransaction(t,e,r){const i=e??1;return i===0?this.getTransactionReceipt(t):new Promise(async(s,o)=>{let c=null;const u=async f=>{try{const h=await this.getTransactionReceipt(t);if(h!=null&&f-h.blockNumber+1>=i){s(h),c&&(clearTimeout(c),c=null);return}}catch(h){console.log("EEE",h)}this.once("block",u)};r!=null&&(c=setTimeout(()=>{c!=null&&(c=null,this.off("block",u),o(Ze("timeout","TIMEOUT",{reason:"timeout"})))},r)),u(await this.getBlockNumber())})}async waitForBlock(t){ht(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(t){const e=T(this,Xr).get(t);e&&(e.timer&&clearTimeout(e.timer),T(this,Xr).delete(t))}_setTimeout(t,e){e==null&&(e=0);const r=df(this,Ph)._++,i=()=>{T(this,Xr).delete(r),t()};if(this.paused)T(this,Xr).set(r,{timer:null,func:i,time:e});else{const s=setTimeout(i,e);T(this,Xr).set(r,{timer:s,func:i,time:ym()})}return r}_forEachSubscriber(t){for(const e of T(this,ir).values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new H0(t.type);case"block":{const e=new eZ(this);return e.pollingInterval=this.pollingInterval,e}case"safe":case"finalized":return new nZ(this,t.type);case"event":return new cb(this,t.filter);case"transaction":return new iZ(this,t.hash);case"orphan":return new rZ(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of T(this,ir).values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),T(this,sr)!=null&&e.pause(T(this,sr));break}}async on(t,e){const r=await _t(this,se,n0).call(this,t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,T(this,sr)!=null&&r.subscriber.pause(T(this,sr))),this}async once(t,e){const r=await _t(this,se,n0).call(this,t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,T(this,sr)!=null&&r.subscriber.pause(T(this,sr))),this}async emit(t,...e){const r=await _t(this,se,Of).call(this,t,e);if(!r||r.listeners.length===0)return!1;const i=r.listeners.length;return r.listeners=r.listeners.filter(({listener:s,once:o})=>{const c=new jI(this,o?null:s,t);try{s.call(this,...e,c)}catch{}return!o}),r.listeners.length===0&&(r.started&&r.subscriber.stop(),T(this,ir).delete(r.tag)),i>0}async listenerCount(t){if(t){const r=await _t(this,se,Of).call(this,t);return r?r.listeners.length:0}let e=0;for(const{listeners:r}of T(this,ir).values())e+=r.length;return e}async listeners(t){if(t){const r=await _t(this,se,Of).call(this,t);return r?r.listeners.map(({listener:i})=>i):[]}let e=[];for(const{listeners:r}of T(this,ir).values())e=e.concat(r.map(({listener:i})=>i));return e}async off(t,e){const r=await _t(this,se,Of).call(this,t);if(!r)return this;if(e){const i=r.listeners.map(({listener:s})=>s).indexOf(e);i>=0&&r.listeners.splice(i,1)}return(!e||r.listeners.length===0)&&(r.started&&r.subscriber.stop(),T(this,ir).delete(r.tag)),this}async removeAllListeners(t){if(t){const{tag:e,started:r,subscriber:i}=await _t(this,se,n0).call(this,t);r&&i.stop(),T(this,ir).delete(e)}else for(const[e,{started:r,subscriber:i}]of T(this,ir))r&&i.stop(),T(this,ir).delete(e);return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return this.off(t,e)}get destroyed(){return T(this,ju)}destroy(){this.removeAllListeners();for(const t of T(this,Xr).keys())this._clearTimeout(t);$(this,ju,!0)}get paused(){return T(this,sr)!=null}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if($(this,Ps,-1),T(this,sr)!=null){if(T(this,sr)==!!t)return;ht(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(e=>e.pause(t)),$(this,sr,!!t);for(const e of T(this,Xr).values())e.timer&&clearTimeout(e.timer),e.time=ym()-e.time}resume(){if(T(this,sr)!=null){this._forEachSubscriber(t=>t.resume()),$(this,sr,null);for(const t of T(this,Xr).values()){let e=t.time;e<0&&(e=0),t.time=ym(),setTimeout(t.func,e)}}}}ir=new WeakMap,Oo=new WeakMap,sr=new WeakMap,ju=new WeakMap,$r=new WeakMap,Va=new WeakMap,No=new WeakMap,Ps=new WeakMap,Ph=new WeakMap,Xr=new WeakMap,Wu=new WeakMap,Zu=new WeakMap,se=new WeakSet,Cr=async function(t){const e=T(this,Zu).cacheTimeout;if(e<0)return await this._perform(t);const r=e0(t.method,t);let i=T(this,No).get(r);return i||(i=this._perform(t),T(this,No).set(r,i),setTimeout(()=>{T(this,No).get(r)===i&&T(this,No).delete(r)},e)),await i},Iw=async function(t,e,r){ht(r<oZ,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const i=D0(t);try{return kt(await this._perform({method:"call",transaction:i,blockTag:e}))}catch(s){if(!this.disableCcipRead&&$1(s)&&s.data&&r>=0&&e==="latest"&&i.to!=null&&bn(s.data,0,4)==="0x556f1830"){const o=s.data,c=await yr(i.to,this);let u;try{u=pZ(bn(s.data,4))}catch(y){ht(!1,y.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:i,info:{data:o}})}ht(u.sender.toLowerCase()===c.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:i,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:u.errorArgs}});const f=await this.ccipReadFetch(i,u.calldata,u.urls);ht(f!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:i,info:{data:s.data,errorArgs:u.errorArgs}});const h={to:c,data:Rn([u.selector,dZ([f,u.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const y=await _t(this,se,Iw).call(this,h,e,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:y}),y}catch(y){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:y}),y}}throw s}},kw=async function(t){const{value:e}=await lr({network:this.getNetwork(),value:t});return e},Tf=async function(t,e,r){let i=this._getAddress(e),s=this._getBlockTag(r);return(typeof i!="string"||typeof s!="string")&&([i,s]=await Promise.all([i,s])),await _t(this,se,kw).call(this,_t(this,se,Cr).call(this,Object.assign(t,{address:i,blockTag:s})))},Tw=async function(t,e){if(He(t,32))return await _t(this,se,Cr).call(this,{method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return typeof r!="string"&&(r=await r),await _t(this,se,Cr).call(this,{method:"getBlock",blockTag:r,includeTransactions:e})},Of=async function(t,e){let r=await gm(t,this);return r.type==="event"&&e&&e.length>0&&e[0].removed===!0&&(r=await gm({orphan:"drop-log",log:e[0]},this)),T(this,ir).get(r.tag)||null},n0=async function(t){const e=await gm(t,this),r=e.tag;let i=T(this,ir).get(r);return i||(i={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},T(this,ir).set(r,i)),i};function lZ(n,t){try{const e=Ow(n,t);if(e)return T0(e)}catch{}return null}function Ow(n,t){if(n==="0x")return null;try{const e=oe(bn(n,t,t+32)),r=oe(bn(n,e,e+32));return bn(n,e+32,e+32+r)}catch{}return null}function Fv(n){const t=pr(n);if(t.length>32)throw new Error("internal; should not happen");const e=new Uint8Array(32);return e.set(t,32-t.length),e}function fZ(n){if(n.length%32===0)return n;const t=new Uint8Array(Math.ceil(n.length/32)*32);return t.set(n),t}const hZ=new Uint8Array([]);function dZ(n){const t=[];let e=0;for(let r=0;r<n.length;r++)t.push(hZ),e+=32;for(let r=0;r<n.length;r++){const i=ye(n[r]);t[r]=Fv(e),t.push(Fv(i.length)),t.push(fZ(i)),e+=32+Math.ceil(i.length/32)*32}return Rn(t)}const $v="0x0000000000000000000000000000000000000000000000000000000000000000";function pZ(n){const t={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ht(uu(n)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const e=bn(n,0,32);ht(bn(e,0,12)===bn($v,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),t.sender=bn(e,12);try{const r=[],i=oe(bn(n,32,64)),s=oe(bn(n,i,i+32)),o=bn(n,i+32);for(let c=0;c<s;c++){const u=lZ(o,c*32);if(u==null)throw new Error("abort");r.push(u)}t.urls=r}catch{ht(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=Ow(n,64);if(r==null)throw new Error("abort");t.calldata=r}catch{ht(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}ht(bn(n,100,128)===bn($v,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),t.selector=bn(n,96,100);try{const r=Ow(n,128);if(r==null)throw new Error("abort");t.extraData=r}catch{ht(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return t.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(r=>t[r]),t}function $c(n,t){if(n.provider)return n.provider;ht(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:t})}async function Hv(n,t){let e=D0(t);if(e.to!=null&&(e.to=yr(e.to,n)),e.from!=null){const r=e.from;e.from=Promise.all([n.getAddress(),yr(r,n)]).then(([i,s])=>(K(i.toLowerCase()===s.toLowerCase(),"transaction from mismatch","tx.from",s),i))}else e.from=n.getAddress();return await lr(e)}class gZ{constructor(t){Z(this,"provider");$t(this,{provider:t||null})}async getNonce(t){return $c(this,"getTransactionCount").getTransactionCount(await this.getAddress(),t)}async populateCall(t){return await Hv(this,t)}async populateTransaction(t){const e=$c(this,"populateTransaction"),r=await Hv(this,t);r.nonce==null&&(r.nonce=await this.getNonce("pending")),r.gasLimit==null&&(r.gasLimit=await this.estimateGas(r));const i=await this.provider.getNetwork();if(r.chainId!=null){const o=Nt(r.chainId);K(o===i.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else r.chainId=i.chainId;const s=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||s)?K(!1,"eip-1559 transaction do not support gasPrice","tx",t):(r.type===0||r.type===1)&&s&&K(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1){const o=await e.getFeeData();ht(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice)}else{const o=await e.getFeeData();if(r.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const c=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=c,r.maxPriorityFeePerGas=c}else r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(ht(!s,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice),r.type=0):ht(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(r.type===2||r.type===3)&&(r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await lr(r)}async estimateGas(t){return $c(this,"estimateGas").estimateGas(await this.populateCall(t))}async call(t){return $c(this,"call").call(await this.populateCall(t))}async resolveName(t){return await $c(this,"resolveName").resolveName(t)}async sendTransaction(t){const e=$c(this,"sendTransaction"),r=await this.populateTransaction(t);delete r.from;const i=L0.from(r);return await e.broadcastTransaction(await this.signTransaction(i))}}function yZ(n){return JSON.parse(JSON.stringify(n))}var ur,Fi,Ka,Co,ja,qu,ta,Nw,Cw;class OT{constructor(t){nt(this,ta);nt(this,ur);nt(this,Fi);nt(this,Ka);nt(this,Co);nt(this,ja);nt(this,qu);$(this,ur,t),$(this,Fi,null),$(this,Ka,_t(this,ta,Nw).bind(this)),$(this,Co,!1),$(this,ja,null),$(this,qu,!1)}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}start(){T(this,Co)||($(this,Co,!0),_t(this,ta,Nw).call(this,-2))}stop(){T(this,Co)&&($(this,Co,!1),$(this,qu,!0),_t(this,ta,Cw).call(this),T(this,ur).off("block",T(this,Ka)))}pause(t){t&&_t(this,ta,Cw).call(this),T(this,ur).off("block",T(this,Ka))}resume(){this.start()}}ur=new WeakMap,Fi=new WeakMap,Ka=new WeakMap,Co=new WeakMap,ja=new WeakMap,qu=new WeakMap,ta=new WeakSet,Nw=async function(t){try{T(this,Fi)==null&&$(this,Fi,this._subscribe(T(this,ur)));let e=null;try{e=await T(this,Fi)}catch(s){if(!Wn(s,"UNSUPPORTED_OPERATION")||s.operation!=="eth_newFilter")throw s}if(e==null){$(this,Fi,null),T(this,ur)._recoverSubscriber(this,this._recover(T(this,ur)));return}const r=await T(this,ur).getNetwork();if(T(this,ja)||$(this,ja,r),T(this,ja).chainId!==r.chainId)throw new Error("chaid changed");if(T(this,qu))return;const i=await T(this,ur).send("eth_getFilterChanges",[e]);await this._emitResults(T(this,ur),i)}catch(e){console.log("@TODO",e)}T(this,ur).once("block",T(this,Ka))},Cw=function(){const t=T(this,Fi);t&&($(this,Fi,null),t.then(e=>{T(this,ur).destroyed||T(this,ur).send("eth_uninstallFilter",[e])}))};var Wa;class mZ extends OT{constructor(e,r){super(e);nt(this,Wa);$(this,Wa,yZ(r))}_recover(e){return new cb(e,T(this,Wa))}async _subscribe(e){return await e.send("eth_newFilter",[T(this,Wa)])}async _emitResults(e,r){for(const i of r)e.emit(T(this,Wa),e._wrapLog(i,e._network))}}Wa=new WeakMap;class wZ extends OT{async _subscribe(t){return await t.send("eth_newPendingTransactionFilter",[])}async _emitResults(t,e){for(const r of e)t.emit("pending",r)}}const bZ="bigint,boolean,function,number,string,symbol".split(/,/g);function r0(n){if(n==null||bZ.indexOf(typeof n)>=0||typeof n.getAddress=="function")return n;if(Array.isArray(n))return n.map(r0);if(typeof n=="object")return Object.keys(n).reduce((t,e)=>(t[e]=n[e],t),{});throw new Error(`should not happen: ${n} (${typeof n})`)}function _Z(n){return new Promise(t=>{setTimeout(t,n)})}function Hc(n){return n&&n.toLowerCase()}function zv(n){return n&&typeof n.pollingInterval=="number"}const NT={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class mm extends gZ{constructor(e,r){super(e);Z(this,"address");r=Pe(r),$t(this,{address:r})}connect(e){ht(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(e){return await this.populateCall(e)}async sendUncheckedTransaction(e){const r=r0(e),i=[];if(r.from){const o=r.from;i.push((async()=>{const c=await yr(o,this.provider);K(c!=null&&c.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),r.from=c})())}else r.from=this.address;if(r.gasLimit==null&&i.push((async()=>{r.gasLimit=await this.provider.estimateGas({...r,from:this.address})})()),r.to!=null){const o=r.to;i.push((async()=>{r.to=await yr(o,this.provider)})())}i.length&&await Promise.all(i);const s=this.provider.getRpcTransaction(r);return this.provider.send("eth_sendTransaction",[s])}async sendTransaction(e){const r=await this.provider.getBlockNumber(),i=await this.sendUncheckedTransaction(e);return await new Promise((s,o)=>{const c=[1e3,100];let u=0;const f=async()=>{try{const h=await this.provider.getTransaction(i);if(h!=null){s(h.replaceableTransaction(r));return}}catch(h){if(Wn(h,"CANCELLED")||Wn(h,"BAD_DATA")||Wn(h,"NETWORK_ERROR")||Wn(h,"UNSUPPORTED_OPERATION")){h.info==null&&(h.info={}),h.info.sendTransactionHash=i,o(h);return}if(Wn(h,"INVALID_ARGUMENT")&&(u++,h.info==null&&(h.info={}),h.info.sendTransactionHash=i,u>10)){o(h);return}this.provider.emit("error",Ze("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:h}))}this.provider._setTimeout(()=>{f()},c.pop()||4e3)};f()})}async signTransaction(e){const r=r0(e);if(r.from){const s=await yr(r.from,this.provider);K(s!=null&&s.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),r.from=s}else r.from=this.address;const i=this.provider.getRpcTransaction(r);return await this.provider.send("eth_signTransaction",[i])}async signMessage(e){const r=typeof e=="string"?Vs(e):e;return await this.provider.send("personal_sign",[kt(r),this.address.toLowerCase()])}async signTypedData(e,r,i){const s=r0(i),o=await U0.resolveNames(e,r,s,async c=>{const u=await yr(c);return K(u!=null,"TypedData does not support null address","value",c),u});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(U0.getPayload(o.domain,r,o.value))])}async unlock(e){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),e,null])}async _legacySignMessage(e){const r=typeof e=="string"?Vs(e):e;return await this.provider.send("eth_sign",[this.address.toLowerCase(),kt(r)])}}var Za,Qu,Ms,$i,gi,ti,Er,Mh,Bw;class CT extends uZ{constructor(e,r){super(e,r);nt(this,Mh);nt(this,Za);nt(this,Qu);nt(this,Ms);nt(this,$i);nt(this,gi);nt(this,ti);nt(this,Er);$(this,Qu,1),$(this,Za,Object.assign({},NT,r||{})),$(this,Ms,[]),$(this,$i,null),$(this,ti,null),$(this,Er,null);{let s=null;const o=new Promise(c=>{s=c});$(this,gi,{promise:o,resolve:s})}const i=this._getOption("staticNetwork");typeof i=="boolean"?(K(!i||e!=="any","staticNetwork cannot be used on special network 'any'","options",r),i&&e!=null&&$(this,ti,Ji.from(e))):i&&(K(e==null||i.matches(e),"staticNetwork MUST match network object","options",r),$(this,ti,i))}_getOption(e){return T(this,Za)[e]}get _network(){return ht(T(this,ti),"network is not available yet","NETWORK_ERROR"),T(this,ti)}async _perform(e){if(e.method==="call"||e.method==="estimateGas"){let i=e.transaction;if(i&&i.type!=null&&Nt(i.type)&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=await this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(e=Object.assign({},e,{transaction:Object.assign({},i,{type:void 0})}))}}const r=this.getRpcRequest(e);return r!=null?await this.send(r.method,r.args):super._perform(e)}async _detectNetwork(){const e=this._getOption("staticNetwork");if(e)if(e===!0){if(T(this,ti))return T(this,ti)}else return e;return T(this,Er)?await T(this,Er):this.ready?($(this,Er,(async()=>{try{const r=Ji.from(Nt(await this.send("eth_chainId",[])));return $(this,Er,null),r}catch(r){throw $(this,Er,null),r}})()),await T(this,Er)):($(this,Er,(async()=>{const r={id:df(this,Qu)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:r});let i;try{i=(await this._send(r))[0],$(this,Er,null)}catch(s){throw $(this,Er,null),this.emit("debug",{action:"receiveRpcError",error:s}),s}if(this.emit("debug",{action:"receiveRpcResult",result:i}),"result"in i)return Ji.from(Nt(i.result));throw this.getRpcError(r,i)})()),await T(this,Er))}_start(){T(this,gi)==null||T(this,gi).resolve==null||(T(this,gi).resolve(),$(this,gi,null),(async()=>{for(;T(this,ti)==null&&!this.destroyed;)try{$(this,ti,await this._detectNetwork())}catch(e){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Ze("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:e}})),await _Z(1e3)}_t(this,Mh,Bw).call(this)})())}async _waitUntilReady(){if(T(this,gi)!=null)return await T(this,gi).promise}_getSubscriber(e){return e.type==="pending"?new wZ(this):e.type==="event"?this._getOption("polling")?new cb(this,e.filter):new mZ(this,e.filter):e.type==="orphan"&&e.filter.orphan==="drop-log"?new H0("orphan"):super._getSubscriber(e)}get ready(){return T(this,gi)==null}getRpcTransaction(e){const r={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(i=>{if(e[i]==null)return;let s=i;i==="gasLimit"&&(s="gas"),r[s]=tu(Nt(e[i],`tx.${i}`))}),["from","to","data"].forEach(i=>{e[i]!=null&&(r[i]=kt(e[i]))}),e.accessList&&(r.accessList=Sc(e.accessList)),e.blobVersionedHashes&&(r.blobVersionedHashes=e.blobVersionedHashes.map(i=>i.toLowerCase())),r}getRpcRequest(e){switch(e.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[Hc(e.address),e.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Hc(e.address),e.blockTag]};case"getCode":return{method:"eth_getCode",args:[Hc(e.address),e.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Hc(e.address),"0x"+e.position.toString(16),e.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[e.signedTransaction]};case"getBlock":if("blockTag"in e)return{method:"eth_getBlockByNumber",args:[e.blockTag,!!e.includeTransactions]};if("blockHash"in e)return{method:"eth_getBlockByHash",args:[e.blockHash,!!e.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[e.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[e.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(e.transaction),e.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(e.transaction)]};case"getLogs":return e.filter&&e.filter.address!=null&&(Array.isArray(e.filter.address)?e.filter.address=e.filter.address.map(Hc):e.filter.address=Hc(e.filter.address)),{method:"eth_getLogs",args:[e.filter]}}return null}getRpcError(e,r){const{method:i}=e,{error:s}=r;if(i==="eth_estimateGas"&&s.message){const u=s.message;if(!u.match(/revert/i)&&u.match(/insufficient funds/i))return Ze("insufficient funds","INSUFFICIENT_FUNDS",{transaction:e.params[0],info:{payload:e,error:s}})}if(i==="eth_call"||i==="eth_estimateGas"){const u=Pw(s),f=Eh.getBuiltinCallException(i==="eth_call"?"call":"estimateGas",e.params[0],u?u.data:null);return f.info={error:s,payload:e},f}const o=JSON.stringify(vZ(s));if(typeof s.message=="string"&&s.message.match(/user denied|ethers-user-denied/i))return Ze("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[i]||"unknown",reason:"rejected",info:{payload:e,error:s}});if(i==="eth_sendRawTransaction"||i==="eth_sendTransaction"){const u=e.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return Ze("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:u,info:{error:s}});if(o.match(/nonce/i)&&o.match(/too low/i))return Ze("nonce has already been used","NONCE_EXPIRED",{transaction:u,info:{error:s}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Ze("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:u,info:{error:s}});if(o.match(/only replay-protected/i))return Ze("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:i,info:{transaction:u,info:{error:s}}})}let c=!!o.match(/the method .* does not exist/i);return c||s&&s.details&&s.details.startsWith("Unauthorized method:")&&(c=!0),c?Ze("unsupported operation","UNSUPPORTED_OPERATION",{operation:e.method,info:{error:s,payload:e}}):Ze("could not coalesce error","UNKNOWN_ERROR",{error:s,payload:e})}send(e,r){if(this.destroyed)return Promise.reject(Ze("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e}));const i=df(this,Qu)._++,s=new Promise((o,c)=>{T(this,Ms).push({resolve:o,reject:c,payload:{method:e,params:r,id:i,jsonrpc:"2.0"}})});return _t(this,Mh,Bw).call(this),s}async getSigner(e){e==null&&(e=0);const r=this.send("eth_accounts",[]);if(typeof e=="number"){const s=await r;if(e>=s.length)throw new Error("no such account");return new mm(this,s[e])}const{accounts:i}=await lr({network:this.getNetwork(),accounts:r});e=Pe(e);for(const s of i)if(Pe(s)===e)return new mm(this,e);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(r=>new mm(this,r))}destroy(){T(this,$i)&&(clearTimeout(T(this,$i)),$(this,$i,null));for(const{payload:e,reject:r}of T(this,Ms))r(Ze("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e.method}));$(this,Ms,[]),super.destroy()}}Za=new WeakMap,Qu=new WeakMap,Ms=new WeakMap,$i=new WeakMap,gi=new WeakMap,ti=new WeakMap,Er=new WeakMap,Mh=new WeakSet,Bw=function(){if(T(this,$i))return;const e=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");$(this,$i,setTimeout(()=>{$(this,$i,null);const r=T(this,Ms);for($(this,Ms,[]);r.length;){const i=[r.shift()];for(;r.length&&i.length!==T(this,Za).batchMaxCount;)if(i.push(r.shift()),JSON.stringify(i.map(o=>o.payload)).length>T(this,Za).batchMaxSize){r.unshift(i.pop());break}(async()=>{const s=i.length===1?i[0].payload:i.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:s});try{const o=await this._send(s);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:c,reject:u,payload:f}of i){if(this.destroyed){u(Ze("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:f.method}));continue}const h=o.filter(y=>y.id===f.id)[0];if(h==null){const y=Ze("missing response for request","BAD_DATA",{value:o,info:{payload:f}});this.emit("error",y),u(y);continue}if("error"in h){u(this.getRpcError(f,h));continue}c(h.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:c}of i)c(o)}})()}},e))};var Bo;class AZ extends CT{constructor(e,r){super(e,r);nt(this,Bo);let i=this._getOption("pollingInterval");i==null&&(i=NT.pollingInterval),$(this,Bo,i)}_getSubscriber(e){const r=super._getSubscriber(e);return zv(r)&&(r.pollingInterval=T(this,Bo)),r}get pollingInterval(){return T(this,Bo)}set pollingInterval(e){if(!Number.isInteger(e)||e<0)throw new Error("invalid interval");$(this,Bo,e),this._forEachSubscriber(r=>{zv(r)&&(r.pollingInterval=T(this,Bo))})}}Bo=new WeakMap;var Ju;class EZ extends AZ{constructor(e,r,i){e==null&&(e="http://localhost:8545");super(r,i);nt(this,Ju);typeof e=="string"?$(this,Ju,new Zs(e)):$(this,Ju,e.clone())}_getConnection(){return T(this,Ju).clone()}async send(e,r){return await this._start(),await super.send(e,r)}async _send(e){const r=this._getConnection();r.body=JSON.stringify(e),r.setHeader("content-type","application/json");const i=await r.send();i.assertOk();let s=i.bodyJson;return Array.isArray(s)||(s=[s]),s}}Ju=new WeakMap;function Pw(n){if(n==null)return null;if(typeof n.message=="string"&&n.message.match(/revert/i)&&He(n.data))return{message:n.message,data:n.data};if(typeof n=="object"){for(const t in n){const e=Pw(n[t]);if(e)return e}return null}if(typeof n=="string")try{return Pw(JSON.parse(n))}catch{}return null}function Mw(n,t){if(n!=null){if(typeof n.message=="string"&&t.push(n.message),typeof n=="object")for(const e in n)Mw(n[e],t);if(typeof n=="string")try{return Mw(JSON.parse(n),t)}catch{}}}function vZ(n){const t=[];return Mw(n,t),t}function xZ(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof nl<"u")return nl;throw new Error("unable to locate global object")}const RZ=xZ().WebSocket;var Hi,Lh,Po,qa,Mo;class ub{constructor(t,e){nt(this,Hi);nt(this,Lh);nt(this,Po);nt(this,qa);nt(this,Mo);$(this,Hi,t),$(this,Lh,JSON.stringify(e)),$(this,Po,null),$(this,qa,null),$(this,Mo,null)}get filter(){return JSON.parse(T(this,Lh))}start(){$(this,Po,T(this,Hi).send("eth_subscribe",this.filter).then(t=>(T(this,Hi)._register(t,this),t)))}stop(){T(this,Po).then(t=>{T(this,Hi).destroyed||T(this,Hi).send("eth_unsubscribe",[t])}),$(this,Po,null)}pause(t){ht(t,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),$(this,qa,!!t)}resume(){$(this,qa,null)}_handleMessage(t){if(T(this,Po)!=null&&T(this,qa)===null){let e=T(this,Mo);e==null?e=this._emit(T(this,Hi),t):e=e.then(async()=>{await this._emit(T(this,Hi),t)}),$(this,Mo,e.then(()=>{T(this,Mo)===e&&$(this,Mo,null)}))}}async _emit(t,e){throw new Error("sub-classes must implemente this; _emit")}}Hi=new WeakMap,Lh=new WeakMap,Po=new WeakMap,qa=new WeakMap,Mo=new WeakMap;class SZ extends ub{constructor(t){super(t,["newHeads"])}async _emit(t,e){t.emit("block",parseInt(e.number))}}class IZ extends ub{constructor(t){super(t,["newPendingTransactions"])}async _emit(t,e){t.emit("pending",e)}}var Uh;class kZ extends ub{constructor(e,r){super(e,["logs",r]);nt(this,Uh);$(this,Uh,JSON.stringify(r))}get logFilter(){return JSON.parse(T(this,Uh))}async _emit(e,r){e.emit(this.logFilter,e._wrapLog(r,e._network))}}Uh=new WeakMap;var Qa,Yu,Lo;class TZ extends CT{constructor(e,r){const i=Object.assign({},r??{});K(i.batchMaxCount==null||i.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",r),i.batchMaxCount=1,i.staticNetwork==null&&(i.staticNetwork=!0);super(e,i);nt(this,Qa);nt(this,Yu);nt(this,Lo);$(this,Qa,new Map),$(this,Yu,new Map),$(this,Lo,new Map)}_getSubscriber(e){switch(e.type){case"close":return new H0("close");case"block":return new SZ(this);case"pending":return new IZ(this);case"event":return new kZ(this,e.filter);case"orphan":if(e.filter.orphan==="drop-log")return new H0("drop-log")}return super._getSubscriber(e)}_register(e,r){T(this,Yu).set(e,r);const i=T(this,Lo).get(e);if(i){for(const s of i)r._handleMessage(s);T(this,Lo).delete(e)}}async _send(e){K(!Array.isArray(e),"WebSocket does not support batch send","payload",e);const r=new Promise((i,s)=>{T(this,Qa).set(e.id,{payload:e,resolve:i,reject:s})});return await this._waitUntilReady(),await this._write(JSON.stringify(e)),[await r]}async _processMessage(e){const r=JSON.parse(e);if(r&&typeof r=="object"&&"id"in r){const i=T(this,Qa).get(r.id);if(i==null){this.emit("error",Ze("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:r}));return}T(this,Qa).delete(r.id),i.resolve(r)}else if(r&&r.method==="eth_subscription"){const i=r.params.subscription,s=T(this,Yu).get(i);if(s)s._handleMessage(r.params.result);else{let o=T(this,Lo).get(i);o==null&&(o=[],T(this,Lo).set(i,o)),o.push(r.params.result)}}else{this.emit("error",Ze("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:r}));return}}async _write(e){throw new Error("sub-classes must override this")}}Qa=new WeakMap,Yu=new WeakMap,Lo=new WeakMap;var Ja,yi;class OZ extends TZ{constructor(e,r,i){super(r,i);nt(this,Ja);nt(this,yi);typeof e=="string"?($(this,Ja,()=>new RZ(e)),$(this,yi,T(this,Ja).call(this))):typeof e=="function"?($(this,Ja,e),$(this,yi,e())):($(this,Ja,null),$(this,yi,e)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(s){console.log("failed to start WebsocketProvider",s)}},this.websocket.onmessage=s=>{this._processMessage(s.data)}}get websocket(){if(T(this,yi)==null)throw new Error("websocket closed");return T(this,yi)}async _write(e){this.websocket.send(e)}async destroy(){T(this,yi)!=null&&(T(this,yi).close(),$(this,yi,null)),super.destroy()}}Ja=new WeakMap,yi=new WeakMap;const NZ="hh-sol-artifact-1",CZ="SwarmEventEmitter",BZ="contracts/SwarmEventEmitter.sol",PZ=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"string",name:"message",type:"string"}],name:"MessageLogged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"}],name:"RemovedFromWhitelist",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"}],name:"Whitelisted",type:"event"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"addToWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"admin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"string",name:"message",type:"string"}],name:"emitMessage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"removeFromWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"whitelisted",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}],MZ="0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a26107b08061013b6000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632ac0df261461005c5780638ab1d68114610078578063d936547e14610094578063e43252d7146100c4578063f851a440146100e0575b600080fd5b610076600480360381019061007191906104e8565b6100fe565b005b610092600480360381019061008d9190610593565b6101de565b005b6100ae60048036038101906100a99190610593565b61030a565b6040516100bb91906105db565b60405180910390f35b6100de60048036038101906100d99190610593565b61032a565b005b6100e8610455565b6040516100f59190610605565b60405180910390f35b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101819061067d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fda502b164eb5cfccfa9f947e0fdc1a0bd060adfef2947810b256321c1a74ca4183836040516101d29291906106ea565b60405180910390a25050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102639061075a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a250565b60016020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061075a565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a250565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126104a8576104a7610483565b5b8235905067ffffffffffffffff8111156104c5576104c4610488565b5b6020830191508360018202830111156104e1576104e061048d565b5b9250929050565b600080602083850312156104ff576104fe610479565b5b600083013567ffffffffffffffff81111561051d5761051c61047e565b5b61052985828601610492565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b61057081610555565b811461057b57600080fd5b50565b60008135905061058d81610567565b92915050565b6000602082840312156105a9576105a8610479565b5b60006105b78482850161057e565b91505092915050565b60008115159050919050565b6105d5816105c0565b82525050565b60006020820190506105f060008301846105cc565b92915050565b6105ff81610555565b82525050565b600060208201905061061a60008301846105f6565b92915050565b600082825260208201905092915050565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b6000610667600f83610620565b915061067282610631565b602082019050919050565b600060208201905081810360008301526106968161065a565b9050919050565b82818337600083830152505050565b6000601f19601f8301169050919050565b60006106c98385610620565b93506106d683858461069d565b6106df836106ac565b840190509392505050565b600060208201905081810360008301526107058184866106bd565b90509392505050565b7f4e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b6000610744600983610620565b915061074f8261070e565b602082019050919050565b6000602082019050818103600083015261077381610737565b905091905056fea26469706673582212202ad433ea9240cc561f6b9168c7880800e372f26e322166cedd6ce135222e699764736f6c634300081c0033",LZ="0x608060405234801561001057600080fd5b50600436106100575760003560e01c80632ac0df261461005c5780638ab1d68114610078578063d936547e14610094578063e43252d7146100c4578063f851a440146100e0575b600080fd5b610076600480360381019061007191906104e8565b6100fe565b005b610092600480360381019061008d9190610593565b6101de565b005b6100ae60048036038101906100a99190610593565b61030a565b6040516100bb91906105db565b60405180910390f35b6100de60048036038101906100d99190610593565b61032a565b005b6100e8610455565b6040516100f59190610605565b60405180910390f35b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101819061067d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fda502b164eb5cfccfa9f947e0fdc1a0bd060adfef2947810b256321c1a74ca4183836040516101d29291906106ea565b60405180910390a25050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102639061075a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a250565b60016020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061075a565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a250565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126104a8576104a7610483565b5b8235905067ffffffffffffffff8111156104c5576104c4610488565b5b6020830191508360018202830111156104e1576104e061048d565b5b9250929050565b600080602083850312156104ff576104fe610479565b5b600083013567ffffffffffffffff81111561051d5761051c61047e565b5b61052985828601610492565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b61057081610555565b811461057b57600080fd5b50565b60008135905061058d81610567565b92915050565b6000602082840312156105a9576105a8610479565b5b60006105b78482850161057e565b91505092915050565b60008115159050919050565b6105d5816105c0565b82525050565b60006020820190506105f060008301846105cc565b92915050565b6105ff81610555565b82525050565b600060208201905061061a60008301846105f6565b92915050565b600082825260208201905092915050565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b6000610667600f83610620565b915061067282610631565b602082019050919050565b600060208201905081810360008301526106968161065a565b9050919050565b82818337600083830152505050565b6000601f19601f8301169050919050565b60006106c98385610620565b93506106d683858461069d565b6106df836106ac565b840190509392505050565b600060208201905081810360008301526107058184866106bd565b90509392505050565b7f4e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b6000610744600983610620565b915061074f8261070e565b602082019050919050565b6000602082019050818103600083015261077381610737565b905091905056fea26469706673582212202ad433ea9240cc561f6b9168c7880800e372f26e322166cedd6ce135222e699764736f6c634300081c0033",UZ={},DZ={},FZ={_format:NZ,contractName:CZ,sourceName:BZ,abi:PZ,bytecode:MZ,deployedBytecode:LZ,linkReferences:UZ,deployedLinkReferences:DZ},$Z="Eai8D93JKad51sYmft1r74fzLkBSwRGPQVAmwZoLoWDf",HZ={name:"swarm_event_emitter",version:"0.1.0",spec:"0.1.0",description:"Created with Anchor"},zZ=[{name:"add_to_whitelist",discriminator:[157,211,52,54,144,81,5,55],accounts:[{name:"state",writable:!0},{name:"admin",signer:!0}],args:[{name:"user",type:"pubkey"}]},{name:"emit_message",discriminator:[118,99,20,87,25,132,207,62],accounts:[{name:"state",writable:!0},{name:"user",signer:!0}],args:[{name:"message",type:"string"}]},{name:"initialize",discriminator:[175,175,109,31,13,152,155,237],accounts:[{name:"state",writable:!0,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"admin",writable:!0,signer:!0},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"remove_from_whitelist",discriminator:[7,144,216,239,243,236,193,235],accounts:[{name:"state",writable:!0},{name:"admin",signer:!0}],args:[{name:"user",type:"pubkey"}]}],GZ=[{name:"State",discriminator:[216,146,107,94,104,75,182,177]}],VZ=[{name:"MessageLogged",discriminator:[24,236,247,207,227,70,101,210]},{name:"RemovedFromWhitelist",discriminator:[107,247,94,185,182,200,82,172]},{name:"Whitelisted",discriminator:[235,202,86,232,226,75,139,182]}],KZ=[{code:6e3,name:"NotAdmin",msg:"Only the admin can perform this action."},{code:6001,name:"NotWhitelisted",msg:"You are not whitelisted."}],jZ=[{name:"MessageLogged",type:{kind:"struct",fields:[{name:"sender",type:"pubkey"},{name:"message",type:"string"}]}},{name:"RemovedFromWhitelist",type:{kind:"struct",fields:[{name:"account",type:"pubkey"}]}},{name:"State",type:{kind:"struct",fields:[{name:"admin",type:"pubkey"},{name:"whitelisted",type:{vec:"pubkey"}}]}},{name:"Whitelisted",type:{kind:"struct",fields:[{name:"account",type:"pubkey"}]}}],WZ={address:$Z,metadata:HZ,instructions:zZ,accounts:GZ,events:VZ,errors:KZ,types:jZ};class ZZ{constructor(t){this.settings=t,this.evm=null,this.svm=null,this.init()}init(){this.settings.chainType==="EVM"?this.initEvm():this.settings.chainType==="SVM"&&this.initSvm()}initEvm(){const{rpcUrl:t,contractAddress:e}=this.settings;if(!e)throw new Error("Contract address is required for EVM chain type");const r=t.startsWith("ws")?new OZ(t):new EZ(t),i=new hu(e,FZ.abi,r);this.evm={provider:r,contract:i}}initSvm(){const t=new Z2(this.settings.rpcUrl,"confirmed"),e=tc.generate(),r={signTransaction:async o=>o,signAllTransactions:async o=>o,publicKey:e.publicKey},i=new dh(t,r,{}),s=new hl(WZ,i);this.svm={provider:t,program:s}}async onMessageFrom(t,e){this.settings.chainType==="EVM"?this.listenToEvm(t,e):this.settings.chainType==="SVM"&&await this.listenToSvm(t,e)}listenToEvm(t,e){var r;(r=this.evm)==null||r.contract.on("MessageLogged",(i,s)=>{const[o,c]=s.split("_");Ff(i.toLowerCase())===Ff(this.settings.swarmEmitterAddress.toLowerCase())&&o===t&&e(i,s)})}async listenToSvm(t,e){var i;const r=(i=this.svm)==null?void 0:i.program.addEventListener("messageLogged",s=>{const{sender:o,message:c}=s,[u,f]=c.split("_");o.toBase58()===this.settings.swarmEmitterAddress&&u===t&&e(o.toBase58(),c)});this.svm&&r!==void 0&&(this.svm.listenerId=r)}async removeAllListeners(){var t,e;this.settings.chainType==="EVM"&&((t=this.evm)==null||t.contract.removeAllListeners("MessageLogged")),this.settings.chainType==="SVM"&&((e=this.svm)==null?void 0:e.listenerId)!==void 0&&(await this.svm.program.removeEventListener(this.svm.listenerId),this.svm.listenerId=void 0)}}const qZ=new TextEncoder,Gv=1,Vv=4096,wm=4096,QZ=32;function JZ(n,t){return t=typeof t=="number"?Qt.FeedIndex.fromBigInt(BigInt(t)):t,new Qt.Identifier(or.keccak256(or.concatBytes(n.toUint8Array(),t.toUint8Array())))}function YZ(n){const t=n.slice(0,Qt.Span.LENGTH),e=n.slice(Qt.Span.LENGTH),r=XZ(e),i=or.keccak256(or.concatBytes(t,r));return new Qt.Reference(i)}function XZ(n){if(n.length>wm)throw new Qt.BeeArgumentError(`payload size ${n.length} exceeds maximum chunk payload size ${wm}`,n);const t=new Uint8Array(wm);return t.set(n),or.log2Reduce(or.partition(t,QZ),(e,r)=>or.keccak256(or.concatBytes(e,r)))}function Kv(n){if(n instanceof Uint8Array||(n=qZ.encode(n)),n.length<Gv||n.length>Vv)throw new RangeError(`payload size ${n.length} exceeds limits [${Gv}, ${Vv}]`);const t=Qt.Span.fromBigInt(BigInt(n.length)),e=or.concatBytes(t.toUint8Array(),n);return{data:e,span:t,payload:Qt.Bytes.fromSlice(e,Qt.Span.LENGTH),address:YZ(e)}}function tq(n,t){return new Qt.Reference(or.keccak256(or.concatBytes(n.toUint8Array(),t.toUint8Array())))}function jv(n,t,e){t=new Qt.Identifier(t),e=new Qt.PrivateKey(e);const r=tq(t,e.publicKey().address()),i=e.sign(or.concatBytes(t.toUint8Array(),n.address.toUint8Array())),s=or.concatBytes(t.toUint8Array(),i.toUint8Array(),n.data),o=Qt.Span.fromSlice(n.data,0),c=Qt.Bytes.fromSlice(n.data,Qt.Span.LENGTH);return{data:s,identifier:t,signature:i,span:o,payload:c,address:r,owner:e.publicKey().address()}}class eq{constructor(t,e){this.userDetails=t,this.swarmSettings=e,this.depth=24,this.logger=Qi.getInstance(),this.errorHandler=new np,this.UPLOAD_GSOC_TIMEOUT=2e3}async writeOwnFeedDataByIndex(t,e){const{enveloped:r,stamp:i}=this.swarmSettings;if(!r)await this.writeOwnFeedDataByIndexOwned(t,e);else if(i)await this.writeOwnFeedDataByIndexEnvelope(t,e);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async writeOwnFeedDataByIndexOwned(t,e){const{bee:r,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:c}=this.userDetails,u=this.generateUserOwnedFeedId(s,c),f=Qt.Topic.fromString(u);console.log("DEBUG: feedID write",f.toString(),c,t,u),await r.makeFeedWriter(f,new Qt.PrivateKey(o)).uploadPayload(i,JSON.stringify(e),{index:t})}async writeOwnFeedDataByIndexEnvelope(t,e){const{bee:r,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:c}=this.userDetails,u=new Qt.PrivateKey(o),f=Qt.Stamper.fromBlank(o,i,this.depth),h=this.generateUserOwnedFeedId(s,c),y=Qt.Topic.fromString(h),A=JZ(y,t),b=Kv(e),R=jv(b,A,u),k={hash:()=>R.address.toUint8Array()},S=f.stamp(k),{upload:B}=r.makeSOCWriter(u),H=Qt.Bytes.fromUtf8(e);return(await B(S,A,H.toUint8Array())).reference.toHex()}async fetchUserFeedDataByIndex(t,e,r){const{bee:i,chatTopic:s}=this.swarmSettings,o=(r==null?void 0:r.timeout)??1500,c=this.generateUserOwnedFeedId(s,t),u=Qt.Topic.fromString(c);return console.log("DEBUG: feedID read",u.toString(),t,e,c),(await i.makeFeedReader(u,t,{timeout:o}).downloadPayload({index:e})).payload.toJSON()}orderMessages(t){return t.sort((e,r)=>e.timestamp-r.timestamp)}async retryAwaitableAsync(t,e=3,r=250){return new Promise((i,s)=>{t().then(i).catch(o=>{e>0?(this.logger.info(`Retrying... Attempts left: ${e}. Error: ${o.message}`),setTimeout(()=>{this.retryAwaitableAsync(t,e-1,r).then(i).catch(s)},r)):(this.errorHandler.handleError(o,"Utils.retryAwaitableAsync"),s(o))})})}async uploadObjectToBee(t){const{enveloped:e,stamp:r}=this.swarmSettings;if(e){if(r)return this.uploadObjectToBeeEnvelope(t);throw new Error("Enveloped mode is enabled, but stamp is not provided")}else return this.uploadObjectToBeeOwn(t)}async uploadObjectToBeeOwn(t){try{const{bee:e,stamp:r}=this.swarmSettings,i=await e.uploadData(r,JSON.stringify(t),{redundancyLevel:4});return console.log("DEBUG: result",i.reference.toString()),i.reference.toString()}catch(e){return this.errorHandler.handleError(e,"Utils.uploadObjectToBee"),null}}async uploadObjectToBeeEnvelope(t){try{const{bee:e,stamp:r}=this.swarmSettings,{privateKey:i}=this.userDetails,s=Qt.Stamper.fromBlank(i,r,this.depth),o=Qt.Bytes.fromUtf8(JSON.stringify(t)),c=new mM(async f=>{await e.uploadChunk(s.stamp(f),f.build())});await c.append(o.toUint8Array());const u=await c.finalize();return or.uint8ArrayToHex(u.hash())}catch(e){return this.errorHandler.handleError(e,"Utils.uploadObjectToBee"),null}}async downloadObjectFromBee(t){try{const{bee:e}=this.swarmSettings;return(await e.downloadData(t)).toJSON()}catch(e){return this.errorHandler.handleError(e,"Utils.beeDownloadObject"),null}}async getOwnLatestFeedIndex(){try{const{bee:t,chatTopic:e}=this.swarmSettings,{ownAddress:r}=this.userDetails,i=this.generateUserOwnedFeedId(e,r),s=Qt.Topic.fromString(i),c=await t.makeFeedReader(s,r).downloadPayload(),u=Number(c.feedIndex.toBigInt()),f=u+1;return console.log("DEBUG: getLatestFeedIndex",u,f),{latestIndex:u,nextIndex:f}}catch(t){if(this.isNotFoundError(t))return{latestIndex:-1,nextIndex:0};throw t}}async fetchLatestChatMessage(){const{bee:t,chatTopic:e,chatAddress:r}=this.swarmSettings,s=await t.makeFeedReader(Qt.Topic.fromString(e),Ff(r)).downloadPayload();return{message:s.payload.toJSON(),index:s.feedIndex}}async fetchChatMessage(t){const{bee:e,chatTopic:r,chatAddress:i}=this.swarmSettings;return(await e.makeFeedReader(Qt.Topic.fromString(r),Ff(i)).downloadPayload({index:t})).payload.toJSON()}async sendMessageToGsoc(t){const{enveloped:e,stamp:r}=this.swarmSettings;if(!e)await this.sendMessageToGsocOwn(t);else if(r)await this.sendMessageToGsocEnvelope(t);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async sendMessageToGsocOwn(t){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:e,stamp:r,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,o=new Qt.PrivateKey(s),c=Qt.Identifier.fromString(i),u=Qt.Bytes.fromUtf8(t),{upload:f}=e.makeSOCWriter(o,{timeout:this.UPLOAD_GSOC_TIMEOUT});await f(r,c,u.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}async sendMessageToGsocEnvelope(t){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:e,stamp:r,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,{privateKey:o}=this.userDetails,c=Qt.Stamper.fromBlank(o,r,this.depth),u=new Qt.PrivateKey(s),f=Qt.Identifier.fromString(i),h=Qt.Bytes.fromUtf8(t),y=Kv(h.toUint8Array()),A=jv(y,f,u),b={hash:()=>A.address.toUint8Array()},R=c.stamp(b),{upload:k}=e.makeSOCWriter(u,{timeout:this.UPLOAD_GSOC_TIMEOUT});await k(R,f,h.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}generateUserOwnedFeedId(t,e){return`${t}_EthercastChat_${e}`}isNotFoundError(t){return t.stack.includes("404")||t.message.includes("Not Found")||t.message.includes("404")}}class nq{constructor(t){var r,i,s;this.logger=Qi.getInstance(),this.errorHandler=new np,this.messagesQueue=new Z_({clearWaitTime:200}),this.gsocListenerQueue=new Z_({clearWaitTime:200}),this.activeUsers={},this.latestMessage=null,this.userIndexCache={};const e=new Qt.PrivateKey(Ff(t.user.privateKey));this.userDetails={privateKey:t.user.privateKey,ownAddress:e.publicKey().address().toString(),nickname:t.user.nickname,ownIndex:-1},this.swarmSettings={bee:new Qt.Bee(t.infra.swarm.beeUrl),stamp:t.infra.swarm.stamp||"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",enveloped:t.infra.swarm.enveloped,customGsocCallback:t.infra.swarm.customGsocCallback,gsocTopic:t.infra.swarm.gsocTopic,gsocResourceId:t.infra.swarm.gsocResourceId,chatTopic:t.infra.swarm.chatTopic,chatAddress:t.infra.swarm.chatAddress},this.options={fetchMessageTimer:null,idleUserCleanupInterval:null,FETCH_MESSAGE_INTERVAL_TIME:((r=t.options)==null?void 0:r.fetchMessageIntervalTime)||1e3,IDLE_USER_CLEANUP_INTERVAL_TIME:((i=t.options)==null?void 0:i.idleUserCleanupIntervalTime)||5e3,READ_MESSAGE_TIMEOUT:((s=t.options)==null?void 0:s.readMessageTimeout)||1500},this.emitter=new yM,this.utils=new eq(this.userDetails,this.swarmSettings),this.history=new CL(this.utils,this.emitter),this.swarmEventEmitterReader=new ZZ(t.infra.chain)}start(){this.init(),this.swarmSettings.customGsocCallback||this.subscribeToGSOCEvent(),this.startMessagesFetchProcess(),this.startIdleUserCleanup()}stop(){this.stopMessagesFetchProcess(),this.stopIdleUserCleanup(),this.unsubFromGSOCEvent(),this.emitter.cleanAll()}getEmitter(){return this.emitter}orderMessages(t){return this.utils.orderMessages(t)}async sendMessage(t,e){const r=this.userDetails.ownIndex===-1?0:this.userDetails.ownIndex+1,i={id:e||gM(),username:this.userDetails.nickname,address:this.userDetails.ownAddress,timestamp:Date.now(),index:r,message:t};try{this.emitter.emit(Br.MESSAGE_REQUEST_INITIATED,i),await this.utils.writeOwnFeedDataByIndex(r,JSON.stringify(i)),this.userDetails.ownIndex=r,this.emitter.emit(Br.MESSAGE_REQUEST_UPLOADED,i),await this.broadcastUserMessage()}catch(s){this.emitter.emit(Br.MESSAGE_REQUEST_ERROR,i),this.errorHandler.handleError(s,"Chat.sendMessage")}}async fetchPreviousMessages(){try{return this.emitter.emit(Br.LOADING_PREVIOUS_MESSAGES,!0),await this.history.fetchPreviousMessages()}finally{this.emitter.emit(Br.LOADING_PREVIOUS_MESSAGES,!1)}}async retrySendMessage(t){this.sendMessage(t.message,t.id)}async retryBroadcastUserMessage(t){this.broadcastUserMessage()}async init(){try{this.emitter.emit(Br.LOADING_INIT,!0);const[t,e]=await Promise.allSettled([this.initOwnIndex(),this.history.init()]);if(t.status==="rejected")throw t.reason;e.status==="rejected"&&this.logger.warn(`historyInitResult failed: ${e.reason}`),this.emitter.emit(Br.LOADING_INIT,!1)}catch(t){this.errorHandler.handleError(t,"Chat.initSelfState"),this.emitter.emit(Br.CRITICAL_ERROR,t)}}async initOwnIndex(){const{latestIndex:r}=await this.utils.retryAwaitableAsync(()=>this.utils.getOwnLatestFeedIndex(),10,1e3);this.userDetails.ownIndex=r}subscribeToGSOCEvent(){try{this.swarmEventEmitterReader.onMessageFrom(this.swarmSettings.chatTopic,(t,e)=>this.gsocListenerQueue.enqueue(()=>this.processGsocEvent(e)))}catch(t){this.errorHandler.handleError(t,"Chat.subscribeToGSOCEvent"),this.emitter.emit(Br.CRITICAL_ERROR,t)}}callbackProcessGsocEvent(t){try{this.gsocListenerQueue.enqueue(()=>this.processGsocEvent(t))}catch(e){this.errorHandler.handleError(e,"Chat.callbackProcessGsocEvent"),this.emitter.emit(Br.CRITICAL_ERROR,e)}}async processGsocEvent(t){try{console.log("processGsocMessage CALLED",t);const[e,r]=t.split("_"),i=Qt.FeedIndex.fromBigInt(BigInt(`0x${r}`)),s=await this.utils.fetchChatMessage(i);if(console.log("DEBUG processGsocMessage",s),!IL(s)){this.logger.warn("Invalid GSOC message during processing");return}if(this.logger.debug("New GSOC message:",s),lM(this.latestMessage,s))return;this.updateActiveUsers(s.messageSender),this.latestMessage=s}catch(e){this.errorHandler.handleError(e,"Chat.processGsocMessage")}}async waitForMessageBroadcast(t){return OL({condition:()=>Object.values(this.activeUsers).some(e=>e.index===t),broadcast:()=>this.broadcastUserMessage()})}async broadcastUserMessage(){try{this.logger.debug("broadcastUserMessage entry CALLED");const t=await this.makeMessageSender();console.log("DEBUG broadcastUserMessage",t),await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({topic:this.swarmSettings.chatTopic,messageSender:t})))}catch(t){this.errorHandler.handleError(t,"Chat.broadcastUserMessage")}}async makeMessageSender(){const{ownAddress:t,privateKey:e,nickname:r}=this.userDetails,i=new Qt.EthAddress(t).toString(),s=new Qt.PrivateKey(e);if(s.publicKey().address().toString()!==i)throw new Error("The provided address does not match the address derived from the private key");const c=Date.now(),u=s.sign(JSON.stringify({username:r,address:i,timestamp:c}));return{address:i,timestamp:c,signature:u.toHex(),index:this.getOwnIndex(),username:r}}async readAllActiveUserMessage(){if(!await this.messagesQueue.waitForProcessing())for(const e of Object.values(this.activeUsers))this.messagesQueue.enqueue(()=>this.readMessage(e))}async readMessage(t){try{let e;const r=this.isUserIndexRead(t.address,t.index);if(r.isIndexRead)return;e=r.cachedIndex?r.cachedIndex+1:t.index;const i=await this.utils.fetchUserFeedDataByIndex(t.address,e);this.setUserIndexCache(t.address,e),this.emitter.emit(Br.MESSAGE_RECEIVED,JSON.parse(i))}catch(e){this.errorHandler.handleError(e,"readMessage")}}unsubFromGSOCEvent(){this.swarmEventEmitterReader.removeAllListeners()}startMessagesFetchProcess(){const{fetchMessageTimer:t,FETCH_MESSAGE_INTERVAL_TIME:e}=this.options;if(t){this.logger.warn("Messages fetch process is already running.");return}this.options.fetchMessageTimer=setInterval(this.readAllActiveUserMessage.bind(this),e)}stopMessagesFetchProcess(){const{fetchMessageTimer:t}=this.options;t&&(clearInterval(t),this.options.fetchMessageTimer=null)}startIdleUserCleanup(){const{idleUserCleanupInterval:t,IDLE_USER_CLEANUP_INTERVAL_TIME:e}=this.options;if(t){this.logger.warn("Idle user cleanup is already running.");return}this.options.idleUserCleanupInterval=setInterval(this.removeIdleUsers.bind(this),e)}stopIdleUserCleanup(){const{idleUserCleanupInterval:t}=this.options;t&&(clearInterval(t),this.options.idleUserCleanupInterval=null)}isUserIndexRead(t,e){const r=this.userIndexCache[t];return{cachedIndex:r,isIndexRead:r===e}}setUserIndexCache(t,e){this.userIndexCache[t]=e}getOwnIndex(){return this.userDetails.ownIndex}removeIdleUsers(){const t=Date.now();for(const e of Object.values(this.activeUsers))t-e.timestamp>300*NL&&delete this.activeUsers[e.address]}updateActiveUsers(t){this.activeUsers[t.address]=t}}exports.EVENTS=Br;exports.SwarmChat=nq;
|
|
22
|
+
`+s+o;break;default:a=`Unknown action '${(u=>u)(t)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=r,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}async getLogs(t){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((e,r)=>{t.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){const s=i.meta.logMessages;this.transactionLogs=s,e(s)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const BF={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class Pt extends Error{constructor({code:t,message:e,data:r},i){super(i!=null?`${i}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=r,this.name="SolanaJSONRPCError"}}async function iw(n,t,e,r){const i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},s=await n.sendTransaction(t,e,i);let o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,signature:s,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:a}=t.nonceInfo,u=a.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:t.nonceInfo.nonce,signature:s},r&&r.commitment)).value}else(r==null?void 0:r.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await n.confirmTransaction(s,r&&r.commitment)).value;if(o.err)throw s!=null?new sa({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(o)})`);return s}function va(n){return new Promise(t=>setTimeout(t,n))}function de(n,t){const e=n.layout.span>=0?n.layout.span:cR(n,t),r=St.alloc(e),i=Object.assign({instruction:n.index},t);return n.layout.encode(i,r),r}function Se(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${e.instruction} != ${n.index}`);return e}const fR=Gn("lamportsPerSignature"),hR=Ot([Tt("version"),Tt("state"),ae("authorizedPubkey"),ae("nonce"),Ot([fR],"feeCalculator")]),sw=hR.span;class Dp{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=hR.decode(ne(t),0);return new Dp({authorizedPubkey:new pt(e.authorizedPubkey),nonce:new pt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const PF=n=>{const t=n.decode.bind(n),e=n.encode.bind(n);return{decode:t,encode:e}},MF=n=>t=>{const e=Ve(n,t),{encode:r,decode:i}=PF(e),s=e;return s.decode=(o,a)=>{const u=i(o,a);return s9(St.from(u))},s.encode=(o,a,u)=>{const f=V2(o,n);return r(f,a,u)},s},Al=MF(8);class LF{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Tt("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(He))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a SystemInstruction");return i}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:r,programId:i}=Se(He.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:r,programId:new pt(i)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Se(He.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:r,programId:i}=Se(He.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:r,programId:new pt(i)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Se(He.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,space:i,programId:s}=Se(He.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new pt(e),seed:r,space:i,programId:new pt(s)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Se(He.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new pt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,programId:i}=Se(He.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new pt(e),seed:r,programId:new pt(i)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:r,lamports:i,space:s,programId:o}=Se(He.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new pt(e),seed:r,lamports:i,space:s,programId:new pt(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Se(He.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new pt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Se(He.AdvanceNonceAccount,t.data),{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static decodeNonceWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Se(He.WithdrawNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e}}static decodeNonceAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e}=Se(He.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new pt(e)}}static checkProgramId(t){if(!t.equals(On.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const He=Object.freeze({Create:{index:0,layout:Ot([Tt("instruction"),Gr("lamports"),Gr("space"),ae("programId")])},Assign:{index:1,layout:Ot([Tt("instruction"),ae("programId")])},Transfer:{index:2,layout:Ot([Tt("instruction"),Al("lamports")])},CreateWithSeed:{index:3,layout:Ot([Tt("instruction"),ae("base"),ka("seed"),Gr("lamports"),Gr("space"),ae("programId")])},AdvanceNonceAccount:{index:4,layout:Ot([Tt("instruction")])},WithdrawNonceAccount:{index:5,layout:Ot([Tt("instruction"),Gr("lamports")])},InitializeNonceAccount:{index:6,layout:Ot([Tt("instruction"),ae("authorized")])},AuthorizeNonceAccount:{index:7,layout:Ot([Tt("instruction"),ae("authorized")])},Allocate:{index:8,layout:Ot([Tt("instruction"),Gr("space")])},AllocateWithSeed:{index:9,layout:Ot([Tt("instruction"),ae("base"),ka("seed"),Gr("space"),ae("programId")])},AssignWithSeed:{index:10,layout:Ot([Tt("instruction"),ae("base"),ka("seed"),ae("programId")])},TransferWithSeed:{index:11,layout:Ot([Tt("instruction"),Al("lamports"),ka("seed"),ae("programId")])},UpgradeNonceAccount:{index:12,layout:Ot([Tt("instruction")])}});class On{constructor(){}static createAccount(t){const e=He.Create,r=de(e,{lamports:t.lamports,space:t.space,programId:ne(t.programId.toBuffer())});return new Pe({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(t){let e,r;if("basePubkey"in t){const i=He.TransferWithSeed;e=de(i,{lamports:BigInt(t.lamports),seed:t.seed,programId:ne(t.programId.toBuffer())}),r=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{const i=He.Transfer;e=de(i,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Pe({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;if("basePubkey"in t){const i=He.AssignWithSeed;e=de(i,{base:ne(t.basePubkey.toBuffer()),seed:t.seed,programId:ne(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=He.Assign;e=de(i,{programId:ne(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Pe({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=He.CreateWithSeed,r=de(e,{base:ne(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:ne(t.programId.toBuffer())});let i=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||i.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Pe({keys:i,programId:this.programId,data:r})}static createNonceAccount(t){const e=new Oe;"basePubkey"in t&&"seed"in t?e.add(On.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:sw,programId:this.programId})):e.add(On.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:sw,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=He.InitializeNonceAccount,r=de(e,{authorized:ne(t.authorizedPubkey.toBuffer())}),i={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:c0,isSigner:!1,isWritable:!1},{pubkey:_l,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Pe(i)}static nonceAdvance(t){const e=He.AdvanceNonceAccount,r=de(e),i={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:c0,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Pe(i)}static nonceWithdraw(t){const e=He.WithdrawNonceAccount,r=de(e,{lamports:t.lamports});return new Pe({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:c0,isSigner:!1,isWritable:!1},{pubkey:_l,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(t){const e=He.AuthorizeNonceAccount,r=de(e,{authorized:ne(t.newAuthorizedPubkey.toBuffer())});return new Pe({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(t){let e,r;if("basePubkey"in t){const i=He.AllocateWithSeed;e=de(i,{base:ne(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:ne(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const i=He.Allocate;e=de(i,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Pe({keys:r,programId:this.programId,data:e})}}On.programId=new pt("11111111111111111111111111111111");const UF=qo-300;class wc{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/wc.chunkSize)+1+1)}static async load(t,e,r,i,s){{const y=await t.getMinimumBalanceForRentExemption(s.length),_=await t.getAccountInfo(r.publicKey,"confirmed");let w=null;if(_!==null){if(_.executable)return console.error("Program load failed, account is already executable"),!1;_.data.length!==s.length&&(w=w||new Oe,w.add(On.allocate({accountPubkey:r.publicKey,space:s.length}))),_.owner.equals(i)||(w=w||new Oe,w.add(On.assign({accountPubkey:r.publicKey,programId:i}))),_.lamports<y&&(w=w||new Oe,w.add(On.transfer({fromPubkey:e.publicKey,toPubkey:r.publicKey,lamports:y-_.lamports})))}else w=new Oe().add(On.createAccount({fromPubkey:e.publicKey,newAccountPubkey:r.publicKey,lamports:y>0?y:1,space:s.length,programId:i}));w!==null&&await iw(t,w,[e,r],{commitment:"confirmed"})}const o=Ot([Tt("instruction"),Tt("offset"),Tt("bytesLength"),Tt("bytesLengthPadding"),Qn(ge("byte"),Zo(Tt(),-8),"bytes")]),a=wc.chunkSize;let u=0,f=s,h=[];for(;f.length>0;){const y=f.slice(0,a),_=St.alloc(a+16);o.encode({instruction:0,offset:u,bytes:y,bytesLength:0,bytesLengthPadding:0},_);const w=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:_});h.push(iw(t,w,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await va(1e3/4),u+=a,f=f.slice(a)}await Promise.all(h);{const y=Ot([Tt("instruction")]),_=St.alloc(y.span);y.encode({instruction:1},_);const w=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:_l,isSigner:!1,isWritable:!1}],programId:i,data:_}),R="processed",T=await t.sendTransaction(w,[e,r],{preflightCommitment:R}),{context:I,value:B}=await t.confirmTransaction({signature:T,lastValidBlockHeight:w.lastValidBlockHeight,blockhash:w.recentBlockhash},R);if(B.err)throw new Error(`Transaction ${T} failed (${JSON.stringify(B)})`);for(;;){try{if(await t.getSlot({commitment:R})>I.slot)break}catch{}await new Promise(H=>setTimeout(H,Math.round(lR/2)))}}return!0}}wc.chunkSize=UF;const DF=new pt("BPFLoader2111111111111111111111111111111111");class FF{static getMinNumSignatures(t){return wc.getMinNumSignatures(t)}static load(t,e,r,i,s){return wc.load(t,e,r,s,i)}}function $F(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Jy,GA;function HF(){if(GA)return Jy;GA=1;var n=Object.prototype.toString,t=Object.keys||function(r){var i=[];for(var s in r)i.push(s);return i};function e(r,i){var s,o,a,u,f,h,y;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return e(r.toJSON(),i);if(y=n.call(r),y==="[object Array]"){for(a="[",o=r.length-1,s=0;s<o;s++)a+=e(r[s],!0)+",";return o>-1&&(a+=e(r[s],!0)),a+"]"}else if(y==="[object Object]"){for(u=t(r).sort(),o=u.length,a="",s=0;s<o;)f=u[s],h=e(r[f],!1),h!==void 0&&(a&&(a+=","),a+=JSON.stringify(f)+":"+h),s++;return"{"+a+"}"}else return JSON.stringify(r);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return Jy=function(r){var i=e(r,!1);if(i!==void 0)return""+i},Jy}var zF=HF(),VA=$F(zF);const kf=32;function Yy(n){let t=0;for(;n>1;)n/=2,t++;return t}function GF(n){return n===0?1:(n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n|=n>>32,n+1)}class dR{constructor(t,e,r,i,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=r,this.firstNormalEpoch=i,this.firstNormalSlot=s}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=Yy(GF(t+kf+1))-Yy(kf)-1,r=this.getSlotsInEpoch(e),i=t-(r-kf);return[e,i]}else{const e=t-this.firstNormalSlot,r=Math.floor(e/this.slotsPerEpoch),i=this.firstNormalEpoch+r,s=e%this.slotsPerEpoch;return[i,s]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*kf:(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+Yy(kf)):this.slotsPerEpoch}}var VF=globalThis.fetch;class KF extends K9{constructor(t,e,r){const i=s=>{const o=G9(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,t,e,r),this.underlyingSocket=void 0}call(...t){var r;const e=(r=this.underlyingSocket)==null?void 0:r.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var r;const e=(r=this.underlyingSocket)==null?void 0:r.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}function jF(n,t){let e;try{e=n.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(e.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${n.index}`);return e}const KA=56;class ow{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=jF(WF,t),r=t.length-KA;be(r>=0,"lookup table is invalid"),be(r%32===0,"lookup table is invalid");const i=r/32,{addresses:s}=Ot([Qn(ae(),i,"addresses")]).decode(t.slice(KA));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new pt(e.authority[0]):void 0,addresses:s.map(o=>new pt(o))}}}const WF={index:1,layout:Ot([Tt("typeIndex"),Al("deactivationSlot"),Gn("lastExtendedSlot"),ge("lastExtendedStartIndex"),ge(),Qn(ae(),Zo(ge(),-1),"authority")])},ZF=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function qF(n){const t=n.match(ZF);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[e,r,i,s]=t,o=n.startsWith("https:")?"wss:":"ws:",a=i==null?null:parseInt(i.slice(1),10),u=a==null?"":`:${a+1}`;return`${o}//${r}${u}${s}`}const on=od(O1(pt),mt(),n=>new pt(n)),pR=N1([mt(),nn("base64")]),F1=od(O1(St),pR,n=>St.from(n[0],"base64")),gR=30*1e3;function QF(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function $e(n){let t,e;if(typeof n=="string")t=n;else if(n){const{commitment:r,...i}=n;t=r,e=i}return{commitment:t,config:e}}function jA(n){return n.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function yR(n){return Ar([dt({jsonrpc:nn("2.0"),id:mt(),result:n}),dt({jsonrpc:nn("2.0"),id:mt(),error:dt({code:Vl(),message:mt(),data:Dt(p9())})})])}const JF=yR(Vl());function ee(n){return od(yR(n),JF,t=>"error"in t?t:{...t,result:bt(t.result,n)})}function En(n){return ee(dt({context:dt({slot:tt()}),value:n}))}function Fp(n){return dt({context:dt({slot:tt()}),value:n})}function Xy(n,t){return n===0?new mc({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new pt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:kn.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Ti(t)}const YF=dt({foundation:tt(),foundationTerm:tt(),initial:tt(),taper:tt(),terminal:tt()}),XF=ee(Et(vt(dt({epoch:tt(),effectiveSlot:tt(),amount:tt(),postBalance:tt(),commission:Dt(vt(tt()))})))),t7=Et(dt({slot:tt(),prioritizationFee:tt()})),e7=dt({total:tt(),validator:tt(),foundation:tt(),epoch:tt()}),n7=dt({epoch:tt(),slotIndex:tt(),slotsInEpoch:tt(),absoluteSlot:tt(),blockHeight:Dt(tt()),transactionCount:Dt(tt())}),r7=dt({slotsPerEpoch:tt(),leaderScheduleSlotOffset:tt(),warmup:ls(),firstNormalEpoch:tt(),firstNormalSlot:tt()}),i7=W2(mt(),Et(tt())),Oc=vt(Ar([dt({}),mt()])),s7=dt({err:Oc}),o7=nn("receivedSignature"),a7=dt({"solana-core":mt(),"feature-set":Dt(tt())}),c7=dt({program:mt(),programId:on,parsed:Vl()}),u7=dt({programId:on,accounts:Et(on),data:mt()}),WA=En(dt({err:vt(Ar([dt({}),mt()])),logs:vt(Et(mt())),accounts:Dt(vt(Et(vt(dt({executable:ls(),owner:mt(),lamports:tt(),data:Et(mt()),rentEpoch:Dt(tt())}))))),unitsConsumed:Dt(tt()),returnData:Dt(vt(dt({programId:mt(),data:N1([mt(),nn("base64")])}))),innerInstructions:Dt(vt(Et(dt({index:tt(),instructions:Et(Ar([c7,u7]))}))))})),l7=En(dt({byIdentity:W2(mt(),Et(tt())),range:dt({firstSlot:tt(),lastSlot:tt()})}));function f7(n,t,e,r,i,s){const o=e||VF;let a;s!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return r&&(u=async(h,y)=>{const _=await new Promise((w,R)=>{try{r(h,y,(T,I)=>w([T,I]))}catch(T){R(T)}});return await o(..._)}),new H9(async(h,y)=>{const _={method:"POST",body:h,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},f$)};try{let w=5,R,T=500;for(;u?R=await u(n,_):R=await o(n,_),!(R.status!==429||i===!0||(w-=1,w===0));)console.error(`Server responded with ${R.status} ${R.statusText}. Retrying after ${T}ms delay...`),await va(T),T*=2;const I=await R.text();R.ok?y(null,I):y(new Error(`${R.status} ${R.statusText}: ${I}`))}catch(w){w instanceof Error&&y(w)}},{})}function h7(n){return(t,e)=>new Promise((r,i)=>{n.request(t,e,(s,o)=>{if(s){i(s);return}r(o)})})}function d7(n){return t=>new Promise((e,r)=>{t.length===0&&e([]);const i=t.map(s=>n.request(s.methodName,s.args));n.request(i,(s,o)=>{if(s){r(s);return}e(o)})})}const p7=ee(YF),g7=ee(e7),y7=ee(t7),m7=ee(n7),w7=ee(r7),b7=ee(i7),_7=ee(tt()),A7=En(dt({total:tt(),circulating:tt(),nonCirculating:tt(),nonCirculatingAccounts:Et(on)})),aw=dt({amount:mt(),uiAmount:vt(tt()),decimals:tt(),uiAmountString:Dt(mt())}),E7=En(Et(dt({address:on,amount:mt(),uiAmount:vt(tt()),decimals:tt(),uiAmountString:Dt(mt())}))),v7=En(Et(dt({pubkey:on,account:dt({executable:ls(),owner:on,lamports:tt(),data:F1,rentEpoch:tt()})}))),cw=dt({program:mt(),parsed:Vl(),space:tt()}),x7=En(Et(dt({pubkey:on,account:dt({executable:ls(),owner:on,lamports:tt(),data:cw,rentEpoch:tt()})}))),R7=En(Et(dt({lamports:tt(),address:on}))),yh=dt({executable:ls(),owner:on,lamports:tt(),data:F1,rentEpoch:tt()}),I7=dt({pubkey:on,account:yh}),S7=od(Ar([O1(St),cw]),Ar([pR,cw]),n=>Array.isArray(n)?bt(n,F1):n),uw=dt({executable:ls(),owner:on,lamports:tt(),data:S7,rentEpoch:tt()}),k7=dt({pubkey:on,account:uw}),T7=dt({state:Ar([nn("active"),nn("inactive"),nn("activating"),nn("deactivating")]),active:tt(),inactive:tt()}),O7=ee(Et(dt({signature:mt(),slot:tt(),err:Oc,memo:vt(mt()),blockTime:Dt(vt(tt()))}))),N7=ee(Et(dt({signature:mt(),slot:tt(),err:Oc,memo:vt(mt()),blockTime:Dt(vt(tt()))}))),C7=dt({subscription:tt(),result:Fp(yh)}),B7=dt({pubkey:on,account:yh}),P7=dt({subscription:tt(),result:Fp(B7)}),M7=dt({parent:tt(),slot:tt(),root:tt()}),L7=dt({subscription:tt(),result:M7}),U7=Ar([dt({type:Ar([nn("firstShredReceived"),nn("completed"),nn("optimisticConfirmation"),nn("root")]),slot:tt(),timestamp:tt()}),dt({type:nn("createdBank"),parent:tt(),slot:tt(),timestamp:tt()}),dt({type:nn("frozen"),slot:tt(),timestamp:tt(),stats:dt({numTransactionEntries:tt(),numSuccessfulTransactions:tt(),numFailedTransactions:tt(),maxTransactionsPerEntry:tt()})}),dt({type:nn("dead"),slot:tt(),timestamp:tt(),err:mt()})]),D7=dt({subscription:tt(),result:U7}),F7=dt({subscription:tt(),result:Fp(Ar([s7,o7]))}),$7=dt({subscription:tt(),result:tt()}),H7=dt({pubkey:mt(),gossip:vt(mt()),tpu:vt(mt()),rpc:vt(mt()),version:vt(mt())}),ZA=dt({votePubkey:mt(),nodePubkey:mt(),activatedStake:tt(),epochVoteAccount:ls(),epochCredits:Et(N1([tt(),tt(),tt()])),commission:tt(),lastVote:tt(),rootSlot:vt(tt())}),z7=ee(dt({current:Et(ZA),delinquent:Et(ZA)})),G7=Ar([nn("processed"),nn("confirmed"),nn("finalized")]),V7=dt({slot:tt(),confirmations:vt(tt()),err:Oc,confirmationStatus:Dt(G7)}),K7=En(Et(vt(V7))),j7=ee(tt()),mR=dt({accountKey:on,writableIndexes:Et(tt()),readonlyIndexes:Et(tt())}),$1=dt({signatures:Et(mt()),message:dt({accountKeys:Et(mt()),header:dt({numRequiredSignatures:tt(),numReadonlySignedAccounts:tt(),numReadonlyUnsignedAccounts:tt()}),instructions:Et(dt({accounts:Et(tt()),data:mt(),programIdIndex:tt()})),recentBlockhash:mt(),addressTableLookups:Dt(Et(mR))})}),wR=dt({pubkey:on,signer:ls(),writable:ls(),source:Dt(Ar([nn("transaction"),nn("lookupTable")]))}),bR=dt({accountKeys:Et(wR),signatures:Et(mt())}),_R=dt({parsed:Vl(),program:mt(),programId:on}),AR=dt({accounts:Et(on),data:mt(),programId:on}),W7=Ar([AR,_R]),Z7=Ar([dt({parsed:Vl(),program:mt(),programId:mt()}),dt({accounts:Et(mt()),data:mt(),programId:mt()})]),ER=od(W7,Z7,n=>"accounts"in n?bt(n,AR):bt(n,_R)),vR=dt({signatures:Et(mt()),message:dt({accountKeys:Et(wR),instructions:Et(ER),recentBlockhash:mt(),addressTableLookups:Dt(vt(Et(mR)))})}),H0=dt({accountIndex:tt(),mint:mt(),owner:Dt(mt()),programId:Dt(mt()),uiTokenAmount:aw}),xR=dt({writable:Et(on),readonly:Et(on)}),$p=dt({err:Oc,fee:tt(),innerInstructions:Dt(vt(Et(dt({index:tt(),instructions:Et(dt({accounts:Et(tt()),data:mt(),programIdIndex:tt()}))})))),preBalances:Et(tt()),postBalances:Et(tt()),logMessages:Dt(vt(Et(mt()))),preTokenBalances:Dt(vt(Et(H0))),postTokenBalances:Dt(vt(Et(H0))),loadedAddresses:Dt(xR),computeUnitsConsumed:Dt(tt())}),H1=dt({err:Oc,fee:tt(),innerInstructions:Dt(vt(Et(dt({index:tt(),instructions:Et(ER)})))),preBalances:Et(tt()),postBalances:Et(tt()),logMessages:Dt(vt(Et(mt()))),preTokenBalances:Dt(vt(Et(H0))),postTokenBalances:Dt(vt(Et(H0))),loadedAddresses:Dt(xR),computeUnitsConsumed:Dt(tt())}),Kl=Ar([nn(0),nn("legacy")]),Nc=dt({pubkey:mt(),lamports:tt(),postBalance:vt(tt()),rewardType:vt(mt()),commission:Dt(vt(tt()))}),q7=ee(vt(dt({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),transactions:Et(dt({transaction:$1,meta:vt($p),version:Dt(Kl)})),rewards:Dt(Et(Nc)),blockTime:vt(tt()),blockHeight:vt(tt())}))),Q7=ee(vt(dt({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),rewards:Dt(Et(Nc)),blockTime:vt(tt()),blockHeight:vt(tt())}))),J7=ee(vt(dt({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),transactions:Et(dt({transaction:bR,meta:vt($p),version:Dt(Kl)})),rewards:Dt(Et(Nc)),blockTime:vt(tt()),blockHeight:vt(tt())}))),Y7=ee(vt(dt({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),transactions:Et(dt({transaction:vR,meta:vt(H1),version:Dt(Kl)})),rewards:Dt(Et(Nc)),blockTime:vt(tt()),blockHeight:vt(tt())}))),X7=ee(vt(dt({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),transactions:Et(dt({transaction:bR,meta:vt(H1),version:Dt(Kl)})),rewards:Dt(Et(Nc)),blockTime:vt(tt()),blockHeight:vt(tt())}))),t$=ee(vt(dt({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),rewards:Dt(Et(Nc)),blockTime:vt(tt()),blockHeight:vt(tt())}))),e$=ee(vt(dt({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),transactions:Et(dt({transaction:$1,meta:vt($p)})),rewards:Dt(Et(Nc)),blockTime:vt(tt())}))),qA=ee(vt(dt({blockhash:mt(),previousBlockhash:mt(),parentSlot:tt(),signatures:Et(mt()),blockTime:vt(tt())}))),tm=ee(vt(dt({slot:tt(),meta:vt($p),blockTime:Dt(vt(tt())),transaction:$1,version:Dt(Kl)}))),zd=ee(vt(dt({slot:tt(),transaction:vR,meta:vt(H1),blockTime:Dt(vt(tt())),version:Dt(Kl)}))),n$=En(dt({blockhash:mt(),lastValidBlockHeight:tt()})),r$=En(ls()),i$=dt({slot:tt(),numTransactions:tt(),numSlots:tt(),samplePeriodSecs:tt()}),s$=ee(Et(i$)),o$=En(vt(dt({feeCalculator:dt({lamportsPerSignature:tt()})}))),a$=ee(mt()),c$=ee(mt()),u$=dt({err:Oc,logs:Et(mt()),signature:mt()}),l$=dt({result:Fp(u$),subscription:tt()}),f$={"solana-client":"js/1.0.0-maintenance"};class RR{constructor(t,e){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const f={};return async h=>{const{commitment:y,config:_}=$e(h),w=this._buildArgs([],y,void 0,_),R=VA(w);return f[R]=f[R]??(async()=>{try{const T=await this._rpcRequest("getBlockHeight",w),I=bt(T,ee(tt()));if("error"in I)throw new Pt(I.error,"failed to get block height information");return I.result}finally{delete f[R]}})(),await f[R]}})();let r,i,s,o,a,u;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,r=e.wsEndpoint,i=e.httpHeaders,s=e.fetch,o=e.fetchMiddleware,a=e.disableRetryOnRateLimit,u=e.httpAgent),this._rpcEndpoint=QF(t),this._rpcWsEndpoint=r||qF(t),this._rpcClient=f7(t,i,s,o,a,u),this._rpcRequest=h7(this._rpcClient),this._rpcBatchRequest=d7(this._rpcClient),this._rpcWebSocket=new KF(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(t,e){const{commitment:r,config:i}=$e(e),s=this._buildArgs([t.toBase58()],r,void 0,i),o=await this._rpcRequest("getBalance",s),a=bt(o,En(tt()));if("error"in a)throw new Pt(a.error,`failed to get balance for ${t.toBase58()}`);return a.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+r)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),r=bt(e,ee(vt(tt())));if("error"in r)throw new Pt(r.error,`failed to get block time for slot ${t}`);return r.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=bt(t,ee(tt()));if("error"in e)throw new Pt(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=bt(t,_7);if("error"in e)throw new Pt(e.error,"failed to get first available block");return e.result}async getSupply(t){let e={};typeof t=="string"?e={commitment:t}:t?e={...t,commitment:t&&t.commitment||this.commitment}:e={commitment:this.commitment};const r=await this._rpcRequest("getSupply",[e]),i=bt(r,A7);if("error"in i)throw new Pt(i.error,"failed to get supply");return i.result}async getTokenSupply(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenSupply",r),s=bt(i,En(aw));if("error"in s)throw new Pt(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenAccountBalance",r),s=bt(i,En(aw));if("error"in s)throw new Pt(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(t,e,r){const{commitment:i,config:s}=$e(r);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const a=this._buildArgs(o,i,"base64",s),u=await this._rpcRequest("getTokenAccountsByOwner",a),f=bt(u,v7);if("error"in f)throw new Pt(f.error,`failed to get token accounts owned by account ${t.toBase58()}`);return f.result}async getParsedTokenAccountsByOwner(t,e,r){let i=[t.toBase58()];"mint"in e?i.push({mint:e.mint.toBase58()}):i.push({programId:e.programId.toBase58()});const s=this._buildArgs(i,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",s),a=bt(o,x7);if("error"in a)throw new Pt(a.error,`failed to get token accounts owned by account ${t.toBase58()}`);return a.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},r=e.filter||e.commitment?[e]:[],i=await this._rpcRequest("getLargestAccounts",r),s=bt(i,R7);if("error"in s)throw new Pt(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(t,e){const r=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenLargestAccounts",r),s=bt(i,E7);if("error"in s)throw new Pt(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(t,e){const{commitment:r,config:i}=$e(e),s=this._buildArgs([t.toBase58()],r,"base64",i),o=await this._rpcRequest("getAccountInfo",s),a=bt(o,En(vt(yh)));if("error"in a)throw new Pt(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getParsedAccountInfo(t,e){const{commitment:r,config:i}=$e(e),s=this._buildArgs([t.toBase58()],r,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",s),a=bt(o,En(vt(uw)));if("error"in a)throw new Pt(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(r){throw new Error("failed to get info about account "+t.toBase58()+": "+r)}}async getMultipleParsedAccounts(t,e){const{commitment:r,config:i}=$e(e),s=t.map(f=>f.toBase58()),o=this._buildArgs([s],r,"jsonParsed",i),a=await this._rpcRequest("getMultipleAccounts",o),u=bt(a,En(Et(vt(uw))));if("error"in u)throw new Pt(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:r,config:i}=$e(e),s=t.map(f=>f.toBase58()),o=this._buildArgs([s],r,"base64",i),a=await this._rpcRequest("getMultipleAccounts",o),u=bt(a,En(Et(vt(yh))));if("error"in u)throw new Pt(u.error,`failed to get info for accounts ${s}`);return u.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,r){const{commitment:i,config:s}=$e(e),o=this._buildArgs([t.toBase58()],i,void 0,{...s,epoch:r??(s==null?void 0:s.epoch)}),a=await this._rpcRequest("getStakeActivation",o),u=bt(a,ee(T7));if("error"in u)throw new Pt(u.error,`failed to get Stake Activation ${t.toBase58()}`);return u.result}async getProgramAccounts(t,e){const{commitment:r,config:i}=$e(e),{encoding:s,...o}=i||{},a=this._buildArgs([t.toBase58()],r,s||"base64",{...o,...o.filters?{filters:jA(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",a),f=Et(I7),h=o.withContext===!0?bt(u,En(f)):bt(u,ee(f));if("error"in h)throw new Pt(h.error,`failed to get accounts owned by program ${t.toBase58()}`);return h.result}async getParsedProgramAccounts(t,e){const{commitment:r,config:i}=$e(e),s=this._buildArgs([t.toBase58()],r,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",s),a=bt(o,ee(Et(k7)));if("error"in a)throw new Pt(a.error,`failed to get accounts owned by program ${t.toBase58()}`);return a.result}async confirmTransaction(t,e){var s;let r;if(typeof t=="string")r=t;else{const o=t;if((s=o.abortSignal)!=null&&s.aborted)return Promise.reject(o.abortSignal.reason);r=o.signature}let i;try{i=kn.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return be(i.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:r}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise((e,r)=>{t!=null&&(t.aborted?r(t.reason):t.addEventListener("abort",()=>{r(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let r,i,s=!1;const o=new Promise((u,f)=>{try{r=this.onSignature(e,(y,_)=>{r=void 0;const w={context:_,value:y};u({__type:As.PROCESSED,response:w})},t);const h=new Promise(y=>{r==null?y():i=this._onSubscriptionStateChange(r,_=>{_==="subscribed"&&y()})});(async()=>{if(await h,s)return;const y=await this.getSignatureStatus(e);if(s||y==null)return;const{context:_,value:w}=y;if(w!=null)if(w!=null&&w.err)f(w.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(w.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(w.confirmationStatus==="processed"||w.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,u({__type:As.PROCESSED,response:{context:_,value:w}})}})()}catch(h){f(h)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:r,signature:i}}){let s=!1;const o=new Promise(y=>{const _=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let w=await _();if(!s){for(;w<=r;)if(await va(1e3),s||(w=await _(),s))return;y({__type:As.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:t,signature:i}),f=this.getCancellationPromise(e);let h;try{const y=await Promise.race([f,u,o]);if(y.__type===As.PROCESSED)h=y.response;else throw new P1(i)}finally{s=!0,a()}return h}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:i,nonceValue:s,signature:o}}){let a=!1;const u=new Promise(w=>{let R=s,T=null;const I=async()=>{try{const{context:B,value:H}=await this.getNonceAndContext(i,{commitment:t,minContextSlot:r});return T=B.slot,H==null?void 0:H.nonce}catch{return R}};(async()=>{if(R=await I(),!a)for(;;){if(s!==R){w({__type:As.NONCE_INVALID,slotInWhichNonceDidAdvance:T});return}if(await va(2e3),a||(R=await I(),a))return}})()}),{abortConfirmation:f,confirmationPromise:h}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),y=this.getCancellationPromise(e);let _;try{const w=await Promise.race([y,h,u]);if(w.__type===As.PROCESSED)_=w.response;else{let R;for(;;){const T=await this.getSignatureStatus(o);if(T==null)break;if(T.context.slot<(w.slotInWhichNonceDidAdvance??r)){await va(400);continue}R=T;break}if(R!=null&&R.value){const T=t||"finalized",{confirmationStatus:I}=R.value;switch(T){case"processed":case"recent":if(I!=="processed"&&I!=="confirmed"&&I!=="finalized")throw new iu(o);break;case"confirmed":case"single":case"singleGossip":if(I!=="confirmed"&&I!=="finalized")throw new iu(o);break;case"finalized":case"max":case"root":if(I!=="finalized")throw new iu(o);break;default:}_={context:R.context,value:{err:R.value.err}}}else throw new iu(o)}}finally{a=!0,f()}return _}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const i=new Promise(u=>{let f=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{f=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>u({__type:As.TIMED_OUT,timeoutMs:f}),f)}),{abortConfirmation:s,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let a;try{const u=await Promise.race([o,i]);if(u.__type===As.PROCESSED)a=u.response;else throw new M1(e,u.timeoutMs/1e3)}finally{clearTimeout(r),s()}return a}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=bt(t,ee(Et(H7)));if("error"in e)throw new Pt(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getVoteAccounts",e),i=bt(r,z7);if("error"in i)throw new Pt(i.error,"failed to get vote accounts");return i.result}async getSlot(t){const{commitment:e,config:r}=$e(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getSlot",i),o=bt(s,ee(tt()));if("error"in o)throw new Pt(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:r}=$e(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getSlotLeader",i),o=bt(s,ee(mt()));if("error"in o)throw new Pt(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const r=[t,e],i=await this._rpcRequest("getSlotLeaders",r),s=bt(i,ee(Et(on)));if("error"in s)throw new Pt(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(t,e){const{context:r,value:i}=await this.getSignatureStatuses([t],e);be(i.length===1);const s=i[0];return{context:r,value:s}}async getSignatureStatuses(t,e){const r=[t];e&&r.push(e);const i=await this._rpcRequest("getSignatureStatuses",r),s=bt(i,K7);if("error"in s)throw new Pt(s.error,"failed to get signature status");return s.result}async getTransactionCount(t){const{commitment:e,config:r}=$e(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getTransactionCount",i),o=bt(s,ee(tt()));if("error"in o)throw new Pt(o.error,"failed to get transaction count");return o.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getInflationGovernor",e),i=bt(r,p7);if("error"in i)throw new Pt(i.error,"failed to get inflation");return i.result}async getInflationReward(t,e,r){const{commitment:i,config:s}=$e(r),o=this._buildArgs([t.map(f=>f.toBase58())],i,void 0,{...s,epoch:e??(s==null?void 0:s.epoch)}),a=await this._rpcRequest("getInflationReward",o),u=bt(a,XF);if("error"in u)throw new Pt(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=bt(t,g7);if("error"in e)throw new Pt(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:r}=$e(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getEpochInfo",i),o=bt(s,m7);if("error"in o)throw new Pt(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=bt(t,w7);if("error"in e)throw new Pt(e.error,"failed to get epoch schedule");const r=e.result;return new dR(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=bt(t,b7);if("error"in e)throw new Pt(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const r=this._buildArgs([t],e),i=await this._rpcRequest("getMinimumBalanceForRentExemption",r),s=bt(i,j7);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(t){const{context:e,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),r=bt(e,s$);if("error"in r)throw new Pt(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(t,e){const r=this._buildArgs([t],e),i=await this._rpcRequest("getFeeCalculatorForBlockhash",r),s=bt(i,o$);if("error"in s)throw new Pt(s.error,"failed to get fee calculator");const{context:o,value:a}=s.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(t,e){const r=ne(t.serialize()).toString("base64"),i=this._buildArgs([r],e),s=await this._rpcRequest("getFeeForMessage",i),o=bt(s,En(vt(tt())));if("error"in o)throw new Pt(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(t){var o;const e=(o=t==null?void 0:t.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),r=e!=null&&e.length?[e]:[],i=await this._rpcRequest("getRecentPrioritizationFees",r),s=bt(i,y7);if("error"in s)throw new Pt(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:r}=$e(t),i=this._buildArgs([],e,void 0,r),s=await this._rpcRequest("getLatestBlockhash",i),o=bt(s,n$);if("error"in o)throw new Pt(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:r,config:i}=$e(e),s=this._buildArgs([t],r,void 0,i),o=await this._rpcRequest("isBlockhashValid",s),a=bt(o,r$);if("error"in a)throw new Pt(a.error,"failed to determine if the blockhash `"+t+"`is valid");return a.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=bt(t,ee(a7));if("error"in e)throw new Pt(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=bt(t,ee(mt()));if("error"in e)throw new Pt(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:r,config:i}=$e(e),s=this._buildArgsAtLeastConfirmed([t],r,void 0,i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=bt(o,J7);if("error"in a)throw a.error;return a.result}case"none":{const a=bt(o,Q7);if("error"in a)throw a.error;return a.result}default:{const a=bt(o,q7);if("error"in a)throw a.error;const{result:u}=a;return u?{...u,transactions:u.transactions.map(({transaction:f,meta:h,version:y})=>({meta:h,transaction:{...f,message:Xy(y,f.message)},version:y}))}:null}}}catch(a){throw new Pt(a,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:r,config:i}=$e(e),s=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",i),o=await this._rpcRequest("getBlock",s);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=bt(o,X7);if("error"in a)throw a.error;return a.result}case"none":{const a=bt(o,t$);if("error"in a)throw a.error;return a.result}default:{const a=bt(o,Y7);if("error"in a)throw a.error;return a.result}}}catch(a){throw new Pt(a,"failed to get block")}}async getBlockProduction(t){let e,r;if(typeof t=="string")r=t;else if(t){const{commitment:a,...u}=t;r=a,e=u}const i=this._buildArgs([],r,"base64",e),s=await this._rpcRequest("getBlockProduction",i),o=bt(s,l7);if("error"in o)throw new Pt(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:r,config:i}=$e(e),s=this._buildArgsAtLeastConfirmed([t],r,void 0,i),o=await this._rpcRequest("getTransaction",s),a=bt(o,tm);if("error"in a)throw new Pt(a.error,"failed to get transaction");const u=a.result;return u&&{...u,transaction:{...u.transaction,message:Xy(u.version,u.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:r,config:i}=$e(e),s=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",i),o=await this._rpcRequest("getTransaction",s),a=bt(o,zd);if("error"in a)throw new Pt(a.error,"failed to get transaction");return a.result}async getParsedTransactions(t,e){const{commitment:r,config:i}=$e(e),s=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],r,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(u=>{const f=bt(u,zd);if("error"in f)throw new Pt(f.error,"failed to get transactions");return f.result})}async getTransactions(t,e){const{commitment:r,config:i}=$e(e),s=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],r,void 0,i)}));return(await this._rpcBatchRequest(s)).map(u=>{const f=bt(u,tm);if("error"in f)throw new Pt(f.error,"failed to get transactions");const h=f.result;return h&&{...h,transaction:{...h.transaction,message:Xy(h.version,h.transaction.message)}}})}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getBlock",r),s=bt(i,e$);if("error"in s)throw new Pt(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+t+" not found");const a={...o,transactions:o.transactions.map(({transaction:u,meta:f})=>{const h=new Ti(u.message);return{meta:f,transaction:{...u,message:h}}})};return{...a,transactions:a.transactions.map(({transaction:u,meta:f})=>({meta:f,transaction:Oe.populate(u.message,u.signatures)}))}}async getBlocks(t,e,r){const i=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],r),s=await this._rpcRequest("getBlocks",i),o=bt(s,ee(Et(tt())));if("error"in o)throw new Pt(o.error,"failed to get blocks");return o.result}async getBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=bt(i,qA);if("error"in s)throw new Pt(s.error,"failed to get block");const o=s.result;if(!o)throw new Error("Block "+t+" not found");return o}async getConfirmedBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=bt(i,qA);if("error"in s)throw new Pt(s.error,"failed to get confirmed block");const o=s.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getTransaction",r),s=bt(i,tm);if("error"in s)throw new Pt(s.error,"failed to get transaction");const o=s.result;if(!o)return o;const a=new Ti(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:Oe.populate(a,u)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),i=await this._rpcRequest("getTransaction",r),s=bt(i,zd);if("error"in s)throw new Pt(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(t,e){const r=t.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const a=bt(o,zd);if("error"in a)throw new Pt(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(t,e,r){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&(e--,!(e<=0||e<s));)try{const u=await this.getConfirmedBlockSignatures(e,"finalized");u.signatures.length>0&&(i.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let o=await this.getSlot("finalized");for(;!("before"in i)&&(r++,!(r>o));)try{const u=await this.getConfirmedBlockSignatures(r);u.signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(t,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(t,e,r){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=bt(s,O7);if("error"in o)throw new Pt(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,r){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),s=await this._rpcRequest("getSignaturesForAddress",i),o=bt(s,N7);if("error"in o)throw new Pt(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:r,value:i}=await this.getAccountInfoAndContext(t,e);let s=null;return i!==null&&(s=new ow({key:t,state:ow.deserialize(i.data)})),{context:r,value:s}}async getNonceAndContext(t,e){const{context:r,value:i}=await this.getAccountInfoAndContext(t,e);let s=null;return i!==null&&(s=Dp.fromAccountData(i.data)),{context:r,value:s}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+r)})}async requestAirdrop(t,e){const r=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),i=bt(r,a$);if("error"in i)throw new Pt(i.error,`airdrop to ${t.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await va(100);const r=Date.now()-this._blockhashInfo.lastFetch>=gR;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,r=e?e.blockhash:null;for(let i=0;i<50;i++){const s=await this.getLatestBlockhash("finalized");if(r!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await va(lR/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:r}=$e(t),i=this._buildArgs([],e,"base64",r),s=await this._rpcRequest("getStakeMinimumDelegation",i),o=bt(s,En(tt()));if("error"in o)throw new Pt(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,r){if("message"in t){const T=t.serialize(),I=St.from(T).toString("base64");if(Array.isArray(e)||r!==void 0)throw new Error("Invalid arguments");const B=e||{};B.encoding="base64","commitment"in B||(B.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(B.innerInstructions=e.innerInstructions);const H=[I,B],U=await this._rpcRequest("simulateTransaction",H),G=bt(U,WA);if("error"in G)throw new Error("failed to simulate transaction: "+G.error.message);return G.result}let i;if(t instanceof Oe){let R=t;i=new Oe,i.feePayer=R.feePayer,i.instructions=t.instructions,i.nonceInfo=R.nonceInfo,i.signatures=R.signatures}else i=Oe.populate(t),i._message=i._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(i.nonceInfo&&s)i.sign(...s);else{let R=this._disableBlockhashCaching;for(;;){const T=await this._blockhashWithExpiryBlockHeight(R);if(i.lastValidBlockHeight=T.lastValidBlockHeight,i.recentBlockhash=T.blockhash,!s)break;if(i.sign(...s),!i.signature)throw new Error("!signature");const I=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(I)&&!this._blockhashInfo.transactionSignatures.includes(I)){this._blockhashInfo.simulatedSignatures.push(I);break}else R=!0}}const o=i._compile(),a=o.serialize(),f=i._serialize(a).toString("base64"),h={encoding:"base64",commitment:this.commitment};if(r){const R=(Array.isArray(r)?r:o.nonProgramIds()).map(T=>T.toBase58());h.accounts={encoding:"base64",addresses:R}}s&&(h.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(h.innerInstructions=e.innerInstructions);const y=[f,h],_=await this._rpcRequest("simulateTransaction",y),w=bt(_,WA);if("error"in w){let R;if("data"in w.error&&(R=w.error.data.logs,R&&Array.isArray(R))){const T=`
|
|
23
|
+
`,I=T+R.join(T);console.error(w.error.message,I)}throw new sa({action:"simulate",signature:"",transactionMessage:w.error.message,logs:R})}return w.result}async sendTransaction(t,e,r){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const o=t.serialize();return await this.sendRawTransaction(o,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(t.nonceInfo)t.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=a.lastValidBlockHeight,t.recentBlockhash=a.blockhash,t.sign(...i),!t.signature)throw new Error("!signature");const u=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const s=t.serialize();return await this.sendRawTransaction(s,r)}async sendRawTransaction(t,e){const r=ne(t).toString("base64");return await this.sendEncodedTransaction(r,e)}async sendEncodedTransaction(t,e){const r={encoding:"base64"},i=e&&e.skipPreflight,s=i===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(r.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(r.minContextSlot=e.minContextSlot),i&&(r.skipPreflight=i),s&&(r.preflightCommitment=s);const o=[t,r],a=await this._rpcRequest("sendTransaction",o),u=bt(a,c$);if("error"in u){let f;throw"data"in u.error&&(f=u.error.data.logs),new sa({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:f})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,r])=>{this._setSubscription(e,{...r,state:"pending"})})}_setSubscription(t,e){var i;const r=(i=this._subscriptionsByHash[t])==null?void 0:i.state;if(this._subscriptionsByHash[t]=e,r!==e.state){const s=this._subscriptionStateChangeCallbacksByHash[t];s&&s.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var s;const r=this._subscriptionHashByClientSubscriptionId[t];if(r==null)return()=>{};const i=(s=this._subscriptionStateChangeCallbacksByHash)[r]||(s[r]=new Set);return i.add(e),()=>{i.delete(e),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{const i=this._subscriptionsByHash[r];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[r],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:s,method:o}=i;try{this._setSubscription(r,{...i,state:"subscribing"});const a=await this._rpcWebSocket.call(o,s);this._setSubscription(r,{...i,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=i.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:s,error:a}),!e())return;this._setSubscription(r,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:s,unsubscribeMethod:o}=i;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(r,{...i,state:"unsubscribing"}),this._setSubscription(r,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[s])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!e())return;this._setSubscription(r,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const r=this._subscriptionCallbacksByServerSubscriptionId[t];r!==void 0&&r.forEach(i=>{try{i(...e)}catch(s){console.error(s)}})}_wsOnAccountNotification(t){const{result:e,subscription:r}=bt(t,C7);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,i=VA([t.method,e]),s=this._subscriptionsByHash[i];return s===void 0?this._subscriptionsByHash[i]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:s.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[i];be(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),o.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(t,e,r){const{commitment:i,config:s}=$e(r),o=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:r}=bt(t,P7);this._handleServerNotification(r,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,r,i){const{commitment:s,config:o}=$e(r),a=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",o||(i?{filters:jA(i)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,r){const i=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],r||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:r}=bt(t,l$);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=bt(t,L7);this._handleServerNotification(r,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:r}=bt(t,D7);this._handleServerNotification(r,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,r,i){const s=e||this._commitment;if(s||r||i){let o={};r&&(o.encoding=r),s&&(o.commitment=s),i&&(o=Object.assign(o,i)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,r,i){const s=e||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,r,i)}_wsOnSignatureNotification(t){const{result:e,subscription:r}=bt(t,F7);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,r){const i=this._buildArgs([t],r||this._commitment||"finalized"),s=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){e(o.result,a);try{this.removeSignatureListener(s)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}onSignatureWithOptions(t,e,r){const{commitment:i,...s}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([t],i,void 0,s),a=this._makeSubscription({callback:(u,f)=>{e(u,f);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:r}=bt(t,$7);this._handleServerNotification(r,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}class cc{constructor(t){this._keypair=void 0,this._keypair=t??$A()}static generate(){return new cc($A())}static fromSecretKey(t,e){if(t.byteLength!==64)throw new Error("bad secret key size");const r=t.slice(32,64);if(!e||!e.skipValidation){const i=t.slice(0,32),s=$0(i);for(let o=0;o<32;o++)if(r[o]!==s[o])throw new Error("provided secretKey is invalid")}return new cc({publicKey:r,secretKey:t})}static fromSeed(t){const e=$0(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),new cc({publicKey:e,secretKey:r})}get publicKey(){return new pt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const js=Object.freeze({CreateLookupTable:{index:0,layout:Ot([Tt("instruction"),Al("recentSlot"),ge("bumpSeed")])},FreezeLookupTable:{index:1,layout:Ot([Tt("instruction")])},ExtendLookupTable:{index:2,layout:Ot([Tt("instruction"),Al(),Qn(ae(),Zo(Tt(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Ot([Tt("instruction")])},CloseLookupTable:{index:4,layout:Ot([Tt("instruction")])}});class h${constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Tt("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(js))if(o.index==r){i=s;break}if(!i)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return i}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Se(js.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=Se(js.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map(r=>new pt(r))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(z1.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}class z1{constructor(){}static createLookupTable(t){const[e,r]=pt.findProgramAddressSync([t.authority.toBuffer(),V2(BigInt(t.recentSlot),8)],this.programId),i=js.CreateLookupTable,s=de(i,{recentSlot:BigInt(t.recentSlot),bumpSeed:r}),o=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:On.programId,isSigner:!1,isWritable:!1}];return[new Pe({programId:this.programId,keys:o,data:s}),e]}static freezeLookupTable(t){const e=js.FreezeLookupTable,r=de(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Pe({programId:this.programId,keys:i,data:r})}static extendLookupTable(t){const e=js.ExtendLookupTable,r=de(e,{addresses:t.addresses.map(s=>s.toBytes())}),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&i.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:On.programId,isSigner:!1,isWritable:!1}),new Pe({programId:this.programId,keys:i,data:r})}static deactivateLookupTable(t){const e=js.DeactivateLookupTable,r=de(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Pe({programId:this.programId,keys:i,data:r})}static closeLookupTable(t){const e=js.CloseLookupTable,r=de(e),i=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Pe({programId:this.programId,keys:i,data:r})}}z1.programId=new pt("AddressLookupTab1e1111111111111111111111111");class d${constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=ge("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Qi))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return i}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:r}=Se(Qi.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Se(Qi.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Se(Qi.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Se(Qi.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(G1.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Qi=Object.freeze({RequestUnits:{index:0,layout:Ot([ge("instruction"),Tt("units"),Tt("additionalFee")])},RequestHeapFrame:{index:1,layout:Ot([ge("instruction"),Tt("bytes")])},SetComputeUnitLimit:{index:2,layout:Ot([ge("instruction"),Tt("units")])},SetComputeUnitPrice:{index:3,layout:Ot([ge("instruction"),Al("microLamports")])}});class G1{constructor(){}static requestUnits(t){const e=Qi.RequestUnits,r=de(e,t);return new Pe({keys:[],programId:this.programId,data:r})}static requestHeapFrame(t){const e=Qi.RequestHeapFrame,r=de(e,t);return new Pe({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(t){const e=Qi.SetComputeUnitLimit,r=de(e,t);return new Pe({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(t){const e=Qi.SetComputeUnitPrice,r=de(e,{microLamports:BigInt(t.microLamports)});return new Pe({keys:[],programId:this.programId,data:r})}}G1.programId=new pt("ComputeBudget111111111111111111111111111111");const QA=64,JA=32,YA=64,XA=Ot([ge("numSignatures"),ge("padding"),ai("signatureOffset"),ai("signatureInstructionIndex"),ai("publicKeyOffset"),ai("publicKeyInstructionIndex"),ai("messageDataOffset"),ai("messageDataSize"),ai("messageInstructionIndex")]);class Hp{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:i,instructionIndex:s}=t;be(e.length===JA,`Public Key must be ${JA} bytes but received ${e.length} bytes`),be(i.length===YA,`Signature must be ${YA} bytes but received ${i.length} bytes`);const o=XA.span,a=o+e.length,u=a+i.length,f=1,h=St.alloc(u+r.length),y=s??65535;return XA.encode({numSignatures:f,padding:0,signatureOffset:a,signatureInstructionIndex:y,publicKeyOffset:o,publicKeyInstructionIndex:y,messageDataOffset:u,messageDataSize:r.length,messageInstructionIndex:y},h),h.fill(e,o),h.fill(i,a),h.fill(r,u),new Pe({keys:[],programId:Hp.programId,data:h})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:i}=t;be(e.length===QA,`Private key must be ${QA} bytes but received ${e.length} bytes`);try{const s=cc.fromSecretKey(e),o=s.publicKey.toBytes(),a=C1(r,s.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}Hp.programId=new pt("Ed25519SigVerify111111111111111111111111111");const p$=(n,t)=>{const e=Mp.sign(n,t);return[e.toCompactRawBytes(),e.recovery]};Mp.utils.isValidPrivateKey;const g$=Mp.getPublicKey,tE=32,em=20,eE=64,y$=11,nm=Ot([ge("numSignatures"),ai("signatureOffset"),ge("signatureInstructionIndex"),ai("ethAddressOffset"),ge("ethAddressInstructionIndex"),ai("messageDataOffset"),ai("messageDataSize"),ge("messageInstructionIndex"),Ve(20,"ethAddress"),Ve(64,"signature"),ge("recoveryId")]);class pu{constructor(){}static publicKeyToEthAddress(t){be(t.length===eE,`Public key must be ${eE} bytes but received ${t.length} bytes`);try{return St.from(MA(ne(t))).slice(-em)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:i,recoveryId:s,instructionIndex:o}=t;return pu.createInstructionWithEthAddress({ethAddress:pu.publicKeyToEthAddress(e),message:r,signature:i,recoveryId:s,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:r,signature:i,recoveryId:s,instructionIndex:o=0}=t;let a;typeof e=="string"?e.startsWith("0x")?a=St.from(e.substr(2),"hex"):a=St.from(e,"hex"):a=e,be(a.length===em,`Address must be ${em} bytes but received ${a.length} bytes`);const u=1+y$,f=u,h=u+a.length,y=h+i.length+1,_=1,w=St.alloc(nm.span+r.length);return nm.encode({numSignatures:_,signatureOffset:h,signatureInstructionIndex:o,ethAddressOffset:f,ethAddressInstructionIndex:o,messageDataOffset:y,messageDataSize:r.length,messageInstructionIndex:o,signature:ne(i),ethAddress:ne(a),recoveryId:s},w),w.fill(ne(r),nm.span),new Pe({keys:[],programId:pu.programId,data:w})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:i}=t;be(e.length===tE,`Private key must be ${tE} bytes but received ${e.length} bytes`);try{const s=ne(e),o=g$(s,!1).slice(1),a=St.from(MA(ne(r))),[u,f]=p$(a,s);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:u,recoveryId:f,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}pu.programId=new pt("KeccakSecp256k11111111111111111111111111111");var IR;const SR=new pt("StakeConfig11111111111111111111111111111111");class kR{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class ad{constructor(t,e,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=r}}IR=ad;ad.default=new IR(0,0,pt.default);class m${constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Tt("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Un))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a StakeInstruction");return i}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:r}=Se(Un.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new kR(new pt(e.staker),new pt(e.withdrawer)),lockup:new ad(r.unixTimestamp,r.epoch,new pt(r.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Se(Un.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:r}=Se(Un.Authorize,t.data),i={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new pt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(i.custodianPubkey=t.keys[3].pubkey),i}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:r,authoritySeed:i,authorityOwner:s}=Se(Un.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:i,authorityOwner:new pt(s),newAuthorizedPubkey:new pt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(o.custodianPubkey=t.keys[3].pubkey),o}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Se(Un.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Se(Un.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Se(Un.Withdraw,t.data),r={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(r.custodianPubkey=t.keys[5].pubkey),r}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Se(Un.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(zp.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const Un=Object.freeze({Initialize:{index:0,layout:Ot([Tt("instruction"),_F(),AF()])},Authorize:{index:1,layout:Ot([Tt("instruction"),ae("newAuthorized"),Tt("stakeAuthorizationType")])},Delegate:{index:2,layout:Ot([Tt("instruction")])},Split:{index:3,layout:Ot([Tt("instruction"),Gr("lamports")])},Withdraw:{index:4,layout:Ot([Tt("instruction"),Gr("lamports")])},Deactivate:{index:5,layout:Ot([Tt("instruction")])},Merge:{index:7,layout:Ot([Tt("instruction")])},AuthorizeWithSeed:{index:8,layout:Ot([Tt("instruction"),ae("newAuthorized"),Tt("stakeAuthorizationType"),ka("authoritySeed"),ae("authorityOwner")])}}),w$=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class zp{constructor(){}static initialize(t){const{stakePubkey:e,authorized:r,lockup:i}=t,s=i||ad.default,o=Un.Initialize,a=de(o,{authorized:{staker:ne(r.staker.toBuffer()),withdrawer:ne(r.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:ne(s.custodian.toBuffer())}}),u={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:_l,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Pe(u)}static createAccountWithSeed(t){const e=new Oe;e.add(On.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:i,lockup:s}=t;return e.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static createAccount(t){const e=new Oe;e.add(On.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:i,lockup:s}=t;return e.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:r,votePubkey:i}=t,s=Un.Delegate,o=de(s);return new Oe().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:u0,isSigner:!1,isWritable:!1},{pubkey:SR,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(t){const{stakePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:o}=t,a=Un.Authorize,u=de(a,{newAuthorized:ne(i.toBuffer()),stakeAuthorizationType:s.index}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&f.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:f,programId:this.programId,data:u})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:u}=t,f=Un.AuthorizeWithSeed,h=de(f,{newAuthorized:ne(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:i,authorityOwner:ne(s.toBuffer())}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:Wi,isSigner:!1,isWritable:!1}];return u&&y.push({pubkey:u,isSigner:!0,isWritable:!1}),new Oe().add({keys:y,programId:this.programId,data:h})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:i,lamports:s}=t,o=Un.Split,a=de(o,{lamports:s});return new Pe({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(t,e){const r=new Oe;return r.add(On.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),r.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,basePubkey:o,seed:a,lamports:u}=t,f=new Oe;return f.add(On.allocate({accountPubkey:s,basePubkey:o,seed:a,space:this.space,programId:this.programId})),e&&e>0&&f.add(On.transfer({fromPubkey:t.authorizedPubkey,toPubkey:s,lamports:e})),f.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,lamports:u}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:r,authorizedPubkey:i}=t,s=Un.Merge,o=de(s);return new Oe().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:u0,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:r,toPubkey:i,lamports:s,custodianPubkey:o}=t,a=Un.Withdraw,u=de(a,{lamports:s}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:u0,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&f.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:f,programId:this.programId,data:u})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:r}=t,i=Un.Deactivate,s=de(i);return new Oe().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}zp.programId=new pt("Stake11111111111111111111111111111111111111");zp.space=200;class TR{constructor(t,e,r,i){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=r,this.commission=i}}class b${constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=Tt("instruction").decode(t.data);let i;for(const[s,o]of Object.entries(Ji))if(o.index==r){i=s;break}if(!i)throw new Error("Instruction type incorrect; not a VoteInstruction");return i}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Se(Ji.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new TR(new pt(e.nodePubkey),new pt(e.authorizedVoter),new pt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:r}=Se(Ji.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new pt(e),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:r,newAuthorized:i,voteAuthorizationType:s}}=Se(Ji.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new pt(e),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new pt(i),voteAuthorizationType:{index:s},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Se(Ji.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(jl.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}}const Ji=Object.freeze({InitializeAccount:{index:0,layout:Ot([Tt("instruction"),EF()])},Authorize:{index:1,layout:Ot([Tt("instruction"),ae("newAuthorized"),Tt("voteAuthorizationType")])},Withdraw:{index:3,layout:Ot([Tt("instruction"),Gr("lamports")])},UpdateValidatorIdentity:{index:4,layout:Ot([Tt("instruction")])},AuthorizeWithSeed:{index:10,layout:Ot([Tt("instruction"),vF()])}}),_$=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class jl{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:i}=t,s=Ji.InitializeAccount,o=de(s,{voteInit:{nodePubkey:ne(i.nodePubkey.toBuffer()),authorizedVoter:ne(i.authorizedVoter.toBuffer()),authorizedWithdrawer:ne(i.authorizedWithdrawer.toBuffer()),commission:i.commission}}),a={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:_l,isSigner:!1,isWritable:!1},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Pe(a)}static createAccount(t){const e=new Oe;return e.add(On.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:i,voteAuthorizationType:s}=t,o=Ji.Authorize,a=de(o,{newAuthorized:ne(i.toBuffer()),voteAuthorizationType:s.index}),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:u,programId:this.programId,data:a})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:o,votePubkey:a}=t,u=Ji.AuthorizeWithSeed,f=de(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:ne(r.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:ne(s.toBuffer()),voteAuthorizationType:o.index}}),h=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Wi,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new Oe().add({keys:h,programId:this.programId,data:f})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,lamports:i,toPubkey:s}=t,o=Ji.Withdraw,a=de(o,{lamports:i}),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:u,programId:this.programId,data:a})}static safeWithdraw(t,e,r){if(t.lamports>e-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return jl.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,nodePubkey:i}=t,s=Ji.UpdateValidatorIdentity,o=de(s),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:a,programId:this.programId,data:o})}}jl.programId=new pt("Vote111111111111111111111111111111111111111");jl.space=3762;const OR=new pt("Va1idator1nfo111111111111111111111111111111"),A$=dt({name:mt(),website:Dt(mt()),details:Dt(mt()),iconUrl:Dt(mt()),keybaseUsername:Dt(mt())});class V1{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(Rr(e)!==2)return null;const i=[];for(let s=0;s<2;s++){const o=new pt(Ir(e,0,is)),a=qi(e)===1;i.push({publicKey:o,isSigner:a})}if(i[0].publicKey.equals(OR)&&i[1].isSigner){const s=ka().decode(St.from(e)),o=JSON.parse(s);return K2(o,A$),new V1(i[1].publicKey,o)}return null}}const E$=new pt("Vote111111111111111111111111111111111111111"),v$=Ot([ae("nodePubkey"),ae("authorizedWithdrawer"),ge("commission"),Gn(),Qn(Ot([Gn("slot"),Tt("confirmationCount")]),Zo(Tt(),-8),"votes"),ge("rootSlotValid"),Gn("rootSlot"),Gn(),Qn(Ot([Gn("epoch"),ae("authorizedVoter")]),Zo(Tt(),-8),"authorizedVoters"),Ot([Qn(Ot([ae("authorizedPubkey"),Gn("epochOfLastAuthorizedSwitch"),Gn("targetEpoch")]),32,"buf"),Gn("idx"),ge("isEmpty")],"priorVoters"),Gn(),Qn(Ot([Gn("epoch"),Gn("credits"),Gn("prevCredits")]),Zo(Tt(),-8),"epochCredits"),Ot([Gn("slot"),Gn("timestamp")],"lastTimestamp")]);class K1{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const r=v$.decode(ne(t),4);let i=r.rootSlot;return r.rootSlotValid||(i=null),new K1({nodePubkey:new pt(r.nodePubkey),authorizedWithdrawer:new pt(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:i,authorizedVoters:r.authorizedVoters.map(x$),priorVoters:R$(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function x$({authorizedVoter:n,epoch:t}){return{epoch:t,authorizedVoter:new pt(n)}}function nE({authorizedPubkey:n,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new pt(n),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function R$({buf:n,idx:t,isEmpty:e}){return e?[]:[...n.slice(t+1).map(nE),...n.slice(0,t).map(nE)]}const rE={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function I$(n,t){const e=t===!1?"http":"https";if(!n)return rE[e].devnet;const r=rE[e][n];if(!r)throw new Error(`Unknown ${e} cluster: ${n}`);return r}async function S$(n,t,e,r){let i,s;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(i=e,s=r):s=e;const o=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},a=await n.sendRawTransaction(t,o),u=s&&s.commitment,h=(await(i?n.confirmTransaction(i,u):n.confirmTransaction(a,u))).value;if(h.err)throw a!=null?new sa({action:o!=null&&o.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(h)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(h)})`);return a}const k$=1e9,T$=Object.freeze(Object.defineProperty({__proto__:null,Account:mF,AddressLookupTableAccount:ow,AddressLookupTableInstruction:h$,AddressLookupTableProgram:z1,Authorized:kR,BLOCKHASH_CACHE_TIMEOUT_MS:gR,BPF_LOADER_DEPRECATED_PROGRAM_ID:wF,BPF_LOADER_PROGRAM_ID:DF,BpfLoader:FF,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Qi,ComputeBudgetInstruction:d$,ComputeBudgetProgram:G1,Connection:RR,Ed25519Program:Hp,Enum:gF,EpochSchedule:dR,FeeCalculatorLayout:fR,Keypair:cc,LAMPORTS_PER_SOL:k$,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:js,Loader:wc,Lockup:ad,MAX_SEED_LENGTH:aR,Message:Ti,MessageAccountKeys:gh,MessageV0:mc,NONCE_ACCOUNT_LENGTH:sw,NonceAccount:Dp,PACKET_DATA_SIZE:qo,PUBLIC_KEY_LENGTH:is,PublicKey:pt,SIGNATURE_LENGTH_IN_BYTES:ph,SOLANA_SCHEMA:Gf,STAKE_CONFIG_ID:SR,STAKE_INSTRUCTION_LAYOUTS:Un,SYSTEM_INSTRUCTION_LAYOUTS:He,SYSVAR_CLOCK_PUBKEY:Wi,SYSVAR_EPOCH_SCHEDULE_PUBKEY:kF,SYSVAR_INSTRUCTIONS_PUBKEY:TF,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:c0,SYSVAR_RENT_PUBKEY:_l,SYSVAR_REWARDS_PUBKEY:OF,SYSVAR_SLOT_HASHES_PUBKEY:NF,SYSVAR_SLOT_HISTORY_PUBKEY:CF,SYSVAR_STAKE_HISTORY_PUBKEY:u0,Secp256k1Program:pu,SendTransactionError:sa,SolanaJSONRPCError:Pt,SolanaJSONRPCErrorCode:BF,StakeAuthorizationLayout:w$,StakeInstruction:m$,StakeProgram:zp,Struct:B1,SystemInstruction:LF,SystemProgram:On,Transaction:Oe,TransactionExpiredBlockheightExceededError:P1,TransactionExpiredNonceInvalidError:iu,TransactionExpiredTimeoutError:M1,TransactionInstruction:Pe,TransactionMessage:U1,TransactionStatus:As,VALIDATOR_INFO_KEY:OR,VERSION_PREFIX_MASK:Lp,VOTE_PROGRAM_ID:E$,ValidatorInfo:V1,VersionedMessage:L1,VersionedTransaction:D1,VoteAccount:K1,VoteAuthorizationLayout:_$,VoteInit:TR,VoteInstruction:b$,VoteProgram:jl,clusterApiUrl:I$,sendAndConfirmRawTransaction:S$,sendAndConfirmTransaction:iw},Symbol.toStringTag,{value:"Module"}));var j1={exports:{}};const O$=/[\p{Lu}]/u,N$=/[\p{Ll}]/u,iE=/^[\p{Lu}](?![\p{Lu}])/gu,NR=/([\p{Alpha}\p{N}_]|$)/u,CR=/[_.\- ]+/,C$=new RegExp("^"+CR.source),sE=new RegExp(CR.source+NR.source,"gu"),oE=new RegExp("\\d+"+NR.source,"gu"),B$=(n,t,e)=>{let r=!1,i=!1,s=!1;for(let o=0;o<n.length;o++){const a=n[o];r&&O$.test(a)?(n=n.slice(0,o)+"-"+n.slice(o),r=!1,s=i,i=!0,o++):i&&s&&N$.test(a)?(n=n.slice(0,o-1)+"-"+n.slice(o-1),s=i,i=!1,r=!0):(r=t(a)===a&&e(a)!==a,s=i,i=e(a)===a&&t(a)!==a)}return n},P$=(n,t)=>(iE.lastIndex=0,n.replace(iE,e=>t(e))),M$=(n,t)=>(sE.lastIndex=0,oE.lastIndex=0,n.replace(sE,(e,r)=>t(r)).replace(oE,e=>t(e))),BR=(n,t)=>{if(!(typeof n=="string"||Array.isArray(n)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(n)?n=n.map(s=>s.trim()).filter(s=>s.length).join("-"):n=n.trim(),n.length===0)return"";const e=t.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(t.locale),r=t.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(t.locale);return n.length===1?t.pascalCase?r(n):e(n):(n!==e(n)&&(n=B$(n,e,r)),n=n.replace(C$,""),t.preserveConsecutiveUppercase?n=P$(n,e):n=e(n),t.pascalCase&&(n=r(n.charAt(0))+n.slice(1)),M$(n,r))};j1.exports=BR;j1.exports.default=BR;var L$=j1.exports;const U$=ua(L$);var qt={},xt={};let Ce=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};xt.Layout=Ce;function W1(n,t){return t.property?n+"["+t.property+"]":n}xt.nameWithProperty=W1;function D$(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(n.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Ce))throw new TypeError("layout must be a Layout");if(t.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value:function(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(n,"decode",{value:function(e,r){return t.decode(e,r)},writable:!0})}xt.bindConstructorLayout=D$;let Or=class extends Ce{isCount(){throw new Error("ExternalLayout is abstract")}};class PR extends Or{constructor(t,e){if(t===void 0&&(t=1),!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e){e===void 0&&(e=0);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}let Z1=class extends Or{constructor(t,e,r){if(!(t instanceof Ce))throw new TypeError("layout must be a Layout");if(e===void 0)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof ps||this.layout instanceof io}decode(t,e){return e===void 0&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return r===void 0&&(r=0),this.layout.encode(t,e,r+this.offset)}},ps=class extends Ce{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntLE(t,r,this.span),this.span}},io=class extends Ce{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntBE(t,r,this.span),this.span}};class Cc extends Ce{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeIntLE(t,r,this.span),this.span}}class Wl extends Ce{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeIntBE(t,r,this.span),this.span}}const lw=Math.pow(2,32);function Gp(n){const t=Math.floor(n/lw),e=n-t*lw;return{hi32:t,lo32:e}}function Vp(n,t){return n*lw+t}let F$=class extends Ce{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readUInt32LE(e+4);return Vp(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=Gp(t);return e.writeUInt32LE(i.lo32,r),e.writeUInt32LE(i.hi32,r+4),8}};class $$ extends Ce{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32BE(e),i=t.readUInt32BE(e+4);return Vp(r,i)}encode(t,e,r){r===void 0&&(r=0);const i=Gp(t);return e.writeUInt32BE(i.hi32,r),e.writeUInt32BE(i.lo32,r+4),8}}let H$=class extends Ce{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readInt32LE(e+4);return Vp(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=Gp(t);return e.writeUInt32LE(i.lo32,r),e.writeInt32LE(i.hi32,r+4),8}};class z$ extends Ce{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readInt32BE(e),i=t.readUInt32BE(e+4);return Vp(r,i)}encode(t,e,r){r===void 0&&(r=0);const i=Gp(t);return e.writeInt32BE(i.hi32,r),e.writeUInt32BE(i.lo32,r+4),8}}class MR extends Ce{constructor(t){super(4,t)}decode(t,e){return e===void 0&&(e=0),t.readFloatLE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeFloatLE(t,r),4}}class LR extends Ce{constructor(t){super(4,t)}decode(t,e){return e===void 0&&(e=0),t.readFloatBE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeFloatBE(t,r),4}}class UR extends Ce{constructor(t){super(8,t)}decode(t,e){return e===void 0&&(e=0),t.readDoubleLE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeDoubleLE(t,r),8}}class DR extends Ce{constructor(t){super(8,t)}decode(t,e){return e===void 0&&(e=0),t.readDoubleBE(e)}encode(t,e,r){return r===void 0&&(r=0),e.writeDoubleBE(t,r),8}}class FR extends Ce{constructor(t,e,r){if(!(t instanceof Ce))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Or&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(e instanceof Or)&&0<t.span&&(i=e*t.span),super(i,r),this.elementLayout=t,this.count=e}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0,i=this.count;if(i instanceof Or&&(i=i.decode(t,e)),0<this.elementLayout.span)r=i*this.elementLayout.span;else{let s=0;for(;s<i;)r+=this.elementLayout.getSpan(t,e+r),++s}return r}decode(t,e){e===void 0&&(e=0);const r=[];let i=0,s=this.count;for(s instanceof Or&&(s=s.decode(t,e));i<s;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),i+=1;return r}encode(t,e,r){r===void 0&&(r=0);const i=this.elementLayout,s=t.reduce((o,a)=>o+i.encode(a,e,r+o),0);return this.count instanceof Or&&this.count.encode(t.length,e,r),s}}let $R=class extends Ce{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Ce,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e){e===void 0&&(e=0);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){r===void 0&&(r=0);const i=r;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const f=t[a.property];f!==void 0&&(o=a.encode(f,e,r),0>u&&(u=a.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}},q1=class{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}},z0=class extends q1{constructor(t,e){if(!(t instanceof Or&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}},Q1=class extends Ce{constructor(t,e,r){const i=t instanceof ps||t instanceof io;if(i)t=new z0(new Z1(t));else if(t instanceof Or&&t.isCount())t=new z0(t);else if(!(t instanceof q1))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Ce))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&i&&(s+=t.layout.span)),super(s,r),this.discriminator=t,this.usesPrefixDiscriminator=i,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){e===void 0&&(e=0);let r;const i=this.discriminator,s=i.decode(t,e);let o=this.registry[s];if(o===void 0){let a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[o.property]=this.defaultLayout.decode(t,e+a)}else r=o.decode(t,e);return r}encode(t,e,r){r===void 0&&(r=0);const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(t[s.property],e,r),a+o.encode(t[o.property],e,r+a)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new HR(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e){let r=t;return Zt.isBuffer(t)&&(e===void 0&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}},HR=class extends Ce{constructor(t,e,r,i){if(!(t instanceof Q1))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Ce))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(e===void 0&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){r===void 0&&(r=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};function Yc(n){return 0>n&&(n+=4294967296),n}class J1 extends Ce{constructor(t,e,r){if(!(t instanceof ps||t instanceof io))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&r===void 0&&(r=e,e=void 0),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let i=0;this._packedSetValue=function(s){return i=Yc(s),this},this._packedGetValue=function(){return i}}decode(t,e){const r=this.makeDestinationObject();e===void 0&&(e=0);const i=this.word.decode(t,e);this._packedSetValue(i);for(const s of this.fields)s.property!==void 0&&(r[s.property]=s.decode(i));return r}encode(t,e,r){r===void 0&&(r=0);const i=this.word.decode(e,r);this._packedSetValue(i);for(const s of this.fields)if(s.property!==void 0){const o=t[s.property];o!==void 0&&s.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new Vf(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new zR(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}class Vf{constructor(t,e,r){if(!(t instanceof J1))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const i=8*t.span,s=t.fields.reduce((o,a)=>o+a.bits,0);if(e+s>i)throw new Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=i-s-e),this.wordMask=Yc(this.valueMask<<this.start),this.property=r}decode(){const t=this.container._packedGetValue();return Yc(t&this.wordMask)>>>this.start}encode(t){if(!Number.isInteger(t)||t!==Yc(t&this.valueMask))throw new TypeError(W1("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=Yc(t<<this.start);this.container._packedSetValue(Yc(e&~this.wordMask)|r)}}let zR=class extends Vf{constructor(t,e){super(t,1,e)}decode(t,e){return!!Vf.prototype.decode.call(this,t,e)}encode(t){return typeof t=="boolean"&&(t=+t),Vf.prototype.encode.call(this,t)}},GR=class extends Ce{constructor(t,e){if(!(t instanceof Or&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Or||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){e===void 0&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof Or&&(i=t.length),!(Zt.isBuffer(t)&&i===t.length))throw new TypeError(W1("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,i,"hex"),this.length instanceof Or&&this.length.encode(i,e,r),i}};class VR extends Ce{constructor(t){super(-1,t)}getSpan(t,e){if(!Zt.isBuffer(t))throw new TypeError("b must be a Buffer");e===void 0&&(e=0);let r=e;for(;r<t.length&&t[r]!==0;)r+=1;return 1+r-e}decode(t,e,r){e===void 0&&(e=0);let i=this.getSpan(t,e);return t.slice(e,e+i-1).toString("utf-8")}encode(t,e,r){r===void 0&&(r=0),typeof t!="string"&&(t=t.toString());const i=new Zt(t,"utf8"),s=i.length;if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(e,r),e[r+s]=0,s+1}}class KR extends Ce{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e){if(!Zt.isBuffer(t))throw new TypeError("b must be a Buffer");return e===void 0&&(e=0),t.length-e}decode(t,e,r){e===void 0&&(e=0);let i=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");return t.slice(e,e+i).toString("utf-8")}encode(t,e,r){r===void 0&&(r=0),typeof t!="string"&&(t=t.toString());const i=new Zt(t,"utf8"),s=i.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(r+s>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(e,r),s}}class jR extends Ce{constructor(t,e){super(0,e),this.value=t}decode(t,e,r){return this.value}encode(t,e,r){return 0}}xt.ExternalLayout=Or;xt.GreedyCount=PR;xt.OffsetLayout=Z1;xt.UInt=ps;xt.UIntBE=io;xt.Int=Cc;xt.IntBE=Wl;xt.Float=MR;xt.FloatBE=LR;xt.Double=UR;xt.DoubleBE=DR;xt.Sequence=FR;xt.Structure=$R;xt.UnionDiscriminator=q1;xt.UnionLayoutDiscriminator=z0;xt.Union=Q1;xt.VariantLayout=HR;xt.BitStructure=J1;xt.BitField=Vf;xt.Boolean=zR;xt.Blob=GR;xt.CString=VR;xt.UTF8=KR;xt.Constant=jR;xt.greedy=(n,t)=>new PR(n,t);xt.offset=(n,t,e)=>new Z1(n,t,e);xt.u8=n=>new ps(1,n);xt.u16=n=>new ps(2,n);xt.u24=n=>new ps(3,n);xt.u32=n=>new ps(4,n);xt.u40=n=>new ps(5,n);xt.u48=n=>new ps(6,n);xt.nu64=n=>new F$(n);xt.u16be=n=>new io(2,n);xt.u24be=n=>new io(3,n);xt.u32be=n=>new io(4,n);xt.u40be=n=>new io(5,n);xt.u48be=n=>new io(6,n);xt.nu64be=n=>new $$(n);xt.s8=n=>new Cc(1,n);xt.s16=n=>new Cc(2,n);xt.s24=n=>new Cc(3,n);xt.s32=n=>new Cc(4,n);xt.s40=n=>new Cc(5,n);xt.s48=n=>new Cc(6,n);xt.ns64=n=>new H$(n);xt.s16be=n=>new Wl(2,n);xt.s24be=n=>new Wl(3,n);xt.s32be=n=>new Wl(4,n);xt.s40be=n=>new Wl(5,n);xt.s48be=n=>new Wl(6,n);xt.ns64be=n=>new z$(n);xt.f32=n=>new MR(n);xt.f32be=n=>new LR(n);xt.f64=n=>new UR(n);xt.f64be=n=>new DR(n);xt.struct=(n,t,e)=>new $R(n,t,e);xt.bits=(n,t,e)=>new J1(n,t,e);xt.seq=(n,t,e)=>new FR(n,t,e);xt.union=(n,t,e)=>new Q1(n,t,e);xt.unionLayoutDiscriminator=(n,t)=>new z0(n,t);xt.blob=(n,t)=>new GR(n,t);xt.cstr=n=>new VR(n);xt.utf8=(n,t)=>new KR(n,t);xt.const=(n,t)=>new jR(n,t);const G$=gp(T$);(function(n){var t=qn&&qn.__importDefault||function(ot){return ot&&ot.__esModule?ot:{default:ot}};Object.defineProperty(n,"__esModule",{value:!0}),n.struct=n.f64=n.f32=n.i32=n.u32=n.i16=n.u16=n.i8=n.u8=void 0,n.u64=a,n.i64=u,n.u128=f,n.i128=h,n.u256=y,n.i256=_,n.publicKey=R,n.option=I,n.bool=B,n.vec=G,n.tagged=W,n.vecU8=X,n.str=j,n.rustEnum=Y,n.array=it,n.map=rt;const e=xt,r=G$,i=t(d1);var s=xt;Object.defineProperty(n,"u8",{enumerable:!0,get:function(){return s.u8}}),Object.defineProperty(n,"i8",{enumerable:!0,get:function(){return s.s8}}),Object.defineProperty(n,"u16",{enumerable:!0,get:function(){return s.u16}}),Object.defineProperty(n,"i16",{enumerable:!0,get:function(){return s.s16}}),Object.defineProperty(n,"u32",{enumerable:!0,get:function(){return s.u32}}),Object.defineProperty(n,"i32",{enumerable:!0,get:function(){return s.s32}}),Object.defineProperty(n,"f32",{enumerable:!0,get:function(){return s.f32}}),Object.defineProperty(n,"f64",{enumerable:!0,get:function(){return s.f64}}),Object.defineProperty(n,"struct",{enumerable:!0,get:function(){return s.struct}});class o extends e.Layout{constructor(C,p,m){super(C,m),this.blob=(0,e.blob)(C),this.signed=p}decode(C,p=0){const m=new i.default(this.blob.decode(C,p),10,"le");return this.signed?m.fromTwos(this.span*8).clone():m}encode(C,p,m=0){return this.signed&&(C=C.toTwos(this.span*8)),this.blob.encode(C.toArrayLike(Zt,"le",this.span),p,m)}}function a(ot){return new o(8,!1,ot)}function u(ot){return new o(8,!0,ot)}function f(ot){return new o(16,!1,ot)}function h(ot){return new o(16,!0,ot)}function y(ot){return new o(32,!1,ot)}function _(ot){return new o(32,!0,ot)}class w extends e.Layout{constructor(C,p,m,v){super(C.span,v),this.layout=C,this.decoder=p,this.encoder=m}decode(C,p){return this.decoder(this.layout.decode(C,p))}encode(C,p,m){return this.layout.encode(this.encoder(C),p,m)}getSpan(C,p){return this.layout.getSpan(C,p)}}function R(ot){return new w((0,e.blob)(32),C=>new r.PublicKey(C),C=>C.toBuffer(),ot)}class T extends e.Layout{constructor(C,p){super(-1,p),this.layout=C,this.discriminator=(0,e.u8)()}encode(C,p,m=0){return C==null?this.discriminator.encode(0,p,m):(this.discriminator.encode(1,p,m),this.layout.encode(C,p,m+1)+1)}decode(C,p=0){const m=this.discriminator.decode(C,p);if(m===0)return null;if(m===1)return this.layout.decode(C,p+1);throw new Error("Invalid option "+this.property)}getSpan(C,p=0){const m=this.discriminator.decode(C,p);if(m===0)return 1;if(m===1)return this.layout.getSpan(C,p+1)+1;throw new Error("Invalid option "+this.property)}}function I(ot,C){return new T(ot,C)}function B(ot){return new w((0,e.u8)(),H,U,ot)}function H(ot){if(ot===0)return!1;if(ot===1)return!0;throw new Error("Invalid bool: "+ot)}function U(ot){return ot?1:0}function G(ot,C){const p=(0,e.u32)("length"),m=(0,e.struct)([p,(0,e.seq)(ot,(0,e.offset)(p,-p.span),"values")]);return new w(m,({values:v})=>v,v=>({values:v}),C)}function W(ot,C,p){const m=(0,e.struct)([a("tag"),C.replicate("data")]);function v({tag:k,data:N}){if(!k.eq(ot))throw new Error("Invalid tag, expected: "+ot.toString("hex")+", got: "+k.toString("hex"));return N}return new w(m,v,k=>({tag:ot,data:k}),p)}function X(ot){const C=(0,e.u32)("length"),p=(0,e.struct)([C,(0,e.blob)((0,e.offset)(C,-C.span),"data")]);return new w(p,({data:m})=>m,m=>({data:m}),ot)}function j(ot){return new w(X(),C=>C.toString("utf-8"),C=>Zt.from(C,"utf-8"),ot)}function Y(ot,C,p){const m=(0,e.union)(p??(0,e.u8)(),C);return ot.forEach((v,k)=>m.addVariant(k,v,v.property)),m}function it(ot,C,p){const m=(0,e.struct)([(0,e.seq)(ot,C,"values")]);return new w(m,({values:v})=>v,v=>({values:v}),p)}class ut extends e.Layout{constructor(C,p,m){super(C.span+p.span,m),this.keyLayout=C,this.valueLayout=p}decode(C,p){p=p||0;const m=this.keyLayout.decode(C,p),v=this.valueLayout.decode(C,p+this.keyLayout.getSpan(C,p));return[m,v]}encode(C,p,m){m=m||0;const v=this.keyLayout.encode(C[0],p,m),k=this.valueLayout.encode(C[1],p,m+v);return v+k}getSpan(C,p){return this.keyLayout.getSpan(C,p)+this.valueLayout.getSpan(C,p)}}function rt(ot,C,p){const m=(0,e.u32)("length"),v=(0,e.struct)([m,(0,e.seq)(new ut(ot,C),(0,e.offset)(m,-m.span),"values")]);return new w(v,({values:k})=>new Map(k),k=>({values:Array.from(k.entries())}),p)}})(qt);/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const V$=4,aE=0,cE=1,K$=2;function Zl(n){let t=n.length;for(;--t>=0;)n[t]=0}const j$=0,WR=1,W$=2,Z$=3,q$=258,Y1=29,cd=256,mh=cd+1+Y1,gu=30,X1=19,ZR=2*mh+1,Ta=15,rm=16,Q$=7,tb=256,qR=16,QR=17,JR=18,fw=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]),l0=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]),J$=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),YR=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Y$=512,Ss=new Array((mh+2)*2);Zl(Ss);const Kf=new Array(gu*2);Zl(Kf);const wh=new Array(Y$);Zl(wh);const bh=new Array(q$-Z$+1);Zl(bh);const eb=new Array(Y1);Zl(eb);const G0=new Array(gu);Zl(G0);function im(n,t,e,r,i){this.static_tree=n,this.extra_bits=t,this.extra_base=e,this.elems=r,this.max_length=i,this.has_stree=n&&n.length}let XR,tI,eI;function sm(n,t){this.dyn_tree=n,this.max_code=0,this.stat_desc=t}const nI=n=>n<256?wh[n]:wh[256+(n>>>7)],_h=(n,t)=>{n.pending_buf[n.pending++]=t&255,n.pending_buf[n.pending++]=t>>>8&255},Nr=(n,t,e)=>{n.bi_valid>rm-e?(n.bi_buf|=t<<n.bi_valid&65535,_h(n,n.bi_buf),n.bi_buf=t>>rm-n.bi_valid,n.bi_valid+=e-rm):(n.bi_buf|=t<<n.bi_valid&65535,n.bi_valid+=e)},Yi=(n,t,e)=>{Nr(n,e[t*2],e[t*2+1])},rI=(n,t)=>{let e=0;do e|=n&1,n>>>=1,e<<=1;while(--t>0);return e>>>1},X$=n=>{n.bi_valid===16?(_h(n,n.bi_buf),n.bi_buf=0,n.bi_valid=0):n.bi_valid>=8&&(n.pending_buf[n.pending++]=n.bi_buf&255,n.bi_buf>>=8,n.bi_valid-=8)},tH=(n,t)=>{const e=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,u=t.stat_desc.max_length;let f,h,y,_,w,R,T=0;for(_=0;_<=Ta;_++)n.bl_count[_]=0;for(e[n.heap[n.heap_max]*2+1]=0,f=n.heap_max+1;f<ZR;f++)h=n.heap[f],_=e[e[h*2+1]*2+1]+1,_>u&&(_=u,T++),e[h*2+1]=_,!(h>r)&&(n.bl_count[_]++,w=0,h>=a&&(w=o[h-a]),R=e[h*2],n.opt_len+=R*(_+w),s&&(n.static_len+=R*(i[h*2+1]+w)));if(T!==0){do{for(_=u-1;n.bl_count[_]===0;)_--;n.bl_count[_]--,n.bl_count[_+1]+=2,n.bl_count[u]--,T-=2}while(T>0);for(_=u;_!==0;_--)for(h=n.bl_count[_];h!==0;)y=n.heap[--f],!(y>r)&&(e[y*2+1]!==_&&(n.opt_len+=(_-e[y*2+1])*e[y*2],e[y*2+1]=_),h--)}},iI=(n,t,e)=>{const r=new Array(Ta+1);let i=0,s,o;for(s=1;s<=Ta;s++)i=i+e[s-1]<<1,r[s]=i;for(o=0;o<=t;o++){let a=n[o*2+1];a!==0&&(n[o*2]=rI(r[a]++,a))}},eH=()=>{let n,t,e,r,i;const s=new Array(Ta+1);for(e=0,r=0;r<Y1-1;r++)for(eb[r]=e,n=0;n<1<<fw[r];n++)bh[e++]=r;for(bh[e-1]=r,i=0,r=0;r<16;r++)for(G0[r]=i,n=0;n<1<<l0[r];n++)wh[i++]=r;for(i>>=7;r<gu;r++)for(G0[r]=i<<7,n=0;n<1<<l0[r]-7;n++)wh[256+i++]=r;for(t=0;t<=Ta;t++)s[t]=0;for(n=0;n<=143;)Ss[n*2+1]=8,n++,s[8]++;for(;n<=255;)Ss[n*2+1]=9,n++,s[9]++;for(;n<=279;)Ss[n*2+1]=7,n++,s[7]++;for(;n<=287;)Ss[n*2+1]=8,n++,s[8]++;for(iI(Ss,mh+1,s),n=0;n<gu;n++)Kf[n*2+1]=5,Kf[n*2]=rI(n,5);XR=new im(Ss,fw,cd+1,mh,Ta),tI=new im(Kf,l0,0,gu,Ta),eI=new im(new Array(0),J$,0,X1,Q$)},sI=n=>{let t;for(t=0;t<mh;t++)n.dyn_ltree[t*2]=0;for(t=0;t<gu;t++)n.dyn_dtree[t*2]=0;for(t=0;t<X1;t++)n.bl_tree[t*2]=0;n.dyn_ltree[tb*2]=1,n.opt_len=n.static_len=0,n.sym_next=n.matches=0},oI=n=>{n.bi_valid>8?_h(n,n.bi_buf):n.bi_valid>0&&(n.pending_buf[n.pending++]=n.bi_buf),n.bi_buf=0,n.bi_valid=0},uE=(n,t,e,r)=>{const i=t*2,s=e*2;return n[i]<n[s]||n[i]===n[s]&&r[t]<=r[e]},om=(n,t,e)=>{const r=n.heap[e];let i=e<<1;for(;i<=n.heap_len&&(i<n.heap_len&&uE(t,n.heap[i+1],n.heap[i],n.depth)&&i++,!uE(t,r,n.heap[i],n.depth));)n.heap[e]=n.heap[i],e=i,i<<=1;n.heap[e]=r},lE=(n,t,e)=>{let r,i,s=0,o,a;if(n.sym_next!==0)do r=n.pending_buf[n.sym_buf+s++]&255,r+=(n.pending_buf[n.sym_buf+s++]&255)<<8,i=n.pending_buf[n.sym_buf+s++],r===0?Yi(n,i,t):(o=bh[i],Yi(n,o+cd+1,t),a=fw[o],a!==0&&(i-=eb[o],Nr(n,i,a)),r--,o=nI(r),Yi(n,o,e),a=l0[o],a!==0&&(r-=G0[o],Nr(n,r,a)));while(s<n.sym_next);Yi(n,tb,t)},hw=(n,t)=>{const e=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,u=-1,f;for(n.heap_len=0,n.heap_max=ZR,o=0;o<s;o++)e[o*2]!==0?(n.heap[++n.heap_len]=u=o,n.depth[o]=0):e[o*2+1]=0;for(;n.heap_len<2;)f=n.heap[++n.heap_len]=u<2?++u:0,e[f*2]=1,n.depth[f]=0,n.opt_len--,i&&(n.static_len-=r[f*2+1]);for(t.max_code=u,o=n.heap_len>>1;o>=1;o--)om(n,e,o);f=s;do o=n.heap[1],n.heap[1]=n.heap[n.heap_len--],om(n,e,1),a=n.heap[1],n.heap[--n.heap_max]=o,n.heap[--n.heap_max]=a,e[f*2]=e[o*2]+e[a*2],n.depth[f]=(n.depth[o]>=n.depth[a]?n.depth[o]:n.depth[a])+1,e[o*2+1]=e[a*2+1]=f,n.heap[1]=f++,om(n,e,1);while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],tH(n,t),iI(e,u,n.bl_count)},fE=(n,t,e)=>{let r,i=-1,s,o=t[0*2+1],a=0,u=7,f=4;for(o===0&&(u=138,f=3),t[(e+1)*2+1]=65535,r=0;r<=e;r++)s=o,o=t[(r+1)*2+1],!(++a<u&&s===o)&&(a<f?n.bl_tree[s*2]+=a:s!==0?(s!==i&&n.bl_tree[s*2]++,n.bl_tree[qR*2]++):a<=10?n.bl_tree[QR*2]++:n.bl_tree[JR*2]++,a=0,i=s,o===0?(u=138,f=3):s===o?(u=6,f=3):(u=7,f=4))},hE=(n,t,e)=>{let r,i=-1,s,o=t[0*2+1],a=0,u=7,f=4;for(o===0&&(u=138,f=3),r=0;r<=e;r++)if(s=o,o=t[(r+1)*2+1],!(++a<u&&s===o)){if(a<f)do Yi(n,s,n.bl_tree);while(--a!==0);else s!==0?(s!==i&&(Yi(n,s,n.bl_tree),a--),Yi(n,qR,n.bl_tree),Nr(n,a-3,2)):a<=10?(Yi(n,QR,n.bl_tree),Nr(n,a-3,3)):(Yi(n,JR,n.bl_tree),Nr(n,a-11,7));a=0,i=s,o===0?(u=138,f=3):s===o?(u=6,f=3):(u=7,f=4)}},nH=n=>{let t;for(fE(n,n.dyn_ltree,n.l_desc.max_code),fE(n,n.dyn_dtree,n.d_desc.max_code),hw(n,n.bl_desc),t=X1-1;t>=3&&n.bl_tree[YR[t]*2+1]===0;t--);return n.opt_len+=3*(t+1)+5+5+4,t},rH=(n,t,e,r)=>{let i;for(Nr(n,t-257,5),Nr(n,e-1,5),Nr(n,r-4,4),i=0;i<r;i++)Nr(n,n.bl_tree[YR[i]*2+1],3);hE(n,n.dyn_ltree,t-1),hE(n,n.dyn_dtree,e-1)},iH=n=>{let t=4093624447,e;for(e=0;e<=31;e++,t>>>=1)if(t&1&&n.dyn_ltree[e*2]!==0)return aE;if(n.dyn_ltree[9*2]!==0||n.dyn_ltree[10*2]!==0||n.dyn_ltree[13*2]!==0)return cE;for(e=32;e<cd;e++)if(n.dyn_ltree[e*2]!==0)return cE;return aE};let dE=!1;const sH=n=>{dE||(eH(),dE=!0),n.l_desc=new sm(n.dyn_ltree,XR),n.d_desc=new sm(n.dyn_dtree,tI),n.bl_desc=new sm(n.bl_tree,eI),n.bi_buf=0,n.bi_valid=0,sI(n)},aI=(n,t,e,r)=>{Nr(n,(j$<<1)+(r?1:0),3),oI(n),_h(n,e),_h(n,~e),e&&n.pending_buf.set(n.window.subarray(t,t+e),n.pending),n.pending+=e},oH=n=>{Nr(n,WR<<1,3),Yi(n,tb,Ss),X$(n)},aH=(n,t,e,r)=>{let i,s,o=0;n.level>0?(n.strm.data_type===K$&&(n.strm.data_type=iH(n)),hw(n,n.l_desc),hw(n,n.d_desc),o=nH(n),i=n.opt_len+3+7>>>3,s=n.static_len+3+7>>>3,s<=i&&(i=s)):i=s=e+5,e+4<=i&&t!==-1?aI(n,t,e,r):n.strategy===V$||s===i?(Nr(n,(WR<<1)+(r?1:0),3),lE(n,Ss,Kf)):(Nr(n,(W$<<1)+(r?1:0),3),rH(n,n.l_desc.max_code+1,n.d_desc.max_code+1,o+1),lE(n,n.dyn_ltree,n.dyn_dtree)),sI(n),r&&oI(n)},cH=(n,t,e)=>(n.pending_buf[n.sym_buf+n.sym_next++]=t,n.pending_buf[n.sym_buf+n.sym_next++]=t>>8,n.pending_buf[n.sym_buf+n.sym_next++]=e,t===0?n.dyn_ltree[e*2]++:(n.matches++,t--,n.dyn_ltree[(bh[e]+cd+1)*2]++,n.dyn_dtree[nI(t)*2]++),n.sym_next===n.sym_end);var uH=sH,lH=aI,fH=aH,hH=cH,dH=oH,pH={_tr_init:uH,_tr_stored_block:lH,_tr_flush_block:fH,_tr_tally:hH,_tr_align:dH};const gH=(n,t,e,r)=>{let i=n&65535|0,s=n>>>16&65535|0,o=0;for(;e!==0;){o=e>2e3?2e3:e,e-=o;do i=i+t[r++]|0,s=s+i|0;while(--o);i%=65521,s%=65521}return i|s<<16|0};var Ah=gH;const yH=()=>{let n,t=[];for(var e=0;e<256;e++){n=e;for(var r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n}return t},mH=new Uint32Array(yH()),wH=(n,t,e,r)=>{const i=mH,s=r+e;n^=-1;for(let o=r;o<s;o++)n=n>>>8^i[(n^t[o])&255];return n^-1};var Ln=wH,El={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"},ud={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:bH,_tr_stored_block:dw,_tr_flush_block:_H,_tr_tally:Qo,_tr_align:AH}=pH,{Z_NO_FLUSH:Jo,Z_PARTIAL_FLUSH:EH,Z_FULL_FLUSH:vH,Z_FINISH:ui,Z_BLOCK:pE,Z_OK:Kn,Z_STREAM_END:gE,Z_STREAM_ERROR:ss,Z_DATA_ERROR:xH,Z_BUF_ERROR:am,Z_DEFAULT_COMPRESSION:RH,Z_FILTERED:IH,Z_HUFFMAN_ONLY:Gd,Z_RLE:SH,Z_FIXED:kH,Z_DEFAULT_STRATEGY:TH,Z_UNKNOWN:OH,Z_DEFLATED:Kp}=ud,NH=9,CH=15,BH=8,PH=29,MH=256,pw=MH+1+PH,LH=30,UH=19,DH=2*pw+1,FH=15,le=3,Wo=258,os=Wo+le+1,$H=32,vl=42,nb=57,gw=69,yw=73,mw=91,ww=103,Oa=113,Mf=666,gr=1,ql=2,bc=3,Ql=4,HH=3,Na=(n,t)=>(n.msg=El[t],t),yE=n=>n*2-(n>4?9:0),vo=n=>{let t=n.length;for(;--t>=0;)n[t]=0},zH=n=>{let t,e,r,i=n.w_size;t=n.hash_size,r=t;do e=n.head[--r],n.head[r]=e>=i?e-i:0;while(--t);t=i,r=t;do e=n.prev[--r],n.prev[r]=e>=i?e-i:0;while(--t)};let GH=(n,t,e)=>(t<<n.hash_shift^e)&n.hash_mask,Yo=GH;const Ur=n=>{const t=n.state;let e=t.pending;e>n.avail_out&&(e=n.avail_out),e!==0&&(n.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+e),n.next_out),n.next_out+=e,t.pending_out+=e,n.total_out+=e,n.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))},Kr=(n,t)=>{_H(n,n.block_start>=0?n.block_start:-1,n.strstart-n.block_start,t),n.block_start=n.strstart,Ur(n.strm)},Re=(n,t)=>{n.pending_buf[n.pending++]=t},Tf=(n,t)=>{n.pending_buf[n.pending++]=t>>>8&255,n.pending_buf[n.pending++]=t&255},bw=(n,t,e,r)=>{let i=n.avail_in;return i>r&&(i=r),i===0?0:(n.avail_in-=i,t.set(n.input.subarray(n.next_in,n.next_in+i),e),n.state.wrap===1?n.adler=Ah(n.adler,t,i,e):n.state.wrap===2&&(n.adler=Ln(n.adler,t,i,e)),n.next_in+=i,n.total_in+=i,i)},cI=(n,t)=>{let e=n.max_chain_length,r=n.strstart,i,s,o=n.prev_length,a=n.nice_match;const u=n.strstart>n.w_size-os?n.strstart-(n.w_size-os):0,f=n.window,h=n.w_mask,y=n.prev,_=n.strstart+Wo;let w=f[r+o-1],R=f[r+o];n.prev_length>=n.good_match&&(e>>=2),a>n.lookahead&&(a=n.lookahead);do if(i=t,!(f[i+o]!==R||f[i+o-1]!==w||f[i]!==f[r]||f[++i]!==f[r+1])){r+=2,i++;do;while(f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&f[++r]===f[++i]&&r<_);if(s=Wo-(_-r),r=_-Wo,s>o){if(n.match_start=t,o=s,s>=a)break;w=f[r+o-1],R=f[r+o]}}while((t=y[t&h])>u&&--e!==0);return o<=n.lookahead?o:n.lookahead},xl=n=>{const t=n.w_size;let e,r,i;do{if(r=n.window_size-n.lookahead-n.strstart,n.strstart>=t+(t-os)&&(n.window.set(n.window.subarray(t,t+t-r),0),n.match_start-=t,n.strstart-=t,n.block_start-=t,n.insert>n.strstart&&(n.insert=n.strstart),zH(n),r+=t),n.strm.avail_in===0)break;if(e=bw(n.strm,n.window,n.strstart+n.lookahead,r),n.lookahead+=e,n.lookahead+n.insert>=le)for(i=n.strstart-n.insert,n.ins_h=n.window[i],n.ins_h=Yo(n,n.ins_h,n.window[i+1]);n.insert&&(n.ins_h=Yo(n,n.ins_h,n.window[i+le-1]),n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++,n.insert--,!(n.lookahead+n.insert<le)););}while(n.lookahead<os&&n.strm.avail_in!==0)},uI=(n,t)=>{let e=n.pending_buf_size-5>n.w_size?n.w_size:n.pending_buf_size-5,r,i,s,o=0,a=n.strm.avail_in;do{if(r=65535,s=n.bi_valid+42>>3,n.strm.avail_out<s||(s=n.strm.avail_out-s,i=n.strstart-n.block_start,r>i+n.strm.avail_in&&(r=i+n.strm.avail_in),r>s&&(r=s),r<e&&(r===0&&t!==ui||t===Jo||r!==i+n.strm.avail_in)))break;o=t===ui&&r===i+n.strm.avail_in?1:0,dw(n,0,0,o),n.pending_buf[n.pending-4]=r,n.pending_buf[n.pending-3]=r>>8,n.pending_buf[n.pending-2]=~r,n.pending_buf[n.pending-1]=~r>>8,Ur(n.strm),i&&(i>r&&(i=r),n.strm.output.set(n.window.subarray(n.block_start,n.block_start+i),n.strm.next_out),n.strm.next_out+=i,n.strm.avail_out-=i,n.strm.total_out+=i,n.block_start+=i,r-=i),r&&(bw(n.strm,n.strm.output,n.strm.next_out,r),n.strm.next_out+=r,n.strm.avail_out-=r,n.strm.total_out+=r)}while(o===0);return a-=n.strm.avail_in,a&&(a>=n.w_size?(n.matches=2,n.window.set(n.strm.input.subarray(n.strm.next_in-n.w_size,n.strm.next_in),0),n.strstart=n.w_size,n.insert=n.strstart):(n.window_size-n.strstart<=a&&(n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,n.insert>n.strstart&&(n.insert=n.strstart)),n.window.set(n.strm.input.subarray(n.strm.next_in-a,n.strm.next_in),n.strstart),n.strstart+=a,n.insert+=a>n.w_size-n.insert?n.w_size-n.insert:a),n.block_start=n.strstart),n.high_water<n.strstart&&(n.high_water=n.strstart),o?Ql:t!==Jo&&t!==ui&&n.strm.avail_in===0&&n.strstart===n.block_start?ql:(s=n.window_size-n.strstart,n.strm.avail_in>s&&n.block_start>=n.w_size&&(n.block_start-=n.w_size,n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,s+=n.w_size,n.insert>n.strstart&&(n.insert=n.strstart)),s>n.strm.avail_in&&(s=n.strm.avail_in),s&&(bw(n.strm,n.window,n.strstart,s),n.strstart+=s,n.insert+=s>n.w_size-n.insert?n.w_size-n.insert:s),n.high_water<n.strstart&&(n.high_water=n.strstart),s=n.bi_valid+42>>3,s=n.pending_buf_size-s>65535?65535:n.pending_buf_size-s,e=s>n.w_size?n.w_size:s,i=n.strstart-n.block_start,(i>=e||(i||t===ui)&&t!==Jo&&n.strm.avail_in===0&&i<=s)&&(r=i>s?s:i,o=t===ui&&n.strm.avail_in===0&&r===i?1:0,dw(n,n.block_start,r,o),n.block_start+=r,Ur(n.strm)),o?bc:gr)},cm=(n,t)=>{let e,r;for(;;){if(n.lookahead<os){if(xl(n),n.lookahead<os&&t===Jo)return gr;if(n.lookahead===0)break}if(e=0,n.lookahead>=le&&(n.ins_h=Yo(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),e!==0&&n.strstart-e<=n.w_size-os&&(n.match_length=cI(n,e)),n.match_length>=le)if(r=Qo(n,n.strstart-n.match_start,n.match_length-le),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=le){n.match_length--;do n.strstart++,n.ins_h=Yo(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart;while(--n.match_length!==0);n.strstart++}else n.strstart+=n.match_length,n.match_length=0,n.ins_h=n.window[n.strstart],n.ins_h=Yo(n,n.ins_h,n.window[n.strstart+1]);else r=Qo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++;if(r&&(Kr(n,!1),n.strm.avail_out===0))return gr}return n.insert=n.strstart<le-1?n.strstart:le-1,t===ui?(Kr(n,!0),n.strm.avail_out===0?bc:Ql):n.sym_next&&(Kr(n,!1),n.strm.avail_out===0)?gr:ql},Kc=(n,t)=>{let e,r,i;for(;;){if(n.lookahead<os){if(xl(n),n.lookahead<os&&t===Jo)return gr;if(n.lookahead===0)break}if(e=0,n.lookahead>=le&&(n.ins_h=Yo(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),n.prev_length=n.match_length,n.prev_match=n.match_start,n.match_length=le-1,e!==0&&n.prev_length<n.max_lazy_match&&n.strstart-e<=n.w_size-os&&(n.match_length=cI(n,e),n.match_length<=5&&(n.strategy===IH||n.match_length===le&&n.strstart-n.match_start>4096)&&(n.match_length=le-1)),n.prev_length>=le&&n.match_length<=n.prev_length){i=n.strstart+n.lookahead-le,r=Qo(n,n.strstart-1-n.prev_match,n.prev_length-le),n.lookahead-=n.prev_length-1,n.prev_length-=2;do++n.strstart<=i&&(n.ins_h=Yo(n,n.ins_h,n.window[n.strstart+le-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart);while(--n.prev_length!==0);if(n.match_available=0,n.match_length=le-1,n.strstart++,r&&(Kr(n,!1),n.strm.avail_out===0))return gr}else if(n.match_available){if(r=Qo(n,0,n.window[n.strstart-1]),r&&Kr(n,!1),n.strstart++,n.lookahead--,n.strm.avail_out===0)return gr}else n.match_available=1,n.strstart++,n.lookahead--}return n.match_available&&(r=Qo(n,0,n.window[n.strstart-1]),n.match_available=0),n.insert=n.strstart<le-1?n.strstart:le-1,t===ui?(Kr(n,!0),n.strm.avail_out===0?bc:Ql):n.sym_next&&(Kr(n,!1),n.strm.avail_out===0)?gr:ql},VH=(n,t)=>{let e,r,i,s;const o=n.window;for(;;){if(n.lookahead<=Wo){if(xl(n),n.lookahead<=Wo&&t===Jo)return gr;if(n.lookahead===0)break}if(n.match_length=0,n.lookahead>=le&&n.strstart>0&&(i=n.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){s=n.strstart+Wo;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<s);n.match_length=Wo-(s-i),n.match_length>n.lookahead&&(n.match_length=n.lookahead)}if(n.match_length>=le?(e=Qo(n,1,n.match_length-le),n.lookahead-=n.match_length,n.strstart+=n.match_length,n.match_length=0):(e=Qo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++),e&&(Kr(n,!1),n.strm.avail_out===0))return gr}return n.insert=0,t===ui?(Kr(n,!0),n.strm.avail_out===0?bc:Ql):n.sym_next&&(Kr(n,!1),n.strm.avail_out===0)?gr:ql},KH=(n,t)=>{let e;for(;;){if(n.lookahead===0&&(xl(n),n.lookahead===0)){if(t===Jo)return gr;break}if(n.match_length=0,e=Qo(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++,e&&(Kr(n,!1),n.strm.avail_out===0))return gr}return n.insert=0,t===ui?(Kr(n,!0),n.strm.avail_out===0?bc:Ql):n.sym_next&&(Kr(n,!1),n.strm.avail_out===0)?gr:ql};function Li(n,t,e,r,i){this.good_length=n,this.max_lazy=t,this.nice_length=e,this.max_chain=r,this.func=i}const Lf=[new Li(0,0,0,0,uI),new Li(4,4,8,4,cm),new Li(4,5,16,8,cm),new Li(4,6,32,32,cm),new Li(4,4,16,16,Kc),new Li(8,16,32,32,Kc),new Li(8,16,128,128,Kc),new Li(8,32,128,256,Kc),new Li(32,128,258,1024,Kc),new Li(32,258,258,4096,Kc)],jH=n=>{n.window_size=2*n.w_size,vo(n.head),n.max_lazy_match=Lf[n.level].max_lazy,n.good_match=Lf[n.level].good_length,n.nice_match=Lf[n.level].nice_length,n.max_chain_length=Lf[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=le-1,n.match_available=0,n.ins_h=0};function WH(){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=Kp,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(DH*2),this.dyn_dtree=new Uint16Array((2*LH+1)*2),this.bl_tree=new Uint16Array((2*UH+1)*2),vo(this.dyn_ltree),vo(this.dyn_dtree),vo(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(FH+1),this.heap=new Uint16Array(2*pw+1),vo(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*pw+1),vo(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 ld=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.status!==vl&&t.status!==nb&&t.status!==gw&&t.status!==yw&&t.status!==mw&&t.status!==ww&&t.status!==Oa&&t.status!==Mf?1:0},lI=n=>{if(ld(n))return Na(n,ss);n.total_in=n.total_out=0,n.data_type=OH;const t=n.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?nb:t.wrap?vl:Oa,n.adler=t.wrap===2?0:1,t.last_flush=-2,bH(t),Kn},fI=n=>{const t=lI(n);return t===Kn&&jH(n.state),t},ZH=(n,t)=>ld(n)||n.state.wrap!==2?ss:(n.state.gzhead=t,Kn),hI=(n,t,e,r,i,s)=>{if(!n)return ss;let o=1;if(t===RH&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>NH||e!==Kp||r<8||r>15||t<0||t>9||s<0||s>kH||r===8&&o!==1)return Na(n,ss);r===8&&(r=9);const a=new WH;return n.state=a,a.strm=n,a.status=vl,a.wrap=o,a.gzhead=null,a.w_bits=r,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+le-1)/le),a.window=new Uint8Array(a.w_size*2),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=(a.lit_bufsize-1)*3,a.level=t,a.strategy=s,a.method=e,fI(n)},qH=(n,t)=>hI(n,t,Kp,CH,BH,TH),QH=(n,t)=>{if(ld(n)||t>pE||t<0)return n?Na(n,ss):ss;const e=n.state;if(!n.output||n.avail_in!==0&&!n.input||e.status===Mf&&t!==ui)return Na(n,n.avail_out===0?am:ss);const r=e.last_flush;if(e.last_flush=t,e.pending!==0){if(Ur(n),n.avail_out===0)return e.last_flush=-1,Kn}else if(n.avail_in===0&&yE(t)<=yE(r)&&t!==ui)return Na(n,am);if(e.status===Mf&&n.avail_in!==0)return Na(n,am);if(e.status===vl&&e.wrap===0&&(e.status=Oa),e.status===vl){let i=Kp+(e.w_bits-8<<4)<<8,s=-1;if(e.strategy>=Gd||e.level<2?s=0:e.level<6?s=1:e.level===6?s=2:s=3,i|=s<<6,e.strstart!==0&&(i|=$H),i+=31-i%31,Tf(e,i),e.strstart!==0&&(Tf(e,n.adler>>>16),Tf(e,n.adler&65535)),n.adler=1,e.status=Oa,Ur(n),e.pending!==0)return e.last_flush=-1,Kn}if(e.status===nb){if(n.adler=0,Re(e,31),Re(e,139),Re(e,8),e.gzhead)Re(e,(e.gzhead.text?1:0)+(e.gzhead.hcrc?2:0)+(e.gzhead.extra?4:0)+(e.gzhead.name?8:0)+(e.gzhead.comment?16:0)),Re(e,e.gzhead.time&255),Re(e,e.gzhead.time>>8&255),Re(e,e.gzhead.time>>16&255),Re(e,e.gzhead.time>>24&255),Re(e,e.level===9?2:e.strategy>=Gd||e.level<2?4:0),Re(e,e.gzhead.os&255),e.gzhead.extra&&e.gzhead.extra.length&&(Re(e,e.gzhead.extra.length&255),Re(e,e.gzhead.extra.length>>8&255)),e.gzhead.hcrc&&(n.adler=Ln(n.adler,e.pending_buf,e.pending,0)),e.gzindex=0,e.status=gw;else if(Re(e,0),Re(e,0),Re(e,0),Re(e,0),Re(e,0),Re(e,e.level===9?2:e.strategy>=Gd||e.level<2?4:0),Re(e,HH),e.status=Oa,Ur(n),e.pending!==0)return e.last_flush=-1,Kn}if(e.status===gw){if(e.gzhead.extra){let i=e.pending,s=(e.gzhead.extra.length&65535)-e.gzindex;for(;e.pending+s>e.pending_buf_size;){let a=e.pending_buf_size-e.pending;if(e.pending_buf.set(e.gzhead.extra.subarray(e.gzindex,e.gzindex+a),e.pending),e.pending=e.pending_buf_size,e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex+=a,Ur(n),e.pending!==0)return e.last_flush=-1,Kn;i=0,s-=a}let o=new Uint8Array(e.gzhead.extra);e.pending_buf.set(o.subarray(e.gzindex,e.gzindex+s),e.pending),e.pending+=s,e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex=0}e.status=yw}if(e.status===yw){if(e.gzhead.name){let i=e.pending,s;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i)),Ur(n),e.pending!==0)return e.last_flush=-1,Kn;i=0}e.gzindex<e.gzhead.name.length?s=e.gzhead.name.charCodeAt(e.gzindex++)&255:s=0,Re(e,s)}while(s!==0);e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i)),e.gzindex=0}e.status=mw}if(e.status===mw){if(e.gzhead.comment){let i=e.pending,s;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i)),Ur(n),e.pending!==0)return e.last_flush=-1,Kn;i=0}e.gzindex<e.gzhead.comment.length?s=e.gzhead.comment.charCodeAt(e.gzindex++)&255:s=0,Re(e,s)}while(s!==0);e.gzhead.hcrc&&e.pending>i&&(n.adler=Ln(n.adler,e.pending_buf,e.pending-i,i))}e.status=ww}if(e.status===ww){if(e.gzhead.hcrc){if(e.pending+2>e.pending_buf_size&&(Ur(n),e.pending!==0))return e.last_flush=-1,Kn;Re(e,n.adler&255),Re(e,n.adler>>8&255),n.adler=0}if(e.status=Oa,Ur(n),e.pending!==0)return e.last_flush=-1,Kn}if(n.avail_in!==0||e.lookahead!==0||t!==Jo&&e.status!==Mf){let i=e.level===0?uI(e,t):e.strategy===Gd?KH(e,t):e.strategy===SH?VH(e,t):Lf[e.level].func(e,t);if((i===bc||i===Ql)&&(e.status=Mf),i===gr||i===bc)return n.avail_out===0&&(e.last_flush=-1),Kn;if(i===ql&&(t===EH?AH(e):t!==pE&&(dw(e,0,0,!1),t===vH&&(vo(e.head),e.lookahead===0&&(e.strstart=0,e.block_start=0,e.insert=0))),Ur(n),n.avail_out===0))return e.last_flush=-1,Kn}return t!==ui?Kn:e.wrap<=0?gE:(e.wrap===2?(Re(e,n.adler&255),Re(e,n.adler>>8&255),Re(e,n.adler>>16&255),Re(e,n.adler>>24&255),Re(e,n.total_in&255),Re(e,n.total_in>>8&255),Re(e,n.total_in>>16&255),Re(e,n.total_in>>24&255)):(Tf(e,n.adler>>>16),Tf(e,n.adler&65535)),Ur(n),e.wrap>0&&(e.wrap=-e.wrap),e.pending!==0?Kn:gE)},JH=n=>{if(ld(n))return ss;const t=n.state.status;return n.state=null,t===Oa?Na(n,xH):Kn},YH=(n,t)=>{let e=t.length;if(ld(n))return ss;const r=n.state,i=r.wrap;if(i===2||i===1&&r.status!==vl||r.lookahead)return ss;if(i===1&&(n.adler=Ah(n.adler,t,e,0)),r.wrap=0,e>=r.w_size){i===0&&(vo(r.head),r.strstart=0,r.block_start=0,r.insert=0);let u=new Uint8Array(r.w_size);u.set(t.subarray(e-r.w_size,e),0),t=u,e=r.w_size}const s=n.avail_in,o=n.next_in,a=n.input;for(n.avail_in=e,n.next_in=0,n.input=t,xl(r);r.lookahead>=le;){let u=r.strstart,f=r.lookahead-(le-1);do r.ins_h=Yo(r,r.ins_h,r.window[u+le-1]),r.prev[u&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=u,u++;while(--f);r.strstart=u,r.lookahead=le-1,xl(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=le-1,r.match_available=0,n.next_in=o,n.input=a,n.avail_in=s,r.wrap=i,Kn};var XH=qH,tz=hI,ez=fI,nz=lI,rz=ZH,iz=QH,sz=JH,oz=YH,az="pako deflate (from Nodeca project)",jf={deflateInit:XH,deflateInit2:tz,deflateReset:ez,deflateResetKeep:nz,deflateSetHeader:rz,deflate:iz,deflateEnd:sz,deflateSetDictionary:oz,deflateInfo:az};const cz=(n,t)=>Object.prototype.hasOwnProperty.call(n,t);var uz=function(n){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const e=t.shift();if(e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(const r in e)cz(e,r)&&(n[r]=e[r])}}return n},lz=n=>{let t=0;for(let r=0,i=n.length;r<i;r++)t+=n[r].length;const e=new Uint8Array(t);for(let r=0,i=0,s=n.length;r<s;r++){let o=n[r];e.set(o,i),i+=o.length}return e},jp={assign:uz,flattenChunks:lz};let dI=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{dI=!1}const Eh=new Uint8Array(256);for(let n=0;n<256;n++)Eh[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;Eh[254]=Eh[254]=1;var fz=n=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(n);let t,e,r,i,s,o=n.length,a=0;for(i=0;i<o;i++)e=n.charCodeAt(i),(e&64512)===55296&&i+1<o&&(r=n.charCodeAt(i+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),i++)),a+=e<128?1:e<2048?2:e<65536?3:4;for(t=new Uint8Array(a),s=0,i=0;s<a;i++)e=n.charCodeAt(i),(e&64512)===55296&&i+1<o&&(r=n.charCodeAt(i+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),i++)),e<128?t[s++]=e:e<2048?(t[s++]=192|e>>>6,t[s++]=128|e&63):e<65536?(t[s++]=224|e>>>12,t[s++]=128|e>>>6&63,t[s++]=128|e&63):(t[s++]=240|e>>>18,t[s++]=128|e>>>12&63,t[s++]=128|e>>>6&63,t[s++]=128|e&63);return t};const hz=(n,t)=>{if(t<65534&&n.subarray&&dI)return String.fromCharCode.apply(null,n.length===t?n:n.subarray(0,t));let e="";for(let r=0;r<t;r++)e+=String.fromCharCode(n[r]);return e};var dz=(n,t)=>{const e=t||n.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(n.subarray(0,t));let r,i;const s=new Array(e*2);for(i=0,r=0;r<e;){let o=n[r++];if(o<128){s[i++]=o;continue}let a=Eh[o];if(a>4){s[i++]=65533,r+=a-1;continue}for(o&=a===2?31:a===3?15:7;a>1&&r<e;)o=o<<6|n[r++]&63,a--;if(a>1){s[i++]=65533;continue}o<65536?s[i++]=o:(o-=65536,s[i++]=55296|o>>10&1023,s[i++]=56320|o&1023)}return hz(s,i)},pz=(n,t)=>{t=t||n.length,t>n.length&&(t=n.length);let e=t-1;for(;e>=0&&(n[e]&192)===128;)e--;return e<0||e===0?t:e+Eh[n[e]]>t?e:t},vh={string2buf:fz,buf2string:dz,utf8border:pz};function gz(){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}var pI=gz;const gI=Object.prototype.toString,{Z_NO_FLUSH:yz,Z_SYNC_FLUSH:mz,Z_FULL_FLUSH:wz,Z_FINISH:bz,Z_OK:V0,Z_STREAM_END:_z,Z_DEFAULT_COMPRESSION:Az,Z_DEFAULT_STRATEGY:Ez,Z_DEFLATED:vz}=ud;function rb(n){this.options=jp.assign({level:Az,method:vz,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ez},n||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new pI,this.strm.avail_out=0;let e=jf.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==V0)throw new Error(El[e]);if(t.header&&jf.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=vh.string2buf(t.dictionary):gI.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,e=jf.deflateSetDictionary(this.strm,r),e!==V0)throw new Error(El[e]);this._dict_set=!0}}rb.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize;let i,s;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?bz:yz,typeof n=="string"?e.input=vh.string2buf(n):gI.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){if(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),(s===mz||s===wz)&&e.avail_out<=6){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(i=jf.deflate(e,s),i===_z)return e.next_out>0&&this.onData(e.output.subarray(0,e.next_out)),i=jf.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===V0;if(e.avail_out===0){this.onData(e.output);continue}if(s>0&&e.next_out>0){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(e.avail_in===0)break}return!0};rb.prototype.onData=function(n){this.chunks.push(n)};rb.prototype.onEnd=function(n){n===V0&&(this.result=jp.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};const Vd=16209,xz=16191;var Rz=function(t,e){let r,i,s,o,a,u,f,h,y,_,w,R,T,I,B,H,U,G,W,X,j,Y,it,ut;const rt=t.state;r=t.next_in,it=t.input,i=r+(t.avail_in-5),s=t.next_out,ut=t.output,o=s-(e-t.avail_out),a=s+(t.avail_out-257),u=rt.dmax,f=rt.wsize,h=rt.whave,y=rt.wnext,_=rt.window,w=rt.hold,R=rt.bits,T=rt.lencode,I=rt.distcode,B=(1<<rt.lenbits)-1,H=(1<<rt.distbits)-1;t:do{R<15&&(w+=it[r++]<<R,R+=8,w+=it[r++]<<R,R+=8),U=T[w&B];e:for(;;){if(G=U>>>24,w>>>=G,R-=G,G=U>>>16&255,G===0)ut[s++]=U&65535;else if(G&16){W=U&65535,G&=15,G&&(R<G&&(w+=it[r++]<<R,R+=8),W+=w&(1<<G)-1,w>>>=G,R-=G),R<15&&(w+=it[r++]<<R,R+=8,w+=it[r++]<<R,R+=8),U=I[w&H];n:for(;;){if(G=U>>>24,w>>>=G,R-=G,G=U>>>16&255,G&16){if(X=U&65535,G&=15,R<G&&(w+=it[r++]<<R,R+=8,R<G&&(w+=it[r++]<<R,R+=8)),X+=w&(1<<G)-1,X>u){t.msg="invalid distance too far back",rt.mode=Vd;break t}if(w>>>=G,R-=G,G=s-o,X>G){if(G=X-G,G>h&&rt.sane){t.msg="invalid distance too far back",rt.mode=Vd;break t}if(j=0,Y=_,y===0){if(j+=f-G,G<W){W-=G;do ut[s++]=_[j++];while(--G);j=s-X,Y=ut}}else if(y<G){if(j+=f+y-G,G-=y,G<W){W-=G;do ut[s++]=_[j++];while(--G);if(j=0,y<W){G=y,W-=G;do ut[s++]=_[j++];while(--G);j=s-X,Y=ut}}}else if(j+=y-G,G<W){W-=G;do ut[s++]=_[j++];while(--G);j=s-X,Y=ut}for(;W>2;)ut[s++]=Y[j++],ut[s++]=Y[j++],ut[s++]=Y[j++],W-=3;W&&(ut[s++]=Y[j++],W>1&&(ut[s++]=Y[j++]))}else{j=s-X;do ut[s++]=ut[j++],ut[s++]=ut[j++],ut[s++]=ut[j++],W-=3;while(W>2);W&&(ut[s++]=ut[j++],W>1&&(ut[s++]=ut[j++]))}}else if(G&64){t.msg="invalid distance code",rt.mode=Vd;break t}else{U=I[(U&65535)+(w&(1<<G)-1)];continue n}break}}else if(G&64)if(G&32){rt.mode=xz;break t}else{t.msg="invalid literal/length code",rt.mode=Vd;break t}else{U=T[(U&65535)+(w&(1<<G)-1)];continue e}break}}while(r<i&&s<a);W=R>>3,r-=W,R-=W<<3,w&=(1<<R)-1,t.next_in=r,t.next_out=s,t.avail_in=r<i?5+(i-r):5-(r-i),t.avail_out=s<a?257+(a-s):257-(s-a),rt.hold=w,rt.bits=R};const jc=15,mE=852,wE=592,bE=0,um=1,_E=2,Iz=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]),Sz=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]),kz=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]),Tz=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]),Oz=(n,t,e,r,i,s,o,a)=>{const u=a.bits;let f=0,h=0,y=0,_=0,w=0,R=0,T=0,I=0,B=0,H=0,U,G,W,X,j,Y=null,it;const ut=new Uint16Array(jc+1),rt=new Uint16Array(jc+1);let ot=null,C,p,m;for(f=0;f<=jc;f++)ut[f]=0;for(h=0;h<r;h++)ut[t[e+h]]++;for(w=u,_=jc;_>=1&&ut[_]===0;_--);if(w>_&&(w=_),_===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,a.bits=1,0;for(y=1;y<_&&ut[y]===0;y++);for(w<y&&(w=y),I=1,f=1;f<=jc;f++)if(I<<=1,I-=ut[f],I<0)return-1;if(I>0&&(n===bE||_!==1))return-1;for(rt[1]=0,f=1;f<jc;f++)rt[f+1]=rt[f]+ut[f];for(h=0;h<r;h++)t[e+h]!==0&&(o[rt[t[e+h]]++]=h);if(n===bE?(Y=ot=o,it=20):n===um?(Y=Iz,ot=Sz,it=257):(Y=kz,ot=Tz,it=0),H=0,h=0,f=y,j=s,R=w,T=0,W=-1,B=1<<w,X=B-1,n===um&&B>mE||n===_E&&B>wE)return 1;for(;;){C=f-T,o[h]+1<it?(p=0,m=o[h]):o[h]>=it?(p=ot[o[h]-it],m=Y[o[h]-it]):(p=96,m=0),U=1<<f-T,G=1<<R,y=G;do G-=U,i[j+(H>>T)+G]=C<<24|p<<16|m|0;while(G!==0);for(U=1<<f-1;H&U;)U>>=1;if(U!==0?(H&=U-1,H+=U):H=0,h++,--ut[f]===0){if(f===_)break;f=t[e+o[h]]}if(f>w&&(H&X)!==W){for(T===0&&(T=w),j+=y,R=f-T,I=1<<R;R+T<_&&(I-=ut[R+T],!(I<=0));)R++,I<<=1;if(B+=1<<R,n===um&&B>mE||n===_E&&B>wE)return 1;W=H&X,i[W]=w<<24|R<<16|j-s|0}}return H!==0&&(i[j+H]=f-T<<24|64<<16|0),a.bits=w,0};var Wf=Oz;const Nz=0,yI=1,mI=2,{Z_FINISH:AE,Z_BLOCK:Cz,Z_TREES:Kd,Z_OK:_c,Z_STREAM_END:Bz,Z_NEED_DICT:Pz,Z_STREAM_ERROR:fi,Z_DATA_ERROR:wI,Z_MEM_ERROR:bI,Z_BUF_ERROR:Mz,Z_DEFLATED:EE}=ud,Wp=16180,vE=16181,xE=16182,RE=16183,IE=16184,SE=16185,kE=16186,TE=16187,OE=16188,NE=16189,K0=16190,bs=16191,lm=16192,CE=16193,fm=16194,BE=16195,PE=16196,ME=16197,LE=16198,jd=16199,Wd=16200,UE=16201,DE=16202,FE=16203,$E=16204,HE=16205,hm=16206,zE=16207,GE=16208,Ze=16209,_I=16210,AI=16211,Lz=852,Uz=592,Dz=15,Fz=Dz,VE=n=>(n>>>24&255)+(n>>>8&65280)+((n&65280)<<8)+((n&255)<<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 Bc=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.mode<Wp||t.mode>AI?1:0},EI=n=>{if(Bc(n))return fi;const t=n.state;return n.total_in=n.total_out=t.total=0,n.msg="",t.wrap&&(n.adler=t.wrap&1),t.mode=Wp,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Lz),t.distcode=t.distdyn=new Int32Array(Uz),t.sane=1,t.back=-1,_c},vI=n=>{if(Bc(n))return fi;const t=n.state;return t.wsize=0,t.whave=0,t.wnext=0,EI(n)},xI=(n,t)=>{let e;if(Bc(n))return fi;const r=n.state;return t<0?(e=0,t=-t):(e=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?fi:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=e,r.wbits=t,vI(n))},RI=(n,t)=>{if(!n)return fi;const e=new $z;n.state=e,e.strm=n,e.window=null,e.mode=Wp;const r=xI(n,t);return r!==_c&&(n.state=null),r},Hz=n=>RI(n,Fz);let KE=!0,dm,pm;const zz=n=>{if(KE){dm=new Int32Array(512),pm=new Int32Array(32);let t=0;for(;t<144;)n.lens[t++]=8;for(;t<256;)n.lens[t++]=9;for(;t<280;)n.lens[t++]=7;for(;t<288;)n.lens[t++]=8;for(Wf(yI,n.lens,0,288,dm,0,n.work,{bits:9}),t=0;t<32;)n.lens[t++]=5;Wf(mI,n.lens,0,32,pm,0,n.work,{bits:5}),KE=!1}n.lencode=dm,n.lenbits=9,n.distcode=pm,n.distbits=5},II=(n,t,e,r)=>{let i;const s=n.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(e-s.wsize,e),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),s.window.set(t.subarray(e-r,e-r+i),s.wnext),r-=i,r?(s.window.set(t.subarray(e-r,e),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0},Gz=(n,t)=>{let e,r,i,s,o,a,u,f,h,y,_,w,R,T,I=0,B,H,U,G,W,X,j,Y;const it=new Uint8Array(4);let ut,rt;const ot=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Bc(n)||!n.output||!n.input&&n.avail_in!==0)return fi;e=n.state,e.mode===bs&&(e.mode=lm),o=n.next_out,i=n.output,u=n.avail_out,s=n.next_in,r=n.input,a=n.avail_in,f=e.hold,h=e.bits,y=a,_=u,Y=_c;t:for(;;)switch(e.mode){case Wp:if(e.wrap===0){e.mode=lm;break}for(;h<16;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(e.wrap&2&&f===35615){e.wbits===0&&(e.wbits=15),e.check=0,it[0]=f&255,it[1]=f>>>8&255,e.check=Ln(e.check,it,2,0),f=0,h=0,e.mode=vE;break}if(e.head&&(e.head.done=!1),!(e.wrap&1)||(((f&255)<<8)+(f>>8))%31){n.msg="incorrect header check",e.mode=Ze;break}if((f&15)!==EE){n.msg="unknown compression method",e.mode=Ze;break}if(f>>>=4,h-=4,j=(f&15)+8,e.wbits===0&&(e.wbits=j),j>15||j>e.wbits){n.msg="invalid window size",e.mode=Ze;break}e.dmax=1<<e.wbits,e.flags=0,n.adler=e.check=1,e.mode=f&512?NE:bs,f=0,h=0;break;case vE:for(;h<16;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(e.flags=f,(e.flags&255)!==EE){n.msg="unknown compression method",e.mode=Ze;break}if(e.flags&57344){n.msg="unknown header flags set",e.mode=Ze;break}e.head&&(e.head.text=f>>8&1),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Ln(e.check,it,2,0)),f=0,h=0,e.mode=xE;case xE:for(;h<32;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.head&&(e.head.time=f),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,it[2]=f>>>16&255,it[3]=f>>>24&255,e.check=Ln(e.check,it,4,0)),f=0,h=0,e.mode=RE;case RE:for(;h<16;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.head&&(e.head.xflags=f&255,e.head.os=f>>8),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Ln(e.check,it,2,0)),f=0,h=0,e.mode=IE;case IE:if(e.flags&1024){for(;h<16;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.length=f,e.head&&(e.head.extra_len=f),e.flags&512&&e.wrap&4&&(it[0]=f&255,it[1]=f>>>8&255,e.check=Ln(e.check,it,2,0)),f=0,h=0}else e.head&&(e.head.extra=null);e.mode=SE;case SE:if(e.flags&1024&&(w=e.length,w>a&&(w=a),w&&(e.head&&(j=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(r.subarray(s,s+w),j)),e.flags&512&&e.wrap&4&&(e.check=Ln(e.check,r,w,s)),a-=w,s+=w,e.length-=w),e.length))break t;e.length=0,e.mode=kE;case kE:if(e.flags&2048){if(a===0)break t;w=0;do j=r[s+w++],e.head&&j&&e.length<65536&&(e.head.name+=String.fromCharCode(j));while(j&&w<a);if(e.flags&512&&e.wrap&4&&(e.check=Ln(e.check,r,w,s)),a-=w,s+=w,j)break t}else e.head&&(e.head.name=null);e.length=0,e.mode=TE;case TE:if(e.flags&4096){if(a===0)break t;w=0;do j=r[s+w++],e.head&&j&&e.length<65536&&(e.head.comment+=String.fromCharCode(j));while(j&&w<a);if(e.flags&512&&e.wrap&4&&(e.check=Ln(e.check,r,w,s)),a-=w,s+=w,j)break t}else e.head&&(e.head.comment=null);e.mode=OE;case OE:if(e.flags&512){for(;h<16;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(e.wrap&4&&f!==(e.check&65535)){n.msg="header crc mismatch",e.mode=Ze;break}f=0,h=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),n.adler=e.check=0,e.mode=bs;break;case NE:for(;h<32;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}n.adler=e.check=VE(f),f=0,h=0,e.mode=K0;case K0:if(e.havedict===0)return n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=a,e.hold=f,e.bits=h,Pz;n.adler=e.check=1,e.mode=bs;case bs:if(t===Cz||t===Kd)break t;case lm:if(e.last){f>>>=h&7,h-=h&7,e.mode=hm;break}for(;h<3;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}switch(e.last=f&1,f>>>=1,h-=1,f&3){case 0:e.mode=CE;break;case 1:if(zz(e),e.mode=jd,t===Kd){f>>>=2,h-=2;break t}break;case 2:e.mode=PE;break;case 3:n.msg="invalid block type",e.mode=Ze}f>>>=2,h-=2;break;case CE:for(f>>>=h&7,h-=h&7;h<32;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if((f&65535)!==(f>>>16^65535)){n.msg="invalid stored block lengths",e.mode=Ze;break}if(e.length=f&65535,f=0,h=0,e.mode=fm,t===Kd)break t;case fm:e.mode=BE;case BE:if(w=e.length,w){if(w>a&&(w=a),w>u&&(w=u),w===0)break t;i.set(r.subarray(s,s+w),o),a-=w,s+=w,u-=w,o+=w,e.length-=w;break}e.mode=bs;break;case PE:for(;h<14;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(e.nlen=(f&31)+257,f>>>=5,h-=5,e.ndist=(f&31)+1,f>>>=5,h-=5,e.ncode=(f&15)+4,f>>>=4,h-=4,e.nlen>286||e.ndist>30){n.msg="too many length or distance symbols",e.mode=Ze;break}e.have=0,e.mode=ME;case ME:for(;e.have<e.ncode;){for(;h<3;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.lens[ot[e.have++]]=f&7,f>>>=3,h-=3}for(;e.have<19;)e.lens[ot[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,ut={bits:e.lenbits},Y=Wf(Nz,e.lens,0,19,e.lencode,0,e.work,ut),e.lenbits=ut.bits,Y){n.msg="invalid code lengths set",e.mode=Ze;break}e.have=0,e.mode=LE;case LE:for(;e.have<e.nlen+e.ndist;){for(;I=e.lencode[f&(1<<e.lenbits)-1],B=I>>>24,H=I>>>16&255,U=I&65535,!(B<=h);){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(U<16)f>>>=B,h-=B,e.lens[e.have++]=U;else{if(U===16){for(rt=B+2;h<rt;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(f>>>=B,h-=B,e.have===0){n.msg="invalid bit length repeat",e.mode=Ze;break}j=e.lens[e.have-1],w=3+(f&3),f>>>=2,h-=2}else if(U===17){for(rt=B+3;h<rt;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}f>>>=B,h-=B,j=0,w=3+(f&7),f>>>=3,h-=3}else{for(rt=B+7;h<rt;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}f>>>=B,h-=B,j=0,w=11+(f&127),f>>>=7,h-=7}if(e.have+w>e.nlen+e.ndist){n.msg="invalid bit length repeat",e.mode=Ze;break}for(;w--;)e.lens[e.have++]=j}}if(e.mode===Ze)break;if(e.lens[256]===0){n.msg="invalid code -- missing end-of-block",e.mode=Ze;break}if(e.lenbits=9,ut={bits:e.lenbits},Y=Wf(yI,e.lens,0,e.nlen,e.lencode,0,e.work,ut),e.lenbits=ut.bits,Y){n.msg="invalid literal/lengths set",e.mode=Ze;break}if(e.distbits=6,e.distcode=e.distdyn,ut={bits:e.distbits},Y=Wf(mI,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,ut),e.distbits=ut.bits,Y){n.msg="invalid distances set",e.mode=Ze;break}if(e.mode=jd,t===Kd)break t;case jd:e.mode=Wd;case Wd:if(a>=6&&u>=258){n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=a,e.hold=f,e.bits=h,Rz(n,_),o=n.next_out,i=n.output,u=n.avail_out,s=n.next_in,r=n.input,a=n.avail_in,f=e.hold,h=e.bits,e.mode===bs&&(e.back=-1);break}for(e.back=0;I=e.lencode[f&(1<<e.lenbits)-1],B=I>>>24,H=I>>>16&255,U=I&65535,!(B<=h);){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(H&&!(H&240)){for(G=B,W=H,X=U;I=e.lencode[X+((f&(1<<G+W)-1)>>G)],B=I>>>24,H=I>>>16&255,U=I&65535,!(G+B<=h);){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}f>>>=G,h-=G,e.back+=G}if(f>>>=B,h-=B,e.back+=B,e.length=U,H===0){e.mode=HE;break}if(H&32){e.back=-1,e.mode=bs;break}if(H&64){n.msg="invalid literal/length code",e.mode=Ze;break}e.extra=H&15,e.mode=UE;case UE:if(e.extra){for(rt=e.extra;h<rt;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.length+=f&(1<<e.extra)-1,f>>>=e.extra,h-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=DE;case DE:for(;I=e.distcode[f&(1<<e.distbits)-1],B=I>>>24,H=I>>>16&255,U=I&65535,!(B<=h);){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(!(H&240)){for(G=B,W=H,X=U;I=e.distcode[X+((f&(1<<G+W)-1)>>G)],B=I>>>24,H=I>>>16&255,U=I&65535,!(G+B<=h);){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}f>>>=G,h-=G,e.back+=G}if(f>>>=B,h-=B,e.back+=B,H&64){n.msg="invalid distance code",e.mode=Ze;break}e.offset=U,e.extra=H&15,e.mode=FE;case FE:if(e.extra){for(rt=e.extra;h<rt;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}e.offset+=f&(1<<e.extra)-1,f>>>=e.extra,h-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){n.msg="invalid distance too far back",e.mode=Ze;break}e.mode=$E;case $E:if(u===0)break t;if(w=_-u,e.offset>w){if(w=e.offset-w,w>e.whave&&e.sane){n.msg="invalid distance too far back",e.mode=Ze;break}w>e.wnext?(w-=e.wnext,R=e.wsize-w):R=e.wnext-w,w>e.length&&(w=e.length),T=e.window}else T=i,R=o-e.offset,w=e.length;w>u&&(w=u),u-=w,e.length-=w;do i[o++]=T[R++];while(--w);e.length===0&&(e.mode=Wd);break;case HE:if(u===0)break t;i[o++]=e.length,u--,e.mode=Wd;break;case hm:if(e.wrap){for(;h<32;){if(a===0)break t;a--,f|=r[s++]<<h,h+=8}if(_-=u,n.total_out+=_,e.total+=_,e.wrap&4&&_&&(n.adler=e.check=e.flags?Ln(e.check,i,_,o-_):Ah(e.check,i,_,o-_)),_=u,e.wrap&4&&(e.flags?f:VE(f))!==e.check){n.msg="incorrect data check",e.mode=Ze;break}f=0,h=0}e.mode=zE;case zE:if(e.wrap&&e.flags){for(;h<32;){if(a===0)break t;a--,f+=r[s++]<<h,h+=8}if(e.wrap&4&&f!==(e.total&4294967295)){n.msg="incorrect length check",e.mode=Ze;break}f=0,h=0}e.mode=GE;case GE:Y=Bz;break t;case Ze:Y=wI;break t;case _I:return bI;case AI:default:return fi}return n.next_out=o,n.avail_out=u,n.next_in=s,n.avail_in=a,e.hold=f,e.bits=h,(e.wsize||_!==n.avail_out&&e.mode<Ze&&(e.mode<hm||t!==AE))&&II(n,n.output,n.next_out,_-n.avail_out),y-=n.avail_in,_-=n.avail_out,n.total_in+=y,n.total_out+=_,e.total+=_,e.wrap&4&&_&&(n.adler=e.check=e.flags?Ln(e.check,i,_,n.next_out-_):Ah(e.check,i,_,n.next_out-_)),n.data_type=e.bits+(e.last?64:0)+(e.mode===bs?128:0)+(e.mode===jd||e.mode===fm?256:0),(y===0&&_===0||t===AE)&&Y===_c&&(Y=Mz),Y},Vz=n=>{if(Bc(n))return fi;let t=n.state;return t.window&&(t.window=null),n.state=null,_c},Kz=(n,t)=>{if(Bc(n))return fi;const e=n.state;return e.wrap&2?(e.head=t,t.done=!1,_c):fi},jz=(n,t)=>{const e=t.length;let r,i,s;return Bc(n)||(r=n.state,r.wrap!==0&&r.mode!==K0)?fi:r.mode===K0&&(i=1,i=Ah(i,t,e,0),i!==r.check)?wI:(s=II(n,t,e,e),s?(r.mode=_I,bI):(r.havedict=1,_c))};var Wz=vI,Zz=xI,qz=EI,Qz=Hz,Jz=RI,Yz=Gz,Xz=Vz,tG=Kz,eG=jz,nG="pako inflate (from Nodeca project)",ks={inflateReset:Wz,inflateReset2:Zz,inflateResetKeep:qz,inflateInit:Qz,inflateInit2:Jz,inflate:Yz,inflateEnd:Xz,inflateGetHeader:tG,inflateSetDictionary:eG,inflateInfo:nG};function rG(){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}var iG=rG;const SI=Object.prototype.toString,{Z_NO_FLUSH:sG,Z_FINISH:oG,Z_OK:xh,Z_STREAM_END:gm,Z_NEED_DICT:ym,Z_STREAM_ERROR:aG,Z_DATA_ERROR:jE,Z_MEM_ERROR:cG}=ud;function fd(n){this.options=jp.assign({chunkSize:1024*64,windowBits:15,to:""},n||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(n&&n.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new pI,this.strm.avail_out=0;let e=ks.inflateInit2(this.strm,t.windowBits);if(e!==xh)throw new Error(El[e]);if(this.header=new iG,ks.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=vh.string2buf(t.dictionary):SI.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=ks.inflateSetDictionary(this.strm,t.dictionary),e!==xh)))throw new Error(El[e])}fd.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?oG:sG,SI.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),s=ks.inflate(e,o),s===ym&&i&&(s=ks.inflateSetDictionary(e,i),s===xh?s=ks.inflate(e,o):s===jE&&(s=ym));e.avail_in>0&&s===gm&&e.state.wrap>0&&n[e.next_in]!==0;)ks.inflateReset(e),s=ks.inflate(e,o);switch(s){case aG:case jE:case ym:case cG:return this.onEnd(s),this.ended=!0,!1}if(a=e.avail_out,e.next_out&&(e.avail_out===0||s===gm))if(this.options.to==="string"){let u=vh.utf8border(e.output,e.next_out),f=e.next_out-u,h=vh.buf2string(e.output,u);e.next_out=f,e.avail_out=r-f,f&&e.output.set(e.output.subarray(u,u+f),0),this.onData(h)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(s===xh&&a===0)){if(s===gm)return s=ks.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(e.avail_in===0)break}}return!0};fd.prototype.onData=function(n){this.chunks.push(n)};fd.prototype.onEnd=function(n){n===xh&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=jp.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function ib(n,t){const e=new fd(t);if(e.push(n),e.err)throw e.msg||El[e.err];return e.result}function uG(n,t){return t=t||{},t.raw=!0,ib(n,t)}var lG=fd,fG=ib,hG=uG,dG=ib,pG=ud,gG={Inflate:lG,inflate:fG,inflateRaw:hG,ungzip:dG,constants:pG};const{Inflate:UQ,inflate:yG,inflateRaw:DQ,ungzip:FQ}=gG;var mG=yG,kI={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function i(u,f,h){this.fn=u,this.context=f,this.once=h||!1}function s(u,f,h,y,_){if(typeof h!="function")throw new TypeError("The listener must be a function");var w=new i(h,y||u,_),R=e?e+f:f;return u._events[R]?u._events[R].fn?u._events[R]=[u._events[R],w]:u._events[R].push(w):(u._events[R]=w,u._eventsCount++),u}function o(u,f){--u._eventsCount===0?u._events=new r:delete u._events[f]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var f=[],h,y;if(this._eventsCount===0)return f;for(y in h=this._events)t.call(h,y)&&f.push(e?y.slice(1):y);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},a.prototype.listeners=function(f){var h=e?e+f:f,y=this._events[h];if(!y)return[];if(y.fn)return[y.fn];for(var _=0,w=y.length,R=new Array(w);_<w;_++)R[_]=y[_].fn;return R},a.prototype.listenerCount=function(f){var h=e?e+f:f,y=this._events[h];return y?y.fn?1:y.length:0},a.prototype.emit=function(f,h,y,_,w,R){var T=e?e+f:f;if(!this._events[T])return!1;var I=this._events[T],B=arguments.length,H,U;if(I.fn){switch(I.once&&this.removeListener(f,I.fn,void 0,!0),B){case 1:return I.fn.call(I.context),!0;case 2:return I.fn.call(I.context,h),!0;case 3:return I.fn.call(I.context,h,y),!0;case 4:return I.fn.call(I.context,h,y,_),!0;case 5:return I.fn.call(I.context,h,y,_,w),!0;case 6:return I.fn.call(I.context,h,y,_,w,R),!0}for(U=1,H=new Array(B-1);U<B;U++)H[U-1]=arguments[U];I.fn.apply(I.context,H)}else{var G=I.length,W;for(U=0;U<G;U++)switch(I[U].once&&this.removeListener(f,I[U].fn,void 0,!0),B){case 1:I[U].fn.call(I[U].context);break;case 2:I[U].fn.call(I[U].context,h);break;case 3:I[U].fn.call(I[U].context,h,y);break;case 4:I[U].fn.call(I[U].context,h,y,_);break;default:if(!H)for(W=1,H=new Array(B-1);W<B;W++)H[W-1]=arguments[W];I[U].fn.apply(I[U].context,H)}}return!0},a.prototype.on=function(f,h,y){return s(this,f,h,y,!1)},a.prototype.once=function(f,h,y){return s(this,f,h,y,!0)},a.prototype.removeListener=function(f,h,y,_){var w=e?e+f:f;if(!this._events[w])return this;if(!h)return o(this,w),this;var R=this._events[w];if(R.fn)R.fn===h&&(!_||R.once)&&(!y||R.context===y)&&o(this,w);else{for(var T=0,I=[],B=R.length;T<B;T++)(R[T].fn!==h||_&&!R[T].once||y&&R[T].context!==y)&&I.push(R[T]);I.length?this._events[w]=I.length===1?I[0]:I:o(this,w)}return this},a.prototype.removeAllListeners=function(f){var h;return f?(h=e?e+f:f,this._events[h]&&o(this,h)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,n.exports=a})(kI);var wG=kI.exports;const bG=ua(wG);function _G(n,t){return Array.apply(0,new Array(Math.ceil(n.length/t))).map((e,r)=>n.slice(r*t,(r+1)*t))}const ma=n=>"version"in n;function AG(n){return new TextDecoder("utf-8").decode(n)}function WE(n){return kn.encode(n)}function TI(n){return St.from(n,"base64")}function Eo(n){return"accounts"in n}async function EG(n){const t=(await pt.findProgramAddress([],n))[0];return await pt.createWithSeed(t,vG(),n)}function vG(){return"anchor:idl"}const xG=qt.struct([qt.publicKey("authority"),qt.vecU8("data")]);function RG(n){return xG.decode(n)}function IG(n){const t=["name","path","account","relations","generic"],e=s=>s.split(".").map(U$).join("."),r=s=>{for(const o in s){const a=s[o];t.includes(o)?s[o]=Array.isArray(a)?a.map(e):e(a):typeof a=="object"&&r(a)}},i=structuredClone(n);return r(i),i}function su(n,t,e,r){return n!=null&&n.length?n[0].name?e(n):r(n):t()}function SG(n){const t=new Map;return n.errors&&n.errors.forEach(e=>{var r;let i=(r=e.msg)!==null&&r!==void 0?r:e.name;t.set(e.code,i)}),t}function kG(n,...t){if(n.args.length!=t.length)throw new Error("Invalid argument length");const e={};let r=0;return n.args.forEach(i=>{e[i.name]=t[r],r+=1}),e}function OI(n,t={}){n.forEach(e=>{if(Eo(e))OI(e.accounts,t[e.name]);else if(!t[e.name])throw new Error(`Account \`${e.name}\` not provided.`)})}function xi(n){return n instanceof pt?n:new pt(n)}class TG extends TypeError{constructor(t,e){let r;const{message:i,...s}=t,{path:o}=t,a=o.length===0?i:"At path: "+o.join(".")+" -- "+i;super(a),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,s),this.name=this.constructor.name,this.failures=()=>{var u;return(u=r)!=null?u:r=[t,...e()]}}}function OG(n){return yu(n)&&typeof n[Symbol.iterator]=="function"}function yu(n){return typeof n=="object"&&n!=null}function oa(n){return typeof n=="string"?JSON.stringify(n):""+n}function NG(n){const{done:t,value:e}=n.next();return t?void 0:e}function CG(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:i,branch:s}=t,{type:o}=e,{refinement:a,message:u="Expected a value of type `"+o+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+oa(r)+"`"}=n;return{value:r,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...n,message:u}}function*ZE(n,t,e,r){OG(n)||(n=[n]);for(const i of n){const s=CG(i,t,e,r);s&&(yield s)}}function*sb(n,t,e){e===void 0&&(e={});const{path:r=[],branch:i=[n],coerce:s=!1,mask:o=!1}=e,a={path:r,branch:i};if(s&&(n=t.coercer(n,a),o&&t.type!=="type"&&yu(t.schema)&&yu(n)&&!Array.isArray(n)))for(const f in n)t.schema[f]===void 0&&delete n[f];let u=!0;for(const f of t.validator(n,a))u=!1,yield[f,void 0];for(let[f,h,y]of t.entries(n,a)){const _=sb(h,y,{path:f===void 0?r:[...r,f],branch:f===void 0?i:[...i,h],coerce:s,mask:o});for(const w of _)w[0]?(u=!1,yield[w[0],void 0]):s&&(h=w[1],f===void 0?n=h:n instanceof Map?n.set(f,h):n instanceof Set?n.add(h):yu(n)&&(n[f]=h))}if(u)for(const f of t.refiner(n,a))u=!1,yield[f,void 0];u&&(yield[void 0,n])}class la{constructor(t){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:e,schema:r,validator:i,refiner:s,coercer:o=u=>u,entries:a=function*(){}}=t;this.type=e,this.schema=r,this.entries=a,this.coercer=o,i?this.validator=(u,f)=>{const h=i(u,f);return ZE(h,f,this,u)}:this.validator=()=>[],s?this.refiner=(u,f)=>{const h=s(u,f);return ZE(h,f,this,u)}:this.refiner=()=>[]}assert(t){return BG(t,this)}create(t){return ob(t,this)}is(t){return NI(t,this)}mask(t){return PG(t,this)}validate(t,e){return e===void 0&&(e={}),hd(t,this,e)}}function BG(n,t){const e=hd(n,t);if(e[0])throw e[0]}function ob(n,t){const e=hd(n,t,{coerce:!0});if(e[0])throw e[0];return e[1]}function PG(n,t){const e=hd(n,t,{coerce:!0,mask:!0});if(e[0])throw e[0];return e[1]}function NI(n,t){return!hd(n,t)[0]}function hd(n,t,e){e===void 0&&(e={});const r=sb(n,t,e),i=NG(r);return i[0]?[new TG(i[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function dd(n,t){return new la({type:n,schema:null,validator:t})}function MG(){return dd("any",()=>!0)}function mm(n){return new la({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[e,r]of t.entries())yield[e,r,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||"Expected an array value, but received: "+oa(t)}})}function LG(){return dd("boolean",n=>typeof n=="boolean")}function qE(n){const t=oa(n);return new la({type:"literal",schema:n,validator(e){return e===n||"Expected the literal `"+t+"`, but received: "+oa(e)}})}function Zd(n){return new la({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function f0(){return dd("number",n=>typeof n=="number"&&!isNaN(n)||"Expected a number, but received: "+oa(n))}function h0(n){return new la({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function Ca(){return dd("string",n=>typeof n=="string"||"Expected a string, but received: "+oa(n))}function Xo(n){const t=Object.keys(n);return new la({type:"type",schema:n,*entries(e){if(yu(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return yu(e)||"Expected an object, but received: "+oa(e)}})}function CI(n){const t=n.map(e=>e.type).join(" | ");return new la({type:"union",schema:null,coercer(e,r){return(n.find(s=>{const[o]=s.validate(e,{coerce:!0});return!o})||ab()).coercer(e,r)},validator(e,r){const i=[];for(const s of n){const[...o]=sb(e,s,r),[a]=o;if(a[0])for(const[u]of o)u&&i.push(u);else return[]}return["Expected the value to satisfy a union of `"+t+"`, but received: "+oa(e),...i]}})}function ab(){return dd("unknown",()=>!0)}function UG(n,t,e){return new la({...n,coercer:(r,i)=>NI(r,t)?n.coercer(e(r,i),i):n.coercer(r,i)})}const QE=99;async function DG(n,t,e){if(t.length<=QE)return await JE(n,t,e);{const r=_G(t,QE);return(await Promise.all(r.map(s=>JE(n,s,e)))).flat()}}async function JE(n,t,e){const r=e??n.commitment,{value:i,context:s}=await n.getMultipleAccountsInfoAndContext(t,r);return i.map((a,u)=>a===null?null:{publicKey:t[u],account:a,context:s})}async function FG(n,t,e,r,i){var s;e&&e.length>0&&t.sign(...e);const o=t._compile(),a=o.serialize(),f=t._serialize(a).toString("base64"),h={encoding:"base64",commitment:r??n.commitment};if(i){const R=(Array.isArray(i)?i:o.nonProgramIds()).map(T=>T.toBase58());h.accounts={encoding:"base64",addresses:R}}e&&e.length>0&&(h.sigVerify=!0);const y=[f,h],_=await n._rpcRequest("simulateTransaction",y),w=ob(_,GG);if("error"in w){let R;if("data"in w.error&&(R=(s=w.error.data)===null||s===void 0?void 0:s.logs,R&&Array.isArray(R))){const T=`
|
|
24
|
+
`,I=T+R.join(T);console.error(w.error.message,I)}throw new sa("failed to simulate transaction: "+w.error.message,R)}return w.result}function $G(n){return UG(BI(n),HG,t=>"error"in t?t:{...t,result:ob(t.result,n)})}const HG=BI(ab());function BI(n){return CI([Xo({jsonrpc:qE("2.0"),id:Ca(),result:n}),Xo({jsonrpc:qE("2.0"),id:Ca(),error:Xo({code:ab(),message:Ca(),data:h0(MG())})})])}function zG(n){return $G(Xo({context:Xo({slot:f0()}),value:n}))}const GG=zG(Xo({err:Zd(CI([Xo({}),Ca()])),logs:Zd(mm(Ca())),accounts:h0(Zd(mm(Zd(Xo({executable:LG(),owner:Ca(),lamports:f0(),data:mm(Ca()),rentEpoch:h0(f0())}))))),unitsConsumed:h0(f0())}));class Rh{constructor(t,e,r=Rh.defaultOptions()){this.connection=t,this.wallet=e,this.opts=r,this.publicKey=e==null?void 0:e.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(t,e=Rh.defaultOptions()){throw new Error("Provider local is not available on browser.")}static env(){throw new Error("Provider env is not available on browser.")}async sendAndConfirm(t,e,r){var i,s,o,a;if(r===void 0&&(r=this.opts),ma(t))e&&t.sign(e);else if(t.feePayer=(i=t.feePayer)!==null&&i!==void 0?i:this.wallet.publicKey,t.recentBlockhash=(await this.connection.getLatestBlockhash(r.preflightCommitment)).blockhash,e)for(const f of e)t.partialSign(f);t=await this.wallet.signTransaction(t);const u=t.serialize();try{return await YE(this.connection,u,r)}catch(f){if(f instanceof _w){const h=WE(ma(t)?((s=t.signatures)===null||s===void 0?void 0:s[0])||new Uint8Array:(o=t.signature)!==null&&o!==void 0?o:new Uint8Array),y=ma(t)?0:void 0,_=await this.connection.getTransaction(h,{commitment:"confirmed",maxSupportedTransactionVersion:y});if(_){const w=(a=_.meta)===null||a===void 0?void 0:a.logMessages;throw w?new sa(f.message,w):f}else throw f}else throw f}}async sendAll(t,e){var r,i,s;e===void 0&&(e=this.opts);const o=(await this.connection.getLatestBlockhash(e.preflightCommitment)).blockhash;let a=t.map(h=>{var y,_;if(ma(h.tx)){let w=h.tx;return h.signers&&w.sign(h.signers),w}else{let w=h.tx,R=(y=h.signers)!==null&&y!==void 0?y:[];return w.feePayer=(_=w.feePayer)!==null&&_!==void 0?_:this.wallet.publicKey,w.recentBlockhash=o,R.forEach(T=>{w.partialSign(T)}),w}});const u=await this.wallet.signAllTransactions(a),f=[];for(let h=0;h<a.length;h+=1){const y=u[h],_=y.serialize();try{f.push(await YE(this.connection,_,e))}catch(w){if(w instanceof _w){const R=WE(ma(y)?((r=y.signatures)===null||r===void 0?void 0:r[0])||new Uint8Array:(i=y.signature)!==null&&i!==void 0?i:new Uint8Array),T=ma(y)?0:void 0,I=await this.connection.getTransaction(R,{commitment:"confirmed",maxSupportedTransactionVersion:T});if(I){const B=(s=I.meta)===null||s===void 0?void 0:s.logMessages;throw B?new sa(w.message,B):w}else throw w}else throw w}}return f}async simulate(t,e,r,i){let s=(await this.connection.getLatestBlockhash(r??this.connection.commitment)).blockhash,o;if(ma(t)?(e&&e.length>0&&(t.sign(e),t=await this.wallet.signTransaction(t)),o=await this.connection.simulateTransaction(t,{commitment:r})):(t.feePayer=t.feePayer||this.wallet.publicKey,t.recentBlockhash=s,e&&e.length>0&&(t=await this.wallet.signTransaction(t)),o=await FG(this.connection,t,e,r,i)),o.value.err)throw new VG(o.value);return o.value}}class VG extends Error{constructor(t,e){super(e),this.simulationResponse=t}}async function YE(n,t,e){const r=e?{skipPreflight:e.skipPreflight,preflightCommitment:e.preflightCommitment||e.commitment,maxRetries:e.maxRetries,minContextSlot:e.minContextSlot}:{};let i;const s=Date.now();for(;Date.now()-s<6e4;)try{const o=await n.sendRawTransaction(t,r);if(e!=null&&e.blockhash)if(r.maxRetries===0){const a=AbortSignal.timeout(15e3);i=(await n.confirmTransaction({abortSignal:a,signature:o,...e.blockhash},e&&e.commitment)).value}else i=(await n.confirmTransaction({signature:o,...e.blockhash},e&&e.commitment)).value;else i=(await n.confirmTransaction(o,e&&e.commitment)).value;if(i.err)throw new _w(`Raw transaction ${o} failed (${JSON.stringify(i)})`);return o}catch(o){if(o.name==="TimeoutError")continue;throw o}throw Error("Transaction failed to confirm in 60s")}class _w extends Error{constructor(t){super(t)}}function Aw(){return Rh.local()}var KG=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof gl<"u"?gl:typeof self<"u"?self:{},et={};Object.defineProperty(et,"__esModule",{value:!0});var PI=et.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=OS=et.ANCHOR_ERROR__REQUIRE_VIOLATED=TS=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=kS=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=SS=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=IS=et.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=RS=et.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=xS=et.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=vS=et.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=ES=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=AS=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=_S=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=bS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=wS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=mS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=yS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=gS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=pS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=dS=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=hS=et.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=fS=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=lS=et.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=uS=et.ANCHOR_ERROR__CONSTRAINT_SPACE=cS=et.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=aS=et.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=oS=et.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=sS=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=iS=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=rS=et.ANCHOR_ERROR__CONSTRAINT_ZERO=nS=et.ANCHOR_ERROR__CONSTRAINT_ADDRESS=eS=et.ANCHOR_ERROR__CONSTRAINT_CLOSE=tS=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=XI=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=YI=et.ANCHOR_ERROR__CONSTRAINT_STATE=JI=et.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=QI=et.ANCHOR_ERROR__CONSTRAINT_SEEDS=qI=et.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=ZI=et.ANCHOR_ERROR__CONSTRAINT_OWNER=WI=et.ANCHOR_ERROR__CONSTRAINT_RAW=jI=et.ANCHOR_ERROR__CONSTRAINT_SIGNER=KI=et.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=VI=et.ANCHOR_ERROR__CONSTRAINT_MUT=GI=et.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=zI=et.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=HI=et.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=$I=et.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=FI=et.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=DI=et.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=UI=et.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=LI=et.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0,MI=et.ANCHOR_ERROR__DEPRECATED=nk=et.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=ek=et.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=tk=et.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=XS=et.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=YS=et.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=JS=et.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=QS=et.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=qS=et.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=ZS=et.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=WS=et.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=jS=et.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=KS=et.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=VS=et.ANCHOR_ERROR__INVALID_PROGRAM_ID=GS=et.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=zS=et.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=HS=et.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=$S=et.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=FS=et.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=DS=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=US=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=LS=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=MS=et.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=PS=et.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=BS=et.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=CS=et.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=NS=et.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0,LI=et.ANCHOR_ERROR__INSTRUCTION_MISSING=100,UI=et.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101,DI=et.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102,FI=et.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103,$I=et.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3,HI=et.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=1001,zI=et.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002,GI=et.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500,VI=et.ANCHOR_ERROR__CONSTRAINT_MUT=2e3,KI=et.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001,jI=et.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002,WI=et.ANCHOR_ERROR__CONSTRAINT_RAW=2003,ZI=et.ANCHOR_ERROR__CONSTRAINT_OWNER=2004,qI=et.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005,QI=et.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006,JI=et.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007,YI=et.ANCHOR_ERROR__CONSTRAINT_STATE=2008,XI=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009,tS=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010,eS=et.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011,nS=et.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012,rS=et.ANCHOR_ERROR__CONSTRAINT_ZERO=2013,iS=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014,sS=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015,oS=et.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016,aS=et.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017,cS=et.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018,uS=et.ANCHOR_ERROR__CONSTRAINT_SPACE=2019,lS=et.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020,fS=et.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021,hS=et.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022,dS=et.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023,pS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024,gS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025,yS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026,mS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027,wS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028,bS=et.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029,_S=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030,AS=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031,ES=et.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032,vS=et.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033,xS=et.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034,RS=et.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035,IS=et.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036,SS=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037,kS=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038,TS=et.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039,OS=et.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;PI=et.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;var NS=et.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502,CS=et.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503,BS=et.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504,PS=et.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505,MS=et.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506,LS=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3,US=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001,DS=et.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002,FS=et.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003,$S=et.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004,HS=et.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005,zS=et.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006,GS=et.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007,VS=et.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008,KS=et.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009,jS=et.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010,WS=et.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011,ZS=et.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012,qS=et.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013,QS=et.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014,JS=et.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015,YS=et.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016,XS=et.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017,tk=et.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100,ek=et.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101,nk=et.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;MI=et.ANCHOR_ERROR__DEPRECATED=5e3;const jG=new Map;function rk(n){return jG.get(n)!==void 0}class bo extends Error{constructor(t){super(t),this.name="IdlError"}}class pd{constructor(t){this.stack=t}static parse(t){var e;const r=/^Program (\w*) invoke/,i=/^Program \w* success/,s=[];for(let o=0;o<t.length;o++){if(i.exec(t[o])){s.pop();continue}const a=(e=r.exec(t[o]))===null||e===void 0?void 0:e[1];a&&s.push(new pt(a))}return new pd(s)}}class Zf extends Error{constructor(t,e,r,i,s,o){super(r.join(`
|
|
25
|
+
`).replace("Program log: ","")),this.errorLogs=r,this.logs=i,this.error={errorCode:t,errorMessage:e,comparedValues:o,origin:s},this._programErrorStack=pd.parse(i)}static parse(t){if(!t)return null;const e=t.findIndex(_=>_.startsWith("Program log: AnchorError"));if(e===-1)return null;const r=t[e],i=[r];let s;if(e+1<t.length){if(t[e+1]==="Program log: Left:"){const _=/^Program log: (.*)$/,w=_.exec(t[e+2])[1],R=_.exec(t[e+4])[1];s=[new pt(w),new pt(R)],i.push(...t.slice(e+1,e+5))}else if(t[e+1].startsWith("Program log: Left:")){const _=/^Program log: (Left|Right): (.*)$/,w=_.exec(t[e+1])[2],R=_.exec(t[e+2])[2];i.push(...t.slice(e+1,e+3)),s=[w,R]}}const a=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),f=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),y=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r);if(a){const[_,w,R]=a.slice(1,4),T={code:_,number:parseInt(w)};return new Zf(T,R,i,t,void 0,s)}else if(f){const[_,w,R,T,I]=f.slice(1,6),B={code:R,number:parseInt(T)},H={file:_,line:parseInt(w)};return new Zf(B,I,i,t,H,s)}else if(y){const[_,w,R,T]=y.slice(1,5),I=_,B={code:w,number:parseInt(R)};return new Zf(B,T,i,t,I,s)}else return null}get program(){return this._programErrorStack.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){return this._programErrorStack.stack}toString(){return this.message}}class j0 extends Error{constructor(t,e,r){super(),this.code=t,this.msg=e,this.logs=r,r&&(this._programErrorStack=pd.parse(r))}static parse(t,e){const r=t.toString();let i;if(r.includes("custom program error:")){let a=r.split("custom program error: ");if(a.length!==2)return null;i=a[1]}else{const a=r.match(/"Custom":([0-9]+)}/g);if(!a||a.length>1)return null;i=a[0].match(/([0-9]+)/g)[0]}let s;try{s=parseInt(i)}catch{return null}let o=e.get(s);return o!==void 0?new j0(s,o,t.logs):(o=WG.get(s),o!==void 0?new j0(s,o,t.logs):null)}get program(){var t;return(t=this._programErrorStack)===null||t===void 0?void 0:t.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var t;return(t=this._programErrorStack)===null||t===void 0?void 0:t.stack}toString(){return this.msg}}function ik(n,t){rk("debug-logs")&&console.log("Translating error:",n);const e=Zf.parse(n.logs);if(e)return e;const r=j0.parse(n,t);if(r)return r;if(n.logs){const i={get:function(s,o){return o==="programErrorStack"?s.programErrorStack.stack:o==="program"?s.programErrorStack.stack[n.programErrorStack.stack.length-1]:Reflect.get(...arguments)}};return n.programErrorStack=pd.parse(n.logs),new Proxy(n,i)}return n}const _t={InstructionMissing:LI,InstructionFallbackNotFound:UI,InstructionDidNotDeserialize:DI,InstructionDidNotSerialize:FI,IdlInstructionStub:$I,IdlInstructionInvalidProgram:HI,IdlAccountNotEmpty:zI,EventInstructionStub:GI,ConstraintMut:VI,ConstraintHasOne:KI,ConstraintSigner:jI,ConstraintRaw:WI,ConstraintOwner:ZI,ConstraintRentExempt:qI,ConstraintSeeds:QI,ConstraintExecutable:JI,ConstraintState:YI,ConstraintAssociated:XI,ConstraintAssociatedInit:tS,ConstraintClose:eS,ConstraintAddress:nS,ConstraintZero:rS,ConstraintTokenMint:iS,ConstraintTokenOwner:sS,ConstraintMintMintAuthority:oS,ConstraintMintFreezeAuthority:aS,ConstraintMintDecimals:cS,ConstraintSpace:uS,ConstraintAccountIsNone:lS,ConstraintTokenTokenProgram:fS,ConstraintMintTokenProgram:hS,ConstraintAssociatedTokenTokenProgram:dS,ConstraintMintGroupPointerExtension:pS,ConstraintMintGroupPointerExtensionAuthority:gS,ConstraintMintGroupPointerExtensionGroupAddress:yS,ConstraintMintGroupMemberPointerExtension:mS,ConstraintMintGroupMemberPointerExtensionAuthority:wS,ConstraintMintGroupMemberPointerExtensionMemberAddress:bS,ConstraintMintMetadataPointerExtension:_S,ConstraintMintMetadataPointerExtensionAuthority:AS,ConstraintMintMetadataPointerExtensionMetadataAddress:ES,ConstraintMintCloseAuthorityExtension:vS,ConstraintMintCloseAuthorityExtensionAuthority:xS,ConstraintMintPermanentDelegateExtension:RS,ConstraintMintPermanentDelegateExtensionDelegate:IS,ConstraintMintTransferHookExtension:SS,ConstraintMintTransferHookExtensionAuthority:kS,ConstraintMintTransferHookExtensionProgramId:TS,RequireViolated:OS,RequireEqViolated:PI,RequireKeysEqViolated:NS,RequireNeqViolated:CS,RequireKeysNeqViolated:BS,RequireGtViolated:PS,RequireGteViolated:MS,AccountDiscriminatorAlreadySet:LS,AccountDiscriminatorNotFound:US,AccountDiscriminatorMismatch:DS,AccountDidNotDeserialize:FS,AccountDidNotSerialize:$S,AccountNotEnoughKeys:HS,AccountNotMutable:zS,AccountOwnedByWrongProgram:GS,InvalidProgramId:VS,InvalidProgramExecutable:KS,AccountNotSigner:jS,AccountNotSystemOwned:WS,AccountNotInitialized:ZS,AccountNotProgramData:qS,AccountNotAssociatedTokenAccount:QS,AccountSysvarMismatch:JS,AccountReallocExceedsLimit:YS,AccountDuplicateReallocs:XS,DeclaredProgramIdMismatch:tk,TryingToInitPayerAsProgramAccount:ek,InvalidNumericConversion:nk,Deprecated:MI},WG=new Map([[_t.InstructionMissing,"Instruction discriminator not provided"],[_t.InstructionFallbackNotFound,"Fallback functions are not supported"],[_t.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[_t.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[_t.IdlInstructionStub,"The program was compiled without idl instructions"],[_t.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[_t.IdlAccountNotEmpty,"IDL account must be empty in order to resize, try closing first"],[_t.EventInstructionStub,"The program was compiled without `event-cpi` feature"],[_t.ConstraintMut,"A mut constraint was violated"],[_t.ConstraintHasOne,"A has one constraint was violated"],[_t.ConstraintSigner,"A signer constraint was violated"],[_t.ConstraintRaw,"A raw constraint was violated"],[_t.ConstraintOwner,"An owner constraint was violated"],[_t.ConstraintRentExempt,"A rent exemption constraint was violated"],[_t.ConstraintSeeds,"A seeds constraint was violated"],[_t.ConstraintExecutable,"An executable constraint was violated"],[_t.ConstraintState,"Deprecated Error, feel free to replace with something else"],[_t.ConstraintAssociated,"An associated constraint was violated"],[_t.ConstraintAssociatedInit,"An associated init constraint was violated"],[_t.ConstraintClose,"A close constraint was violated"],[_t.ConstraintAddress,"An address constraint was violated"],[_t.ConstraintZero,"Expected zero account discriminant"],[_t.ConstraintTokenMint,"A token mint constraint was violated"],[_t.ConstraintTokenOwner,"A token owner constraint was violated"],[_t.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[_t.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[_t.ConstraintMintDecimals,"A mint decimals constraint was violated"],[_t.ConstraintSpace,"A space constraint was violated"],[_t.ConstraintAccountIsNone,"A required account for the constraint is None"],[_t.ConstraintTokenTokenProgram,"A token account token program constraint was violated"],[_t.ConstraintMintTokenProgram,"A mint token program constraint was violated"],[_t.ConstraintAssociatedTokenTokenProgram,"An associated token account token program constraint was violated"],[_t.ConstraintMintGroupPointerExtension,"A group pointer extension constraint was violated"],[_t.ConstraintMintGroupPointerExtensionAuthority,"A group pointer extension authority constraint was violated"],[_t.ConstraintMintGroupPointerExtensionGroupAddress,"A group pointer extension group address constraint was violated"],[_t.ConstraintMintGroupMemberPointerExtension,"A group member pointer extension constraint was violated"],[_t.ConstraintMintGroupMemberPointerExtensionAuthority,"A group member pointer extension authority constraint was violated"],[_t.ConstraintMintGroupMemberPointerExtensionMemberAddress,"A group member pointer extension group address constraint was violated"],[_t.ConstraintMintMetadataPointerExtension,"A metadata pointer extension constraint was violated"],[_t.ConstraintMintMetadataPointerExtensionAuthority,"A metadata pointer extension authority constraint was violated"],[_t.ConstraintMintMetadataPointerExtensionMetadataAddress,"A metadata pointer extension metadata address constraint was violated"],[_t.ConstraintMintCloseAuthorityExtension,"A close authority constraint was violated"],[_t.ConstraintMintCloseAuthorityExtensionAuthority,"A close authority extension authority constraint was violated"],[_t.ConstraintMintPermanentDelegateExtension,"A permanent delegate extension constraint was violated"],[_t.ConstraintMintPermanentDelegateExtensionDelegate,"A permanent delegate extension delegate constraint was violated"],[_t.ConstraintMintTransferHookExtension,"A transfer hook extension constraint was violated"],[_t.ConstraintMintTransferHookExtensionAuthority,"A transfer hook extension authority constraint was violated"],[_t.ConstraintMintTransferHookExtensionProgramId,"A transfer hook extension transfer hook program id constraint was violated"],[_t.RequireViolated,"A require expression was violated"],[_t.RequireEqViolated,"A require_eq expression was violated"],[_t.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[_t.RequireNeqViolated,"A require_neq expression was violated"],[_t.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[_t.RequireGtViolated,"A require_gt expression was violated"],[_t.RequireGteViolated,"A require_gte expression was violated"],[_t.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[_t.AccountDiscriminatorNotFound,"No discriminator was found on the account"],[_t.AccountDiscriminatorMismatch,"Account discriminator did not match what was expected"],[_t.AccountDidNotDeserialize,"Failed to deserialize the account"],[_t.AccountDidNotSerialize,"Failed to serialize the account"],[_t.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[_t.AccountNotMutable,"The given account is not mutable"],[_t.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[_t.InvalidProgramId,"Program ID was not as expected"],[_t.InvalidProgramExecutable,"Program account is not executable"],[_t.AccountNotSigner,"The given account did not sign"],[_t.AccountNotSystemOwned,"The given account is not owned by the system program"],[_t.AccountNotInitialized,"The program expected this account to be already initialized"],[_t.AccountNotProgramData,"The given account is not a program data account"],[_t.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[_t.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[_t.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[_t.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[_t.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[_t.TryingToInitPayerAsProgramAccount,"You cannot/should not initialize the payer account as a program account"],[_t.InvalidNumericConversion,"The program could not perform the numeric conversion, out of range integral type conversion attempted"],[_t.Deprecated,"The API being used is deprecated and should no longer be used"]]);class fe{static fieldLayout(t,e=[],r){const i=t.name;switch(t.type){case"bool":return qt.bool(i);case"u8":return qt.u8(i);case"i8":return qt.i8(i);case"u16":return qt.u16(i);case"i16":return qt.i16(i);case"u32":return qt.u32(i);case"i32":return qt.i32(i);case"f32":return qt.f32(i);case"u64":return qt.u64(i);case"i64":return qt.i64(i);case"f64":return qt.f64(i);case"u128":return qt.u128(i);case"i128":return qt.i128(i);case"u256":return qt.u256(i);case"i256":return qt.i256(i);case"bytes":return qt.vecU8(i);case"string":return qt.str(i);case"pubkey":return qt.publicKey(i);default:{if("option"in t.type)return qt.option(fe.fieldLayout({type:t.type.option},e,r),i);if("vec"in t.type)return qt.vec(fe.fieldLayout({type:t.type.vec},e,r),i);if("array"in t.type){let[s,o]=t.type.array;return o=fe.resolveArrayLen(o,r),qt.array(fe.fieldLayout({type:s},e,r),o,i)}if("defined"in t.type){if(!e)throw new bo("User defined types not provided");const s=t.type.defined.name,o=e.find(a=>a.name===s);if(!o)throw new bo(`Type not found: ${t.name}`);return fe.typeDefLayout({typeDef:o,types:e,genericArgs:r??t.type.defined.generics,name:i})}if("generic"in t.type){const s=r==null?void 0:r.at(0);if((s==null?void 0:s.kind)!=="type")throw new bo(`Invalid generic field: ${t.name}`);return fe.fieldLayout({...t,type:s.type},e)}throw new bo(`Not yet implemented: ${JSON.stringify(t.type)}`)}}}static typeDefLayout({typeDef:t,types:e,name:r,genericArgs:i}){switch(t.type.kind){case"struct":{const s=su(t.type.fields,()=>[],o=>o.map(a=>{const u=i&&fe.resolveGenericArgs({type:a.type,typeDef:t,genericArgs:i});return fe.fieldLayout(a,e,u)}),o=>o.map((a,u)=>{const f=i&&fe.resolveGenericArgs({type:a,typeDef:t,genericArgs:i});return fe.fieldLayout({name:u.toString(),type:a},e,f)}));return qt.struct(s,r)}case"enum":{const s=t.type.variants.map(o=>{const a=su(o.fields,()=>[],u=>u.map(f=>{const h=i&&fe.resolveGenericArgs({type:f.type,typeDef:t,genericArgs:i});return fe.fieldLayout(f,e,h)}),u=>u.map((f,h)=>{const y=i&&fe.resolveGenericArgs({type:f,typeDef:t,genericArgs:i});return fe.fieldLayout({name:h.toString(),type:f},e,y)}));return qt.struct(a,o.name)});return r!==void 0?qt.rustEnum(s).replicate(r):qt.rustEnum(s,r)}case"type":return fe.fieldLayout({type:t.type.alias,name:r},e)}}static typeSize(t,e,r){var i;switch(t){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"pubkey":return 32;default:if("option"in t)return 1+fe.typeSize(t.option,e,r);if("coption"in t)return 4+fe.typeSize(t.coption,e,r);if("vec"in t)return 1;if("array"in t){let[s,o]=t.array;return o=fe.resolveArrayLen(o,r),fe.typeSize(s,e,r)*o}if("defined"in t){const s=(i=e.types)===null||i===void 0?void 0:i.find(a=>a.name===t.defined.name);if(!s)throw new bo(`Type not found: ${JSON.stringify(t)}`);const o=a=>{const u=r??t.defined.generics,f=u&&fe.resolveGenericArgs({type:a,typeDef:s,genericArgs:u});return fe.typeSize(a,e,f)};switch(s.type.kind){case"struct":return su(s.type.fields,()=>[0],a=>a.map(u=>o(u.type)),a=>a.map(u=>o(u))).reduce((a,u)=>a+u,0);case"enum":{const a=s.type.variants.map(u=>su(u.fields,()=>[0],f=>f.map(h=>o(h.type)),f=>f.map(h=>o(h))).reduce((f,h)=>f+h,0));return Math.max(...a)+1}case"type":return fe.typeSize(s.type.alias,e,r)}}if("generic"in t){const s=r==null?void 0:r.at(0);if((s==null?void 0:s.kind)!=="type")throw new bo(`Invalid generic: ${t.generic}`);return fe.typeSize(s.type,e,r)}throw new Error(`Invalid type ${JSON.stringify(t)}`)}}static resolveArrayLen(t,e){if(typeof t=="number")return t;if(e){const r=e.find(i=>i.kind==="const");(r==null?void 0:r.kind)==="const"&&(t=+r.value)}if(typeof t!="number")throw new bo("Generic array length did not resolve");return t}static resolveGenericArgs({type:t,typeDef:e,genericArgs:r,isDefined:i}){if(typeof t!="object")return null;for(const s in e.generics){const o=e.generics[s];if("generic"in t&&o.name===t.generic)return[r[s]];if("option"in t){const a=fe.resolveGenericArgs({type:t.option,typeDef:e,genericArgs:r,isDefined:i});if(!a||!i)return a;if(a[0].kind==="type")return[{kind:"type",type:{option:a[0].type}}]}if("vec"in t){const a=fe.resolveGenericArgs({type:t.vec,typeDef:e,genericArgs:r,isDefined:i});if(!a||!i)return a;if(a[0].kind==="type")return[{kind:"type",type:{vec:a[0].type}}]}if("array"in t){const[a,u]=t.array,f=typeof u=="object",h=fe.resolveGenericArgs({type:a,typeDef:e,genericArgs:r,isDefined:i});if(h){for(const y in e.generics.slice(+s)){const _=+s+ +y;f&&e.generics[_].name===u.generic&&h.push(r[_])}if(!i)return h;if(h[0].kind==="type"&&h[1].kind==="const")return[{kind:"type",type:{array:[h[0].type,+h[1].value]}}]}if(f&&o.name===u.generic){const y=r[s];return i?[{kind:"type",type:{array:[a,+y.value]}}]:[y]}return null}if("defined"in t)return t.defined.generics?t.defined.generics.flatMap(a=>{switch(a.kind){case"type":return fe.resolveGenericArgs({type:a.type,typeDef:e,genericArgs:r,isDefined:!0});case"const":return[a]}}).filter(a=>a!==null):null}return null}}class ZG{constructor(t){this.idl=t;const e=t.instructions.map(r=>{const i=r.name,s=r.args.map(a=>fe.fieldLayout(a,t.types)),o=qt.struct(s,i);return[i,{discriminator:r.discriminator,layout:o}]});this.ixLayouts=new Map(e)}encode(t,e){const r=St.alloc(1e3),i=this.ixLayouts.get(t);if(!i)throw new Error(`Unknown method: ${t}`);const s=i.layout.encode(e,r),o=r.slice(0,s);return St.concat([St.from(i.discriminator),o])}decode(t,e="hex"){typeof t=="string"&&(t=e==="hex"?St.from(t,"hex"):kn.decode(t));for(const[r,i]of this.ixLayouts){const s=t.subarray(0,i.discriminator.length);if(s.equals(St.from(i.discriminator)))return{name:r,data:i.layout.decode(t.subarray(s.length))}}return null}format(t,e){return Lr.format(t,e,this.idl)}}class Lr{static format(t,e,r){const i=r.instructions.find(u=>t.name===u.name);if(!i)return console.error("Invalid instruction given"),null;const s=i.args.map(u=>({name:u.name,type:Lr.formatIdlType(u.type),data:Lr.formatIdlData(u,t.data[u.name],r.types)})),o=Lr.flattenIdlAccounts(i.accounts),a=e.map((u,f)=>f<o.length?{name:o[f].name,...u}:{name:void 0,...u});return{args:s,accounts:a}}static formatIdlType(t){if(typeof t=="string")return t;if("option"in t)return`Option<${this.formatIdlType(t.option)}>`;if("coption"in t)return`COption<${this.formatIdlType(t.coption)}>`;if("vec"in t)return`Vec<${this.formatIdlType(t.vec)}>`;if("array"in t)return`Array<${t.array[0]}; ${t.array[1]}>`;if("defined"in t){const e=t.defined.name;if(t.defined.generics){const r=t.defined.generics.map(i=>{switch(i.kind){case"type":return Lr.formatIdlType(i.type);case"const":return i.value}}).join(", ");return`${e}<${r}>`}return e}throw new Error(`Unknown IDL type: ${t}`)}static formatIdlData(t,e,r){if(typeof t.type=="string")return e.toString();if("vec"in t.type)return"["+e.map(i=>this.formatIdlData({name:"",type:t.type.vec},i,r)).join(", ")+"]";if("option"in t.type)return e===null?"null":this.formatIdlData({name:"",type:t.type.option},e,r);if("defined"in t.type){if(!r)throw new Error("User defined types not provided");const i=t.type.defined.name,s=r.find(o=>o.name===i);if(!s)throw new Error(`Type not found: ${i}`);return Lr.formatIdlDataDefined(s,e,r)}return"unknown"}static formatIdlDataDefined(t,e,r){switch(t.type.kind){case"struct":return"{ "+su(t.type.fields,()=>"",i=>Object.entries(e).map(([s,o])=>{const a=i.find(u=>u.name===s);if(!a)throw new Error(`Field not found: ${s}`);return s+": "+Lr.formatIdlData(a,o,r)}).join(", "),i=>Object.entries(e).map(([s,o])=>s+": "+Lr.formatIdlData({name:"",type:i[s]},o,r)).join(", "))+" }";case"enum":{const i=Object.keys(e)[0],s=t.type.variants.find(a=>a.name===i);if(!s)throw new Error(`Unable to find variant: ${i}`);const o=e[i];return su(s.fields,()=>i,a=>{const u=Object.keys(o).map(f=>{const h=o[f],y=a.find(_=>_.name===f);if(!y)throw new Error(`Field not found: ${f}`);return f+": "+Lr.formatIdlData(y,h,r)}).join(", ");return`${i} { ${u} }`},a=>{const u=Object.entries(o).map(([f,h])=>f+": "+Lr.formatIdlData({name:"",type:a[f]},h,r)).join(", ");return`${i} { ${u} }`})}case"type":return Lr.formatIdlType(t.type.alias)}}static flattenIdlAccounts(t,e){return t.map(r=>{const i=qG(r.name);if(r.hasOwnProperty("accounts")){const s=e?`${e} > ${i}`:i;return Lr.flattenIdlAccounts(r.accounts,s)}else return{...r,name:e?`${e} > ${i}`:i}}).flat()}}function qG(n){const t=n.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)}class QG{constructor(t){if(this.idl=t,!t.accounts){this.accountLayouts=new Map;return}const e=t.types;if(!e)throw new Error("Accounts require `idl.types`");const r=t.accounts.map(i=>{const s=e.find(o=>o.name===i.name);if(!s)throw new Error(`Account not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:fe.typeDefLayout({typeDef:s,types:e})}]});this.accountLayouts=new Map(r)}async encode(t,e){const r=St.alloc(1e3),i=this.accountLayouts.get(t);if(!i)throw new Error(`Unknown account: ${t}`);const s=i.layout.encode(e,r),o=r.slice(0,s),a=this.accountDiscriminator(t);return St.concat([a,o])}decode(t,e){const r=this.accountDiscriminator(t);if(r.compare(e.slice(0,r.length)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(t,e)}decodeAny(t){for(const[e,r]of this.accountLayouts)if(t.subarray(0,r.discriminator.length).equals(St.from(r.discriminator)))return this.decodeUnchecked(e,t);throw new Error("Account not found")}decodeUnchecked(t,e){const r=this.accountDiscriminator(t),i=e.subarray(r.length),s=this.accountLayouts.get(t);if(!s)throw new Error(`Unknown account: ${t}`);return s.layout.decode(i)}memcmp(t,e){const r=this.accountDiscriminator(t);return{offset:0,bytes:kn.encode(e?St.concat([r,e]):r)}}size(t){return this.accountDiscriminator(t).length+fe.typeSize({defined:{name:t}},this.idl)}accountDiscriminator(t){var e;const r=(e=this.idl.accounts)===null||e===void 0?void 0:e.find(i=>i.name===t);if(!r)throw new Error(`Account not found: ${t}`);return St.from(r.discriminator)}}class JG{constructor(t){if(!t.events){this.layouts=new Map;return}const e=t.types;if(!e)throw new Error("Events require `idl.types`");const r=t.events.map(i=>{const s=e.find(o=>o.name===i.name);if(!s)throw new Error(`Event not found: ${i.name}`);return[i.name,{discriminator:i.discriminator,layout:fe.typeDefLayout({typeDef:s,types:e})}]});this.layouts=new Map(r)}decode(t){let e;try{e=TI(t)}catch{return null}for(const[r,i]of this.layouts){const s=e.subarray(0,i.discriminator.length);if(s.equals(St.from(i.discriminator)))return{name:r,data:i.layout.decode(e.subarray(s.length))}}return null}}class YG{constructor(t){const e=t.types;if(!e){this.typeLayouts=new Map;return}const r=e.filter(i=>!i.generics).map(i=>[i.name,fe.typeDefLayout({typeDef:i,types:e})]);this.typeLayouts=new Map(r)}encode(t,e){const r=St.alloc(1e3),i=this.typeLayouts.get(t);if(!i)throw new Error(`Unknown type: ${t}`);const s=i.encode(e,r);return r.slice(0,s)}decode(t,e){const r=this.typeLayouts.get(t);if(!r)throw new Error(`Unknown type: ${t}`);return r.decode(e)}}class sk{constructor(t){this.instruction=new ZG(t),this.accounts=new QG(t),this.events=new JG(t),this.types=new YG(t)}}class Cr{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}var Zp=Cr;function XG(n,t){return t.property?n+"["+t.property+"]":n}class Ba extends Cr{isCount(){throw new Error("ExternalLayout is abstract")}}class ok extends Ba{constructor(t,e,r){if(!(t instanceof Cr))throw new TypeError("layout must be a Layout");if(e===void 0)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof qp||this.layout instanceof ak}decode(t,e){return e===void 0&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return r===void 0&&(r=0),this.layout.encode(t,e,r+this.offset)}}class qp extends Cr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class ak extends Cr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return r===void 0&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}const Ew=Math.pow(2,32);function ck(n){const t=Math.floor(n/Ew),e=n-t*Ew;return{hi32:t,lo32:e}}function uk(n,t){return n*Ew+t}class tV extends Cr{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readUInt32LE(e+4);return uk(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=ck(t);return e.writeUInt32LE(i.lo32,r),e.writeUInt32LE(i.hi32,r+4),8}}class eV extends Cr{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const r=t.readUInt32LE(e),i=t.readInt32LE(e+4);return uk(i,r)}encode(t,e,r){r===void 0&&(r=0);const i=ck(t);return e.writeUInt32LE(i.lo32,r),e.writeInt32LE(i.hi32,r+4),8}}class nV extends Cr{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((s,o)=>s&&o instanceof Cr,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const s of t)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((s,o)=>s+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;try{r=this.fields.reduce((i,s)=>{const o=s.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e){e===void 0&&(e=0);const r=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(r[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){r===void 0&&(r=0);const i=r;let s=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const f=t[a.property];f!==void 0&&(o=a.encode(f,e,r),0>u&&(u=a.getSpan(e,r)))}s=r,r+=u}return s+o-i}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)r.property!==void 0&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class lk{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class XE extends lk{constructor(t,e){if(!(t instanceof Ba&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class fk extends Cr{constructor(t,e,r){const i=t instanceof qp||t instanceof ak;if(i)t=new XE(new ok(t));else if(t instanceof Ba&&t.isCount())t=new XE(t);else if(!(t instanceof lk))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Cr))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let s=-1;e&&(s=e.span,0<=s&&i&&(s+=t.layout.span)),super(s,r),this.discriminator=t,this.usesPrefixDiscriminator=i,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){e===void 0&&(e=0);let r;const i=this.discriminator,s=i.decode(t,e);let o=this.registry[s];if(o===void 0){let a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),r=this.makeDestinationObject(),r[i.property]=s,r[o.property]=this.defaultLayout.decode(t,e+a)}else r=o.decode(t,e);return r}encode(t,e,r){r===void 0&&(r=0);const i=this.getSourceVariant(t);if(i===void 0){const s=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=s.layout.span),s.encode(t[s.property],e,r),a+o.encode(t[o.property],e,r+a)}return i.encode(t,e,r)}addVariant(t,e,r){const i=new rV(this,t,e,r);return this.registry[t]=i,i}getVariant(t,e){let r=t;return Zt.isBuffer(t)&&(e===void 0&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class rV extends Cr{constructor(t,e,r,i){if(!(t instanceof fk))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&i===void 0&&(i=r,r=null),r){if(!(r instanceof Cr))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let s=t.span;0>t.span&&(s=r?r.span:0,0<=s&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span)),super(s,i),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(e===void 0&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){r===void 0&&(r=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let s=i;if(this.layout&&(this.layout.encode(t[this.property],e,r+i),s+=this.layout.getSpan(e,r+i),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}class iV extends Cr{constructor(t,e){if(!(t instanceof Ba&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Ba||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){e===void 0&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let i=this.length;if(this.length instanceof Ba&&(i=t.length),!(Zt.isBuffer(t)&&i===t.length))throw new TypeError(XG("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,i,"hex"),this.length instanceof Ba&&this.length.encode(i,e,r),i}}var sV=(n,t,e)=>new ok(n,t,e),oV=n=>new qp(1,n),Ws=n=>new qp(4,n),aV=n=>new tV(n),to=n=>new eV(n),Nn=(n,t,e)=>new nV(n,t,e),hk=(n,t,e)=>new fk(n,t,e),gd=(n,t)=>new iV(n,t);class cV extends Zp{constructor(t){super(-1,t),this.property=t,this.layout=Nn([Ws("length"),Ws("lengthPadding"),gd(sV(Ws(),-8),"chars")],this.property)}encode(t,e,r=0){if(t==null)return this.layout.span;const i={chars:Zt.from(t,"utf8")};return this.layout.encode(i,e,r)}decode(t,e=0){return this.layout.decode(t,e).chars.toString()}getSpan(t,e=0){return Ws().span+Ws().span+new Gs(new Uint8Array(t).slice(e,e+4),10,"le").toNumber()}}function Qp(n){return new cV(n)}function hi(n){return gd(32,n)}const Zr=hk(Ws("instruction"));Zr.addVariant(0,Nn([to("lamports"),to("space"),hi("owner")]),"createAccount");Zr.addVariant(1,Nn([hi("owner")]),"assign");Zr.addVariant(2,Nn([to("lamports")]),"transfer");Zr.addVariant(3,Nn([hi("base"),Qp("seed"),to("lamports"),to("space"),hi("owner")]),"createAccountWithSeed");Zr.addVariant(4,Nn([hi("authorized")]),"advanceNonceAccount");Zr.addVariant(5,Nn([to("lamports")]),"withdrawNonceAccount");Zr.addVariant(6,Nn([hi("authorized")]),"initializeNonceAccount");Zr.addVariant(7,Nn([hi("authorized")]),"authorizeNonceAccount");Zr.addVariant(8,Nn([to("space")]),"allocate");Zr.addVariant(9,Nn([hi("base"),Qp("seed"),to("space"),hi("owner")]),"allocateWithSeed");Zr.addVariant(10,Nn([hi("base"),Qp("seed"),hi("owner")]),"assignWithSeed");Zr.addVariant(11,Nn([to("lamports"),Qp("seed"),hi("owner")]),"transferWithSeed");Math.max(...Object.values(Zr.registry).map(n=>n.span));class uV extends Zp{constructor(t,e,r,i){super(t.span,i),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}function tv(n){return new uV(gd(32),t=>new pt(t),t=>t.toBuffer(),n)}Nn([Ws("version"),Ws("state"),tv("authorizedPubkey"),tv("nonce"),Nn([aV("lamportsPerSignature")],"feeCalculator")]);new pt("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new pt("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var ev={exports:{}};(function(n,t){var e=typeof self<"u"?self:KG,r=function(){function s(){this.fetch=!1,this.DOMException=e.DOMException}return s.prototype=e,new s}();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function u(p){return p&&DataView.prototype.isPrototypeOf(p)}if(a.arrayBuffer)var f=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(p){return p&&f.indexOf(Object.prototype.toString.call(p))>-1};function y(p){if(typeof p!="string"&&(p=String(p)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(p))throw new TypeError("Invalid character in header field name");return p.toLowerCase()}function _(p){return typeof p!="string"&&(p=String(p)),p}function w(p){var m={next:function(){var v=p.shift();return{done:v===void 0,value:v}}};return a.iterable&&(m[Symbol.iterator]=function(){return m}),m}function R(p){this.map={},p instanceof R?p.forEach(function(m,v){this.append(v,m)},this):Array.isArray(p)?p.forEach(function(m){this.append(m[0],m[1])},this):p&&Object.getOwnPropertyNames(p).forEach(function(m){this.append(m,p[m])},this)}R.prototype.append=function(p,m){p=y(p),m=_(m);var v=this.map[p];this.map[p]=v?v+", "+m:m},R.prototype.delete=function(p){delete this.map[y(p)]},R.prototype.get=function(p){return p=y(p),this.has(p)?this.map[p]:null},R.prototype.has=function(p){return this.map.hasOwnProperty(y(p))},R.prototype.set=function(p,m){this.map[y(p)]=_(m)},R.prototype.forEach=function(p,m){for(var v in this.map)this.map.hasOwnProperty(v)&&p.call(m,this.map[v],v,this)},R.prototype.keys=function(){var p=[];return this.forEach(function(m,v){p.push(v)}),w(p)},R.prototype.values=function(){var p=[];return this.forEach(function(m){p.push(m)}),w(p)},R.prototype.entries=function(){var p=[];return this.forEach(function(m,v){p.push([v,m])}),w(p)},a.iterable&&(R.prototype[Symbol.iterator]=R.prototype.entries);function T(p){if(p.bodyUsed)return Promise.reject(new TypeError("Already read"));p.bodyUsed=!0}function I(p){return new Promise(function(m,v){p.onload=function(){m(p.result)},p.onerror=function(){v(p.error)}})}function B(p){var m=new FileReader,v=I(m);return m.readAsArrayBuffer(p),v}function H(p){var m=new FileReader,v=I(m);return m.readAsText(p),v}function U(p){for(var m=new Uint8Array(p),v=new Array(m.length),k=0;k<m.length;k++)v[k]=String.fromCharCode(m[k]);return v.join("")}function G(p){if(p.slice)return p.slice(0);var m=new Uint8Array(p.byteLength);return m.set(new Uint8Array(p)),m.buffer}function W(){return this.bodyUsed=!1,this._initBody=function(p){this._bodyInit=p,p?typeof p=="string"?this._bodyText=p:a.blob&&Blob.prototype.isPrototypeOf(p)?this._bodyBlob=p:a.formData&&FormData.prototype.isPrototypeOf(p)?this._bodyFormData=p:a.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)?this._bodyText=p.toString():a.arrayBuffer&&a.blob&&u(p)?(this._bodyArrayBuffer=G(p.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(p)||h(p))?this._bodyArrayBuffer=G(p):this._bodyText=p=Object.prototype.toString.call(p):this._bodyText="",this.headers.get("content-type")||(typeof p=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):a.searchParams&&URLSearchParams.prototype.isPrototypeOf(p)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a.blob&&(this.blob=function(){var p=T(this);if(p)return p;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(){return this._bodyArrayBuffer?T(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var p=T(this);if(p)return p;if(this._bodyBlob)return H(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(U(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(it)}),this.json=function(){return this.text().then(JSON.parse)},this}var X=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function j(p){var m=p.toUpperCase();return X.indexOf(m)>-1?m:p}function Y(p,m){m=m||{};var v=m.body;if(p instanceof Y){if(p.bodyUsed)throw new TypeError("Already read");this.url=p.url,this.credentials=p.credentials,m.headers||(this.headers=new R(p.headers)),this.method=p.method,this.mode=p.mode,this.signal=p.signal,!v&&p._bodyInit!=null&&(v=p._bodyInit,p.bodyUsed=!0)}else this.url=String(p);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new R(m.headers)),this.method=j(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&v)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(v)}Y.prototype.clone=function(){return new Y(this,{body:this._bodyInit})};function it(p){var m=new FormData;return p.trim().split("&").forEach(function(v){if(v){var k=v.split("="),N=k.shift().replace(/\+/g," "),M=k.join("=").replace(/\+/g," ");m.append(decodeURIComponent(N),decodeURIComponent(M))}}),m}function ut(p){var m=new R,v=p.replace(/\r?\n[\t ]+/g," ");return v.split(/\r?\n/).forEach(function(k){var N=k.split(":"),M=N.shift().trim();if(M){var z=N.join(":").trim();m.append(M,z)}}),m}W.call(Y.prototype);function rt(p,m){m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in m?m.statusText:"OK",this.headers=new R(m.headers),this.url=m.url||"",this._initBody(p)}W.call(rt.prototype),rt.prototype.clone=function(){return new rt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new R(this.headers),url:this.url})},rt.error=function(){var p=new rt(null,{status:0,statusText:""});return p.type="error",p};var ot=[301,302,303,307,308];rt.redirect=function(p,m){if(ot.indexOf(m)===-1)throw new RangeError("Invalid status code");return new rt(null,{status:m,headers:{location:p}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,v){this.message=m,this.name=v;var k=Error(m);this.stack=k.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function C(p,m){return new Promise(function(v,k){var N=new Y(p,m);if(N.signal&&N.signal.aborted)return k(new o.DOMException("Aborted","AbortError"));var M=new XMLHttpRequest;function z(){M.abort()}M.onload=function(){var P={status:M.status,statusText:M.statusText,headers:ut(M.getAllResponseHeaders()||"")};P.url="responseURL"in M?M.responseURL:P.headers.get("X-Request-URL");var A="response"in M?M.response:M.responseText;v(new rt(A,P))},M.onerror=function(){k(new TypeError("Network request failed"))},M.ontimeout=function(){k(new TypeError("Network request failed"))},M.onabort=function(){k(new o.DOMException("Aborted","AbortError"))},M.open(N.method,N.url,!0),N.credentials==="include"?M.withCredentials=!0:N.credentials==="omit"&&(M.withCredentials=!1),"responseType"in M&&a.blob&&(M.responseType="blob"),N.headers.forEach(function(P,A){M.setRequestHeader(A,P)}),N.signal&&(N.signal.addEventListener("abort",z),M.onreadystatechange=function(){M.readyState===4&&N.signal.removeEventListener("abort",z)}),M.send(typeof N._bodyInit>"u"?null:N._bodyInit)})}return C.polyfill=!0,s.fetch||(s.fetch=C,s.Headers=R,s.Request=Y,s.Response=rt),o.Headers=R,o.Request=Y,o.Response=rt,o.fetch=C,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var i=r;t=i.fetch,t.default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,n.exports=t})(ev,ev.exports);qt.rustEnum([qt.struct([],"uninitialized"),qt.struct([qt.option(qt.publicKey(),"authorityAddress")],"buffer"),qt.struct([qt.publicKey("programdataAddress")],"program"),qt.struct([qt.u64("slot"),qt.option(qt.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,qt.u32());const vw="Program log: ",dk="Program data: ",lV=vw.length,fV=dk.length;class hV{constructor(t,e,r){this._programId=t,this._provider=e,this._eventParser=new pk(t,r),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(t,e,r){var i;let s=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(t)||this._eventListeners.set(t,[]),this._eventListeners.set(t,((i=this._eventListeners.get(t))!==null&&i!==void 0?i:[]).concat(s)),this._eventCallbacks.set(s,[t,e]),this._onLogsSubscriptionId!==void 0||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,(o,a)=>{if(!o.err)for(const u of this._eventParser.parseLogs(o.logs)){const f=this._eventListeners.get(u.name);f&&f.forEach(h=>{const y=this._eventCallbacks.get(h);if(y){const[,_]=y;_(u.data,a.slot,o.signature)}})}},r)),s}async removeEventListener(t){const e=this._eventCallbacks.get(t);if(!e)throw new Error(`Event listener ${t} doesn't exist!`);const[r]=e;let i=this._eventListeners.get(r);if(!i)throw new Error(`Event listeners don't exist for ${r}!`);if(this._eventCallbacks.delete(t),i=i.filter(s=>s!==t),this._eventListeners.set(r,i),i.length===0&&this._eventListeners.delete(r),this._eventCallbacks.size===0){if(this._eventListeners.size!==0)throw new Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);this._onLogsSubscriptionId!==void 0&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}}class pk{constructor(t,e){this.coder=e,this.programId=t}*parseLogs(t,e=!1){const r=new pV(t),i=new dV;let s=r.next();for(;s!==null;){let[o,a,u]=this.handleLog(i,s,e);o&&(yield o),a&&i.push(a),u&&i.pop(),s=r.next()}}handleLog(t,e,r){return t.stack.length>0&&t.program()===this.programId.toString()?this.handleProgramLog(e,r):[null,...this.handleSystemLog(e)]}handleProgramLog(t,e){if(t.startsWith(vw)||t.startsWith(dk)){const r=t.startsWith(vw)?t.slice(lV):t.slice(fV),i=this.coder.events.decode(r);if(e&&i===null)throw new Error(`Unable to decode event ${r}`);return[i,null,!1]}else return[null,...this.handleSystemLog(t)]}handleSystemLog(t){const e=t.split(":")[0];return e.match(/^Program (.*) success/g)!==null?[null,!0]:e.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:e.includes("invoke")?["cpi",!1]:[null,!1]}}class dV{constructor(){this.stack=[]}program(){if(!this.stack.length)throw new Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(t){this.stack.push(t)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}}class pV{constructor(t){this.logs=t}next(){if(this.logs.length===0)return null;let t=this.logs[0];return this.logs=this.logs.slice(1),t}}function Jp(n,t){var e,r;let i={};const s=n.args?n.args.length:0;if(t.length>s){if(t.length!==s+1)throw new Error(`provided too many arguments ${t} to instruction ${n==null?void 0:n.name} expecting: ${(r=(e=n.args)===null||e===void 0?void 0:e.map(o=>o.name))!==null&&r!==void 0?r:[]}`);i=t.pop()}return[t,i]}class W0{static build(t,e,r){if(t.name==="_inner")throw new bo("the _inner name is reserved");const i=(...s)=>{const[o,a]=Jp(t,[...s]);OI(t.accounts,a.accounts),gV(t,...s);const u=i.accounts(a.accounts);return a.remainingAccounts!==void 0&&u.push(...a.remainingAccounts),rk("debug-logs")&&console.log("Outgoing account metas:",u),new Pe({keys:u,programId:r,data:e(t.name,kG(t,...o))})};return i.accounts=s=>W0.accountsArray(s,t.accounts,r,t.name),i}static accountsArray(t,e,r,i){return t?e.map(s=>{if(Eo(s)){const h=t[s.name];return W0.accountsArray(h,s.accounts,r,i).flat()}let o;try{o=xi(t[s.name])}catch{throw new Error(`Wrong input type for account "${s.name}" in the instruction accounts object${i!==void 0?' for instruction "'+i+'"':""}. Expected PublicKey or string.`)}const a=s.optional&&o.equals(r),u=!!(s.writable&&!a),f=!!(s.signer&&!a);return{pubkey:o,isWritable:u,isSigner:f}}).flat():[]}}function gV(n,...t){}class yV{static build(t,e){return(...i)=>{var s,o,a;const[,u]=Jp(t,[...i]),f=new Oe;if(u.preInstructions&&u.instructions)throw new Error("instructions is deprecated, use preInstructions");return(s=u.preInstructions)===null||s===void 0||s.forEach(h=>f.add(h)),(o=u.instructions)===null||o===void 0||o.forEach(h=>f.add(h)),f.add(e(...i)),(a=u.postInstructions)===null||a===void 0||a.forEach(h=>f.add(h)),f}}}class mV{static build(t,e,r,i){return async(...o)=>{var a;const u=e(...o),[,f]=Jp(t,[...o]);if(i.sendAndConfirm===void 0)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await i.sendAndConfirm(u,(a=f.signers)!==null&&a!==void 0?a:[],f.options)}catch(h){throw ik(h,r)}}}}class wV{static build(t,e,r,i){var s;return((s=t.accounts)!==null&&s!==void 0?s:[]).reduce((o,a)=>(o[a.name]=new bV(t,a,r,i,e),o),{})}}class bV{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}constructor(t,e,r,i,s){this._idlAccount=e,this._programId=r,this._provider=i??Aw(),this._coder=s??new sk(t),this._size=this._coder.accounts.size(e.name)}async fetchNullable(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);return r}async fetchNullableAndContext(t,e){const r=await this.getAccountInfoAndContext(t,e),{value:i,context:s}=r;return{data:i&&i.data.length!==0?this._coder.accounts.decode(this._idlAccount.name,i.data):null,context:s}}async fetch(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);if(r===null)throw new Error(`Account does not exist or has no data ${t.toString()}`);return r}async fetchAndContext(t,e){const{data:r,context:i}=await this.fetchNullableAndContext(t,e);if(r===null)throw new Error(`Account does not exist ${t.toString()}`);return{data:r,context:i}}async fetchMultiple(t,e){return(await this.fetchMultipleAndContext(t,e)).map(i=>i?i.data:null)}async fetchMultipleAndContext(t,e){return(await DG(this._provider.connection,t.map(i=>xi(i)),e)).map(i=>{if(i==null)return null;const{account:s,context:o}=i;return{data:this._coder.accounts.decode(this._idlAccount.name,s.data),context:o}})}async all(t){const e=this.coder.accounts.memcmp(this._idlAccount.name,t instanceof Zt?t:void 0),r=[];return(e==null?void 0:e.offset)!=null&&(e==null?void 0:e.bytes)!=null&&r.push({memcmp:{offset:e.offset,bytes:e.bytes}}),(e==null?void 0:e.dataSize)!=null&&r.push({dataSize:e.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...r,...Array.isArray(t)?t:[]]})).map(({pubkey:s,account:o})=>({publicKey:s,account:this._coder.accounts.decode(this._idlAccount.name,o.data)}))}subscribe(t,e){const r=Of.get(t.toString());if(r)return r.ee;const i=new bG;t=xi(t);const s=this._provider.connection.onAccountChange(t,o=>{const a=this._coder.accounts.decode(this._idlAccount.name,o.data);i.emit("change",a)},e);return Of.set(t.toString(),{ee:i,listener:s}),i}async unsubscribe(t){let e=Of.get(t.toString());if(!e){console.warn("Address is not subscribed");return}Of&&await this._provider.connection.removeAccountChangeListener(e.listener).then(()=>{Of.delete(t.toString())}).catch(console.error)}async createInstruction(t,e){const r=this.size;if(this._provider.publicKey===void 0)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return On.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:t.publicKey,space:e??r,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(e??r),programId:this._programId})}async getAccountInfo(t,e){return await this._provider.connection.getAccountInfo(xi(t),e)}async getAccountInfoAndContext(t,e){return await this._provider.connection.getAccountInfoAndContext(xi(t),e)}}const Of=new Map;class _V{static build(t,e,r,i,s,o,a){return async(...f)=>{var h;const y=e(...f),[,_]=Jp(t,[...f]);let w;if(i.simulate===void 0)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{w=await i.simulate(y,_.signers,(h=_.options)===null||h===void 0?void 0:h.commitment)}catch(I){throw ik(I,r)}if(w===void 0)throw new Error("Unable to simulate transaction");const R=w.logs;if(!R)throw new Error("Simulated logs not found");const T=[];if(a.events){let I=new pk(o,s);for(const B of I.parseLogs(R))T.push(B)}return{events:T,raw:R}}}}function wm(n){return new gk(gd(8),t=>EV.fromBuffer(t),t=>t.toBuffer(),n)}function qd(n){return new gk(gd(32),t=>new pt(t),t=>t.toBuffer(),n)}function bm(n,t){return new AV(n,t)}class gk extends Zp{constructor(t,e,r,i){super(t.span,i),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}class AV extends Zp{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=Ws()}encode(t,e,r=0){return t==null?this.layout.span+this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+4)+4)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(r===0)return null;if(r===1)return this.layout.decode(t,e+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(t,e=0){return this.layout.getSpan(t,e+4)+4}}let EV=class yk extends Gs{toBuffer(){const t=super.toArray().reverse(),e=Zt.from(t);if(e.length===8)return e;if(e.length>=8)throw new Error("u64 too large");const r=Zt.alloc(8);return e.copy(r),r}static fromBuffer(t){if(t.length!==8)throw new Error(`Invalid buffer length: ${t.length}`);return new yk([...t].reverse().map(e=>`00${e.toString(16)}`.slice(-2)).join(""),16)}};const vV=Nn([qd("mint"),qd("owner"),wm("amount"),bm(qd(),"delegate"),(n=>{const t=hk(oV("discriminator"),null,n);return t.addVariant(0,Nn([]),"uninitialized"),t.addVariant(1,Nn([]),"initialized"),t.addVariant(2,Nn([]),"frozen"),t})("state"),bm(wm(),"isNative"),wm("delegatedAmount"),bm(qd(),"closeAuthority")]);function xV(n){return vV.decode(n)}class RV{constructor(t,e,r,i,s,o,a,u){this._args=t,this._accounts=e,this._provider=r,this._programId=i,this._idlIx=s,this._idlTypes=a,this._customResolver=u,this._accountStore=new IV(r,o,i)}args(t){this._args=t}async resolve(){this.resolveEventCpi(this._idlIx.accounts),this.resolveConst(this._idlIx.accounts);let t=0;for(;await this.resolvePdasAndRelations(this._idlIx.accounts)+await this.resolveCustom()>0;)if(t++,t===16){const e=o=>Eo(o)?o.accounts.some(e):!!(o.address||o.pda||o.relations),r=(o,a=[],u=[])=>{for(const f of o)Eo(f)?u.push(...r(f.accounts,[...a,f.name])):u.push([...a,f.name]);return u},i=this._idlIx.accounts.filter(e),s=r(i).filter(o=>!this.get(o)).map(o=>o.reduce((a,u)=>a+"."+u)).map(o=>`\`${o}\``).join(", ");throw new Error(["Reached maximum depth for account resolution.",`Unresolved accounts: ${s}`].join(" "))}}resolveOptionals(t){Object.assign(this._accounts,this.resolveOptionalsHelper(t,this._idlIx.accounts))}get(t){const e=t.reduce((r,i)=>r&&r[i],this._accounts);if(e&&e.toBase58)return e}set(t,e){let r=this._accounts;t.forEach((i,s)=>{var o;s===t.length-1&&(r[i]=e),r[i]=(o=r[i])!==null&&o!==void 0?o:{},r=r[i]})}resolveOptionalsHelper(t,e){const r={};for(const i of e){const s=i.name,o=t[s];o!==void 0&&(mk(o)?Eo(i)?r[s]=this.resolveOptionalsHelper(o,i.accounts):r[s]=wk(o):o!==null?r[s]=xi(o):i.optional&&(r[s]=this._programId))}return r}async resolveCustom(){if(this._customResolver){const{accounts:t,resolved:e}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=t,e}return 0}resolveEventCpi(t,e=[]){for(const r in t){const i=t[r];Eo(i)&&this.resolveEventCpi(i.accounts,[...e,i.name]);const s=+r+1;if(s===t.length)return;const o=t[r].name,a=t[s].name;if(o==="eventAuthority"&&a==="program"){const u=[...e,o],f=[...e,a];this.get(u)||this.set(u,pt.findProgramAddressSync([Zt.from("__event_authority")],this._programId)[0]),this.get(f)||this.set(f,this._programId);return}}}resolveConst(t,e=[]){for(const r of t){const i=r.name;if(Eo(r))this.resolveConst(r.accounts,[...e,i]);else{const s=r;if((s.signer||s.address)&&!this.get([...e,i])){if(s.signer){if(!this._provider.wallet)throw new Error("This function requires the `Provider` interface implementor to have a `wallet` field.");this.set([...e,i],this._provider.wallet.publicKey)}s.address&&this.set([...e,i],xi(s.address))}}}}async resolvePdasAndRelations(t,e=[]){let r=0;for(const i of t){const s=i.name;if(Eo(i))r+=await this.resolvePdasAndRelations(i.accounts,[...e,s]);else{const o=i;if((o.pda||o.relations)&&!this.get([...e,s])){r++;try{if(o.pda){const a=await Promise.all(o.pda.seeds.map(h=>this.toBuffer(h,e)));if(a.some(h=>!h))continue;const u=await this.parseProgramId(o,e),[f]=pt.findProgramAddressSync(a,u);this.set([...e,s],f)}}catch{}try{if(o.relations){const a=this.get([...e,o.relations[0]]);if(a){const u=await this._accountStore.fetchAccount({publicKey:a});this.set([...e,s],u[s])}}}catch{}}}}return r}async parseProgramId(t,e=[]){var r;if(!(!((r=t.pda)===null||r===void 0)&&r.program))return this._programId;const i=await this.toBuffer(t.pda.program,e);if(!i)throw new Error(`Program seed not resolved: ${t.name}`);return new pt(i)}async toBuffer(t,e=[]){switch(t.kind){case"const":return this.toBufferConst(t);case"arg":return await this.toBufferArg(t);case"account":return await this.toBufferAccount(t,e);default:throw new Error(`Unexpected seed: ${t}`)}}toBufferConst(t){return this.toBufferValue("bytes",t.value)}async toBufferArg(t){const[e,...r]=t.path.split("."),i=this._idlIx.args.findIndex(a=>a.name===e);if(i===-1)throw new Error(`Unable to find argument for seed: ${e}`);const s=r.reduce((a,u)=>(a??{})[u],this._args[i]);if(s===void 0)return;const o=this.getType(this._idlIx.args[i].type,r);return this.toBufferValue(o,s)}async toBufferAccount(t,e=[]){const[r,...i]=t.path.split("."),s=this.get([...e,r]);if(!s)return;if(!i.length)return this.toBufferValue("pubkey",s);if(!t.account)throw new Error(`Seed account is required in order to resolve type: ${t.path}`);let a=await this._accountStore.fetchAccount({publicKey:s,name:t.account}),u=i;for(;u.length>0;)a=a[u[0]],u=u.slice(1);if(a===void 0)return;const f=this.getType({defined:{name:t.account}},i);return this.toBufferValue(f,a)}toBufferValue(t,e){switch(t){case"u8":case"i8":return Zt.from([e]);case"u16":case"i16":return new Gs(e).toArrayLike(Zt,"le",2);case"u32":case"i32":return new Gs(e).toArrayLike(Zt,"le",4);case"u64":case"i64":return new Gs(e).toArrayLike(Zt,"le",8);case"u128":case"i128":return new Gs(e).toArrayLike(Zt,"le",16);case"u256":case"i256":return new Gs(e).toArrayLike(Zt,"le",32);case"string":return Zt.from(e);case"pubkey":return e.toBuffer();case"bytes":return Zt.from(e);default:if(t!=null&&t.array)return Zt.from(e);throw new Error(`Unexpected seed type: ${t}`)}}getType(t,e=[]){var r;const i=(r=t==null?void 0:t.defined)===null||r===void 0?void 0:r.name;if(i){if(i==="tokenAccount")switch(e.at(0)){case"mint":case"owner":return"pubkey";case"amount":case"delagatedAmount":return"u64";default:throw new Error(`Unknown token account path: ${e}`)}const s=this._idlTypes.find(h=>h.name===i);if(!s)throw new Error(`Type not found: ${i}`);const[o,...a]=e,f=s.type.fields.find(h=>h.name===o);if(!f)throw new Error(`Field not found: ${o}`);return this.getType(f.type,a)}return t}}class IV{constructor(t,e,r){this._provider=t,this._cache=new Map,this._idls={},this._idls[r.toBase58()]=e}async fetchAccount({publicKey:t,name:e}){const r=t.toBase58();if(!this._cache.has(r)){const i=await this._provider.connection.getAccountInfo(t);if(i===null)throw new Error(`Account not found: ${r}`);if(e==="tokenAccount"){const s=xV(i.data);this._cache.set(r,s)}else{const s=await this.getAccountsNs(i.owner);if(s){const o=Object.values(s)[0];if(o){const a=o.coder.accounts.decodeAny(i.data);this._cache.set(r,a)}}}}return this._cache.get(r)}async getAccountsNs(t){const e=t.toBase58();if(!this._idls[e]){const r=await Rl.fetchIdl(t,this._provider);if(r){const i=new Rl(r,this._provider);this._idls[e]=i.account}}return this._idls[e]}}class SV{static build(t,e,r,i,s,o,a,u,f,h,y){return(..._)=>new kV(_,i,s,o,a,u,t,e,r,f,h,y)}}function mk(n){return typeof n=="object"&&n!==null&&!("_bn"in n)}function wk(n,t){const e={};for(const r in n){const i=n[r];if(i===null)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!");e[r]=mk(i)?wk(i):xi(i)}return e}class kV{constructor(t,e,r,i,s,o,a,u,f,h,y,_){this._args=t,this._ixFn=e,this._txFn=r,this._rpcFn=i,this._simulateFn=s,this._viewFn=o,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._resolveAccounts=!0,this._accountsResolver=new RV(t,this._accounts,a,u,f,h,y,_)}args(t){this._args=t,this._accountsResolver.args(t)}accounts(t){return this.accountsPartial(t)}accountsPartial(t){return this._resolveAccounts=!0,this._accountsResolver.resolveOptionals(t),this}accountsStrict(t){return this._resolveAccounts=!1,this._accountsResolver.resolveOptionals(t),this}signers(t){return this._signers=this._signers.concat(t),this}remainingAccounts(t){return this._remainingAccounts=this._remainingAccounts.concat(t),this}preInstructions(t,e=!1){return e?this._preInstructions=t.concat(this._preInstructions):this._preInstructions=this._preInstructions.concat(t),this}postInstructions(t){return this._postInstructions=this._postInstructions.concat(t),this}async pubkeys(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._accounts}async instruction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async transaction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async simulate(t){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async view(t){if(this._resolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw new Error(["Method does not support views.","The instruction should return a value, and its accounts must be read-only"].join(" "));return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpc(t){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpcAndKeys(t){return{signature:await this.rpc(t),pubkeys:await this.pubkeys()}}async prepare(){return{instruction:await this.instruction(),signers:this._signers,pubkeys:await this.pubkeys()}}}class TV{static build(t,e,r,i){const s=e.accounts.find(u=>u.writable),o=!!e.returns;return s||!o?void 0:async(...u)=>{let f=await r(...u);const h=`Program return: ${t} `;let y=f.raw.find(T=>T.startsWith(h));if(!y)throw new Error("View expected return log");let _=TI(y.slice(h.length)),w=e.returns;if(!w)throw new Error("View expected return type");return fe.fieldLayout({type:w},i.types).decode(_)}}}class OV{static build(t,e,r,i,s){const o={},a={},u={},f={},h={},y={},_=SG(t),w=t.accounts?wV.build(t,e,r,i):{};return t.instructions.forEach(R=>{const T=W0.build(R,(X,j)=>e.instruction.encode(X,j),r),I=yV.build(R,T),B=mV.build(R,I,_,i),H=_V.build(R,I,_,i,e,r,t),U=TV.build(r,R,H,t),G=SV.build(i,r,R,T,I,B,H,U,w,t.types||[],s==null?void 0:s(R)),W=R.name;a[W]=T,u[W]=I,o[W]=B,f[W]=H,h[W]=G,U&&(y[W]=U)}),[o,a,u,w,f,h,y]}}class Rl{get programId(){return this._programId}get idl(){return this._idl}get rawIdl(){return this._rawIdl}get coder(){return this._coder}get provider(){return this._provider}constructor(t,e=Aw(),r,i){this._idl=IG(t),this._rawIdl=t,this._provider=e,this._programId=xi(t.address),this._coder=r??new sk(this._idl),this._events=new hV(this._programId,e,this._coder);const[s,o,a,u,f,h,y]=OV.build(this._idl,this._coder,this._programId,e,i);this.rpc=s,this.instruction=o,this.transaction=a,this.account=u,this.simulate=f,this.methods=h,this.views=y}static async at(t,e){const r=xi(t),i=await Rl.fetchIdl(r,e);if(!i)throw new Error(`IDL not found for program: ${t.toString()}`);return new Rl(i,e)}static async fetchIdl(t,e){e=e??Aw();const r=xi(t),i=await EG(r),s=await e.connection.getAccountInfo(i);if(!s)return null;let o=RG(s.data.slice(8));const a=mG(o.data);return JSON.parse(AG(a))}addEventListener(t,e,r){return this._events.addEventListener(t,e,r)}async removeEventListener(t){return await this._events.removeEventListener(t)}}new pt("11111111111111111111111111111111");const NV="6.13.5";function CV(n,t,e){const r=t.split("|").map(s=>s.trim());for(let s=0;s<r.length;s++)switch(t){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===t)return}const i=new Error(`invalid value for type ${t}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${e}`,i.value=n,i}async function hr(n){const t=Object.keys(n);return(await Promise.all(t.map(r=>Promise.resolve(n[r])))).reduce((r,i,s)=>(r[t[s]]=i,r),{})}function $t(n,t,e){for(let r in t){let i=t[r];const s=e?e[r]:null;s&&CV(i,s,r),Object.defineProperty(n,r,{enumerable:!0,value:i,writable:!1})}}function ou(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(ou).join(", ")+" ]";if(n instanceof Uint8Array){const t="0123456789abcdef";let e="0x";for(let r=0;r<n.length;r++)e+=t[n[r]>>4],e+=t[n[r]&15];return e}if(typeof n=="object"&&typeof n.toJSON=="function")return ou(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const t=Object.keys(n);return t.sort(),"{ "+t.map(e=>`${ou(e)}: ${ou(n[e])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Zn(n,t){return n&&n.code===t}function cb(n){return Zn(n,"CALL_EXCEPTION")}function qe(n,t,e){let r=n;{const s=[];if(e){if("message"in e||"code"in e||"name"in e)throw new Error(`value will overwrite populated values: ${ou(e)}`);for(const o in e){if(o==="shortMessage")continue;const a=e[o];s.push(o+"="+ou(a))}}s.push(`code=${t}`),s.push(`version=${NV}`),s.length&&(n+=" ("+s.join(", ")+")")}let i;switch(t){case"INVALID_ARGUMENT":i=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(n);break;default:i=new Error(n)}return $t(i,{code:t}),e&&Object.assign(i,e),i.shortMessage==null&&$t(i,{shortMessage:r}),i}function ht(n,t,e,r){if(!n)throw qe(t,e,r)}function K(n,t,e,r){ht(n,t,"INVALID_ARGUMENT",{argument:e,value:r})}function bk(n,t,e){e==null&&(e=""),e&&(e=": "+e),ht(n>=t,"missing argument"+e,"MISSING_ARGUMENT",{count:n,expectedCount:t}),ht(n<=t,"too many arguments"+e,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:t})}["NFD","NFC","NFKD","NFKC"].reduce((n,t)=>{try{if("test".normalize(t)!=="test")throw new Error("bad");if(t==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");n.push(t)}catch{}return n},[]);function Yp(n,t,e){if(e==null&&(e=""),n!==t){let r=e,i="new";e&&(r+=".",i+=" "+e),ht(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function _k(n,t,e){if(n instanceof Uint8Array)return e?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let i=2;for(let s=0;s<r.length;s++)r[s]=parseInt(n.substring(i,i+2),16),i+=2;return r}K(!1,"invalid BytesLike value",t||"value",n)}function ye(n,t){return _k(n,t,!1)}function dr(n,t){return _k(n,t,!0)}function ze(n,t){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof t=="number"&&n.length!==2+2*t||t===!0&&n.length%2!==0)}function ub(n){return ze(n,!0)||n instanceof Uint8Array}const nv="0123456789abcdef";function kt(n){const t=ye(n);let e="0x";for(let r=0;r<t.length;r++){const i=t[r];e+=nv[(i&240)>>4]+nv[i&15]}return e}function In(n){return"0x"+n.map(t=>kt(t).substring(2)).join("")}function mu(n){return ze(n,!0)?(n.length-2)/2:ye(n).length}function _n(n,t,e){const r=ye(n);return e!=null&&e>r.length&&ht(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:e}),kt(r.slice(t??0,e??r.length))}function Ak(n,t,e){const r=ye(n);ht(t>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:t,offset:t+1});const i=new Uint8Array(t);return i.fill(0),e?i.set(r,t-r.length):i.set(r,0),kt(i)}function Ac(n,t){return Ak(n,t,!0)}function BV(n,t){return Ak(n,t,!1)}const Xp=BigInt(0),Ei=BigInt(1),au=9007199254740991;function PV(n,t){const e=tg(n,"value"),r=BigInt(oe(t,"width"));if(ht(e>>r===Xp,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),e>>r-Ei){const i=(Ei<<r)-Ei;return-((~e&i)+Ei)}return e}function Ek(n,t){let e=Nt(n,"value");const r=BigInt(oe(t,"width")),i=Ei<<r-Ei;if(e<Xp){e=-e,ht(e<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const s=(Ei<<r)-Ei;return(~e&s)+Ei}else ht(e<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return e}function Uf(n,t){const e=tg(n,"value"),r=BigInt(oe(t,"bits"));return e&(Ei<<r)-Ei}function Nt(n,t){switch(typeof n){case"bigint":return n;case"number":return K(Number.isInteger(n),"underflow",t||"value",n),K(n>=-au&&n<=au,"overflow",t||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(e){K(!1,`invalid BigNumberish string: ${e.message}`,t||"value",n)}}K(!1,"invalid BigNumberish value",t||"value",n)}function tg(n,t){const e=Nt(n,t);return ht(e>=Xp,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),e}const rv="0123456789abcdef";function lb(n){if(n instanceof Uint8Array){let t="0x0";for(const e of n)t+=rv[e>>4],t+=rv[e&15];return BigInt(t)}return Nt(n)}function oe(n,t){switch(typeof n){case"bigint":return K(n>=-au&&n<=au,"overflow",t||"value",n),Number(n);case"number":return K(Number.isInteger(n),"underflow",t||"value",n),K(n>=-au&&n<=au,"overflow",t||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return oe(BigInt(n),t)}catch(e){K(!1,`invalid numeric string: ${e.message}`,t||"value",n)}}K(!1,"invalid numeric value",t||"value",n)}function MV(n){return oe(lb(n))}function aa(n,t){let r=tg(n,"value").toString(16);if(t==null)r.length%2&&(r="0"+r);else{const i=oe(t,"width");for(ht(i*2>=r.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<i*2;)r="0"+r}return"0x"+r}function yr(n){const t=tg(n,"value");if(t===Xp)return new Uint8Array([]);let e=t.toString(16);e.length%2&&(e="0"+e);const r=new Uint8Array(e.length/2);for(let i=0;i<r.length;i++){const s=i*2;r[i]=parseInt(e.substring(s,s+2),16)}return r}function cu(n){let t=kt(ub(n)?n:yr(n)).substring(2);for(;t.startsWith("0");)t=t.substring(1);return t===""&&(t="0"),"0x"+t}const iv="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const sv=BigInt(58);function LV(n){const t=ye(n);let e=lb(t),r="";for(;e;)r=iv[Number(e%sv)]+r,e/=sv;for(let i=0;i<t.length&&!t[i];i++)r=iv[0]+r;return r}function UV(n){n=atob(n);const t=new Uint8Array(n.length);for(let e=0;e<n.length;e++)t[e]=n.charCodeAt(e);return ye(t)}function DV(n){const t=ye(n);let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}var Iu;class vk{constructor(t,e,r){Z(this,"filter");Z(this,"emitter");J(this,Iu);F(this,Iu,e),$t(this,{emitter:t,filter:r})}async removeListener(){S(this,Iu)!=null&&await this.emitter.off(this.filter,S(this,Iu))}}Iu=new WeakMap;function FV(n,t,e,r,i){K(!1,`invalid codepoint at offset ${t}; ${n}`,"bytes",e)}function xk(n,t,e,r,i){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let s=0;for(let o=t+1;o<e.length&&e[o]>>6===2;o++)s++;return s}return n==="OVERRUN"?e.length-t-1:0}function $V(n,t,e,r,i){return n==="OVERLONG"?(K(typeof i=="number","invalid bad code point for replacement","badCodepoint",i),r.push(i),0):(r.push(65533),xk(n,t,e))}const HV=Object.freeze({error:FV,ignore:xk,replace:$V});function zV(n,t){t==null&&(t=HV.error);const e=ye(n,"bytes"),r=[];let i=0;for(;i<e.length;){const s=e[i++];if(!(s>>7)){r.push(s);continue}let o=null,a=null;if((s&224)===192)o=1,a=127;else if((s&240)===224)o=2,a=2047;else if((s&248)===240)o=3,a=65535;else{(s&192)===128?i+=t("UNEXPECTED_CONTINUE",i-1,e,r):i+=t("BAD_PREFIX",i-1,e,r);continue}if(i-1+o>=e.length){i+=t("OVERRUN",i-1,e,r);continue}let u=s&(1<<8-o-1)-1;for(let f=0;f<o;f++){let h=e[i];if((h&192)!=128){i+=t("MISSING_CONTINUE",i,e,r),u=null;break}u=u<<6|h&63,i++}if(u!==null){if(u>1114111){i+=t("OUT_OF_RANGE",i-1-o,e,r,u);continue}if(u>=55296&&u<=57343){i+=t("UTF16_SURROGATE",i-1-o,e,r,u);continue}if(u<=a){i+=t("OVERLONG",i-1-o,e,r,u);continue}r.push(u)}}return r}function Js(n,t){K(typeof n=="string","invalid string value","str",n);let e=[];for(let r=0;r<n.length;r++){const i=n.charCodeAt(r);if(i<128)e.push(i);else if(i<2048)e.push(i>>6|192),e.push(i&63|128);else if((i&64512)==55296){r++;const s=n.charCodeAt(r);K(r<n.length&&(s&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((i&1023)<<10)+(s&1023);e.push(o>>18|240),e.push(o>>12&63|128),e.push(o>>6&63|128),e.push(o&63|128)}else e.push(i>>12|224),e.push(i>>6&63|128),e.push(i&63|128)}return new Uint8Array(e)}function GV(n){return n.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function Z0(n,t){return GV(zV(n,t))}function Rk(n){async function t(e,r){ht(r==null||!r.cancelled,"request cancelled before sending","CANCELLED");const i=e.url.split(":")[0].toLowerCase();ht(i==="http"||i==="https",`unsupported protocol ${i}`,"UNSUPPORTED_OPERATION",{info:{protocol:i},operation:"request"}),ht(i==="https"||!e.credentials||e.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let s=null;const o=new AbortController,a=setTimeout(()=>{s=qe("request timeout","TIMEOUT"),o.abort()},e.timeout);r&&r.addListener(()=>{s=qe("request cancelled","CANCELLED"),o.abort()});const u={method:e.method,headers:new Headers(Array.from(e)),body:e.body||void 0,signal:o.signal};let f;try{f=await fetch(e.url,u)}catch(w){throw clearTimeout(a),s||w}clearTimeout(a);const h={};f.headers.forEach((w,R)=>{h[R.toLowerCase()]=w});const y=await f.arrayBuffer(),_=y==null?null:new Uint8Array(y);return{statusCode:f.status,statusMessage:f.statusText,headers:h,body:_}}return t}const VV=12,KV=250;let ov=Rk();const jV=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),WV=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let _m=!1;async function Ik(n,t){try{const e=n.match(jV);if(!e)throw new Error("invalid data");return new ta(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?UV(e[3]):qV(e[3]))}catch{return new ta(599,"BAD REQUEST (invalid data: URI)",{},null,new eo(n))}}function Sk(n){async function t(e,r){try{const i=e.match(WV);if(!i)throw new Error("invalid link");return new eo(`${n}${i[2]}`)}catch{return new ta(599,"BAD REQUEST (invalid IPFS URI)",{},null,new eo(e))}}return t}const Qd={data:Ik,ipfs:Sk("https://gateway.ipfs.io/ipfs/")},kk=new WeakMap;var Ua,Ro;class ZV{constructor(t){J(this,Ua);J(this,Ro);F(this,Ua,[]),F(this,Ro,!1),kk.set(t,()=>{if(!S(this,Ro)){F(this,Ro,!0);for(const e of S(this,Ua))setTimeout(()=>{e()},0);F(this,Ua,[])}})}addListener(t){ht(!S(this,Ro),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),S(this,Ua).push(t)}get cancelled(){return S(this,Ro)}checkSignal(){ht(!this.cancelled,"cancelled","CANCELLED",{})}}Ua=new WeakMap,Ro=new WeakMap;function Jd(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}var Su,ku,mi,Ns,Tu,Ou,Pn,Fr,Cs,Da,Fa,$a,Di,wi,Io,Ha,Df;const cp=class cp{constructor(t){J(this,Ha);J(this,Su);J(this,ku);J(this,mi);J(this,Ns);J(this,Tu);J(this,Ou);J(this,Pn);J(this,Fr);J(this,Cs);J(this,Da);J(this,Fa);J(this,$a);J(this,Di);J(this,wi);J(this,Io);F(this,Ou,String(t)),F(this,Su,!1),F(this,ku,!0),F(this,mi,{}),F(this,Ns,""),F(this,Tu,3e5),F(this,wi,{slotInterval:KV,maxAttempts:VV}),F(this,Io,null)}get url(){return S(this,Ou)}set url(t){F(this,Ou,String(t))}get body(){return S(this,Pn)==null?null:new Uint8Array(S(this,Pn))}set body(t){if(t==null)F(this,Pn,void 0),F(this,Fr,void 0);else if(typeof t=="string")F(this,Pn,Js(t)),F(this,Fr,"text/plain");else if(t instanceof Uint8Array)F(this,Pn,t),F(this,Fr,"application/octet-stream");else if(typeof t=="object")F(this,Pn,Js(JSON.stringify(t))),F(this,Fr,"application/json");else throw new Error("invalid body")}hasBody(){return S(this,Pn)!=null}get method(){return S(this,Ns)?S(this,Ns):this.hasBody()?"POST":"GET"}set method(t){t==null&&(t=""),F(this,Ns,String(t).toUpperCase())}get headers(){const t=Object.assign({},S(this,mi));return S(this,Cs)&&(t.authorization=`Basic ${DV(Js(S(this,Cs)))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),t["content-type"]==null&&S(this,Fr)&&(t["content-type"]=S(this,Fr)),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){S(this,mi)[String(t).toLowerCase()]=String(e)}clearHeaders(){F(this,mi,{})}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const i=e[r++];return{value:[i,t[i]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return S(this,Cs)||null}setCredentials(t,e){K(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),F(this,Cs,`${t}:${e}`)}get allowGzip(){return S(this,ku)}set allowGzip(t){F(this,ku,!!t)}get allowInsecureAuthentication(){return!!S(this,Su)}set allowInsecureAuthentication(t){F(this,Su,!!t)}get timeout(){return S(this,Tu)}set timeout(t){K(t>=0,"timeout must be non-zero","timeout",t),F(this,Tu,t)}get preflightFunc(){return S(this,Da)||null}set preflightFunc(t){F(this,Da,t)}get processFunc(){return S(this,Fa)||null}set processFunc(t){F(this,Fa,t)}get retryFunc(){return S(this,$a)||null}set retryFunc(t){F(this,$a,t)}get getUrlFunc(){return S(this,Io)||ov}set getUrlFunc(t){F(this,Io,t)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${S(this,Pn)?kt(S(this,Pn)):"null"}>`}setThrottleParams(t){t.slotInterval!=null&&(S(this,wi).slotInterval=t.slotInterval),t.maxAttempts!=null&&(S(this,wi).maxAttempts=t.maxAttempts)}send(){return ht(S(this,Di)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),F(this,Di,new ZV(this)),yt(this,Ha,Df).call(this,0,av()+this.timeout,0,this,new ta(0,"",{},null,this))}cancel(){ht(S(this,Di)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=kk.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(t){const e=this.url.split(":")[0].toLowerCase(),r=t.split(":")[0].toLowerCase();ht(this.method==="GET"&&(e!=="https"||r!=="http")&&t.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});const i=new cp(t);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,F(i,mi,Object.assign({},S(this,mi))),S(this,Pn)&&F(i,Pn,new Uint8Array(S(this,Pn))),F(i,Fr,S(this,Fr)),i}clone(){const t=new cp(this.url);return F(t,Ns,S(this,Ns)),S(this,Pn)&&F(t,Pn,S(this,Pn)),F(t,Fr,S(this,Fr)),F(t,mi,Object.assign({},S(this,mi))),F(t,Cs,S(this,Cs)),this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),F(t,Da,S(this,Da)),F(t,Fa,S(this,Fa)),F(t,$a,S(this,$a)),F(t,wi,Object.assign({},S(this,wi))),F(t,Io,S(this,Io)),t}static lockConfig(){_m=!0}static getGateway(t){return Qd[t.toLowerCase()]||null}static registerGateway(t,e){if(t=t.toLowerCase(),t==="http"||t==="https")throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(_m)throw new Error("gateways locked");Qd[t]=e}static registerGetUrl(t){if(_m)throw new Error("gateways locked");ov=t}static createGetUrlFunc(t){return Rk()}static createDataGateway(){return Ik}static createIpfsGatewayFunc(t){return Sk(t)}};Su=new WeakMap,ku=new WeakMap,mi=new WeakMap,Ns=new WeakMap,Tu=new WeakMap,Ou=new WeakMap,Pn=new WeakMap,Fr=new WeakMap,Cs=new WeakMap,Da=new WeakMap,Fa=new WeakMap,$a=new WeakMap,Di=new WeakMap,wi=new WeakMap,Io=new WeakMap,Ha=new WeakSet,Df=async function(t,e,r,i,s){var h,y,_;if(t>=S(this,wi).maxAttempts)return s.makeServerError("exceeded maximum retry limit");ht(av()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:i}),r>0&&await QV(r);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in Qd){const w=await Qd[a](o.url,Jd(S(i,Di)));if(w instanceof ta){let R=w;if(this.processFunc){Jd(S(i,Di));try{R=await this.processFunc(o,R)}catch(T){(T.throttle==null||typeof T.stall!="number")&&R.makeServerError("error in post-processing function",T).assertOk()}}return R}o=w}this.preflightFunc&&(o=await this.preflightFunc(o));const u=await this.getUrlFunc(o,Jd(S(i,Di)));let f=new ta(u.statusCode,u.statusMessage,u.headers,u.body,i);if(f.statusCode===301||f.statusCode===302){try{const w=f.headers.location||"";return yt(h=o.redirect(w),Ha,Df).call(h,t+1,e,0,i,f)}catch{}return f}else if(f.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,f,t))){const w=f.headers["retry-after"];let R=S(this,wi).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return typeof w=="string"&&w.match(/^[1-9][0-9]*$/)&&(R=parseInt(w)),yt(y=o.clone(),Ha,Df).call(y,t+1,e,R,i,f)}if(this.processFunc){Jd(S(i,Di));try{f=await this.processFunc(o,f)}catch(w){(w.throttle==null||typeof w.stall!="number")&&f.makeServerError("error in post-processing function",w).assertOk();let R=S(this,wi).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return w.stall>=0&&(R=w.stall),yt(_=o.clone(),Ha,Df).call(_,t+1,e,R,i,f)}}return f};let eo=cp;var $h,Hh,zh,$r,Nu,za;const Cb=class Cb{constructor(t,e,r,i,s){J(this,$h);J(this,Hh);J(this,zh);J(this,$r);J(this,Nu);J(this,za);F(this,$h,t),F(this,Hh,e),F(this,zh,Object.keys(r).reduce((o,a)=>(o[a.toLowerCase()]=String(r[a]),o),{})),F(this,$r,i==null?null:new Uint8Array(i)),F(this,Nu,s||null),F(this,za,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${S(this,$r)?kt(S(this,$r)):"null"}>`}get statusCode(){return S(this,$h)}get statusMessage(){return S(this,Hh)}get headers(){return Object.assign({},S(this,zh))}get body(){return S(this,$r)==null?null:new Uint8Array(S(this,$r))}get bodyText(){try{return S(this,$r)==null?"":Z0(S(this,$r))}catch{ht(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{ht(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const i=e[r++];return{value:[i,t[i]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(t,e){let r;t?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:(t=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${t})`);const i=new Cb(599,r,this.headers,this.body,S(this,Nu)||void 0);return F(i,za,{message:t,error:e}),i}throwThrottleError(t,e){e==null?e=-1:K(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const r=new Error(t||"throttling requests");throw $t(r,{stall:e,throttle:!0}),r}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return S(this,$r)!=null}get request(){return S(this,Nu)}ok(){return S(this,za).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=S(this,za);t===""&&(t=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let i=null;try{S(this,$r)&&(i=Z0(S(this,$r)))}catch{}ht(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:i,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};$h=new WeakMap,Hh=new WeakMap,zh=new WeakMap,$r=new WeakMap,Nu=new WeakMap,za=new WeakMap;let ta=Cb;function av(){return new Date().getTime()}function qV(n){return Js(n.replace(/%([0-9a-f][0-9a-f])/gi,(t,e)=>String.fromCharCode(parseInt(e,16))))}function QV(n){return new Promise(t=>setTimeout(t,n))}function JV(n){let t=n.toString(16);for(;t.length<2;)t="0"+t;return"0x"+t}function cv(n,t,e){let r=0;for(let i=0;i<e;i++)r=r*256+n[t+i];return r}function uv(n,t,e,r){const i=[];for(;e<t+1+r;){const s=Tk(n,e);i.push(s.result),e+=s.consumed,ht(e<=t+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:t})}return{consumed:1+r,result:i}}function Tk(n,t){ht(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});const e=r=>{ht(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r})};if(n[t]>=248){const r=n[t]-247;e(t+1+r);const i=cv(n,t+1,r);return e(t+1+r+i),uv(n,t,t+1+r,r+i)}else if(n[t]>=192){const r=n[t]-192;return e(t+1+r),uv(n,t,t+1,r)}else if(n[t]>=184){const r=n[t]-183;e(t+1+r);const i=cv(n,t+1,r);e(t+1+r+i);const s=kt(n.slice(t+1+r,t+1+r+i));return{consumed:1+r+i,result:s}}else if(n[t]>=128){const r=n[t]-128;e(t+1+r);const i=kt(n.slice(t+1,t+1+r));return{consumed:1+r,result:i}}return{consumed:1,result:JV(n[t])}}function eg(n){const t=ye(n,"data"),e=Tk(t,0);return K(e.consumed===t.length,"unexpected junk after rlp payload","data",n),e.result}function lv(n){const t=[];for(;n;)t.unshift(n&255),n>>=8;return t}function Ok(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(s){r=r.concat(Ok(s))}),r.length<=55)return r.unshift(192+r.length),r;const i=lv(r.length);return i.unshift(247+i.length),i.concat(r)}const t=Array.prototype.slice.call(ye(n,"object"));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const e=lv(t.length);return e.unshift(183+e.length),e.concat(t)}const fv="0123456789abcdef";function Ec(n){let t="0x";for(const e of Ok(n))t+=fv[e>>4],t+=fv[e&15];return t}const mr=32,xw=new Uint8Array(mr),YV=["then"],Yd={},Nk=new WeakMap;function xa(n){return Nk.get(n)}function hv(n,t){Nk.set(n,t)}function Nf(n,t){const e=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw e.error=t,e}function Rw(n,t,e){return n.indexOf(null)>=0?t.map((r,i)=>r instanceof Il?Rw(xa(r),r,e):r):n.reduce((r,i,s)=>{let o=t.getValue(i);return i in r||(e&&o instanceof Il&&(o=Rw(xa(o),o,e)),r[i]=o),r},{})}var Cu;const uu=class uu extends Array{constructor(...e){const r=e[0];let i=e[1],s=(e[2]||[]).slice(),o=!0;r!==Yd&&(i=e,s=[],o=!1);super(i.length);J(this,Cu);i.forEach((f,h)=>{this[h]=f});const a=s.reduce((f,h)=>(typeof h=="string"&&f.set(h,(f.get(h)||0)+1),f),new Map);if(hv(this,Object.freeze(i.map((f,h)=>{const y=s[h];return y!=null&&a.get(y)===1?y:null}))),F(this,Cu,[]),S(this,Cu)==null&&S(this,Cu),!o)return;Object.freeze(this);const u=new Proxy(this,{get:(f,h,y)=>{if(typeof h=="string"){if(h.match(/^[0-9]+$/)){const w=oe(h,"%index");if(w<0||w>=this.length)throw new RangeError("out of result range");const R=f[w];return R instanceof Error&&Nf(`index ${w}`,R),R}if(YV.indexOf(h)>=0)return Reflect.get(f,h,y);const _=f[h];if(_ instanceof Function)return function(...w){return _.apply(this===y?f:this,w)};if(!(h in f))return f.getValue.apply(this===y?f:this,[h])}return Reflect.get(f,h,y)}});return hv(u,xa(this)),u}toArray(e){const r=[];return this.forEach((i,s)=>{i instanceof Error&&Nf(`index ${s}`,i),e&&i instanceof uu&&(i=i.toArray(e)),r.push(i)}),r}toObject(e){const r=xa(this);return r.reduce((i,s,o)=>(ht(s!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Rw(r,this,e)),{})}slice(e,r){e==null&&(e=0),e<0&&(e+=this.length,e<0&&(e=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const i=xa(this),s=[],o=[];for(let a=e;a<r;a++)s.push(this[a]),o.push(i[a]);return new uu(Yd,s,o)}filter(e,r){const i=xa(this),s=[],o=[];for(let a=0;a<this.length;a++){const u=this[a];u instanceof Error&&Nf(`index ${a}`,u),e.call(r,u,a,this)&&(s.push(u),o.push(i[a]))}return new uu(Yd,s,o)}map(e,r){const i=[];for(let s=0;s<this.length;s++){const o=this[s];o instanceof Error&&Nf(`index ${s}`,o),i.push(e.call(r,o,s,this))}return i}getValue(e){const r=xa(this).indexOf(e);if(r===-1)return;const i=this[r];return i instanceof Error&&Nf(`property ${JSON.stringify(e)}`,i.error),i}static fromItems(e,r){return new uu(Yd,e,r)}};Cu=new WeakMap;let Il=uu;function dv(n){let t=yr(n);return ht(t.length<=mr,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:mr,offset:t.length}),t.length!==mr&&(t=dr(In([xw.slice(t.length%mr),t]))),t}class so{constructor(t,e,r,i){Z(this,"name");Z(this,"type");Z(this,"localName");Z(this,"dynamic");$t(this,{name:t,type:e,localName:r,dynamic:i},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){K(!1,t,this.localName,e)}}var Bs,Ga,Bu,d0;class Iw{constructor(){J(this,Bu);J(this,Bs);J(this,Ga);F(this,Bs,[]),F(this,Ga,0)}get data(){return In(S(this,Bs))}get length(){return S(this,Ga)}appendWriter(t){return yt(this,Bu,d0).call(this,dr(t.data))}writeBytes(t){let e=dr(t);const r=e.length%mr;return r&&(e=dr(In([e,xw.slice(r)]))),yt(this,Bu,d0).call(this,e)}writeValue(t){return yt(this,Bu,d0).call(this,dv(t))}writeUpdatableValue(){const t=S(this,Bs).length;return S(this,Bs).push(xw),F(this,Ga,S(this,Ga)+mr),e=>{S(this,Bs)[t]=dv(e)}}}Bs=new WeakMap,Ga=new WeakMap,Bu=new WeakSet,d0=function(t){return S(this,Bs).push(t),F(this,Ga,S(this,Ga)+t.length),t.length};var vr,Hr,Va,Ka,So,Sc,kw,Ck;const Bb=class Bb{constructor(t,e,r){J(this,Sc);Z(this,"allowLoose");J(this,vr);J(this,Hr);J(this,Va);J(this,Ka);J(this,So);$t(this,{allowLoose:!!e}),F(this,vr,dr(t)),F(this,Va,0),F(this,Ka,null),F(this,So,r??1024),F(this,Hr,0)}get data(){return kt(S(this,vr))}get dataLength(){return S(this,vr).length}get consumed(){return S(this,Hr)}get bytes(){return new Uint8Array(S(this,vr))}subReader(t){const e=new Bb(S(this,vr).slice(S(this,Hr)+t),this.allowLoose,S(this,So));return F(e,Ka,this),e}readBytes(t,e){let r=yt(this,Sc,Ck).call(this,0,t,!!e);return yt(this,Sc,kw).call(this,t),F(this,Hr,S(this,Hr)+r.length),r.slice(0,t)}readValue(){return lb(this.readBytes(mr))}readIndex(){return MV(this.readBytes(mr))}};vr=new WeakMap,Hr=new WeakMap,Va=new WeakMap,Ka=new WeakMap,So=new WeakMap,Sc=new WeakSet,kw=function(t){var e;if(S(this,Ka))return yt(e=S(this,Ka),Sc,kw).call(e,t);F(this,Va,S(this,Va)+t),ht(S(this,So)<1||S(this,Va)<=S(this,So)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${S(this,So)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:dr(S(this,vr)),offset:S(this,Hr),length:t,info:{bytesRead:S(this,Va),dataLength:this.dataLength}})},Ck=function(t,e,r){let i=Math.ceil(e/mr)*mr;return S(this,Hr)+i>S(this,vr).length&&(this.allowLoose&&r&&S(this,Hr)+e<=S(this,vr).length?i=e:ht(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:dr(S(this,vr)),length:S(this,vr).length,offset:S(this,Hr)+i})),S(this,vr).slice(S(this,Hr),S(this,Hr)+i)};let Sw=Bb;function q0(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function fb(n,...t){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(n.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${n.length}`)}function XV(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");q0(n.outputLen),q0(n.blockLen)}function Sl(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function Bk(n,t){fb(n);const e=t.outputLen;if(n.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const Am=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pk=n=>n instanceof Uint8Array,tK=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Em=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Ui=(n,t)=>n<<32-t|n>>>t,eK=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!eK)throw new Error("Non little-endian hardware is not supported");function nK(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function ng(n){if(typeof n=="string"&&(n=nK(n)),!Pk(n))throw new Error(`expected Uint8Array, got ${typeof n}`);return n}function rK(...n){const t=new Uint8Array(n.reduce((r,i)=>r+i.length,0));let e=0;return n.forEach(r=>{if(!Pk(r))throw new Error("Uint8Array expected");t.set(r,e),e+=r.length}),t}class hb{clone(){return this._cloneInto()}}function db(n){const t=r=>n().update(ng(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function iK(n=32){if(Am&&typeof Am.getRandomValues=="function")return Am.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}class Mk extends hb{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,XV(t);const r=ng(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=t.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(t){return Sl(this),this.iHash.update(t),this}digestInto(t){Sl(this),fb(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:i,destroyed:s,blockLen:o,outputLen:a}=this;return t=t,t.finished=i,t.destroyed=s,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Lk=(n,t,e)=>new Mk(n,t).update(e).digest();Lk.create=(n,t)=>new Mk(n,t);function sK(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),a=Number(e&s),u=r?4:0,f=r?0:4;n.setUint32(t+u,o,r),n.setUint32(t+f,a,r)}class Uk extends hb{constructor(t,e,r,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Em(this.buffer)}update(t){Sl(this);const{view:e,buffer:r,blockLen:i}=this;t=ng(t);const s=t.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const u=Em(t);for(;i<=s-o;o+=i)this.process(u,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Sl(this),Bk(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let y=o;y<i;y++)e[y]=0;sK(r,i-8,BigInt(this.length*8),s),this.process(r,0);const a=Em(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<f;y++)a.setUint32(4*y,h[y],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:i,finished:s,destroyed:o,pos:a}=this;return t.length=i,t.pos=a,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(r),t}}const oK=(n,t,e)=>n&t^~n&e,aK=(n,t,e)=>n&t^n&e^t&e,cK=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),go=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),yo=new Uint32Array(64);class uK extends Uk{constructor(){super(64,32,8,!1),this.A=go[0]|0,this.B=go[1]|0,this.C=go[2]|0,this.D=go[3]|0,this.E=go[4]|0,this.F=go[5]|0,this.G=go[6]|0,this.H=go[7]|0}get(){const{A:t,B:e,C:r,D:i,E:s,F:o,G:a,H:u}=this;return[t,e,r,i,s,o,a,u]}set(t,e,r,i,s,o,a,u){this.A=t|0,this.B=e|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=u|0}process(t,e){for(let y=0;y<16;y++,e+=4)yo[y]=t.getUint32(e,!1);for(let y=16;y<64;y++){const _=yo[y-15],w=yo[y-2],R=Ui(_,7)^Ui(_,18)^_>>>3,T=Ui(w,17)^Ui(w,19)^w>>>10;yo[y]=T+yo[y-7]+R+yo[y-16]|0}let{A:r,B:i,C:s,D:o,E:a,F:u,G:f,H:h}=this;for(let y=0;y<64;y++){const _=Ui(a,6)^Ui(a,11)^Ui(a,25),w=h+_+oK(a,u,f)+cK[y]+yo[y]|0,T=(Ui(r,2)^Ui(r,13)^Ui(r,22))+aK(r,i,s)|0;h=f,f=u,u=a,a=o+w|0,o=s,s=i,i=r,r=w+T|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(r,i,s,o,a,u,f,h)}roundClean(){yo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Dk=db(()=>new uK),Xd=BigInt(2**32-1),Tw=BigInt(32);function Fk(n,t=!1){return t?{h:Number(n&Xd),l:Number(n>>Tw&Xd)}:{h:Number(n>>Tw&Xd)|0,l:Number(n&Xd)|0}}function $k(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let i=0;i<n.length;i++){const{h:s,l:o}=Fk(n[i],t);[e[i],r[i]]=[s,o]}return[e,r]}const lK=(n,t)=>BigInt(n>>>0)<<Tw|BigInt(t>>>0),fK=(n,t,e)=>n>>>e,hK=(n,t,e)=>n<<32-e|t>>>e,dK=(n,t,e)=>n>>>e|t<<32-e,pK=(n,t,e)=>n<<32-e|t>>>e,gK=(n,t,e)=>n<<64-e|t>>>e-32,yK=(n,t,e)=>n>>>e-32|t<<64-e,mK=(n,t)=>t,wK=(n,t)=>n,Hk=(n,t,e)=>n<<e|t>>>32-e,zk=(n,t,e)=>t<<e|n>>>32-e,Gk=(n,t,e)=>t<<e-32|n>>>64-e,Vk=(n,t,e)=>n<<e-32|t>>>64-e;function bK(n,t,e,r){const i=(t>>>0)+(r>>>0);return{h:n+e+(i/2**32|0)|0,l:i|0}}const _K=(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),AK=(n,t,e,r)=>t+e+r+(n/2**32|0)|0,EK=(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),vK=(n,t,e,r,i)=>t+e+r+i+(n/2**32|0)|0,xK=(n,t,e,r,i)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),RK=(n,t,e,r,i,s)=>t+e+r+i+s+(n/2**32|0)|0,te={fromBig:Fk,split:$k,toBig:lK,shrSH:fK,shrSL:hK,rotrSH:dK,rotrSL:pK,rotrBH:gK,rotrBL:yK,rotr32H:mK,rotr32L:wK,rotlSH:Hk,rotlSL:zk,rotlBH:Gk,rotlBL:Vk,add:bK,add3L:_K,add3H:AK,add4L:EK,add4H:vK,add5H:RK,add5L:xK},[IK,SK]=te.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),mo=new Uint32Array(80),wo=new Uint32Array(80);class kK extends Uk{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:i,Ch:s,Cl:o,Dh:a,Dl:u,Eh:f,El:h,Fh:y,Fl:_,Gh:w,Gl:R,Hh:T,Hl:I}=this;return[t,e,r,i,s,o,a,u,f,h,y,_,w,R,T,I]}set(t,e,r,i,s,o,a,u,f,h,y,_,w,R,T,I){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=f|0,this.El=h|0,this.Fh=y|0,this.Fl=_|0,this.Gh=w|0,this.Gl=R|0,this.Hh=T|0,this.Hl=I|0}process(t,e){for(let U=0;U<16;U++,e+=4)mo[U]=t.getUint32(e),wo[U]=t.getUint32(e+=4);for(let U=16;U<80;U++){const G=mo[U-15]|0,W=wo[U-15]|0,X=te.rotrSH(G,W,1)^te.rotrSH(G,W,8)^te.shrSH(G,W,7),j=te.rotrSL(G,W,1)^te.rotrSL(G,W,8)^te.shrSL(G,W,7),Y=mo[U-2]|0,it=wo[U-2]|0,ut=te.rotrSH(Y,it,19)^te.rotrBH(Y,it,61)^te.shrSH(Y,it,6),rt=te.rotrSL(Y,it,19)^te.rotrBL(Y,it,61)^te.shrSL(Y,it,6),ot=te.add4L(j,rt,wo[U-7],wo[U-16]),C=te.add4H(ot,X,ut,mo[U-7],mo[U-16]);mo[U]=C|0,wo[U]=ot|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:a,Cl:u,Dh:f,Dl:h,Eh:y,El:_,Fh:w,Fl:R,Gh:T,Gl:I,Hh:B,Hl:H}=this;for(let U=0;U<80;U++){const G=te.rotrSH(y,_,14)^te.rotrSH(y,_,18)^te.rotrBH(y,_,41),W=te.rotrSL(y,_,14)^te.rotrSL(y,_,18)^te.rotrBL(y,_,41),X=y&w^~y&T,j=_&R^~_&I,Y=te.add5L(H,W,j,SK[U],wo[U]),it=te.add5H(Y,B,G,X,IK[U],mo[U]),ut=Y|0,rt=te.rotrSH(r,i,28)^te.rotrBH(r,i,34)^te.rotrBH(r,i,39),ot=te.rotrSL(r,i,28)^te.rotrBL(r,i,34)^te.rotrBL(r,i,39),C=r&s^r&a^s&a,p=i&o^i&u^o&u;B=T|0,H=I|0,T=w|0,I=R|0,w=y|0,R=_|0,{h:y,l:_}=te.add(f|0,h|0,it|0,ut|0),f=a|0,h=u|0,a=s|0,u=o|0,s=r|0,o=i|0;const m=te.add3L(ut,ot,p);r=te.add3H(m,it,rt,C),i=m|0}({h:r,l:i}=te.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=te.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:u}=te.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:f,l:h}=te.add(this.Dh|0,this.Dl|0,f|0,h|0),{h:y,l:_}=te.add(this.Eh|0,this.El|0,y|0,_|0),{h:w,l:R}=te.add(this.Fh|0,this.Fl|0,w|0,R|0),{h:T,l:I}=te.add(this.Gh|0,this.Gl|0,T|0,I|0),{h:B,l:H}=te.add(this.Hh|0,this.Hl|0,B|0,H|0),this.set(r,i,s,o,a,u,f,h,y,_,w,R,T,I,B,H)}roundClean(){mo.fill(0),wo.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const TK=db(()=>new kK);function OK(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof gl<"u")return gl;throw new Error("unable to locate global object")}const pv=OK();pv.crypto||pv.msCrypto;function NK(n){switch(n){case"sha256":return Dk.create();case"sha512":return TK.create()}K(!1,"invalid hashing algorithm name","algorithm",n)}const[Kk,jk,Wk]=[[],[],[]],CK=BigInt(0),Cf=BigInt(1),BK=BigInt(2),PK=BigInt(7),MK=BigInt(256),LK=BigInt(113);for(let n=0,t=Cf,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],Kk.push(2*(5*r+e)),jk.push((n+1)*(n+2)/2%64);let i=CK;for(let s=0;s<7;s++)t=(t<<Cf^(t>>PK)*LK)%MK,t&BK&&(i^=Cf<<(Cf<<BigInt(s))-Cf);Wk.push(i)}const[UK,DK]=$k(Wk,!0),gv=(n,t,e)=>e>32?Gk(n,t,e):Hk(n,t,e),yv=(n,t,e)=>e>32?Vk(n,t,e):zk(n,t,e);function FK(n,t=24){const e=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)e[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,f=e[u],h=e[u+1],y=gv(f,h,1)^e[a],_=yv(f,h,1)^e[a+1];for(let w=0;w<50;w+=10)n[o+w]^=y,n[o+w+1]^=_}let i=n[2],s=n[3];for(let o=0;o<24;o++){const a=jk[o],u=gv(i,s,a),f=yv(i,s,a),h=Kk[o];i=n[h],s=n[h+1],n[h]=u,n[h+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)e[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~e[(a+2)%10]&e[(a+4)%10]}n[0]^=UK[r],n[1]^=DK[r]}e.fill(0)}class pb extends hb{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,q0(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=tK(this.state)}keccak(){FK(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Sl(this);const{blockLen:e,state:r}=this;t=ng(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(e-this.pos,i-s);for(let a=0;a<o;a++)r[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:i}=this;t[r]^=e,e&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){Sl(this,!1),fb(t),this.finish();const e=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(e.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return q0(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Bk(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new pb(e,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const $K=(n,t,e)=>db(()=>new pb(t,n,e)),HK=$K(1,136,256/8);let Zk=!1;const qk=function(n){return HK(n)};let Qk=qk;function Tn(n){const t=ye(n,"data");return kt(Qk(t))}Tn._=qk;Tn.lock=function(){Zk=!0};Tn.register=function(n){if(Zk)throw new TypeError("keccak256 is locked");Qk=n};Object.freeze(Tn);const Jk=function(n){return NK("sha256").update(n).digest()};let Yk=Jk,Xk=!1;function Jl(n){const t=ye(n,"data");return kt(Yk(t))}Jl._=Jk;Jl.lock=function(){Xk=!0};Jl.register=function(n){if(Xk)throw new Error("sha256 is locked");Yk=n};Object.freeze(Jl);Object.freeze(Jl);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const tT=BigInt(0),rg=BigInt(1),zK=BigInt(2),ig=n=>n instanceof Uint8Array,GK=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function kl(n){if(!ig(n))throw new Error("Uint8Array expected");let t="";for(let e=0;e<n.length;e++)t+=GK[n[e]];return t}function eT(n){const t=n.toString(16);return t.length&1?`0${t}`:t}function gb(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}function Tl(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const t=n.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const e=new Uint8Array(t/2);for(let r=0;r<e.length;r++){const i=r*2,s=n.slice(i,i+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function uc(n){return gb(kl(n))}function yb(n){if(!ig(n))throw new Error("Uint8Array expected");return gb(kl(Uint8Array.from(n).reverse()))}function Ol(n,t){return Tl(n.toString(16).padStart(t*2,"0"))}function mb(n,t){return Ol(n,t).reverse()}function VK(n){return Tl(eT(n))}function yi(n,t,e){let r;if(typeof t=="string")try{r=Tl(t)}catch(s){throw new Error(`${n} must be valid hex string, got "${t}". Cause: ${s}`)}else if(ig(t))r=Uint8Array.from(t);else throw new Error(`${n} must be hex string or Uint8Array`);const i=r.length;if(typeof e=="number"&&i!==e)throw new Error(`${n} expected ${e} bytes, got ${i}`);return r}function Ih(...n){const t=new Uint8Array(n.reduce((r,i)=>r+i.length,0));let e=0;return n.forEach(r=>{if(!ig(r))throw new Error("Uint8Array expected");t.set(r,e),e+=r.length}),t}function KK(n,t){if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==t[e])return!1;return!0}function jK(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function WK(n){let t;for(t=0;n>tT;n>>=rg,t+=1);return t}function ZK(n,t){return n>>BigInt(t)&rg}const qK=(n,t,e)=>n|(e?rg:tT)<<BigInt(t),wb=n=>(zK<<BigInt(n-1))-rg,vm=n=>new Uint8Array(n),mv=n=>Uint8Array.from(n);function nT(n,t,e){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let r=vm(n),i=vm(n),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...y)=>e(i,r,...y),u=(y=vm())=>{i=a(mv([0]),y),r=a(),y.length!==0&&(i=a(mv([1]),y),r=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let y=0;const _=[];for(;y<t;){r=a();const w=r.slice();_.push(w),y+=r.length}return Ih(..._)};return(y,_)=>{o(),u(y);let w;for(;!(w=_(f()));)u();return o(),w}}const QK={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||n instanceof Uint8Array,isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,t)=>t.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function yd(n,t,e={}){const r=(i,s,o)=>{const a=QK[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);const u=n[i];if(!(o&&u===void 0)&&!a(u,n))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(const[i,s]of Object.entries(t))r(i,s,!1);for(const[i,s]of Object.entries(e))r(i,s,!0);return n}const JK=Object.freeze(Object.defineProperty({__proto__:null,bitGet:ZK,bitLen:WK,bitMask:wb,bitSet:qK,bytesToHex:kl,bytesToNumberBE:uc,bytesToNumberLE:yb,concatBytes:Ih,createHmacDrbg:nT,ensureBytes:yi,equalBytes:KK,hexToBytes:Tl,hexToNumber:gb,numberToBytesBE:Ol,numberToBytesLE:mb,numberToHexUnpadded:eT,numberToVarBytesBE:VK,utf8ToBytes:jK,validateObject:yd},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $n=BigInt(0),xn=BigInt(1),Ra=BigInt(2),YK=BigInt(3),Ow=BigInt(4),wv=BigInt(5),bv=BigInt(8);BigInt(9);BigInt(16);function Sr(n,t){const e=n%t;return e>=$n?e:t+e}function XK(n,t,e){if(e<=$n||t<$n)throw new Error("Expected power/modulo > 0");if(e===xn)return $n;let r=xn;for(;t>$n;)t&xn&&(r=r*n%e),n=n*n%e,t>>=xn;return r}function qr(n,t,e){let r=n;for(;t-- >$n;)r*=r,r%=e;return r}function Nw(n,t){if(n===$n||t<=$n)throw new Error(`invert: expected positive integers, got n=${n} mod=${t}`);let e=Sr(n,t),r=t,i=$n,s=xn;for(;e!==$n;){const a=r/e,u=r%e,f=i-s*a;r=e,e=u,i=s,s=f}if(r!==xn)throw new Error("invert: does not exist");return Sr(i,t)}function tj(n){const t=(n-xn)/Ra;let e,r,i;for(e=n-xn,r=0;e%Ra===$n;e/=Ra,r++);for(i=Ra;i<n&&XK(i,t,n)!==n-xn;i++);if(r===1){const o=(n+xn)/Ow;return function(u,f){const h=u.pow(f,o);if(!u.eql(u.sqr(h),f))throw new Error("Cannot find square root");return h}}const s=(e+xn)/Ra;return function(a,u){if(a.pow(u,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=r,h=a.pow(a.mul(a.ONE,i),e),y=a.pow(u,s),_=a.pow(u,e);for(;!a.eql(_,a.ONE);){if(a.eql(_,a.ZERO))return a.ZERO;let w=1;for(let T=a.sqr(_);w<f&&!a.eql(T,a.ONE);w++)T=a.sqr(T);const R=a.pow(h,xn<<BigInt(f-w-1));h=a.sqr(R),y=a.mul(y,R),_=a.mul(_,h),f=w}return y}}function ej(n){if(n%Ow===YK){const t=(n+xn)/Ow;return function(r,i){const s=r.pow(i,t);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(n%bv===wv){const t=(n-wv)/bv;return function(r,i){const s=r.mul(i,Ra),o=r.pow(s,t),a=r.mul(i,o),u=r.mul(r.mul(a,Ra),o),f=r.mul(a,r.sub(u,r.ONE));if(!r.eql(r.sqr(f),i))throw new Error("Cannot find square root");return f}}return tj(n)}const nj=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function rj(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=nj.reduce((r,i)=>(r[i]="function",r),t);return yd(n,e)}function ij(n,t,e){if(e<$n)throw new Error("Expected power > 0");if(e===$n)return n.ONE;if(e===xn)return t;let r=n.ONE,i=t;for(;e>$n;)e&xn&&(r=n.mul(r,i)),i=n.sqr(i),e>>=xn;return r}function sj(n,t){const e=new Array(t.length),r=t.reduce((s,o,a)=>n.is0(o)?s:(e[a]=s,n.mul(s,o)),n.ONE),i=n.inv(r);return t.reduceRight((s,o,a)=>n.is0(o)?s:(e[a]=n.mul(s,e[a]),n.mul(s,o)),i),e}function rT(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function oj(n,t,e=!1,r={}){if(n<=$n)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:i,nByteLength:s}=rT(n,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=ej(n),a=Object.freeze({ORDER:n,BITS:i,BYTES:s,MASK:wb(i),ZERO:$n,ONE:xn,create:u=>Sr(u,n),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return $n<=u&&u<n},is0:u=>u===$n,isOdd:u=>(u&xn)===xn,neg:u=>Sr(-u,n),eql:(u,f)=>u===f,sqr:u=>Sr(u*u,n),add:(u,f)=>Sr(u+f,n),sub:(u,f)=>Sr(u-f,n),mul:(u,f)=>Sr(u*f,n),pow:(u,f)=>ij(a,u,f),div:(u,f)=>Sr(u*Nw(f,n),n),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>Nw(u,n),sqrt:r.sqrt||(u=>o(a,u)),invertBatch:u=>sj(a,u),cmov:(u,f,h)=>h?f:u,toBytes:u=>e?mb(u,s):Ol(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return e?yb(u):uc(u)}});return Object.freeze(a)}function iT(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function sT(n){const t=iT(n);return t+Math.ceil(t/2)}function aj(n,t,e=!1){const r=n.length,i=iT(t),s=sT(t);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=e?uc(n):yb(n),a=Sr(o,t-xn)+xn;return e?mb(a,i):Ol(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cj=BigInt(0),xm=BigInt(1);function uj(n,t){const e=(i,s)=>{const o=s.negate();return i?o:s},r=i=>{const s=Math.ceil(t/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:e,unsafeLadder(i,s){let o=n.ZERO,a=i;for(;s>cj;)s&xm&&(o=o.add(a)),a=a.double(),s>>=xm;return o},precomputeWindow(i,s){const{windows:o,windowSize:a}=r(s),u=[];let f=i,h=f;for(let y=0;y<o;y++){h=f,u.push(h);for(let _=1;_<a;_++)h=h.add(f),u.push(h);f=h.double()}return u},wNAF(i,s,o){const{windows:a,windowSize:u}=r(i);let f=n.ZERO,h=n.BASE;const y=BigInt(2**i-1),_=2**i,w=BigInt(i);for(let R=0;R<a;R++){const T=R*u;let I=Number(o&y);o>>=w,I>u&&(I-=_,o+=xm);const B=T,H=T+Math.abs(I)-1,U=R%2!==0,G=I<0;I===0?h=h.add(e(U,s[B])):f=f.add(e(G,s[H]))}return{p:f,f:h}},wNAFCached(i,s,o,a){const u=i._WINDOW_SIZE||1;let f=s.get(i);return f||(f=this.precomputeWindow(i,u),u!==1&&s.set(i,a(f))),this.wNAF(u,f,o)}}}function oT(n){return rj(n.Fp),yd(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...rT(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function lj(n){const t=oT(n);yd(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:i}=t;if(e){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:fj,hexToBytes:hj}=JK,Pa={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(n){const{Err:t}=Pa;if(n.length<2||n[0]!==2)throw new t("Invalid signature integer tag");const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:fj(r),l:n.subarray(e+2)}},toSig(n){const{Err:t}=Pa,e=typeof n=="string"?hj(n):n;if(!(e instanceof Uint8Array))throw new Error("ui8a expected");let r=e.length;if(r<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:i,l:s}=Pa._parseInt(e.subarray(2)),{d:o,l:a}=Pa._parseInt(s);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(n){const t=f=>Number.parseInt(f[0],16)&8?"00"+f:f,e=f=>{const h=f.toString(16);return h.length&1?`0${h}`:h},r=t(e(n.s)),i=t(e(n.r)),s=r.length/2,o=i.length/2,a=e(s),u=e(o);return`30${e(o+s+4)}02${u}${i}02${a}${r}`}},Zs=BigInt(0),oi=BigInt(1);BigInt(2);const _v=BigInt(3);BigInt(4);function dj(n){const t=lj(n),{Fp:e}=t,r=t.toBytes||((R,T,I)=>{const B=T.toAffine();return Ih(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),i=t.fromBytes||(R=>{const T=R.subarray(1),I=e.fromBytes(T.subarray(0,e.BYTES)),B=e.fromBytes(T.subarray(e.BYTES,2*e.BYTES));return{x:I,y:B}});function s(R){const{a:T,b:I}=t,B=e.sqr(R),H=e.mul(B,R);return e.add(e.add(H,e.mul(R,T)),I)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(R){return typeof R=="bigint"&&Zs<R&&R<t.n}function a(R){if(!o(R))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(R){const{allowedPrivateKeyLengths:T,nByteLength:I,wrapPrivateKey:B,n:H}=t;if(T&&typeof R!="bigint"){if(R instanceof Uint8Array&&(R=kl(R)),typeof R!="string"||!T.includes(R.length))throw new Error("Invalid key");R=R.padStart(I*2,"0")}let U;try{U=typeof R=="bigint"?R:uc(yi("private key",R,I))}catch{throw new Error(`private key must be ${I} bytes, hex or bigint, not ${typeof R}`)}return B&&(U=Sr(U,H)),a(U),U}const f=new Map;function h(R){if(!(R instanceof y))throw new Error("ProjectivePoint expected")}class y{constructor(T,I,B){if(this.px=T,this.py=I,this.pz=B,T==null||!e.isValid(T))throw new Error("x required");if(I==null||!e.isValid(I))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required")}static fromAffine(T){const{x:I,y:B}=T||{};if(!T||!e.isValid(I)||!e.isValid(B))throw new Error("invalid affine point");if(T instanceof y)throw new Error("projective point not allowed");const H=U=>e.eql(U,e.ZERO);return H(I)&&H(B)?y.ZERO:new y(I,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(T){const I=e.invertBatch(T.map(B=>B.pz));return T.map((B,H)=>B.toAffine(I[H])).map(y.fromAffine)}static fromHex(T){const I=y.fromAffine(i(yi("pointHex",T)));return I.assertValidity(),I}static fromPrivateKey(T){return y.BASE.multiply(u(T))}_setWindowSize(T){this._WINDOW_SIZE=T,f.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:T,y:I}=this.toAffine();if(!e.isValid(T)||!e.isValid(I))throw new Error("bad point: x or y not FE");const B=e.sqr(I),H=s(T);if(!e.eql(B,H))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(e.isOdd)return!e.isOdd(T);throw new Error("Field doesn't support isOdd")}equals(T){h(T);const{px:I,py:B,pz:H}=this,{px:U,py:G,pz:W}=T,X=e.eql(e.mul(I,W),e.mul(U,H)),j=e.eql(e.mul(B,W),e.mul(G,H));return X&&j}negate(){return new y(this.px,e.neg(this.py),this.pz)}double(){const{a:T,b:I}=t,B=e.mul(I,_v),{px:H,py:U,pz:G}=this;let W=e.ZERO,X=e.ZERO,j=e.ZERO,Y=e.mul(H,H),it=e.mul(U,U),ut=e.mul(G,G),rt=e.mul(H,U);return rt=e.add(rt,rt),j=e.mul(H,G),j=e.add(j,j),W=e.mul(T,j),X=e.mul(B,ut),X=e.add(W,X),W=e.sub(it,X),X=e.add(it,X),X=e.mul(W,X),W=e.mul(rt,W),j=e.mul(B,j),ut=e.mul(T,ut),rt=e.sub(Y,ut),rt=e.mul(T,rt),rt=e.add(rt,j),j=e.add(Y,Y),Y=e.add(j,Y),Y=e.add(Y,ut),Y=e.mul(Y,rt),X=e.add(X,Y),ut=e.mul(U,G),ut=e.add(ut,ut),Y=e.mul(ut,rt),W=e.sub(W,Y),j=e.mul(ut,it),j=e.add(j,j),j=e.add(j,j),new y(W,X,j)}add(T){h(T);const{px:I,py:B,pz:H}=this,{px:U,py:G,pz:W}=T;let X=e.ZERO,j=e.ZERO,Y=e.ZERO;const it=t.a,ut=e.mul(t.b,_v);let rt=e.mul(I,U),ot=e.mul(B,G),C=e.mul(H,W),p=e.add(I,B),m=e.add(U,G);p=e.mul(p,m),m=e.add(rt,ot),p=e.sub(p,m),m=e.add(I,H);let v=e.add(U,W);return m=e.mul(m,v),v=e.add(rt,C),m=e.sub(m,v),v=e.add(B,H),X=e.add(G,W),v=e.mul(v,X),X=e.add(ot,C),v=e.sub(v,X),Y=e.mul(it,m),X=e.mul(ut,C),Y=e.add(X,Y),X=e.sub(ot,Y),Y=e.add(ot,Y),j=e.mul(X,Y),ot=e.add(rt,rt),ot=e.add(ot,rt),C=e.mul(it,C),m=e.mul(ut,m),ot=e.add(ot,C),C=e.sub(rt,C),C=e.mul(it,C),m=e.add(m,C),rt=e.mul(ot,m),j=e.add(j,rt),rt=e.mul(v,m),X=e.mul(p,X),X=e.sub(X,rt),rt=e.mul(p,ot),Y=e.mul(v,Y),Y=e.add(Y,rt),new y(X,j,Y)}subtract(T){return this.add(T.negate())}is0(){return this.equals(y.ZERO)}wNAF(T){return w.wNAFCached(this,f,T,I=>{const B=e.invertBatch(I.map(H=>H.pz));return I.map((H,U)=>H.toAffine(B[U])).map(y.fromAffine)})}multiplyUnsafe(T){const I=y.ZERO;if(T===Zs)return I;if(a(T),T===oi)return this;const{endo:B}=t;if(!B)return w.unsafeLadder(this,T);let{k1neg:H,k1:U,k2neg:G,k2:W}=B.splitScalar(T),X=I,j=I,Y=this;for(;U>Zs||W>Zs;)U&oi&&(X=X.add(Y)),W&oi&&(j=j.add(Y)),Y=Y.double(),U>>=oi,W>>=oi;return H&&(X=X.negate()),G&&(j=j.negate()),j=new y(e.mul(j.px,B.beta),j.py,j.pz),X.add(j)}multiply(T){a(T);let I=T,B,H;const{endo:U}=t;if(U){const{k1neg:G,k1:W,k2neg:X,k2:j}=U.splitScalar(I);let{p:Y,f:it}=this.wNAF(W),{p:ut,f:rt}=this.wNAF(j);Y=w.constTimeNegate(G,Y),ut=w.constTimeNegate(X,ut),ut=new y(e.mul(ut.px,U.beta),ut.py,ut.pz),B=Y.add(ut),H=it.add(rt)}else{const{p:G,f:W}=this.wNAF(I);B=G,H=W}return y.normalizeZ([B,H])[0]}multiplyAndAddUnsafe(T,I,B){const H=y.BASE,U=(W,X)=>X===Zs||X===oi||!W.equals(H)?W.multiplyUnsafe(X):W.multiply(X),G=U(this,I).add(U(T,B));return G.is0()?void 0:G}toAffine(T){const{px:I,py:B,pz:H}=this,U=this.is0();T==null&&(T=U?e.ONE:e.inv(H));const G=e.mul(I,T),W=e.mul(B,T),X=e.mul(H,T);if(U)return{x:e.ZERO,y:e.ZERO};if(!e.eql(X,e.ONE))throw new Error("invZ was invalid");return{x:G,y:W}}isTorsionFree(){const{h:T,isTorsionFree:I}=t;if(T===oi)return!0;if(I)return I(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:T,clearCofactor:I}=t;return T===oi?this:I?I(y,this):this.multiplyUnsafe(t.h)}toRawBytes(T=!0){return this.assertValidity(),r(y,this,T)}toHex(T=!0){return kl(this.toRawBytes(T))}}y.BASE=new y(t.Gx,t.Gy,e.ONE),y.ZERO=new y(e.ZERO,e.ONE,e.ZERO);const _=t.nBitLength,w=uj(y,t.endo?Math.ceil(_/2):_);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:u,weierstrassEquation:s,isWithinCurveOrder:o}}function pj(n){const t=oT(n);return yd(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function gj(n){const t=pj(n),{Fp:e,n:r}=t,i=e.BYTES+1,s=2*e.BYTES+1;function o(m){return Zs<m&&m<e.ORDER}function a(m){return Sr(m,r)}function u(m){return Nw(m,r)}const{ProjectivePoint:f,normPrivateKeyToScalar:h,weierstrassEquation:y,isWithinCurveOrder:_}=dj({...t,toBytes(m,v,k){const N=v.toAffine(),M=e.toBytes(N.x),z=Ih;return k?z(Uint8Array.from([v.hasEvenY()?2:3]),M):z(Uint8Array.from([4]),M,e.toBytes(N.y))},fromBytes(m){const v=m.length,k=m[0],N=m.subarray(1);if(v===i&&(k===2||k===3)){const M=uc(N);if(!o(M))throw new Error("Point is not on curve");const z=y(M);let P=e.sqrt(z);const A=(P&oi)===oi;return(k&1)===1!==A&&(P=e.neg(P)),{x:M,y:P}}else if(v===s&&k===4){const M=e.fromBytes(N.subarray(0,e.BYTES)),z=e.fromBytes(N.subarray(e.BYTES,2*e.BYTES));return{x:M,y:z}}else throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),w=m=>kl(Ol(m,t.nByteLength));function R(m){const v=r>>oi;return m>v}function T(m){return R(m)?a(-m):m}const I=(m,v,k)=>uc(m.slice(v,k));class B{constructor(v,k,N){this.r=v,this.s=k,this.recovery=N,this.assertValidity()}static fromCompact(v){const k=t.nByteLength;return v=yi("compactSignature",v,k*2),new B(I(v,0,k),I(v,k,2*k))}static fromDER(v){const{r:k,s:N}=Pa.toSig(yi("DER",v));return new B(k,N)}assertValidity(){if(!_(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!_(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(v){return new B(this.r,this.s,v)}recoverPublicKey(v){const{r:k,s:N,recovery:M}=this,z=j(yi("msgHash",v));if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");const P=M===2||M===3?k+t.n:k;if(P>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const A=M&1?"03":"02",$=f.fromHex(A+w(P)),ct=u(P),ft=a(-z*ct),wt=a(N*ct),Ht=f.BASE.multiplyAndAddUnsafe($,ft,wt);if(!Ht)throw new Error("point at infinify");return Ht.assertValidity(),Ht}hasHighS(){return R(this.s)}normalizeS(){return this.hasHighS()?new B(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Tl(this.toDERHex())}toDERHex(){return Pa.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Tl(this.toCompactHex())}toCompactHex(){return w(this.r)+w(this.s)}}const H={isValidPrivateKey(m){try{return h(m),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const m=sT(t.n);return aj(t.randomBytes(m),t.n)},precompute(m=8,v=f.BASE){return v._setWindowSize(m),v.multiply(BigInt(3)),v}};function U(m,v=!0){return f.fromPrivateKey(m).toRawBytes(v)}function G(m){const v=m instanceof Uint8Array,k=typeof m=="string",N=(v||k)&&m.length;return v?N===i||N===s:k?N===2*i||N===2*s:m instanceof f}function W(m,v,k=!0){if(G(m))throw new Error("first arg must be private key");if(!G(v))throw new Error("second arg must be public key");return f.fromHex(v).multiply(h(m)).toRawBytes(k)}const X=t.bits2int||function(m){const v=uc(m),k=m.length*8-t.nBitLength;return k>0?v>>BigInt(k):v},j=t.bits2int_modN||function(m){return a(X(m))},Y=wb(t.nBitLength);function it(m){if(typeof m!="bigint")throw new Error("bigint expected");if(!(Zs<=m&&m<Y))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Ol(m,t.nByteLength)}function ut(m,v,k=rt){if(["recovered","canonical"].some(Mt=>Mt in k))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:M}=t;let{lowS:z,prehash:P,extraEntropy:A}=k;z==null&&(z=!0),m=yi("msgHash",m),P&&(m=yi("prehashed msgHash",N(m)));const $=j(m),ct=h(v),ft=[it(ct),it($)];if(A!=null){const Mt=A===!0?M(e.BYTES):A;ft.push(yi("extraEntropy",Mt))}const wt=Ih(...ft),Ht=$;function Lt(Mt){const Ee=X(Mt);if(!_(Ee))return;const Vt=u(Ee),Ut=f.BASE.multiply(Ee).toAffine(),Ie=a(Ut.x);if(Ie===Zs)return;const Yt=a(Vt*a(Ht+Ie*ct));if(Yt===Zs)return;let ie=(Ut.x===Ie?0:2)|Number(Ut.y&oi),Je=Yt;return z&&R(Yt)&&(Je=T(Yt),ie^=1),new B(Ie,Je,ie)}return{seed:wt,k2sig:Lt}}const rt={lowS:t.lowS,prehash:!1},ot={lowS:t.lowS,prehash:!1};function C(m,v,k=rt){const{seed:N,k2sig:M}=ut(m,v,k),z=t;return nT(z.hash.outputLen,z.nByteLength,z.hmac)(N,M)}f.BASE._setWindowSize(8);function p(m,v,k,N=ot){var Ut;const M=m;if(v=yi("msgHash",v),k=yi("publicKey",k),"strict"in N)throw new Error("options.strict was renamed to lowS");const{lowS:z,prehash:P}=N;let A,$;try{if(typeof M=="string"||M instanceof Uint8Array)try{A=B.fromDER(M)}catch(Ie){if(!(Ie instanceof Pa.Err))throw Ie;A=B.fromCompact(M)}else if(typeof M=="object"&&typeof M.r=="bigint"&&typeof M.s=="bigint"){const{r:Ie,s:Yt}=M;A=new B(Ie,Yt)}else throw new Error("PARSE");$=f.fromHex(k)}catch(Ie){if(Ie.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(z&&A.hasHighS())return!1;P&&(v=t.hash(v));const{r:ct,s:ft}=A,wt=j(v),Ht=u(ft),Lt=a(wt*Ht),Mt=a(ct*Ht),Ee=(Ut=f.BASE.multiplyAndAddUnsafe($,Lt,Mt))==null?void 0:Ut.toAffine();return Ee?a(Ee.x)===ct:!1}return{CURVE:t,getPublicKey:U,getSharedSecret:W,sign:C,verify:p,ProjectivePoint:f,Signature:B,utils:H}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function yj(n){return{hash:n,hmac:(t,...e)=>Lk(n,t,rK(...e)),randomBytes:iK}}function mj(n,t){const e=r=>gj({...n,...yj(r)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const aT=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Av=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),wj=BigInt(1),Cw=BigInt(2),Ev=(n,t)=>(n+t/Cw)/t;function bj(n){const t=aT,e=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),f=n*n*n%t,h=f*f*n%t,y=qr(h,e,t)*h%t,_=qr(y,e,t)*h%t,w=qr(_,Cw,t)*f%t,R=qr(w,i,t)*w%t,T=qr(R,s,t)*R%t,I=qr(T,a,t)*T%t,B=qr(I,u,t)*I%t,H=qr(B,a,t)*T%t,U=qr(H,e,t)*h%t,G=qr(U,o,t)*R%t,W=qr(G,r,t)*f%t,X=qr(W,Cw,t);if(!Bw.eql(Bw.sqr(X),n))throw new Error("Cannot find square root");return X}const Bw=oj(aT,void 0,void 0,{sqrt:bj}),_o=mj({a:BigInt(0),b:BigInt(7),Fp:Bw,n:Av,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=Av,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-wj*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,o=BigInt("0x100000000000000000000000000000000"),a=Ev(s*n,t),u=Ev(-r*n,t);let f=Sr(n-a*e-u*i,t),h=Sr(-a*r-u*s,t);const y=f>o,_=h>o;if(y&&(f=t-f),_&&(h=t-h),f>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:y,k1:f,k2neg:_,k2:h}}}},Dk);BigInt(0);_o.ProjectivePoint;const Sh="0x0000000000000000000000000000000000000000",vv="0x0000000000000000000000000000000000000000000000000000000000000000",xv=BigInt(0),Rv=BigInt(1),Iv=BigInt(2),Sv=BigInt(27),kv=BigInt(28),t0=BigInt(35),Wc={};function Tv(n){return Ac(yr(n),32)}var Pu,Mu,Lu,ja;const gi=class gi{constructor(t,e,r,i){J(this,Pu);J(this,Mu);J(this,Lu);J(this,ja);Yp(t,Wc,"Signature"),F(this,Pu,e),F(this,Mu,r),F(this,Lu,i),F(this,ja,null)}get r(){return S(this,Pu)}set r(t){K(mu(t)===32,"invalid r","value",t),F(this,Pu,kt(t))}get s(){return S(this,Mu)}set s(t){K(mu(t)===32,"invalid s","value",t);const e=kt(t);K(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),F(this,Mu,e)}get v(){return S(this,Lu)}set v(t){const e=oe(t,"value");K(e===27||e===28,"invalid v","v",t),F(this,Lu,e)}get networkV(){return S(this,ja)}get legacyChainId(){const t=this.networkV;return t==null?null:gi.getChainId(t)}get yParity(){return this.v===27?0:1}get yParityAndS(){const t=ye(this.s);return this.yParity&&(t[0]|=128),kt(t)}get compactSerialized(){return In([this.r,this.yParityAndS])}get serialized(){return In([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const t=new gi(Wc,this.r,this.s,this.v);return this.networkV&&F(t,ja,this.networkV),t}toJSON(){const t=this.networkV;return{_type:"signature",networkV:t!=null?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=Nt(t,"v");return e==Sv||e==kv?xv:(K(e>=t0,"invalid EIP-155 v","v",t),(e-t0)/Iv)}static getChainIdV(t,e){return Nt(t)*Iv+BigInt(35+e-27)}static getNormalizedV(t){const e=Nt(t);return e===xv||e===Sv?27:e===Rv||e===kv?28:(K(e>=t0,"invalid v","v",t),e&Rv?27:28)}static from(t){function e(f,h){K(f,h,"signature",t)}if(t==null)return new gi(Wc,vv,vv,27);if(typeof t=="string"){const f=ye(t,"signature");if(f.length===64){const h=kt(f.slice(0,32)),y=f.slice(32,64),_=y[0]&128?28:27;return y[0]&=127,new gi(Wc,h,kt(y),_)}if(f.length===65){const h=kt(f.slice(0,32)),y=f.slice(32,64);e((y[0]&128)===0,"non-canonical s");const _=gi.getNormalizedV(f[64]);return new gi(Wc,h,kt(y),_)}e(!1,"invalid raw signature length")}if(t instanceof gi)return t.clone();const r=t.r;e(r!=null,"missing r");const i=Tv(r),s=function(f,h){if(f!=null)return Tv(f);if(h!=null){e(ze(h,32),"invalid yParityAndS");const y=ye(h);return y[0]&=127,kt(y)}e(!1,"missing s")}(t.s,t.yParityAndS);e((ye(s)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(f,h,y){if(f!=null){const _=Nt(f);return{networkV:_>=t0?_:void 0,v:gi.getNormalizedV(_)}}if(h!=null)return e(ze(h,32),"invalid yParityAndS"),{v:ye(h)[0]&128?28:27};if(y!=null){switch(oe(y,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}e(!1,"invalid yParity")}e(!1,"missing v")}(t.v,t.yParityAndS,t.yParity),u=new gi(Wc,i,s,a);return o&&F(u,ja,o),e(t.yParity==null||oe(t.yParity,"sig.yParity")===u.yParity,"yParity mismatch"),e(t.yParityAndS==null||t.yParityAndS===u.yParityAndS,"yParityAndS mismatch"),u}};Pu=new WeakMap,Mu=new WeakMap,Lu=new WeakMap,ja=new WeakMap;let Oi=gi;var Ps;const Ia=class Ia{constructor(t){J(this,Ps);K(mu(t)===32,"invalid private key","privateKey","[REDACTED]"),F(this,Ps,kt(t))}get privateKey(){return S(this,Ps)}get publicKey(){return Ia.computePublicKey(S(this,Ps))}get compressedPublicKey(){return Ia.computePublicKey(S(this,Ps),!0)}sign(t){K(mu(t)===32,"invalid digest length","digest",t);const e=_o.sign(dr(t),dr(S(this,Ps)),{lowS:!0});return Oi.from({r:aa(e.r,32),s:aa(e.s,32),v:e.recovery?28:27})}computeSharedSecret(t){const e=Ia.computePublicKey(t);return kt(_o.getSharedSecret(dr(S(this,Ps)),ye(e),!1))}static computePublicKey(t,e){let r=ye(t,"key");if(r.length===32){const s=_o.getPublicKey(r,!!e);return kt(s)}if(r.length===64){const s=new Uint8Array(65);s[0]=4,s.set(r,1),r=s}const i=_o.ProjectivePoint.fromHex(r);return kt(i.toRawBytes(e))}static recoverPublicKey(t,e){K(mu(t)===32,"invalid digest length","digest",t);const r=Oi.from(e);let i=_o.Signature.fromCompact(dr(In([r.r,r.s])));i=i.addRecoveryBit(r.yParity);const s=i.recoverPublicKey(dr(t));return K(s!=null,"invalid signautre for digest","signature",e),"0x"+s.toHex(!1)}static addPoints(t,e,r){const i=_o.ProjectivePoint.fromHex(Ia.computePublicKey(t).substring(2)),s=_o.ProjectivePoint.fromHex(Ia.computePublicKey(e).substring(2));return"0x"+i.add(s).toHex(!!r)}};Ps=new WeakMap;let kh=Ia;const _j=BigInt(0),Aj=BigInt(36);function Ov(n){n=n.toLowerCase();const t=n.substring(2).split(""),e=new Uint8Array(40);for(let i=0;i<40;i++)e[i]=t[i].charCodeAt(0);const r=ye(Tn(e));for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(r[i>>1]&15)>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}const bb={};for(let n=0;n<10;n++)bb[String(n)]=String(n);for(let n=0;n<26;n++)bb[String.fromCharCode(65+n)]=String(10+n);const Nv=15;function Ej(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let t=n.split("").map(r=>bb[r]).join("");for(;t.length>=Nv;){let r=t.substring(0,Nv);t=parseInt(r,10)%97+t.substring(r.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}const vj=function(){const n={};for(let t=0;t<36;t++){const e="0123456789abcdefghijklmnopqrstuvwxyz"[t];n[e]=BigInt(t)}return n}();function xj(n){n=n.toLowerCase();let t=_j;for(let e=0;e<n.length;e++)t=t*Aj+vj[n[e]];return t}function Me(n){if(K(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const t=Ov(n);return K(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===n,"bad address checksum","address",n),t}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){K(n.substring(2,4)===Ej(n),"bad icap checksum","address",n);let t=xj(n.substring(4)).toString(16);for(;t.length<40;)t="0"+t;return Ov("0x"+t)}K(!1,"invalid address","address",n)}function Rj(n){const t=Me(n.from);let r=Nt(n.nonce,"tx.nonce").toString(16);return r==="0"?r="0x":r.length%2?r="0x0"+r:r="0x"+r,Me(_n(Tn(Ec([t,r])),12))}function cT(n){return n&&typeof n.getAddress=="function"}async function Rm(n,t){const e=await t;return(e==null||e==="0x0000000000000000000000000000000000000000")&&(ht(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),K(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),Me(e)}function wr(n,t){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?Me(n):(ht(t!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Rm(n,t.resolveName(n)));if(cT(n))return Rm(n,n.getAddress());if(n&&typeof n.then=="function")return Rm(n,n);K(!1,"unsupported addressable value","target",n)}const Es={};function It(n,t){let e=!1;return t<0&&(e=!0,t*=-1),new cr(Es,`${e?"":"u"}int${t}`,n,{signed:e,width:t})}function we(n,t){return new cr(Es,`bytes${t||""}`,n,{size:t})}const Cv=Symbol.for("_ethers_typed");var Wa;const vs=class vs{constructor(t,e,r,i){Z(this,"type");Z(this,"value");J(this,Wa);Z(this,"_typedSymbol");i==null&&(i=null),Yp(Es,t,"Typed"),$t(this,{_typedSymbol:Cv,type:e,value:r}),F(this,Wa,i),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(t=>t.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return S(this,Wa)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return S(this,Wa)===!0?-1:S(this,Wa)===!1?this.value.length:null}static from(t,e){return new vs(Es,t,e)}static uint8(t){return It(t,8)}static uint16(t){return It(t,16)}static uint24(t){return It(t,24)}static uint32(t){return It(t,32)}static uint40(t){return It(t,40)}static uint48(t){return It(t,48)}static uint56(t){return It(t,56)}static uint64(t){return It(t,64)}static uint72(t){return It(t,72)}static uint80(t){return It(t,80)}static uint88(t){return It(t,88)}static uint96(t){return It(t,96)}static uint104(t){return It(t,104)}static uint112(t){return It(t,112)}static uint120(t){return It(t,120)}static uint128(t){return It(t,128)}static uint136(t){return It(t,136)}static uint144(t){return It(t,144)}static uint152(t){return It(t,152)}static uint160(t){return It(t,160)}static uint168(t){return It(t,168)}static uint176(t){return It(t,176)}static uint184(t){return It(t,184)}static uint192(t){return It(t,192)}static uint200(t){return It(t,200)}static uint208(t){return It(t,208)}static uint216(t){return It(t,216)}static uint224(t){return It(t,224)}static uint232(t){return It(t,232)}static uint240(t){return It(t,240)}static uint248(t){return It(t,248)}static uint256(t){return It(t,256)}static uint(t){return It(t,256)}static int8(t){return It(t,-8)}static int16(t){return It(t,-16)}static int24(t){return It(t,-24)}static int32(t){return It(t,-32)}static int40(t){return It(t,-40)}static int48(t){return It(t,-48)}static int56(t){return It(t,-56)}static int64(t){return It(t,-64)}static int72(t){return It(t,-72)}static int80(t){return It(t,-80)}static int88(t){return It(t,-88)}static int96(t){return It(t,-96)}static int104(t){return It(t,-104)}static int112(t){return It(t,-112)}static int120(t){return It(t,-120)}static int128(t){return It(t,-128)}static int136(t){return It(t,-136)}static int144(t){return It(t,-144)}static int152(t){return It(t,-152)}static int160(t){return It(t,-160)}static int168(t){return It(t,-168)}static int176(t){return It(t,-176)}static int184(t){return It(t,-184)}static int192(t){return It(t,-192)}static int200(t){return It(t,-200)}static int208(t){return It(t,-208)}static int216(t){return It(t,-216)}static int224(t){return It(t,-224)}static int232(t){return It(t,-232)}static int240(t){return It(t,-240)}static int248(t){return It(t,-248)}static int256(t){return It(t,-256)}static int(t){return It(t,-256)}static bytes1(t){return we(t,1)}static bytes2(t){return we(t,2)}static bytes3(t){return we(t,3)}static bytes4(t){return we(t,4)}static bytes5(t){return we(t,5)}static bytes6(t){return we(t,6)}static bytes7(t){return we(t,7)}static bytes8(t){return we(t,8)}static bytes9(t){return we(t,9)}static bytes10(t){return we(t,10)}static bytes11(t){return we(t,11)}static bytes12(t){return we(t,12)}static bytes13(t){return we(t,13)}static bytes14(t){return we(t,14)}static bytes15(t){return we(t,15)}static bytes16(t){return we(t,16)}static bytes17(t){return we(t,17)}static bytes18(t){return we(t,18)}static bytes19(t){return we(t,19)}static bytes20(t){return we(t,20)}static bytes21(t){return we(t,21)}static bytes22(t){return we(t,22)}static bytes23(t){return we(t,23)}static bytes24(t){return we(t,24)}static bytes25(t){return we(t,25)}static bytes26(t){return we(t,26)}static bytes27(t){return we(t,27)}static bytes28(t){return we(t,28)}static bytes29(t){return we(t,29)}static bytes30(t){return we(t,30)}static bytes31(t){return we(t,31)}static bytes32(t){return we(t,32)}static address(t){return new vs(Es,"address",t)}static bool(t){return new vs(Es,"bool",!!t)}static bytes(t){return new vs(Es,"bytes",t)}static string(t){return new vs(Es,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new vs(Es,"overrides",Object.assign({},t))}static isTyped(t){return t&&typeof t=="object"&&"_typedSymbol"in t&&t._typedSymbol===Cv}static dereference(t,e){if(vs.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}};Wa=new WeakMap;let cr=vs;class Ij extends so{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=cr.dereference(e,"string");try{r=Me(r)}catch(i){return this._throwError(i.message,e)}return t.writeValue(r)}decode(t){return Me(aa(t.readValue(),20))}}class Sj extends so{constructor(e){super(e.name,e.type,"_",e.dynamic);Z(this,"coder");this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,r){return this.coder.encode(e,r)}decode(e){return this.coder.decode(e)}}function uT(n,t,e){let r=[];if(Array.isArray(e))r=e;else if(e&&typeof e=="object"){let u={};r=t.map(f=>{const h=f.localName;return ht(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:f},value:e}),ht(!u[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:f},value:e}),u[h]=!0,e[h]})}else K(!1,"invalid tuple value","tuple",e);K(t.length===r.length,"types/value length mismatch","tuple",e);let i=new Iw,s=new Iw,o=[];t.forEach((u,f)=>{let h=r[f];if(u.dynamic){let y=s.length;u.encode(s,h);let _=i.writeUpdatableValue();o.push(w=>{_(w+y)})}else u.encode(i,h)}),o.forEach(u=>{u(i.length)});let a=n.appendWriter(i);return a+=n.appendWriter(s),a}function lT(n,t){let e=[],r=[],i=n.subReader(0);return t.forEach(s=>{let o=null;if(s.dynamic){let a=n.readIndex(),u=i.subReader(a);try{o=s.decode(u)}catch(f){if(Zn(f,"BUFFER_OVERRUN"))throw f;o=f,o.baseType=s.name,o.name=s.localName,o.type=s.type}}else try{o=s.decode(n)}catch(a){if(Zn(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=s.name,o.name=s.localName,o.type=s.type}if(o==null)throw new Error("investigate");e.push(o),r.push(s.localName||null)}),Il.fromItems(e,r)}class kj extends so{constructor(e,r,i){const s=e.type+"["+(r>=0?r:"")+"]",o=r===-1||e.dynamic;super("array",s,i,o);Z(this,"coder");Z(this,"length");$t(this,{coder:e,length:r})}defaultValue(){const e=this.coder.defaultValue(),r=[];for(let i=0;i<this.length;i++)r.push(e);return r}encode(e,r){const i=cr.dereference(r,"array");Array.isArray(i)||this._throwError("expected array value",i);let s=this.length;s===-1&&(s=i.length,e.writeValue(i.length)),bk(i.length,s,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<i.length;a++)o.push(this.coder);return uT(e,o,i)}decode(e){let r=this.length;r===-1&&(r=e.readIndex(),ht(r*mr<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:r*mr,length:e.dataLength}));let i=[];for(let s=0;s<r;s++)i.push(new Sj(this.coder));return lT(e,i)}}class Tj extends so{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=cr.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class fT extends so{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=dr(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class Oj extends fT{constructor(t){super("bytes",t)}decode(t){return kt(super.decode(t))}}class Nj extends so{constructor(e,r){let i="bytes"+String(e);super(i,i,r,!1);Z(this,"size");$t(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,r){let i=dr(cr.dereference(r,this.type));return i.length!==this.size&&this._throwError("incorrect data length",r),e.writeBytes(i)}decode(e){return kt(e.readBytes(this.size))}}const Cj=new Uint8Array([]);class Bj extends so{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return e!=null&&this._throwError("not null",e),t.writeBytes(Cj)}decode(t){return t.readBytes(0),null}}const Pj=BigInt(0),Mj=BigInt(1),Lj=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class Uj extends so{constructor(e,r,i){const s=(r?"int":"uint")+e*8;super(s,s,i,!1);Z(this,"size");Z(this,"signed");$t(this,{size:e,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,r){let i=Nt(cr.dereference(r,this.type)),s=Uf(Lj,mr*8);if(this.signed){let o=Uf(s,this.size*8-1);(i>o||i<-(o+Mj))&&this._throwError("value out-of-bounds",r),i=Ek(i,8*mr)}else(i<Pj||i>Uf(s,this.size*8))&&this._throwError("value out-of-bounds",r);return e.writeValue(i)}decode(e){let r=Uf(e.readValue(),this.size*8);return this.signed&&(r=PV(r,this.size*8)),r}}class Dj extends fT{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,Js(cr.dereference(e,"string")))}decode(t){return Z0(super.decode(t))}}class e0 extends so{constructor(e,r){let i=!1;const s=[];e.forEach(a=>{a.dynamic&&(i=!0),s.push(a.type)});const o="tuple("+s.join(",")+")";super("tuple",o,r,i);Z(this,"coders");$t(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach(i=>{e.push(i.defaultValue())});const r=this.coders.reduce((i,s)=>{const o=s.localName;return o&&(i[o]||(i[o]=0),i[o]++),i},{});return this.coders.forEach((i,s)=>{let o=i.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),e[o]==null&&(e[o]=e[s]))}),Object.freeze(e)}encode(e,r){const i=cr.dereference(r,"tuple");return uT(e,this.coders,i)}decode(e){return lT(e,this.coders)}}function vc(n){return Tn(Js(n))}var Fj="AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3YQZtAm0A+VEfAzEJDQBRSQCzAQBlAHsAM70GD/v3IZWHBwARKQAxALsjTwHZAeMPEzmXgIHwABIAGQA8AEUAQDt3gdvIEGcQZAkGTRFMdEIVEwK0D64L7REdDNkq09PgADSxB/MDWwfzA1sDWwfzB/MDWwfzA1sDWwNbA1scEvAi28gQZw9QBHUFlgWTBN4IiyZREYkHMAjaVBV0JhxPA00BBCMtSSQ7mzMTJUpMFE0LCAQ2SmyvfUADTzGzVP2QqgPTMlc5dAkGHnkSqAAyD3skNb1OhnpPcagKU0+2tYdJak5vAsY6sEAACikJm2/Dd1YGRRAfJ6kQ+ww3AbkBPw3xS9wE9QY/BM0fgRkdD9GVoAipLeEM8SbnLqWAXiP5KocF8Uv4POELUVFsD10LaQnnOmeBUgMlAREijwrhDT0IcRD3Cs1vDekRSQc9A9lJngCpBwULFR05FbkmFGKwCw05ewb/GvoLkyazEy17AAXXGiUGUQEtGwMA0y7rhbRaNVwgT2MGBwspI8sUrFAkDSlAu3hMGh8HGSWtApVDdEqLUToelyH6PEENai4XUYAH+TwJGVMLhTyiRq9FEhHWPpE9TCJNTDAEOYMsMyePCdMPiQy9fHYBXQklCbUMdRM1ERs3yQg9Bx0xlygnGQglRplgngT7owP3E9UDDwVDCUUHFwO5HDETMhUtBRGBKNsC9zbZLrcCk1aEARsFzw8pH+MQVEfkDu0InwJpA4cl7wAxFSUAGyKfCEdnAGOP3FMJLs8Iy2pwI3gDaxTrZRF3B5UOWwerHDcVwxzlcMxeD4YMKKezCV8BeQmdAWME5wgNNV+MpCBFZ1eLXBifIGVBQ14AAjUMaRWjRMGHfAKPD28SHwE5AXcHPQ0FAnsR8RFvEJkI74YINbkz/DopBFMhhyAVCisDU2zSCysm/Qz8bQGnEmYDEDRBd/Jnr2C6KBgBBx0yyUFkIfULlk/RDKAaxRhGVDIZ6AfDA/ca9yfuQVsGAwOnBxc6UTPyBMELbQiPCUMATQ6nGwfbGG4KdYzUATWPAbudA1uVhwJzkwY7Bw8Aaw+LBX3pACECqwinAAkA0wNbAD0CsQehAB0AiUUBQQMrMwEl6QKTA5cINc8BmTMB9y0EH8cMGQD7O25OAsO1AoBuZqYF4VwCkgJNOQFRKQQJUktVA7N15QDfAE8GF+NLARmvTs8e50cB43MvAMsA/wAJOQcJRQHRAfdxALsBYws1Caa3uQFR7S0AhwAZbwHbAo0A4QA5AIP1AVcAUQVd/QXXAlNNARU1HC9bZQG/AyMBNwERAH0Gz5GpzQsjBHEH1wIQHxXlAu8yB7kFAyLjE9FCyQK94lkAMhoKPAqrCqpgX2Q3CjV2PVQAEh+sPss/UgVVO1c7XDtXO1w7VztcO1c7XDtXO1wDm8Pmw+YKcF9JYe8Mqg3YRMw6TRPfYFVgNhPMLbsUxRXSJVoZQRrAJwkl6FUNDwgt12Y0CDA0eRfAAEMpbINFY4oeNApPHOtTlVT8LR8AtUumM7MNsBsZREQFS3XxYi4WEgomAmSFAmJGX1GzAV83JAKh+wJonAJmDQKfiDgfDwJmPwJmKgRyBIMDfxcDfpY5Cjl7GzmGOicnAmwhAjI6OA4CbcsCbbLzjgM3a0kvAWsA4gDlAE4JB5wMkQECD8YAEbkCdzMCdqZDAnlPRwJ4viFg30WyRvcCfEMCeswCfQ0CfPRIBEiBZygALxlJXEpfGRtK0ALRBQLQ0EsrA4hTA4fqRMmRNgLypV0HAwOyS9JMMSkH001QTbMCi0MCitzFHwshR2sJuwKOOwKOYESbhQKO3QKOYHxRuFM5AQ5S2FSJApP/ApMQAO0AIFUiVbNV1AosHymZijLleGpFPz0Cl6MC77ZYJawAXSkClpMCloCgAK1ZsFoNhVEAPwKWuQKWUlxIXNUCmc8CmWhczl0LHQKcnznGOqECnBoCn58CnryOACETNS4TAp31Ap6WALlBYThh8wKe1wKgcgGtAp6jIwKeUqljzGQrKS8CJ7MCJoICoP8CoFDbAqYzAqXSAqgDAIECp/ZogGi1AAdNaiBq1QKs5wKssgKtawKtBgJXIQJV4AKx5dsDH1JsmwKywRECsuwbbORtZ21MYwMl0QK2YD9DbpQDKUkCuGICuUsZArkue3A6cOUCvR0DLbYDMhUCvoxyBgMzdQK+HnMmc1MCw88CwwhzhnRPOUl05AM8qwEDPJ4DPcMCxYACxksCxhSNAshtVQLISALJUwLJMgJkoQLd1nh9ZXiyeSlL1AMYp2cGAmH4GfeVKHsPXpZevxUCz28Cz3AzT1fW9xejAMqxAs93AS3uA04Wfk8JAtwrAtuOAtJTA1JgA1NjAQUDVZCAjUMEzxrxZEl5A4LSg5EC2ssC2eKEFIRNp0ADhqkAMwNkEoZ1Xf0AWQLfaQLevHd7AuIz7RgB8zQrAfSfAfLWiwLr9wLpdH0DAur9AuroAP1LAb0C7o0C66CWrpcHAu5DA4XkmH1w5HGlAvMHAG0DjhqZlwL3FwORcgOSiwL3nAL53QL4apogmq+/O5siA52HAv7+AR8APZ8gAZ+3AwWRA6ZuA6bdANXJAwZuoYyiCQ0DDE0BEwEjB3EGZb1rCQC/BG/DFY8etxEAG3k9ACcDNxJRA42DAWcrJQCM8wAlAOanC6OVCLsGI6fJBgCvBRnDBvElRUYFFoAFcD9GSDNCKUK8X3kZX8QAls0FOgCQVCGbwTsuYDoZutcONxjOGJHJ/gVfBWAFXwVgBWsFYAVfBWAFXwVgBV8FYAVfBWBOHQjfjW8KCgoKbF7xMwTRA7kGN8PDAMMEr8MA70gxFroFTj5xPnhCR0K+X30/X/AAWBkzswCNBsxzzASm70aCRS4rDDMeLz49fnXfcsH5GcoscQFz13Y4HwVnBXLJycnACNdRYwgICAqEXoWTxgA7P4kACxbZBu21Kw0AjMsTAwkVAOVtJUUsJ1JCuULESUArXy9gPi9AKwnJRQYKTD9LPoA+iT54PnkCkULEUUpDX9NWV3JVEjQAc1w3A3IBE3YnX+g7QiMJb6MKaiszRCUuQrNCxDPMCcwEX9EWJzYREBEEBwIHKn6l33JCNVIfybPJtAltydPUCmhBZw/tEKsZAJOVJU1CLRuxbUHOQAo7P0s+eEJHHA8SJVRPdGM0NVrpvBoKhfUlM0JHHGUQUhEWO1xLSj8MO0ucNAqJIzVCRxv9EFsqKyA4OQgNj2nwZgp5ZNFgE2A1K3YHS2AhQQojJmC7DgpzGG1WYFUZCQYHZO9gHWCdYIVgu2BTYJlwFh8GvRbcXbG8YgtDHrMBwzPVyQonHQgkCyYBgQJ0Ajc4nVqIAwGSCsBPIgDsK3SWEtIVBa5N8gGjAo+kVwVIZwD/AEUSCDweX4ITrRQsJ8K3TwBXFDwEAB0TvzVcAtoTS20RIwDgVgZ9BBImYgA5AL4Coi8LFnezOkCnIQFjAY4KBAPh9RcGsgZSBsEAJctdsWIRu2kTkQstRw7DAcMBKgpPBGIGMDAwKCYnKTQaLg4AKRSVAFwCdl+YUZ0JdicFD3lPAdt1F9ZZKCGxuE3yBxkFVGcA/wBFEgiCBwAOLHQSjxOtQDg1z7deFRMAZ8QTAGtKb1ApIiPHADkAvgKiLy1DFtYCmBiDAlDDWNB0eo7fpaMO/aEVRRv0ATEQZBIODyMEAc8JQhCbDRgzFD4TAEMAu9YBCgCsAOkAm5I3ABwAYxvONnR+MhXJAxgKQyxL2+kkJhMbhQKDBMkSsvF0AD9BNQ6uQC7WqSQHwxEAEEIu1hkhAH2z4iQPwyJPHNWpdyYBRSpnJALzoBAEVPPsH20MxA0CCEQKRgAFyAtFAlMNwwjEDUQJRArELtapMg7DDZgJIw+TGukEIwvDFkMAqAtDEMMMBhioe+QAO3MMRAACrgnEBSPY9Q0FDnbSBoMAB8MSYxkSxAEJAPIJAAB8FWMOFtMc/HcXwxhDAC7DAvOowwAewwJdKDKHAAHDAALrFUQVwwAbwyvzpWMWv8wA/ABpAy++bcYDUKPD0KhDCwKmJ1MAAmMA5+UZwxAagwipBRL/eADfw6fDGOMCGsOjk3l6BwOpo4sAEsMOGxMAA5sAbcMOAAvDp0MJGkMDwgipnNIPAwfIqUMGAOGDAAPzABXDAAcDAAnDAGmTABrDAA7DChjDjnEWAwABYwAOcwAuUyYABsMAF8MIKQANUgC6wy4AA8MADqMq8wCyYgAcIwAB8wqpAAXOCx0V4wAHowBCwwEKAGnDAAuDAB3DAAjDCakABdIAbqcZ3QCZCCkABdIAAAFDAAfjAB2jCCkABqIACYMAGzMAbSMA5sOIAAhjAAhDABTDBAkpAAbSAOOTAAlDC6kOzPtnAAdDAG6kQFAATwAKwwwAA0MACbUDPwAHIwAZgwACE6cDAAojAApDAAoDp/MGwwAJIwADEwAQQwgAFEMAEXMAD5MADfMADcMAGRMOFiMAFUMAbqMWuwHDAMIAE0MLAGkzEgDhUwACQwAEWgAXgwUjAAbYABjDBSYBgzBaAEFNALcQBxUMegAwMngBrA0IZgJ0KxQHBREPd1N0ZzKRJwaIHAZqNT4DqQq8BwngAB4DAwt2AX56T1ocKQNXAh1GATQGC3tOxYNagkgAMQA5CQADAQEAWxLjAIOYNAEzAH7tFRk6TglSAF8NAAlYAQ+S1ACAQwQorQBiAN4dAJ1wPyeTANVzuQDX3AIeEMp9eyMgXiUAEdkBkJizKltbVVAaRMqRAAEAhyQ/SDEz6BmfVwB6ATEsOClKIRcDOF0E/832AFNt5AByAnkCRxGCOs94NjXdAwINGBonDBwPALW2AwICAgAAAAAAAAYDBQMDARrUAwAtAAAAAgEGBgYGBgYFBQUFBQUEBQYHCAkEBQUFBQQAAAICAAAAIgCNAJAAlT0A6gC7ANwApEQAwgCyAK0AqADuAKYA2gCjAOcBCAEDAMcAgQBiANIA1AEDAN4A8gCQAKkBMQDqAN8A3AsBCQ8yO9ra2tq8xuLT1tRJOB0BUgFcNU0BWgFpAWgBWwFMUUlLbhMBUxsNEAs6PhMOACcUKy0vMj5AQENDQ0RFFEYGJFdXV1dZWVhZL1pbXVxcI2NnZ2ZoZypsbnZ1eHh4eHh4enp6enp6enp6enp8fH18e2IARPIASQCaAHgAMgBm+ACOAFcAVwA3AnbvAIsABfj4AGQAk/IAnwBPAGIAZP//sACFAIUAaQBWALEAJAC2AIMCQAJDAPwA5wD+AP4A6AD/AOkA6QDoAOYALwJ7AVEBQAE+AVQBPgE+AT4BOQE4ATgBOAEcAVgXADEQCAEAUx8SHgsdHhYAjgCWAKYAUQBqIAIxAHYAbwCXAxUDJzIDIUlGTzEAkQJPAMcCVwKkAMAClgKWApYClgKWApYCiwKWApYClgKWApYClgKVApUCmAKgApcClgKWApQClAKUApQCkgKVAnUB1AKXAp8ClgKWApUeAIETBQD+DQOfAmECOh8BVBg9AuIZEjMbAU4/G1WZAXusRAFpYQEFA0FPAQYAmTEeIJdyADFoAHEANgCRA5zMk/C2jGINwjMWygIZCaXdfDILBCs5dAE7YnQBugDlhoiHhoiGiYqKhouOjIaNkI6Ij4qQipGGkoaThpSSlYaWhpeKmIaZhpqGm4aci52QnoqfhuIC4XTpAt90AIp0LHSoAIsAdHQEQwRABEIERQRDBEkERgRBBEcESQRIBEQERgRJAJ5udACrA490ALxuAQ10ANFZdHQA13QCFHQA/mJ0AP4BIQD+APwA/AD9APwDhGZ03ASMK23HAP4A/AD8AP0A/CR0dACRYnQA/gCRASEA/gCRAvQA/gCRA4RmdNwEjCttxyR0AP9idAEhAP4A/gD8APwA/QD8AP8A/AD8AP0A/AOEZnTcBIwrbcckdHQAkWJ0ASEA/gCRAP4AkQL0AP4AkQOEZnTcBIwrbcckdAJLAT50AlIBQXQCU8l0dAJfdHQDpgL0A6YDpgOnA6cDpwOnA4RmdNwEjCttxyR0dACRYnQBIQOmAJEDpgCRAvQDpgCRA4RmdNwEjCttxyR0BDh0AJEEOQCRDpU5dSgCADR03gV2CwArdAEFAM5iCnR0AF1iAAYcOgp0dACRCnQAXAEIwWZ0CnRmdHQAkWZ0CnRmdEXgAFF03gp0dEY0tlT2u3SOAQTwscwhjZZKrhYcBSfFp9XNbKiVDOD2b+cpe4/Z17mQnbtzzhaeQtE2GGj0IDNTjRUSyTxxw/RPHW/+vS7d1NfRt9z9QPZg4X7QFfhCnkvgNPIItOsC2eV6hPannZNHlZ9xrwZXIMOlu3jSoQSq78WEjwLjw1ELSlF1aBvfzwk5ZX7AUvQzjPQKbDuQ+sm4wNOp4A6AdVuRS0t1y/DZpg4R6m7FNjM9HgvW7Bi88zaMjOo6lM8wtBBdj8LP4ylv3zCXPhebMKJc066o9sF71oFW/8JXu86HJbwDID5lzw5GWLR/LhT0Qqnp2JQxNZNfcbLIzPy+YypqRm/lBmGmex+82+PisxUumSeJkALIT6rJezxMH+CTJmQtt5uwTVbL3ptmjDUQzlSIvWi8Tl7ng1NpuRn1Ng4n14Qc+3Iil7OwkvNWogLSPkn3pihIFytyIGmMhOe3n1tWsuMy9BdKyqF4Z3v2SgggTL9KVvMXPnCbRe+oOuFFP3HejBG/w9gvmfNYvg6JuWia2lcSSN1uIjBktzoIazOHPJZ7kKHPz8mRWVdW3lA8WGF9dQF6Bm673boov3BUWDU2JNcahR23GtfHKLOz/viZ+rYnZFaIznXO67CYEJ1fXuTRpZhYZkKe54xeoagkNGLs+NTZHE0rX45/XvQ2RGADX6vcAvdxIUBV27wxGm2zjZo4X3ILgAlrOFheuZ6wtsvaIj4yLY7qqawlliaIcrz2G+c3vscAnCkCuMzMmZvMfu9lLwTvfX+3cVSyPdN9ZwgDZhfjRgNJcLiJ67b9xx8JHswprbiE3v9UphotAPIgnXVIN5KmMc0piXhc6cChPnN+MRhG9adtdttQTTwSIpl8I4/j//d3sz1326qTBTpPRM/Hgh3kzqEXs8ZAk4ErQhNO8hzrQ0DLkWMA/N+91tn2MdOJnWC2FCZehkQrwzwbKOjhvZsbM95QoeL9skYyMf4srVPVJSgg7pOLUtr/n9eT99oe9nLtFRpjA9okV2Kj8h9k5HaC0oivRD8VyXkJ81tcd4fHNXPCfloIQasxsuO18/46dR2jgul/UIet2G0kRvnyONMKhHs6J26FEoqSqd+rfYjeEGwHWVDpX1fh1jBBcKGMqRepju9Y00mDVHC+Xdij/j44rKfvfjGinNs1jO/0F3jB83XCDINN/HB84axlP+3E/klktRo+vl3U/aiyMJbIodE1XSsDn6UAzIoMtUObY2+k/4gY/l+AkZJ5Sj2vQrkyLm3FoxjhDX+31UXBFf9XrAH31fFqoBmDEZvhvvpnZ87N+oZEu7U9O/nnk+QWj3x8uyoRbEnf+O5UMr9i0nHP38IF5AvzrBW8YWBUR0mIAzIvndQq9N3v/Jto3aPjPXUPl8ASdPPyAp7jENf8bk7VMM9ol9XGmlBmeDMuGqt+WzuL6CXAxXjIhCPM5vACchgMJ/8XBGLO/D1isVvGhwwHHr1DLaI5mn2Jr/b1pUD90uciDaS8cXNDzCWvNmT/PhQe5e8nTnnnkt8Ds/SIjibcum/fqDhKopxAY8AkSrPn+IGDEKOO+U3XOP6djFs2H5N9+orhOahiQk5KnEUWa+CzkVzhp8bMHRbg81qhjjXuIKbHjSLSIBKWqockGtKinY+z4/RdBUF6pcc3JmnlxVcNgrI4SEzKUZSwcD2QCyxzKve+gAmg6ZuSRkpPFa6mfThu7LJNu3H5K42uCpNvPAsoedolKV/LHe/eJ+BbaG5MG0NaSGVPRUmNFMFFSSpXEcXwbVh7UETOZZtoVNRGOIbbkig3McEtR68cG0RZAoJevWYo7Dg/lZ1CQzblWeUvVHmr8fY4Nqd9JJiH/zEX24mJviH60fAyFr0A3c4bC1j3yZU60VgJxXn8JgJXLUIsiBnmKmMYz+7yBQFBvqb2eYnuW59joZBf56/wXvWIR4R8wTmV80i1mZy+S4+BUES+hzjk0uXpC///z/IlqHZ1monzlXp8aCfhGKMti73FI1KbL1q6IKO4fuBuZ59gagjn5xU79muMpHXg6S+e+gDM/U9BKLHbl9l6o8czQKl4RUkJJiqftQG2i3BMg/TQlUYFkJDYBOOvAugYuzYSDnZbDDd/aSd9x0Oe6F+bJcHfl9+gp6L5/TgA+BdFFovbfCrQ40s5vMPw8866pNX8zyFGeFWdxIpPVp9Rg1UPOVFbFZrvaFq/YAzHQgqMWpahMYfqHpmwXfHL1/kpYmGuHFwT55mQu0dylfNuq2Oq0hTMCPwqfxnuBIPLXfci4Y1ANy+1CUipQxld/izVh16WyG2Q0CQQ9NqtAnx1HCHwDj7sYxOSB0wopZSnOzxQOcExmxrVTF2BkOthVpGfuhaGECfCJpJKpjnihY+xOT2QJxN61+9K6QSqtv2Shr82I3jgJrqBg0wELFZPjvHpvzTtaJnLK6Vb97Yn933koO/saN7fsjwNKzp4l2lJVx2orjCGzC/4ZL4zCver6aQYtC5sdoychuFE6ufOiog+VWi5UDkbmvmtah/3aArEBIi39s5ILUnlFLgilcGuz9CQshEY7fw2ouoILAYPVT/gyAIq3TFAIwVsl+ktkRz/qGfnCDGrm5gsl/l9QdvCWGsjPz3dU7XuqKfdUrr/6XIgjp4rey6AJBmCmUJMjITHVdFb5m1p+dLMCL8t55zD42cmftmLEJC0Da04YiRCVUBLLa8D071/N5UBNBXDh0LFsmhV/5B5ExOB4j3WVG/S3lfK5o+V6ELHvy6RR9n4ac+VsK4VE4yphPvV+kG9FegTBH4ZRXL2HytUHCduJazB/KykjfetYxOXTLws267aGOd+I+JhKP//+VnXmS90OD/jvLcVu0asyqcuYN1mSb6XTlCkqv1vigZPIYwNF/zpWcT1GR/6aEIRjkh0yhg4LXJfaGobYJTY4JI58KiAKgmmgAKWdl5nYCeLqavRJGQNuYuZtZFGx+IkI4w4NS2xwbetNMunOjBu/hmKCI/w7tfiiyUd//4rbTeWt4izBY8YvGIN6vyKYmP/8X8wHKCeN+WRcKM70+tXKNGyevU9H2Dg5BsljnTf8YbsJ1TmMs74Ce2XlHisleguhyeg44rQOHZuw/6HTkhnnurK2d62q6yS7210SsAIaR+jXMQA+svkrLpsUY+F30Uw89uOdGAR6vo4FIME0EfVVeHTu6eKicfhSqOeXJhbftcd08sWEnNUL1C9fnprTgd83IMut8onVUF0hvqzZfHduPjbjwEXIcoYmy+P6tcJZHmeOv6VrvEdkHDJecjHuHeWANe79VG662qTjA/HCvumVv3qL+LrOcpqGps2ZGwQdFJ7PU4iuyRlBrwfO+xnPyr47s2cXVbWzAyznDiBGjCM3ksxjjqM62GE9C8f5U38kB3VjtabKp/nRdvMESPGDG90bWRLAt1Qk5DyLuazRR1YzdC1c+hZXvAWV8xA72S4A8B67vjVhbba3MMop293FeEXpe7zItMWrJG/LOH9ByOXmYnNJfjmfuX9KbrpgLOba4nZ+fl8Gbdv/ihv+6wFGKHCYrVwmhFC0J3V2bn2tIB1wCc1CST3d3X2OyxhguXcs4sm679UngzofuSeBewMFJboIQHbUh/m2JhW2hG9DIvG2t7yZIzKBTz9wBtnNC+2pCRYhSIuQ1j8xsz5VvqnyUIthvuoyyu7fNIrg/KQUVmGQaqkqZk/Vx5b33/gsEs8yX7SC1J+NV4icz6bvIE7C5G6McBaI8rVg56q5QBJWxn/87Q1sPK4+sQa8fLU5gXo4paaq4cOcQ4wR0VBHPGjKh+UlPCbA1nLXyEUX45qZ8J7/Ln4FPJE2TdzD0Z8MLSNQiykMMmSyOCiFfy84Rq60emYB2vD09KjYwsoIpeDcBDTElBbXxND72yhd9pC/1CMid/5HUMvAL27OtcIJDzNKpRPNqPOpyt2aPGz9QWIs9hQ9LiX5s8m9hjTUu/f7MyIatjjd+tSfQ3ufZxPpmJhTaBtZtKLUcfOCUqADuO+QoH8B9v6U+P0HV1GLQmtoNFTb3s74ivZgjES0qfK+8RdGgBbcCMSy8eBvh98+et1KIFqSe1KQPyXULBMTsIYnysIwiZBJYdI20vseV+wuJkcqGemehKjaAb9L57xZm3g2zX0bZ2xk/fU+bCo7TlnbW7JuF1YdURo/2Gw7VclDG1W7LOtas2LX4upifZ/23rzpsnY/ALfRgrcWP5hYmV9VxVOQA1fZvp9F2UNU+7d7xRyVm5wiLp3/0dlV7vdw1PMiZrbDAYzIVqEjRY2YU03sJhPnlwIPcZUG5ltL6S8XCxU1eYS5cjr34veBmXAvy7yN4ZjArIG0dfD/5UpBNlX1ZPoxJOwyqRi3wQWtOzd4oNKh0LkoTm8cwqgIfKhqqGOhwo71I+zXnMemTv2B2AUzABWyFztGgGULjDDzWYwJUVBTjKCn5K2QGMK1CQT7SzziOjo+BhAmqBjzuc3xYym2eedGeOIRJVyTwDw37iCMe4g5Vbnsb5ZBdxOAnMT7HU4DHpxWGuQ7GeiY30Cpbvzss55+5Km1YsbD5ea3NI9QNYIXol5apgSu9dZ8f8xS5dtHpido5BclDuLWY4lhik0tbJa07yJhH0BOyEut/GRbYTS6RfiTYWGMCkNpfSHi7HvdiTglEVHKZXaVhezH4kkXiIvKopYAlPusftpE4a5IZwvw1x/eLvoDIh/zpo9FiQInsTb2SAkKHV42XYBjpJDg4374XiVb3ws4qM0s9eSQ5HzsMU4OZJKuopFjBM+dAZEl8RUMx5uU2N486Kr141tVsGQfGjORYMCJAMsxELeNT4RmWjRcpdTGBwcx6XN9drWqPmJzcrGrH4+DRc7+n1w3kPZwu0BkNr6hQrqgo7JTB9A5kdJ/H7P4cWBMwsmuixAzJB3yrQpnGIq90lxAXLzDCdn1LPibsRt7rHNjgQBklRgPZ8vTbjXdgXrTWQsK5MdrXXQVPp0Rinq3frzZKJ0qD6Qhc40VzAraUXlob1gvkhK3vpmHgI6FRlQZNx6eRqkp0zy4AQlX813fAPtL3jMRaitGFFjo0zmErloC+h+YYdVQ6k4F/epxAoF0BmqEoKNTt6j4vQZNQ2BoqF9Vj53TOIoNmDiu9Xp15RkIgQIGcoLpfoIbenzpGUAtqFJp5W+LLnx38jHeECTJ/navKY1NWfN0sY1T8/pB8kIH3DU3DX+u6W3YwpypBMYOhbSxGjq84RZ84fWJow8pyHqn4S/9J15EcCMsXqrfwyd9mhiu3+rEo9pPpoJkdZqHjra4NvzFwuThNKy6hao/SlLw3ZADUcUp3w3SRVfW2rhl80zOgTYnKE0Hs2qp1J6H3xqPqIkvUDRMFDYyRbsFI3M9MEyovPk8rlw7/0a81cDVLmBsR2ze2pBuKb23fbeZC0uXoIvDppfTwIDxk1Oq2dGesGc+oJXWJLGkOha3CX+DUnzgAp9HGH9RsPZN63Hn4RMA5eSVhPHO+9RcRb/IOgtW31V1Q5IPGtoxPjC+MEJbVlIMYADd9aHYWUIQKopuPOHmoqSkubnAKnzgKHqgIOfW5RdAgotN6BN+O2ZYHkuemLnvQ8U9THVrS1RtLmKbcC7PeeDsYznvqzeg6VCNwmr0Yyx1wnLjyT84BZz3EJyCptD3yeueAyDWIs0L2qs/VQ3HUyqfrja0V1LdDzqAikeWuV4sc7RLIB69jEIBjCkyZedoUHqCrOvShVzyd73OdrJW0hPOuQv2qOoHDc9xVb6Yu6uq3Xqp2ZaH46A7lzevbxQEmfrzvAYSJuZ4WDk1Hz3QX1LVdiUK0EvlAGAYlG3Md30r7dcPN63yqBCIj25prpvZP0nI4+EgWoFG95V596CurXpKRBGRjQlHCvy5Ib/iW8nZJWwrET3mgd6mEhfP4KCuaLjopWs7h+MdXFdIv8dHQJgg1xi1eYqB0uDYjxwVmri0Sv5XKut/onqapC+FQiC2C1lvYJ9MVco6yDYsS3AANUfMtvtbYI2hfwZatiSsnoUeMZd34GVjkMMKA+XnjJpXgRW2SHTZplVowPmJsvXy6w3cfO1AK2dvtZEKTkC/TY9LFiKHCG0DnrMQdGm2lzlBHM9iEYynH2UcVMhUEjsc0oDBTgo2ZSQ1gzkAHeWeBXYFjYLuuf8yzTCy7/RFR81WDjXMbq2BOH5dURnxo6oivmxL3cKzKInlZkD31nvpHB9Kk7GfcfE1t+1V64b9LtgeJGlpRFxQCAqWJ5DoY77ski8gsOEOr2uywZaoO/NGa0X0y1pNQHBi3b2SUGNpcZxDT7rLbBf1FSnQ8guxGW3W+36BW0gBje4DOz6Ba6SVk0xiKgt+q2JOFyr4SYfnu+Ic1QZYIuwHBrgzr6UvOcSCzPTOo7D6IC4ISeS7zkl4h+2VoeHpnG/uWR3+ysNgPcOIXQbv0n4mr3BwQcdKJxgPSeyuP/z1Jjg4e9nUvoXegqQVIE30EHx5GHv+FAVUNTowYDJgyFhf5IvlYmEqRif6+WN1MkEJmDcQITx9FX23a4mxy1AQRsOHO/+eImX9l8EMJI3oPWzVXxSOeHU1dUWYr2uAA7AMb+vAEZSbU3qob9ibCyXeypEMpZ6863o6QPqlqGHZkuWABSTVNd4cOh9hv3qEpSx2Zy/DJMP6cItEmiBJ5PFqQnDEIt3NrA3COlOSgz43D7gpNFNJ5MBh4oFzhDPiglC2ypsNU4ISywY2erkyb1NC3Qh/IfWj0eDgZI4/ln8WPfBsT3meTjq1Uqt1E7Zl/qftqkx6aM9KueMCekSnMrcHj1CqTWWzEzPsZGcDe3Ue4Ws+XFYVxNbOFF8ezkvQGR6ZOtOLU2lQEnMBStx47vE6Pb7AYMBRj2OOfZXfisjJnpTfSNjo6sZ6qSvNxZNmDeS7Gk3yYyCk1HtKN2UnhMIjOXUzAqDv90lx9O/q/AT1ZMnit5XQe9wmQxnE/WSH0CqZ9/2Hy+Sfmpeg8RwsHI5Z8kC8H293m/LHVVM/BA7HaTJYg5Enk7M/xWpq0192ACfBai2LA/qrCjCr6Dh1BIMzMXINBmX96MJ5Hn2nxln/RXPFhwHxUmSV0EV2V0jm86/dxxuYSU1W7sVkEbN9EzkG0QFwPhyHKyb3t+Fj5WoUUTErcazE/N6EW6Lvp0d//SDPj7EV9UdJN+Amnf3Wwk3A0SlJ9Z00yvXZ7n3z70G47Hfsow8Wq1JXcfwnA+Yxa5mFsgV464KKP4T31wqIgzFPd3eCe3j5ory5fBF2hgCFyVFrLzI9eetNXvM7oQqyFgDo4CTp/hDV9NMX9JDHQ/nyHTLvZLNLF6ftn2OxjGm8+PqOwhxnPHWipkE/8wbtyri80Sr7pMNkQGMfo4ZYK9OcCC4ESVFFbLMIvlxSoRqWie0wxqnLfcLSXMSpMMQEJYDVObYsXIQNv4TGNwjq1kvT1UOkicTrG3IaBZ3XdScS3u8sgeZPVpOLkbiF940FjbCeNRINNvDbd01EPBrTCPpm12m43ze1bBB59Ia6Ovhnur/Nvx3IxwSWol+3H2qfCJR8df6aQf4v6WiONxkK+IqT4pKQrZK/LplgDI/PJZbOep8dtbV7oCr6CgfpWa8NczOkPx81iSHbsNhVSJBOtrLIMrL31LK9TqHqAbAHe0RLmmV806kRLDLNEhUEJfm9u0sxpkL93Zgd6rw+tqBfTMi59xqXHLXSHwSbSBl0EK0+loECOPtrl+/nsaFe197di4yUgoe4jKoAJDXc6DGDjrQOoFDWZJ9HXwt8xDrQP+7aRwWKWI1GF8s8O4KzxWBBcwnl3vnl1Oez3oh6Ea1vjR7/z7DDTrFtqU2W/KAEzAuXDNZ7MY73MF216dzdSbWmUp4lcm7keJfWaMHgut9x5C9mj66Z0lJ+yhsjVvyiWrfk1lzPOTdhG15Y7gQlXtacvI7qv/XNSscDwqkgwHT/gUsD5yB7LdRRvJxQGYINn9hTpodKFVSTPrtGvyQw+HlRFXIkodErAGu9Iy1YpfSPc3jkFh5CX3lPxv7aqjE/JAfTIpEjGb/H7MO0e2vsViSW1qa/Lmi4/n4DEI3g7lYrcanspDfEpKkdV1OjSLOy0BCUqVoECaB55vs06rXl4jqmLsPsFM/7vYJ0vrBhDCm/00A/H81l1uekJ/6Lml3Hb9+NKiLqATJmDpyzfYZFHumEjC662L0Bwkxi7E9U4cQA0XMVDuMYAIeLMPgQaMVOd8fmt5SflFIfuBoszeAw7ow5gXPE2Y/yBc/7jExARUf/BxIHQBF5Sn3i61w4z5xJdCyO1F1X3+3ax+JSvMeZ7S6QSKp1Fp/sjYz6Z+VgCZzibGeEoujryfMulH7Rai5kAft9ebcW50DyJr2uo2z97mTWIu45YsSnNSMrrNUuG1XsYBtD9TDYzQffKB87vWbkM4EbPAFgoBV4GQS+vtFDUqOFAoi1nTtmIOvg38N4hT2Sn8r8clmBCXspBlMBYTnrqFJGBT3wZOzAyJDre9dHH7+x7qaaKDOB4UQALD5ecS0DE4obubQEiuJZ0EpBVpLuYcce8Aa4PYd/V4DLDAJBYKQPCWTcrEaZ5HYbJi11Gd6hjGom1ii18VHYnG28NKpkz2UKVPxlhYSp8uZr367iOmoy7zsxehW9wzcy2zG0a80PBMCRQMb32hnaHeOR8fnNDzZhaNYhkOdDsBUZ3loDMa1YP0uS0cjUP3b/6DBlqmZOeNABDsLl5BI5QJups8uxAuWJdkUB/pO6Zax6tsg7fN5mjjDgMGngO+DPcKqiHIDbFIGudxtPTIyDi9SFMKBDcfdGQRv41q1AqmxgkVfJMnP8w/Bc7N9/TR6C7mGObFqFkIEom8sKi2xYqJLTCHK7cxzaZvqODo22c3wisBCP4HeAgcRbNPAsBkNRhSmD48dHupdBRw4mIvtS5oeF6zeT1KMCyhMnmhpkFAGWnGscoNkwvQ8ZM5lE/vgTHFYL99OuNxdFBxTEDd5v2qLR8y9WkXsWgG6kZNndFG+pO/UAkOCipqIhL3hq7cRSdrCq7YhUsTocEcnaFa6nVkhnSeRYUA1YO0z5itF9Sly3VlxYDw239TJJH6f3EUfYO5lb7bcFcz8Bp7Oo8QmnsUHOz/fagVUBtKEw1iT88j+aKkv8cscKNkMxjYr8344D1kFoZ7/td1W6LCNYN594301tUGRmFjAzeRg5vyoM1F6+bJZ/Q54jN/k8SFd3DxPTYaAUsivsBfgTn7Mx8H2SpPt4GOdYRnEJOH6jHM2p6SgB0gzIRq6fHxGMmSmqaPCmlfwxiuloaVIitLGN8wie2CDWhkzLoCJcODh7KIOAqbHEvXdUxaS4TTTs07Clzj/6GmVs9kiZDerMxEnhUB6QQPlcfqkG9882RqHoLiHGBoHfQuXIsAG8GTAtao2KVwRnvvam8jo1e312GQAKWEa4sUVEAMG4G6ckcONDwRcg1e2D3+ohXgY4UAWF8wHKQMrSnzCgfFpsxh+aHXMGtPQroQasRY4U6UdG0rz1Vjbka0MekOGRZQEvqQFlxseFor8zWFgHek3v29+WqN6gaK5gZOTOMZzpQIC1201LkMCXild3vWXSc5UX9xcFYfbRPzGFa1FDcPfPB/jUEq/FeGt419CI3YmBlVoHsa4KdcwQP5ZSwHHhFJ7/Ph/Rap/4vmG91eDwPP0lDfCDRCLszTqfzM71xpmiKi2HwS4WlqvGNwtvwF5Dqpn6KTq8ax00UMPkxDcZrEEEsIvHiUXXEphdb4GB4FymlPwBz4Gperqq5pW7TQ6/yNRhW8VT5NhuP0udlxo4gILq5ZxAZk8ZGh3g4CqxJlPKY7AQxupfUcVpWT5VItp1+30UqoyP4wWsRo3olRRgkWZZ2ZN6VC3OZFeXB8NbnUrSdikNptD1QiGuKkr8EmSR/AK9Rw+FF3s5uwuPbvHGiPeFOViltMK7AUaOsq9+x9cndk3iJEE5LKZRlWJbKOZweROzmPNVPkjE3K/TyA57Rs68TkZ3MR8akKpm7cFjnjPd/DdkWjgYoKHSr5Wu5ssoBYU4acRs5g2DHxUmdq8VXOXRbunD8QN0LhgkssgahcdoYsNvuXGUK/KXD/7oFb+VGdhqIn02veuM5bLudJOc2Ky0GMaG4W/xWBxIJcL7yliJOXOpx0AkBqUgzlDczmLT4iILXDxxtRR1oZa2JWFgiAb43obrJnG/TZC2KSK2wqOzRZTXavZZFMb1f3bXvVaNaK828w9TO610gk8JNf3gMfETzXXsbcvRGCG9JWQZ6+cDPqc4466Yo2RcKH+PILeKOqtnlbInR3MmBeGG3FH10yzkybuqEC2HSQwpA0An7d9+73BkDUTm30bZmoP/RGbgFN+GrCOfADgqr0WbI1a1okpFms8iHYw9hm0zUvlEMivBRxModrbJJ+9/p3jUdQQ9BCtQdxnOGrT5dzRUmw0593/mbRSdBg0nRvRZM5/E16m7ZHmDEtWhwvfdZCZ8J8M12W0yRMszXamWfQTwIZ4ayYktrnscQuWr8idp3PjT2eF/jmtdhIfcpMnb+IfZY2FebW6UY/AK3jP4u3Tu4zE4qlnQgLFbM19EBIsNf7KhjdbqQ/D6yiDb+NlEi2SKD+ivXVUK8ib0oBo366gXkR8ZxGjpJIDcEgZPa9TcYe0TIbiPl/rPUQDu3XBJ9X/GNq3FAUsKsll57DzaGMrjcT+gctp+9MLYXCq+sqP81eVQ0r9lt+gcQfZbACRbEjvlMskztZG8gbC8Qn9tt26Q7y7nDrbZq/LEz7kR6Jc6pg3N9rVX8Y5MJrGlML9p9lU4jbTkKqCveeZUJjHB03m2KRKR2TytoFkTXOLg7keU1s1lrPMQJpoOKLuAAC+y1HlJucU6ysB5hsXhvSPPLq5J7JtnqHKZ4vYjC4Vy8153QY+6780xDuGARsGbOs1WqzH0QS765rnSKEbbKlkO8oI/VDwUd0is13tKpqILu1mDJFNy/iJAWcvDgjxvusIT+PGz3ST/J9r9Mtfd0jpaGeiLYIqXc7DiHSS8TcjFVksi66PEkxW1z6ujbLLUGNNYnzOWpH8BZGK4bCK7iR+MbIv8ncDAz1u4StN3vTTzewr9IQjk9wxFxn+6N1ddKs0vffJiS08N3a4G1SVrlZ97Q/M+8G9fe5AP6d9/Qq4WRnORVhofPIKEdCr3llspUfE0oKIIYoByBRPh+bX1HLS3JWGJRhIvE1aW4NTd8ePi4Z+kXb+Z8snYfSNcqijhAgVsx4RCM54cXUiYkjeBmmC4ajOHrChoELscJJC7+9jjMjw5BagZKlgRMiSNYz7h7vvZIoQqbtQmspc0cUk1G/73iXtSpROl5wtLgQi0mW2Ex8i3WULhcggx6E1LMVHUsdc9GHI1PH3U2Ko0PyGdn9KdVOLm7FPBui0i9a0HpA60MsewVE4z8CAt5d401Gv6zXlIT5Ybit1VIA0FCs7wtvYreru1fUyW3oLAZ/+aTnZrOcYRNVA8spoRtlRoWflsRClFcgzkqiHOrf0/SVw+EpVaFlJ0g4Kxq1MMOmiQdpMNpte8lMMQqm6cIFXlnGbfJllysKDi+0JJMotkqgIxOSQgU9dn/lWkeVf8nUm3iwX2Nl3WDw9i6AUK3vBAbZZrcJpDQ/N64AVwjT07Jef30GSSmtNu2WlW7YoyW2FlWfZFQUwk867EdLYKk9VG6JgEnBiBxkY7LMo4YLQJJlAo9l/oTvJkSARDF/XtyAzM8O2t3eT/iXa6wDN3WewNmQHdPfsxChU/KtLG2Mn8i4ZqKdSlIaBZadxJmRzVS/o4yA65RTSViq60oa395Lqw0pzY4SipwE0SXXsKV+GZraGSkr/RW08wPRvqvSUkYBMA9lPx4m24az+IHmCbXA+0faxTRE9wuGeO06DIXa6QlKJ3puIyiuAVfPr736vzo2pBirS+Vxel3TMm3JKhz9o2ZoRvaFVpIkykb0Hcm4oHFBMcNSNj7/4GJt43ogonY2Vg4nsDQIWxAcorpXACzgBqQPjYsE/VUpXpwNManEru4NwMCFPkXvMoqvoeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const Bv=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),Pv=4;function $j(n){let t=0;function e(){return n[t++]<<8|n[t++]}let r=e(),i=1,s=[0,1];for(let W=1;W<r;W++)s.push(i+=e());let o=e(),a=t;t+=o;let u=0,f=0;function h(){return u==0&&(f=f<<8|n[t++],u=8),f>>--u&1}const y=31,_=2**y,w=_>>>1,R=w>>1,T=_-1;let I=0;for(let W=0;W<y;W++)I=I<<1|h();let B=[],H=0,U=_;for(;;){let W=Math.floor(((I-H+1)*i-1)/U),X=0,j=r;for(;j-X>1;){let ut=X+j>>>1;W<s[ut]?j=ut:X=ut}if(X==0)break;B.push(X);let Y=H+Math.floor(U*s[X]/i),it=H+Math.floor(U*s[X+1]/i)-1;for(;!((Y^it)&w);)I=I<<1&T|h(),Y=Y<<1&T,it=it<<1&T|1;for(;Y&~it&R;)I=I&w|I<<1&T>>>1|h(),Y=Y<<1^w,it=(it^w)<<1|w|1;H=Y,U=1+it-Y}let G=r-4;return B.map(W=>{switch(W-G){case 3:return G+65792+(n[a++]<<16|n[a++]<<8|n[a++]);case 2:return G+256+(n[a++]<<8|n[a++]);case 1:return G+n[a++];default:return W-1}})}function Hj(n){let t=0;return()=>n[t++]}function hT(n){return Hj($j(zj(n)))}function zj(n){let t=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((i,s)=>t[i.charCodeAt(0)]=s);let e=n.length,r=new Uint8Array(6*e>>3);for(let i=0,s=0,o=0,a=0;i<e;i++)a=a<<6|t[n.charCodeAt(i)],o+=6,o>=8&&(r[s++]=a>>(o-=8));return r}function Gj(n){return n&1?~n>>1:n>>1}function Vj(n,t){let e=Array(n);for(let r=0,i=0;r<n;r++)e[r]=i+=Gj(t());return e}function Th(n,t=0){let e=[];for(;;){let r=n(),i=n();if(!i)break;t+=r;for(let s=0;s<i;s++)e.push(t+s);t+=i+1}return e}function dT(n){return Oh(()=>{let t=Th(n);if(t.length)return t})}function pT(n){let t=[];for(;;){let e=n();if(e==0)break;t.push(Kj(e,n))}for(;;){let e=n()-1;if(e<0)break;t.push(jj(e,n))}return t.flat()}function Oh(n){let t=[];for(;;){let e=n(t.length);if(!e)break;t.push(e)}return t}function gT(n,t,e){let r=Array(n).fill().map(()=>[]);for(let i=0;i<t;i++)Vj(n,e).forEach((s,o)=>r[o].push(s));return r}function Kj(n,t){let e=1+t(),r=t(),i=Oh(t);return gT(i.length,1+n,t).flatMap((o,a)=>{let[u,...f]=o;return Array(i[a]).fill().map((h,y)=>{let _=y*r;return[u+y*e,f.map(w=>w+_)]})})}function jj(n,t){let e=1+t();return gT(e,1+n,t).map(i=>[i[0],i.slice(1)])}function Wj(n){let t=[],e=Th(n);return i(r([]),[]),t;function r(s){let o=n(),a=Oh(()=>{let u=Th(n).map(f=>e[f]);if(u.length)return r(u)});return{S:o,B:a,Q:s}}function i({S:s,B:o},a,u){if(!(s&4&&u===a[a.length-1])){s&2&&(u=a[a.length-1]),s&1&&t.push(a);for(let f of o)for(let h of f.Q)i(f,[...a,h],u)}}}function Zj(n){return n.toString(16).toUpperCase().padStart(2,"0")}function yT(n){return`{${Zj(n)}}`}function qj(n){let t=[];for(let e=0,r=n.length;e<r;){let i=n.codePointAt(e);e+=i<65536?1:2,t.push(i)}return t}function Nl(n){let e=n.length;if(e<4096)return String.fromCodePoint(...n);let r=[];for(let i=0;i<e;)r.push(String.fromCodePoint(...n.slice(i,i+=4096)));return r.join("")}function Qj(n,t){let e=n.length,r=e-t.length;for(let i=0;r==0&&i<e;i++)r=n[i]-t[i];return r}var Jj="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30ZGQ/NlZwIpS3dDO0m4y6hgFoj9SqDBe1L9DzdC01RaA9ZC2UJ4zpjgU4DIQENIosK3Q05CG0Q8wrJaw3lEUUHOQPVSZoApQcBCxEdNRW1JhBirAsJOXcG+xr2C48mrxMpevwF0xohBk0BKRr/AM8u54WwWjFcHE9fBgMLJSPHFKhQIA0lQLd4SBobBxUlqQKRQ3BKh1E2HpMh9jw9DWYuE1F8B/U8BRlPC4E8nkarRQ4R0j6NPUgiSUwsBDV/LC8niwnPD4UMuXxyAVkJIQmxDHETMREXN8UIOQcZLZckJxUIIUaVYJoE958D8xPRAwsFPwlBBxMDtRwtEy4VKQUNgSTXAvM21S6zAo9WgAEXBcsPJR/fEFBH4A7pCJsCZQODJesALRUhABcimwhDYwBfj9hTBS7LCMdqbCN0A2cU52ERcweRDlcHpxwzFb8c4XDIXguGCCijrwlbAXUJmQFfBOMICTVbjKAgQWdTi1gYmyBhQT9d/AIxDGUVn0S9h3gCiw9rEhsBNQFzBzkNAQJ3Ee0RaxCVCOuGBDW1M/g6JQRPIYMgEQonA09szgsnJvkM+GkBoxJiAww0PXfuZ6tgtiQX/QcZMsVBYCHxC5JPzQycGsEYQlQuGeQHvwPzGvMn6kFXBf8DowMTOk0z7gS9C2kIiwk/AEkOoxcH1xhqCnGM0AExiwG3mQNXkYMCb48GNwcLAGcLhwV55QAdAqcIowAFAM8DVwA5Aq0HnQAZAIVBAT0DJy8BIeUCjwOTCDHLAZUvAfMpBBvDDBUA9zduSgLDsQKAamaiBd1YAo4CSTUBTSUEBU5HUQOvceEA2wBLBhPfRwEVq0rLGuNDAd9vKwDHAPsABTUHBUEBzQHzbQC3AV8LMQmis7UBTekpAIMAFWsB1wKJAN0ANQB/8QFTAE0FWfkF0wJPSQERMRgrV2EBuwMfATMBDQB5BsuNpckHHwRtB9MCEBsV4QLvLge1AQMi3xPNQsUCvd5VoWACZIECYkJbTa9bNyACofcCaJgCZgkCn4Q4GwsCZjsCZiYEbgR/A38TA36SOQY5dxc5gjojIwJsHQIyNjgKAm3HAm2u74ozZ0UrAWcA3gDhAEoFB5gMjQD+C8IADbUCdy8CdqI/AnlLQwJ4uh1c20WuRtcCfD8CesgCfQkCfPAFWQUgSABIfWMkAoFtAoAAAoAFAn+uSVhKWxUXSswC0QEC0MxLJwOITwOH5kTFkTIC8qFdAwMDrkvOTC0lA89NTE2vAos/AorYwRsHHUNnBbcCjjcCjlxAl4ECjtkCjlx4UbRTNQpS1FSFApP7ApMMAOkAHFUeVa9V0AYsGymVhjLheGZFOzkCl58C77JYIagAWSUClo8ClnycAKlZrFoJgU0AOwKWtQKWTlxEXNECmcsCmWRcyl0HGQKcmznCOp0CnBYCn5sCnriKAB0PMSoPAp3xAp6SALU9YTRh7wKe0wKgbgGpAp6fHwKeTqVjyGQnJSsCJ68CJn4CoPsCoEwCot0CocQCpi8Cpc4Cp/8AfQKn8mh8aLEAA0lqHGrRAqzjAqyuAq1nAq0CAlcdAlXcArHh1wMfTmyXArK9DQKy6Bds4G1jbUhfAyXNArZcOz9ukAMpRQK4XgK5RxUCuSp3cDZw4QK9GQK72nCWAzIRAr6IcgIDM3ECvhpzInNPAsPLAsMEc4J0SzVFdOADPKcDPJoDPb8CxXwCxkcCxhCJAshpUQLIRALJTwLJLgJknQLd0nh5YXiueSVL0AMYo2cCAmH0GfOVJHsLXpJeuxECz2sCz2wvS1PS8xOfAMatAs9zASnqA04SfksFAtwnAtuKAtJPA1JcA1NfAQEDVYyAiT8AyxbtYEWCHILTgs6DjQLaxwLZ3oQQhEmnPAOGpQAvA2QOhnFZ+QBVAt9lAt64c3cC4i/tFAHzMCcB9JsB8tKHAuvzAulweQLq+QLq5AD5RwG5Au6JAuuclqqXAwLuPwOF4Jh5cOBxoQLzAwBpA44WmZMC9xMDkW4DkocC95gC+dkC+GaaHJqruzebHgOdgwL++gEbADmfHJ+zAwWNA6ZqA6bZANHFAwZqoYiiBQkDDEkCwAA/AwDhQRdTARHzA2sHl2cFAJMtK7evvdsBiZkUfxEEOQH7KQUhDp0JnwCS/SlXxQL3AZ0AtwW5AG8LbUEuFCaNLgFDAYD8AbUmAHUDDgRtACwCFgyhAAAKAj0CagPdA34EkQEgRQUhfAoABQBEABMANhICdwEABdUDa+8KxQIA9wqfJ7+xt+UBkSFBQgHpFH8RNMCJAAQAGwBaAkUChIsABjpTOpSNbQC4Oo860ACNOME63AClAOgAywE6gTo7Ofw5+Tt2iTpbO56JOm85GAFWATMBbAUvNV01njWtNWY1dTW2NcU1gjWRNdI14TWeNa017jX9NbI1wTYCNhE1xjXVNhY2JzXeNe02LjY9Ni41LSE2OjY9Njw2yTcIBJA8VzY4Nt03IDcPNsogN4k3MAoEsDxnNiQ3GTdsOo03IULUQwdC4EMLHA8PCZsobShRVQYA6X8A6bABFCnXAukBowC9BbcAbwNzBL8MDAMMAQgDAAkKCwsLCQoGBAVVBI/DvwDz9b29kaUCb0QtsRTNLt4eGBcSHAMZFhYZEhYEARAEBUEcQRxBHEEcQRxBHEEaQRxBHEFCSTxBPElISUhBNkM2QTYbNklISVmBVIgBFLWZAu0BhQCjBcEAbykBvwGJAaQcEZ0ePCklMAAhMvAIMAL54gC7Bm8EescjzQMpARQpKgDUABavAj626xQAJP0A3etzuf4NNRA7efy2Z9NQrCnC0OSyANz5BBIbJ5IFDR6miIavYS6tprjjmuKebxm5C74Q225X1pkaYYPb6f1DK4k3xMEBb9S2WMjEibTNWhsRJIA+vwNVEiXTE5iXs/wezV66oFLfp9NZGYW+Gk19J2+bCT6Ye2w6LDYdgzKMUabk595eLBCXANz9HUpWbATq9vqXVx9XDg+Pc9Xp4+bsS005SVM/BJBM4687WUuf+Uj9dEi8aDNaPxtpbDxcG1THTImUMZq4UCaaNYpsVqraNyKLJXDYsFZ/5jl7bLRtO88t7P3xZaAxhb5OdPMXqsSkp1WCieG8jXm1U99+blvLlXzPCS+M93VnJCiK+09LfaSaBAVBomyDgJua8dfUzR7ga34IvR2Nvj+A9heJ6lsl1KG4NkI1032Cnff1m1wof2B9oHJK4bi6JkEdSqeNeiuo6QoZZincoc73/TH9SXF8sCE7XyuYyW8WSgbGFCjPV0ihLKhdPs08Tx82fYAkLLc4I2wdl4apY7GU5lHRFzRWJep7Ww3wbeA3qmd59/86P4xuNaqDpygXt6M85glSBHOCGgJDnt+pN9bK7HApMguX6+06RZNjzVmcZJ+wcUrJ9//bpRNxNuKpNl9uFds+S9tdx7LaM5ZkIrPj6nIU9mnbFtVbs9s/uLgl8MVczAwet+iOEzzBlYW7RCMgE6gyNLeq6+1tIx4dpgZnd0DksJS5f+JNDpwwcPNXaaVspq1fbQajOrJgK0ofKtJ1Ne90L6VO4MOl5S886p7u6xo7OLjG8TGL+HU1JXGJgppg4nNbNJ5nlzSpuPYy21JUEcUA94PoFiZfjZue+QnyQ80ekOuZVkxx4g+cvhJfHgNl4hy1/a6+RKcKlar/J29y//EztlbVPHVUeQ1zX86eQVAjR/M3dA9w4W8LfaXp4EgM85wOWasli837PzVMOnsLzR+k3o75/lRPAJSE1xAKQzEi5v10ke+VBvRt1cwQRMd+U5mLCTGVd6XiZtgBG5cDi0w22GKcVNvHiu5LQbZEDVtz0onn7k5+heuKXVsZtSzilkLRAUmjMXEMB3J9YC50XBxPiz53SC+EhnPl9WsKCv92SM/OFFIMJZYfl0WW8tIO3UxYcwdMAj7FSmgrsZ2aAZO03BOhP1bNNZItyXYQFTpC3SG1VuPDqH9GkiCDmE+JwxyIVSO5siDErAOpEXFgjy6PQtOVDj+s6e1r8heWVvmZnTciuf4EiNZzCAd7SOMhXERIOlsHIMG399i9aLTy3m2hRLZjJVDNLS53iGIK11dPqQt0zBDyg6qc7YqkDm2M5Ve6dCWCaCbTXX2rToaIgz6+zh4lYUi/+6nqcFMAkQJKHYLK0wYk5N9szV6xihDbDDFr45lN1K4aCXBq/FitPSud9gLt5ZVn+ZqGX7cwm2z5EGMgfFpIFyhGGuDPmso6TItTMwny+7uPnLCf4W6goFQFV0oQSsc9VfMmVLcLr6ZetDZbaSFTLqnSO/bIPjA3/zAUoqgGFAEQS4IhuMzEp2I3jJzbzkk/IEmyax+rhZTwd6f+CGtwPixu8IvzACquPWPREu9ZvGkUzpRwvRRuaNN6cr0W1wWits9ICdYJ7ltbgMiSL3sTPeufgNcVqMVWFkCPDH4jG2jA0XcVgQj62Cb29v9f/z/+2KbYvIv/zzjpQAPkliaVDzNrW57TZ/ZOyZD0nlfMmAIBIAGAI0D3k/mdN4xr9v85ZbZbbqfH2jGd5hUqNZWwl5SPfoGmfElmazUIeNL1j/mkF7VNAzTq4jNt8JoQ11NQOcmhprXoxSxfRGJ9LDEOAQ+dmxAQH90iti9e2u/MoeuaGcDTHoC+xsmEeWmxEKefQuIzHbpw5Tc5cEocboAD09oipWQhtTO1wivf/O+DRe2rpl/E9wlrzBorjJsOeG1B/XPW4EaJEFdNlECEZga5ZoGRHXgYouGRuVkm8tDESiEyFNo+3s5M5puSdTyUL2llnINVHEt91XUNW4ewdMgJ4boJfEyt/iY5WXqbA+A2Fkt5Z0lutiWhe9nZIyIUjyXDC3UsaG1t+eNx6z4W/OYoTB7A6x+dNSTOi9AInctbESqm5gvOLww7OWXPrmHwVZasrl4eD113pm+JtT7JVOvnCXqdzzdTRHgJ0PiGTFYW5Gvt9R9LD6Lzfs0v/TZZHSmyVNq7viIHE6DBK7Qp07Iz55EM8SYtQvZf/obBniTWi5C2/ovHfw4VndkE5XYdjOhCMRjDeOEfXeN/CwfGduiUIfsoFeUxXeQXba7c7972XNv8w+dTjjUM0QeNAReW+J014dKAD/McQYXT7c0GQPIkn3Ll6R7gGjuiQoZD0TEeEqQpKoZ15g/0OPQI17QiSv9AUROa/V/TQN3dvLArec3RrsYlvBm1b8LWzltdugsC50lNKYLEp2a+ZZYqPejULRlOJh5zj/LVMyTDvwKhMxxwuDkxJ1QpoNI0OTWLom4Z71SNzI9TV1iXJrIu9Wcnd+MCaAw8o1jSXd94YU/1gnkrC9BUEOtQvEIQ7g0i6h+KL2JKk8Ydl7HruvgWMSAmNe+LshGhV4qnWHhO9/RIPQzY1tHRj2VqOyNsDpK0cww+56AdDC4gsWwY0XxoucIWIqs/GcwnWqlaT0KPr8mbK5U94/301i1WLt4YINTVvCFBrFZbIbY8eycOdeJ2teD5IfPLCRg7jjcFTwlMFNl9zdh/o3E/hHPwj7BWg0MU09pPrBLbrCgm54A6H+I6v27+jL5gkjWg/iYdks9jbfVP5y/n0dlgWEMlKasl7JvFZd56LfybW1eeaVO0gxTfXZwD8G4SI116yx7UKVRgui6Ya1YpixqXeNLc8IxtAwCU5IhwQgn+NqHnRaDv61CxKhOq4pOX7M6pkA+Pmpd4j1vn6ACUALoLLc4vpXci8VidLxzm7qFBe7s+quuJs6ETYmnpgS3LwSZxPIltgBDXz8M1k/W2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g";const Nh=44032,Q0=4352,J0=4449,Y0=4519,mT=19,wT=21,Cl=28,X0=wT*Cl,Yj=mT*X0,Xj=Nh+Yj,tW=Q0+mT,eW=J0+wT,nW=Y0+Cl;function Ff(n){return n>>24&255}function bT(n){return n&16777215}let Pw,Mv,Mw,p0;function rW(){let n=hT(Jj);Pw=new Map(dT(n).flatMap((t,e)=>t.map(r=>[r,e+1<<24]))),Mv=new Set(Th(n)),Mw=new Map,p0=new Map;for(let[t,e]of pT(n)){if(!Mv.has(t)&&e.length==2){let[r,i]=e,s=p0.get(r);s||(s=new Map,p0.set(r,s)),s.set(i,t)}Mw.set(t,e.reverse())}}function _T(n){return n>=Nh&&n<Xj}function iW(n,t){if(n>=Q0&&n<tW&&t>=J0&&t<eW)return Nh+(n-Q0)*X0+(t-J0)*Cl;if(_T(n)&&t>Y0&&t<nW&&(n-Nh)%Cl==0)return n+(t-Y0);{let e=p0.get(n);return e&&(e=e.get(t),e)?e:-1}}function AT(n){Pw||rW();let t=[],e=[],r=!1;function i(s){let o=Pw.get(s);o&&(r=!0,s|=o),t.push(s)}for(let s of n)for(;;){if(s<128)t.push(s);else if(_T(s)){let o=s-Nh,a=o/X0|0,u=o%X0/Cl|0,f=o%Cl;i(Q0+a),i(J0+u),f>0&&i(Y0+f)}else{let o=Mw.get(s);o?e.push(...o):i(s)}if(!e.length)break;s=e.pop()}if(r&&t.length>1){let s=Ff(t[0]);for(let o=1;o<t.length;o++){let a=Ff(t[o]);if(a==0||s<=a){s=a;continue}let u=o-1;for(;;){let f=t[u+1];if(t[u+1]=t[u],t[u]=f,!u||(s=Ff(t[--u]),s<=a))break}s=Ff(t[o])}}return t}function sW(n){let t=[],e=[],r=-1,i=0;for(let s of n){let o=Ff(s),a=bT(s);if(r==-1)o==0?r=a:t.push(a);else if(i>0&&i>=o)o==0?(t.push(r,...e),e.length=0,r=a):e.push(a),i=o;else{let u=iW(r,a);u>=0?r=u:i==0&&o==0?(t.push(r),r=a):(e.push(a),i=o)}}return r>=0&&t.push(r,...e),t}function ET(n){return AT(n).map(bT)}function oW(n){return sW(AT(n))}const Lv=45,vT=".",xT=65039,RT=1,tp=n=>Array.from(n);function Ch(n,t){return n.P.has(t)||n.Q.has(t)}class aW extends Array{get is_emoji(){return!0}}let Lw,IT,Ma,Uw,ST,wu,Im,Xc,ba,Uv,Dw;function _b(){if(Lw)return;let n=hT(Fj);const t=()=>Th(n),e=()=>new Set(t()),r=(h,y)=>y.forEach(_=>h.add(_));Lw=new Map(pT(n)),IT=e(),Ma=t(),Uw=new Set(t().map(h=>Ma[h])),Ma=new Set(Ma),ST=e(),e();let i=dT(n),s=n();const o=()=>{let h=new Set;return t().forEach(y=>r(h,i[y])),r(h,t()),h};wu=Oh(h=>{let y=Oh(n).map(_=>_+96);if(y.length){let _=h>=s;y[0]-=32,y=Nl(y),_&&(y=`Restricted[${y}]`);let w=o(),R=o(),T=!n();return{N:y,P:w,Q:R,M:T,R:_}}}),Im=e(),Xc=new Map;let a=t().concat(tp(Im)).sort((h,y)=>h-y);a.forEach((h,y)=>{let _=n(),w=a[y]=_?a[y-_]:{V:[],M:new Map};w.V.push(h),Im.has(h)||Xc.set(h,w)});for(let{V:h,M:y}of new Set(Xc.values())){let _=[];for(let R of h){let T=wu.filter(B=>Ch(B,R)),I=_.find(({G:B})=>T.some(H=>B.has(H)));I||(I={G:new Set,V:[]},_.push(I)),I.V.push(R),r(I.G,T)}let w=_.flatMap(R=>tp(R.G));for(let{G:R,V:T}of _){let I=new Set(w.filter(B=>!R.has(B)));for(let B of T)y.set(B,I)}}ba=new Set;let u=new Set;const f=h=>ba.has(h)?u.add(h):ba.add(h);for(let h of wu){for(let y of h.P)f(y);for(let y of h.Q)f(y)}for(let h of ba)!Xc.has(h)&&!u.has(h)&&Xc.set(h,RT);r(ba,ET(ba)),Uv=Wj(n).map(h=>aW.from(h)).sort(Qj),Dw=new Map;for(let h of Uv){let y=[Dw];for(let _ of h){let w=y.map(R=>{let T=R.get(_);return T||(T=new Map,R.set(_,T)),T});_===xT?y.push(...w):y=w}for(let _ of y)_.V=h}}function Ab(n){return(kT(n)?"":`${Eb(sg([n]))} `)+yT(n)}function Eb(n){return`"${n}"`}function cW(n){if(n.length>=4&&n[2]==Lv&&n[3]==Lv)throw new Error(`invalid label extension: "${Nl(n.slice(0,4))}"`)}function uW(n){for(let e=n.lastIndexOf(95);e>0;)if(n[--e]!==95)throw new Error("underscore allowed only at start")}function lW(n){let t=n[0],e=Bv.get(t);if(e)throw qf(`leading ${e}`);let r=n.length,i=-1;for(let s=1;s<r;s++){t=n[s];let o=Bv.get(t);if(o){if(i==s)throw qf(`${e} + ${o}`);i=s+1,e=o}}if(i==r)throw qf(`trailing ${e}`)}function sg(n,t=1/0,e=yT){let r=[];fW(n[0])&&r.push("◌"),n.length>t&&(t>>=1,n=[...n.slice(0,t),8230,...n.slice(-t)]);let i=0,s=n.length;for(let o=0;o<s;o++){let a=n[o];kT(a)&&(r.push(Nl(n.slice(i,o))),r.push(e(a)),i=o+1)}return r.push(Nl(n.slice(i,s))),r.join("")}function fW(n){return _b(),Ma.has(n)}function kT(n){return _b(),ST.has(n)}function hW(n){return yW(dW(n,oW,bW))}function dW(n,t,e){if(!n)return[];_b();let r=0;return n.split(vT).map(i=>{let s=qj(i),o={input:s,offset:r};r+=s.length+1;try{let a=o.tokens=wW(s,t,e),u=a.length,f;if(!u)throw new Error("empty label");let h=o.output=a.flat();if(uW(h),!(o.emoji=u>1||a[0].is_emoji)&&h.every(_=>_<128))cW(h),f="ASCII";else{let _=a.flatMap(w=>w.is_emoji?[]:w);if(!_.length)f="Emoji";else{if(Ma.has(h[0]))throw qf("leading combining mark");for(let T=1;T<u;T++){let I=a[T];if(!I.is_emoji&&Ma.has(I[0]))throw qf(`emoji + combining mark: "${Nl(a[T-1])} + ${sg([I[0]])}"`)}lW(h);let w=tp(new Set(_)),[R]=gW(w);mW(R,_),pW(R,w),f=R.N}}o.type=f}catch(a){o.error=a}return o})}function pW(n,t){let e,r=[];for(let i of t){let s=Xc.get(i);if(s===RT)return;if(s){let o=s.M.get(i);if(e=e?e.filter(a=>o.has(a)):tp(o),!e.length)return}else r.push(i)}if(e){for(let i of e)if(r.every(s=>Ch(i,s)))throw new Error(`whole-script confusable: ${n.N}/${i.N}`)}}function gW(n){let t=wu;for(let e of n){let r=t.filter(i=>Ch(i,e));if(!r.length)throw wu.some(i=>Ch(i,e))?OT(t[0],e):TT(e);if(t=r,r.length==1)break}return t}function yW(n){return n.map(({input:t,error:e,output:r})=>{if(e){let i=e.message;throw new Error(n.length==1?i:`Invalid label ${Eb(sg(t,63))}: ${i}`)}return Nl(r)}).join(vT)}function TT(n){return new Error(`disallowed character: ${Ab(n)}`)}function OT(n,t){let e=Ab(t),r=wu.find(i=>i.P.has(t));return r&&(e=`${r.N} ${e}`),new Error(`illegal mixture: ${n.N} + ${e}`)}function qf(n){return new Error(`illegal placement: ${n}`)}function mW(n,t){for(let e of t)if(!Ch(n,e))throw OT(n,e);if(n.M){let e=ET(t);for(let r=1,i=e.length;r<i;r++)if(Uw.has(e[r])){let s=r+1;for(let o;s<i&&Uw.has(o=e[s]);s++)for(let a=r;a<s;a++)if(e[a]==o)throw new Error(`duplicate non-spacing marks: ${Ab(o)}`);if(s-r>Pv)throw new Error(`excessive non-spacing marks: ${Eb(sg(e.slice(r-1,s)))} (${s-r}/${Pv})`);r=s}}}function wW(n,t,e){let r=[],i=[];for(n=n.slice().reverse();n.length;){let s=_W(n);if(s)i.length&&(r.push(t(i)),i=[]),r.push(e(s));else{let o=n.pop();if(ba.has(o))i.push(o);else{let a=Lw.get(o);if(a)i.push(...a);else if(!IT.has(o))throw TT(o)}}}return i.length&&r.push(t(i)),r}function bW(n){return n.filter(t=>t!=xT)}function _W(n,t){let e=Dw,r,i=n.length;for(;i&&(e=e.get(n[--i]),!!e);){let{V:s}=e;s&&(r=s,n.length=i)}return r}const NT=new Uint8Array(32);NT.fill(0);function Dv(n){return K(n.length!==0,"invalid ENS name; empty component","comp",n),n}function CT(n){const t=Js(AW(n)),e=[];if(n.length===0)return e;let r=0;for(let i=0;i<t.length;i++)t[i]===46&&(e.push(Dv(t.slice(r,i))),r=i+1);return K(r<t.length,"invalid ENS name; empty component","name",n),e.push(Dv(t.slice(r))),e}function AW(n){try{if(n.length===0)throw new Error("empty label");return hW(n)}catch(t){K(!1,`invalid ENS name (${t.message})`,"name",n)}}function Fw(n){K(typeof n=="string","invalid ENS name; not a string","name",n),K(n.length,"invalid ENS name (empty label)","name",n);let t=NT;const e=CT(n);for(;e.length;)t=Tn(In([t,Tn(e.pop())]));return kt(t)}function EW(n,t){const e=t;return K(e<=255,"DNS encoded label cannot exceed 255","length",e),kt(In(CT(n).map(r=>{K(r.length<=e,`label ${JSON.stringify(n)} exceeds ${e} bytes`,"name",n);const i=new Uint8Array(r.length+1);return i.set(r,1),i[0]=i.length-1,i})))+"00"}function Sm(n,t){return{address:Me(n),storageKeys:t.map((e,r)=>(K(ze(e,32),"invalid slot",`storageKeys[${r}]`,e),e.toLowerCase()))}}function Pc(n){if(Array.isArray(n))return n.map((e,r)=>Array.isArray(e)?(K(e.length===2,"invalid slot set",`value[${r}]`,e),Sm(e[0],e[1])):(K(e!=null&&typeof e=="object","invalid address-slot set","value",n),Sm(e.address,e.storageKeys)));K(n!=null&&typeof n=="object","invalid access list","value",n);const t=Object.keys(n).map(e=>{const r=n[e].reduce((i,s)=>(i[s]=!0,i),{});return Sm(e,Object.keys(r).sort())});return t.sort((e,r)=>e.address.localeCompare(r.address)),t}function vW(n){let t;return typeof n=="string"?t=kh.computePublicKey(n,!1):t=n.publicKey,Me(Tn("0x"+t.substring(4)).substring(26))}function xW(n,t){return vW(kh.recoverPublicKey(n,t))}const Dn=BigInt(0),RW=BigInt(2),IW=BigInt(27),SW=BigInt(28),kW=BigInt(35),TW=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),km=4096*32;function Fv(n,t){let e=n.toString(16);for(;e.length<2;)e="0"+e;return e+=Jl(t).substring(4),"0x"+e}function og(n){return n==="0x"?null:Me(n)}function vb(n,t){try{return Pc(n)}catch(e){K(!1,e.message,t,n)}}function md(n,t){return n==="0x"?0:oe(n,t)}function Rn(n,t){if(n==="0x")return Dn;const e=Nt(n,t);return K(e<=TW,"value exceeds uint size",t,e),e}function Ke(n,t){const e=Nt(n,"value"),r=yr(e);return K(r.length<=32,"value too large",`tx.${t}`,e),r}function xb(n){return Pc(n).map(t=>[t.address,t.storageKeys])}function OW(n,t){K(Array.isArray(n),`invalid ${t}`,"value",n);for(let e=0;e<n.length;e++)K(ze(n[e],32),"invalid ${ param } hash",`value[${e}]`,n[e]);return n}function NW(n){const t=eg(n);K(Array.isArray(t)&&(t.length===9||t.length===6),"invalid field count for legacy transaction","data",n);const e={type:0,nonce:md(t[0],"nonce"),gasPrice:Rn(t[1],"gasPrice"),gasLimit:Rn(t[2],"gasLimit"),to:og(t[3]),value:Rn(t[4],"value"),data:kt(t[5]),chainId:Dn};if(t.length===6)return e;const r=Rn(t[6],"v"),i=Rn(t[7],"r"),s=Rn(t[8],"s");if(i===Dn&&s===Dn)e.chainId=r;else{let o=(r-kW)/RW;o<Dn&&(o=Dn),e.chainId=o,K(o!==Dn||r===IW||r===SW,"non-canonical legacy v","v",t[6]),e.signature=Oi.from({r:Ac(t[7],32),s:Ac(t[8],32),v:r})}return e}function CW(n,t){const e=[Ke(n.nonce,"nonce"),Ke(n.gasPrice||0,"gasPrice"),Ke(n.gasLimit,"gasLimit"),n.to||"0x",Ke(n.value,"value"),n.data];let r=Dn;if(n.chainId!=Dn)r=Nt(n.chainId,"tx.chainId"),K(!t||t.networkV==null||t.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",t);else if(n.signature){const s=n.signature.legacyChainId;s!=null&&(r=s)}if(!t)return r!==Dn&&(e.push(yr(r)),e.push("0x"),e.push("0x")),Ec(e);let i=BigInt(27+t.yParity);return r!==Dn?i=Oi.getChainIdV(r,t.v):BigInt(t.v)!==i&&K(!1,"tx.chainId/sig.v mismatch","sig",t),e.push(yr(i)),e.push(yr(t.r)),e.push(yr(t.s)),Ec(e)}function Rb(n,t){let e;try{if(e=md(t[0],"yParity"),e!==0&&e!==1)throw new Error("bad yParity")}catch{K(!1,"invalid yParity","yParity",t[0])}const r=Ac(t[1],32),i=Ac(t[2],32),s=Oi.from({r,s:i,yParity:e});n.signature=s}function BW(n){const t=eg(ye(n).slice(1));K(Array.isArray(t)&&(t.length===9||t.length===12),"invalid field count for transaction type: 2","data",kt(n));const e={type:2,chainId:Rn(t[0],"chainId"),nonce:md(t[1],"nonce"),maxPriorityFeePerGas:Rn(t[2],"maxPriorityFeePerGas"),maxFeePerGas:Rn(t[3],"maxFeePerGas"),gasPrice:null,gasLimit:Rn(t[4],"gasLimit"),to:og(t[5]),value:Rn(t[6],"value"),data:kt(t[7]),accessList:vb(t[8],"accessList")};return t.length===9||Rb(e,t.slice(9)),e}function PW(n,t){const e=[Ke(n.chainId,"chainId"),Ke(n.nonce,"nonce"),Ke(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ke(n.maxFeePerGas||0,"maxFeePerGas"),Ke(n.gasLimit,"gasLimit"),n.to||"0x",Ke(n.value,"value"),n.data,xb(n.accessList||[])];return t&&(e.push(Ke(t.yParity,"yParity")),e.push(yr(t.r)),e.push(yr(t.s))),In(["0x02",Ec(e)])}function MW(n){const t=eg(ye(n).slice(1));K(Array.isArray(t)&&(t.length===8||t.length===11),"invalid field count for transaction type: 1","data",kt(n));const e={type:1,chainId:Rn(t[0],"chainId"),nonce:md(t[1],"nonce"),gasPrice:Rn(t[2],"gasPrice"),gasLimit:Rn(t[3],"gasLimit"),to:og(t[4]),value:Rn(t[5],"value"),data:kt(t[6]),accessList:vb(t[7],"accessList")};return t.length===8||Rb(e,t.slice(8)),e}function LW(n,t){const e=[Ke(n.chainId,"chainId"),Ke(n.nonce,"nonce"),Ke(n.gasPrice||0,"gasPrice"),Ke(n.gasLimit,"gasLimit"),n.to||"0x",Ke(n.value,"value"),n.data,xb(n.accessList||[])];return t&&(e.push(Ke(t.yParity,"recoveryParam")),e.push(yr(t.r)),e.push(yr(t.s))),In(["0x01",Ec(e)])}function UW(n){let t=eg(ye(n).slice(1)),e="3",r=null;if(t.length===4&&Array.isArray(t[0])){e="3 (network format)";const s=t[1],o=t[2],a=t[3];K(Array.isArray(s),"invalid network format: blobs not an array","fields[1]",s),K(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),K(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),K(s.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",t),K(s.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",t),r=[];for(let u=0;u<t[1].length;u++)r.push({data:s[u],commitment:o[u],proof:a[u]});t=t[0]}K(Array.isArray(t)&&(t.length===11||t.length===14),`invalid field count for transaction type: ${e}`,"data",kt(n));const i={type:3,chainId:Rn(t[0],"chainId"),nonce:md(t[1],"nonce"),maxPriorityFeePerGas:Rn(t[2],"maxPriorityFeePerGas"),maxFeePerGas:Rn(t[3],"maxFeePerGas"),gasPrice:null,gasLimit:Rn(t[4],"gasLimit"),to:og(t[5]),value:Rn(t[6],"value"),data:kt(t[7]),accessList:vb(t[8],"accessList"),maxFeePerBlobGas:Rn(t[9],"maxFeePerBlobGas"),blobVersionedHashes:t[10]};r&&(i.blobs=r),K(i.to!=null,`invalid address for transaction type: ${e}`,"data",n),K(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",n);for(let s=0;s<i.blobVersionedHashes.length;s++)K(ze(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",n);return t.length===11||Rb(i,t.slice(11)),i}function DW(n,t,e){const r=[Ke(n.chainId,"chainId"),Ke(n.nonce,"nonce"),Ke(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ke(n.maxFeePerGas||0,"maxFeePerGas"),Ke(n.gasLimit,"gasLimit"),n.to||Sh,Ke(n.value,"value"),n.data,xb(n.accessList||[]),Ke(n.maxFeePerBlobGas||0,"maxFeePerBlobGas"),OW(n.blobVersionedHashes||[],"blobVersionedHashes")];return t&&(r.push(Ke(t.yParity,"yParity")),r.push(yr(t.r)),r.push(yr(t.s)),e)?In(["0x03",Ec([r,e.map(i=>i.data),e.map(i=>i.commitment),e.map(i=>i.proof)])]):In(["0x03",Ec(r)])}var Fi,Uu,Du,Fu,$u,Hu,zu,Gu,Vu,Ku,ju,Wu,Za,ko,Ms,To,Zu,g0;const xs=class xs{constructor(){J(this,Zu);J(this,Fi);J(this,Uu);J(this,Du);J(this,Fu);J(this,$u);J(this,Hu);J(this,zu);J(this,Gu);J(this,Vu);J(this,Ku);J(this,ju);J(this,Wu);J(this,Za);J(this,ko);J(this,Ms);J(this,To);F(this,Fi,null),F(this,Uu,null),F(this,Fu,0),F(this,$u,Dn),F(this,Hu,null),F(this,zu,null),F(this,Gu,null),F(this,Du,"0x"),F(this,Vu,Dn),F(this,Ku,Dn),F(this,ju,null),F(this,Wu,null),F(this,Za,null),F(this,ko,null),F(this,To,null),F(this,Ms,null)}get type(){return S(this,Fi)}set type(t){switch(t){case null:F(this,Fi,null);break;case 0:case"legacy":F(this,Fi,0);break;case 1:case"berlin":case"eip-2930":F(this,Fi,1);break;case 2:case"london":case"eip-1559":F(this,Fi,2);break;case 3:case"cancun":case"eip-4844":F(this,Fi,3);break;default:K(!1,"unsupported transaction type","type",t)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const t=S(this,Uu);return t==null&&this.type===3?Sh:t}set to(t){F(this,Uu,t==null?null:Me(t))}get nonce(){return S(this,Fu)}set nonce(t){F(this,Fu,oe(t,"value"))}get gasLimit(){return S(this,$u)}set gasLimit(t){F(this,$u,Nt(t))}get gasPrice(){const t=S(this,Hu);return t==null&&(this.type===0||this.type===1)?Dn:t}set gasPrice(t){F(this,Hu,t==null?null:Nt(t,"gasPrice"))}get maxPriorityFeePerGas(){const t=S(this,zu);return t??(this.type===2||this.type===3?Dn:null)}set maxPriorityFeePerGas(t){F(this,zu,t==null?null:Nt(t,"maxPriorityFeePerGas"))}get maxFeePerGas(){const t=S(this,Gu);return t??(this.type===2||this.type===3?Dn:null)}set maxFeePerGas(t){F(this,Gu,t==null?null:Nt(t,"maxFeePerGas"))}get data(){return S(this,Du)}set data(t){F(this,Du,kt(t))}get value(){return S(this,Vu)}set value(t){F(this,Vu,Nt(t,"value"))}get chainId(){return S(this,Ku)}set chainId(t){F(this,Ku,Nt(t))}get signature(){return S(this,ju)||null}set signature(t){F(this,ju,t==null?null:Oi.from(t))}get accessList(){const t=S(this,Wu)||null;return t??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(t){F(this,Wu,t==null?null:Pc(t))}get maxFeePerBlobGas(){const t=S(this,Za);return t==null&&this.type===3?Dn:t}set maxFeePerBlobGas(t){F(this,Za,t==null?null:Nt(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=S(this,ko);return t==null&&this.type===3?[]:t}set blobVersionedHashes(t){if(t!=null){K(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)K(ze(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}F(this,ko,t)}get blobs(){return S(this,To)==null?null:S(this,To).map(t=>Object.assign({},t))}set blobs(t){if(t==null){F(this,To,null);return}const e=[],r=[];for(let i=0;i<t.length;i++){const s=t[i];if(ub(s)){ht(S(this,Ms),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=ye(s);if(K(o.length<=km,"blob is too large",`blobs[${i}]`,s),o.length!==km){const f=new Uint8Array(km);f.set(o),o=f}const a=S(this,Ms).blobToKzgCommitment(o),u=kt(S(this,Ms).computeBlobKzgProof(o,a));e.push({data:kt(o),commitment:kt(a),proof:u}),r.push(Fv(1,a))}else{const o=kt(s.commitment);e.push({data:kt(s.data),commitment:o,proof:kt(s.proof)}),r.push(Fv(1,o))}}F(this,To,e),F(this,ko,r)}get kzg(){return S(this,Ms)}set kzg(t){F(this,Ms,t)}get hash(){return this.signature==null?null:Tn(yt(this,Zu,g0).call(this,!0,!1))}get unsignedHash(){return Tn(this.unsignedSerialized)}get from(){return this.signature==null?null:xW(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:kh.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return yt(this,Zu,g0).call(this,!0,!0)}get unsignedSerialized(){return yt(this,Zu,g0).call(this,!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=this.gasPrice!=null,e=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,i=S(this,Za)!=null||S(this,ko);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&ht(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ht(!e||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ht(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const s=[];return this.type!=null?s.push(this.type):e?s.push(2):t?(s.push(1),r||s.push(0)):r?(s.push(1),s.push(2)):(i&&this.to||(s.push(0),s.push(1),s.push(2)),s.push(3)),s.sort(),s}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return xs.from(this)}toJSON(){const t=e=>e==null?null:e.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(t){if(t==null)return new xs;if(typeof t=="string"){const r=ye(t);if(r[0]>=127)return xs.from(NW(r));switch(r[0]){case 1:return xs.from(MW(r));case 2:return xs.from(BW(r));case 3:return xs.from(UW(r))}ht(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const e=new xs;return t.type!=null&&(e.type=t.type),t.to!=null&&(e.to=t.to),t.nonce!=null&&(e.nonce=t.nonce),t.gasLimit!=null&&(e.gasLimit=t.gasLimit),t.gasPrice!=null&&(e.gasPrice=t.gasPrice),t.maxPriorityFeePerGas!=null&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas),t.maxFeePerGas!=null&&(e.maxFeePerGas=t.maxFeePerGas),t.maxFeePerBlobGas!=null&&(e.maxFeePerBlobGas=t.maxFeePerBlobGas),t.data!=null&&(e.data=t.data),t.value!=null&&(e.value=t.value),t.chainId!=null&&(e.chainId=t.chainId),t.signature!=null&&(e.signature=Oi.from(t.signature)),t.accessList!=null&&(e.accessList=t.accessList),t.blobVersionedHashes!=null&&(e.blobVersionedHashes=t.blobVersionedHashes),t.kzg!=null&&(e.kzg=t.kzg),t.blobs!=null&&(e.blobs=t.blobs),t.hash!=null&&(K(e.isSigned(),"unsigned transaction cannot define '.hash'","tx",t),K(e.hash===t.hash,"hash mismatch","tx",t)),t.from!=null&&(K(e.isSigned(),"unsigned transaction cannot define '.from'","tx",t),K(e.from.toLowerCase()===(t.from||"").toLowerCase(),"from mismatch","tx",t)),e}};Fi=new WeakMap,Uu=new WeakMap,Du=new WeakMap,Fu=new WeakMap,$u=new WeakMap,Hu=new WeakMap,zu=new WeakMap,Gu=new WeakMap,Vu=new WeakMap,Ku=new WeakMap,ju=new WeakMap,Wu=new WeakMap,Za=new WeakMap,ko=new WeakMap,Ms=new WeakMap,To=new WeakMap,Zu=new WeakSet,g0=function(t,e){ht(!t||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return CW(this,r);case 1:return LW(this,r);case 2:return PW(this,r);case 3:return DW(this,r,e?this.blobs:null)}ht(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let ep=xs;const BT=new Uint8Array(32);BT.fill(0);const FW=BigInt(-1),PT=BigInt(0),MT=BigInt(1),$W=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function HW(n){const t=ye(n),e=t.length%32;return e?In([t,BT.slice(e)]):kt(t)}const zW=aa(MT,32),GW=aa(PT,32),$v={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Tm=["name","version","chainId","verifyingContract","salt"];function Hv(n){return function(t){return K(typeof t=="string",`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,t),t}}const VW={name:Hv("name"),version:Hv("version"),chainId:function(n){const t=Nt(n,"domain.chainId");return K(t>=0,"invalid chain ID","domain.chainId",n),Number.isSafeInteger(t)?Number(t):cu(t)},verifyingContract:function(n){try{return Me(n).toLowerCase()}catch{}K(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){const t=ye(n,"domain.salt");return K(t.length===32,'invalid domain value "salt"',"domain.salt",n),kt(t)}};function Om(n){{const t=n.match(/^(u?)int(\d+)$/);if(t){const e=t[1]==="",r=parseInt(t[2]);K(r%8===0&&r!==0&&r<=256&&t[2]===String(r),"invalid numeric width","type",n);const i=Uf($W,e?r-1:r),s=e?(i+MT)*FW:PT;return function(o){const a=Nt(o,"value");return K(a>=s&&a<=i,`value out-of-bounds for ${n}`,"value",a),aa(e?Ek(a,256):a,32)}}}{const t=n.match(/^bytes(\d+)$/);if(t){const e=parseInt(t[1]);return K(e!==0&&e<=32&&t[1]===String(e),"invalid bytes width","type",n),function(r){const i=ye(r);return K(i.length===e,`invalid length for ${n}`,"value",r),HW(r)}}}switch(n){case"address":return function(t){return Ac(Me(t),32)};case"bool":return function(t){return t?zW:GW};case"bytes":return function(t){return Tn(t)};case"string":return function(t){return vc(t)}}return null}function zv(n,t){return`${n}(${t.map(({name:e,type:r})=>r+" "+e).join(",")})`}function n0(n){const t=n.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return t?{base:t[1],index:t[2]+t[4],array:{base:t[1],prefix:t[1]+t[2],count:t[5]?parseInt(t[5]):-1}}:{base:n}}var Gh,Ls,qu,up,LT;const Qr=class Qr{constructor(t){J(this,up);Z(this,"primaryType");J(this,Gh);J(this,Ls);J(this,qu);F(this,Ls,new Map),F(this,qu,new Map);const e=new Map,r=new Map,i=new Map,s={};Object.keys(t).forEach(u=>{s[u]=t[u].map(({name:f,type:h})=>{let{base:y,index:_}=n0(h);return y==="int"&&!t.int&&(y="int256"),y==="uint"&&!t.uint&&(y="uint256"),{name:f,type:y+(_||"")}}),e.set(u,new Set),r.set(u,[]),i.set(u,new Set)}),F(this,Gh,JSON.stringify(s));for(const u in s){const f=new Set;for(const h of s[u]){K(!f.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(u)}`,"types",t),f.add(h.name);const y=n0(h.type).base;K(y!==u,`circular type reference to ${JSON.stringify(y)}`,"types",t),!Om(y)&&(K(r.has(y),`unknown type ${JSON.stringify(y)}`,"types",t),r.get(y).push(u),e.get(u).add(y))}}const o=Array.from(r.keys()).filter(u=>r.get(u).length===0);K(o.length!==0,"missing primary type","types",t),K(o.length===1,`ambiguous primary types or unused types: ${o.map(u=>JSON.stringify(u)).join(", ")}`,"types",t),$t(this,{primaryType:o[0]});function a(u,f){K(!f.has(u),`circular type reference to ${JSON.stringify(u)}`,"types",t),f.add(u);for(const h of e.get(u))if(r.has(h)){a(h,f);for(const y of f)i.get(y).add(h)}f.delete(u)}a(this.primaryType,new Set);for(const[u,f]of i){const h=Array.from(f);h.sort(),S(this,Ls).set(u,zv(u,s[u])+h.map(y=>zv(y,s[y])).join(""))}}get types(){return JSON.parse(S(this,Gh))}getEncoder(t){let e=S(this,qu).get(t);return e||(e=yt(this,up,LT).call(this,t),S(this,qu).set(t,e)),e}encodeType(t){const e=S(this,Ls).get(t);return K(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return Tn(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(Om(t))return r(t,e);const i=n0(t).array;if(i)return K(i.count===-1||i.count===e.length,`array length mismatch; expected length ${i.count}`,"value",e),e.map(o=>this._visit(i.prefix,o,r));const s=this.types[t];if(s)return s.reduce((o,{name:a,type:u})=>(o[a]=this._visit(u,e[a],r),o),{});K(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new Qr(t)}static getPrimaryType(t){return Qr.from(t).primaryType}static hashStruct(t,e,r){return Qr.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){if(t[r]==null)continue;const i=$v[r];K(i,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:i})}return e.sort((r,i)=>Tm.indexOf(r.name)-Tm.indexOf(i.name)),Qr.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return In(["0x1901",Qr.hashDomain(t),Qr.from(e).hash(r)])}static hash(t,e,r){return Tn(Qr.encode(t,e,r))}static async resolveNames(t,e,r,i){t=Object.assign({},t);for(const a in t)t[a]==null&&delete t[a];const s={};t.verifyingContract&&!ze(t.verifyingContract,20)&&(s[t.verifyingContract]="0x");const o=Qr.from(e);o.visit(r,(a,u)=>(a==="address"&&!ze(u,20)&&(s[u]="0x"),u));for(const a in s)s[a]=await i(a);return t.verifyingContract&&s[t.verifyingContract]&&(t.verifyingContract=s[t.verifyingContract]),r=o.visit(r,(a,u)=>a==="address"&&s[u]?s[u]:u),{domain:t,value:r}}static getPayload(t,e,r){Qr.hashDomain(t);const i={},s=[];Tm.forEach(u=>{const f=t[u];f!=null&&(i[u]=VW[u](f),s.push({name:u,type:$v[u]}))});const o=Qr.from(e);e=o.types;const a=Object.assign({},e);return K(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",e),a.EIP712Domain=s,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,(u,f)=>{if(u.match(/^bytes(\d*)/))return kt(ye(f));if(u.match(/^u?int/))return Nt(f).toString();switch(u){case"address":return f.toLowerCase();case"bool":return!!f;case"string":return K(typeof f=="string","invalid string","value",f),f}K(!1,"unsupported type","type",u)})}}};Gh=new WeakMap,Ls=new WeakMap,qu=new WeakMap,up=new WeakSet,LT=function(t){{const i=Om(t);if(i)return i}const e=n0(t).array;if(e){const i=e.prefix,s=this.getEncoder(i);return o=>{K(e.count===-1||e.count===o.length,`array length mismatch; expected length ${e.count}`,"value",o);let a=o.map(s);return S(this,Ls).has(i)&&(a=a.map(Tn)),Tn(In(a))}}const r=this.types[t];if(r){const i=vc(S(this,Ls).get(t));return s=>{const o=r.map(({name:a,type:u})=>{const f=this.getEncoder(u)(s[a]);return S(this,Ls).has(u)?Tn(f):f});return o.unshift(i),In(o)}}K(!1,`unknown type: ${t}`,"type",t)};let np=Qr;function br(n){const t=new Set;return n.forEach(e=>t.add(e)),Object.freeze(t)}const KW="external public payable override",jW=br(KW.split(" ")),UT="constant external internal payable private public pure view override",WW=br(UT.split(" ")),DT="constructor error event fallback function receive struct",FT=br(DT.split(" ")),$T="calldata memory storage payable indexed",ZW=br($T.split(" ")),qW="tuple returns",QW=[DT,$T,qW,UT].join(" "),JW=br(QW.split(" ")),YW={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},XW=new RegExp("^(\\s*)"),tZ=new RegExp("^([0-9]+)"),eZ=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),HT=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),zT=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");var Vn,bi,Vh,$w;const lp=class lp{constructor(t){J(this,Vh);J(this,Vn);J(this,bi);F(this,Vn,0),F(this,bi,t.slice())}get offset(){return S(this,Vn)}get length(){return S(this,bi).length-S(this,Vn)}clone(){return new lp(S(this,bi))}reset(){F(this,Vn,0)}popKeyword(t){const e=this.peek();if(e.type!=="KEYWORD"||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=yt(this,Vh,$w).call(this,S(this,Vn)+1,t.match+1);return F(this,Vn,t.match+1),e}popParams(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=[];for(;S(this,Vn)<t.match-1;){const r=this.peek().linkNext;e.push(yt(this,Vh,$w).call(this,S(this,Vn)+1,r)),F(this,Vn,r)}return F(this,Vn,t.match+1),e}peek(){if(S(this,Vn)>=S(this,bi).length)throw new Error("out-of-bounds");return S(this,bi)[S(this,Vn)]}peekKeyword(t){const e=this.peekType("KEYWORD");return e!=null&&t.has(e)?e:null}peekType(t){if(this.length===0)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return ms(this,Vn)._++,t}toString(){const t=[];for(let e=S(this,Vn);e<S(this,bi).length;e++){const r=S(this,bi)[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}};Vn=new WeakMap,bi=new WeakMap,Vh=new WeakSet,$w=function(t=0,e=0){return new lp(S(this,bi).slice(t,e).map(r=>Object.freeze(Object.assign({},r,{match:r.match-t,linkBack:r.linkBack-t,linkNext:r.linkNext-t}))))};let Ni=lp;function fa(n){const t=[],e=o=>{const a=s<n.length?JSON.stringify(n[s]):"$EOI";throw new Error(`invalid token ${a} at ${s}: ${o}`)};let r=[],i=[],s=0;for(;s<n.length;){let o=n.substring(s),a=o.match(XW);a&&(s+=a[1].length,o=n.substring(s));const u={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};t.push(u);let f=YW[o[0]]||"";if(f){if(u.type=f,u.text=o[0],s++,f==="OPEN_PAREN")r.push(t.length-1),i.push(t.length-1);else if(f=="CLOSE_PAREN")r.length===0&&e("no matching open bracket"),u.match=r.pop(),t[u.match].match=t.length-1,u.depth--,u.linkBack=i.pop(),t[u.linkBack].linkNext=t.length-1;else if(f==="COMMA")u.linkBack=i.pop(),t[u.linkBack].linkNext=t.length-1,i.push(t.length-1);else if(f==="OPEN_BRACKET")u.type="BRACKET";else if(f==="CLOSE_BRACKET"){let h=t.pop().text;if(t.length>0&&t[t.length-1].type==="NUMBER"){const y=t.pop().text;h=y+h,t[t.length-1].value=oe(y)}if(t.length===0||t[t.length-1].type!=="BRACKET")throw new Error("missing opening bracket");t[t.length-1].text+=h}continue}if(a=o.match(eZ),a){if(u.text=a[1],s+=u.text.length,JW.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(zT)){u.type="TYPE";continue}u.type="ID";continue}if(a=o.match(tZ),a){u.text=a[1],u.type="NUMBER",s+=u.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${s}`)}return new Ni(t.map(o=>Object.freeze(o)))}function Gv(n,t){let e=[];for(const r in t.keys())n.has(r)&&e.push(r);if(e.length>1)throw new Error(`conflicting types: ${e.join(", ")}`)}function ag(n,t){if(t.peekKeyword(FT)){const e=t.pop().text;if(e!==n)throw new Error(`expected ${n}, got ${e}`)}return t.popType("ID")}function no(n,t){const e=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||t&&!t.has(r))break;if(n.pop(),e.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);e.add(r)}return Object.freeze(e)}function GT(n){let t=no(n,WW);return Gv(t,br("constant payable nonpayable".split(" "))),Gv(t,br("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function Ys(n,t){return n.popParams().map(e=>Jn.from(e,t))}function VT(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return Nt(n.pop().text);throw new Error("invalid gas")}return null}function xc(n){if(n.length)throw new Error(`unexpected tokens at offset ${n.offset}: ${n.toString()}`)}const nZ=new RegExp(/^(.*)\[([0-9]*)\]$/);function Vv(n){const t=n.match(zT);if(K(t,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(t[2]){const e=parseInt(t[2]);K(e!==0&&e<=32,"invalid bytes length","type",n)}else if(t[3]){const e=parseInt(t[3]);K(e!==0&&e<=256&&e%8===0,"invalid numeric width","type",n)}return n}const sn={},Br=Symbol.for("_ethers_internal"),Kv="_ParamTypeInternal",jv="_ErrorInternal",Wv="_EventInternal",Zv="_ConstructorInternal",qv="_FallbackInternal",Qv="_FunctionInternal",Jv="_StructInternal";var Qu,y0;const Jr=class Jr{constructor(t,e,r,i,s,o,a,u){J(this,Qu);Z(this,"name");Z(this,"type");Z(this,"baseType");Z(this,"indexed");Z(this,"components");Z(this,"arrayLength");Z(this,"arrayChildren");if(Yp(t,sn,"ParamType"),Object.defineProperty(this,Br,{value:Kv}),o&&(o=Object.freeze(o.slice())),i==="array"){if(a==null||u==null)throw new Error("")}else if(a!=null||u!=null)throw new Error("");if(i==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");$t(this,{name:e,type:r,baseType:i,indexed:s,components:o,arrayLength:a,arrayChildren:u})}format(t){if(t==null&&(t="sighash"),t==="json"){const r=this.name||"";if(this.isArray()){const s=JSON.parse(this.arrayChildren.format("json"));return s.name=r,s.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(s)}const i={type:this.baseType==="tuple"?"tuple":this.type,name:r};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.isTuple()&&(i.components=this.components.map(s=>JSON.parse(s.format(t)))),JSON.stringify(i)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map(r=>r.format(t)).join(t==="full"?", ":",")+")":e+=this.type,t!=="sighash"&&(this.indexed===!0&&(e+=" indexed"),t==="full"&&this.name&&(e+=" "+this.name)),e}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return t.map(i=>r.arrayChildren.walk(i,e))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const r=this;return t.map((i,s)=>r.components[s].walk(i,e))}return e(this.type,t)}async walkAsync(t,e){const r=[],i=[t];return yt(this,Qu,y0).call(this,r,t,e,s=>{i[0]=s}),r.length&&await Promise.all(r),i[0]}static from(t,e){if(Jr.isParamType(t))return t;if(typeof t=="string")try{return Jr.from(fa(t),e)}catch{K(!1,"invalid param type","obj",t)}else if(t instanceof Ni){let a="",u="",f=null;no(t,br(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(u="tuple",f=t.popParams().map(T=>Jr.from(T)),a=`tuple(${f.map(T=>T.format()).join(",")})`):(a=Vv(t.popType("TYPE")),u=a);let h=null,y=null;for(;t.length&&t.peekType("BRACKET");){const T=t.pop();h=new Jr(sn,"",a,u,null,f,y,h),y=T.value,a+=T.text,u="array",f=null}let _=null;if(no(t,ZW).has("indexed")){if(!e)throw new Error("");_=!0}const R=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new Jr(sn,R,a,u,_,f,y,h)}const r=t.name;K(!r||typeof r=="string"&&r.match(HT),"invalid name","obj.name",r);let i=t.indexed;i!=null&&(K(e,"parameter cannot be indexed","obj.indexed",t.indexed),i=!!i);let s=t.type,o=s.match(nZ);if(o){const a=parseInt(o[2]||"-1"),u=Jr.from({type:o[1],components:t.components});return new Jr(sn,r||"",s,"array",i,null,a,u)}if(s==="tuple"||s.startsWith("tuple(")||s.startsWith("(")){const a=t.components!=null?t.components.map(f=>Jr.from(f)):null;return new Jr(sn,r||"",s,"tuple",i,a,null,null)}return s=Vv(t.type),new Jr(sn,r||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[Br]===Kv}};Qu=new WeakSet,y0=function(t,e,r,i){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=e.slice();a.forEach((u,f)=>{var h;yt(h=o,Qu,y0).call(h,t,u,r,y=>{a[f]=y})}),i(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(e))a=e.slice();else{if(e==null||typeof e!="object")throw new Error("invalid tuple value");a=o.map(u=>{if(!u.name)throw new Error("cannot use object value with unnamed components");if(!(u.name in e))throw new Error(`missing value for component ${u.name}`);return e[u.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((u,f)=>{var h;yt(h=o[f],Qu,y0).call(h,t,u,r,y=>{a[f]=y})}),i(a);return}const s=r(this.type,e);s.then?t.push(async function(){i(await s)}()):i(s)};let Jn=Jr;class Rc{constructor(t,e,r){Z(this,"type");Z(this,"inputs");Yp(t,sn,"Fragment"),r=Object.freeze(r.slice()),$t(this,{type:e,inputs:r})}static from(t){if(typeof t=="string"){try{Rc.from(JSON.parse(t))}catch{}return Rc.from(fa(t))}if(t instanceof Ni)switch(t.peekKeyword(FT)){case"constructor":return qs.from(t);case"error":return kr.from(t);case"event":return Xi.from(t);case"fallback":case"receive":return Ts.from(t);case"function":return ts.from(t);case"struct":return lc.from(t)}else if(typeof t=="object"){switch(t.type){case"constructor":return qs.from(t);case"error":return kr.from(t);case"event":return Xi.from(t);case"fallback":case"receive":return Ts.from(t);case"function":return ts.from(t);case"struct":return lc.from(t)}ht(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}K(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return qs.isFragment(t)}static isError(t){return kr.isFragment(t)}static isEvent(t){return Xi.isFragment(t)}static isFunction(t){return ts.isFragment(t)}static isStruct(t){return lc.isFragment(t)}}class cg extends Rc{constructor(e,r,i,s){super(e,r,s);Z(this,"name");K(typeof i=="string"&&i.match(HT),"invalid identifier","name",i),s=Object.freeze(s.slice()),$t(this,{name:i})}}function Bh(n,t){return"("+t.map(e=>e.format(n)).join(n==="full"?", ":",")+")"}class kr extends cg{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Br,{value:jv})}get selector(){return vc(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(t)))});const e=[];return t!=="sighash"&&e.push("error"),e.push(this.name+Bh(t,this.inputs)),e.join(" ")}static from(t){if(kr.isFragment(t))return t;if(typeof t=="string")return kr.from(fa(t));if(t instanceof Ni){const e=ag("error",t),r=Ys(t);return xc(t),new kr(sn,e,r)}return new kr(sn,t.name,t.inputs?t.inputs.map(Jn.from):[])}static isFragment(t){return t&&t[Br]===jv}}class Xi extends cg{constructor(e,r,i,s){super(e,"event",r,i);Z(this,"anonymous");Object.defineProperty(this,Br,{value:Wv}),$t(this,{anonymous:s})}get topicHash(){return vc(this.format("sighash"))}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});const r=[];return e!=="sighash"&&r.push("event"),r.push(this.name+Bh(e,this.inputs)),e!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(e,r){return r=(r||[]).map(s=>Jn.from(s)),new Xi(sn,e,r,!1).topicHash}static from(e){if(Xi.isFragment(e))return e;if(typeof e=="string")try{return Xi.from(fa(e))}catch{K(!1,"invalid event fragment","obj",e)}else if(e instanceof Ni){const r=ag("event",e),i=Ys(e,!0),s=!!no(e,br(["anonymous"])).has("anonymous");return xc(e),new Xi(sn,r,i,s)}return new Xi(sn,e.name,e.inputs?e.inputs.map(r=>Jn.from(r,!0)):[],!!e.anonymous)}static isFragment(e){return e&&e[Br]===Wv}}class qs extends Rc{constructor(e,r,i,s,o){super(e,r,i);Z(this,"payable");Z(this,"gas");Object.defineProperty(this,Br,{value:Zv}),$t(this,{payable:s,gas:o})}format(e){if(ht(e!=null&&e!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),e==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});const r=[`constructor${Bh(e,this.inputs)}`];return this.payable&&r.push("payable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(e){if(qs.isFragment(e))return e;if(typeof e=="string")try{return qs.from(fa(e))}catch{K(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof Ni){no(e,br(["constructor"]));const r=Ys(e),i=!!no(e,jW).has("payable"),s=VT(e);return xc(e),new qs(sn,"constructor",r,i,s)}return new qs(sn,"constructor",e.inputs?e.inputs.map(Jn.from):[],!!e.payable,e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[Br]===Zv}}class Ts extends Rc{constructor(e,r,i){super(e,"fallback",r);Z(this,"payable");Object.defineProperty(this,Br,{value:qv}),$t(this,{payable:i})}format(e){const r=this.inputs.length===0?"receive":"fallback";if(e==="json"){const i=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:i})}return`${r}()${this.payable?" payable":""}`}static from(e){if(Ts.isFragment(e))return e;if(typeof e=="string")try{return Ts.from(fa(e))}catch{K(!1,"invalid fallback fragment","obj",e)}else if(e instanceof Ni){const r=e.toString(),i=e.peekKeyword(br(["fallback","receive"]));if(K(i,"type must be fallback or receive","obj",r),e.popKeyword(br(["fallback","receive"]))==="receive"){const u=Ys(e);return K(u.length===0,"receive cannot have arguments","obj.inputs",u),no(e,br(["payable"])),xc(e),new Ts(sn,[],!0)}let o=Ys(e);o.length?K(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(u=>u.format("minimal")).join(", ")):o=[Jn.from("bytes")];const a=GT(e);if(K(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),no(e,br(["returns"])).has("returns")){const u=Ys(e);K(u.length===1&&u[0].type==="bytes","invalid fallback outputs","obj.outputs",u.map(f=>f.format("minimal")).join(", "))}return xc(e),new Ts(sn,o,a==="payable")}if(e.type==="receive")return new Ts(sn,[],!0);if(e.type==="fallback"){const r=[Jn.from("bytes")],i=e.stateMutability==="payable";return new Ts(sn,r,i)}K(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[Br]===qv}}class ts extends cg{constructor(e,r,i,s,o,a){super(e,"function",r,s);Z(this,"constant");Z(this,"outputs");Z(this,"stateMutability");Z(this,"payable");Z(this,"gas");Object.defineProperty(this,Br,{value:Qv}),o=Object.freeze(o.slice()),$t(this,{constant:i==="view"||i==="pure",gas:a,outputs:o,payable:i==="payable",stateMutability:i})}get selector(){return vc(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(e))),outputs:this.outputs.map(i=>JSON.parse(i.format(e)))});const r=[];return e!=="sighash"&&r.push("function"),r.push(this.name+Bh(e,this.inputs)),e!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(Bh(e,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(e,r){return r=(r||[]).map(s=>Jn.from(s)),new ts(sn,e,"view",r,[],null).selector}static from(e){if(ts.isFragment(e))return e;if(typeof e=="string")try{return ts.from(fa(e))}catch{K(!1,"invalid function fragment","obj",e)}else if(e instanceof Ni){const i=ag("function",e),s=Ys(e),o=GT(e);let a=[];no(e,br(["returns"])).has("returns")&&(a=Ys(e));const u=VT(e);return xc(e),new ts(sn,i,o,s,a,u)}let r=e.stateMutability;return r==null&&(r="payable",typeof e.constant=="boolean"?(r="view",e.constant||(r="payable",typeof e.payable=="boolean"&&!e.payable&&(r="nonpayable"))):typeof e.payable=="boolean"&&!e.payable&&(r="nonpayable")),new ts(sn,e.name,r,e.inputs?e.inputs.map(Jn.from):[],e.outputs?e.outputs.map(Jn.from):[],e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[Br]===Qv}}class lc extends cg{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Br,{value:Jv})}format(){throw new Error("@TODO")}static from(t){if(typeof t=="string")try{return lc.from(fa(t))}catch{K(!1,"invalid struct fragment","obj",t)}else if(t instanceof Ni){const e=ag("struct",t),r=Ys(t);return xc(t),new lc(sn,e,r)}return new lc(sn,t.name,t.inputs?t.inputs.map(Jn.from):[])}static isFragment(t){return t&&t[Br]===Jv}}const Ci=new Map;Ci.set(0,"GENERIC_PANIC");Ci.set(1,"ASSERT_FALSE");Ci.set(17,"OVERFLOW");Ci.set(18,"DIVIDE_BY_ZERO");Ci.set(33,"ENUM_RANGE_ERROR");Ci.set(34,"BAD_STORAGE_DATA");Ci.set(49,"STACK_UNDERFLOW");Ci.set(50,"ARRAY_RANGE_ERROR");Ci.set(65,"OUT_OF_MEMORY");Ci.set(81,"UNINITIALIZED_FUNCTION_CALL");const rZ=new RegExp(/^bytes([0-9]*)$/),iZ=new RegExp(/^(u?int)([0-9]*)$/);let Nm=null,Yv=1024;function sZ(n,t,e,r){let i="missing revert data",s=null;const o=null;let a=null;if(e){i="execution reverted";const f=ye(e);if(e=kt(e),f.length===0)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(f.length%32!==4)i+=" (could not decode reason; invalid data length)";else if(kt(f.slice(0,4))==="0x08c379a0")try{s=r.decode(["string"],f.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch{i+=" (could not decode reason; invalid string data)"}else if(kt(f.slice(0,4))==="0x4e487b71")try{const h=Number(r.decode(["uint256"],f.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[h]},s=`Panic due to ${Ci.get(h)||"UNKNOWN"}(${h})`,i+=`: ${s}`}catch{i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const u={to:t.to?Me(t.to):null,data:t.data||"0x"};return t.from&&(u.from=Me(t.from)),qe(i,"CALL_EXCEPTION",{action:n,data:e,reason:s,transaction:u,invocation:o,revert:a})}var Oo,tu;const fp=class fp{constructor(){J(this,Oo)}getDefaultValue(t){const e=t.map(i=>yt(this,Oo,tu).call(this,Jn.from(i)));return new e0(e,"_").defaultValue()}encode(t,e){bk(e.length,t.length,"types/values length mismatch");const r=t.map(o=>yt(this,Oo,tu).call(this,Jn.from(o))),i=new e0(r,"_"),s=new Iw;return i.encode(s,e),s.data}decode(t,e,r){const i=t.map(o=>yt(this,Oo,tu).call(this,Jn.from(o)));return new e0(i,"_").decode(new Sw(e,r,Yv))}static _setDefaultMaxInflation(t){K(typeof t=="number"&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),Yv=t}static defaultAbiCoder(){return Nm==null&&(Nm=new fp),Nm}static getBuiltinCallException(t,e,r){return sZ(t,e,r,fp.defaultAbiCoder())}};Oo=new WeakSet,tu=function(t){if(t.isArray())return new kj(yt(this,Oo,tu).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new e0(t.components.map(r=>yt(this,Oo,tu).call(this,r)),t.name);switch(t.baseType){case"address":return new Ij(t.name);case"bool":return new Tj(t.name);case"string":return new Dj(t.name);case"bytes":return new Oj(t.name);case"":return new Bj(t.name)}let e=t.type.match(iZ);if(e){let r=parseInt(e[2]||"256");return K(r!==0&&r<=256&&r%8===0,"invalid "+e[1]+" bit length","param",t),new Uj(r/8,e[1]==="int",t.name)}if(e=t.type.match(rZ),e){let r=parseInt(e[1]);return K(r!==0&&r<=32,"invalid bytes length","param",t),new Nj(r,t.name)}K(!1,"invalid type","type",t.type)};let Ph=fp;class oZ{constructor(t,e,r){Z(this,"fragment");Z(this,"name");Z(this,"signature");Z(this,"topic");Z(this,"args");const i=t.name,s=t.format();$t(this,{fragment:t,name:i,signature:s,topic:e,args:r})}}class aZ{constructor(t,e,r,i){Z(this,"fragment");Z(this,"name");Z(this,"args");Z(this,"signature");Z(this,"selector");Z(this,"value");const s=t.name,o=t.format();$t(this,{fragment:t,name:s,args:r,signature:o,selector:e,value:i})}}class cZ{constructor(t,e,r){Z(this,"fragment");Z(this,"name");Z(this,"args");Z(this,"signature");Z(this,"selector");const i=t.name,s=t.format();$t(this,{fragment:t,name:i,args:r,signature:s,selector:e})}}class Xv{constructor(t){Z(this,"hash");Z(this,"_isIndexed");$t(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!!(t&&t._isIndexed)}}const tx={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},ex={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let t="unknown panic code";return n>=0&&n<=255&&tx[n.toString()]&&(t=tx[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${t})`}}};var $i,Hi,zi,ir,as,m0,w0;const Sa=class Sa{constructor(t){J(this,as);Z(this,"fragments");Z(this,"deploy");Z(this,"fallback");Z(this,"receive");J(this,$i);J(this,Hi);J(this,zi);J(this,ir);let e=[];typeof t=="string"?e=JSON.parse(t):e=t,F(this,zi,new Map),F(this,$i,new Map),F(this,Hi,new Map);const r=[];for(const o of e)try{r.push(Rc.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}$t(this,{fragments:Object.freeze(r)});let i=null,s=!1;F(this,ir,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let u;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}$t(this,{deploy:o});return;case"fallback":o.inputs.length===0?s=!0:(K(!i||o.payable!==i.payable,"conflicting fallback fragments",`fragments[${a}]`,o),i=o,s=i.payable);return;case"function":u=S(this,zi);break;case"event":u=S(this,Hi);break;case"error":u=S(this,$i);break;default:return}const f=o.format();u.has(f)||u.set(f,o)}),this.deploy||$t(this,{deploy:qs.from("constructor()")}),$t(this,{fallback:i,receive:s})}format(t){const e=t?"minimal":"full";return this.fragments.map(i=>i.format(e))}formatJson(){const t=this.fragments.map(e=>e.format("json"));return JSON.stringify(t.map(e=>JSON.parse(e)))}getAbiCoder(){return Ph.defaultAbiCoder()}getFunctionName(t){const e=yt(this,as,m0).call(this,t,null,!1);return K(e,"no matching function","key",t),e.name}hasFunction(t){return!!yt(this,as,m0).call(this,t,null,!1)}getFunction(t,e){return yt(this,as,m0).call(this,t,e||null,!0)}forEachFunction(t){const e=Array.from(S(this,zi).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(S(this,zi).get(i),r)}}getEventName(t){const e=yt(this,as,w0).call(this,t,null,!1);return K(e,"no matching event","key",t),e.name}hasEvent(t){return!!yt(this,as,w0).call(this,t,null,!1)}getEvent(t,e){return yt(this,as,w0).call(this,t,e||null,!0)}forEachEvent(t){const e=Array.from(S(this,Hi).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(S(this,Hi).get(i),r)}}getError(t,e){if(ze(t)){const i=t.toLowerCase();if(ex[i])return kr.from(ex[i].signature);for(const s of S(this,$i).values())if(i===s.selector)return s;return null}if(t.indexOf("(")===-1){const i=[];for(const[s,o]of S(this,$i))s.split("(")[0]===t&&i.push(o);if(i.length===0)return t==="Error"?kr.from("error Error(string)"):t==="Panic"?kr.from("error Panic(uint256)"):null;if(i.length>1){const s=i.map(o=>JSON.stringify(o.format())).join(", ");K(!1,`ambiguous error description (i.e. ${s})`,"name",t)}return i[0]}if(t=kr.from(t).format(),t==="Error(string)")return kr.from("error Error(string)");if(t==="Panic(uint256)")return kr.from("error Panic(uint256)");const r=S(this,$i).get(t);return r||null}forEachError(t){const e=Array.from(S(this,$i).keys());e.sort((r,i)=>r.localeCompare(i));for(let r=0;r<e.length;r++){const i=e[r];t(S(this,$i).get(i),r)}}_decodeParams(t,e){return S(this,ir).decode(t,e)}_encodeParams(t,e){return S(this,ir).encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if(typeof t=="string"){const r=this.getError(t);K(r,"unknown error","fragment",t),t=r}return K(_n(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,_n(e,4))}encodeErrorResult(t,e){if(typeof t=="string"){const r=this.getError(t);K(r,"unknown error","fragment",t),t=r}return In([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return K(_n(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,_n(e,4))}encodeFunctionData(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return In([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if(typeof t=="string"){const s=this.getFunction(t);K(s,"unknown function","fragment",t),t=s}let r="invalid length for result data";const i=dr(e);if(i.length%32===0)try{return S(this,ir).decode(t.outputs,i)}catch{r="could not decode result data"}ht(!1,r,"BAD_DATA",{value:kt(i),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=ye(t,"data"),i=Ph.getBuiltinCallException("call",e,r);if(i.message.startsWith("execution reverted (unknown custom error)")){const a=kt(r.slice(0,4)),u=this.getError(a);if(u)try{const f=S(this,ir).decode(u.inputs,r.slice(4));i.revert={name:u.name,signature:u.format(),args:f},i.reason=i.revert.signature,i.message=`execution reverted: ${i.reason}`}catch{i.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(e);return o&&(i.invocation={method:o.name,signature:o.signature,args:o.args}),i}encodeFunctionResult(t,e){if(typeof t=="string"){const r=this.getFunction(t);K(r,"unknown function","fragment",t),t=r}return kt(S(this,ir).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if(typeof t=="string"){const s=this.getEvent(t);K(s,"unknown event","eventFragment",t),t=s}ht(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const i=(s,o)=>s.type==="string"?vc(o):s.type==="bytes"?Tn(kt(o)):(s.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":s.type.match(/^u?int/)?o=aa(o):s.type.match(/^bytes/)?o=BV(o,32):s.type==="address"&&S(this,ir).encode(["address"],[o]),Ac(kt(o),32));for(e.forEach((s,o)=>{const a=t.inputs[o];if(!a.indexed){K(s==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,s);return}s==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?K(!1,"filtering with tuples or arrays not supported","contract."+a.name,s):Array.isArray(s)?r.push(s.map(u=>i(a,u))):r.push(i(a,s))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(t,e){if(typeof t=="string"){const o=this.getEvent(t);K(o,"unknown event","eventFragment",t),t=o}const r=[],i=[],s=[];return t.anonymous||r.push(t.topicHash),K(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach((o,a)=>{const u=e[a];if(o.indexed)if(o.type==="string")r.push(vc(u));else if(o.type==="bytes")r.push(Tn(u));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(S(this,ir).encode([o.type],[u]))}else i.push(o),s.push(u)}),{data:S(this,ir).encode(i,s),topics:r}}decodeEventLog(t,e,r){if(typeof t=="string"){const w=this.getEvent(t);K(w,"unknown event","eventFragment",t),t=w}if(r!=null&&!t.anonymous){const w=t.topicHash;K(ze(r[0],32)&&r[0].toLowerCase()===w,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const i=[],s=[],o=[];t.inputs.forEach((w,R)=>{w.indexed?w.type==="string"||w.type==="bytes"||w.baseType==="tuple"||w.baseType==="array"?(i.push(Jn.from({type:"bytes32",name:w.name})),o.push(!0)):(i.push(w),o.push(!1)):(s.push(w),o.push(!1))});const a=r!=null?S(this,ir).decode(i,In(r)):null,u=S(this,ir).decode(s,e,!0),f=[],h=[];let y=0,_=0;return t.inputs.forEach((w,R)=>{let T=null;if(w.indexed)if(a==null)T=new Xv(null);else if(o[R])T=new Xv(a[_++]);else try{T=a[_++]}catch(I){T=I}else try{T=u[y++]}catch(I){T=I}f.push(T),h.push(w.name||null)}),Il.fromItems(f,h)}parseTransaction(t){const e=ye(t.data,"tx.data"),r=Nt(t.value!=null?t.value:0,"tx.value"),i=this.getFunction(kt(e.slice(0,4)));if(!i)return null;const s=S(this,ir).decode(i.inputs,e.slice(4));return new aZ(i,i.selector,s,r)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new oZ(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=kt(t),r=this.getError(_n(e,0,4));if(!r)return null;const i=S(this,ir).decode(r.inputs,_n(e,4));return new cZ(r,r.selector,i)}static from(t){return t instanceof Sa?t:typeof t=="string"?new Sa(JSON.parse(t)):typeof t.formatJson=="function"?new Sa(t.formatJson()):typeof t.format=="function"?new Sa(t.format("json")):new Sa(t)}};$i=new WeakMap,Hi=new WeakMap,zi=new WeakMap,ir=new WeakMap,as=new WeakSet,m0=function(t,e,r){if(ze(t)){const s=t.toLowerCase();for(const o of S(this,zi).values())if(s===o.selector)return o;return null}if(t.indexOf("(")===-1){const s=[];for(const[o,a]of S(this,zi))o.split("(")[0]===t&&s.push(a);if(e){const o=e.length>0?e[e.length-1]:null;let a=e.length,u=!0;cr.isTyped(o)&&o.type==="overrides"&&(u=!1,a--);for(let f=s.length-1;f>=0;f--){const h=s[f].inputs.length;h!==a&&(!u||h!==a-1)&&s.splice(f,1)}for(let f=s.length-1;f>=0;f--){const h=s[f].inputs;for(let y=0;y<e.length;y++)if(cr.isTyped(e[y])){if(y>=h.length){if(e[y].type==="overrides")continue;s.splice(f,1);break}if(e[y].type!==h[y].baseType){s.splice(f,1);break}}}}if(s.length===1&&e&&e.length!==s[0].inputs.length){const o=e[e.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&s.splice(0,1)}if(s.length===0)return null;if(s.length>1&&r){const o=s.map(a=>JSON.stringify(a.format())).join(", ");K(!1,`ambiguous function description (i.e. matches ${o})`,"key",t)}return s[0]}const i=S(this,zi).get(ts.from(t).format());return i||null},w0=function(t,e,r){if(ze(t)){const s=t.toLowerCase();for(const o of S(this,Hi).values())if(s===o.topicHash)return o;return null}if(t.indexOf("(")===-1){const s=[];for(const[o,a]of S(this,Hi))o.split("(")[0]===t&&s.push(a);if(e){for(let o=s.length-1;o>=0;o--)s[o].inputs.length<e.length&&s.splice(o,1);for(let o=s.length-1;o>=0;o--){const a=s[o].inputs;for(let u=0;u<e.length;u++)if(cr.isTyped(e[u])&&e[u].type!==a[u].baseType){s.splice(o,1);break}}}if(s.length===0)return null;if(s.length>1&&r){const o=s.map(a=>JSON.stringify(a.format())).join(", ");K(!1,`ambiguous event description (i.e. matches ${o})`,"key",t)}return s[0]}const i=S(this,Hi).get(Xi.from(t).format());return i||null};let Hw=Sa;const KT=BigInt(0);function bu(n){return n??null}function vn(n){return n==null?null:n.toString()}class nx{constructor(t,e,r){Z(this,"gasPrice");Z(this,"maxFeePerGas");Z(this,"maxPriorityFeePerGas");$t(this,{gasPrice:bu(t),maxFeePerGas:bu(e),maxPriorityFeePerGas:bu(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:vn(t),maxFeePerGas:vn(e),maxPriorityFeePerGas:vn(r)}}}function rp(n){const t={};n.to&&(t.to=n.to),n.from&&(t.from=n.from),n.data&&(t.data=kt(n.data));const e="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of e)!(i in n)||n[i]==null||(t[i]=Nt(n[i],`request.${i}`));const r="type,nonce".split(/,/);for(const i of r)!(i in n)||n[i]==null||(t[i]=oe(n[i],`request.${i}`));return n.accessList&&(t.accessList=Pc(n.accessList)),"blockTag"in n&&(t.blockTag=n.blockTag),"enableCcipRead"in n&&(t.enableCcipRead=!!n.enableCcipRead),"customData"in n&&(t.customData=n.customData),"blobVersionedHashes"in n&&n.blobVersionedHashes&&(t.blobVersionedHashes=n.blobVersionedHashes.slice()),"kzg"in n&&(t.kzg=n.kzg),"blobs"in n&&n.blobs&&(t.blobs=n.blobs.map(i=>ub(i)?kt(i):Object.assign({},i))),t}var Us;class uZ{constructor(t,e){Z(this,"provider");Z(this,"number");Z(this,"hash");Z(this,"timestamp");Z(this,"parentHash");Z(this,"parentBeaconBlockRoot");Z(this,"nonce");Z(this,"difficulty");Z(this,"gasLimit");Z(this,"gasUsed");Z(this,"stateRoot");Z(this,"receiptsRoot");Z(this,"blobGasUsed");Z(this,"excessBlobGas");Z(this,"miner");Z(this,"prevRandao");Z(this,"extraData");Z(this,"baseFeePerGas");J(this,Us);F(this,Us,t.transactions.map(r=>typeof r!="string"?new Mh(r,e):r)),$t(this,{provider:e,hash:bu(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:bu(t.prevRandao),extraData:t.extraData,baseFeePerGas:bu(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return S(this,Us).map(t=>typeof t=="string"?t:t.hash)}get prefetchedTransactions(){const t=S(this,Us).slice();return t.length===0?[]:(ht(typeof t[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:i,gasUsed:s,hash:o,miner:a,prevRandao:u,nonce:f,number:h,parentHash:y,parentBeaconBlockRoot:_,stateRoot:w,receiptsRoot:R,timestamp:T,transactions:I}=this;return{_type:"Block",baseFeePerGas:vn(t),difficulty:vn(e),extraData:r,gasLimit:vn(i),gasUsed:vn(s),blobGasUsed:vn(this.blobGasUsed),excessBlobGas:vn(this.excessBlobGas),hash:o,miner:a,prevRandao:u,nonce:f,number:h,parentHash:y,timestamp:T,parentBeaconBlockRoot:_,stateRoot:w,receiptsRoot:R,transactions:I}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return S(this,Us).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(t){let e;if(typeof t=="number")e=S(this,Us)[t];else{const r=t.toLowerCase();for(const i of S(this,Us))if(typeof i=="string"){if(i!==r)continue;e=i;break}else{if(i.hash!==r)continue;e=i;break}}if(e==null)throw new Error("no such tx");return typeof e=="string"?await this.provider.getTransaction(e):e}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if(typeof t=="number")return e[t];t=t.toLowerCase();for(const r of e)if(r.hash===t)return r;K(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return lZ(this)}}Us=new WeakMap;class wd{constructor(t,e){Z(this,"provider");Z(this,"transactionHash");Z(this,"blockHash");Z(this,"blockNumber");Z(this,"removed");Z(this,"address");Z(this,"data");Z(this,"topics");Z(this,"index");Z(this,"transactionIndex");this.provider=e;const r=Object.freeze(t.topics.slice());$t(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:i,index:s,removed:o,topics:a,transactionHash:u,transactionIndex:f}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:i,index:s,removed:o,topics:a,transactionHash:u,transactionIndex:f}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return ht(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return ht(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return ht(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return fZ(this)}}var Kh;class jT{constructor(t,e){Z(this,"provider");Z(this,"to");Z(this,"from");Z(this,"contractAddress");Z(this,"hash");Z(this,"index");Z(this,"blockHash");Z(this,"blockNumber");Z(this,"logsBloom");Z(this,"gasUsed");Z(this,"blobGasUsed");Z(this,"cumulativeGasUsed");Z(this,"gasPrice");Z(this,"blobGasPrice");Z(this,"type");Z(this,"status");Z(this,"root");J(this,Kh);F(this,Kh,Object.freeze(t.logs.map(i=>new wd(i,e))));let r=KT;t.effectiveGasPrice!=null?r=t.effectiveGasPrice:t.gasPrice!=null&&(r=t.gasPrice),$t(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return S(this,Kh)}toJSON(){const{to:t,from:e,contractAddress:r,hash:i,index:s,blockHash:o,blockNumber:a,logsBloom:u,logs:f,status:h,root:y}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:vn(this.cumulativeGasUsed),from:e,gasPrice:vn(this.gasPrice),blobGasUsed:vn(this.blobGasUsed),blobGasPrice:vn(this.blobGasPrice),gasUsed:vn(this.gasUsed),hash:i,index:s,logs:f,logsBloom:u,root:y,status:h,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(t==null)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(t==null)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return ZT(this)}reorderedEvent(t){return ht(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),WT(this,t)}}Kh=new WeakMap;var No;const Pb=class Pb{constructor(t,e){Z(this,"provider");Z(this,"blockNumber");Z(this,"blockHash");Z(this,"index");Z(this,"hash");Z(this,"type");Z(this,"to");Z(this,"from");Z(this,"nonce");Z(this,"gasLimit");Z(this,"gasPrice");Z(this,"maxPriorityFeePerGas");Z(this,"maxFeePerGas");Z(this,"maxFeePerBlobGas");Z(this,"data");Z(this,"value");Z(this,"chainId");Z(this,"signature");Z(this,"accessList");Z(this,"blobVersionedHashes");J(this,No);this.provider=e,this.blockNumber=t.blockNumber!=null?t.blockNumber:null,this.blockHash=t.blockHash!=null?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=t.maxPriorityFeePerGas!=null?t.maxPriorityFeePerGas:null,this.maxFeePerGas=t.maxFeePerGas!=null?t.maxFeePerGas:null,this.maxFeePerBlobGas=t.maxFeePerBlobGas!=null?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=t.accessList!=null?t.accessList:null,this.blobVersionedHashes=t.blobVersionedHashes!=null?t.blobVersionedHashes:null,F(this,No,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:i,type:s,to:o,from:a,nonce:u,data:f,signature:h,accessList:y,blobVersionedHashes:_}=this;return{_type:"TransactionResponse",accessList:y,blockNumber:t,blockHash:e,blobVersionedHashes:_,chainId:vn(this.chainId),data:f,from:a,gasLimit:vn(this.gasLimit),gasPrice:vn(this.gasPrice),hash:i,maxFeePerGas:vn(this.maxFeePerGas),maxPriorityFeePerGas:vn(this.maxPriorityFeePerGas),maxFeePerBlobGas:vn(this.maxFeePerBlobGas),nonce:u,signature:h,to:o,index:r,type:s,value:vn(this.value)}}async getBlock(){let t=this.blockNumber;if(t==null){const r=await this.getTransaction();r&&(t=r.blockNumber)}if(t==null)return null;const e=this.provider.getBlock(t);if(e==null)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:e,blockNumber:r}=await hr({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return e==null||e.blockNumber==null?0:r-e.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const r=t??1,i=e??0;let s=S(this,No),o=-1,a=s===-1;const u=async()=>{if(a)return null;const{blockNumber:_,nonce:w}=await hr({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(w<this.nonce){s=_;return}if(a)return null;const R=await this.getTransaction();if(!(R&&R.blockNumber!=null))for(o===-1&&(o=s-3,o<S(this,No)&&(o=S(this,No)));o<=_;){if(a)return null;const T=await this.provider.getBlock(o,!0);if(T==null)return;for(const I of T)if(I===this.hash)return;for(let I=0;I<T.length;I++){const B=await T.getTransaction(I);if(B.from===this.from&&B.nonce===this.nonce){if(a)return null;const H=await this.provider.getTransactionReceipt(B.hash);if(H==null||_-H.blockNumber+1<r)return;let U="replaced";B.data===this.data&&B.to===this.to&&B.value===this.value?U="repriced":B.data==="0x"&&B.from===B.to&&B.value===KT&&(U="cancelled"),ht(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:U==="replaced"||U==="cancelled",reason:U,replacement:B.replaceableTransaction(s),hash:B.hash,receipt:H})}}o++}},f=_=>{if(_==null||_.status!==0)return _;ht(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:_.to,from:_.from,data:""},receipt:_})},h=await this.provider.getTransactionReceipt(this.hash);if(r===0)return f(h);if(h){if(await h.confirmations()>=r)return f(h)}else if(await u(),r===0)return null;return await new Promise((_,w)=>{const R=[],T=()=>{R.forEach(B=>B())};if(R.push(()=>{a=!0}),i>0){const B=setTimeout(()=>{T(),w(qe("wait for transaction timeout","TIMEOUT"))},i);R.push(()=>{clearTimeout(B)})}const I=async B=>{if(await B.confirmations()>=r){T();try{_(f(B))}catch(H){w(H)}}};if(R.push(()=>{this.provider.off(this.hash,I)}),this.provider.on(this.hash,I),s>=0){const B=async()=>{try{await u()}catch(H){if(Zn(H,"TRANSACTION_REPLACED")){T(),w(H);return}}a||this.provider.once("block",B)};R.push(()=>{this.provider.off("block",B)}),this.provider.once("block",B)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return ht(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ZT(this)}reorderedEvent(t){return ht(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ht(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),WT(this,t)}replaceableTransaction(t){K(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new Pb(this,this.provider);return F(e,No,t),e}};No=new WeakMap;let Mh=Pb;function lZ(n){return{orphan:"drop-block",hash:n.hash,number:n.number}}function WT(n,t){return{orphan:"reorder-transaction",tx:n,other:t}}function ZT(n){return{orphan:"drop-transaction",tx:n}}function fZ(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class Ib extends wd{constructor(e,r,i){super(e,e.provider);Z(this,"interface");Z(this,"fragment");Z(this,"args");const s=r.decodeEventLog(i,e.data,e.topics);$t(this,{args:s,fragment:i,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class qT extends wd{constructor(e,r){super(e,e.provider);Z(this,"error");$t(this,{error:r})}}var Ju;class hZ extends jT{constructor(e,r,i){super(i,r);J(this,Ju);F(this,Ju,e)}get logs(){return super.logs.map(e=>{const r=e.topics.length?S(this,Ju).getEvent(e.topics[0]):null;if(r)try{return new Ib(e,S(this,Ju),r)}catch(i){return new qT(e,i)}return e})}}Ju=new WeakMap;var jh;class Sb extends Mh{constructor(e,r,i){super(i,r);J(this,jh);F(this,jh,e)}async wait(e,r){const i=await super.wait(e,r);return i==null?null:new hZ(S(this,jh),this.provider,i)}}jh=new WeakMap;class QT extends vk{constructor(e,r,i,s){super(e,r,i);Z(this,"log");$t(this,{log:s})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class dZ extends QT{constructor(t,e,r,i,s){super(t,e,r,new Ib(s,t.interface,i));const o=t.interface.decodeEventLog(i,this.log.data,this.log.topics);$t(this,{args:o,fragment:i})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const rx=BigInt(0);function JT(n){return n&&typeof n.call=="function"}function YT(n){return n&&typeof n.estimateGas=="function"}function ug(n){return n&&typeof n.resolveName=="function"}function XT(n){return n&&typeof n.sendTransaction=="function"}function tO(n){if(n!=null){if(ug(n))return n;if(n.provider)return n.provider}}var Wh;class pZ{constructor(t,e,r){J(this,Wh);Z(this,"fragment");if($t(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const i=Ic(t.runner,"resolveName"),s=ug(i)?i:null;F(this,Wh,async function(){const o=await Promise.all(e.inputs.map((a,u)=>r[u]==null?null:a.walkAsync(r[u],(h,y)=>h==="address"?Array.isArray(y)?Promise.all(y.map(_=>wr(_,s))):wr(y,s):y)));return t.interface.encodeFilterTopics(e,o)}())}getTopicFilter(){return S(this,Wh)}}Wh=new WeakMap;function Ic(n,t){return n==null?null:typeof n[t]=="function"?n:n.provider&&typeof n.provider[t]=="function"?n.provider:null}function La(n){return n==null?null:n.provider||null}async function eO(n,t){const e=cr.dereference(n,"overrides");K(typeof e=="object","invalid overrides parameter","overrides",n);const r=rp(e);return K(r.to==null||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),K(r.data==null||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}async function gZ(n,t,e){const r=Ic(n,"resolveName"),i=ug(r)?r:null;return await Promise.all(t.map((s,o)=>s.walkAsync(e[o],(a,u)=>(u=cr.dereference(u,a),a==="address"?wr(u,i):u))))}function yZ(n){const t=async function(o){const a=await eO(o,["data"]);a.to=await n.getAddress(),a.from&&(a.from=await wr(a.from,tO(n.runner)));const u=n.interface,f=Nt(a.value||rx,"overrides.value")===rx,h=(a.data||"0x")==="0x";u.fallback&&!u.fallback.payable&&u.receive&&!h&&!f&&K(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),K(u.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data);const y=u.receive||u.fallback&&u.fallback.payable;return K(y||f,"cannot send value to non-payable fallback","overrides.value",a.value),K(u.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data),a},e=async function(o){const a=Ic(n.runner,"call");ht(JT(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await t(o);try{return await a.call(u)}catch(f){throw cb(f)&&f.data?n.interface.makeError(f.data,u):f}},r=async function(o){const a=n.runner;ht(XT(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await a.sendTransaction(await t(o)),f=La(n.runner);return new Sb(n.interface,f,u)},i=async function(o){const a=Ic(n.runner,"estimateGas");return ht(YT(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await t(o))},s=async o=>await r(o);return $t(s,{_contract:n,estimateGas:i,populateTransaction:t,send:r,staticCall:e}),s}function mZ(n,t){const e=function(...f){const h=n.interface.getFunction(t,f);return ht(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:f}}),h},r=async function(...f){const h=e(...f);let y={};if(h.inputs.length+1===f.length&&(y=await eO(f.pop()),y.from&&(y.from=await wr(y.from,tO(n.runner)))),h.inputs.length!==f.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const _=await gZ(n.runner,h.inputs,f);return Object.assign({},y,await hr({to:n.getAddress(),data:n.interface.encodeFunctionData(h,_)}))},i=async function(...f){const h=await a(...f);return h.length===1?h[0]:h},s=async function(...f){const h=n.runner;ht(XT(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const y=await h.sendTransaction(await r(...f)),_=La(n.runner);return new Sb(n.interface,_,y)},o=async function(...f){const h=Ic(n.runner,"estimateGas");return ht(YT(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await r(...f))},a=async function(...f){const h=Ic(n.runner,"call");ht(JT(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const y=await r(...f);let _="0x";try{_=await h.call(y)}catch(R){throw cb(R)&&R.data?n.interface.makeError(R.data,y):R}const w=e(...f);return n.interface.decodeFunctionResult(w,_)},u=async(...f)=>e(...f).constant?await i(...f):await s(...f);return $t(u,{name:n.interface.getFunctionName(t),_contract:n,_key:t,getFragment:e,estimateGas:o,populateTransaction:r,send:s,staticCall:i,staticCallResult:a}),Object.defineProperty(u,"fragment",{configurable:!1,enumerable:!0,get:()=>{const f=n.interface.getFunction(t);return ht(f,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),f}}),u}function wZ(n,t){const e=function(...i){const s=n.interface.getEvent(t,i);return ht(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:i}}),s},r=function(...i){return new pZ(n,e(...i),i)};return $t(r,{name:n.interface.getEventName(t),_contract:n,_key:t,getFragment:e}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const i=n.interface.getEvent(t);return ht(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),i}}),r}const ip=Symbol.for("_ethersInternal_contract"),nO=new WeakMap;function bZ(n,t){nO.set(n[ip],t)}function Dr(n){return nO.get(n[ip])}function _Z(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function kb(n,t){let e,r=null;if(Array.isArray(t)){const s=function(o){if(ze(o,32))return o;const a=n.interface.getEvent(o);return K(a,"unknown fragment","name",o),a.topicHash};e=t.map(o=>o==null?null:Array.isArray(o)?o.map(s):s(o))}else t==="*"?e=[null]:typeof t=="string"?ze(t,32)?e=[t]:(r=n.interface.getEvent(t),K(r,"unknown fragment","event",t),e=[r.topicHash]):_Z(t)?e=await t.getTopicFilter():"fragment"in t?(r=t.fragment,e=[r.topicHash]):K(!1,"unknown event name","event",t);e=e.map(s=>{if(s==null)return null;if(Array.isArray(s)){const o=Array.from(new Set(s.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return s.toLowerCase()});const i=e.map(s=>s==null?"null":Array.isArray(s)?s.join("|"):s).join("&");return{fragment:r,tag:i,topics:e}}async function $f(n,t){const{subs:e}=Dr(n);return e.get((await kb(n,t)).tag)||null}async function ix(n,t,e){const r=La(n.runner);ht(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:i,tag:s,topics:o}=await kb(n,e),{addr:a,subs:u}=Dr(n);let f=u.get(s);if(!f){const y={address:a||n,topics:o},_=I=>{let B=i;if(B==null)try{B=n.interface.getEvent(I.topics[0])}catch{}if(B){const H=B,U=i?n.interface.decodeEventLog(i,I.data,I.topics):[];Gw(n,e,U,G=>new dZ(n,G,e,H,I))}else Gw(n,e,[],H=>new QT(n,H,e,I))};let w=[];f={tag:s,listeners:[],start:()=>{w.length||w.push(r.on(y,_))},stop:async()=>{if(w.length==0)return;let I=w;w=[],await Promise.all(I),r.off(y,_)}},u.set(s,f)}return f}let zw=Promise.resolve();async function AZ(n,t,e,r){await zw;const i=await $f(n,t);if(!i)return!1;const s=i.listeners.length;return i.listeners=i.listeners.filter(({listener:o,once:a})=>{const u=Array.from(e);r&&u.push(r(a?null:o));try{o.call(n,...u)}catch{}return!a}),i.listeners.length===0&&(i.stop(),Dr(n).subs.delete(i.tag)),s>0}async function Gw(n,t,e,r){try{await zw}catch{}const i=AZ(n,t,e,r);return zw=i,await i}const r0=["then"];var wx;wx=ip;const Qf=class Qf{constructor(t,e,r,i){Z(this,"target");Z(this,"interface");Z(this,"runner");Z(this,"filters");Z(this,wx);Z(this,"fallback");K(typeof t=="string"||cT(t),"invalid value for Contract target","target",t),r==null&&(r=null);const s=Hw.from(e);$t(this,{target:t,runner:r,interface:s}),Object.defineProperty(this,ip,{value:{}});let o,a=null,u=null;if(i){const y=La(r);u=new Sb(this.interface,y,i)}let f=new Map;if(typeof t=="string")if(ze(t))a=t,o=Promise.resolve(t);else{const y=Ic(r,"resolveName");if(!ug(y))throw qe("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=y.resolveName(t).then(_=>{if(_==null)throw qe("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Dr(this).addr=_,_})}else o=t.getAddress().then(y=>{if(y==null)throw new Error("TODO");return Dr(this).addr=y,y});bZ(this,{addrPromise:o,addr:a,deployTx:u,subs:f});const h=new Proxy({},{get:(y,_,w)=>{if(typeof _=="symbol"||r0.indexOf(_)>=0)return Reflect.get(y,_,w);try{return this.getEvent(_)}catch(R){if(!Zn(R,"INVALID_ARGUMENT")||R.argument!=="key")throw R}},has:(y,_)=>r0.indexOf(_)>=0?Reflect.has(y,_):Reflect.has(y,_)||this.interface.hasEvent(String(_))});return $t(this,{filters:h}),$t(this,{fallback:s.receive||s.fallback?yZ(this):null}),new Proxy(this,{get:(y,_,w)=>{if(typeof _=="symbol"||_ in y||r0.indexOf(_)>=0)return Reflect.get(y,_,w);try{return y.getFunction(_)}catch(R){if(!Zn(R,"INVALID_ARGUMENT")||R.argument!=="key")throw R}},has:(y,_)=>typeof _=="symbol"||_ in y||r0.indexOf(_)>=0?Reflect.has(y,_):y.interface.hasFunction(_)})}connect(t){return new Qf(this.target,this.interface,t)}attach(t){return new Qf(t,this.interface,this.runner)}async getAddress(){return await Dr(this).addrPromise}async getDeployedCode(){const t=La(this.runner);ht(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return e==="0x"?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=La(this.runner);return ht(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((i,s)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return i(this);r.once("block",o)}catch(a){s(a)}};o()})}deploymentTransaction(){return Dr(this).deployTx}getFunction(t){return typeof t!="string"&&(t=t.format()),mZ(this,t)}getEvent(t){return typeof t!="string"&&(t=t.format()),wZ(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,r){e==null&&(e=0),r==null&&(r="latest");const{addr:i,addrPromise:s}=Dr(this),o=i||await s,{fragment:a,topics:u}=await kb(this,t),f={address:o,topics:u,fromBlock:e,toBlock:r},h=La(this.runner);return ht(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(f)).map(y=>{let _=a;if(_==null)try{_=this.interface.getEvent(y.topics[0])}catch{}if(_)try{return new Ib(y,this.interface,_)}catch(w){return new qT(y,w)}return new wd(y,h)})}async on(t,e){const r=await ix(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}async once(t,e){const r=await ix(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.start(),this}async emit(t,...e){return await Gw(this,t,e,null)}async listenerCount(t){if(t){const i=await $f(this,t);return i?i.listeners.length:0}const{subs:e}=Dr(this);let r=0;for(const{listeners:i}of e.values())r+=i.length;return r}async listeners(t){if(t){const i=await $f(this,t);return i?i.listeners.map(({listener:s})=>s):[]}const{subs:e}=Dr(this);let r=[];for(const{listeners:i}of e.values())r=r.concat(i.map(({listener:s})=>s));return r}async off(t,e){const r=await $f(this,t);if(!r)return this;if(e){const i=r.listeners.map(({listener:s})=>s).indexOf(e);i>=0&&r.listeners.splice(i,1)}return(e==null||r.listeners.length===0)&&(r.stop(),Dr(this).subs.delete(r.tag)),this}async removeAllListeners(t){if(t){const e=await $f(this,t);if(!e)return this;e.stop(),Dr(this).subs.delete(e.tag)}else{const{subs:e}=Dr(this);for(const{tag:r,stop:i}of e.values())i(),e.delete(r)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){class e extends Qf{constructor(i,s=null){super(i,t,s)}}return e}static from(t,e,r){return r==null&&(r=null),new this(t,e,r)}};let Vw=Qf;function EZ(){return Vw}class _u extends EZ(){}function Cm(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):K(!1,"unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}class vZ{constructor(t){Z(this,"name");$t(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}async encodeAddress(t,e){throw new Error("unsupported coin")}async decodeAddress(t,e){throw new Error("unsupported coin")}}const rO=new RegExp("^(ipfs)://(.*)$","i"),sx=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),rO,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];var Co,qa,Bo,eu,hp,iO;const lu=class lu{constructor(t,e,r){J(this,Bo);Z(this,"provider");Z(this,"address");Z(this,"name");J(this,Co);J(this,qa);$t(this,{provider:t,address:e,name:r}),F(this,Co,null),F(this,qa,new _u(e,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],t))}async supportsWildcard(){return S(this,Co)==null&&F(this,Co,(async()=>{try{return await S(this,qa).supportsInterface("0x9061b923")}catch(t){if(Zn(t,"CALL_EXCEPTION"))return!1;throw F(this,Co,null),t}})()),await S(this,Co)}async getAddress(t){if(t==null&&(t=60),t===60)try{const s=await yt(this,Bo,eu).call(this,"addr(bytes32)");return s==null||s===Sh?null:s}catch(s){if(Zn(s,"CALL_EXCEPTION"))return null;throw s}if(t>=0&&t<2147483648){let s=t+2147483648;const o=await yt(this,Bo,eu).call(this,"addr(bytes32,uint)",[s]);if(ze(o,20))return Me(o)}let e=null;for(const s of this.provider.plugins)if(s instanceof vZ&&s.supportsCoinType(t)){e=s;break}if(e==null)return null;const r=await yt(this,Bo,eu).call(this,"addr(bytes32,uint)",[t]);if(r==null||r==="0x")return null;const i=await e.decodeAddress(t,r);if(i!=null)return i;ht(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}async getText(t){const e=await yt(this,Bo,eu).call(this,"text(bytes32,string)",[t]);return e==null||e==="0x"?null:e}async getContentHash(){const t=await yt(this,Bo,eu).call(this,"contenthash(bytes32)");if(t==null||t==="0x")return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const i=e[1]==="e3010170"?"ipfs":"ipns",s=parseInt(e[4],16);if(e[5].length===s*2)return`${i}://${LV("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&r[1].length===64)return`bzz://${r[1]}`;ht(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const t=[{type:"name",value:this.name}];try{const e=await this.getText("avatar");if(e==null)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:e});for(let r=0;r<sx.length;r++){const i=e.match(sx[r]);if(i==null)continue;const s=i[1].toLowerCase();switch(s){case"https":case"data":return t.push({type:"url",value:e}),{linkage:t,url:e};case"ipfs":{const o=Cm(e);return t.push({type:"ipfs",value:e}),t.push({type:"url",value:o}),{linkage:t,url:o}}case"erc721":case"erc1155":{const o=s==="erc721"?"tokenURI(uint256)":"uri(uint256)";t.push({type:s,value:e});const a=await this.getAddress();if(a==null)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const u=(i[2]||"").split("/");if(u.length!==2)return t.push({type:`!${s}caip`,value:i[2]||""}),{url:null,linkage:t};const f=u[1],h=new _u(u[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(s==="erc721"){const T=await h.ownerOf(f);if(a!==T)return t.push({type:"!owner",value:T}),{url:null,linkage:t};t.push({type:"owner",value:T})}else if(s==="erc1155"){const T=await h.balanceOf(a,f);if(!T)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:T.toString()})}let y=await h[o](f);if(y==null||y==="0x")return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:y}),s==="erc1155"&&(y=y.replace("{id}",aa(f,32).substring(2)),t.push({type:"metadata-url-expanded",value:y})),y.match(/^ipfs:/i)&&(y=Cm(y)),t.push({type:"metadata-url",value:y});let _={};const w=await new eo(y).send();w.assertOk();try{_=w.bodyJson}catch{try{t.push({type:"!metadata",value:w.bodyText})}catch{const B=w.body;return B&&t.push({type:"!metadata",value:kt(B)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!_)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(_)});let R=_.image;if(typeof R!="string")return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(!R.match(/^(https:\/\/|data:)/i)){if(R.match(rO)==null)return t.push({type:"!imageUrl-ipfs",value:R}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:R}),R=Cm(R)}return t.push({type:"url",value:R}),{linkage:t,url:R}}}}}catch{}return{linkage:t,url:null}}static async getEnsAddress(t){const e=await t.getNetwork(),r=e.getPlugin("org.ethers.plugins.network.Ens");return ht(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}static async fromName(t,e){var i;let r=e;for(;;){if(r===""||r==="."||e!=="eth"&&r==="eth")return null;const s=await yt(i=lu,hp,iO).call(i,t,r);if(s!=null){const o=new lu(t,s,e);return r!==e&&!await o.supportsWildcard()?null:o}r=r.split(".").slice(1).join(".")}}};Co=new WeakMap,qa=new WeakMap,Bo=new WeakSet,eu=async function(t,e){e=(e||[]).slice();const r=S(this,qa).interface;e.unshift(Fw(this.name));let i=null;await this.supportsWildcard()&&(i=r.getFunction(t),ht(i,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[EW(this.name,255),r.encodeFunctionData(i,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const s=await S(this,qa)[t](...e);return i?r.decodeFunctionResult(i,s)[0]:s}catch(s){if(!Zn(s,"CALL_EXCEPTION"))throw s}return null},hp=new WeakSet,iO=async function(t,e){const r=await lu.getEnsAddress(t);try{const s=await new _u(r,["function resolver(bytes32) view returns (address)"],t).resolver(Fw(e),{enableCcipRead:!0});return s===Sh?null:s}catch(i){throw i}return null},J(lu,hp);let sp=lu;const ox=BigInt(0);function he(n,t){return function(e){return e==null?t:n(e)}}function lg(n,t){return e=>{if(t&&e==null)return null;if(!Array.isArray(e))throw new Error("not an array");return e.map(r=>n(r))}}function bd(n,t){return e=>{const r={};for(const i in n){let s=i;if(t&&i in t&&!(s in e)){for(const o of t[i])if(o in e){s=o;break}}try{const o=n[i](e[s]);o!==void 0&&(r[i]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";ht(!1,`invalid value for value.${i} (${a})`,"BAD_DATA",{value:e})}}return r}}function xZ(n){switch(n){case!0:case"true":return!0;case!1:case"false":return!1}K(!1,`invalid boolean; ${JSON.stringify(n)}`,"value",n)}function Bl(n){return K(ze(n,!0),"invalid data","value",n),n}function Wn(n){return K(ze(n,32),"invalid hash","value",n),n}const RZ=bd({address:Me,blockHash:Wn,blockNumber:oe,data:Bl,index:oe,removed:he(xZ,!1),topics:lg(Wn),transactionHash:Wn,transactionIndex:oe},{index:["logIndex"]});function IZ(n){return RZ(n)}const SZ=bd({hash:he(Wn),parentHash:Wn,parentBeaconBlockRoot:he(Wn,null),number:oe,timestamp:oe,nonce:he(Bl),difficulty:Nt,gasLimit:Nt,gasUsed:Nt,stateRoot:he(Wn,null),receiptsRoot:he(Wn,null),blobGasUsed:he(Nt,null),excessBlobGas:he(Nt,null),miner:he(Me),prevRandao:he(Wn,null),extraData:Bl,baseFeePerGas:he(Nt)},{prevRandao:["mixHash"]});function kZ(n){const t=SZ(n);return t.transactions=n.transactions.map(e=>typeof e=="string"?e:sO(e)),t}const TZ=bd({transactionIndex:oe,blockNumber:oe,transactionHash:Wn,address:Me,topics:lg(Wn),data:Bl,index:oe,blockHash:Wn},{index:["logIndex"]});function OZ(n){return TZ(n)}const NZ=bd({to:he(Me,null),from:he(Me,null),contractAddress:he(Me,null),index:oe,root:he(kt),gasUsed:Nt,blobGasUsed:he(Nt,null),logsBloom:he(Bl),blockHash:Wn,hash:Wn,logs:lg(OZ),blockNumber:oe,cumulativeGasUsed:Nt,effectiveGasPrice:he(Nt),blobGasPrice:he(Nt,null),status:he(oe),type:he(oe,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function CZ(n){return NZ(n)}function sO(n){n.to&&Nt(n.to)===ox&&(n.to="0x0000000000000000000000000000000000000000");const t=bd({hash:Wn,index:he(oe,void 0),type:e=>e==="0x"||e==null?0:oe(e),accessList:he(Pc,null),blobVersionedHashes:he(lg(Wn,!0),null),blockHash:he(Wn,null),blockNumber:he(oe,null),transactionIndex:he(oe,null),from:Me,gasPrice:he(Nt),maxPriorityFeePerGas:he(Nt),maxFeePerGas:he(Nt),maxFeePerBlobGas:he(Nt,null),gasLimit:Nt,to:he(Me,null),value:Nt,nonce:oe,data:Bl,creates:he(Me,null),chainId:he(Nt,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(n);if(t.to==null&&t.creates==null&&(t.creates=Rj(t)),(n.type===1||n.type===2)&&n.accessList==null&&(t.accessList=[]),n.signature?t.signature=Oi.from(n.signature):t.signature=Oi.from(n),t.chainId==null){const e=t.signature.legacyChainId;e!=null&&(t.chainId=e)}return t.blockHash&&Nt(t.blockHash)===ox&&(t.blockHash=null),t}const BZ="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class _d{constructor(t){Z(this,"name");$t(this,{name:t})}clone(){return new _d(this.name)}}class fg extends _d{constructor(e,r){e==null&&(e=0);super(`org.ethers.network.plugins.GasCost#${e||0}`);Z(this,"effectiveBlock");Z(this,"txBase");Z(this,"txCreate");Z(this,"txDataZero");Z(this,"txDataNonzero");Z(this,"txAccessListStorageKey");Z(this,"txAccessListAddress");const i={effectiveBlock:e};function s(o,a){let u=(r||{})[o];u==null&&(u=a),K(typeof u=="number",`invalud value for ${o}`,"costs",r),i[o]=u}s("txBase",21e3),s("txCreate",32e3),s("txDataZero",4),s("txDataNonzero",16),s("txAccessListStorageKey",1900),s("txAccessListAddress",2400),$t(this,i)}clone(){return new fg(this.effectiveBlock,this)}}class hg extends _d{constructor(e,r){super("org.ethers.plugins.network.Ens");Z(this,"address");Z(this,"targetNetwork");$t(this,{address:e||BZ,targetNetwork:r??1})}clone(){return new hg(this.address,this.targetNetwork)}}var Zh,qh;class PZ extends _d{constructor(e,r){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");J(this,Zh);J(this,qh);F(this,Zh,e),F(this,qh,r)}get url(){return S(this,Zh)}get processFunc(){return S(this,qh)}clone(){return this}}Zh=new WeakMap,qh=new WeakMap;const Bm=new Map;var Yu,Xu,Po;const fu=class fu{constructor(t,e){J(this,Yu);J(this,Xu);J(this,Po);F(this,Yu,t),F(this,Xu,Nt(e)),F(this,Po,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return S(this,Yu)}set name(t){F(this,Yu,t)}get chainId(){return S(this,Xu)}set chainId(t){F(this,Xu,Nt(t,"chainId"))}matches(t){if(t==null)return!1;if(typeof t=="string"){try{return this.chainId===Nt(t)}catch{}return this.name===t}if(typeof t=="number"||typeof t=="bigint"){try{return this.chainId===Nt(t)}catch{}return!1}if(typeof t=="object"){if(t.chainId!=null){try{return this.chainId===Nt(t.chainId)}catch{}return!1}return t.name!=null?this.name===t.name:!1}return!1}get plugins(){return Array.from(S(this,Po).values())}attachPlugin(t){if(S(this,Po).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return S(this,Po).set(t.name,t.clone()),this}getPlugin(t){return S(this,Po).get(t)||null}getPlugins(t){return this.plugins.filter(e=>e.name.split("#")[0]===t)}clone(){const t=new fu(this.name,this.chainId);return this.plugins.forEach(e=>{t.attachPlugin(e.clone())}),t}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new fg;let r=e.txBase;if(t.to==null&&(r+=e.txCreate),t.data)for(let i=2;i<t.data.length;i+=2)t.data.substring(i,i+2)==="00"?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const i=Pc(t.accessList);for(const s in i)r+=e.txAccessListAddress+e.txAccessListStorageKey*i[s].storageKeys.length}return r}static from(t){if(MZ(),t==null)return fu.from("mainnet");if(typeof t=="number"&&(t=BigInt(t)),typeof t=="string"||typeof t=="bigint"){const e=Bm.get(t);if(e)return e();if(typeof t=="bigint")return new fu("unknown",t);K(!1,"unknown network","network",t)}if(typeof t.clone=="function")return t.clone();if(typeof t=="object"){K(typeof t.name=="string"&&typeof t.chainId=="number","invalid network object name or chainId","network",t);const e=new fu(t.name,t.chainId);return(t.ensAddress||t.ensNetwork!=null)&&e.attachPlugin(new hg(t.ensAddress,t.ensNetwork)),e}K(!1,"invalid network","network",t)}static register(t,e){typeof t=="number"&&(t=BigInt(t));const r=Bm.get(t);r&&K(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),Bm.set(t,e)}};Yu=new WeakMap,Xu=new WeakMap,Po=new WeakMap;let ns=fu;function ax(n,t){const e=String(n);if(!e.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${n}`);const r=e.split(".");if(r.length===1&&r.push(""),r.length!==2)throw new Error(`invalid gwei value: ${n}`);for(;r[1].length<t;)r[1]+="0";if(r[1].length>9){let i=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||i++,r[1]=i.toString()}return BigInt(r[0]+r[1])}function cx(n){return new PZ(n,async(t,e,r)=>{r.setHeader("User-Agent","ethers");let i;try{const[s,o]=await Promise.all([r.send(),t()]);i=s;const a=i.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:ax(a.maxFee,9),maxPriorityFeePerGas:ax(a.maxPriorityFee,9)}}catch(s){ht(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:i,error:s})}})}let ux=!1;function MZ(){if(ux)return;ux=!0;function n(t,e,r){const i=function(){const s=new ns(t,e);return r.ensNetwork!=null&&s.attachPlugin(new hg(null,r.ensNetwork)),s.attachPlugin(new fg),(r.plugins||[]).forEach(o=>{s.attachPlugin(o)}),s};ns.register(t,i),ns.register(e,i),r.altNames&&r.altNames.forEach(s=>{ns.register(s,i)})}n("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),n("ropsten",3,{ensNetwork:3}),n("rinkeby",4,{ensNetwork:4}),n("goerli",5,{ensNetwork:5}),n("kovan",42,{ensNetwork:42}),n("sepolia",11155111,{ensNetwork:11155111}),n("holesky",17e3,{ensNetwork:17e3}),n("classic",61,{}),n("classicKotti",6,{}),n("arbitrum",42161,{ensNetwork:1}),n("arbitrum-goerli",421613,{}),n("arbitrum-sepolia",421614,{}),n("base",8453,{ensNetwork:1}),n("base-goerli",84531,{}),n("base-sepolia",84532,{}),n("bnb",56,{ensNetwork:1}),n("bnbt",97,{}),n("linea",59144,{ensNetwork:1}),n("linea-goerli",59140,{}),n("linea-sepolia",59141,{}),n("matic",137,{ensNetwork:1,plugins:[cx("https://gasstation.polygon.technology/v2")]}),n("matic-amoy",80002,{}),n("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[cx("https://gasstation-testnet.polygon.technology/v2")]}),n("optimism",10,{ensNetwork:1,plugins:[]}),n("optimism-goerli",420,{}),n("optimism-sepolia",11155420,{}),n("xdai",100,{ensNetwork:1})}function Kw(n){return JSON.parse(JSON.stringify(n))}var Ds,ni,Mo,Gi,tl,b0;class LZ{constructor(t){J(this,tl);J(this,Ds);J(this,ni);J(this,Mo);J(this,Gi);F(this,Ds,t),F(this,ni,null),F(this,Mo,4e3),F(this,Gi,-2)}get pollingInterval(){return S(this,Mo)}set pollingInterval(t){F(this,Mo,t)}start(){S(this,ni)||(F(this,ni,S(this,Ds)._setTimeout(yt(this,tl,b0).bind(this),S(this,Mo))),yt(this,tl,b0).call(this))}stop(){S(this,ni)&&(S(this,Ds)._clearTimeout(S(this,ni)),F(this,ni,null))}pause(t){this.stop(),t&&F(this,Gi,-2)}resume(){this.start()}}Ds=new WeakMap,ni=new WeakMap,Mo=new WeakMap,Gi=new WeakMap,tl=new WeakSet,b0=async function(){try{const t=await S(this,Ds).getBlockNumber();if(S(this,Gi)===-2){F(this,Gi,t);return}if(t!==S(this,Gi)){for(let e=S(this,Gi)+1;e<=t;e++){if(S(this,ni)==null)return;await S(this,Ds).emit("block",e)}F(this,Gi,t)}}catch{}S(this,ni)!=null&&F(this,ni,S(this,Ds)._setTimeout(yt(this,tl,b0).bind(this),S(this,Mo)))};var Qa,Ja,Lo;class Tb{constructor(t){J(this,Qa);J(this,Ja);J(this,Lo);F(this,Qa,t),F(this,Lo,!1),F(this,Ja,e=>{this._poll(e,S(this,Qa))})}async _poll(t,e){throw new Error("sub-classes must override this")}start(){S(this,Lo)||(F(this,Lo,!0),S(this,Ja).call(this,-2),S(this,Qa).on("block",S(this,Ja)))}stop(){S(this,Lo)&&(F(this,Lo,!1),S(this,Qa).off("block",S(this,Ja)))}pause(t){this.stop()}resume(){this.start()}}Qa=new WeakMap,Ja=new WeakMap,Lo=new WeakMap;var el,Fs;class UZ extends Tb{constructor(e,r){super(e);J(this,el);J(this,Fs);F(this,el,r),F(this,Fs,-2)}pause(e){e&&F(this,Fs,-2),super.pause(e)}async _poll(e,r){const i=await r.getBlock(S(this,el));i!=null&&(S(this,Fs)===-2?F(this,Fs,i.number):i.number>S(this,Fs)&&(r.emit(S(this,el),i.number),F(this,Fs,i.number)))}}el=new WeakMap,Fs=new WeakMap;var dp;class DZ extends Tb{constructor(e,r){super(e);J(this,dp);F(this,dp,Kw(r))}async _poll(e,r){throw new Error("@TODO")}}dp=new WeakMap;var nl;class FZ extends Tb{constructor(e,r){super(e);J(this,nl);F(this,nl,r)}async _poll(e,r){const i=await r.getTransactionReceipt(S(this,nl));i&&r.emit(S(this,nl),i)}}nl=new WeakMap;var $s,rl,il,Uo,ri,pp,oO;class Ob{constructor(t,e){J(this,pp);J(this,$s);J(this,rl);J(this,il);J(this,Uo);J(this,ri);F(this,$s,t),F(this,rl,Kw(e)),F(this,il,yt(this,pp,oO).bind(this)),F(this,Uo,!1),F(this,ri,-2)}start(){S(this,Uo)||(F(this,Uo,!0),S(this,ri)===-2&&S(this,$s).getBlockNumber().then(t=>{F(this,ri,t)}),S(this,$s).on("block",S(this,il)))}stop(){S(this,Uo)&&(F(this,Uo,!1),S(this,$s).off("block",S(this,il)))}pause(t){this.stop(),t&&F(this,ri,-2)}resume(){this.start()}}$s=new WeakMap,rl=new WeakMap,il=new WeakMap,Uo=new WeakMap,ri=new WeakMap,pp=new WeakSet,oO=async function(t){if(S(this,ri)===-2)return;const e=Kw(S(this,rl));e.fromBlock=S(this,ri)+1,e.toBlock=t;const r=await S(this,$s).getLogs(e);if(r.length===0){S(this,ri)<t-60&&F(this,ri,t-60);return}for(const i of r)S(this,$s).emit(S(this,rl),i),F(this,ri,i.blockNumber)};const $Z=BigInt(2),HZ=10;function i0(n){return n&&typeof n.then=="function"}function _0(n,t){return n+":"+JSON.stringify(t,(e,r)=>{if(r==null)return"null";if(typeof r=="bigint")return`bigint:${r.toString()}`;if(typeof r=="string")return r.toLowerCase();if(typeof r=="object"&&!Array.isArray(r)){const i=Object.keys(r);return i.sort(),i.reduce((s,o)=>(s[o]=r[o],s),{})}return r})}class op{constructor(t){Z(this,"name");$t(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function zZ(n){return JSON.parse(JSON.stringify(n))}function jw(n){return n=Array.from(new Set(n).values()),n.sort(),n}async function Pm(n,t){if(n==null)throw new Error("invalid event");if(Array.isArray(n)&&(n={topics:n}),typeof n=="string")switch(n){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:n,tag:n}}if(ze(n,32)){const e=n.toLowerCase();return{type:"transaction",tag:_0("tx",{hash:e}),hash:e}}if(n.orphan){const e=n;return{type:"orphan",tag:_0("orphan",e),filter:zZ(e)}}if(n.address||n.topics){const e=n,r={topics:(e.topics||[]).map(i=>i==null?null:Array.isArray(i)?jw(i.map(s=>s.toLowerCase())):i.toLowerCase())};if(e.address){const i=[],s=[],o=a=>{ze(a)?i.push(a):s.push((async()=>{i.push(await wr(a,t))})())};Array.isArray(e.address)?e.address.forEach(o):o(e.address),s.length&&await Promise.all(s),r.address=jw(i.map(a=>a.toLowerCase()))}return{filter:r,tag:_0("event",r),type:"event"}}K(!1,"unknown ProviderEvent","event",n)}function Mm(){return new Date().getTime()}const GZ={cacheTimeout:250,pollingInterval:4e3};var sr,Do,or,sl,zr,Ya,Fo,Hs,Qh,ii,ol,al,se,Pr,Ww,Zw,Hf,qw,zf,A0;class VZ{constructor(t,e){J(this,se);J(this,sr);J(this,Do);J(this,or);J(this,sl);J(this,zr);J(this,Ya);J(this,Fo);J(this,Hs);J(this,Qh);J(this,ii);J(this,ol);J(this,al);if(F(this,al,Object.assign({},GZ,e||{})),t==="any")F(this,Ya,!0),F(this,zr,null);else if(t){const r=ns.from(t);F(this,Ya,!1),F(this,zr,Promise.resolve(r)),setTimeout(()=>{this.emit("network",r,null)},0)}else F(this,Ya,!1),F(this,zr,null);F(this,Hs,-1),F(this,Fo,new Map),F(this,sr,new Map),F(this,Do,new Map),F(this,or,null),F(this,sl,!1),F(this,Qh,1),F(this,ii,new Map),F(this,ol,!1)}get pollingInterval(){return S(this,al).pollingInterval}get provider(){return this}get plugins(){return Array.from(S(this,Do).values())}attachPlugin(t){if(S(this,Do).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return S(this,Do).set(t.name,t.connect(this)),this}getPlugin(t){return S(this,Do).get(t)||null}get disableCcipRead(){return S(this,ol)}set disableCcipRead(t){F(this,ol,!!t)}async ccipReadFetch(t,e,r){if(this.disableCcipRead||r.length===0||t.to==null)return null;const i=t.to.toLowerCase(),s=e.toLowerCase(),o=[];for(let a=0;a<r.length;a++){const u=r[a],f=u.replace("{sender}",i).replace("{data}",s),h=new eo(f);u.indexOf("{data}")===-1&&(h.body={data:s,sender:i}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:a,urls:r});let y="unknown error",_;try{_=await h.send()}catch(w){o.push(w.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:{error:w}});continue}try{const w=_.bodyJson;if(w.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:w}),w.data;w.message&&(y=w.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:w})}catch{}ht(_.statusCode<400||_.statusCode>=500,`response not found during CCIP fetch: ${y}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:u,errorMessage:y}}),o.push(y)}ht(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,errorMessages:o}})}_wrapBlock(t,e){return new uZ(kZ(t),this)}_wrapLog(t,e){return new wd(IZ(t),this)}_wrapTransactionReceipt(t,e){return new jT(CZ(t),this)}_wrapTransactionResponse(t,e){return new Mh(sO(t),this)}_detectNetwork(){ht(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(t){ht(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}async getBlockNumber(){const t=oe(await yt(this,se,Pr).call(this,{method:"getBlockNumber"}),"%response");return S(this,Hs)>=0&&F(this,Hs,t),t}_getAddress(t){return wr(t,this)}_getBlockTag(t){if(t==null)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}if(ze(t))return ze(t,32)?t:cu(t);if(typeof t=="bigint"&&(t=oe(t,"blockTag")),typeof t=="number")return t>=0?cu(t):S(this,Hs)>=0?cu(S(this,Hs)+t):this.getBlockNumber().then(e=>cu(e+t));K(!1,"invalid blockTag","blockTag",t)}_getFilter(t){const e=(t.topics||[]).map(u=>u==null?null:Array.isArray(u)?jw(u.map(f=>f.toLowerCase())):u.toLowerCase()),r="blockHash"in t?t.blockHash:void 0,i=(u,f,h)=>{let y;switch(u.length){case 0:break;case 1:y=u[0];break;default:u.sort(),y=u}if(r&&(f!=null||h!=null))throw new Error("invalid filter");const _={};return y&&(_.address=y),e.length&&(_.topics=e),f&&(_.fromBlock=f),h&&(_.toBlock=h),r&&(_.blockHash=r),_};let s=[];if(t.address)if(Array.isArray(t.address))for(const u of t.address)s.push(this._getAddress(u));else s.push(this._getAddress(t.address));let o;"fromBlock"in t&&(o=this._getBlockTag(t.fromBlock));let a;return"toBlock"in t&&(a=this._getBlockTag(t.toBlock)),s.filter(u=>typeof u!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(s),o,a]).then(u=>i(u[0],u[1],u[2])):i(s,o,a)}_getTransactionRequest(t){const e=rp(t),r=[];if(["to","from"].forEach(i=>{if(e[i]==null)return;const s=wr(e[i],this);i0(s)?r.push(async function(){e[i]=await s}()):e[i]=s}),e.blockTag!=null){const i=this._getBlockTag(e.blockTag);i0(i)?r.push(async function(){e.blockTag=await i}()):e.blockTag=i}return r.length?async function(){return await Promise.all(r),e}():e}async getNetwork(){if(S(this,zr)==null){const i=(async()=>{try{const s=await this._detectNetwork();return this.emit("network",s,null),s}catch(s){throw S(this,zr)===i&&F(this,zr,null),s}})();return F(this,zr,i),(await i).clone()}const t=S(this,zr),[e,r]=await Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(S(this,Ya)?(this.emit("network",r,e),S(this,zr)===t&&F(this,zr,Promise.resolve(r))):ht(!1,`network changed: ${e.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}async getFeeData(){const t=await this.getNetwork(),e=async()=>{const{_block:i,gasPrice:s,priorityFee:o}=await hr({_block:yt(this,se,qw).call(this,"latest",!1),gasPrice:(async()=>{try{const h=await yt(this,se,Pr).call(this,{method:"getGasPrice"});return Nt(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await yt(this,se,Pr).call(this,{method:"getPriorityFee"});return Nt(h,"%response")}catch{}return null})()});let a=null,u=null;const f=this._wrapBlock(i,t);return f&&f.baseFeePerGas&&(u=o??BigInt("1000000000"),a=f.baseFeePerGas*$Z+u),new nx(s,a,u)},r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const i=new eo(r.url),s=await r.processFunc(e,this,i);return new nx(s.gasPrice,s.maxFeePerGas,s.maxPriorityFeePerGas)}return await e()}async estimateGas(t){let e=this._getTransactionRequest(t);return i0(e)&&(e=await e),Nt(await yt(this,se,Pr).call(this,{method:"estimateGas",transaction:e}),"%response")}async call(t){const{tx:e,blockTag:r}=await hr({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return await yt(this,se,Zw).call(this,yt(this,se,Ww).call(this,e,r,t.enableCcipRead?0:-1))}async getBalance(t,e){return Nt(await yt(this,se,Hf).call(this,{method:"getBalance"},t,e),"%response")}async getTransactionCount(t,e){return oe(await yt(this,se,Hf).call(this,{method:"getTransactionCount"},t,e),"%response")}async getCode(t,e){return kt(await yt(this,se,Hf).call(this,{method:"getCode"},t,e))}async getStorage(t,e,r){const i=Nt(e,"position");return kt(await yt(this,se,Hf).call(this,{method:"getStorage",position:i},t,r))}async broadcastTransaction(t){const{blockNumber:e,hash:r,network:i}=await hr({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),s=ep.from(t);if(s.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(s,i).replaceableTransaction(e)}async getBlock(t,e){const{network:r,params:i}=await hr({network:this.getNetwork(),params:yt(this,se,qw).call(this,t,!!e)});return i==null?null:this._wrapBlock(i,r)}async getTransaction(t){const{network:e,params:r}=await hr({network:this.getNetwork(),params:yt(this,se,Pr).call(this,{method:"getTransaction",hash:t})});return r==null?null:this._wrapTransactionResponse(r,e)}async getTransactionReceipt(t){const{network:e,params:r}=await hr({network:this.getNetwork(),params:yt(this,se,Pr).call(this,{method:"getTransactionReceipt",hash:t})});if(r==null)return null;if(r.gasPrice==null&&r.effectiveGasPrice==null){const i=await yt(this,se,Pr).call(this,{method:"getTransaction",hash:t});if(i==null)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=i.gasPrice}return this._wrapTransactionReceipt(r,e)}async getTransactionResult(t){const{result:e}=await hr({network:this.getNetwork(),result:yt(this,se,Pr).call(this,{method:"getTransactionResult",hash:t})});return e==null?null:kt(e)}async getLogs(t){let e=this._getFilter(t);i0(e)&&(e=await e);const{network:r,params:i}=await hr({network:this.getNetwork(),params:yt(this,se,Pr).call(this,{method:"getLogs",filter:e})});return i.map(s=>this._wrapLog(s,r))}_getProvider(t){ht(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(t){return await sp.fromName(this,t)}async getAvatar(t){const e=await this.getResolver(t);return e?await e.getAvatar():null}async resolveName(t){const e=await this.getResolver(t);return e?await e.getAddress():null}async lookupAddress(t){t=Me(t);const e=Fw(t.substring(2).toLowerCase()+".addr.reverse");try{const r=await sp.getEnsAddress(this),s=await new _u(r,["function resolver(bytes32) view returns (address)"],this).resolver(e);if(s==null||s===Sh)return null;const a=await new _u(s,["function name(bytes32) view returns (string)"],this).name(e);return await this.resolveName(a)!==t?null:a}catch(r){if(Zn(r,"BAD_DATA")&&r.value==="0x"||Zn(r,"CALL_EXCEPTION"))return null;throw r}return null}async waitForTransaction(t,e,r){const i=e??1;return i===0?this.getTransactionReceipt(t):new Promise(async(s,o)=>{let a=null;const u=async f=>{try{const h=await this.getTransactionReceipt(t);if(h!=null&&f-h.blockNumber+1>=i){s(h),a&&(clearTimeout(a),a=null);return}}catch(h){console.log("EEE",h)}this.once("block",u)};r!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",u),o(qe("timeout","TIMEOUT",{reason:"timeout"})))},r)),u(await this.getBlockNumber())})}async waitForBlock(t){ht(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(t){const e=S(this,ii).get(t);e&&(e.timer&&clearTimeout(e.timer),S(this,ii).delete(t))}_setTimeout(t,e){e==null&&(e=0);const r=ms(this,Qh)._++,i=()=>{S(this,ii).delete(r),t()};if(this.paused)S(this,ii).set(r,{timer:null,func:i,time:e});else{const s=setTimeout(i,e);S(this,ii).set(r,{timer:s,func:i,time:Mm()})}return r}_forEachSubscriber(t){for(const e of S(this,sr).values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new op(t.type);case"block":{const e=new LZ(this);return e.pollingInterval=this.pollingInterval,e}case"safe":case"finalized":return new UZ(this,t.type);case"event":return new Ob(this,t.filter);case"transaction":return new FZ(this,t.hash);case"orphan":return new DZ(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of S(this,sr).values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),S(this,or)!=null&&e.pause(S(this,or));break}}async on(t,e){const r=await yt(this,se,A0).call(this,t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,S(this,or)!=null&&r.subscriber.pause(S(this,or))),this}async once(t,e){const r=await yt(this,se,A0).call(this,t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,S(this,or)!=null&&r.subscriber.pause(S(this,or))),this}async emit(t,...e){const r=await yt(this,se,zf).call(this,t,e);if(!r||r.listeners.length===0)return!1;const i=r.listeners.length;return r.listeners=r.listeners.filter(({listener:s,once:o})=>{const a=new vk(this,o?null:s,t);try{s.call(this,...e,a)}catch{}return!o}),r.listeners.length===0&&(r.started&&r.subscriber.stop(),S(this,sr).delete(r.tag)),i>0}async listenerCount(t){if(t){const r=await yt(this,se,zf).call(this,t);return r?r.listeners.length:0}let e=0;for(const{listeners:r}of S(this,sr).values())e+=r.length;return e}async listeners(t){if(t){const r=await yt(this,se,zf).call(this,t);return r?r.listeners.map(({listener:i})=>i):[]}let e=[];for(const{listeners:r}of S(this,sr).values())e=e.concat(r.map(({listener:i})=>i));return e}async off(t,e){const r=await yt(this,se,zf).call(this,t);if(!r)return this;if(e){const i=r.listeners.map(({listener:s})=>s).indexOf(e);i>=0&&r.listeners.splice(i,1)}return(!e||r.listeners.length===0)&&(r.started&&r.subscriber.stop(),S(this,sr).delete(r.tag)),this}async removeAllListeners(t){if(t){const{tag:e,started:r,subscriber:i}=await yt(this,se,A0).call(this,t);r&&i.stop(),S(this,sr).delete(e)}else for(const[e,{started:r,subscriber:i}]of S(this,sr))r&&i.stop(),S(this,sr).delete(e);return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return this.off(t,e)}get destroyed(){return S(this,sl)}destroy(){this.removeAllListeners();for(const t of S(this,ii).keys())this._clearTimeout(t);F(this,sl,!0)}get paused(){return S(this,or)!=null}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(F(this,Hs,-1),S(this,or)!=null){if(S(this,or)==!!t)return;ht(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(e=>e.pause(t)),F(this,or,!!t);for(const e of S(this,ii).values())e.timer&&clearTimeout(e.timer),e.time=Mm()-e.time}resume(){if(S(this,or)!=null){this._forEachSubscriber(t=>t.resume()),F(this,or,null);for(const t of S(this,ii).values()){let e=t.time;e<0&&(e=0),t.time=Mm(),setTimeout(t.func,e)}}}}sr=new WeakMap,Do=new WeakMap,or=new WeakMap,sl=new WeakMap,zr=new WeakMap,Ya=new WeakMap,Fo=new WeakMap,Hs=new WeakMap,Qh=new WeakMap,ii=new WeakMap,ol=new WeakMap,al=new WeakMap,se=new WeakSet,Pr=async function(t){const e=S(this,al).cacheTimeout;if(e<0)return await this._perform(t);const r=_0(t.method,t);let i=S(this,Fo).get(r);return i||(i=this._perform(t),S(this,Fo).set(r,i),setTimeout(()=>{S(this,Fo).get(r)===i&&S(this,Fo).delete(r)},e)),await i},Ww=async function(t,e,r){ht(r<HZ,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const i=rp(t);try{return kt(await this._perform({method:"call",transaction:i,blockTag:e}))}catch(s){if(!this.disableCcipRead&&cb(s)&&s.data&&r>=0&&e==="latest"&&i.to!=null&&_n(s.data,0,4)==="0x556f1830"){const o=s.data,a=await wr(i.to,this);let u;try{u=qZ(_n(s.data,4))}catch(y){ht(!1,y.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:i,info:{data:o}})}ht(u.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:i,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:u.errorArgs}});const f=await this.ccipReadFetch(i,u.calldata,u.urls);ht(f!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:i,info:{data:s.data,errorArgs:u.errorArgs}});const h={to:a,data:In([u.selector,ZZ([f,u.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const y=await yt(this,se,Ww).call(this,h,e,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:y}),y}catch(y){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:y}),y}}throw s}},Zw=async function(t){const{value:e}=await hr({network:this.getNetwork(),value:t});return e},Hf=async function(t,e,r){let i=this._getAddress(e),s=this._getBlockTag(r);return(typeof i!="string"||typeof s!="string")&&([i,s]=await Promise.all([i,s])),await yt(this,se,Zw).call(this,yt(this,se,Pr).call(this,Object.assign(t,{address:i,blockTag:s})))},qw=async function(t,e){if(ze(t,32))return await yt(this,se,Pr).call(this,{method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return typeof r!="string"&&(r=await r),await yt(this,se,Pr).call(this,{method:"getBlock",blockTag:r,includeTransactions:e})},zf=async function(t,e){let r=await Pm(t,this);return r.type==="event"&&e&&e.length>0&&e[0].removed===!0&&(r=await Pm({orphan:"drop-log",log:e[0]},this)),S(this,sr).get(r.tag)||null},A0=async function(t){const e=await Pm(t,this),r=e.tag;let i=S(this,sr).get(r);return i||(i={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},S(this,sr).set(r,i)),i};function KZ(n,t){try{const e=Qw(n,t);if(e)return Z0(e)}catch{}return null}function Qw(n,t){if(n==="0x")return null;try{const e=oe(_n(n,t,t+32)),r=oe(_n(n,e,e+32));return _n(n,e+32,e+32+r)}catch{}return null}function lx(n){const t=yr(n);if(t.length>32)throw new Error("internal; should not happen");const e=new Uint8Array(32);return e.set(t,32-t.length),e}function jZ(n){if(n.length%32===0)return n;const t=new Uint8Array(Math.ceil(n.length/32)*32);return t.set(n),t}const WZ=new Uint8Array([]);function ZZ(n){const t=[];let e=0;for(let r=0;r<n.length;r++)t.push(WZ),e+=32;for(let r=0;r<n.length;r++){const i=ye(n[r]);t[r]=lx(e),t.push(lx(i.length)),t.push(jZ(i)),e+=32+Math.ceil(i.length/32)*32}return In(t)}const fx="0x0000000000000000000000000000000000000000000000000000000000000000";function qZ(n){const t={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ht(mu(n)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const e=_n(n,0,32);ht(_n(e,0,12)===_n(fx,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),t.sender=_n(e,12);try{const r=[],i=oe(_n(n,32,64)),s=oe(_n(n,i,i+32)),o=_n(n,i+32);for(let a=0;a<s;a++){const u=KZ(o,a*32);if(u==null)throw new Error("abort");r.push(u)}t.urls=r}catch{ht(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=Qw(n,64);if(r==null)throw new Error("abort");t.calldata=r}catch{ht(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}ht(_n(n,100,128)===_n(fx,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),t.selector=_n(n,96,100);try{const r=Qw(n,128);if(r==null)throw new Error("abort");t.extraData=r}catch{ht(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return t.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(r=>t[r]),t}function Zc(n,t){if(n.provider)return n.provider;ht(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:t})}async function hx(n,t){let e=rp(t);if(e.to!=null&&(e.to=wr(e.to,n)),e.from!=null){const r=e.from;e.from=Promise.all([n.getAddress(),wr(r,n)]).then(([i,s])=>(K(i.toLowerCase()===s.toLowerCase(),"transaction from mismatch","tx.from",s),i))}else e.from=n.getAddress();return await hr(e)}class QZ{constructor(t){Z(this,"provider");$t(this,{provider:t||null})}async getNonce(t){return Zc(this,"getTransactionCount").getTransactionCount(await this.getAddress(),t)}async populateCall(t){return await hx(this,t)}async populateTransaction(t){const e=Zc(this,"populateTransaction"),r=await hx(this,t);r.nonce==null&&(r.nonce=await this.getNonce("pending")),r.gasLimit==null&&(r.gasLimit=await this.estimateGas(r));const i=await this.provider.getNetwork();if(r.chainId!=null){const o=Nt(r.chainId);K(o===i.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else r.chainId=i.chainId;const s=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||s)?K(!1,"eip-1559 transaction do not support gasPrice","tx",t):(r.type===0||r.type===1)&&s&&K(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1){const o=await e.getFeeData();ht(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice)}else{const o=await e.getFeeData();if(r.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const a=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=a,r.maxPriorityFeePerGas=a}else r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(ht(!s,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice),r.type=0):ht(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(r.type===2||r.type===3)&&(r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await hr(r)}async estimateGas(t){return Zc(this,"estimateGas").estimateGas(await this.populateCall(t))}async call(t){return Zc(this,"call").call(await this.populateCall(t))}async resolveName(t){return await Zc(this,"resolveName").resolveName(t)}async sendTransaction(t){const e=Zc(this,"sendTransaction"),r=await this.populateTransaction(t);delete r.from;const i=ep.from(r);return await e.broadcastTransaction(await this.signTransaction(i))}}function JZ(n){return JSON.parse(JSON.stringify(n))}var fr,Vi,Xa,$o,tc,cl,ca,Jw,Yw;class aO{constructor(t){J(this,ca);J(this,fr);J(this,Vi);J(this,Xa);J(this,$o);J(this,tc);J(this,cl);F(this,fr,t),F(this,Vi,null),F(this,Xa,yt(this,ca,Jw).bind(this)),F(this,$o,!1),F(this,tc,null),F(this,cl,!1)}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}start(){S(this,$o)||(F(this,$o,!0),yt(this,ca,Jw).call(this,-2))}stop(){S(this,$o)&&(F(this,$o,!1),F(this,cl,!0),yt(this,ca,Yw).call(this),S(this,fr).off("block",S(this,Xa)))}pause(t){t&&yt(this,ca,Yw).call(this),S(this,fr).off("block",S(this,Xa))}resume(){this.start()}}fr=new WeakMap,Vi=new WeakMap,Xa=new WeakMap,$o=new WeakMap,tc=new WeakMap,cl=new WeakMap,ca=new WeakSet,Jw=async function(t){try{S(this,Vi)==null&&F(this,Vi,this._subscribe(S(this,fr)));let e=null;try{e=await S(this,Vi)}catch(s){if(!Zn(s,"UNSUPPORTED_OPERATION")||s.operation!=="eth_newFilter")throw s}if(e==null){F(this,Vi,null),S(this,fr)._recoverSubscriber(this,this._recover(S(this,fr)));return}const r=await S(this,fr).getNetwork();if(S(this,tc)||F(this,tc,r),S(this,tc).chainId!==r.chainId)throw new Error("chaid changed");if(S(this,cl))return;const i=await S(this,fr).send("eth_getFilterChanges",[e]);await this._emitResults(S(this,fr),i)}catch(e){console.log("@TODO",e)}S(this,fr).once("block",S(this,Xa))},Yw=function(){const t=S(this,Vi);t&&(F(this,Vi,null),t.then(e=>{S(this,fr).destroyed||S(this,fr).send("eth_uninstallFilter",[e])}))};var ec;class YZ extends aO{constructor(e,r){super(e);J(this,ec);F(this,ec,JZ(r))}_recover(e){return new Ob(e,S(this,ec))}async _subscribe(e){return await e.send("eth_newFilter",[S(this,ec)])}async _emitResults(e,r){for(const i of r)e.emit(S(this,ec),e._wrapLog(i,e._network))}}ec=new WeakMap;class XZ extends aO{async _subscribe(t){return await t.send("eth_newPendingTransactionFilter",[])}async _emitResults(t,e){for(const r of e)t.emit("pending",r)}}const tq="bigint,boolean,function,number,string,symbol".split(/,/g);function E0(n){if(n==null||tq.indexOf(typeof n)>=0||typeof n.getAddress=="function")return n;if(Array.isArray(n))return n.map(E0);if(typeof n=="object")return Object.keys(n).reduce((t,e)=>(t[e]=n[e],t),{});throw new Error(`should not happen: ${n} (${typeof n})`)}function eq(n){return new Promise(t=>{setTimeout(t,n)})}function qc(n){return n&&n.toLowerCase()}function dx(n){return n&&typeof n.pollingInterval=="number"}const cO={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Lm extends QZ{constructor(e,r){super(e);Z(this,"address");r=Me(r),$t(this,{address:r})}connect(e){ht(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(e){return await this.populateCall(e)}async sendUncheckedTransaction(e){const r=E0(e),i=[];if(r.from){const o=r.from;i.push((async()=>{const a=await wr(o,this.provider);K(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),r.from=a})())}else r.from=this.address;if(r.gasLimit==null&&i.push((async()=>{r.gasLimit=await this.provider.estimateGas({...r,from:this.address})})()),r.to!=null){const o=r.to;i.push((async()=>{r.to=await wr(o,this.provider)})())}i.length&&await Promise.all(i);const s=this.provider.getRpcTransaction(r);return this.provider.send("eth_sendTransaction",[s])}async sendTransaction(e){const r=await this.provider.getBlockNumber(),i=await this.sendUncheckedTransaction(e);return await new Promise((s,o)=>{const a=[1e3,100];let u=0;const f=async()=>{try{const h=await this.provider.getTransaction(i);if(h!=null){s(h.replaceableTransaction(r));return}}catch(h){if(Zn(h,"CANCELLED")||Zn(h,"BAD_DATA")||Zn(h,"NETWORK_ERROR")||Zn(h,"UNSUPPORTED_OPERATION")){h.info==null&&(h.info={}),h.info.sendTransactionHash=i,o(h);return}if(Zn(h,"INVALID_ARGUMENT")&&(u++,h.info==null&&(h.info={}),h.info.sendTransactionHash=i,u>10)){o(h);return}this.provider.emit("error",qe("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:h}))}this.provider._setTimeout(()=>{f()},a.pop()||4e3)};f()})}async signTransaction(e){const r=E0(e);if(r.from){const s=await wr(r.from,this.provider);K(s!=null&&s.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),r.from=s}else r.from=this.address;const i=this.provider.getRpcTransaction(r);return await this.provider.send("eth_signTransaction",[i])}async signMessage(e){const r=typeof e=="string"?Js(e):e;return await this.provider.send("personal_sign",[kt(r),this.address.toLowerCase()])}async signTypedData(e,r,i){const s=E0(i),o=await np.resolveNames(e,r,s,async a=>{const u=await wr(a);return K(u!=null,"TypedData does not support null address","value",a),u});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(np.getPayload(o.domain,r,o.value))])}async unlock(e){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),e,null])}async _legacySignMessage(e){const r=typeof e=="string"?Js(e):e;return await this.provider.send("eth_sign",[this.address.toLowerCase(),kt(r)])}}var nc,ul,zs,Ki,_i,si,xr,Jh,Xw;class uO extends VZ{constructor(e,r){super(e,r);J(this,Jh);J(this,nc);J(this,ul);J(this,zs);J(this,Ki);J(this,_i);J(this,si);J(this,xr);F(this,ul,1),F(this,nc,Object.assign({},cO,r||{})),F(this,zs,[]),F(this,Ki,null),F(this,si,null),F(this,xr,null);{let s=null;const o=new Promise(a=>{s=a});F(this,_i,{promise:o,resolve:s})}const i=this._getOption("staticNetwork");typeof i=="boolean"?(K(!i||e!=="any","staticNetwork cannot be used on special network 'any'","options",r),i&&e!=null&&F(this,si,ns.from(e))):i&&(K(e==null||i.matches(e),"staticNetwork MUST match network object","options",r),F(this,si,i))}_getOption(e){return S(this,nc)[e]}get _network(){return ht(S(this,si),"network is not available yet","NETWORK_ERROR"),S(this,si)}async _perform(e){if(e.method==="call"||e.method==="estimateGas"){let i=e.transaction;if(i&&i.type!=null&&Nt(i.type)&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=await this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(e=Object.assign({},e,{transaction:Object.assign({},i,{type:void 0})}))}}const r=this.getRpcRequest(e);return r!=null?await this.send(r.method,r.args):super._perform(e)}async _detectNetwork(){const e=this._getOption("staticNetwork");if(e)if(e===!0){if(S(this,si))return S(this,si)}else return e;return S(this,xr)?await S(this,xr):this.ready?(F(this,xr,(async()=>{try{const r=ns.from(Nt(await this.send("eth_chainId",[])));return F(this,xr,null),r}catch(r){throw F(this,xr,null),r}})()),await S(this,xr)):(F(this,xr,(async()=>{const r={id:ms(this,ul)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:r});let i;try{i=(await this._send(r))[0],F(this,xr,null)}catch(s){throw F(this,xr,null),this.emit("debug",{action:"receiveRpcError",error:s}),s}if(this.emit("debug",{action:"receiveRpcResult",result:i}),"result"in i)return ns.from(Nt(i.result));throw this.getRpcError(r,i)})()),await S(this,xr))}_start(){S(this,_i)==null||S(this,_i).resolve==null||(S(this,_i).resolve(),F(this,_i,null),(async()=>{for(;S(this,si)==null&&!this.destroyed;)try{F(this,si,await this._detectNetwork())}catch(e){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",qe("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:e}})),await eq(1e3)}yt(this,Jh,Xw).call(this)})())}async _waitUntilReady(){if(S(this,_i)!=null)return await S(this,_i).promise}_getSubscriber(e){return e.type==="pending"?new XZ(this):e.type==="event"?this._getOption("polling")?new Ob(this,e.filter):new YZ(this,e.filter):e.type==="orphan"&&e.filter.orphan==="drop-log"?new op("orphan"):super._getSubscriber(e)}get ready(){return S(this,_i)==null}getRpcTransaction(e){const r={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(i=>{if(e[i]==null)return;let s=i;i==="gasLimit"&&(s="gas"),r[s]=cu(Nt(e[i],`tx.${i}`))}),["from","to","data"].forEach(i=>{e[i]!=null&&(r[i]=kt(e[i]))}),e.accessList&&(r.accessList=Pc(e.accessList)),e.blobVersionedHashes&&(r.blobVersionedHashes=e.blobVersionedHashes.map(i=>i.toLowerCase())),r}getRpcRequest(e){switch(e.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[qc(e.address),e.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[qc(e.address),e.blockTag]};case"getCode":return{method:"eth_getCode",args:[qc(e.address),e.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[qc(e.address),"0x"+e.position.toString(16),e.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[e.signedTransaction]};case"getBlock":if("blockTag"in e)return{method:"eth_getBlockByNumber",args:[e.blockTag,!!e.includeTransactions]};if("blockHash"in e)return{method:"eth_getBlockByHash",args:[e.blockHash,!!e.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[e.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[e.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(e.transaction),e.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(e.transaction)]};case"getLogs":return e.filter&&e.filter.address!=null&&(Array.isArray(e.filter.address)?e.filter.address=e.filter.address.map(qc):e.filter.address=qc(e.filter.address)),{method:"eth_getLogs",args:[e.filter]}}return null}getRpcError(e,r){const{method:i}=e,{error:s}=r;if(i==="eth_estimateGas"&&s.message){const u=s.message;if(!u.match(/revert/i)&&u.match(/insufficient funds/i))return qe("insufficient funds","INSUFFICIENT_FUNDS",{transaction:e.params[0],info:{payload:e,error:s}})}if(i==="eth_call"||i==="eth_estimateGas"){const u=t1(s),f=Ph.getBuiltinCallException(i==="eth_call"?"call":"estimateGas",e.params[0],u?u.data:null);return f.info={error:s,payload:e},f}const o=JSON.stringify(iq(s));if(typeof s.message=="string"&&s.message.match(/user denied|ethers-user-denied/i))return qe("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[i]||"unknown",reason:"rejected",info:{payload:e,error:s}});if(i==="eth_sendRawTransaction"||i==="eth_sendTransaction"){const u=e.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return qe("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:u,info:{error:s}});if(o.match(/nonce/i)&&o.match(/too low/i))return qe("nonce has already been used","NONCE_EXPIRED",{transaction:u,info:{error:s}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return qe("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:u,info:{error:s}});if(o.match(/only replay-protected/i))return qe("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:i,info:{transaction:u,info:{error:s}}})}let a=!!o.match(/the method .* does not exist/i);return a||s&&s.details&&s.details.startsWith("Unauthorized method:")&&(a=!0),a?qe("unsupported operation","UNSUPPORTED_OPERATION",{operation:e.method,info:{error:s,payload:e}}):qe("could not coalesce error","UNKNOWN_ERROR",{error:s,payload:e})}send(e,r){if(this.destroyed)return Promise.reject(qe("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e}));const i=ms(this,ul)._++,s=new Promise((o,a)=>{S(this,zs).push({resolve:o,reject:a,payload:{method:e,params:r,id:i,jsonrpc:"2.0"}})});return yt(this,Jh,Xw).call(this),s}async getSigner(e){e==null&&(e=0);const r=this.send("eth_accounts",[]);if(typeof e=="number"){const s=await r;if(e>=s.length)throw new Error("no such account");return new Lm(this,s[e])}const{accounts:i}=await hr({network:this.getNetwork(),accounts:r});e=Me(e);for(const s of i)if(Me(s)===e)return new Lm(this,e);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(r=>new Lm(this,r))}destroy(){S(this,Ki)&&(clearTimeout(S(this,Ki)),F(this,Ki,null));for(const{payload:e,reject:r}of S(this,zs))r(qe("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e.method}));F(this,zs,[]),super.destroy()}}nc=new WeakMap,ul=new WeakMap,zs=new WeakMap,Ki=new WeakMap,_i=new WeakMap,si=new WeakMap,xr=new WeakMap,Jh=new WeakSet,Xw=function(){if(S(this,Ki))return;const e=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");F(this,Ki,setTimeout(()=>{F(this,Ki,null);const r=S(this,zs);for(F(this,zs,[]);r.length;){const i=[r.shift()];for(;r.length&&i.length!==S(this,nc).batchMaxCount;)if(i.push(r.shift()),JSON.stringify(i.map(o=>o.payload)).length>S(this,nc).batchMaxSize){r.unshift(i.pop());break}(async()=>{const s=i.length===1?i[0].payload:i.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:s});try{const o=await this._send(s);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:u,payload:f}of i){if(this.destroyed){u(qe("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:f.method}));continue}const h=o.filter(y=>y.id===f.id)[0];if(h==null){const y=qe("missing response for request","BAD_DATA",{value:o,info:{payload:f}});this.emit("error",y),u(y);continue}if("error"in h){u(this.getRpcError(f,h));continue}a(h.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of i)a(o)}})()}},e))};var Ho;class nq extends uO{constructor(e,r){super(e,r);J(this,Ho);let i=this._getOption("pollingInterval");i==null&&(i=cO.pollingInterval),F(this,Ho,i)}_getSubscriber(e){const r=super._getSubscriber(e);return dx(r)&&(r.pollingInterval=S(this,Ho)),r}get pollingInterval(){return S(this,Ho)}set pollingInterval(e){if(!Number.isInteger(e)||e<0)throw new Error("invalid interval");F(this,Ho,e),this._forEachSubscriber(r=>{dx(r)&&(r.pollingInterval=S(this,Ho))})}}Ho=new WeakMap;var ll;class rq extends nq{constructor(e,r,i){e==null&&(e="http://localhost:8545");super(r,i);J(this,ll);typeof e=="string"?F(this,ll,new eo(e)):F(this,ll,e.clone())}_getConnection(){return S(this,ll).clone()}async send(e,r){return await this._start(),await super.send(e,r)}async _send(e){const r=this._getConnection();r.body=JSON.stringify(e),r.setHeader("content-type","application/json");const i=await r.send();i.assertOk();let s=i.bodyJson;return Array.isArray(s)||(s=[s]),s}}ll=new WeakMap;function t1(n){if(n==null)return null;if(typeof n.message=="string"&&n.message.match(/revert/i)&&ze(n.data))return{message:n.message,data:n.data};if(typeof n=="object"){for(const t in n){const e=t1(n[t]);if(e)return e}return null}if(typeof n=="string")try{return t1(JSON.parse(n))}catch{}return null}function e1(n,t){if(n!=null){if(typeof n.message=="string"&&t.push(n.message),typeof n=="object")for(const e in n)e1(n[e],t);if(typeof n=="string")try{return e1(JSON.parse(n),t)}catch{}}}function iq(n){const t=[];return e1(n,t),t}function sq(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof gl<"u")return gl;throw new Error("unable to locate global object")}const oq=sq().WebSocket;var ji,Yh,zo,rc,Go;class Nb{constructor(t,e){J(this,ji);J(this,Yh);J(this,zo);J(this,rc);J(this,Go);F(this,ji,t),F(this,Yh,JSON.stringify(e)),F(this,zo,null),F(this,rc,null),F(this,Go,null)}get filter(){return JSON.parse(S(this,Yh))}start(){F(this,zo,S(this,ji).send("eth_subscribe",this.filter).then(t=>(S(this,ji)._register(t,this),t)))}stop(){S(this,zo).then(t=>{S(this,ji).destroyed||S(this,ji).send("eth_unsubscribe",[t])}),F(this,zo,null)}pause(t){ht(t,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),F(this,rc,!!t)}resume(){F(this,rc,null)}_handleMessage(t){if(S(this,zo)!=null&&S(this,rc)===null){let e=S(this,Go);e==null?e=this._emit(S(this,ji),t):e=e.then(async()=>{await this._emit(S(this,ji),t)}),F(this,Go,e.then(()=>{S(this,Go)===e&&F(this,Go,null)}))}}async _emit(t,e){throw new Error("sub-classes must implemente this; _emit")}}ji=new WeakMap,Yh=new WeakMap,zo=new WeakMap,rc=new WeakMap,Go=new WeakMap;class aq extends Nb{constructor(t){super(t,["newHeads"])}async _emit(t,e){t.emit("block",parseInt(e.number))}}class cq extends Nb{constructor(t){super(t,["newPendingTransactions"])}async _emit(t,e){t.emit("pending",e)}}var Xh;class uq extends Nb{constructor(e,r){super(e,["logs",r]);J(this,Xh);F(this,Xh,JSON.stringify(r))}get logFilter(){return JSON.parse(S(this,Xh))}async _emit(e,r){e.emit(this.logFilter,e._wrapLog(r,e._network))}}Xh=new WeakMap;var ic,fl,Vo;class lq extends uO{constructor(e,r){const i=Object.assign({},r??{});K(i.batchMaxCount==null||i.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",r),i.batchMaxCount=1,i.staticNetwork==null&&(i.staticNetwork=!0);super(e,i);J(this,ic);J(this,fl);J(this,Vo);F(this,ic,new Map),F(this,fl,new Map),F(this,Vo,new Map)}_getSubscriber(e){switch(e.type){case"close":return new op("close");case"block":return new aq(this);case"pending":return new cq(this);case"event":return new uq(this,e.filter);case"orphan":if(e.filter.orphan==="drop-log")return new op("drop-log")}return super._getSubscriber(e)}_register(e,r){S(this,fl).set(e,r);const i=S(this,Vo).get(e);if(i){for(const s of i)r._handleMessage(s);S(this,Vo).delete(e)}}async _send(e){K(!Array.isArray(e),"WebSocket does not support batch send","payload",e);const r=new Promise((i,s)=>{S(this,ic).set(e.id,{payload:e,resolve:i,reject:s})});return await this._waitUntilReady(),await this._write(JSON.stringify(e)),[await r]}async _processMessage(e){const r=JSON.parse(e);if(r&&typeof r=="object"&&"id"in r){const i=S(this,ic).get(r.id);if(i==null){this.emit("error",qe("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:r}));return}S(this,ic).delete(r.id),i.resolve(r)}else if(r&&r.method==="eth_subscription"){const i=r.params.subscription,s=S(this,fl).get(i);if(s)s._handleMessage(r.params.result);else{let o=S(this,Vo).get(i);o==null&&(o=[],S(this,Vo).set(i,o)),o.push(r.params.result)}}else{this.emit("error",qe("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:r}));return}}async _write(e){throw new Error("sub-classes must override this")}}ic=new WeakMap,fl=new WeakMap,Vo=new WeakMap;var sc,Ai;class fq extends lq{constructor(e,r,i){super(r,i);J(this,sc);J(this,Ai);typeof e=="string"?(F(this,sc,()=>new oq(e)),F(this,Ai,S(this,sc).call(this))):typeof e=="function"?(F(this,sc,e),F(this,Ai,e())):(F(this,sc,null),F(this,Ai,e)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(s){console.log("failed to start WebsocketProvider",s)}},this.websocket.onmessage=s=>{this._processMessage(s.data)}}get websocket(){if(S(this,Ai)==null)throw new Error("websocket closed");return S(this,Ai)}async _write(e){this.websocket.send(e)}async destroy(){S(this,Ai)!=null&&(S(this,Ai).close(),F(this,Ai,null)),super.destroy()}}sc=new WeakMap,Ai=new WeakMap;const hq="hh-sol-artifact-1",dq="SwarmEventEmitter",pq="contracts/SwarmEventEmitter.sol",gq=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"sender",type:"address"},{indexed:!1,internalType:"string",name:"message",type:"string"}],name:"MessageLogged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"}],name:"RemovedFromWhitelist",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"account",type:"address"}],name:"Whitelisted",type:"event"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"addToWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"admin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"string",name:"message",type:"string"}],name:"emitMessage",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"removeFromWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"whitelisted",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}],yq="0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a26107b08061013b6000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632ac0df261461005c5780638ab1d68114610078578063d936547e14610094578063e43252d7146100c4578063f851a440146100e0575b600080fd5b610076600480360381019061007191906104e8565b6100fe565b005b610092600480360381019061008d9190610593565b6101de565b005b6100ae60048036038101906100a99190610593565b61030a565b6040516100bb91906105db565b60405180910390f35b6100de60048036038101906100d99190610593565b61032a565b005b6100e8610455565b6040516100f59190610605565b60405180910390f35b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101819061067d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fda502b164eb5cfccfa9f947e0fdc1a0bd060adfef2947810b256321c1a74ca4183836040516101d29291906106ea565b60405180910390a25050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102639061075a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a250565b60016020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061075a565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a250565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126104a8576104a7610483565b5b8235905067ffffffffffffffff8111156104c5576104c4610488565b5b6020830191508360018202830111156104e1576104e061048d565b5b9250929050565b600080602083850312156104ff576104fe610479565b5b600083013567ffffffffffffffff81111561051d5761051c61047e565b5b61052985828601610492565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b61057081610555565b811461057b57600080fd5b50565b60008135905061058d81610567565b92915050565b6000602082840312156105a9576105a8610479565b5b60006105b78482850161057e565b91505092915050565b60008115159050919050565b6105d5816105c0565b82525050565b60006020820190506105f060008301846105cc565b92915050565b6105ff81610555565b82525050565b600060208201905061061a60008301846105f6565b92915050565b600082825260208201905092915050565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b6000610667600f83610620565b915061067282610631565b602082019050919050565b600060208201905081810360008301526106968161065a565b9050919050565b82818337600083830152505050565b6000601f19601f8301169050919050565b60006106c98385610620565b93506106d683858461069d565b6106df836106ac565b840190509392505050565b600060208201905081810360008301526107058184866106bd565b90509392505050565b7f4e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b6000610744600983610620565b915061074f8261070e565b602082019050919050565b6000602082019050818103600083015261077381610737565b905091905056fea26469706673582212202ad433ea9240cc561f6b9168c7880800e372f26e322166cedd6ce135222e699764736f6c634300081c0033",mq="0x608060405234801561001057600080fd5b50600436106100575760003560e01c80632ac0df261461005c5780638ab1d68114610078578063d936547e14610094578063e43252d7146100c4578063f851a440146100e0575b600080fd5b610076600480360381019061007191906104e8565b6100fe565b005b610092600480360381019061008d9190610593565b6101de565b005b6100ae60048036038101906100a99190610593565b61030a565b6040516100bb91906105db565b60405180910390f35b6100de60048036038101906100d99190610593565b61032a565b005b6100e8610455565b6040516100f59190610605565b60405180910390f35b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661018a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101819061067d565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fda502b164eb5cfccfa9f947e0fdc1a0bd060adfef2947810b256321c1a74ca4183836040516101d29291906106ea565b60405180910390a25050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102639061075a565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a250565b60016020528060005260406000206000915054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103af9061075a565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167faab7954e9d246b167ef88aeddad35209ca2489d95a8aeb59e288d9b19fae5a5460405160405180910390a250565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126104a8576104a7610483565b5b8235905067ffffffffffffffff8111156104c5576104c4610488565b5b6020830191508360018202830111156104e1576104e061048d565b5b9250929050565b600080602083850312156104ff576104fe610479565b5b600083013567ffffffffffffffff81111561051d5761051c61047e565b5b61052985828601610492565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b61057081610555565b811461057b57600080fd5b50565b60008135905061058d81610567565b92915050565b6000602082840312156105a9576105a8610479565b5b60006105b78482850161057e565b91505092915050565b60008115159050919050565b6105d5816105c0565b82525050565b60006020820190506105f060008301846105cc565b92915050565b6105ff81610555565b82525050565b600060208201905061061a60008301846105f6565b92915050565b600082825260208201905092915050565b7f4e6f742077686974656c69737465640000000000000000000000000000000000600082015250565b6000610667600f83610620565b915061067282610631565b602082019050919050565b600060208201905081810360008301526106968161065a565b9050919050565b82818337600083830152505050565b6000601f19601f8301169050919050565b60006106c98385610620565b93506106d683858461069d565b6106df836106ac565b840190509392505050565b600060208201905081810360008301526107058184866106bd565b90509392505050565b7f4e6f742061646d696e0000000000000000000000000000000000000000000000600082015250565b6000610744600983610620565b915061074f8261070e565b602082019050919050565b6000602082019050818103600083015261077381610737565b905091905056fea26469706673582212202ad433ea9240cc561f6b9168c7880800e372f26e322166cedd6ce135222e699764736f6c634300081c0033",wq={},bq={},_q={_format:hq,contractName:dq,sourceName:pq,abi:gq,bytecode:yq,deployedBytecode:mq,linkReferences:wq,deployedLinkReferences:bq},Aq="Eai8D93JKad51sYmft1r74fzLkBSwRGPQVAmwZoLoWDf",Eq={name:"swarm_event_emitter",version:"0.1.0",spec:"0.1.0",description:"Created with Anchor"},vq=[{name:"add_to_whitelist",discriminator:[157,211,52,54,144,81,5,55],accounts:[{name:"state",writable:!0},{name:"admin",signer:!0}],args:[{name:"user",type:"pubkey"}]},{name:"emit_message",discriminator:[118,99,20,87,25,132,207,62],accounts:[{name:"state",writable:!0},{name:"user",signer:!0}],args:[{name:"message",type:"string"}]},{name:"initialize",discriminator:[175,175,109,31,13,152,155,237],accounts:[{name:"state",writable:!0,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"admin",writable:!0,signer:!0},{name:"system_program",address:"11111111111111111111111111111111"}],args:[]},{name:"remove_from_whitelist",discriminator:[7,144,216,239,243,236,193,235],accounts:[{name:"state",writable:!0},{name:"admin",signer:!0}],args:[{name:"user",type:"pubkey"}]}],xq=[{name:"State",discriminator:[216,146,107,94,104,75,182,177]}],Rq=[{name:"MessageLogged",discriminator:[24,236,247,207,227,70,101,210]},{name:"RemovedFromWhitelist",discriminator:[107,247,94,185,182,200,82,172]},{name:"Whitelisted",discriminator:[235,202,86,232,226,75,139,182]}],Iq=[{code:6e3,name:"NotAdmin",msg:"Only the admin can perform this action."},{code:6001,name:"NotWhitelisted",msg:"You are not whitelisted."}],Sq=[{name:"MessageLogged",type:{kind:"struct",fields:[{name:"sender",type:"pubkey"},{name:"message",type:"string"}]}},{name:"RemovedFromWhitelist",type:{kind:"struct",fields:[{name:"account",type:"pubkey"}]}},{name:"State",type:{kind:"struct",fields:[{name:"admin",type:"pubkey"},{name:"whitelisted",type:{vec:"pubkey"}}]}},{name:"Whitelisted",type:{kind:"struct",fields:[{name:"account",type:"pubkey"}]}}],kq={address:Aq,metadata:Eq,instructions:vq,accounts:xq,events:Rq,errors:Iq,types:Sq};class Tq{constructor(t){this.settings=t,this.evm=null,this.svm=null,this.init()}init(){this.settings.chainType==="EVM"?this.initEvm():this.settings.chainType==="SVM"&&this.initSvm()}initEvm(){const{rpcUrl:t,contractAddress:e}=this.settings;if(!e)throw new Error("Contract address is required for EVM chain type");const r=t.startsWith("ws")?new fq(t):new rq(t),i=new _u(e,_q.abi,r);this.evm={provider:r,contract:i}}initSvm(){const t=new RR(this.settings.rpcUrl,"confirmed"),e=cc.generate(),r={signTransaction:async o=>o,signAllTransactions:async o=>o,publicKey:e.publicKey},i=new Rh(t,r,{}),s=new Rl(kq,i);this.svm={provider:t,program:s}}async onMessageFrom(t,e){this.settings.chainType==="EVM"?this.listenToEvm(t,e):this.settings.chainType==="SVM"&&await this.listenToSvm(t,e)}listenToEvm(t,e){var r;(r=this.evm)==null||r.contract.on("MessageLogged",(i,s)=>{const[o,a]=s.split("_");Jf(i.toLowerCase())===Jf(this.settings.swarmEmitterAddress.toLowerCase())&&o===t&&e(i,s)})}async listenToSvm(t,e){var i;const r=(i=this.svm)==null?void 0:i.program.addEventListener("messageLogged",s=>{const{sender:o,message:a}=s,[u,f]=a.split("_");o.toBase58()===this.settings.swarmEmitterAddress&&u===t&&e(o.toBase58(),a)});this.svm&&r!==void 0&&(this.svm.listenerId=r)}async removeAllListeners(){var t,e;this.settings.chainType==="EVM"&&((t=this.evm)==null||t.contract.removeAllListeners("MessageLogged")),this.settings.chainType==="SVM"&&((e=this.svm)==null?void 0:e.listenerId)!==void 0&&(await this.svm.program.removeEventListener(this.svm.listenerId),this.svm.listenerId=void 0)}}const Oq=new TextEncoder,px=1,gx=4096,Um=4096,Nq=32;function Cq(n,t){return t=typeof t=="number"?Qt.FeedIndex.fromBigInt(BigInt(t)):t,new Qt.Identifier(ar.keccak256(ar.concatBytes(n.toUint8Array(),t.toUint8Array())))}function Bq(n){const t=n.slice(0,Qt.Span.LENGTH),e=n.slice(Qt.Span.LENGTH),r=Pq(e),i=ar.keccak256(ar.concatBytes(t,r));return new Qt.Reference(i)}function Pq(n){if(n.length>Um)throw new Qt.BeeArgumentError(`payload size ${n.length} exceeds maximum chunk payload size ${Um}`,n);const t=new Uint8Array(Um);return t.set(n),ar.log2Reduce(ar.partition(t,Nq),(e,r)=>ar.keccak256(ar.concatBytes(e,r)))}function yx(n){if(n instanceof Uint8Array||(n=Oq.encode(n)),n.length<px||n.length>gx)throw new RangeError(`payload size ${n.length} exceeds limits [${px}, ${gx}]`);const t=Qt.Span.fromBigInt(BigInt(n.length)),e=ar.concatBytes(t.toUint8Array(),n);return{data:e,span:t,payload:Qt.Bytes.fromSlice(e,Qt.Span.LENGTH),address:Bq(e)}}function Mq(n,t){return new Qt.Reference(ar.keccak256(ar.concatBytes(n.toUint8Array(),t.toUint8Array())))}function mx(n,t,e){t=new Qt.Identifier(t),e=new Qt.PrivateKey(e);const r=Mq(t,e.publicKey().address()),i=e.sign(ar.concatBytes(t.toUint8Array(),n.address.toUint8Array())),s=ar.concatBytes(t.toUint8Array(),i.toUint8Array(),n.data),o=Qt.Span.fromSlice(n.data,0),a=Qt.Bytes.fromSlice(n.data,Qt.Span.LENGTH);return{data:s,identifier:t,signature:i,span:o,payload:a,address:r,owner:e.publicKey().address()}}class Lq{constructor(t,e){this.userDetails=t,this.swarmSettings=e,this.depth=24,this.logger=es.getInstance(),this.errorHandler=new o1,this.UPLOAD_GSOC_TIMEOUT=2e3}async writeOwnFeedDataByIndex(t,e){const{enveloped:r,stamp:i}=this.swarmSettings;if(!r)await this.writeOwnFeedDataByIndexOwned(t,e);else if(i)await this.writeOwnFeedDataByIndexEnvelope(t,e);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async writeOwnFeedDataByIndexOwned(t,e){const{bee:r,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=this.generateUserOwnedFeedId(s,a),f=Qt.Topic.fromString(u);console.log("DEBUG: feedID write",f.toString(),a,t,u),await r.makeFeedWriter(f,new Qt.PrivateKey(o)).uploadPayload(i,JSON.stringify(e),{index:t})}async writeOwnFeedDataByIndexEnvelope(t,e){const{bee:r,stamp:i,chatTopic:s}=this.swarmSettings,{privateKey:o,ownAddress:a}=this.userDetails,u=new Qt.PrivateKey(o),f=Qt.Stamper.fromBlank(o,i,this.depth),h=this.generateUserOwnedFeedId(s,a),y=Qt.Topic.fromString(h),_=Cq(y,t),w=yx(e),R=mx(w,_,u),T={hash:()=>R.address.toUint8Array()},I=f.stamp(T),{upload:B}=r.makeSOCWriter(u),H=Qt.Bytes.fromUtf8(e);return(await B(I,_,H.toUint8Array())).reference.toHex()}async fetchUserFeedDataByIndex(t,e,r){const{bee:i,chatTopic:s}=this.swarmSettings,o=(r==null?void 0:r.timeout)??1500,a=this.generateUserOwnedFeedId(s,t),u=Qt.Topic.fromString(a);return console.log("DEBUG: feedID read",u.toString(),t,e,a),(await i.makeFeedReader(u,t,{timeout:o}).downloadPayload({index:e})).payload.toJSON()}orderMessages(t){return t.sort((e,r)=>e.timestamp-r.timestamp)}async retryAwaitableAsync(t,e=3,r=250){return new Promise((i,s)=>{t().then(i).catch(o=>{e>0?(this.logger.info(`Retrying... Attempts left: ${e}. Error: ${o.message}`),setTimeout(()=>{this.retryAwaitableAsync(t,e-1,r).then(i).catch(s)},r)):(this.errorHandler.handleError(o,"Utils.retryAwaitableAsync"),s(o))})})}async uploadObjectToBee(t){const{enveloped:e,stamp:r}=this.swarmSettings;if(e){if(r)return this.uploadObjectToBeeEnvelope(t);throw new Error("Enveloped mode is enabled, but stamp is not provided")}else return this.uploadObjectToBeeOwn(t)}async uploadObjectToBeeOwn(t){try{const{bee:e,stamp:r}=this.swarmSettings,i=await e.uploadData(r,JSON.stringify(t),{redundancyLevel:4});return console.log("DEBUG: result",i.reference.toString()),i.reference.toString()}catch(e){return this.errorHandler.handleError(e,"Utils.uploadObjectToBee"),null}}async uploadObjectToBeeEnvelope(t){try{const{bee:e,stamp:r}=this.swarmSettings,{privateKey:i}=this.userDetails,s=Qt.Stamper.fromBlank(i,r,this.depth),o=Qt.Bytes.fromUtf8(JSON.stringify(t)),a=new XM(async f=>{await e.uploadChunk(s.stamp(f),f.build())});await a.append(o.toUint8Array());const u=await a.finalize();return ar.uint8ArrayToHex(u.hash())}catch(e){return this.errorHandler.handleError(e,"Utils.uploadObjectToBee"),null}}async downloadObjectFromBee(t){try{const{bee:e}=this.swarmSettings;return(await e.downloadData(t)).toJSON()}catch(e){return this.errorHandler.handleError(e,"Utils.beeDownloadObject"),null}}async getOwnLatestFeedIndex(){try{const{bee:t,chatTopic:e}=this.swarmSettings,{ownAddress:r}=this.userDetails,i=this.generateUserOwnedFeedId(e,r),s=Qt.Topic.fromString(i),a=await t.makeFeedReader(s,r).downloadPayload(),u=Number(a.feedIndex.toBigInt()),f=u+1;return console.log("DEBUG: getLatestFeedIndex",u,f),{latestIndex:u,nextIndex:f}}catch(t){if(this.isNotFoundError(t))return{latestIndex:-1,nextIndex:0};throw t}}async fetchLatestChatMessage(){const{bee:t,chatTopic:e,chatAddress:r}=this.swarmSettings,s=await t.makeFeedReader(Qt.Topic.fromString(e),Jf(r)).downloadPayload();return{message:s.payload.toJSON(),index:s.feedIndex}}async fetchChatMessage(t){const{bee:e,chatTopic:r,chatAddress:i}=this.swarmSettings;return(await e.makeFeedReader(Qt.Topic.fromString(r),Jf(i)).downloadPayload({index:t})).payload.toJSON()}async sendMessageToGsoc(t){const{enveloped:e,stamp:r}=this.swarmSettings;if(!e)await this.sendMessageToGsocOwn(t);else if(r)await this.sendMessageToGsocEnvelope(t);else throw new Error("Enveloped mode is enabled, but stamp is not provided")}async sendMessageToGsocOwn(t){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:e,stamp:r,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,o=new Qt.PrivateKey(s),a=Qt.Identifier.fromString(i),u=Qt.Bytes.fromUtf8(t),{upload:f}=e.makeSOCWriter(o,{timeout:this.UPLOAD_GSOC_TIMEOUT});await f(r,a,u.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}async sendMessageToGsocEnvelope(t){this.logger.debug("sendMessageToGsoc entry CALLED");const{bee:e,stamp:r,gsocTopic:i,gsocResourceId:s}=this.swarmSettings,{privateKey:o}=this.userDetails,a=Qt.Stamper.fromBlank(o,r,this.depth),u=new Qt.PrivateKey(s),f=Qt.Identifier.fromString(i),h=Qt.Bytes.fromUtf8(t),y=yx(h.toUint8Array()),_=mx(y,f,u),w={hash:()=>_.address.toUint8Array()},R=a.stamp(w),{upload:T}=e.makeSOCWriter(u,{timeout:this.UPLOAD_GSOC_TIMEOUT});await T(R,f,h.toUint8Array()),this.logger.debug("sendMessageToGsoc end CALLED")}generateUserOwnedFeedId(t,e){return`${t}_EthercastChat_${e}`}isNotFoundError(t){return t.stack.includes("404")||t.message.includes("Not Found")||t.message.includes("404")}}class Uq{constructor(t){var r,i,s;this.logger=es.getInstance(),this.errorHandler=new o1,this.messagesQueue=new mA({concurrency:1}),this.gsocListenerQueue=new mA({concurrency:1}),this.activeUsers={},this.latestMessage=null,this.userIndexCache={};const e=new Qt.PrivateKey(Jf(t.user.privateKey));this.userDetails={privateKey:t.user.privateKey,ownAddress:e.publicKey().address().toString(),nickname:t.user.nickname,ownIndex:-1},this.swarmSettings={bee:new Qt.Bee(t.infra.swarm.beeUrl),stamp:t.infra.swarm.stamp||"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",enveloped:t.infra.swarm.enveloped,customGsocCallback:t.infra.swarm.customGsocCallback,gsocTopic:t.infra.swarm.gsocTopic,gsocResourceId:t.infra.swarm.gsocResourceId,chatTopic:t.infra.swarm.chatTopic,chatAddress:t.infra.swarm.chatAddress},this.options={fetchMessageTimer:null,idleUserCleanupInterval:null,FETCH_MESSAGE_INTERVAL_TIME:((r=t.options)==null?void 0:r.fetchMessageIntervalTime)||1e3,IDLE_USER_CLEANUP_INTERVAL_TIME:((i=t.options)==null?void 0:i.idleUserCleanupIntervalTime)||5e3,READ_MESSAGE_TIMEOUT:((s=t.options)==null?void 0:s.readMessageTimeout)||1500},this.emitter=new YM,this.utils=new Lq(this.userDetails,this.swarmSettings),this.history=new pU(this.utils,this.emitter),!this.swarmSettings.customGsocCallback&&t.infra.chain&&(this.swarmEventEmitterReader=new Tq(t.infra.chain))}start(){this.init(),this.startMessagesFetchProcess(),this.startIdleUserCleanup(),this.swarmSettings.customGsocCallback||this.subscribeToGSOCEvent()}stop(){this.stopMessagesFetchProcess(),this.stopIdleUserCleanup(),this.emitter.cleanAll(),this.swarmSettings.customGsocCallback||this.unsubFromGSOCEvent()}getEmitter(){return this.emitter}orderMessages(t){return this.utils.orderMessages(t)}async sendMessage(t,e){const r=this.userDetails.ownIndex===-1?0:this.userDetails.ownIndex+1,i={id:e||JM(),username:this.userDetails.nickname,address:this.userDetails.ownAddress,timestamp:Date.now(),index:r,message:t};try{this.emitter.emit(Mr.MESSAGE_REQUEST_INITIATED,i),await this.utils.writeOwnFeedDataByIndex(r,JSON.stringify(i)),this.userDetails.ownIndex=r,this.emitter.emit(Mr.MESSAGE_REQUEST_UPLOADED,i),await this.broadcastUserMessage()}catch(s){this.emitter.emit(Mr.MESSAGE_REQUEST_ERROR,i),this.errorHandler.handleError(s,"Chat.sendMessage")}}async fetchPreviousMessages(){try{return this.emitter.emit(Mr.LOADING_PREVIOUS_MESSAGES,!0),await this.history.fetchPreviousMessages()}finally{this.emitter.emit(Mr.LOADING_PREVIOUS_MESSAGES,!1)}}async retrySendMessage(t){this.sendMessage(t.message,t.id)}async retryBroadcastUserMessage(t){this.broadcastUserMessage()}async init(){try{this.emitter.emit(Mr.LOADING_INIT,!0);const[t,e]=await Promise.allSettled([this.initOwnIndex(),this.history.init()]);if(t.status==="rejected")throw t.reason;e.status==="rejected"&&this.logger.warn(`historyInitResult failed: ${e.reason}`),this.emitter.emit(Mr.LOADING_INIT,!1)}catch(t){this.errorHandler.handleError(t,"Chat.initSelfState"),this.emitter.emit(Mr.CRITICAL_ERROR,t)}}async initOwnIndex(){const{latestIndex:r}=await this.utils.retryAwaitableAsync(()=>this.utils.getOwnLatestFeedIndex(),10,1e3);this.userDetails.ownIndex=r}subscribeToGSOCEvent(){try{this.swarmEventEmitterReader.onMessageFrom(this.swarmSettings.chatTopic,(t,e)=>this.gsocListenerQueue.add(()=>this.processGsocEvent(e)))}catch(t){this.errorHandler.handleError(t,"Chat.subscribeToGSOCEvent"),this.emitter.emit(Mr.CRITICAL_ERROR,t)}}callbackProcessGsocEvent(t){try{this.gsocListenerQueue.add(()=>this.processGsocEvent(t))}catch(e){this.errorHandler.handleError(e,"Chat.callbackProcessGsocEvent"),this.emitter.emit(Mr.CRITICAL_ERROR,e)}}async processGsocEvent(t){try{console.log("processGsocMessage CALLED",t);const[e,r]=t.split("_"),i=Qt.FeedIndex.fromBigInt(BigInt(`0x${r}`)),s=await this.utils.fetchChatMessage(i);if(console.log("DEBUG processGsocMessage",s),!uU(s)){this.logger.warn("Invalid GSOC message during processing");return}if(this.logger.debug("New GSOC message:",s),HM(this.latestMessage,s))return;this.updateActiveUsers(s.messageSender),this.latestMessage=s}catch(e){this.errorHandler.handleError(e,"Chat.processGsocMessage")}}async waitForMessageBroadcast(t){return hU({condition:()=>Object.values(this.activeUsers).some(e=>e.index===t),broadcast:()=>this.broadcastUserMessage()})}async broadcastUserMessage(){try{this.logger.debug("broadcastUserMessage entry CALLED");const t=await this.makeMessageSender();console.log("DEBUG broadcastUserMessage",t),await this.utils.retryAwaitableAsync(()=>this.utils.sendMessageToGsoc(JSON.stringify({topic:this.swarmSettings.chatTopic,messageSender:t})))}catch(t){this.errorHandler.handleError(t,"Chat.broadcastUserMessage")}}async makeMessageSender(){const{ownAddress:t,privateKey:e,nickname:r}=this.userDetails,i=new Qt.EthAddress(t).toString(),s=new Qt.PrivateKey(e);if(s.publicKey().address().toString()!==i)throw new Error("The provided address does not match the address derived from the private key");const a=Date.now(),u=s.sign(JSON.stringify({username:r,address:i,timestamp:a}));return{address:i,timestamp:a,signature:u.toHex(),index:this.getOwnIndex(),username:r}}async readAllActiveUserMessage(){if(!(this.messagesQueue.size>0||this.messagesQueue.pending>0))for(const e of Object.values(this.activeUsers))this.messagesQueue.add(()=>this.readMessage(e))}async readMessage(t){try{let e;const r=this.isUserIndexRead(t.address,t.index);if(r.isIndexRead)return;e=r.cachedIndex?r.cachedIndex+1:t.index;const i=await this.utils.fetchUserFeedDataByIndex(t.address,e);this.setUserIndexCache(t.address,e),this.emitter.emit(Mr.MESSAGE_RECEIVED,JSON.parse(i))}catch(e){this.errorHandler.handleError(e,"readMessage")}}unsubFromGSOCEvent(){this.swarmEventEmitterReader.removeAllListeners()}startMessagesFetchProcess(){const{fetchMessageTimer:t,FETCH_MESSAGE_INTERVAL_TIME:e}=this.options;if(t){this.logger.warn("Messages fetch process is already running.");return}this.options.fetchMessageTimer=setInterval(this.readAllActiveUserMessage.bind(this),e)}stopMessagesFetchProcess(){const{fetchMessageTimer:t}=this.options;t&&(clearInterval(t),this.options.fetchMessageTimer=null)}startIdleUserCleanup(){const{idleUserCleanupInterval:t,IDLE_USER_CLEANUP_INTERVAL_TIME:e}=this.options;if(t){this.logger.warn("Idle user cleanup is already running.");return}this.options.idleUserCleanupInterval=setInterval(this.removeIdleUsers.bind(this),e)}stopIdleUserCleanup(){const{idleUserCleanupInterval:t}=this.options;t&&(clearInterval(t),this.options.idleUserCleanupInterval=null)}isUserIndexRead(t,e){const r=this.userIndexCache[t];return{cachedIndex:r,isIndexRead:r===e}}setUserIndexCache(t,e){this.userIndexCache[t]=e}getOwnIndex(){return this.userDetails.ownIndex}removeIdleUsers(){const t=Date.now();for(const e of Object.values(this.activeUsers))t-e.timestamp>300*dU&&delete this.activeUsers[e.address]}updateActiveUsers(t){this.activeUsers[t.address]=t}}exports.EVENTS=Mr;exports.SwarmChat=Uq;
|