@coinflowlabs/vue 0.3.2 → 1.0.1

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.
Files changed (27) hide show
  1. package/README.md +47 -20
  2. package/dist/coinflow-vue.js +7088 -7829
  3. package/dist/coinflow-vue.umd.cjs +6 -6
  4. package/dist/components/CoinflowPurchase.vue.d.ts +14 -12
  5. package/dist/components/card-form/CoinflowCardNumberInput.vue.d.ts +4 -4
  6. package/dist/components/card-form/CoinflowCardNumberOnlyInput.vue.d.ts +4 -4
  7. package/dist/components/card-form/CoinflowCvvInput.vue.d.ts +1 -1
  8. package/dist/components/card-form/CoinflowCvvOnlyInput.vue.d.ts +4 -4
  9. package/dist/components/card-form/useCardformIframe.d.ts +4 -2
  10. package/dist/components/mobile-wallet/ApplePayOverlay.vue.d.ts +1 -1
  11. package/dist/components/mobile-wallet/CoinflowApplePayButton.vue.d.ts +1 -1
  12. package/dist/components/mobile-wallet/CoinflowGooglePayButton.vue.d.ts +1 -1
  13. package/dist/components/mobile-wallet/MobileWalletButton.vue.d.ts +3 -2
  14. package/dist/lib/common/CoinflowLibMessageHandlers.d.ts +2 -2
  15. package/dist/lib/common/CoinflowTypes.d.ts +19 -4
  16. package/dist/lib/common/CoinflowUtils.d.ts +2 -15
  17. package/dist/lib/common/Subtotal.d.ts +37 -0
  18. package/dist/lib/common/card-form/TokenEx.d.ts +19 -2
  19. package/dist/lib/common/card-form/tokenexHelpers.d.ts +14 -7
  20. package/dist/lib/common/index.d.ts +1 -0
  21. package/dist/testing/CardFormTest.vue.d.ts +1 -1
  22. package/dist/testing/MobileWalletButtonTest.vue.d.ts +1 -1
  23. package/dist/testing/PurchaseTest.vue.d.ts +1 -1
  24. package/dist/testing/SavedCardFormTest.vue.d.ts +1 -1
  25. package/dist/testing/WithdrawTest.vue.d.ts +1 -1
  26. package/package.json +10 -14
  27. package/dist/testing/YouPay.vue.d.ts +0 -2
@@ -1,18 +1,18 @@
1
- (function(se,ft){typeof exports=="object"&&typeof module<"u"?ft(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],ft):(se=typeof globalThis<"u"?globalThis:se||self,ft(se.VueTypeWriter={},se.Vue))})(this,function(se,ft){"use strict";var zd=Object.defineProperty;var Kd=(se,ft,wn)=>ft in se?zd(se,ft,{enumerable:!0,configurable:!0,writable:!0,value:wn}):se[ft]=wn;var nr=(se,ft,wn)=>Kd(se,typeof ft!="symbol"?ft+"":ft,wn);var wn=(n=>(n.Credits="Credits",n.USDC="USDC",n.Bank="Bank",n))(wn||{}),Bo=(n=>(n.Rounded="rounded",n.Sharp="sharp",n.Pill="pill",n))(Bo||{}),Ro=(n=>(n.NoPreference="NoPreference",n.Frictionless="Frictionless",n.Challenge="Challenge",n))(Ro||{}),On=(n=>(n.VISA="VISA",n.MASTERCARD="MSTR",n.AMEX="AMEX",n.DISCOVER="DISC",n))(On||{}),Nr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ni(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function cs(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 s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return n[r]}})}),e}var Ct={},Si={};Si.byteLength=ru,Si.toByteArray=iu,Si.fromByteArray=au;for(var qr=[],Pr=[],tu=typeof Uint8Array<"u"?Uint8Array:Array,us="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Nn=0,eu=us.length;Nn<eu;++Nn)qr[Nn]=us[Nn],Pr[us.charCodeAt(Nn)]=Nn;Pr[45]=62,Pr[95]=63;function To(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 ru(n){var t=To(n),e=t[0],r=t[1];return(e+r)*3/4-r}function nu(n,t,e){return(t+e)*3/4-e}function iu(n){var t,e=To(n),r=e[0],s=e[1],i=new tu(nu(n,r,s)),o=0,a=s>0?r-4:r,l;for(l=0;l<a;l+=4)t=Pr[n.charCodeAt(l)]<<18|Pr[n.charCodeAt(l+1)]<<12|Pr[n.charCodeAt(l+2)]<<6|Pr[n.charCodeAt(l+3)],i[o++]=t>>16&255,i[o++]=t>>8&255,i[o++]=t&255;return s===2&&(t=Pr[n.charCodeAt(l)]<<2|Pr[n.charCodeAt(l+1)]>>4,i[o++]=t&255),s===1&&(t=Pr[n.charCodeAt(l)]<<10|Pr[n.charCodeAt(l+1)]<<4|Pr[n.charCodeAt(l+2)]>>2,i[o++]=t>>8&255,i[o++]=t&255),i}function su(n){return qr[n>>18&63]+qr[n>>12&63]+qr[n>>6&63]+qr[n&63]}function ou(n,t,e){for(var r,s=[],i=t;i<e;i+=3)r=(n[i]<<16&16711680)+(n[i+1]<<8&65280)+(n[i+2]&255),s.push(su(r));return s.join("")}function au(n){for(var t,e=n.length,r=e%3,s=[],i=16383,o=0,a=e-r;o<a;o+=i)s.push(ou(n,o,o+i>a?a:o+i));return r===1?(t=n[e-1],s.push(qr[t>>2]+qr[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],s.push(qr[t>>10]+qr[t>>4&63]+qr[t<<2&63]+"=")),s.join("")}var fs={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */fs.read=function(n,t,e,r,s){var i,o,a=s*8-r-1,l=(1<<a)-1,y=l>>1,x=-7,E=e?s-1:0,L=e?-1:1,C=n[t+E];for(E+=L,i=C&(1<<-x)-1,C>>=-x,x+=a;x>0;i=i*256+n[t+E],E+=L,x-=8);for(o=i&(1<<-x)-1,i>>=-x,x+=r;x>0;o=o*256+n[t+E],E+=L,x-=8);if(i===0)i=1-y;else{if(i===l)return o?NaN:(C?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-y}return(C?-1:1)*o*Math.pow(2,i-r)},fs.write=function(n,t,e,r,s,i){var o,a,l,y=i*8-s-1,x=(1<<y)-1,E=x>>1,L=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=r?0:i-1,N=r?1:-1,M=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=x):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+E>=1?t+=L/l:t+=L*Math.pow(2,1-E),t*l>=2&&(o++,l/=2),o+E>=x?(a=0,o=x):o+E>=1?(a=(t*l-1)*Math.pow(2,s),o=o+E):(a=t*Math.pow(2,E-1)*Math.pow(2,s),o=0));s>=8;n[e+C]=a&255,C+=N,a/=256,s-=8);for(o=o<<s|a,y+=s;y>0;n[e+C]=o&255,C+=N,o/=256,y-=8);n[e+C-N]|=M*128};/*!
1
+ (function(kt,et){typeof exports=="object"&&typeof module<"u"?et(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],et):(kt=typeof globalThis<"u"?globalThis:kt||self,et(kt.VueTypeWriter={},kt.Vue))})(this,function(kt,et){"use strict";var Xh=Object.defineProperty;var Qh=(kt,et,ir)=>et in kt?Xh(kt,et,{enumerable:!0,configurable:!0,writable:!0,value:ir}):kt[et]=ir;var he=(kt,et,ir)=>Qh(kt,typeof et!="symbol"?et+"":et,ir);var ir=(n=>(n.Credits="Credits",n.USDC="USDC",n.Bank="Bank",n))(ir||{}),ms=(n=>(n.Rounded="rounded",n.Sharp="sharp",n.Pill="pill",n))(ms||{}),ws=(n=>(n.NoPreference="NoPreference",n.Frictionless="Frictionless",n.Challenge="Challenge",n))(ws||{}),br=(n=>(n.VISA="VISA",n.MASTERCARD="MSTR",n.AMEX="AMEX",n.DISCOVER="DISC",n))(br||{});function Nr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Fn(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 s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return n[r]}})}),e}var zn={},Fr={},bs;function Ua(){if(bs)return Fr;bs=1,Fr.byteLength=a,Fr.toByteArray=g,Fr.fromByteArray=M;for(var n=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,i=r.length;s<i;++s)n[s]=r[s],t[r.charCodeAt(s)]=s;t[45]=62,t[95]=63;function o(R){var C=R.length;if(C%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=R.indexOf("=");B===-1&&(B=C);var T=B===C?0:4-B%4;return[B,T]}function a(R){var C=o(R),B=C[0],T=C[1];return(B+T)*3/4-T}function h(R,C,B){return(C+B)*3/4-B}function g(R){var C,B=o(R),T=B[0],O=B[1],$=new e(h(R,T,O)),q=0,X=O>0?T-4:T,D;for(D=0;D<X;D+=4)C=t[R.charCodeAt(D)]<<18|t[R.charCodeAt(D+1)]<<12|t[R.charCodeAt(D+2)]<<6|t[R.charCodeAt(D+3)],$[q++]=C>>16&255,$[q++]=C>>8&255,$[q++]=C&255;return O===2&&(C=t[R.charCodeAt(D)]<<2|t[R.charCodeAt(D+1)]>>4,$[q++]=C&255),O===1&&(C=t[R.charCodeAt(D)]<<10|t[R.charCodeAt(D+1)]<<4|t[R.charCodeAt(D+2)]>>2,$[q++]=C>>8&255,$[q++]=C&255),$}function w(R){return n[R>>18&63]+n[R>>12&63]+n[R>>6&63]+n[R&63]}function k(R,C,B){for(var T,O=[],$=C;$<B;$+=3)T=(R[$]<<16&16711680)+(R[$+1]<<8&65280)+(R[$+2]&255),O.push(w(T));return O.join("")}function M(R){for(var C,B=R.length,T=B%3,O=[],$=16383,q=0,X=B-T;q<X;q+=$)O.push(k(R,q,q+$>X?X:q+$));return T===1?(C=R[B-1],O.push(n[C>>2]+n[C<<4&63]+"==")):T===2&&(C=(R[B-2]<<8)+R[B-1],O.push(n[C>>10]+n[C>>4&63]+n[C<<2&63]+"=")),O.join("")}return Fr}var tn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var ks;function Na(){return ks||(ks=1,tn.read=function(n,t,e,r,s){var i,o,a=s*8-r-1,h=(1<<a)-1,g=h>>1,w=-7,k=e?s-1:0,M=e?-1:1,R=n[t+k];for(k+=M,i=R&(1<<-w)-1,R>>=-w,w+=a;w>0;i=i*256+n[t+k],k+=M,w-=8);for(o=i&(1<<-w)-1,i>>=-w,w+=r;w>0;o=o*256+n[t+k],k+=M,w-=8);if(i===0)i=1-g;else{if(i===h)return o?NaN:(R?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-g}return(R?-1:1)*o*Math.pow(2,i-r)},tn.write=function(n,t,e,r,s,i){var o,a,h,g=i*8-s-1,w=(1<<g)-1,k=w>>1,M=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=r?0:i-1,C=r?1:-1,B=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=w):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),o+k>=1?t+=M/h:t+=M*Math.pow(2,1-k),t*h>=2&&(o++,h/=2),o+k>=w?(a=0,o=w):o+k>=1?(a=(t*h-1)*Math.pow(2,s),o=o+k):(a=t*Math.pow(2,k-1)*Math.pow(2,s),o=0));s>=8;n[e+R]=a&255,R+=C,a/=256,s-=8);for(o=o<<s|a,g+=s;g>0;n[e+R]=o&255,R+=C,o/=256,g-=8);n[e+R-C]|=B*128}),tn}/*!
2
2
  * The buffer module from node.js, for the browser.
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
- */(function(n){const t=Si,e=fs,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=Q,n.INSPECT_MAX_BYTES=50;const s=2147483647;n.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.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 i(){try{const w=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(w,f),w.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(w){if(w>s)throw new RangeError('The value "'+w+'" is invalid for option "size"');const f=new Uint8Array(w);return Object.setPrototypeOf(f,a.prototype),f}function a(w,f,d){if(typeof w=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(w)}return l(w,f,d)}a.poolSize=8192;function l(w,f,d){if(typeof w=="string")return L(w,f);if(ArrayBuffer.isView(w))return N(w);if(w==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof w);if(rr(w,ArrayBuffer)||w&&rr(w.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(rr(w,SharedArrayBuffer)||w&&rr(w.buffer,SharedArrayBuffer)))return M(w,f,d);if(typeof w=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const B=w.valueOf&&w.valueOf();if(B!=null&&B!==w)return a.from(B,f,d);const F=O(w);if(F)return F;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof w[Symbol.toPrimitive]=="function")return a.from(w[Symbol.toPrimitive]("string"),f,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof w)}a.from=function(w,f,d){return l(w,f,d)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function y(w){if(typeof w!="number")throw new TypeError('"size" argument must be of type number');if(w<0)throw new RangeError('The value "'+w+'" is invalid for option "size"')}function x(w,f,d){return y(w),w<=0?o(w):f!==void 0?typeof d=="string"?o(w).fill(f,d):o(w).fill(f):o(w)}a.alloc=function(w,f,d){return x(w,f,d)};function E(w){return y(w),o(w<0?0:K(w)|0)}a.allocUnsafe=function(w){return E(w)},a.allocUnsafeSlow=function(w){return E(w)};function L(w,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const d=j(w,f)|0;let B=o(d);const F=B.write(w,f);return F!==d&&(B=B.slice(0,F)),B}function C(w){const f=w.length<0?0:K(w.length)|0,d=o(f);for(let B=0;B<f;B+=1)d[B]=w[B]&255;return d}function N(w){if(rr(w,Uint8Array)){const f=new Uint8Array(w);return M(f.buffer,f.byteOffset,f.byteLength)}return C(w)}function M(w,f,d){if(f<0||w.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(w.byteLength<f+(d||0))throw new RangeError('"length" is outside of buffer bounds');let B;return f===void 0&&d===void 0?B=new Uint8Array(w):d===void 0?B=new Uint8Array(w,f):B=new Uint8Array(w,f,d),Object.setPrototypeOf(B,a.prototype),B}function O(w){if(a.isBuffer(w)){const f=K(w.length)|0,d=o(f);return d.length===0||w.copy(d,0,0,f),d}if(w.length!==void 0)return typeof w.length!="number"||ke(w.length)?o(0):C(w);if(w.type==="Buffer"&&Array.isArray(w.data))return C(w.data)}function K(w){if(w>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return w|0}function Q(w){return+w!=w&&(w=0),a.alloc(+w)}a.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==a.prototype},a.compare=function(f,d){if(rr(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),rr(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),!a.isBuffer(f)||!a.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===d)return 0;let B=f.length,F=d.length;for(let $=0,Z=Math.min(B,F);$<Z;++$)if(f[$]!==d[$]){B=f[$],F=d[$];break}return B<F?-1:F<B?1:0},a.isEncoding=function(f){switch(String(f).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}},a.concat=function(f,d){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return a.alloc(0);let B;if(d===void 0)for(d=0,B=0;B<f.length;++B)d+=f[B].length;const F=a.allocUnsafe(d);let $=0;for(B=0;B<f.length;++B){let Z=f[B];if(rr(Z,Uint8Array))$+Z.length>F.length?(a.isBuffer(Z)||(Z=a.from(Z)),Z.copy(F,$)):Uint8Array.prototype.set.call(F,Z,$);else if(a.isBuffer(Z))Z.copy(F,$);else throw new TypeError('"list" argument must be an Array of Buffers');$+=Z.length}return F};function j(w,f){if(a.isBuffer(w))return w.length;if(ArrayBuffer.isView(w)||rr(w,ArrayBuffer))return w.byteLength;if(typeof w!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof w);const d=w.length,B=arguments.length>2&&arguments[2]===!0;if(!B&&d===0)return 0;let F=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return _e(w).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return Ie(w).length;default:if(F)return B?-1:_e(w).length;f=(""+f).toLowerCase(),F=!0}}a.byteLength=j;function it(w,f,d){let B=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,f>>>=0,d<=f))return"";for(w||(w="utf8");;)switch(w){case"hex":return I(this,f,d);case"utf8":case"utf-8":return u(this,f,d);case"ascii":return R(this,f,d);case"latin1":case"binary":return _(this,f,d);case"base64":return T(this,f,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,f,d);default:if(B)throw new TypeError("Unknown encoding: "+w);w=(w+"").toLowerCase(),B=!0}}a.prototype._isBuffer=!0;function J(w,f,d){const B=w[f];w[f]=w[d],w[d]=B}a.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;d<f;d+=2)J(this,d,d+1);return this},a.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let d=0;d<f;d+=4)J(this,d,d+3),J(this,d+1,d+2);return this},a.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let d=0;d<f;d+=8)J(this,d,d+7),J(this,d+1,d+6),J(this,d+2,d+5),J(this,d+3,d+4);return this},a.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?u(this,0,f):it.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(f){if(!a.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:a.compare(this,f)===0},a.prototype.inspect=function(){let f="";const d=n.INSPECT_MAX_BYTES;return f=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(f+=" ... "),"<Buffer "+f+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(f,d,B,F,$){if(rr(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),!a.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(d===void 0&&(d=0),B===void 0&&(B=f?f.length:0),F===void 0&&(F=0),$===void 0&&($=this.length),d<0||B>f.length||F<0||$>this.length)throw new RangeError("out of range index");if(F>=$&&d>=B)return 0;if(F>=$)return-1;if(d>=B)return 1;if(d>>>=0,B>>>=0,F>>>=0,$>>>=0,this===f)return 0;let Z=$-F,Ht=B-d;const zt=Math.min(Z,Ht),Nt=this.slice(F,$),Re=f.slice(d,B);for(let Lt=0;Lt<zt;++Lt)if(Nt[Lt]!==Re[Lt]){Z=Nt[Lt],Ht=Re[Lt];break}return Z<Ht?-1:Ht<Z?1:0};function D(w,f,d,B,F){if(w.length===0)return-1;if(typeof d=="string"?(B=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,ke(d)&&(d=F?0:w.length-1),d<0&&(d=w.length+d),d>=w.length){if(F)return-1;d=w.length-1}else if(d<0)if(F)d=0;else return-1;if(typeof f=="string"&&(f=a.from(f,B)),a.isBuffer(f))return f.length===0?-1:tt(w,f,d,B,F);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?F?Uint8Array.prototype.indexOf.call(w,f,d):Uint8Array.prototype.lastIndexOf.call(w,f,d):tt(w,[f],d,B,F);throw new TypeError("val must be string, number or Buffer")}function tt(w,f,d,B,F){let $=1,Z=w.length,Ht=f.length;if(B!==void 0&&(B=String(B).toLowerCase(),B==="ucs2"||B==="ucs-2"||B==="utf16le"||B==="utf-16le")){if(w.length<2||f.length<2)return-1;$=2,Z/=2,Ht/=2,d/=2}function zt(Re,Lt){return $===1?Re[Lt]:Re.readUInt16BE(Lt*$)}let Nt;if(F){let Re=-1;for(Nt=d;Nt<Z;Nt++)if(zt(w,Nt)===zt(f,Re===-1?0:Nt-Re)){if(Re===-1&&(Re=Nt),Nt-Re+1===Ht)return Re*$}else Re!==-1&&(Nt-=Nt-Re),Re=-1}else for(d+Ht>Z&&(d=Z-Ht),Nt=d;Nt>=0;Nt--){let Re=!0;for(let Lt=0;Lt<Ht;Lt++)if(zt(w,Nt+Lt)!==zt(f,Lt)){Re=!1;break}if(Re)return Nt}return-1}a.prototype.includes=function(f,d,B){return this.indexOf(f,d,B)!==-1},a.prototype.indexOf=function(f,d,B){return D(this,f,d,B,!0)},a.prototype.lastIndexOf=function(f,d,B){return D(this,f,d,B,!1)};function rt(w,f,d,B){d=Number(d)||0;const F=w.length-d;B?(B=Number(B),B>F&&(B=F)):B=F;const $=f.length;B>$/2&&(B=$/2);let Z;for(Z=0;Z<B;++Z){const Ht=parseInt(f.substr(Z*2,2),16);if(ke(Ht))return Z;w[d+Z]=Ht}return Z}function ue(w,f,d,B){return Ae(_e(f,w.length-d),w,d,B)}function jt(w,f,d,B){return Ae(Oe(f),w,d,B)}function kt(w,f,d,B){return Ae(Ie(f),w,d,B)}function ce(w,f,d,B){return Ae(Ar(f,w.length-d),w,d,B)}a.prototype.write=function(f,d,B,F){if(d===void 0)F="utf8",B=this.length,d=0;else if(B===void 0&&typeof d=="string")F=d,B=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(B)?(B=B>>>0,F===void 0&&(F="utf8")):(F=B,B=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $=this.length-d;if((B===void 0||B>$)&&(B=$),f.length>0&&(B<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");F||(F="utf8");let Z=!1;for(;;)switch(F){case"hex":return rt(this,f,d,B);case"utf8":case"utf-8":return ue(this,f,d,B);case"ascii":case"latin1":case"binary":return jt(this,f,d,B);case"base64":return kt(this,f,d,B);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ce(this,f,d,B);default:if(Z)throw new TypeError("Unknown encoding: "+F);F=(""+F).toLowerCase(),Z=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(w,f,d){return f===0&&d===w.length?t.fromByteArray(w):t.fromByteArray(w.slice(f,d))}function u(w,f,d){d=Math.min(w.length,d);const B=[];let F=f;for(;F<d;){const $=w[F];let Z=null,Ht=$>239?4:$>223?3:$>191?2:1;if(F+Ht<=d){let zt,Nt,Re,Lt;switch(Ht){case 1:$<128&&(Z=$);break;case 2:zt=w[F+1],(zt&192)===128&&(Lt=($&31)<<6|zt&63,Lt>127&&(Z=Lt));break;case 3:zt=w[F+1],Nt=w[F+2],(zt&192)===128&&(Nt&192)===128&&(Lt=($&15)<<12|(zt&63)<<6|Nt&63,Lt>2047&&(Lt<55296||Lt>57343)&&(Z=Lt));break;case 4:zt=w[F+1],Nt=w[F+2],Re=w[F+3],(zt&192)===128&&(Nt&192)===128&&(Re&192)===128&&(Lt=($&15)<<18|(zt&63)<<12|(Nt&63)<<6|Re&63,Lt>65535&&Lt<1114112&&(Z=Lt))}}Z===null?(Z=65533,Ht=1):Z>65535&&(Z-=65536,B.push(Z>>>10&1023|55296),Z=56320|Z&1023),B.push(Z),F+=Ht}return m(B)}const p=4096;function m(w){const f=w.length;if(f<=p)return String.fromCharCode.apply(String,w);let d="",B=0;for(;B<f;)d+=String.fromCharCode.apply(String,w.slice(B,B+=p));return d}function R(w,f,d){let B="";d=Math.min(w.length,d);for(let F=f;F<d;++F)B+=String.fromCharCode(w[F]&127);return B}function _(w,f,d){let B="";d=Math.min(w.length,d);for(let F=f;F<d;++F)B+=String.fromCharCode(w[F]);return B}function I(w,f,d){const B=w.length;(!f||f<0)&&(f=0),(!d||d<0||d>B)&&(d=B);let F="";for(let $=f;$<d;++$)F+=Se[w[$]];return F}function U(w,f,d){const B=w.slice(f,d);let F="";for(let $=0;$<B.length-1;$+=2)F+=String.fromCharCode(B[$]+B[$+1]*256);return F}a.prototype.slice=function(f,d){const B=this.length;f=~~f,d=d===void 0?B:~~d,f<0?(f+=B,f<0&&(f=0)):f>B&&(f=B),d<0?(d+=B,d<0&&(d=0)):d>B&&(d=B),d<f&&(d=f);const F=this.subarray(f,d);return Object.setPrototypeOf(F,a.prototype),F};function k(w,f,d){if(w%1!==0||w<0)throw new RangeError("offset is not uint");if(w+f>d)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=this[f],$=1,Z=0;for(;++Z<d&&($*=256);)F+=this[f+Z]*$;return F},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=this[f+--d],$=1;for(;d>0&&($*=256);)F+=this[f+--d]*$;return F},a.prototype.readUint8=a.prototype.readUInt8=function(f,d){return f=f>>>0,d||k(f,1,this.length),this[f]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(f,d){return f=f>>>0,d||k(f,2,this.length),this[f]|this[f+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(f,d){return f=f>>>0,d||k(f,2,this.length),this[f]<<8|this[f+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(f,d){return f=f>>>0,d||k(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(f,d){return f=f>>>0,d||k(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},a.prototype.readBigUInt64LE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=d+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,$=this[++f]+this[++f]*2**8+this[++f]*2**16+B*2**24;return BigInt(F)+(BigInt($)<<BigInt(32))}),a.prototype.readBigUInt64BE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=d*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],$=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+B;return(BigInt(F)<<BigInt(32))+BigInt($)}),a.prototype.readIntLE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=this[f],$=1,Z=0;for(;++Z<d&&($*=256);)F+=this[f+Z]*$;return $*=128,F>=$&&(F-=Math.pow(2,8*d)),F},a.prototype.readIntBE=function(f,d,B){f=f>>>0,d=d>>>0,B||k(f,d,this.length);let F=d,$=1,Z=this[f+--F];for(;F>0&&($*=256);)Z+=this[f+--F]*$;return $*=128,Z>=$&&(Z-=Math.pow(2,8*d)),Z},a.prototype.readInt8=function(f,d){return f=f>>>0,d||k(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,d){f=f>>>0,d||k(f,2,this.length);const B=this[f]|this[f+1]<<8;return B&32768?B|4294901760:B},a.prototype.readInt16BE=function(f,d){f=f>>>0,d||k(f,2,this.length);const B=this[f+1]|this[f]<<8;return B&32768?B|4294901760:B},a.prototype.readInt32LE=function(f,d){return f=f>>>0,d||k(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},a.prototype.readInt32BE=function(f,d){return f=f>>>0,d||k(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},a.prototype.readBigInt64LE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(B<<24);return(BigInt(F)<<BigInt(32))+BigInt(d+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24)}),a.prototype.readBigInt64BE=fr(function(f){f=f>>>0,le(f,"offset");const d=this[f],B=this[f+7];(d===void 0||B===void 0)&&re(f,this.length-8);const F=(d<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(F)<<BigInt(32))+BigInt(this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+B)}),a.prototype.readFloatLE=function(f,d){return f=f>>>0,d||k(f,4,this.length),e.read(this,f,!0,23,4)},a.prototype.readFloatBE=function(f,d){return f=f>>>0,d||k(f,4,this.length),e.read(this,f,!1,23,4)},a.prototype.readDoubleLE=function(f,d){return f=f>>>0,d||k(f,8,this.length),e.read(this,f,!0,52,8)},a.prototype.readDoubleBE=function(f,d){return f=f>>>0,d||k(f,8,this.length),e.read(this,f,!1,52,8)};function h(w,f,d,B,F,$){if(!a.isBuffer(w))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>F||f<$)throw new RangeError('"value" argument is out of bounds');if(d+B>w.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,d,B,F){if(f=+f,d=d>>>0,B=B>>>0,!F){const Ht=Math.pow(2,8*B)-1;h(this,f,d,B,Ht,0)}let $=1,Z=0;for(this[d]=f&255;++Z<B&&($*=256);)this[d+Z]=f/$&255;return d+B},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,d,B,F){if(f=+f,d=d>>>0,B=B>>>0,!F){const Ht=Math.pow(2,8*B)-1;h(this,f,d,B,Ht,0)}let $=B-1,Z=1;for(this[d+$]=f&255;--$>=0&&(Z*=256);)this[d+$]=f/Z&255;return d+B},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,1,255,0),this[d]=f&255,d+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,65535,0),this[d]=f&255,this[d+1]=f>>>8,d+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,65535,0),this[d]=f>>>8,this[d+1]=f&255,d+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,4294967295,0),this[d+3]=f>>>24,this[d+2]=f>>>16,this[d+1]=f>>>8,this[d]=f&255,d+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,4294967295,0),this[d]=f>>>24,this[d+1]=f>>>16,this[d+2]=f>>>8,this[d+3]=f&255,d+4};function A(w,f,d,B,F){Gt(f,B,F,w,d,7);let $=Number(f&BigInt(4294967295));w[d++]=$,$=$>>8,w[d++]=$,$=$>>8,w[d++]=$,$=$>>8,w[d++]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return w[d++]=Z,Z=Z>>8,w[d++]=Z,Z=Z>>8,w[d++]=Z,Z=Z>>8,w[d++]=Z,d}function at(w,f,d,B,F){Gt(f,B,F,w,d,7);let $=Number(f&BigInt(4294967295));w[d+7]=$,$=$>>8,w[d+6]=$,$=$>>8,w[d+5]=$,$=$>>8,w[d+4]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return w[d+3]=Z,Z=Z>>8,w[d+2]=Z,Z=Z>>8,w[d+1]=Z,Z=Z>>8,w[d]=Z,d+8}a.prototype.writeBigUInt64LE=fr(function(f,d=0){return A(this,f,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=fr(function(f,d=0){return at(this,f,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(f,d,B,F){if(f=+f,d=d>>>0,!F){const zt=Math.pow(2,8*B-1);h(this,f,d,B,zt-1,-zt)}let $=0,Z=1,Ht=0;for(this[d]=f&255;++$<B&&(Z*=256);)f<0&&Ht===0&&this[d+$-1]!==0&&(Ht=1),this[d+$]=(f/Z>>0)-Ht&255;return d+B},a.prototype.writeIntBE=function(f,d,B,F){if(f=+f,d=d>>>0,!F){const zt=Math.pow(2,8*B-1);h(this,f,d,B,zt-1,-zt)}let $=B-1,Z=1,Ht=0;for(this[d+$]=f&255;--$>=0&&(Z*=256);)f<0&&Ht===0&&this[d+$+1]!==0&&(Ht=1),this[d+$]=(f/Z>>0)-Ht&255;return d+B},a.prototype.writeInt8=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,1,127,-128),f<0&&(f=255+f+1),this[d]=f&255,d+1},a.prototype.writeInt16LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,32767,-32768),this[d]=f&255,this[d+1]=f>>>8,d+2},a.prototype.writeInt16BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,2,32767,-32768),this[d]=f>>>8,this[d+1]=f&255,d+2},a.prototype.writeInt32LE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,2147483647,-2147483648),this[d]=f&255,this[d+1]=f>>>8,this[d+2]=f>>>16,this[d+3]=f>>>24,d+4},a.prototype.writeInt32BE=function(f,d,B){return f=+f,d=d>>>0,B||h(this,f,d,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[d]=f>>>24,this[d+1]=f>>>16,this[d+2]=f>>>8,this[d+3]=f&255,d+4},a.prototype.writeBigInt64LE=fr(function(f,d=0){return A(this,f,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=fr(function(f,d=0){return at(this,f,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function H(w,f,d,B,F,$){if(d+B>w.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function ct(w,f,d,B,F){return f=+f,d=d>>>0,F||H(w,f,d,4),e.write(w,f,d,B,23,4),d+4}a.prototype.writeFloatLE=function(f,d,B){return ct(this,f,d,!0,B)},a.prototype.writeFloatBE=function(f,d,B){return ct(this,f,d,!1,B)};function Tt(w,f,d,B,F){return f=+f,d=d>>>0,F||H(w,f,d,8),e.write(w,f,d,B,52,8),d+8}a.prototype.writeDoubleLE=function(f,d,B){return Tt(this,f,d,!0,B)},a.prototype.writeDoubleBE=function(f,d,B){return Tt(this,f,d,!1,B)},a.prototype.copy=function(f,d,B,F){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(B||(B=0),!F&&F!==0&&(F=this.length),d>=f.length&&(d=f.length),d||(d=0),F>0&&F<B&&(F=B),F===B||f.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(B<0||B>=this.length)throw new RangeError("Index out of range");if(F<0)throw new RangeError("sourceEnd out of bounds");F>this.length&&(F=this.length),f.length-d<F-B&&(F=f.length-d+B);const $=F-B;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,B,F):Uint8Array.prototype.set.call(f,this.subarray(B,F),d),$},a.prototype.fill=function(f,d,B,F){if(typeof f=="string"){if(typeof d=="string"?(F=d,d=0,B=this.length):typeof B=="string"&&(F=B,B=this.length),F!==void 0&&typeof F!="string")throw new TypeError("encoding must be a string");if(typeof F=="string"&&!a.isEncoding(F))throw new TypeError("Unknown encoding: "+F);if(f.length===1){const Z=f.charCodeAt(0);(F==="utf8"&&Z<128||F==="latin1")&&(f=Z)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(d<0||this.length<d||this.length<B)throw new RangeError("Out of range index");if(B<=d)return this;d=d>>>0,B=B===void 0?this.length:B>>>0,f||(f=0);let $;if(typeof f=="number")for($=d;$<B;++$)this[$]=f;else{const Z=a.isBuffer(f)?f:a.from(f,F),Ht=Z.length;if(Ht===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for($=0;$<B-d;++$)this[$+d]=Z[$%Ht]}return this};const Mt={};function Pt(w,f,d){Mt[w]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${w}]`,this.stack,delete this.name}get code(){return w}set code(F){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:F,writable:!0})}toString(){return`${this.name} [${w}]: ${this.message}`}}}Pt("ERR_BUFFER_OUT_OF_BOUNDS",function(w){return w?`${w} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Pt("ERR_INVALID_ARG_TYPE",function(w,f){return`The "${w}" argument must be of type number. Received type ${typeof f}`},TypeError),Pt("ERR_OUT_OF_RANGE",function(w,f,d){let B=`The value of "${w}" is out of range.`,F=d;return Number.isInteger(d)&&Math.abs(d)>2**32?F=Ce(String(d)):typeof d=="bigint"&&(F=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(F=Ce(F)),F+="n"),B+=` It must be ${f}. Received ${F}`,B},RangeError);function Ce(w){let f="",d=w.length;const B=w[0]==="-"?1:0;for(;d>=B+4;d-=3)f=`_${w.slice(d-3,d)}${f}`;return`${w.slice(0,d)}${f}`}function Yt(w,f,d){le(f,"offset"),(w[f]===void 0||w[f+d]===void 0)&&re(f,w.length-(d+1))}function Gt(w,f,d,B,F,$){if(w>d||w<f){const Z=typeof f=="bigint"?"n":"";let Ht;throw f===0||f===BigInt(0)?Ht=`>= 0${Z} and < 2${Z} ** ${($+1)*8}${Z}`:Ht=`>= -(2${Z} ** ${($+1)*8-1}${Z}) and < 2 ** ${($+1)*8-1}${Z}`,new Mt.ERR_OUT_OF_RANGE("value",Ht,w)}Yt(B,F,$)}function le(w,f){if(typeof w!="number")throw new Mt.ERR_INVALID_ARG_TYPE(f,"number",w)}function re(w,f,d){throw Math.floor(w)!==w?(le(w,d),new Mt.ERR_OUT_OF_RANGE("offset","an integer",w)):f<0?new Mt.ERR_BUFFER_OUT_OF_BOUNDS:new Mt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,w)}const ve=/[^+/0-9A-Za-z-_]/g;function Or(w){if(w=w.split("=")[0],w=w.trim().replace(ve,""),w.length<2)return"";for(;w.length%4!==0;)w=w+"=";return w}function _e(w,f){f=f||1/0;let d;const B=w.length;let F=null;const $=[];for(let Z=0;Z<B;++Z){if(d=w.charCodeAt(Z),d>55295&&d<57344){if(!F){if(d>56319){(f-=3)>-1&&$.push(239,191,189);continue}else if(Z+1===B){(f-=3)>-1&&$.push(239,191,189);continue}F=d;continue}if(d<56320){(f-=3)>-1&&$.push(239,191,189),F=d;continue}d=(F-55296<<10|d-56320)+65536}else F&&(f-=3)>-1&&$.push(239,191,189);if(F=null,d<128){if((f-=1)<0)break;$.push(d)}else if(d<2048){if((f-=2)<0)break;$.push(d>>6|192,d&63|128)}else if(d<65536){if((f-=3)<0)break;$.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((f-=4)<0)break;$.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return $}function Oe(w){const f=[];for(let d=0;d<w.length;++d)f.push(w.charCodeAt(d)&255);return f}function Ar(w,f){let d,B,F;const $=[];for(let Z=0;Z<w.length&&!((f-=2)<0);++Z)d=w.charCodeAt(Z),B=d>>8,F=d%256,$.push(F),$.push(B);return $}function Ie(w){return t.toByteArray(Or(w))}function Ae(w,f,d,B){let F;for(F=0;F<B&&!(F+d>=f.length||F>=w.length);++F)f[F+d]=w[F];return F}function rr(w,f){return w instanceof f||w!=null&&w.constructor!=null&&w.constructor.name!=null&&w.constructor.name===f.name}function ke(w){return w!==w}const Se=function(){const w="0123456789abcdef",f=new Array(256);for(let d=0;d<16;++d){const B=d*16;for(let F=0;F<16;++F)f[B+F]=w[d]+w[F]}return f}();function fr(w){return typeof BigInt>"u"?Be:w}function Be(){throw new Error("BigInt not supported")}})(Ct);function Ei(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`positive integer expected, not ${n}`)}function cu(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function ii(n,...t){if(!cu(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${n.length}`)}function uu(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ei(n.outputLen),Ei(n.blockLen)}function Fn(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 Mo(n,t){ii(n);const e=t.outputLen;if(n.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const ls=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fu=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),hs=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Hr=(n,t)=>n<<32-t|n>>>t,Po=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,lu=n=>n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255;function Co(n){for(let t=0;t<n.length;t++)n[t]=lu(n[t])}function hu(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function _i(n){return typeof n=="string"&&(n=hu(n)),ii(n),n}function du(...n){let t=0;for(let r=0;r<n.length;r++){const s=n[r];ii(s),t+=s.length}const e=new Uint8Array(t);for(let r=0,s=0;r<n.length;r++){const i=n[r];e.set(i,s),s+=i.length}return e}class ds{clone(){return this._cloneInto()}}function ps(n){const t=r=>n().update(_i(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function Lo(n=32){if(ls&&typeof ls.getRandomValues=="function")return ls.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}function pu(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(e>>s&i),a=Number(e&i),l=r?4:0,y=r?0:4;n.setUint32(t+l,o,r),n.setUint32(t+y,a,r)}const gu=(n,t,e)=>n&t^~n&e,yu=(n,t,e)=>n&t^n&e^t&e;class Uo extends ds{constructor(t,e,r,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=hs(this.buffer)}update(t){Fn(this);const{view:e,buffer:r,blockLen:s}=this;t=_i(t);const i=t.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const l=hs(t);for(;s<=i-o;o+=s)this.process(l,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Fn(this),Mo(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let E=o;E<s;E++)e[E]=0;pu(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=hs(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const y=l/4,x=this.get();if(y>x.length)throw new Error("_sha2: outputLen bigger than state");for(let E=0;E<y;E++)a.setUint32(4*E,x[E],i)}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:s,finished:i,destroyed:o,pos:a}=this;return t.length=s,t.pos=a,t.finished=i,t.destroyed=o,s%e&&t.buffer.set(r),t}}const Ii=BigInt(2**32-1),gs=BigInt(32);function Oo(n,t=!1){return t?{h:Number(n&Ii),l:Number(n>>gs&Ii)}:{h:Number(n>>gs&Ii)|0,l:Number(n&Ii)|0}}function No(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=Oo(n[s],t);[e[s],r[s]]=[i,o]}return[e,r]}const mu=(n,t)=>BigInt(n>>>0)<<gs|BigInt(t>>>0),wu=(n,t,e)=>n>>>e,bu=(n,t,e)=>n<<32-e|t>>>e,xu=(n,t,e)=>n>>>e|t<<32-e,vu=(n,t,e)=>n<<32-e|t>>>e,ku=(n,t,e)=>n<<64-e|t>>>e-32,Su=(n,t,e)=>n>>>e-32|t<<64-e,Eu=(n,t)=>t,_u=(n,t)=>n,Fo=(n,t,e)=>n<<e|t>>>32-e,zo=(n,t,e)=>t<<e|n>>>32-e,Ko=(n,t,e)=>t<<e-32|n>>>64-e,Wo=(n,t,e)=>n<<e-32|t>>>64-e;function Iu(n,t,e,r){const s=(t>>>0)+(r>>>0);return{h:n+e+(s/2**32|0)|0,l:s|0}}const Qt={fromBig:Oo,split:No,toBig:mu,shrSH:wu,shrSL:bu,rotrSH:xu,rotrSL:vu,rotrBH:ku,rotrBL:Su,rotr32H:Eu,rotr32L:_u,rotlSH:Fo,rotlSL:zo,rotlBH:Ko,rotlBL:Wo,add:Iu,add3L:(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),add3H:(n,t,e,r)=>t+e+r+(n/2**32|0)|0,add4L:(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),add4H:(n,t,e,r,s)=>t+e+r+s+(n/2**32|0)|0,add5H:(n,t,e,r,s,i)=>t+e+r+s+i+(n/2**32|0)|0,add5L:(n,t,e,r,s)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(s>>>0)},[Au,Bu]=Qt.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))),un=new Uint32Array(80),fn=new Uint32Array(80);class Ru extends Uo{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:s,Ch:i,Cl:o,Dh:a,Dl:l,Eh:y,El:x,Fh:E,Fl:L,Gh:C,Gl:N,Hh:M,Hl:O}=this;return[t,e,r,s,i,o,a,l,y,x,E,L,C,N,M,O]}set(t,e,r,s,i,o,a,l,y,x,E,L,C,N,M,O){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=l|0,this.Eh=y|0,this.El=x|0,this.Fh=E|0,this.Fl=L|0,this.Gh=C|0,this.Gl=N|0,this.Hh=M|0,this.Hl=O|0}process(t,e){for(let j=0;j<16;j++,e+=4)un[j]=t.getUint32(e),fn[j]=t.getUint32(e+=4);for(let j=16;j<80;j++){const it=un[j-15]|0,J=fn[j-15]|0,D=Qt.rotrSH(it,J,1)^Qt.rotrSH(it,J,8)^Qt.shrSH(it,J,7),tt=Qt.rotrSL(it,J,1)^Qt.rotrSL(it,J,8)^Qt.shrSL(it,J,7),rt=un[j-2]|0,ue=fn[j-2]|0,jt=Qt.rotrSH(rt,ue,19)^Qt.rotrBH(rt,ue,61)^Qt.shrSH(rt,ue,6),kt=Qt.rotrSL(rt,ue,19)^Qt.rotrBL(rt,ue,61)^Qt.shrSL(rt,ue,6),ce=Qt.add4L(tt,kt,fn[j-7],fn[j-16]),T=Qt.add4H(ce,D,jt,un[j-7],un[j-16]);un[j]=T|0,fn[j]=ce|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:l,Dh:y,Dl:x,Eh:E,El:L,Fh:C,Fl:N,Gh:M,Gl:O,Hh:K,Hl:Q}=this;for(let j=0;j<80;j++){const it=Qt.rotrSH(E,L,14)^Qt.rotrSH(E,L,18)^Qt.rotrBH(E,L,41),J=Qt.rotrSL(E,L,14)^Qt.rotrSL(E,L,18)^Qt.rotrBL(E,L,41),D=E&C^~E&M,tt=L&N^~L&O,rt=Qt.add5L(Q,J,tt,Bu[j],fn[j]),ue=Qt.add5H(rt,K,it,D,Au[j],un[j]),jt=rt|0,kt=Qt.rotrSH(r,s,28)^Qt.rotrBH(r,s,34)^Qt.rotrBH(r,s,39),ce=Qt.rotrSL(r,s,28)^Qt.rotrBL(r,s,34)^Qt.rotrBL(r,s,39),T=r&i^r&a^i&a,u=s&o^s&l^o&l;K=M|0,Q=O|0,M=C|0,O=N|0,C=E|0,N=L|0,{h:E,l:L}=Qt.add(y|0,x|0,ue|0,jt|0),y=a|0,x=l|0,a=i|0,l=o|0,i=r|0,o=s|0;const p=Qt.add3L(jt,ce,u);r=Qt.add3H(p,ue,kt,T),s=p|0}({h:r,l:s}=Qt.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=Qt.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l}=Qt.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:y,l:x}=Qt.add(this.Dh|0,this.Dl|0,y|0,x|0),{h:E,l:L}=Qt.add(this.Eh|0,this.El|0,E|0,L|0),{h:C,l:N}=Qt.add(this.Fh|0,this.Fl|0,C|0,N|0),{h:M,l:O}=Qt.add(this.Gh|0,this.Gl|0,M|0,O|0),{h:K,l:Q}=Qt.add(this.Hh|0,this.Hl|0,K|0,Q|0),this.set(r,s,i,o,a,l,y,x,E,L,C,N,M,O,K,Q)}roundClean(){un.fill(0),fn.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 Tu=ps(()=>new Ru);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Do=BigInt(0),Ai=BigInt(1),Mu=BigInt(2);function bn(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function si(n){if(!bn(n))throw new Error("Uint8Array expected")}const Pu=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function xn(n){si(n);let t="";for(let e=0;e<n.length;e++)t+=Pu[n[e]];return t}function $o(n){const t=n.toString(16);return t.length&1?`0${t}`:t}function ys(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}const rn={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qo(n){if(n>=rn._0&&n<=rn._9)return n-rn._0;if(n>=rn._A&&n<=rn._F)return n-(rn._A-10);if(n>=rn._a&&n<=rn._f)return n-(rn._a-10)}function zn(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("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(e);for(let s=0,i=0;s<e;s++,i+=2){const o=qo(n.charCodeAt(i)),a=qo(n.charCodeAt(i+1));if(o===void 0||a===void 0){const l=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+i)}r[s]=o*16+a}return r}function vn(n){return ys(xn(n))}function Kn(n){return si(n),ys(xn(Uint8Array.from(n).reverse()))}function Wn(n,t){return zn(n.toString(16).padStart(t*2,"0"))}function oi(n,t){return Wn(n,t).reverse()}function Cu(n){return zn($o(n))}function ir(n,t,e){let r;if(typeof t=="string")try{r=zn(t)}catch(i){throw new Error(`${n} must be valid hex string, got "${t}". Cause: ${i}`)}else if(bn(t))r=Uint8Array.from(t);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof e=="number"&&s!==e)throw new Error(`${n} expected ${e} bytes, got ${s}`);return r}function kn(...n){let t=0;for(let r=0;r<n.length;r++){const s=n[r];si(s),t+=s.length}const e=new Uint8Array(t);for(let r=0,s=0;r<n.length;r++){const i=n[r];e.set(i,s),s+=i.length}return e}function Lu(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 Uu(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Ou(n){let t;for(t=0;n>Do;n>>=Ai,t+=1);return t}function Nu(n,t){return n>>BigInt(t)&Ai}function Fu(n,t,e){return n|(e?Ai:Do)<<BigInt(t)}const ms=n=>(Mu<<BigInt(n-1))-Ai,ws=n=>new Uint8Array(n),Ho=n=>Uint8Array.from(n);function Vo(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=ws(n),s=ws(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...E)=>e(s,r,...E),l=(E=ws())=>{s=a(Ho([0]),E),r=a(),E.length!==0&&(s=a(Ho([1]),E),r=a())},y=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let E=0;const L=[];for(;E<t;){r=a();const C=r.slice();L.push(C),E+=r.length}return kn(...L)};return(E,L)=>{o(),l(E);let C;for(;!(C=L(y()));)l();return o(),C}}const zu={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"||bn(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 Dn(n,t,e={}){const r=(s,i,o)=>{const a=zu[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const l=n[s];if(!(o&&l===void 0)&&!a(l,n))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${i}`)};for(const[s,i]of Object.entries(t))r(s,i,!1);for(const[s,i]of Object.entries(e))r(s,i,!0);return n}const Ku=Object.freeze(Object.defineProperty({__proto__:null,abytes:si,bitGet:Nu,bitLen:Ou,bitMask:ms,bitSet:Fu,bytesToHex:xn,bytesToNumberBE:vn,bytesToNumberLE:Kn,concatBytes:kn,createHmacDrbg:Vo,ensureBytes:ir,equalBytes:Lu,hexToBytes:zn,hexToNumber:ys,isBytes:bn,numberToBytesBE:Wn,numberToBytesLE:oi,numberToHexUnpadded:$o,numberToVarBytesBE:Cu,utf8ToBytes:Uu,validateObject:Dn},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const or=BigInt(0),qe=BigInt(1),Sn=BigInt(2),Wu=BigInt(3),bs=BigInt(4),jo=BigInt(5),Go=BigInt(8);BigInt(9),BigInt(16);function We(n,t){const e=n%t;return e>=or?e:t+e}function Du(n,t,e){if(e<=or||t<or)throw new Error("Expected power/modulo > 0");if(e===qe)return or;let r=qe;for(;t>or;)t&qe&&(r=r*n%e),n=n*n%e,t>>=qe;return r}function Ge(n,t,e){let r=n;for(;t-- >or;)r*=r,r%=e;return r}function xs(n,t){if(n===or||t<=or)throw new Error(`invert: expected positive integers, got n=${n} mod=${t}`);let e=We(n,t),r=t,s=or,i=qe;for(;e!==or;){const a=r/e,l=r%e,y=s-i*a;r=e,e=l,s=i,i=y}if(r!==qe)throw new Error("invert: does not exist");return We(s,t)}function $u(n){const t=(n-qe)/Sn;let e,r,s;for(e=n-qe,r=0;e%Sn===or;e/=Sn,r++);for(s=Sn;s<n&&Du(s,t,n)!==n-qe;s++);if(r===1){const o=(n+qe)/bs;return function(l,y){const x=l.pow(y,o);if(!l.eql(l.sqr(x),y))throw new Error("Cannot find square root");return x}}const i=(e+qe)/Sn;return function(a,l){if(a.pow(l,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let y=r,x=a.pow(a.mul(a.ONE,s),e),E=a.pow(l,i),L=a.pow(l,e);for(;!a.eql(L,a.ONE);){if(a.eql(L,a.ZERO))return a.ZERO;let C=1;for(let M=a.sqr(L);C<y&&!a.eql(M,a.ONE);C++)M=a.sqr(M);const N=a.pow(x,qe<<BigInt(y-C-1));x=a.sqr(N),E=a.mul(E,N),L=a.mul(L,x),y=C}return E}}function qu(n){if(n%bs===Wu){const t=(n+qe)/bs;return function(r,s){const i=r.pow(s,t);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%Go===jo){const t=(n-jo)/Go;return function(r,s){const i=r.mul(s,Sn),o=r.pow(i,t),a=r.mul(s,o),l=r.mul(r.mul(a,Sn),o),y=r.mul(a,r.sub(l,r.ONE));if(!r.eql(r.sqr(y),s))throw new Error("Cannot find square root");return y}}return $u(n)}const Hu=(n,t)=>(We(n,t)&qe)===qe,Vu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ju(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Vu.reduce((r,s)=>(r[s]="function",r),t);return Dn(n,e)}function Gu(n,t,e){if(e<or)throw new Error("Expected power > 0");if(e===or)return n.ONE;if(e===qe)return t;let r=n.ONE,s=t;for(;e>or;)e&qe&&(r=n.mul(r,s)),s=n.sqr(s),e>>=qe;return r}function Yu(n,t){const e=new Array(t.length),r=t.reduce((i,o,a)=>n.is0(o)?i:(e[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return t.reduceRight((i,o,a)=>n.is0(o)?i:(e[a]=n.mul(i,e[a]),n.mul(i,o)),s),e}function Yo(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function Zo(n,t,e=!1,r={}){if(n<=or)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=Yo(n,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=qu(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:ms(s),ZERO:or,ONE:qe,create:l=>We(l,n),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return or<=l&&l<n},is0:l=>l===or,isOdd:l=>(l&qe)===qe,neg:l=>We(-l,n),eql:(l,y)=>l===y,sqr:l=>We(l*l,n),add:(l,y)=>We(l+y,n),sub:(l,y)=>We(l-y,n),mul:(l,y)=>We(l*y,n),pow:(l,y)=>Gu(a,l,y),div:(l,y)=>We(l*xs(y,n),n),sqrN:l=>l*l,addN:(l,y)=>l+y,subN:(l,y)=>l-y,mulN:(l,y)=>l*y,inv:l=>xs(l,n),sqrt:r.sqrt||(l=>o(a,l)),invertBatch:l=>Yu(a,l),cmov:(l,y,x)=>x?y:l,toBytes:l=>e?oi(l,i):Wn(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return e?Kn(l):vn(l)}});return Object.freeze(a)}function Jo(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 Xo(n){const t=Jo(n);return t+Math.ceil(t/2)}function Zu(n,t,e=!1){const r=n.length,s=Jo(t),i=Xo(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=e?vn(n):Kn(n),a=We(o,t-qe)+qe;return e?oi(a,s):Wn(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ju=BigInt(0),vs=BigInt(1);function Qo(n,t){const e=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(t/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:e,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>Ju;)i&vs&&(o=o.add(a)),a=a.double(),i>>=vs;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),l=[];let y=s,x=y;for(let E=0;E<o;E++){x=y,l.push(x);for(let L=1;L<a;L++)x=x.add(y),l.push(x);y=x.double()}return l},wNAF(s,i,o){const{windows:a,windowSize:l}=r(s);let y=n.ZERO,x=n.BASE;const E=BigInt(2**s-1),L=2**s,C=BigInt(s);for(let N=0;N<a;N++){const M=N*l;let O=Number(o&E);o>>=C,O>l&&(O-=L,o+=vs);const K=M,Q=M+Math.abs(O)-1,j=N%2!==0,it=O<0;O===0?x=x.add(e(j,i[K])):y=y.add(e(it,i[Q]))}return{p:y,f:x}},wNAFCached(s,i,o,a){const l=s._WINDOW_SIZE||1;let y=i.get(s);return y||(y=this.precomputeWindow(s,l),l!==1&&i.set(s,a(y))),this.wNAF(l,y,o)}}}function ks(n){return ju(n.Fp),Dn(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Yo(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fr=BigInt(0),Br=BigInt(1),Bi=BigInt(2),Xu=BigInt(8),Qu={zip215:!0};function tf(n){const t=ks(n);return Dn(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function ef(n){const t=tf(n),{Fp:e,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:l}=t,y=Bi<<BigInt(a*8)-Br,x=e.create,E=t.uvRatio||((_,I)=>{try{return{isValid:!0,value:e.sqrt(_*e.inv(I))}}catch{return{isValid:!1,value:Fr}}}),L=t.adjustScalarBytes||(_=>_),C=t.domain||((_,I,U)=>{if(I.length||U)throw new Error("Contexts/pre-hash are not supported");return _}),N=_=>typeof _=="bigint"&&Fr<_,M=(_,I)=>N(_)&&N(I)&&_<I,O=_=>_===Fr||M(_,y);function K(_,I){if(M(_,I))return _;throw new Error(`Expected valid scalar < ${I}, got ${typeof _} ${_}`)}function Q(_){return _===Fr?_:K(_,r)}const j=new Map;function it(_){if(!(_ instanceof J))throw new Error("ExtendedPoint expected")}class J{constructor(I,U,k,h){if(this.ex=I,this.ey=U,this.ez=k,this.et=h,!O(I))throw new Error("x required");if(!O(U))throw new Error("y required");if(!O(k))throw new Error("z required");if(!O(h))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof J)throw new Error("extended point not allowed");const{x:U,y:k}=I||{};if(!O(U)||!O(k))throw new Error("invalid affine point");return new J(U,k,Br,x(U*k))}static normalizeZ(I){const U=e.invertBatch(I.map(k=>k.ez));return I.map((k,h)=>k.toAffine(U[h])).map(J.fromAffine)}_setWindowSize(I){this._WINDOW_SIZE=I,j.delete(this)}assertValidity(){const{a:I,d:U}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:k,ey:h,ez:A,et:at}=this,H=x(k*k),ct=x(h*h),Tt=x(A*A),Mt=x(Tt*Tt),Pt=x(H*I),Ce=x(Tt*x(Pt+ct)),Yt=x(Mt+x(U*x(H*ct)));if(Ce!==Yt)throw new Error("bad point: equation left != right (1)");const Gt=x(k*h),le=x(A*at);if(Gt!==le)throw new Error("bad point: equation left != right (2)")}equals(I){it(I);const{ex:U,ey:k,ez:h}=this,{ex:A,ey:at,ez:H}=I,ct=x(U*H),Tt=x(A*h),Mt=x(k*H),Pt=x(at*h);return ct===Tt&&Mt===Pt}is0(){return this.equals(J.ZERO)}negate(){return new J(x(-this.ex),this.ey,this.ez,x(-this.et))}double(){const{a:I}=t,{ex:U,ey:k,ez:h}=this,A=x(U*U),at=x(k*k),H=x(Bi*x(h*h)),ct=x(I*A),Tt=U+k,Mt=x(x(Tt*Tt)-A-at),Pt=ct+at,Ce=Pt-H,Yt=ct-at,Gt=x(Mt*Ce),le=x(Pt*Yt),re=x(Mt*Yt),ve=x(Ce*Pt);return new J(Gt,le,ve,re)}add(I){it(I);const{a:U,d:k}=t,{ex:h,ey:A,ez:at,et:H}=this,{ex:ct,ey:Tt,ez:Mt,et:Pt}=I;if(U===BigInt(-1)){const rr=x((A-h)*(Tt+ct)),ke=x((A+h)*(Tt-ct)),Se=x(ke-rr);if(Se===Fr)return this.double();const fr=x(at*Bi*Pt),Be=x(H*Bi*Mt),w=Be+fr,f=ke+rr,d=Be-fr,B=x(w*Se),F=x(f*d),$=x(w*d),Z=x(Se*f);return new J(B,F,Z,$)}const Ce=x(h*ct),Yt=x(A*Tt),Gt=x(H*k*Pt),le=x(at*Mt),re=x((h+A)*(ct+Tt)-Ce-Yt),ve=le-Gt,Or=le+Gt,_e=x(Yt-U*Ce),Oe=x(re*ve),Ar=x(Or*_e),Ie=x(re*_e),Ae=x(ve*Or);return new J(Oe,Ar,Ae,Ie)}subtract(I){return this.add(I.negate())}wNAF(I){return rt.wNAFCached(this,j,I,J.normalizeZ)}multiply(I){const{p:U,f:k}=this.wNAF(K(I,r));return J.normalizeZ([U,k])[0]}multiplyUnsafe(I){let U=Q(I);return U===Fr?tt:this.equals(tt)||U===Br?this:this.equals(D)?this.wNAF(U).p:rt.unsafeLadder(this,U)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return rt.unsafeLadder(this,r).is0()}toAffine(I){const{ex:U,ey:k,ez:h}=this,A=this.is0();I==null&&(I=A?Xu:e.inv(h));const at=x(U*I),H=x(k*I),ct=x(h*I);if(A)return{x:Fr,y:Br};if(ct!==Br)throw new Error("invZ was invalid");return{x:at,y:H}}clearCofactor(){const{h:I}=t;return I===Br?this:this.multiplyUnsafe(I)}static fromHex(I,U=!1){const{d:k,a:h}=t,A=e.BYTES;I=ir("pointHex",I,A);const at=I.slice(),H=I[A-1];at[A-1]=H&-129;const ct=Kn(at);ct===Fr||(U?K(ct,y):K(ct,e.ORDER));const Tt=x(ct*ct),Mt=x(Tt-Br),Pt=x(k*Tt-h);let{isValid:Ce,value:Yt}=E(Mt,Pt);if(!Ce)throw new Error("Point.fromHex: invalid y coordinate");const Gt=(Yt&Br)===Br,le=(H&128)!==0;if(!U&&Yt===Fr&&le)throw new Error("Point.fromHex: x=0 and x_0=1");return le!==Gt&&(Yt=x(-Yt)),J.fromAffine({x:Yt,y:ct})}static fromPrivateKey(I){return kt(I).point}toRawBytes(){const{x:I,y:U}=this.toAffine(),k=oi(U,e.BYTES);return k[k.length-1]|=I&Br?128:0,k}toHex(){return xn(this.toRawBytes())}}J.BASE=new J(t.Gx,t.Gy,Br,x(t.Gx*t.Gy)),J.ZERO=new J(Fr,Br,Br,Fr);const{BASE:D,ZERO:tt}=J,rt=Qo(J,a*8);function ue(_){return We(_,r)}function jt(_){return ue(Kn(_))}function kt(_){const I=a;_=ir("private key",_,I);const U=ir("hashed private key",i(_),2*I),k=L(U.slice(0,I)),h=U.slice(I,2*I),A=jt(k),at=D.multiply(A),H=at.toRawBytes();return{head:k,prefix:h,scalar:A,point:at,pointBytes:H}}function ce(_){return kt(_).pointBytes}function T(_=new Uint8Array,...I){const U=kn(...I);return jt(i(C(U,ir("context",_),!!s)))}function u(_,I,U={}){_=ir("message",_),s&&(_=s(_));const{prefix:k,scalar:h,pointBytes:A}=kt(I),at=T(U.context,k,_),H=D.multiply(at).toRawBytes(),ct=T(U.context,H,A,_),Tt=ue(at+ct*h);Q(Tt);const Mt=kn(H,oi(Tt,e.BYTES));return ir("result",Mt,a*2)}const p=Qu;function m(_,I,U,k=p){const{context:h,zip215:A}=k,at=e.BYTES;_=ir("signature",_,2*at),I=ir("message",I),s&&(I=s(I));const H=Kn(_.slice(at,2*at));let ct,Tt,Mt;try{ct=J.fromHex(U,A),Tt=J.fromHex(_.slice(0,at),A),Mt=D.multiplyUnsafe(H)}catch{return!1}if(!A&&ct.isSmallOrder())return!1;const Pt=T(h,Tt.toRawBytes(),ct.toRawBytes(),I);return Tt.add(ct.multiplyUnsafe(Pt)).subtract(Mt).clearCofactor().equals(J.ZERO)}return D._setWindowSize(8),{CURVE:t,getPublicKey:ce,sign:u,verify:m,ExtendedPoint:J,utils:{getExtendedPublicKey:kt,randomPrivateKey:()=>o(e.BYTES),precompute(_=8,I=J.BASE){return I._setWindowSize(_),I.multiply(BigInt(3)),I}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ss=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ta=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const rf=BigInt(1),ea=BigInt(2);BigInt(3);const nf=BigInt(5),sf=BigInt(8);function of(n){const t=BigInt(10),e=BigInt(20),r=BigInt(40),s=BigInt(80),i=Ss,a=n*n%i*n%i,l=Ge(a,ea,i)*a%i,y=Ge(l,rf,i)*n%i,x=Ge(y,nf,i)*y%i,E=Ge(x,t,i)*x%i,L=Ge(E,e,i)*E%i,C=Ge(L,r,i)*L%i,N=Ge(C,s,i)*C%i,M=Ge(N,s,i)*C%i,O=Ge(M,t,i)*x%i;return{pow_p_5_8:Ge(O,ea,i)*n%i,b2:a}}function af(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function cf(n,t){const e=Ss,r=We(t*t*t,e),s=We(r*r*t,e),i=of(n*s).pow_p_5_8;let o=We(n*r*i,e);const a=We(t*o*o,e),l=o,y=We(o*ta,e),x=a===n,E=a===We(-n,e),L=a===We(-n*ta,e);return x&&(o=l),(E||L)&&(o=y),Hu(o,e)&&(o=We(-o,e)),{isValid:x||E,value:o}}const uf=Zo(Ss,void 0,!0),ff={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:uf,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:sf,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Tu,randomBytes:Lo,adjustScalarBytes:af,uvRatio:cf},$n=ef(ff);var Es={exports:{}};const ra=cs(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));Es.exports,function(n){(function(t,e){function r(T,u){if(!T)throw new Error(u||"Assertion failed")}function s(T,u){T.super_=u;var p=function(){};p.prototype=u.prototype,T.prototype=new p,T.prototype.constructor=T}function i(T,u,p){if(i.isBN(T))return T;this.negative=0,this.words=null,this.length=0,this.red=null,T!==null&&((u==="le"||u==="be")&&(p=u,u=10),this._init(T||0,u||10,p||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=ra.Buffer}catch{}i.isBN=function(u){return u instanceof i?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===i.wordSize&&Array.isArray(u.words)},i.max=function(u,p){return u.cmp(p)>0?u:p},i.min=function(u,p){return u.cmp(p)<0?u:p},i.prototype._init=function(u,p,m){if(typeof u=="number")return this._initNumber(u,p,m);if(typeof u=="object")return this._initArray(u,p,m);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),u=u.toString().replace(/\s+/g,"");var R=0;u[0]==="-"&&(R++,this.negative=1),R<u.length&&(p===16?this._parseHex(u,R,m):(this._parseBase(u,p,R),m==="le"&&this._initArray(this.toArray(),p,m)))},i.prototype._initNumber=function(u,p,m){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(r(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),m==="le"&&this._initArray(this.toArray(),p,m)},i.prototype._initArray=function(u,p,m){if(r(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var R=0;R<this.length;R++)this.words[R]=0;var _,I,U=0;if(m==="be")for(R=u.length-1,_=0;R>=0;R-=3)I=u[R]|u[R-1]<<8|u[R-2]<<16,this.words[_]|=I<<U&67108863,this.words[_+1]=I>>>26-U&67108863,U+=24,U>=26&&(U-=26,_++);else if(m==="le")for(R=0,_=0;R<u.length;R+=3)I=u[R]|u[R+1]<<8|u[R+2]<<16,this.words[_]|=I<<U&67108863,this.words[_+1]=I>>>26-U&67108863,U+=24,U>=26&&(U-=26,_++);return this._strip()};function a(T,u){var p=T.charCodeAt(u);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+T)}function l(T,u,p){var m=a(T,p);return p-1>=u&&(m|=a(T,p-1)<<4),m}i.prototype._parseHex=function(u,p,m){this.length=Math.ceil((u.length-p)/6),this.words=new Array(this.length);for(var R=0;R<this.length;R++)this.words[R]=0;var _=0,I=0,U;if(m==="be")for(R=u.length-1;R>=p;R-=2)U=l(u,p,R)<<_,this.words[I]|=U&67108863,_>=18?(_-=18,I+=1,this.words[I]|=U>>>26):_+=8;else{var k=u.length-p;for(R=k%2===0?p+1:p;R<u.length;R+=2)U=l(u,p,R)<<_,this.words[I]|=U&67108863,_>=18?(_-=18,I+=1,this.words[I]|=U>>>26):_+=8}this._strip()};function y(T,u,p,m){for(var R=0,_=0,I=Math.min(T.length,p),U=u;U<I;U++){var k=T.charCodeAt(U)-48;R*=m,k>=49?_=k-49+10:k>=17?_=k-17+10:_=k,r(k>=0&&_<m,"Invalid character"),R+=_}return R}i.prototype._parseBase=function(u,p,m){this.words=[0],this.length=1;for(var R=0,_=1;_<=67108863;_*=p)R++;R--,_=_/p|0;for(var I=u.length-m,U=I%R,k=Math.min(I,I-U)+m,h=0,A=m;A<k;A+=R)h=y(u,A,A+R,p),this.imuln(_),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(U!==0){var at=1;for(h=y(u,A,u.length,p),A=0;A<U;A++)at*=p;this.imuln(at),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this._strip()},i.prototype.copy=function(u){u.words=new Array(this.length);for(var p=0;p<this.length;p++)u.words[p]=this.words[p];u.length=this.length,u.negative=this.negative,u.red=this.red};function x(T,u){T.words=u.words,T.length=u.length,T.negative=u.negative,T.red=u.red}if(i.prototype._move=function(u){x(u,this)},i.prototype.clone=function(){var u=new i(null);return this.copy(u),u},i.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=E}catch{i.prototype.inspect=E}else i.prototype.inspect=E;function E(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var L=["","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"],C=[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],N=[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];i.prototype.toString=function(u,p){u=u||10,p=p|0||1;var m;if(u===16||u==="hex"){m="";for(var R=0,_=0,I=0;I<this.length;I++){var U=this.words[I],k=((U<<R|_)&16777215).toString(16);_=U>>>24-R&16777215,R+=2,R>=26&&(R-=26,I--),_!==0||I!==this.length-1?m=L[6-k.length]+k+m:m=k+m}for(_!==0&&(m=_.toString(16)+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(u===(u|0)&&u>=2&&u<=36){var h=C[u],A=N[u];m="";var at=this.clone();for(at.negative=0;!at.isZero();){var H=at.modrn(A).toString(u);at=at.idivn(A),at.isZero()?m=H+m:m=L[h-H.length]+H+m}for(this.isZero()&&(m="0"+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(u,p){return this.toArrayLike(o,u,p)}),i.prototype.toArray=function(u,p){return this.toArrayLike(Array,u,p)};var M=function(u,p){return u.allocUnsafe?u.allocUnsafe(p):new u(p)};i.prototype.toArrayLike=function(u,p,m){this._strip();var R=this.byteLength(),_=m||Math.max(1,R);r(R<=_,"byte array longer than desired length"),r(_>0,"Requested array length <= 0");var I=M(u,_),U=p==="le"?"LE":"BE";return this["_toArrayLike"+U](I,R),I},i.prototype._toArrayLikeLE=function(u,p){for(var m=0,R=0,_=0,I=0;_<this.length;_++){var U=this.words[_]<<I|R;u[m++]=U&255,m<u.length&&(u[m++]=U>>8&255),m<u.length&&(u[m++]=U>>16&255),I===6?(m<u.length&&(u[m++]=U>>24&255),R=0,I=0):(R=U>>>24,I+=2)}if(m<u.length)for(u[m++]=R;m<u.length;)u[m++]=0},i.prototype._toArrayLikeBE=function(u,p){for(var m=u.length-1,R=0,_=0,I=0;_<this.length;_++){var U=this.words[_]<<I|R;u[m--]=U&255,m>=0&&(u[m--]=U>>8&255),m>=0&&(u[m--]=U>>16&255),I===6?(m>=0&&(u[m--]=U>>24&255),R=0,I=0):(R=U>>>24,I+=2)}if(m>=0)for(u[m--]=R;m>=0;)u[m--]=0},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var p=u,m=0;return p>=4096&&(m+=13,p>>>=13),p>=64&&(m+=7,p>>>=7),p>=8&&(m+=4,p>>>=4),p>=2&&(m+=2,p>>>=2),m+p},i.prototype._zeroBits=function(u){if(u===0)return 26;var p=u,m=0;return p&8191||(m+=13,p>>>=13),p&127||(m+=7,p>>>=7),p&15||(m+=4,p>>>=4),p&3||(m+=2,p>>>=2),p&1||m++,m},i.prototype.bitLength=function(){var u=this.words[this.length-1],p=this._countBits(u);return(this.length-1)*26+p};function O(T){for(var u=new Array(T.bitLength()),p=0;p<u.length;p++){var m=p/26|0,R=p%26;u[p]=T.words[m]>>>R&1}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,p=0;p<this.length;p++){var m=this._zeroBits(this.words[p]);if(u+=m,m!==26)break}return u},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},i.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var p=0;p<u.length;p++)this.words[p]=this.words[p]|u.words[p];return this._strip()},i.prototype.ior=function(u){return r((this.negative|u.negative)===0),this.iuor(u)},i.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},i.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},i.prototype.iuand=function(u){var p;this.length>u.length?p=u:p=this;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]&u.words[m];return this.length=p.length,this._strip()},i.prototype.iand=function(u){return r((this.negative|u.negative)===0),this.iuand(u)},i.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},i.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},i.prototype.iuxor=function(u){var p,m;this.length>u.length?(p=this,m=u):(p=u,m=this);for(var R=0;R<m.length;R++)this.words[R]=p.words[R]^m.words[R];if(this!==p)for(;R<p.length;R++)this.words[R]=p.words[R];return this.length=p.length,this._strip()},i.prototype.ixor=function(u){return r((this.negative|u.negative)===0),this.iuxor(u)},i.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},i.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},i.prototype.inotn=function(u){r(typeof u=="number"&&u>=0);var p=Math.ceil(u/26)|0,m=u%26;this._expand(p),m>0&&p--;for(var R=0;R<p;R++)this.words[R]=~this.words[R]&67108863;return m>0&&(this.words[R]=~this.words[R]&67108863>>26-m),this._strip()},i.prototype.notn=function(u){return this.clone().inotn(u)},i.prototype.setn=function(u,p){r(typeof u=="number"&&u>=0);var m=u/26|0,R=u%26;return this._expand(m+1),p?this.words[m]=this.words[m]|1<<R:this.words[m]=this.words[m]&~(1<<R),this._strip()},i.prototype.iadd=function(u){var p;if(this.negative!==0&&u.negative===0)return this.negative=0,p=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,p=this.isub(u),u.negative=1,p._normSign();var m,R;this.length>u.length?(m=this,R=u):(m=u,R=this);for(var _=0,I=0;I<R.length;I++)p=(m.words[I]|0)+(R.words[I]|0)+_,this.words[I]=p&67108863,_=p>>>26;for(;_!==0&&I<m.length;I++)p=(m.words[I]|0)+_,this.words[I]=p&67108863,_=p>>>26;if(this.length=m.length,_!==0)this.words[this.length]=_,this.length++;else if(m!==this)for(;I<m.length;I++)this.words[I]=m.words[I];return this},i.prototype.add=function(u){var p;return u.negative!==0&&this.negative===0?(u.negative=0,p=this.sub(u),u.negative^=1,p):u.negative===0&&this.negative!==0?(this.negative=0,p=u.sub(this),this.negative=1,p):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},i.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var p=this.iadd(u);return u.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var m=this.cmp(u);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var R,_;m>0?(R=this,_=u):(R=u,_=this);for(var I=0,U=0;U<_.length;U++)p=(R.words[U]|0)-(_.words[U]|0)+I,I=p>>26,this.words[U]=p&67108863;for(;I!==0&&U<R.length;U++)p=(R.words[U]|0)+I,I=p>>26,this.words[U]=p&67108863;if(I===0&&U<R.length&&R!==this)for(;U<R.length;U++)this.words[U]=R.words[U];return this.length=Math.max(this.length,U),R!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function K(T,u,p){p.negative=u.negative^T.negative;var m=T.length+u.length|0;p.length=m,m=m-1|0;var R=T.words[0]|0,_=u.words[0]|0,I=R*_,U=I&67108863,k=I/67108864|0;p.words[0]=U;for(var h=1;h<m;h++){for(var A=k>>>26,at=k&67108863,H=Math.min(h,u.length-1),ct=Math.max(0,h-T.length+1);ct<=H;ct++){var Tt=h-ct|0;R=T.words[Tt]|0,_=u.words[ct]|0,I=R*_+at,A+=I/67108864|0,at=I&67108863}p.words[h]=at|0,k=A|0}return k!==0?p.words[h]=k|0:p.length--,p._strip()}var Q=function(u,p,m){var R=u.words,_=p.words,I=m.words,U=0,k,h,A,at=R[0]|0,H=at&8191,ct=at>>>13,Tt=R[1]|0,Mt=Tt&8191,Pt=Tt>>>13,Ce=R[2]|0,Yt=Ce&8191,Gt=Ce>>>13,le=R[3]|0,re=le&8191,ve=le>>>13,Or=R[4]|0,_e=Or&8191,Oe=Or>>>13,Ar=R[5]|0,Ie=Ar&8191,Ae=Ar>>>13,rr=R[6]|0,ke=rr&8191,Se=rr>>>13,fr=R[7]|0,Be=fr&8191,w=fr>>>13,f=R[8]|0,d=f&8191,B=f>>>13,F=R[9]|0,$=F&8191,Z=F>>>13,Ht=_[0]|0,zt=Ht&8191,Nt=Ht>>>13,Re=_[1]|0,Lt=Re&8191,ze=Re>>>13,ri=_[2]|0,je=ri&8191,Ze=ri>>>13,as=_[3]|0,Te=as&8191,Le=as>>>13,cn=_[4]|0,De=cn&8191,$e=cn>>>13,vi=_[5]|0,Je=vi&8191,he=vi>>>13,ki=_[6]|0,g=ki&8191,b=ki>>>13,v=_[7]|0,c=v&8191,S=v>>>13,W=_[8]|0,z=W&8191,X=W>>>13,lt=_[9]|0,pt=lt&8191,ht=lt>>>13;m.negative=u.negative^p.negative,m.length=19,k=Math.imul(H,zt),h=Math.imul(H,Nt),h=h+Math.imul(ct,zt)|0,A=Math.imul(ct,Nt);var ae=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(ae>>>26)|0,ae&=67108863,k=Math.imul(Mt,zt),h=Math.imul(Mt,Nt),h=h+Math.imul(Pt,zt)|0,A=Math.imul(Pt,Nt),k=k+Math.imul(H,Lt)|0,h=h+Math.imul(H,ze)|0,h=h+Math.imul(ct,Lt)|0,A=A+Math.imul(ct,ze)|0;var vt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(vt>>>26)|0,vt&=67108863,k=Math.imul(Yt,zt),h=Math.imul(Yt,Nt),h=h+Math.imul(Gt,zt)|0,A=Math.imul(Gt,Nt),k=k+Math.imul(Mt,Lt)|0,h=h+Math.imul(Mt,ze)|0,h=h+Math.imul(Pt,Lt)|0,A=A+Math.imul(Pt,ze)|0,k=k+Math.imul(H,je)|0,h=h+Math.imul(H,Ze)|0,h=h+Math.imul(ct,je)|0,A=A+Math.imul(ct,Ze)|0;var Ft=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,k=Math.imul(re,zt),h=Math.imul(re,Nt),h=h+Math.imul(ve,zt)|0,A=Math.imul(ve,Nt),k=k+Math.imul(Yt,Lt)|0,h=h+Math.imul(Yt,ze)|0,h=h+Math.imul(Gt,Lt)|0,A=A+Math.imul(Gt,ze)|0,k=k+Math.imul(Mt,je)|0,h=h+Math.imul(Mt,Ze)|0,h=h+Math.imul(Pt,je)|0,A=A+Math.imul(Pt,Ze)|0,k=k+Math.imul(H,Te)|0,h=h+Math.imul(H,Le)|0,h=h+Math.imul(ct,Te)|0,A=A+Math.imul(ct,Le)|0;var Kt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,k=Math.imul(_e,zt),h=Math.imul(_e,Nt),h=h+Math.imul(Oe,zt)|0,A=Math.imul(Oe,Nt),k=k+Math.imul(re,Lt)|0,h=h+Math.imul(re,ze)|0,h=h+Math.imul(ve,Lt)|0,A=A+Math.imul(ve,ze)|0,k=k+Math.imul(Yt,je)|0,h=h+Math.imul(Yt,Ze)|0,h=h+Math.imul(Gt,je)|0,A=A+Math.imul(Gt,Ze)|0,k=k+Math.imul(Mt,Te)|0,h=h+Math.imul(Mt,Le)|0,h=h+Math.imul(Pt,Te)|0,A=A+Math.imul(Pt,Le)|0,k=k+Math.imul(H,De)|0,h=h+Math.imul(H,$e)|0,h=h+Math.imul(ct,De)|0,A=A+Math.imul(ct,$e)|0;var Vt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,k=Math.imul(Ie,zt),h=Math.imul(Ie,Nt),h=h+Math.imul(Ae,zt)|0,A=Math.imul(Ae,Nt),k=k+Math.imul(_e,Lt)|0,h=h+Math.imul(_e,ze)|0,h=h+Math.imul(Oe,Lt)|0,A=A+Math.imul(Oe,ze)|0,k=k+Math.imul(re,je)|0,h=h+Math.imul(re,Ze)|0,h=h+Math.imul(ve,je)|0,A=A+Math.imul(ve,Ze)|0,k=k+Math.imul(Yt,Te)|0,h=h+Math.imul(Yt,Le)|0,h=h+Math.imul(Gt,Te)|0,A=A+Math.imul(Gt,Le)|0,k=k+Math.imul(Mt,De)|0,h=h+Math.imul(Mt,$e)|0,h=h+Math.imul(Pt,De)|0,A=A+Math.imul(Pt,$e)|0,k=k+Math.imul(H,Je)|0,h=h+Math.imul(H,he)|0,h=h+Math.imul(ct,Je)|0,A=A+Math.imul(ct,he)|0;var qt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(qt>>>26)|0,qt&=67108863,k=Math.imul(ke,zt),h=Math.imul(ke,Nt),h=h+Math.imul(Se,zt)|0,A=Math.imul(Se,Nt),k=k+Math.imul(Ie,Lt)|0,h=h+Math.imul(Ie,ze)|0,h=h+Math.imul(Ae,Lt)|0,A=A+Math.imul(Ae,ze)|0,k=k+Math.imul(_e,je)|0,h=h+Math.imul(_e,Ze)|0,h=h+Math.imul(Oe,je)|0,A=A+Math.imul(Oe,Ze)|0,k=k+Math.imul(re,Te)|0,h=h+Math.imul(re,Le)|0,h=h+Math.imul(ve,Te)|0,A=A+Math.imul(ve,Le)|0,k=k+Math.imul(Yt,De)|0,h=h+Math.imul(Yt,$e)|0,h=h+Math.imul(Gt,De)|0,A=A+Math.imul(Gt,$e)|0,k=k+Math.imul(Mt,Je)|0,h=h+Math.imul(Mt,he)|0,h=h+Math.imul(Pt,Je)|0,A=A+Math.imul(Pt,he)|0,k=k+Math.imul(H,g)|0,h=h+Math.imul(H,b)|0,h=h+Math.imul(ct,g)|0,A=A+Math.imul(ct,b)|0;var Wt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,k=Math.imul(Be,zt),h=Math.imul(Be,Nt),h=h+Math.imul(w,zt)|0,A=Math.imul(w,Nt),k=k+Math.imul(ke,Lt)|0,h=h+Math.imul(ke,ze)|0,h=h+Math.imul(Se,Lt)|0,A=A+Math.imul(Se,ze)|0,k=k+Math.imul(Ie,je)|0,h=h+Math.imul(Ie,Ze)|0,h=h+Math.imul(Ae,je)|0,A=A+Math.imul(Ae,Ze)|0,k=k+Math.imul(_e,Te)|0,h=h+Math.imul(_e,Le)|0,h=h+Math.imul(Oe,Te)|0,A=A+Math.imul(Oe,Le)|0,k=k+Math.imul(re,De)|0,h=h+Math.imul(re,$e)|0,h=h+Math.imul(ve,De)|0,A=A+Math.imul(ve,$e)|0,k=k+Math.imul(Yt,Je)|0,h=h+Math.imul(Yt,he)|0,h=h+Math.imul(Gt,Je)|0,A=A+Math.imul(Gt,he)|0,k=k+Math.imul(Mt,g)|0,h=h+Math.imul(Mt,b)|0,h=h+Math.imul(Pt,g)|0,A=A+Math.imul(Pt,b)|0,k=k+Math.imul(H,c)|0,h=h+Math.imul(H,S)|0,h=h+Math.imul(ct,c)|0,A=A+Math.imul(ct,S)|0;var $t=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+($t>>>26)|0,$t&=67108863,k=Math.imul(d,zt),h=Math.imul(d,Nt),h=h+Math.imul(B,zt)|0,A=Math.imul(B,Nt),k=k+Math.imul(Be,Lt)|0,h=h+Math.imul(Be,ze)|0,h=h+Math.imul(w,Lt)|0,A=A+Math.imul(w,ze)|0,k=k+Math.imul(ke,je)|0,h=h+Math.imul(ke,Ze)|0,h=h+Math.imul(Se,je)|0,A=A+Math.imul(Se,Ze)|0,k=k+Math.imul(Ie,Te)|0,h=h+Math.imul(Ie,Le)|0,h=h+Math.imul(Ae,Te)|0,A=A+Math.imul(Ae,Le)|0,k=k+Math.imul(_e,De)|0,h=h+Math.imul(_e,$e)|0,h=h+Math.imul(Oe,De)|0,A=A+Math.imul(Oe,$e)|0,k=k+Math.imul(re,Je)|0,h=h+Math.imul(re,he)|0,h=h+Math.imul(ve,Je)|0,A=A+Math.imul(ve,he)|0,k=k+Math.imul(Yt,g)|0,h=h+Math.imul(Yt,b)|0,h=h+Math.imul(Gt,g)|0,A=A+Math.imul(Gt,b)|0,k=k+Math.imul(Mt,c)|0,h=h+Math.imul(Mt,S)|0,h=h+Math.imul(Pt,c)|0,A=A+Math.imul(Pt,S)|0,k=k+Math.imul(H,z)|0,h=h+Math.imul(H,X)|0,h=h+Math.imul(ct,z)|0,A=A+Math.imul(ct,X)|0;var Dt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,k=Math.imul($,zt),h=Math.imul($,Nt),h=h+Math.imul(Z,zt)|0,A=Math.imul(Z,Nt),k=k+Math.imul(d,Lt)|0,h=h+Math.imul(d,ze)|0,h=h+Math.imul(B,Lt)|0,A=A+Math.imul(B,ze)|0,k=k+Math.imul(Be,je)|0,h=h+Math.imul(Be,Ze)|0,h=h+Math.imul(w,je)|0,A=A+Math.imul(w,Ze)|0,k=k+Math.imul(ke,Te)|0,h=h+Math.imul(ke,Le)|0,h=h+Math.imul(Se,Te)|0,A=A+Math.imul(Se,Le)|0,k=k+Math.imul(Ie,De)|0,h=h+Math.imul(Ie,$e)|0,h=h+Math.imul(Ae,De)|0,A=A+Math.imul(Ae,$e)|0,k=k+Math.imul(_e,Je)|0,h=h+Math.imul(_e,he)|0,h=h+Math.imul(Oe,Je)|0,A=A+Math.imul(Oe,he)|0,k=k+Math.imul(re,g)|0,h=h+Math.imul(re,b)|0,h=h+Math.imul(ve,g)|0,A=A+Math.imul(ve,b)|0,k=k+Math.imul(Yt,c)|0,h=h+Math.imul(Yt,S)|0,h=h+Math.imul(Gt,c)|0,A=A+Math.imul(Gt,S)|0,k=k+Math.imul(Mt,z)|0,h=h+Math.imul(Mt,X)|0,h=h+Math.imul(Pt,z)|0,A=A+Math.imul(Pt,X)|0,k=k+Math.imul(H,pt)|0,h=h+Math.imul(H,ht)|0,h=h+Math.imul(ct,pt)|0,A=A+Math.imul(ct,ht)|0;var St=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(St>>>26)|0,St&=67108863,k=Math.imul($,Lt),h=Math.imul($,ze),h=h+Math.imul(Z,Lt)|0,A=Math.imul(Z,ze),k=k+Math.imul(d,je)|0,h=h+Math.imul(d,Ze)|0,h=h+Math.imul(B,je)|0,A=A+Math.imul(B,Ze)|0,k=k+Math.imul(Be,Te)|0,h=h+Math.imul(Be,Le)|0,h=h+Math.imul(w,Te)|0,A=A+Math.imul(w,Le)|0,k=k+Math.imul(ke,De)|0,h=h+Math.imul(ke,$e)|0,h=h+Math.imul(Se,De)|0,A=A+Math.imul(Se,$e)|0,k=k+Math.imul(Ie,Je)|0,h=h+Math.imul(Ie,he)|0,h=h+Math.imul(Ae,Je)|0,A=A+Math.imul(Ae,he)|0,k=k+Math.imul(_e,g)|0,h=h+Math.imul(_e,b)|0,h=h+Math.imul(Oe,g)|0,A=A+Math.imul(Oe,b)|0,k=k+Math.imul(re,c)|0,h=h+Math.imul(re,S)|0,h=h+Math.imul(ve,c)|0,A=A+Math.imul(ve,S)|0,k=k+Math.imul(Yt,z)|0,h=h+Math.imul(Yt,X)|0,h=h+Math.imul(Gt,z)|0,A=A+Math.imul(Gt,X)|0,k=k+Math.imul(Mt,pt)|0,h=h+Math.imul(Mt,ht)|0,h=h+Math.imul(Pt,pt)|0,A=A+Math.imul(Pt,ht)|0;var Bt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,k=Math.imul($,je),h=Math.imul($,Ze),h=h+Math.imul(Z,je)|0,A=Math.imul(Z,Ze),k=k+Math.imul(d,Te)|0,h=h+Math.imul(d,Le)|0,h=h+Math.imul(B,Te)|0,A=A+Math.imul(B,Le)|0,k=k+Math.imul(Be,De)|0,h=h+Math.imul(Be,$e)|0,h=h+Math.imul(w,De)|0,A=A+Math.imul(w,$e)|0,k=k+Math.imul(ke,Je)|0,h=h+Math.imul(ke,he)|0,h=h+Math.imul(Se,Je)|0,A=A+Math.imul(Se,he)|0,k=k+Math.imul(Ie,g)|0,h=h+Math.imul(Ie,b)|0,h=h+Math.imul(Ae,g)|0,A=A+Math.imul(Ae,b)|0,k=k+Math.imul(_e,c)|0,h=h+Math.imul(_e,S)|0,h=h+Math.imul(Oe,c)|0,A=A+Math.imul(Oe,S)|0,k=k+Math.imul(re,z)|0,h=h+Math.imul(re,X)|0,h=h+Math.imul(ve,z)|0,A=A+Math.imul(ve,X)|0,k=k+Math.imul(Yt,pt)|0,h=h+Math.imul(Yt,ht)|0,h=h+Math.imul(Gt,pt)|0,A=A+Math.imul(Gt,ht)|0;var xt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(xt>>>26)|0,xt&=67108863,k=Math.imul($,Te),h=Math.imul($,Le),h=h+Math.imul(Z,Te)|0,A=Math.imul(Z,Le),k=k+Math.imul(d,De)|0,h=h+Math.imul(d,$e)|0,h=h+Math.imul(B,De)|0,A=A+Math.imul(B,$e)|0,k=k+Math.imul(Be,Je)|0,h=h+Math.imul(Be,he)|0,h=h+Math.imul(w,Je)|0,A=A+Math.imul(w,he)|0,k=k+Math.imul(ke,g)|0,h=h+Math.imul(ke,b)|0,h=h+Math.imul(Se,g)|0,A=A+Math.imul(Se,b)|0,k=k+Math.imul(Ie,c)|0,h=h+Math.imul(Ie,S)|0,h=h+Math.imul(Ae,c)|0,A=A+Math.imul(Ae,S)|0,k=k+Math.imul(_e,z)|0,h=h+Math.imul(_e,X)|0,h=h+Math.imul(Oe,z)|0,A=A+Math.imul(Oe,X)|0,k=k+Math.imul(re,pt)|0,h=h+Math.imul(re,ht)|0,h=h+Math.imul(ve,pt)|0,A=A+Math.imul(ve,ht)|0;var Et=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Et>>>26)|0,Et&=67108863,k=Math.imul($,De),h=Math.imul($,$e),h=h+Math.imul(Z,De)|0,A=Math.imul(Z,$e),k=k+Math.imul(d,Je)|0,h=h+Math.imul(d,he)|0,h=h+Math.imul(B,Je)|0,A=A+Math.imul(B,he)|0,k=k+Math.imul(Be,g)|0,h=h+Math.imul(Be,b)|0,h=h+Math.imul(w,g)|0,A=A+Math.imul(w,b)|0,k=k+Math.imul(ke,c)|0,h=h+Math.imul(ke,S)|0,h=h+Math.imul(Se,c)|0,A=A+Math.imul(Se,S)|0,k=k+Math.imul(Ie,z)|0,h=h+Math.imul(Ie,X)|0,h=h+Math.imul(Ae,z)|0,A=A+Math.imul(Ae,X)|0,k=k+Math.imul(_e,pt)|0,h=h+Math.imul(_e,ht)|0,h=h+Math.imul(Oe,pt)|0,A=A+Math.imul(Oe,ht)|0;var _t=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(_t>>>26)|0,_t&=67108863,k=Math.imul($,Je),h=Math.imul($,he),h=h+Math.imul(Z,Je)|0,A=Math.imul(Z,he),k=k+Math.imul(d,g)|0,h=h+Math.imul(d,b)|0,h=h+Math.imul(B,g)|0,A=A+Math.imul(B,b)|0,k=k+Math.imul(Be,c)|0,h=h+Math.imul(Be,S)|0,h=h+Math.imul(w,c)|0,A=A+Math.imul(w,S)|0,k=k+Math.imul(ke,z)|0,h=h+Math.imul(ke,X)|0,h=h+Math.imul(Se,z)|0,A=A+Math.imul(Se,X)|0,k=k+Math.imul(Ie,pt)|0,h=h+Math.imul(Ie,ht)|0,h=h+Math.imul(Ae,pt)|0,A=A+Math.imul(Ae,ht)|0;var mt=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(mt>>>26)|0,mt&=67108863,k=Math.imul($,g),h=Math.imul($,b),h=h+Math.imul(Z,g)|0,A=Math.imul(Z,b),k=k+Math.imul(d,c)|0,h=h+Math.imul(d,S)|0,h=h+Math.imul(B,c)|0,A=A+Math.imul(B,S)|0,k=k+Math.imul(Be,z)|0,h=h+Math.imul(Be,X)|0,h=h+Math.imul(w,z)|0,A=A+Math.imul(w,X)|0,k=k+Math.imul(ke,pt)|0,h=h+Math.imul(ke,ht)|0,h=h+Math.imul(Se,pt)|0,A=A+Math.imul(Se,ht)|0;var G=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(G>>>26)|0,G&=67108863,k=Math.imul($,c),h=Math.imul($,S),h=h+Math.imul(Z,c)|0,A=Math.imul(Z,S),k=k+Math.imul(d,z)|0,h=h+Math.imul(d,X)|0,h=h+Math.imul(B,z)|0,A=A+Math.imul(B,X)|0,k=k+Math.imul(Be,pt)|0,h=h+Math.imul(Be,ht)|0,h=h+Math.imul(w,pt)|0,A=A+Math.imul(w,ht)|0;var Y=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(Y>>>26)|0,Y&=67108863,k=Math.imul($,z),h=Math.imul($,X),h=h+Math.imul(Z,z)|0,A=Math.imul(Z,X),k=k+Math.imul(d,pt)|0,h=h+Math.imul(d,ht)|0,h=h+Math.imul(B,pt)|0,A=A+Math.imul(B,ht)|0;var st=(U+k|0)+((h&8191)<<13)|0;U=(A+(h>>>13)|0)+(st>>>26)|0,st&=67108863,k=Math.imul($,pt),h=Math.imul($,ht),h=h+Math.imul(Z,pt)|0,A=Math.imul(Z,ht);var et=(U+k|0)+((h&8191)<<13)|0;return U=(A+(h>>>13)|0)+(et>>>26)|0,et&=67108863,I[0]=ae,I[1]=vt,I[2]=Ft,I[3]=Kt,I[4]=Vt,I[5]=qt,I[6]=Wt,I[7]=$t,I[8]=Dt,I[9]=St,I[10]=Bt,I[11]=xt,I[12]=Et,I[13]=_t,I[14]=mt,I[15]=G,I[16]=Y,I[17]=st,I[18]=et,U!==0&&(I[19]=U,m.length++),m};Math.imul||(Q=K);function j(T,u,p){p.negative=u.negative^T.negative,p.length=T.length+u.length;for(var m=0,R=0,_=0;_<p.length-1;_++){var I=R;R=0;for(var U=m&67108863,k=Math.min(_,u.length-1),h=Math.max(0,_-T.length+1);h<=k;h++){var A=_-h,at=T.words[A]|0,H=u.words[h]|0,ct=at*H,Tt=ct&67108863;I=I+(ct/67108864|0)|0,Tt=Tt+U|0,U=Tt&67108863,I=I+(Tt>>>26)|0,R+=I>>>26,I&=67108863}p.words[_]=U,m=I,I=R}return m!==0?p.words[_]=m:p.length--,p._strip()}function it(T,u,p){return j(T,u,p)}i.prototype.mulTo=function(u,p){var m,R=this.length+u.length;return this.length===10&&u.length===10?m=Q(this,u,p):R<63?m=K(this,u,p):R<1024?m=j(this,u,p):m=it(this,u,p),m},i.prototype.mul=function(u){var p=new i(null);return p.words=new Array(this.length+u.length),this.mulTo(u,p)},i.prototype.mulf=function(u){var p=new i(null);return p.words=new Array(this.length+u.length),it(this,u,p)},i.prototype.imul=function(u){return this.clone().mulTo(u,this)},i.prototype.imuln=function(u){var p=u<0;p&&(u=-u),r(typeof u=="number"),r(u<67108864);for(var m=0,R=0;R<this.length;R++){var _=(this.words[R]|0)*u,I=(_&67108863)+(m&67108863);m>>=26,m+=_/67108864|0,m+=I>>>26,this.words[R]=I&67108863}return m!==0&&(this.words[R]=m,this.length++),p?this.ineg():this},i.prototype.muln=function(u){return this.clone().imuln(u)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(u){var p=O(u);if(p.length===0)return new i(1);for(var m=this,R=0;R<p.length&&p[R]===0;R++,m=m.sqr());if(++R<p.length)for(var _=m.sqr();R<p.length;R++,_=_.sqr())p[R]!==0&&(m=m.mul(_));return m},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var p=u%26,m=(u-p)/26,R=67108863>>>26-p<<26-p,_;if(p!==0){var I=0;for(_=0;_<this.length;_++){var U=this.words[_]&R,k=(this.words[_]|0)-U<<p;this.words[_]=k|I,I=U>>>26-p}I&&(this.words[_]=I,this.length++)}if(m!==0){for(_=this.length-1;_>=0;_--)this.words[_+m]=this.words[_];for(_=0;_<m;_++)this.words[_]=0;this.length+=m}return this._strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,p,m){r(typeof u=="number"&&u>=0);var R;p?R=(p-p%26)/26:R=0;var _=u%26,I=Math.min((u-_)/26,this.length),U=67108863^67108863>>>_<<_,k=m;if(R-=I,R=Math.max(0,R),k){for(var h=0;h<I;h++)k.words[h]=this.words[h];k.length=I}if(I!==0)if(this.length>I)for(this.length-=I,h=0;h<this.length;h++)this.words[h]=this.words[h+I];else this.words[0]=0,this.length=1;var A=0;for(h=this.length-1;h>=0&&(A!==0||h>=R);h--){var at=this.words[h]|0;this.words[h]=A<<26-_|at>>>_,A=at&U}return k&&A!==0&&(k.words[k.length++]=A),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(u,p,m){return r(this.negative===0),this.iushrn(u,p,m)},i.prototype.shln=function(u){return this.clone().ishln(u)},i.prototype.ushln=function(u){return this.clone().iushln(u)},i.prototype.shrn=function(u){return this.clone().ishrn(u)},i.prototype.ushrn=function(u){return this.clone().iushrn(u)},i.prototype.testn=function(u){r(typeof u=="number"&&u>=0);var p=u%26,m=(u-p)/26,R=1<<p;if(this.length<=m)return!1;var _=this.words[m];return!!(_&R)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var p=u%26,m=(u-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(p!==0&&m++,this.length=Math.min(m,this.length),p!==0){var R=67108863^67108863>>>p<<p;this.words[this.length-1]&=R}return this._strip()},i.prototype.maskn=function(u){return this.clone().imaskn(u)},i.prototype.iaddn=function(u){return r(typeof u=="number"),r(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<=u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},i.prototype._iaddn=function(u){this.words[0]+=u;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(u){if(r(typeof u=="number"),r(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(u){return this.clone().iaddn(u)},i.prototype.subn=function(u){return this.clone().isubn(u)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(u,p,m){var R=u.length+m,_;this._expand(R);var I,U=0;for(_=0;_<u.length;_++){I=(this.words[_+m]|0)+U;var k=(u.words[_]|0)*p;I-=k&67108863,U=(I>>26)-(k/67108864|0),this.words[_+m]=I&67108863}for(;_<this.length-m;_++)I=(this.words[_+m]|0)+U,U=I>>26,this.words[_+m]=I&67108863;if(U===0)return this._strip();for(r(U===-1),U=0,_=0;_<this.length;_++)I=-(this.words[_]|0)+U,U=I>>26,this.words[_]=I&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(u,p){var m=this.length-u.length,R=this.clone(),_=u,I=_.words[_.length-1]|0,U=this._countBits(I);m=26-U,m!==0&&(_=_.ushln(m),R.iushln(m),I=_.words[_.length-1]|0);var k=R.length-_.length,h;if(p!=="mod"){h=new i(null),h.length=k+1,h.words=new Array(h.length);for(var A=0;A<h.length;A++)h.words[A]=0}var at=R.clone()._ishlnsubmul(_,1,k);at.negative===0&&(R=at,h&&(h.words[k]=1));for(var H=k-1;H>=0;H--){var ct=(R.words[_.length+H]|0)*67108864+(R.words[_.length+H-1]|0);for(ct=Math.min(ct/I|0,67108863),R._ishlnsubmul(_,ct,H);R.negative!==0;)ct--,R.negative=0,R._ishlnsubmul(_,1,H),R.isZero()||(R.negative^=1);h&&(h.words[H]=ct)}return h&&h._strip(),R._strip(),p!=="div"&&m!==0&&R.iushrn(m),{div:h||null,mod:R}},i.prototype.divmod=function(u,p,m){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var R,_,I;return this.negative!==0&&u.negative===0?(I=this.neg().divmod(u,p),p!=="mod"&&(R=I.div.neg()),p!=="div"&&(_=I.mod.neg(),m&&_.negative!==0&&_.iadd(u)),{div:R,mod:_}):this.negative===0&&u.negative!==0?(I=this.divmod(u.neg(),p),p!=="mod"&&(R=I.div.neg()),{div:R,mod:I.mod}):this.negative&u.negative?(I=this.neg().divmod(u.neg(),p),p!=="div"&&(_=I.mod.neg(),m&&_.negative!==0&&_.isub(u)),{div:I.div,mod:_}):u.length>this.length||this.cmp(u)<0?{div:new i(0),mod:this}:u.length===1?p==="div"?{div:this.divn(u.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new i(this.modrn(u.words[0]))}:this._wordDiv(u,p)},i.prototype.div=function(u){return this.divmod(u,"div",!1).div},i.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},i.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},i.prototype.divRound=function(u){var p=this.divmod(u);if(p.mod.isZero())return p.div;var m=p.div.negative!==0?p.mod.isub(u):p.mod,R=u.ushrn(1),_=u.andln(1),I=m.cmp(R);return I<0||_===1&&I===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(u){var p=u<0;p&&(u=-u),r(u<=67108863);for(var m=(1<<26)%u,R=0,_=this.length-1;_>=0;_--)R=(m*R+(this.words[_]|0))%u;return p?-R:R},i.prototype.modn=function(u){return this.modrn(u)},i.prototype.idivn=function(u){var p=u<0;p&&(u=-u),r(u<=67108863);for(var m=0,R=this.length-1;R>=0;R--){var _=(this.words[R]|0)+m*67108864;this.words[R]=_/u|0,m=_%u}return this._strip(),p?this.ineg():this},i.prototype.divn=function(u){return this.clone().idivn(u)},i.prototype.egcd=function(u){r(u.negative===0),r(!u.isZero());var p=this,m=u.clone();p.negative!==0?p=p.umod(u):p=p.clone();for(var R=new i(1),_=new i(0),I=new i(0),U=new i(1),k=0;p.isEven()&&m.isEven();)p.iushrn(1),m.iushrn(1),++k;for(var h=m.clone(),A=p.clone();!p.isZero();){for(var at=0,H=1;!(p.words[0]&H)&&at<26;++at,H<<=1);if(at>0)for(p.iushrn(at);at-- >0;)(R.isOdd()||_.isOdd())&&(R.iadd(h),_.isub(A)),R.iushrn(1),_.iushrn(1);for(var ct=0,Tt=1;!(m.words[0]&Tt)&&ct<26;++ct,Tt<<=1);if(ct>0)for(m.iushrn(ct);ct-- >0;)(I.isOdd()||U.isOdd())&&(I.iadd(h),U.isub(A)),I.iushrn(1),U.iushrn(1);p.cmp(m)>=0?(p.isub(m),R.isub(I),_.isub(U)):(m.isub(p),I.isub(R),U.isub(_))}return{a:I,b:U,gcd:m.iushln(k)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var p=this,m=u.clone();p.negative!==0?p=p.umod(u):p=p.clone();for(var R=new i(1),_=new i(0),I=m.clone();p.cmpn(1)>0&&m.cmpn(1)>0;){for(var U=0,k=1;!(p.words[0]&k)&&U<26;++U,k<<=1);if(U>0)for(p.iushrn(U);U-- >0;)R.isOdd()&&R.iadd(I),R.iushrn(1);for(var h=0,A=1;!(m.words[0]&A)&&h<26;++h,A<<=1);if(h>0)for(m.iushrn(h);h-- >0;)_.isOdd()&&_.iadd(I),_.iushrn(1);p.cmp(m)>=0?(p.isub(m),R.isub(_)):(m.isub(p),_.isub(R))}var at;return p.cmpn(1)===0?at=R:at=_,at.cmpn(0)<0&&at.iadd(u),at},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var p=this.clone(),m=u.clone();p.negative=0,m.negative=0;for(var R=0;p.isEven()&&m.isEven();R++)p.iushrn(1),m.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;m.isEven();)m.iushrn(1);var _=p.cmp(m);if(_<0){var I=p;p=m,m=I}else if(_===0||m.cmpn(1)===0)break;p.isub(m)}while(!0);return m.iushln(R)},i.prototype.invm=function(u){return this.egcd(u).a.umod(u)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(u){return this.words[0]&u},i.prototype.bincn=function(u){r(typeof u=="number");var p=u%26,m=(u-p)/26,R=1<<p;if(this.length<=m)return this._expand(m+1),this.words[m]|=R,this;for(var _=R,I=m;_!==0&&I<this.length;I++){var U=this.words[I]|0;U+=_,_=U>>>26,U&=67108863,this.words[I]=U}return _!==0&&(this.words[I]=_,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(u){var p=u<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var m;if(this.length>1)m=1;else{p&&(u=-u),r(u<=67108863,"Number is too big");var R=this.words[0]|0;m=R===u?0:R<u?-1:1}return this.negative!==0?-m|0:m},i.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var p=this.ucmp(u);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var p=0,m=this.length-1;m>=0;m--){var R=this.words[m]|0,_=u.words[m]|0;if(R!==_){R<_?p=-1:R>_&&(p=1);break}}return p},i.prototype.gtn=function(u){return this.cmpn(u)===1},i.prototype.gt=function(u){return this.cmp(u)===1},i.prototype.gten=function(u){return this.cmpn(u)>=0},i.prototype.gte=function(u){return this.cmp(u)>=0},i.prototype.ltn=function(u){return this.cmpn(u)===-1},i.prototype.lt=function(u){return this.cmp(u)===-1},i.prototype.lten=function(u){return this.cmpn(u)<=0},i.prototype.lte=function(u){return this.cmp(u)<=0},i.prototype.eqn=function(u){return this.cmpn(u)===0},i.prototype.eq=function(u){return this.cmp(u)===0},i.red=function(u){return new kt(u)},i.prototype.toRed=function(u){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(u){return this.red=u,this},i.prototype.forceRed=function(u){return r(!this.red,"Already a number in reduction context"),this._forceRed(u)},i.prototype.redAdd=function(u){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},i.prototype.redIAdd=function(u){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},i.prototype.redSub=function(u){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},i.prototype.redISub=function(u){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},i.prototype.redShl=function(u){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},i.prototype.redMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},i.prototype.redIMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(u){return r(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var J={k256:null,p224:null,p192:null,p25519:null};function D(T,u){this.name=T,this.p=new i(u,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}D.prototype._tmp=function(){var u=new i(null);return u.words=new Array(Math.ceil(this.n/13)),u},D.prototype.ireduce=function(u){var p=u,m;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),m=p.bitLength();while(m>this.n);var R=m<this.n?-1:p.ucmp(this.p);return R===0?(p.words[0]=0,p.length=1):R>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},D.prototype.split=function(u,p){u.iushrn(this.n,0,p)},D.prototype.imulK=function(u){return u.imul(this.k)};function tt(){D.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(tt,D),tt.prototype.split=function(u,p){for(var m=4194303,R=Math.min(u.length,9),_=0;_<R;_++)p.words[_]=u.words[_];if(p.length=R,u.length<=9){u.words[0]=0,u.length=1;return}var I=u.words[9];for(p.words[p.length++]=I&m,_=10;_<u.length;_++){var U=u.words[_]|0;u.words[_-10]=(U&m)<<4|I>>>22,I=U}I>>>=22,u.words[_-10]=I,I===0&&u.length>10?u.length-=10:u.length-=9},tt.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var p=0,m=0;m<u.length;m++){var R=u.words[m]|0;p+=R*977,u.words[m]=p&67108863,p=R*64+(p/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function rt(){D.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(rt,D);function ue(){D.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(ue,D);function jt(){D.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(jt,D),jt.prototype.imulK=function(u){for(var p=0,m=0;m<u.length;m++){var R=(u.words[m]|0)*19+p,_=R&67108863;R>>>=26,u.words[m]=_,p=R}return p!==0&&(u.words[u.length++]=p),u},i._prime=function(u){if(J[u])return J[u];var p;if(u==="k256")p=new tt;else if(u==="p224")p=new rt;else if(u==="p192")p=new ue;else if(u==="p25519")p=new jt;else throw new Error("Unknown prime "+u);return J[u]=p,p};function kt(T){if(typeof T=="string"){var u=i._prime(T);this.m=u.p,this.prime=u}else r(T.gtn(1),"modulus must be greater than 1"),this.m=T,this.prime=null}kt.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},kt.prototype._verify2=function(u,p){r((u.negative|p.negative)===0,"red works only with positives"),r(u.red&&u.red===p.red,"red works only with red numbers")},kt.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):(x(u,u.umod(this.m)._forceRed(this)),u)},kt.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},kt.prototype.add=function(u,p){this._verify2(u,p);var m=u.add(p);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},kt.prototype.iadd=function(u,p){this._verify2(u,p);var m=u.iadd(p);return m.cmp(this.m)>=0&&m.isub(this.m),m},kt.prototype.sub=function(u,p){this._verify2(u,p);var m=u.sub(p);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},kt.prototype.isub=function(u,p){this._verify2(u,p);var m=u.isub(p);return m.cmpn(0)<0&&m.iadd(this.m),m},kt.prototype.shl=function(u,p){return this._verify1(u),this.imod(u.ushln(p))},kt.prototype.imul=function(u,p){return this._verify2(u,p),this.imod(u.imul(p))},kt.prototype.mul=function(u,p){return this._verify2(u,p),this.imod(u.mul(p))},kt.prototype.isqr=function(u){return this.imul(u,u.clone())},kt.prototype.sqr=function(u){return this.mul(u,u)},kt.prototype.sqrt=function(u){if(u.isZero())return u.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var m=this.m.add(new i(1)).iushrn(2);return this.pow(u,m)}for(var R=this.m.subn(1),_=0;!R.isZero()&&R.andln(1)===0;)_++,R.iushrn(1);r(!R.isZero());var I=new i(1).toRed(this),U=I.redNeg(),k=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);this.pow(h,k).cmp(U)!==0;)h.redIAdd(U);for(var A=this.pow(h,R),at=this.pow(u,R.addn(1).iushrn(1)),H=this.pow(u,R),ct=_;H.cmp(I)!==0;){for(var Tt=H,Mt=0;Tt.cmp(I)!==0;Mt++)Tt=Tt.redSqr();r(Mt<ct);var Pt=this.pow(A,new i(1).iushln(ct-Mt-1));at=at.redMul(Pt),A=Pt.redSqr(),H=H.redMul(A),ct=Mt}return at},kt.prototype.invm=function(u){var p=u._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},kt.prototype.pow=function(u,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return u.clone();var m=4,R=new Array(1<<m);R[0]=new i(1).toRed(this),R[1]=u;for(var _=2;_<R.length;_++)R[_]=this.mul(R[_-1],u);var I=R[0],U=0,k=0,h=p.bitLength()%26;for(h===0&&(h=26),_=p.length-1;_>=0;_--){for(var A=p.words[_],at=h-1;at>=0;at--){var H=A>>at&1;if(I!==R[0]&&(I=this.sqr(I)),H===0&&U===0){k=0;continue}U<<=1,U|=H,k++,!(k!==m&&(_!==0||at!==0))&&(I=this.mul(I,R[U]),k=0,U=0)}h=26}return I},kt.prototype.convertTo=function(u){var p=u.umod(this.m);return p===u?p.clone():p},kt.prototype.convertFrom=function(u){var p=u.clone();return p.red=null,p},i.mont=function(u){return new ce(u)};function ce(T){kt.call(this,T),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(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)}s(ce,kt),ce.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},ce.prototype.convertFrom=function(u){var p=this.imod(u.mul(this.rinv));return p.red=null,p},ce.prototype.imul=function(u,p){if(u.isZero()||p.isZero())return u.words[0]=0,u.length=1,u;var m=u.imul(p),R=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=m.isub(R).iushrn(this.shift),I=_;return _.cmp(this.m)>=0?I=_.isub(this.m):_.cmpn(0)<0&&(I=_.iadd(this.m)),I._forceRed(this)},ce.prototype.mul=function(u,p){if(u.isZero()||p.isZero())return new i(0)._forceRed(this);var m=u.mul(p),R=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=m.isub(R).iushrn(this.shift),I=_;return _.cmp(this.m)>=0?I=_.isub(this.m):_.cmpn(0)<0&&(I=_.iadd(this.m)),I._forceRed(this)},ce.prototype.invm=function(u){var p=this.imod(u._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(n,Nr)}(Es);var na=Es.exports;const ia=ni(na);var _s={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,t){var e=Ct,r=e.Buffer;function s(o,a){for(var l in o)a[l]=o[l]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(s(e,t),t.Buffer=i);function i(o,a,l){return r(o,a,l)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,l){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,l)},i.alloc=function(o,a,l){if(typeof o!="number")throw new TypeError("Argument must be a number");var y=r(o);return a!==void 0?typeof l=="string"?y.fill(a,l):y.fill(a):y.fill(0),y},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(_s,_s.exports);var lf=_s.exports,Ri=lf.Buffer;function hf(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 s=n.charAt(r),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=r}var o=n.length,a=n.charAt(0),l=Math.log(o)/Math.log(256),y=Math.log(256)/Math.log(o);function x(C){if((Array.isArray(C)||C instanceof Uint8Array)&&(C=Ri.from(C)),!Ri.isBuffer(C))throw new TypeError("Expected Buffer");if(C.length===0)return"";for(var N=0,M=0,O=0,K=C.length;O!==K&&C[O]===0;)O++,N++;for(var Q=(K-O)*y+1>>>0,j=new Uint8Array(Q);O!==K;){for(var it=C[O],J=0,D=Q-1;(it!==0||J<M)&&D!==-1;D--,J++)it+=256*j[D]>>>0,j[D]=it%o>>>0,it=it/o>>>0;if(it!==0)throw new Error("Non-zero carry");M=J,O++}for(var tt=Q-M;tt!==Q&&j[tt]===0;)tt++;for(var rt=a.repeat(N);tt<Q;++tt)rt+=n.charAt(j[tt]);return rt}function E(C){if(typeof C!="string")throw new TypeError("Expected String");if(C.length===0)return Ri.alloc(0);for(var N=0,M=0,O=0;C[N]===a;)M++,N++;for(var K=(C.length-N)*l+1>>>0,Q=new Uint8Array(K);C[N];){var j=t[C.charCodeAt(N)];if(j===255)return;for(var it=0,J=K-1;(j!==0||it<O)&&J!==-1;J--,it++)j+=o*Q[J]>>>0,Q[J]=j%256>>>0,j=j/256>>>0;if(j!==0)throw new Error("Non-zero carry");O=it,N++}for(var D=K-O;D!==K&&Q[D]===0;)D++;var tt=Ri.allocUnsafe(M+(K-D));tt.fill(0,0,M);for(var rt=M;D!==K;)tt[rt++]=Q[D++];return tt}function L(C){var N=E(C);if(N)return N;throw new Error("Non-base"+o+" character")}return{encode:x,decodeUnsafe:E,decode:L}}var df=hf,pf=df,gf="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",sa=pf(gf);const ar=ni(sa),yf=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]),ln=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),hn=new Uint32Array(64);class mf extends Uo{constructor(){super(64,32,8,!1),this.A=ln[0]|0,this.B=ln[1]|0,this.C=ln[2]|0,this.D=ln[3]|0,this.E=ln[4]|0,this.F=ln[5]|0,this.G=ln[6]|0,this.H=ln[7]|0}get(){const{A:t,B:e,C:r,D:s,E:i,F:o,G:a,H:l}=this;return[t,e,r,s,i,o,a,l]}set(t,e,r,s,i,o,a,l){this.A=t|0,this.B=e|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=l|0}process(t,e){for(let E=0;E<16;E++,e+=4)hn[E]=t.getUint32(e,!1);for(let E=16;E<64;E++){const L=hn[E-15],C=hn[E-2],N=Hr(L,7)^Hr(L,18)^L>>>3,M=Hr(C,17)^Hr(C,19)^C>>>10;hn[E]=M+hn[E-7]+N+hn[E-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:l,G:y,H:x}=this;for(let E=0;E<64;E++){const L=Hr(a,6)^Hr(a,11)^Hr(a,25),C=x+L+gu(a,l,y)+yf[E]+hn[E]|0,M=(Hr(r,2)^Hr(r,13)^Hr(r,22))+yu(r,s,i)|0;x=y,y=l,l=a,a=o+C|0,o=i,i=s,s=r,r=C+M|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,y=y+this.G|0,x=x+this.H|0,this.set(r,s,i,o,a,l,y,x)}roundClean(){hn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Is=ps(()=>new mf);var lr={};function nn(n,t,e){return t<=n&&n<=e}function Ti(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function wf(n){for(var t=String(n),e=t.length,r=0,s=[];r<e;){var i=t.charCodeAt(r);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(r===e-1)s.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,l=o&1023;s.push(65536+(a<<10)+l),r+=1}else s.push(65533)}r+=1}return s}function bf(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 Mi=-1;function As(n){this.tokens=[].slice.call(n)}As.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Mi},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 qn=-1;function Bs(n,t){if(n)throw TypeError("Decoder error");return t||65533}var Pi="utf-8";function Ci(n,t){if(!(this instanceof Ci))return new Ci(n,t);if(n=n!==void 0?String(n).toLowerCase():Pi,n!==Pi)throw new Error("Encoding not supported. Only utf-8 is supported");t=Ti(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})}Ci.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=Ti(e),this._streaming||(this._decoder=new xf({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var s=new As(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==qn);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===qn)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),bf(i)}};function Li(n,t){if(!(this instanceof Li))return new Li(n,t);if(n=n!==void 0?String(n).toLowerCase():Pi,n!==Pi)throw new Error("Encoding not supported. Only utf-8 is supported");t=Ti(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Li.prototype={encode:function(t,e){t=t?String(t):"",e=Ti(e),this._streaming||(this._encoder=new vf(this._options)),this._streaming=!!e.stream;for(var r=[],s=new As(wf(t)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==qn);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==qn;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function xf(n){var t=n.fatal,e=0,r=0,s=0,i=128,o=191;this.handler=function(a,l){if(l===Mi&&s!==0)return s=0,Bs(t);if(l===Mi)return qn;if(s===0){if(nn(l,0,127))return l;if(nn(l,194,223))s=1,e=l-192;else if(nn(l,224,239))l===224&&(i=160),l===237&&(o=159),s=2,e=l-224;else if(nn(l,240,244))l===240&&(i=144),l===244&&(o=143),s=3,e=l-240;else return Bs(t);return e=e<<6*s,null}if(!nn(l,i,o))return e=s=r=0,i=128,o=191,a.prepend(l),Bs(t);if(i=128,o=191,r+=1,e+=l-128<<6*(s-r),r!==s)return null;var y=e;return e=s=r=0,y}}function vf(n){n.fatal,this.handler=function(t,e){if(e===Mi)return qn;if(nn(e,0,127))return e;var r,s;nn(e,128,2047)?(r=1,s=192):nn(e,2048,65535)?(r=2,s=224):nn(e,65536,1114111)&&(r=3,s=240);for(var i=[(e>>6*r)+s];r>0;){var o=e>>6*(r-1);i.push(128|o&63),r-=1}return i}}const kf=cs(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Ci,TextEncoder:Li},Symbol.toStringTag,{value:"Module"})));var Sf=Nr&&Nr.__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]}),Ef=Nr&&Nr.__setModuleDefault||(Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t}),Vr=Nr&&Nr.__decorate||function(n,t,e,r){var s=arguments.length,i=s<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,t,e,r);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(i=(s<3?o(i):s>3?o(t,e,i):o(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i},_f=Nr&&Nr.__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)&&Sf(t,n,e);return Ef(t,n),t},oa=Nr&&Nr.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(lr,"__esModule",{value:!0});var aa=lr.deserializeUnchecked=da=lr.deserialize=ha=lr.serialize=lr.BinaryReader=lr.BinaryWriter=lr.BorshError=lr.baseDecode=lr.baseEncode=void 0;const dn=oa(na),ca=oa(sa),If=_f(kf),Af=typeof TextDecoder!="function"?If.TextDecoder:TextDecoder,Bf=new Af("utf-8",{fatal:!0});function Rf(n){return typeof n=="string"&&(n=Buffer.from(n,"utf8")),ca.default.encode(Buffer.from(n))}lr.baseEncode=Rf;function Tf(n){return Buffer.from(ca.default.decode(n))}lr.baseDecode=Tf;const Rs=1024;class kr 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(".")}}lr.BorshError=kr;class ua{constructor(){this.buf=Buffer.alloc(Rs),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(Rs)]))}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(Buffer.from(new dn.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new dn.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(Rs)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.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)}}lr.BinaryWriter=ua;function jr(n,t,e){const r=e.value;e.value=function(...s){try{return r.apply(this,s)}catch(i){if(i instanceof RangeError){const o=i.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new kr("Reached the end of buffer when deserializing")}throw i}}}class Rr{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 dn.default(t,"le")}readU128(){const t=this.readBuffer(16);return new dn.default(t,"le")}readU256(){const t=this.readBuffer(32);return new dn.default(t,"le")}readU512(){const t=this.readBuffer(64);return new dn.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new kr(`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 Bf.decode(e)}catch(r){throw new kr(`Error decoding UTF-8 string: ${r}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let s=0;s<e;++s)r.push(t());return r}}Vr([jr],Rr.prototype,"readU8",null),Vr([jr],Rr.prototype,"readU16",null),Vr([jr],Rr.prototype,"readU32",null),Vr([jr],Rr.prototype,"readU64",null),Vr([jr],Rr.prototype,"readU128",null),Vr([jr],Rr.prototype,"readU256",null),Vr([jr],Rr.prototype,"readU512",null),Vr([jr],Rr.prototype,"readString",null),Vr([jr],Rr.prototype,"readFixedArray",null),Vr([jr],Rr.prototype,"readArray",null),lr.BinaryReader=Rr;function fa(n){return n.charAt(0).toUpperCase()+n.slice(1)}function En(n,t,e,r,s){try{if(typeof r=="string")s[`write${fa(r)}`](e);else if(r instanceof Array)if(typeof r[0]=="number"){if(e.length!==r[0])throw new kr(`Expecting byte array of length ${r[0]}, but got ${e.length} bytes`);s.writeFixedArray(e)}else if(r.length===2&&typeof r[1]=="number"){if(e.length!==r[1])throw new kr(`Expecting byte array of length ${r[1]}, but got ${e.length} bytes`);for(let i=0;i<r[1];i++)En(n,null,e[i],r[0],s)}else s.writeArray(e,i=>{En(n,t,i,r[0],s)});else if(r.kind!==void 0)switch(r.kind){case"option":{e==null?s.writeU8(0):(s.writeU8(1),En(n,t,e,r.type,s));break}case"map":{s.writeU32(e.size),e.forEach((i,o)=>{En(n,t,o,r.key,s),En(n,t,i,r.value,s)});break}default:throw new kr(`FieldType ${r} unrecognized`)}else la(n,e,s)}catch(i){throw i instanceof kr&&i.addToFieldPath(t),i}}function la(n,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const r=n.get(t.constructor);if(!r)throw new kr(`Class ${t.constructor.name} is missing in schema`);if(r.kind==="struct")r.fields.map(([s,i])=>{En(n,s,t[s],i,e)});else if(r.kind==="enum"){const s=t[r.field];for(let i=0;i<r.values.length;++i){const[o,a]=r.values[i];if(o===s){e.writeU8(i),En(n,o,t[o],a,e);break}}}else throw new kr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function Mf(n,t,e=ua){const r=new e;return la(n,t,r),r.toArray()}var ha=lr.serialize=Mf;function _n(n,t,e,r){try{if(typeof e=="string")return r[`read${fa(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return r.readFixedArray(e[0]);if(typeof e[1]=="number"){const s=[];for(let i=0;i<e[1];i++)s.push(_n(n,null,e[0],r));return s}else return r.readArray(()=>_n(n,t,e[0],r))}if(e.kind==="option")return r.readU8()?_n(n,t,e.type,r):void 0;if(e.kind==="map"){let s=new Map;const i=r.readU32();for(let o=0;o<i;o++){const a=_n(n,t,e.key,r),l=_n(n,t,e.value,r);s.set(a,l)}return s}return Ts(n,e,r)}catch(s){throw s instanceof kr&&s.addToFieldPath(t),s}}function Ts(n,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const r=n.get(t);if(!r)throw new kr(`Class ${t.name} is missing in schema`);if(r.kind==="struct"){const s={};for(const[i,o]of n.get(t).fields)s[i]=_n(n,i,o,e);return new t(s)}if(r.kind==="enum"){const s=e.readU8();if(s>=r.values.length)throw new kr(`Enum index: ${s} is out of range`);const[i,o]=r.values[s],a=_n(n,i,o,e);return new t({[i]:a})}throw new kr(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function Pf(n,t,e,r=Rr){const s=new r(e),i=Ts(n,t,s);if(s.offset<e.length)throw new kr(`Unexpected ${e.length-s.offset} bytes after deserialized data`);return i}var da=lr.deserialize=Pf;function Cf(n,t,e,r=Rr){const s=new r(e);return Ts(n,t,s)}aa=lr.deserializeUnchecked=Cf;var V={};Object.defineProperty(V,"__esModule",{value:!0}),V.s16=V.s8=V.nu64be=V.u48be=V.u40be=V.u32be=V.u24be=V.u16be=hr=V.nu64=V.u48=V.u40=It=V.u32=V.u24=Lr=V.u16=ge=V.u8=pn=V.offset=V.greedy=V.Constant=V.UTF8=V.CString=V.Blob=V.Boolean=V.BitField=V.BitStructure=V.VariantLayout=V.Union=V.UnionLayoutDiscriminator=V.UnionDiscriminator=V.Structure=V.Sequence=V.DoubleBE=V.Double=V.FloatBE=V.Float=V.NearInt64BE=V.NearInt64=V.NearUInt64BE=V.NearUInt64=V.IntBE=V.Int=V.UIntBE=V.UInt=V.OffsetLayout=V.GreedyCount=V.ExternalLayout=V.bindConstructorLayout=V.nameWithProperty=V.Layout=V.uint8ArrayToBuffer=V.checkUint8Array=void 0,V.constant=V.utf8=V.cstr=Ke=V.blob=V.unionLayoutDiscriminator=V.union=dr=V.seq=V.bits=At=V.struct=V.f64be=V.f64=V.f32be=V.f32=V.ns64be=V.s48be=V.s40be=V.s32be=V.s24be=V.s16be=Tr=V.ns64=V.s48=V.s40=V.s32=V.s24=void 0;const Ms=Ct;function Hn(n){if(!(n instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}V.checkUint8Array=Hn;function be(n){return Hn(n),Ms.Buffer.from(n.buffer,n.byteOffset,n.length)}V.uint8ArrayToBuffer=be;class Me{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){}}V.Layout=Me;function Ps(n,t){return t.property?n+"["+t.property+"]":n}V.nameWithProperty=Ps;function Lf(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 Me))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})}V.bindConstructorLayout=Lf;class Er extends Me{isCount(){throw new Error("ExternalLayout is abstract")}}V.ExternalLayout=Er;class pa extends Er{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){Hn(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}V.GreedyCount=pa;class Cs extends Er{constructor(t,e=0,r){if(!(t instanceof Me))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 Cr||this.layout instanceof zr}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)}}V.OffsetLayout=Cs;class Cr extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readUIntLE(e,this.span)}encode(t,e,r=0){return be(e).writeUIntLE(t,r,this.span),this.span}}V.UInt=Cr;class zr extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readUIntBE(e,this.span)}encode(t,e,r=0){return be(e).writeUIntBE(t,r,this.span),this.span}}V.UIntBE=zr;class In extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readIntLE(e,this.span)}encode(t,e,r=0){return be(e).writeIntLE(t,r,this.span),this.span}}V.Int=In;class Vn extends Me{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return be(t).readIntBE(e,this.span)}encode(t,e,r=0){return be(e).writeIntBE(t,r,this.span),this.span}}V.IntBE=Vn;const Ls=Math.pow(2,32);function Ui(n){const t=Math.floor(n/Ls),e=n-t*Ls;return{hi32:t,lo32:e}}function Oi(n,t){return n*Ls+t}class ga extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readUInt32LE(e),i=r.readUInt32LE(e+4);return Oi(i,s)}encode(t,e,r=0){const s=Ui(t),i=be(e);return i.writeUInt32LE(s.lo32,r),i.writeUInt32LE(s.hi32,r+4),8}}V.NearUInt64=ga;class ya extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readUInt32BE(e),i=r.readUInt32BE(e+4);return Oi(s,i)}encode(t,e,r=0){const s=Ui(t),i=be(e);return i.writeUInt32BE(s.hi32,r),i.writeUInt32BE(s.lo32,r+4),8}}V.NearUInt64BE=ya;class ma extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readUInt32LE(e),i=r.readInt32LE(e+4);return Oi(i,s)}encode(t,e,r=0){const s=Ui(t),i=be(e);return i.writeUInt32LE(s.lo32,r),i.writeInt32LE(s.hi32,r+4),8}}V.NearInt64=ma;class wa extends Me{constructor(t){super(8,t)}decode(t,e=0){const r=be(t),s=r.readInt32BE(e),i=r.readUInt32BE(e+4);return Oi(s,i)}encode(t,e,r=0){const s=Ui(t),i=be(e);return i.writeInt32BE(s.hi32,r),i.writeUInt32BE(s.lo32,r+4),8}}V.NearInt64BE=wa;class ba extends Me{constructor(t){super(4,t)}decode(t,e=0){return be(t).readFloatLE(e)}encode(t,e,r=0){return be(e).writeFloatLE(t,r),4}}V.Float=ba;class xa extends Me{constructor(t){super(4,t)}decode(t,e=0){return be(t).readFloatBE(e)}encode(t,e,r=0){return be(e).writeFloatBE(t,r),4}}V.FloatBE=xa;class va extends Me{constructor(t){super(8,t)}decode(t,e=0){return be(t).readDoubleLE(e)}encode(t,e,r=0){return be(e).writeDoubleLE(t,r),8}}V.Double=va;class ka extends Me{constructor(t){super(8,t)}decode(t,e=0){return be(t).readDoubleBE(e)}encode(t,e,r=0){return be(e).writeDoubleBE(t,r),8}}V.DoubleBE=ka;class Sa extends Me{constructor(t,e,r){if(!(t instanceof Me))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Er&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let s=-1;!(e instanceof Er)&&0<t.span&&(s=e*t.span),super(s,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,s=this.count;if(s instanceof Er&&(s=s.decode(t,e)),0<this.elementLayout.span)r=s*this.elementLayout.span;else{let i=0;for(;i<s;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e=0){const r=[];let s=0,i=this.count;for(i instanceof Er&&(i=i.decode(t,e));s<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),s+=1;return r}encode(t,e,r=0){const s=this.elementLayout,i=t.reduce((o,a)=>o+s.encode(a,e,r+o),0);return this.count instanceof Er&&this.count.encode(t.length,e,r),i}}V.Sequence=Sa;class Ea extends Me{constructor(t,e,r){if(!(Array.isArray(t)&&t.reduce((i,o)=>i&&o instanceof Me,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&r===void 0&&(r=e,e=void 0);for(const i of t)if(0>i.span&&i.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let s=-1;try{s=t.reduce((i,o)=>i+o.getSpan(),0)}catch{}super(s,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((s,i)=>{const o=i.getSpan(t,e);return e+=o,s+o},0)}catch{throw new RangeError("indeterminate span")}return r}decode(t,e=0){Hn(t);const r=this.makeDestinationObject();for(const s of this.fields)if(s.property!==void 0&&(r[s.property]=s.decode(t,e)),e+=s.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const s=r;let i=0,o=0;for(const a of this.fields){let l=a.span;if(o=0<l?l:0,a.property!==void 0){const y=t[a.property];y!==void 0&&(o=a.encode(y,e,r),0>l&&(l=a.getSpan(e,r)))}i=r,r+=l}return i+o-s}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)}}}V.Structure=Ea;class Us{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}}V.UnionDiscriminator=Us;class Ni extends Us{constructor(t,e){if(!(t instanceof Er&&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)}}V.UnionLayoutDiscriminator=Ni;class Os extends Me{constructor(t,e,r){let s;if(t instanceof Cr||t instanceof zr)s=new Ni(new Cs(t));else if(t instanceof Er&&t.isCount())s=new Ni(t);else if(t instanceof Us)s=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 Me))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 i=-1;e&&(i=e.span,0<=i&&(t instanceof Cr||t instanceof zr)&&(i+=s.layout.span)),super(i,r),this.discriminator=s,this.usesPrefixDiscriminator=t instanceof Cr||t instanceof zr,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 s=this.discriminator,i=s.decode(t,e),o=this.registry[i];if(o===void 0){const a=this.defaultLayout;let l=0;this.usesPrefixDiscriminator&&(l=s.layout.span),r=this.makeDestinationObject(),r[s.property]=i,r[a.property]=a.decode(t,e+l)}else r=o.decode(t,e);return r}encode(t,e,r=0){const s=this.getSourceVariant(t);if(s===void 0){const i=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=i.layout.span),i.encode(t[i.property],e,r),a+o.encode(t[o.property],e,r+a)}return s.encode(t,e,r)}addVariant(t,e,r){const s=new _a(this,t,e,r);return this.registry[t]=s,s}getVariant(t,e=0){let r;return t instanceof Uint8Array?r=this.discriminator.decode(t,e):r=t,this.registry[r]}}V.Union=Os;class _a extends Me{constructor(t,e,r,s){if(!(t instanceof Os))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"&&s===void 0&&(s=r,r=null),r){if(!(r instanceof Me))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 s!="string")throw new TypeError("variant must have a String property")}let i=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,s),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 s=0;return this.layout&&(s=this.layout.getSpan(t,e+r)),r+s}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let s=0;return this.union.usesPrefixDiscriminator&&(s=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+s):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let s=0;if(this.union.usesPrefixDiscriminator&&(s=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 i=s;if(this.layout&&(this.layout.encode(t[this.property],e,r+s),i+=this.layout.getSpan(e,r+s),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}V.VariantLayout=_a;function jn(n){return 0>n&&(n+=4294967296),n}class Ns extends Me{constructor(t,e,r){if(!(t instanceof Cr||t instanceof zr))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 s=0;this._packedSetValue=function(i){return s=jn(i),this},this._packedGetValue=function(){return s}}decode(t,e=0){const r=this.makeDestinationObject(),s=this.word.decode(t,e);this._packedSetValue(s);for(const i of this.fields)i.property!==void 0&&(r[i.property]=i.decode(t));return r}encode(t,e,r=0){const s=this.word.decode(e,r);this._packedSetValue(s);for(const i of this.fields)if(i.property!==void 0){const o=t[i.property];o!==void 0&&i.encode(o)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new Fs(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new Ia(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}}V.BitStructure=Ns;class Fs{constructor(t,e,r){if(!(t instanceof Ns))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const s=8*t.span,i=t.fields.reduce((o,a)=>o+a.bits,0);if(e+i>s)throw new Error("bits too long for span remainder ("+(s-i)+" of "+s+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=s-i-e),this.wordMask=jn(this.valueMask<<this.start),this.property=r}decode(t,e){const r=this.container._packedGetValue();return jn(r&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==jn(t&this.valueMask))throw new TypeError(Ps("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=jn(t<<this.start);this.container._packedSetValue(jn(e&~this.wordMask)|r)}}V.BitField=Fs;let Ia=class extends Fs{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)}};V.Boolean=Ia;class Aa extends Me{constructor(t,e){if(!(t instanceof Er&&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 Er||(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)),be(t).slice(e,e+r)}encode(t,e,r){let s=this.length;if(this.length instanceof Er&&(s=t.length),!(t instanceof Uint8Array&&s===t.length))throw new TypeError(Ps("Blob.encode",this)+" requires (length "+s+") Uint8Array as src");if(r+s>e.length)throw new RangeError("encoding overruns Uint8Array");const i=be(t);return be(e).write(i.toString("hex"),r,s,"hex"),this.length instanceof Er&&this.length.encode(s,e,r),s}}V.Blob=Aa;class Ba extends Me{constructor(t){super(-1,t)}getSpan(t,e=0){Hn(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 be(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const s=Ms.Buffer.from(t,"utf8"),i=s.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");const o=be(e);return s.copy(o,r),o[r+i]=0,i+1}}V.CString=Ba;class Ra extends Me{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 Hn(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 be(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){typeof t!="string"&&(t=String(t));const s=Ms.Buffer.from(t,"utf8"),i=s.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return s.copy(be(e),r),i}}V.UTF8=Ra;class Ta extends Me{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}}V.Constant=Ta,V.greedy=(n,t)=>new pa(n,t);var pn=V.offset=(n,t,e)=>new Cs(n,t,e),ge=V.u8=n=>new Cr(1,n),Lr=V.u16=n=>new Cr(2,n);V.u24=n=>new Cr(3,n);var It=V.u32=n=>new Cr(4,n);V.u40=n=>new Cr(5,n),V.u48=n=>new Cr(6,n);var hr=V.nu64=n=>new ga(n);V.u16be=n=>new zr(2,n),V.u24be=n=>new zr(3,n),V.u32be=n=>new zr(4,n),V.u40be=n=>new zr(5,n),V.u48be=n=>new zr(6,n),V.nu64be=n=>new ya(n),V.s8=n=>new In(1,n),V.s16=n=>new In(2,n),V.s24=n=>new In(3,n),V.s32=n=>new In(4,n),V.s40=n=>new In(5,n),V.s48=n=>new In(6,n);var Tr=V.ns64=n=>new ma(n);V.s16be=n=>new Vn(2,n),V.s24be=n=>new Vn(3,n),V.s32be=n=>new Vn(4,n),V.s40be=n=>new Vn(5,n),V.s48be=n=>new Vn(6,n),V.ns64be=n=>new wa(n),V.f32=n=>new ba(n),V.f32be=n=>new xa(n),V.f64=n=>new va(n),V.f64be=n=>new ka(n);var At=V.struct=(n,t,e)=>new Ea(n,t,e);V.bits=(n,t,e)=>new Ns(n,t,e);var dr=V.seq=(n,t,e)=>new Sa(n,t,e);V.union=(n,t,e)=>new Os(n,t,e),V.unionLayoutDiscriminator=(n,t)=>new Ni(n,t);var Ke=V.blob=(n,t)=>new Aa(n,t);V.cstr=n=>new Ba(n),V.utf8=(n,t)=>new Ra(n,t),V.constant=(n,t)=>new Ta(n,t);var ai={};Object.defineProperty(ai,"__esModule",{value:!0});function Uf(n){{const t=Buffer.from(n);t.reverse();const e=t.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}}var Of=ai.toBigIntLE=Uf;function Nf(n){{const t=n.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}ai.toBigIntBE=Nf;function Ff(n,t){{const e=n.toString(16),r=Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex");return r.reverse(),r}}var Ma=ai.toBufferLE=Ff;function zf(n,t){{const e=n.toString(16);return Buffer.from(e.padStart(t*2,"0").slice(0,t*2),"hex")}}ai.toBufferBE=zf;class Kf extends TypeError{constructor(t,e){let r;const{message:s,explanation:i,...o}=t,{path:a}=t,l=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??l),i!=null&&(this.cause=l),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}}function Wf(n){return ci(n)&&typeof n[Symbol.iterator]=="function"}function ci(n){return typeof n=="object"&&n!=null}function Fi(n){return ci(n)&&!Array.isArray(n)}function Kr(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function Df(n){const{done:t,value:e}=n.next();return t?void 0:e}function $f(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:s,branch:i}=t,{type:o}=e,{refinement:a,message:l=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Kr(r)}\``}=n;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...n,message:l}}function*Pa(n,t,e,r){Wf(n)||(n=[n]);for(const s of n){const i=$f(s,t,e,r);i&&(yield i)}}function*zs(n,t,e={}){const{path:r=[],branch:s=[n],coerce:i=!1,mask:o=!1}=e,a={path:r,branch:s,mask:o};i&&(n=t.coercer(n,a));let l="valid";for(const y of t.validator(n,a))y.explanation=e.message,l="not_valid",yield[y,void 0];for(let[y,x,E]of t.entries(n,a)){const L=zs(x,E,{path:y===void 0?r:[...r,y],branch:y===void 0?s:[...s,x],coerce:i,mask:o,message:e.message});for(const C of L)C[0]?(l=C[0].refinement!=null?"not_refined":"not_valid",yield[C[0],void 0]):i&&(x=C[1],y===void 0?n=x:n instanceof Map?n.set(y,x):n instanceof Set?n.add(x):ci(n)&&(x!==void 0||y in n)&&(n[y]=x))}if(l!=="not_valid")for(const y of t.refiner(n,a))y.explanation=e.message,l="not_refined",yield[y,void 0];l==="valid"&&(yield[void 0,n])}let Gr=class{constructor(t){const{type:e,schema:r,validator:s,refiner:i,coercer:o=l=>l,entries:a=function*(){}}=t;this.type=e,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(l,y)=>{const x=s(l,y);return Pa(x,y,this,l)}:this.validator=()=>[],i?this.refiner=(l,y)=>{const x=i(l,y);return Pa(x,y,this,l)}:this.refiner=()=>[]}assert(t,e){return Ca(t,this,e)}create(t,e){return yt(t,this,e)}is(t){return La(t,this)}mask(t,e){return qf(t,this,e)}validate(t,e={}){return ui(t,this,e)}};function Ca(n,t,e){const r=ui(n,t,{message:e});if(r[0])throw r[0]}function yt(n,t,e){const r=ui(n,t,{coerce:!0,message:e});if(r[0])throw r[0];return r[1]}function qf(n,t,e){const r=ui(n,t,{coerce:!0,mask:!0,message:e});if(r[0])throw r[0];return r[1]}function La(n,t){return!ui(n,t)[0]}function ui(n,t,e={}){const r=zs(n,t,e),s=Df(r);return s[0]?[new Kf(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function An(n,t){return new Gr({type:n,schema:null,validator:t})}function Hf(){return An("any",()=>!0)}function wt(n){return new Gr({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: ${Kr(t)}`}})}function Yr(){return An("boolean",n=>typeof n=="boolean")}function Ks(n){return An("instance",t=>t instanceof n||`Expected a \`${n.name}\` instance, but received: ${Kr(t)}`)}function He(n){const t=Kr(n),e=typeof n;return new Gr({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${t}\`, but received: ${Kr(r)}`}})}function Vf(){return An("never",()=>!1)}function bt(n){return new Gr({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function q(){return An("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${Kr(n)}`)}function Ot(n){return new Gr({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function Ua(n,t){return new Gr({type:"record",schema:null,*entries(e){if(ci(e))for(const r in e){const s=e[r];yield[r,r,n],yield[r,s,t]}},validator(e){return Fi(e)||`Expected an object, but received: ${Kr(e)}`},coercer(e){return Fi(e)?{...e}:e}})}function dt(){return An("string",n=>typeof n=="string"||`Expected a string, but received: ${Kr(n)}`)}function Ws(n){const t=Vf();return new Gr({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const r=Math.max(n.length,e.length);for(let s=0;s<r;s++)yield[s,e[s],n[s]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Kr(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function ot(n){const t=Object.keys(n);return new Gr({type:"type",schema:n,*entries(e){if(ci(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return Fi(e)||`Expected an object, but received: ${Kr(e)}`},coercer(e){return Fi(e)?{...e}:e}})}function Sr(n){const t=n.map(e=>e.type).join(" | ");return new Gr({type:"union",schema:null,coercer(e,r){for(const s of n){const[i,o]=s.validate(e,{coerce:!0,mask:r.mask});if(!i)return o}return e},validator(e,r){const s=[];for(const i of n){const[...o]=zs(e,i,r),[a]=o;if(a[0])for(const[l]of o)l&&s.push(l);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Kr(e)}`,...s]}})}function Gn(){return An("unknown",()=>!0)}function fi(n,t,e){return new Gr({...n,coercer:(r,s)=>La(r,t)?n.coercer(e(r,s),s):n.coercer(r,s)})}var zi,jf=new Uint8Array(16);function Oa(){if(!zi&&(zi=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!zi))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return zi(jf)}const Gf=/^(?:[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 Ki(n){return typeof n=="string"&&Gf.test(n)}for(var pr=[],Ds=0;Ds<256;++Ds)pr.push((Ds+256).toString(16).substr(1));function Wi(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(pr[n[t+0]]+pr[n[t+1]]+pr[n[t+2]]+pr[n[t+3]]+"-"+pr[n[t+4]]+pr[n[t+5]]+"-"+pr[n[t+6]]+pr[n[t+7]]+"-"+pr[n[t+8]]+pr[n[t+9]]+"-"+pr[n[t+10]]+pr[n[t+11]]+pr[n[t+12]]+pr[n[t+13]]+pr[n[t+14]]+pr[n[t+15]]).toLowerCase();if(!Ki(e))throw TypeError("Stringified UUID is invalid");return e}var Na,$s,qs=0,Hs=0;function Yf(n,t,e){var r=t&&e||0,s=t||new Array(16);n=n||{};var i=n.node||Na,o=n.clockseq!==void 0?n.clockseq:$s;if(i==null||o==null){var a=n.random||(n.rng||Oa)();i==null&&(i=Na=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=$s=(a[6]<<8|a[7])&16383)}var l=n.msecs!==void 0?n.msecs:Date.now(),y=n.nsecs!==void 0?n.nsecs:Hs+1,x=l-qs+(y-Hs)/1e4;if(x<0&&n.clockseq===void 0&&(o=o+1&16383),(x<0||l>qs)&&n.nsecs===void 0&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");qs=l,Hs=y,$s=o,l+=122192928e5;var E=((l&268435455)*1e4+y)%4294967296;s[r++]=E>>>24&255,s[r++]=E>>>16&255,s[r++]=E>>>8&255,s[r++]=E&255;var L=l/4294967296*1e4&268435455;s[r++]=L>>>8&255,s[r++]=L&255,s[r++]=L>>>24&15|16,s[r++]=L>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var C=0;C<6;++C)s[r+C]=i[C];return t||Wi(s)}function Fa(n){if(!Ki(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 Zf(n){n=unescape(encodeURIComponent(n));for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var Jf="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Xf="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function za(n,t,e){function r(s,i,o,a){if(typeof s=="string"&&(s=Zf(s)),typeof i=="string"&&(i=Fa(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var l=new Uint8Array(16+s.length);if(l.set(i),l.set(s,i.length),l=e(l),l[6]=l[6]&15|t,l[8]=l[8]&63|128,o){a=a||0;for(var y=0;y<16;++y)o[a+y]=l[y];return o}return Wi(l)}try{r.name=n}catch{}return r.DNS=Jf,r.URL=Xf,r}function Qf(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 tl(el(rl(n),n.length*8))}function tl(n){for(var t=[],e=n.length*32,r="0123456789abcdef",s=0;s<e;s+=8){var i=n[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);t.push(o)}return t}function Ka(n){return(n+64>>>9<<4)+14+1}function el(n,t){n[t>>5]|=128<<t%32,n[Ka(t)-1]=t;for(var e=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<n.length;o+=16){var a=e,l=r,y=s,x=i;e=gr(e,r,s,i,n[o],7,-680876936),i=gr(i,e,r,s,n[o+1],12,-389564586),s=gr(s,i,e,r,n[o+2],17,606105819),r=gr(r,s,i,e,n[o+3],22,-1044525330),e=gr(e,r,s,i,n[o+4],7,-176418897),i=gr(i,e,r,s,n[o+5],12,1200080426),s=gr(s,i,e,r,n[o+6],17,-1473231341),r=gr(r,s,i,e,n[o+7],22,-45705983),e=gr(e,r,s,i,n[o+8],7,1770035416),i=gr(i,e,r,s,n[o+9],12,-1958414417),s=gr(s,i,e,r,n[o+10],17,-42063),r=gr(r,s,i,e,n[o+11],22,-1990404162),e=gr(e,r,s,i,n[o+12],7,1804603682),i=gr(i,e,r,s,n[o+13],12,-40341101),s=gr(s,i,e,r,n[o+14],17,-1502002290),r=gr(r,s,i,e,n[o+15],22,1236535329),e=yr(e,r,s,i,n[o+1],5,-165796510),i=yr(i,e,r,s,n[o+6],9,-1069501632),s=yr(s,i,e,r,n[o+11],14,643717713),r=yr(r,s,i,e,n[o],20,-373897302),e=yr(e,r,s,i,n[o+5],5,-701558691),i=yr(i,e,r,s,n[o+10],9,38016083),s=yr(s,i,e,r,n[o+15],14,-660478335),r=yr(r,s,i,e,n[o+4],20,-405537848),e=yr(e,r,s,i,n[o+9],5,568446438),i=yr(i,e,r,s,n[o+14],9,-1019803690),s=yr(s,i,e,r,n[o+3],14,-187363961),r=yr(r,s,i,e,n[o+8],20,1163531501),e=yr(e,r,s,i,n[o+13],5,-1444681467),i=yr(i,e,r,s,n[o+2],9,-51403784),s=yr(s,i,e,r,n[o+7],14,1735328473),r=yr(r,s,i,e,n[o+12],20,-1926607734),e=mr(e,r,s,i,n[o+5],4,-378558),i=mr(i,e,r,s,n[o+8],11,-2022574463),s=mr(s,i,e,r,n[o+11],16,1839030562),r=mr(r,s,i,e,n[o+14],23,-35309556),e=mr(e,r,s,i,n[o+1],4,-1530992060),i=mr(i,e,r,s,n[o+4],11,1272893353),s=mr(s,i,e,r,n[o+7],16,-155497632),r=mr(r,s,i,e,n[o+10],23,-1094730640),e=mr(e,r,s,i,n[o+13],4,681279174),i=mr(i,e,r,s,n[o],11,-358537222),s=mr(s,i,e,r,n[o+3],16,-722521979),r=mr(r,s,i,e,n[o+6],23,76029189),e=mr(e,r,s,i,n[o+9],4,-640364487),i=mr(i,e,r,s,n[o+12],11,-421815835),s=mr(s,i,e,r,n[o+15],16,530742520),r=mr(r,s,i,e,n[o+2],23,-995338651),e=wr(e,r,s,i,n[o],6,-198630844),i=wr(i,e,r,s,n[o+7],10,1126891415),s=wr(s,i,e,r,n[o+14],15,-1416354905),r=wr(r,s,i,e,n[o+5],21,-57434055),e=wr(e,r,s,i,n[o+12],6,1700485571),i=wr(i,e,r,s,n[o+3],10,-1894986606),s=wr(s,i,e,r,n[o+10],15,-1051523),r=wr(r,s,i,e,n[o+1],21,-2054922799),e=wr(e,r,s,i,n[o+8],6,1873313359),i=wr(i,e,r,s,n[o+15],10,-30611744),s=wr(s,i,e,r,n[o+6],15,-1560198380),r=wr(r,s,i,e,n[o+13],21,1309151649),e=wr(e,r,s,i,n[o+4],6,-145523070),i=wr(i,e,r,s,n[o+11],10,-1120210379),s=wr(s,i,e,r,n[o+2],15,718787259),r=wr(r,s,i,e,n[o+9],21,-343485551),e=gn(e,a),r=gn(r,l),s=gn(s,y),i=gn(i,x)}return[e,r,s,i]}function rl(n){if(n.length===0)return[];for(var t=n.length*8,e=new Uint32Array(Ka(t)),r=0;r<t;r+=8)e[r>>5]|=(n[r/8]&255)<<r%32;return e}function gn(n,t){var e=(n&65535)+(t&65535),r=(n>>16)+(t>>16)+(e>>16);return r<<16|e&65535}function nl(n,t){return n<<t|n>>>32-t}function Di(n,t,e,r,s,i){return gn(nl(gn(gn(t,n),gn(r,i)),s),e)}function gr(n,t,e,r,s,i,o){return Di(t&e|~t&r,n,t,s,i,o)}function yr(n,t,e,r,s,i,o){return Di(t&r|e&~r,n,t,s,i,o)}function mr(n,t,e,r,s,i,o){return Di(t^e^r,n,t,s,i,o)}function wr(n,t,e,r,s,i,o){return Di(e^(t|~r),n,t,s,i,o)}var il=za("v3",48,Qf);const sl=il;function ol(n,t,e){n=n||{};var r=n.random||(n.rng||Oa)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){e=e||0;for(var s=0;s<16;++s)t[e+s]=r[s];return t}return Wi(r)}function al(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 Vs(n,t){return n<<t|n>>>32-t}function cl(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 s=0;s<r.length;++s)n.push(r.charCodeAt(s))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var i=n.length/4+2,o=Math.ceil(i/16),a=new Array(o),l=0;l<o;++l){for(var y=new Uint32Array(16),x=0;x<16;++x)y[x]=n[l*64+x*4]<<24|n[l*64+x*4+1]<<16|n[l*64+x*4+2]<<8|n[l*64+x*4+3];a[l]=y}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 E=0;E<o;++E){for(var L=new Uint32Array(80),C=0;C<16;++C)L[C]=a[E][C];for(var N=16;N<80;++N)L[N]=Vs(L[N-3]^L[N-8]^L[N-14]^L[N-16],1);for(var M=e[0],O=e[1],K=e[2],Q=e[3],j=e[4],it=0;it<80;++it){var J=Math.floor(it/20),D=Vs(M,5)+al(J,O,K,Q)+j+t[J]+L[it]>>>0;j=Q,Q=K,K=Vs(O,30)>>>0,O=M,M=D}e[0]=e[0]+M>>>0,e[1]=e[1]+O>>>0,e[2]=e[2]+K>>>0,e[3]=e[3]+Q>>>0,e[4]=e[4]+j>>>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 ul=za("v5",80,cl);const fl=ul,ll="00000000-0000-0000-0000-000000000000";function hl(n){if(!Ki(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const Wa=cs(Object.freeze(Object.defineProperty({__proto__:null,NIL:ll,parse:Fa,stringify:Wi,v1:Yf,v3:sl,v4:ol,v5:fl,validate:Ki,version:hl},Symbol.toStringTag,{value:"Module"}))),dl=Wa.v4;var pl=function(n,t,e,r){if(typeof n!="string")throw new TypeError(n+" must be a string");r=r||{};const s=typeof r.version=="number"?r.version:2;if(s!==1&&s!==2)throw new TypeError(s+" must be 1 or 2");const i={method:n};if(s===2&&(i.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");i.params=t}if(typeof e>"u"){const o=typeof r.generator=="function"?r.generator:function(){return dl()};i.id=o(i,r)}else s===2&&e===null?r.notificationIdNull&&(i.id=null):i.id=e;return i};const gl=Wa.v4,yl=pl,li=function(n,t){if(!(this instanceof li))return new li(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 gl()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=n};var ml=li;li.prototype.request=function(n,t,e,r){const s=this;let i=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,i=n;else{typeof e=="function"&&(r=e,e=void 0);const y=typeof r=="function";try{i=yl(n,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(x){if(y)return r(x);throw x}if(!y)return i}let l;try{l=JSON.stringify(i,this.options.replacer)}catch(y){return r(y)}return this.callServer(l,function(y,x){s._parseResponse(y,x,r)}),i},li.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(s){return e(s)}if(e.length===3)if(Array.isArray(r)){const s=function(o){return typeof o.error<"u"},i=function(o){return!s(o)};return e(null,r.filter(s),r.filter(i))}else return e(null,r.error,r.result);e(null,r)};const wl=ni(ml);var Da={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function s(l,y,x){this.fn=l,this.context=y,this.once=x||!1}function i(l,y,x,E,L){if(typeof x!="function")throw new TypeError("The listener must be a function");var C=new s(x,E||l,L),N=e?e+y:y;return l._events[N]?l._events[N].fn?l._events[N]=[l._events[N],C]:l._events[N].push(C):(l._events[N]=C,l._eventsCount++),l}function o(l,y){--l._eventsCount===0?l._events=new r:delete l._events[y]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var y=[],x,E;if(this._eventsCount===0)return y;for(E in x=this._events)t.call(x,E)&&y.push(e?E.slice(1):E);return Object.getOwnPropertySymbols?y.concat(Object.getOwnPropertySymbols(x)):y},a.prototype.listeners=function(y){var x=e?e+y:y,E=this._events[x];if(!E)return[];if(E.fn)return[E.fn];for(var L=0,C=E.length,N=new Array(C);L<C;L++)N[L]=E[L].fn;return N},a.prototype.listenerCount=function(y){var x=e?e+y:y,E=this._events[x];return E?E.fn?1:E.length:0},a.prototype.emit=function(y,x,E,L,C,N){var M=e?e+y:y;if(!this._events[M])return!1;var O=this._events[M],K=arguments.length,Q,j;if(O.fn){switch(O.once&&this.removeListener(y,O.fn,void 0,!0),K){case 1:return O.fn.call(O.context),!0;case 2:return O.fn.call(O.context,x),!0;case 3:return O.fn.call(O.context,x,E),!0;case 4:return O.fn.call(O.context,x,E,L),!0;case 5:return O.fn.call(O.context,x,E,L,C),!0;case 6:return O.fn.call(O.context,x,E,L,C,N),!0}for(j=1,Q=new Array(K-1);j<K;j++)Q[j-1]=arguments[j];O.fn.apply(O.context,Q)}else{var it=O.length,J;for(j=0;j<it;j++)switch(O[j].once&&this.removeListener(y,O[j].fn,void 0,!0),K){case 1:O[j].fn.call(O[j].context);break;case 2:O[j].fn.call(O[j].context,x);break;case 3:O[j].fn.call(O[j].context,x,E);break;case 4:O[j].fn.call(O[j].context,x,E,L);break;default:if(!Q)for(J=1,Q=new Array(K-1);J<K;J++)Q[J-1]=arguments[J];O[j].fn.apply(O[j].context,Q)}}return!0},a.prototype.on=function(y,x,E){return i(this,y,x,E,!1)},a.prototype.once=function(y,x,E){return i(this,y,x,E,!0)},a.prototype.removeListener=function(y,x,E,L){var C=e?e+y:y;if(!this._events[C])return this;if(!x)return o(this,C),this;var N=this._events[C];if(N.fn)N.fn===x&&(!L||N.once)&&(!E||N.context===E)&&o(this,C);else{for(var M=0,O=[],K=N.length;M<K;M++)(N[M].fn!==x||L&&!N[M].once||E&&N[M].context!==E)&&O.push(N[M]);O.length?this._events[C]=O.length===1?O[0]:O:o(this,C)}return this},a.prototype.removeAllListeners=function(y){var x;return y?(x=e?e+y:y,this._events[x]&&o(this,x)):(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})(Da);var bl=Da.exports;const $a=ni(bl);var xl=class extends $a{constructor(t,e,r){super();nr(this,"socket");this.socket=new window.WebSocket(t,r),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=s=>this.emit("message",s.data),this.socket.onerror=s=>this.emit("error",s),this.socket.onclose=s=>{this.emit("close",s.code,s.reason)}}send(t,e,r){const s=r||e;try{this.socket.send(t),s()}catch(i){s(i)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,r){this.socket.addEventListener(t,e,r)}};function vl(n,t){return new xl(n,t)}var kl=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},Sl=class extends $a{constructor(t,e="ws://localhost:8080",{autoconnect:r=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...a}={},l,y){super();nr(this,"address");nr(this,"rpc_id");nr(this,"queue");nr(this,"options");nr(this,"autoconnect");nr(this,"ready");nr(this,"reconnect");nr(this,"reconnect_timer_id");nr(this,"reconnect_interval");nr(this,"max_reconnects");nr(this,"rest_options");nr(this,"current_reconnects");nr(this,"generate_request_id");nr(this,"socket");nr(this,"webSocketFactory");nr(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=r,this.ready=!1,this.reconnect=s,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=l||(()=>++this.rpc_id),y?this.dataPack=y:this.dataPack=new kl,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,s){return!s&&typeof r=="object"&&(s=r,r=null),new Promise((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(t,e),l={jsonrpc:"2.0",method:t,params:e||void 0,id:a};this.socket.send(this.dataPack.encode(l),s,y=>{if(y)return o(y);this.queue[a]={promise:[i,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,s)=>{if(!this.ready)return s(new Error("socket not ready"));const i={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(i),o=>{if(o)return s(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=Ct.Buffer.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 s=[r.notification];if(r.params.constructor===Object)s.push(r.params);else for(let i=0;i<r.params.length;i++)s.push(r.params[i]);return Promise.resolve().then(()=>{this.emit.apply(this,s)})}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:s})=>{this.ready&&setTimeout(()=>this.emit("close",r,s),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 qa=[],Ha=[],Va=[],El=BigInt(0),hi=BigInt(1),_l=BigInt(2),Il=BigInt(7),Al=BigInt(256),Bl=BigInt(113);for(let n=0,t=hi,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],qa.push(2*(5*r+e)),Ha.push((n+1)*(n+2)/2%64);let s=El;for(let i=0;i<7;i++)t=(t<<hi^(t>>Il)*Bl)%Al,t&_l&&(s^=hi<<(hi<<BigInt(i))-hi);Va.push(s)}const[Rl,Tl]=No(Va,!0),ja=(n,t,e)=>e>32?Ko(n,t,e):Fo(n,t,e),Ga=(n,t,e)=>e>32?Wo(n,t,e):zo(n,t,e);function Ml(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,l=(o+2)%10,y=e[l],x=e[l+1],E=ja(y,x,1)^e[a],L=Ga(y,x,1)^e[a+1];for(let C=0;C<50;C+=10)n[o+C]^=E,n[o+C+1]^=L}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Ha[o],l=ja(s,i,a),y=Ga(s,i,a),x=qa[o];s=n[x],i=n[x+1],n[x]=l,n[x+1]=y}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]^=Rl[r],n[1]^=Tl[r]}e.fill(0)}class js extends ds{constructor(t,e,r,s=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ei(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=fu(this.state)}keccak(){Po||Co(this.state32),Ml(this.state32,this.rounds),Po||Co(this.state32),this.posOut=0,this.pos=0}update(t){Fn(this);const{blockLen:e,state:r}=this;t=_i(t);const s=t.length;for(let i=0;i<s;){const o=Math.min(e-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:s}=this;t[r]^=e,e&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Fn(this,!1),ii(t),this.finish();const e=this.state,{blockLen:r}=this;for(let s=0,i=t.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);t.set(e.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=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 Ei(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Mo(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:s,rounds:i,enableXOF:o}=this;return t||(t=new js(e,r,s,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=s,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Ya=((n,t,e)=>ps(()=>new js(t,n,e)))(1,136,256/8);class Za extends ds{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,uu(t);const r=_i(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 s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(t){return Fn(this),this.iHash.update(t),this}digestInto(t){Fn(this),ii(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:s,destroyed:i,blockLen:o,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=i,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 Ja=(n,t,e)=>new Za(n,t).update(e).digest();Ja.create=(n,t)=>new Za(n,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Pl(n){const t=ks(n);Dn(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:s}=t;if(e){if(!r.eql(s,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:Cl,hexToBytes:Ll}=Ku,Bn={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(n){const{Err:t}=Bn;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:Cl(r),l:n.subarray(e+2)}},toSig(n){const{Err:t}=Bn,e=typeof n=="string"?Ll(n):n;si(e);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:s,l:i}=Bn._parseInt(e.subarray(2)),{d:o,l:a}=Bn._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const t=y=>Number.parseInt(y[0],16)&8?"00"+y:y,e=y=>{const x=y.toString(16);return x.length&1?`0${x}`:x},r=t(e(n.s)),s=t(e(n.r)),i=r.length/2,o=s.length/2,a=e(i),l=e(o);return`30${e(o+i+4)}02${l}${s}02${a}${r}`}},sn=BigInt(0),Ur=BigInt(1);BigInt(2);const Xa=BigInt(3);BigInt(4);function Ul(n){const t=Pl(n),{Fp:e}=t,r=t.toBytes||((N,M,O)=>{const K=M.toAffine();return kn(Uint8Array.from([4]),e.toBytes(K.x),e.toBytes(K.y))}),s=t.fromBytes||(N=>{const M=N.subarray(1),O=e.fromBytes(M.subarray(0,e.BYTES)),K=e.fromBytes(M.subarray(e.BYTES,2*e.BYTES));return{x:O,y:K}});function i(N){const{a:M,b:O}=t,K=e.sqr(N),Q=e.mul(K,N);return e.add(e.add(Q,e.mul(N,M)),O)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function o(N){return typeof N=="bigint"&&sn<N&&N<t.n}function a(N){if(!o(N))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(N){const{allowedPrivateKeyLengths:M,nByteLength:O,wrapPrivateKey:K,n:Q}=t;if(M&&typeof N!="bigint"){if(bn(N)&&(N=xn(N)),typeof N!="string"||!M.includes(N.length))throw new Error("Invalid key");N=N.padStart(O*2,"0")}let j;try{j=typeof N=="bigint"?N:vn(ir("private key",N,O))}catch{throw new Error(`private key must be ${O} bytes, hex or bigint, not ${typeof N}`)}return K&&(j=We(j,Q)),a(j),j}const y=new Map;function x(N){if(!(N instanceof E))throw new Error("ProjectivePoint expected")}class E{constructor(M,O,K){if(this.px=M,this.py=O,this.pz=K,M==null||!e.isValid(M))throw new Error("x required");if(O==null||!e.isValid(O))throw new Error("y required");if(K==null||!e.isValid(K))throw new Error("z required")}static fromAffine(M){const{x:O,y:K}=M||{};if(!M||!e.isValid(O)||!e.isValid(K))throw new Error("invalid affine point");if(M instanceof E)throw new Error("projective point not allowed");const Q=j=>e.eql(j,e.ZERO);return Q(O)&&Q(K)?E.ZERO:new E(O,K,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(M){const O=e.invertBatch(M.map(K=>K.pz));return M.map((K,Q)=>K.toAffine(O[Q])).map(E.fromAffine)}static fromHex(M){const O=E.fromAffine(s(ir("pointHex",M)));return O.assertValidity(),O}static fromPrivateKey(M){return E.BASE.multiply(l(M))}_setWindowSize(M){this._WINDOW_SIZE=M,y.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:M,y:O}=this.toAffine();if(!e.isValid(M)||!e.isValid(O))throw new Error("bad point: x or y not FE");const K=e.sqr(O),Q=i(M);if(!e.eql(K,Q))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:M}=this.toAffine();if(e.isOdd)return!e.isOdd(M);throw new Error("Field doesn't support isOdd")}equals(M){x(M);const{px:O,py:K,pz:Q}=this,{px:j,py:it,pz:J}=M,D=e.eql(e.mul(O,J),e.mul(j,Q)),tt=e.eql(e.mul(K,J),e.mul(it,Q));return D&&tt}negate(){return new E(this.px,e.neg(this.py),this.pz)}double(){const{a:M,b:O}=t,K=e.mul(O,Xa),{px:Q,py:j,pz:it}=this;let J=e.ZERO,D=e.ZERO,tt=e.ZERO,rt=e.mul(Q,Q),ue=e.mul(j,j),jt=e.mul(it,it),kt=e.mul(Q,j);return kt=e.add(kt,kt),tt=e.mul(Q,it),tt=e.add(tt,tt),J=e.mul(M,tt),D=e.mul(K,jt),D=e.add(J,D),J=e.sub(ue,D),D=e.add(ue,D),D=e.mul(J,D),J=e.mul(kt,J),tt=e.mul(K,tt),jt=e.mul(M,jt),kt=e.sub(rt,jt),kt=e.mul(M,kt),kt=e.add(kt,tt),tt=e.add(rt,rt),rt=e.add(tt,rt),rt=e.add(rt,jt),rt=e.mul(rt,kt),D=e.add(D,rt),jt=e.mul(j,it),jt=e.add(jt,jt),rt=e.mul(jt,kt),J=e.sub(J,rt),tt=e.mul(jt,ue),tt=e.add(tt,tt),tt=e.add(tt,tt),new E(J,D,tt)}add(M){x(M);const{px:O,py:K,pz:Q}=this,{px:j,py:it,pz:J}=M;let D=e.ZERO,tt=e.ZERO,rt=e.ZERO;const ue=t.a,jt=e.mul(t.b,Xa);let kt=e.mul(O,j),ce=e.mul(K,it),T=e.mul(Q,J),u=e.add(O,K),p=e.add(j,it);u=e.mul(u,p),p=e.add(kt,ce),u=e.sub(u,p),p=e.add(O,Q);let m=e.add(j,J);return p=e.mul(p,m),m=e.add(kt,T),p=e.sub(p,m),m=e.add(K,Q),D=e.add(it,J),m=e.mul(m,D),D=e.add(ce,T),m=e.sub(m,D),rt=e.mul(ue,p),D=e.mul(jt,T),rt=e.add(D,rt),D=e.sub(ce,rt),rt=e.add(ce,rt),tt=e.mul(D,rt),ce=e.add(kt,kt),ce=e.add(ce,kt),T=e.mul(ue,T),p=e.mul(jt,p),ce=e.add(ce,T),T=e.sub(kt,T),T=e.mul(ue,T),p=e.add(p,T),kt=e.mul(ce,p),tt=e.add(tt,kt),kt=e.mul(m,p),D=e.mul(u,D),D=e.sub(D,kt),kt=e.mul(u,ce),rt=e.mul(m,rt),rt=e.add(rt,kt),new E(D,tt,rt)}subtract(M){return this.add(M.negate())}is0(){return this.equals(E.ZERO)}wNAF(M){return C.wNAFCached(this,y,M,O=>{const K=e.invertBatch(O.map(Q=>Q.pz));return O.map((Q,j)=>Q.toAffine(K[j])).map(E.fromAffine)})}multiplyUnsafe(M){const O=E.ZERO;if(M===sn)return O;if(a(M),M===Ur)return this;const{endo:K}=t;if(!K)return C.unsafeLadder(this,M);let{k1neg:Q,k1:j,k2neg:it,k2:J}=K.splitScalar(M),D=O,tt=O,rt=this;for(;j>sn||J>sn;)j&Ur&&(D=D.add(rt)),J&Ur&&(tt=tt.add(rt)),rt=rt.double(),j>>=Ur,J>>=Ur;return Q&&(D=D.negate()),it&&(tt=tt.negate()),tt=new E(e.mul(tt.px,K.beta),tt.py,tt.pz),D.add(tt)}multiply(M){a(M);let O=M,K,Q;const{endo:j}=t;if(j){const{k1neg:it,k1:J,k2neg:D,k2:tt}=j.splitScalar(O);let{p:rt,f:ue}=this.wNAF(J),{p:jt,f:kt}=this.wNAF(tt);rt=C.constTimeNegate(it,rt),jt=C.constTimeNegate(D,jt),jt=new E(e.mul(jt.px,j.beta),jt.py,jt.pz),K=rt.add(jt),Q=ue.add(kt)}else{const{p:it,f:J}=this.wNAF(O);K=it,Q=J}return E.normalizeZ([K,Q])[0]}multiplyAndAddUnsafe(M,O,K){const Q=E.BASE,j=(J,D)=>D===sn||D===Ur||!J.equals(Q)?J.multiplyUnsafe(D):J.multiply(D),it=j(this,O).add(j(M,K));return it.is0()?void 0:it}toAffine(M){const{px:O,py:K,pz:Q}=this,j=this.is0();M==null&&(M=j?e.ONE:e.inv(Q));const it=e.mul(O,M),J=e.mul(K,M),D=e.mul(Q,M);if(j)return{x:e.ZERO,y:e.ZERO};if(!e.eql(D,e.ONE))throw new Error("invZ was invalid");return{x:it,y:J}}isTorsionFree(){const{h:M,isTorsionFree:O}=t;if(M===Ur)return!0;if(O)return O(E,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:M,clearCofactor:O}=t;return M===Ur?this:O?O(E,this):this.multiplyUnsafe(t.h)}toRawBytes(M=!0){return this.assertValidity(),r(E,this,M)}toHex(M=!0){return xn(this.toRawBytes(M))}}E.BASE=new E(t.Gx,t.Gy,e.ONE),E.ZERO=new E(e.ZERO,e.ONE,e.ZERO);const L=t.nBitLength,C=Qo(E,t.endo?Math.ceil(L/2):L);return{CURVE:t,ProjectivePoint:E,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:o}}function Ol(n){const t=ks(n);return Dn(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Nl(n){const t=Ol(n),{Fp:e,n:r}=t,s=e.BYTES+1,i=2*e.BYTES+1;function o(p){return sn<p&&p<e.ORDER}function a(p){return We(p,r)}function l(p){return xs(p,r)}const{ProjectivePoint:y,normPrivateKeyToScalar:x,weierstrassEquation:E,isWithinCurveOrder:L}=Ul({...t,toBytes(p,m,R){const _=m.toAffine(),I=e.toBytes(_.x),U=kn;return R?U(Uint8Array.from([m.hasEvenY()?2:3]),I):U(Uint8Array.from([4]),I,e.toBytes(_.y))},fromBytes(p){const m=p.length,R=p[0],_=p.subarray(1);if(m===s&&(R===2||R===3)){const I=vn(_);if(!o(I))throw new Error("Point is not on curve");const U=E(I);let k;try{k=e.sqrt(U)}catch(at){const H=at instanceof Error?": "+at.message:"";throw new Error("Point is not on curve"+H)}const h=(k&Ur)===Ur;return(R&1)===1!==h&&(k=e.neg(k)),{x:I,y:k}}else if(m===i&&R===4){const I=e.fromBytes(_.subarray(0,e.BYTES)),U=e.fromBytes(_.subarray(e.BYTES,2*e.BYTES));return{x:I,y:U}}else throw new Error(`Point of length ${m} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),C=p=>xn(Wn(p,t.nByteLength));function N(p){const m=r>>Ur;return p>m}function M(p){return N(p)?a(-p):p}const O=(p,m,R)=>vn(p.slice(m,R));class K{constructor(m,R,_){this.r=m,this.s=R,this.recovery=_,this.assertValidity()}static fromCompact(m){const R=t.nByteLength;return m=ir("compactSignature",m,R*2),new K(O(m,0,R),O(m,R,2*R))}static fromDER(m){const{r:R,s:_}=Bn.toSig(ir("DER",m));return new K(R,_)}assertValidity(){if(!L(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!L(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(m){return new K(this.r,this.s,m)}recoverPublicKey(m){const{r:R,s:_,recovery:I}=this,U=tt(ir("msgHash",m));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");const k=I===2||I===3?R+t.n:R;if(k>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=I&1?"03":"02",A=y.fromHex(h+C(k)),at=l(k),H=a(-U*at),ct=a(_*at),Tt=y.BASE.multiplyAndAddUnsafe(A,H,ct);if(!Tt)throw new Error("point at infinify");return Tt.assertValidity(),Tt}hasHighS(){return N(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return zn(this.toDERHex())}toDERHex(){return Bn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zn(this.toCompactHex())}toCompactHex(){return C(this.r)+C(this.s)}}const Q={isValidPrivateKey(p){try{return x(p),!0}catch{return!1}},normPrivateKeyToScalar:x,randomPrivateKey:()=>{const p=Xo(t.n);return Zu(t.randomBytes(p),t.n)},precompute(p=8,m=y.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function j(p,m=!0){return y.fromPrivateKey(p).toRawBytes(m)}function it(p){const m=bn(p),R=typeof p=="string",_=(m||R)&&p.length;return m?_===s||_===i:R?_===2*s||_===2*i:p instanceof y}function J(p,m,R=!0){if(it(p))throw new Error("first arg must be private key");if(!it(m))throw new Error("second arg must be public key");return y.fromHex(m).multiply(x(p)).toRawBytes(R)}const D=t.bits2int||function(p){const m=vn(p),R=p.length*8-t.nBitLength;return R>0?m>>BigInt(R):m},tt=t.bits2int_modN||function(p){return a(D(p))},rt=ms(t.nBitLength);function ue(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(sn<=p&&p<rt))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Wn(p,t.nByteLength)}function jt(p,m,R=kt){if(["recovered","canonical"].some(Pt=>Pt in R))throw new Error("sign() legacy options not supported");const{hash:_,randomBytes:I}=t;let{lowS:U,prehash:k,extraEntropy:h}=R;U==null&&(U=!0),p=ir("msgHash",p),k&&(p=ir("prehashed msgHash",_(p)));const A=tt(p),at=x(m),H=[ue(at),ue(A)];if(h!=null&&h!==!1){const Pt=h===!0?I(e.BYTES):h;H.push(ir("extraEntropy",Pt))}const ct=kn(...H),Tt=A;function Mt(Pt){const Ce=D(Pt);if(!L(Ce))return;const Yt=l(Ce),Gt=y.BASE.multiply(Ce).toAffine(),le=a(Gt.x);if(le===sn)return;const re=a(Yt*a(Tt+le*at));if(re===sn)return;let ve=(Gt.x===le?0:2)|Number(Gt.y&Ur),Or=re;return U&&N(re)&&(Or=M(re),ve^=1),new K(le,Or,ve)}return{seed:ct,k2sig:Mt}}const kt={lowS:t.lowS,prehash:!1},ce={lowS:t.lowS,prehash:!1};function T(p,m,R=kt){const{seed:_,k2sig:I}=jt(p,m,R),U=t;return Vo(U.hash.outputLen,U.nByteLength,U.hmac)(_,I)}y.BASE._setWindowSize(8);function u(p,m,R,_=ce){var Gt;const I=p;if(m=ir("msgHash",m),R=ir("publicKey",R),"strict"in _)throw new Error("options.strict was renamed to lowS");const{lowS:U,prehash:k}=_;let h,A;try{if(typeof I=="string"||bn(I))try{h=K.fromDER(I)}catch(le){if(!(le instanceof Bn.Err))throw le;h=K.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:le,s:re}=I;h=new K(le,re)}else throw new Error("PARSE");A=y.fromHex(R)}catch(le){if(le.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(U&&h.hasHighS())return!1;k&&(m=t.hash(m));const{r:at,s:H}=h,ct=tt(m),Tt=l(H),Mt=a(ct*Tt),Pt=a(at*Tt),Ce=(Gt=y.BASE.multiplyAndAddUnsafe(A,Mt,Pt))==null?void 0:Gt.toAffine();return Ce?a(Ce.x)===at:!1}return{CURVE:t,getPublicKey:j,getSharedSecret:J,sign:T,verify:u,ProjectivePoint:y,Signature:K,utils:Q}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Fl(n){return{hash:n,hmac:(t,...e)=>Ja(n,t,du(...e)),randomBytes:Lo}}function zl(n,t){const e=r=>Nl({...n,...Fl(r)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qa=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),tc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Kl=BigInt(1),Gs=BigInt(2),ec=(n,t)=>(n+t/Gs)/t;function Wl(n){const t=Qa,e=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),y=n*n*n%t,x=y*y*n%t,E=Ge(x,e,t)*x%t,L=Ge(E,e,t)*x%t,C=Ge(L,Gs,t)*y%t,N=Ge(C,s,t)*C%t,M=Ge(N,i,t)*N%t,O=Ge(M,a,t)*M%t,K=Ge(O,l,t)*O%t,Q=Ge(K,a,t)*M%t,j=Ge(Q,e,t)*x%t,it=Ge(j,o,t)*N%t,J=Ge(it,r,t)*y%t,D=Ge(J,Gs,t);if(!Ys.eql(Ys.sqr(D),n))throw new Error("Cannot find square root");return D}const Ys=Zo(Qa,void 0,void 0,{sqrt:Wl}),$i=zl({a:BigInt(0),b:BigInt(7),Fp:Ys,n:tc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=tc,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Kl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,o=BigInt("0x100000000000000000000000000000000"),a=ec(i*n,t),l=ec(-r*n,t);let y=We(n-a*e-l*s,t),x=We(-a*r-l*i,t);const E=y>o,L=x>o;if(E&&(y=t-y),L&&(x=t-x),y>o||x>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:E,k1:y,k2neg:L,k2:x}}}},Is);BigInt(0),$i.ProjectivePoint;const Dl=$n.utils.randomPrivateKey,rc=()=>{const n=$n.utils.randomPrivateKey(),t=qi(n),e=new Uint8Array(64);return e.set(n),e.set(t,32),{publicKey:t,secretKey:e}},qi=$n.getPublicKey;function nc(n){try{return $n.ExtendedPoint.fromHex(n),!0}catch{return!1}}const Zs=(n,t)=>$n.sign(n,t.slice(0,32)),$l=$n.verify,te=n=>Ct.Buffer.isBuffer(n)?n:n instanceof Uint8Array?Ct.Buffer.from(n.buffer,n.byteOffset,n.byteLength):Ct.Buffer.from(n);class Js{constructor(t){Object.assign(this,t)}encode(){return Ct.Buffer.from(ha(di,this))}static decode(t){return da(di,this,t)}static decodeUnchecked(t){return aa(di,this,t)}}class ql extends Js{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 di=new Map;var ic;const sc=32,Zr=32;function Hl(n){return n._bn!==void 0}let oc=1;class gt extends Js{constructor(t){if(super({}),this._bn=void 0,Hl(t))this._bn=t._bn;else{if(typeof t=="string"){const e=ar.decode(t);if(e.length!=Zr)throw new Error("Invalid public key input");this._bn=new ia(e)}else this._bn=new ia(t);if(this._bn.byteLength()>Zr)throw new Error("Invalid public key input")}}static unique(){const t=new gt(oc);return oc+=1,new gt(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return ar.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(Ct.Buffer);if(t.length===Zr)return t;const e=Ct.Buffer.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 s=Ct.Buffer.concat([t.toBuffer(),Ct.Buffer.from(e),r.toBuffer()]),i=Is(s);return new gt(i)}static createProgramAddressSync(t,e){let r=Ct.Buffer.alloc(0);t.forEach(function(i){if(i.length>sc)throw new TypeError("Max seed length exceeded");r=Ct.Buffer.concat([r,te(i)])}),r=Ct.Buffer.concat([r,e.toBuffer(),Ct.Buffer.from("ProgramDerivedAddress")]);const s=Is(r);if(nc(s))throw new Error("Invalid seeds, address must fall off the curve");return new gt(s)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r=255,s;for(;r!=0;){try{const i=t.concat(Ct.Buffer.from([r]));s=this.createProgramAddressSync(i,e)}catch(i){if(i instanceof TypeError)throw i;r--;continue}return[s,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 gt(t);return nc(e.toBytes())}}ic=gt,gt.default=new ic("11111111111111111111111111111111"),di.set(gt,{kind:"struct",fields:[["_bn","u256"]]});class Vl{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=te(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=te(Dl()),this._publicKey=te(qi(this._secretKey))}get publicKey(){return new gt(this._publicKey)}get secretKey(){return Ct.Buffer.concat([this._secretKey,this._publicKey],64)}}const jl=new gt("BPFLoader1111111111111111111111111111111111"),yn=1232,Hi=127,pi=64;class Xs extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Xs.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Qs 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(Qs.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Yn extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Yn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class gi{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((i,o)=>{r.set(i.toBase58(),o)});const s=i=>{const o=r.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const oe=(n="publicKey")=>Ke(32,n),Gl=(n="signature")=>Ke(64,n),Rn=(n="string")=>{const t=At([It("length"),It("lengthPadding"),Ke(pn(It(),-8),"chars")],n),e=t.decode.bind(t),r=t.encode.bind(t),s=t;return s.decode=(i,o)=>e(i,o).chars.toString(),s.encode=(i,o,a)=>{const l={chars:Ct.Buffer.from(i,"utf8")};return r(l,o,a)},s.alloc=i=>It().span+It().span+Ct.Buffer.from(i,"utf8").length,s},Yl=(n="authorized")=>At([oe("staker"),oe("withdrawer")],n),Zl=(n="lockup")=>At([Tr("unixTimestamp"),Tr("epoch"),oe("custodian")],n),Jl=(n="voteInit")=>At([oe("nodePubkey"),oe("authorizedVoter"),oe("authorizedWithdrawer"),ge("commission")],n),Xl=(n="voteAuthorizeWithSeedArgs")=>At([It("voteAuthorizationType"),oe("currentAuthorityDerivedKeyOwnerPubkey"),Rn("currentAuthorityDerivedKeySeed"),oe("newAuthorized")],n);function ac(n,t){const e=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(t[s.property]);if("count"in s&&"elementLayout"in s){const i=t[s.property];if(Array.isArray(i))return i.length*e(s.elementLayout)}else if("fields"in s)return ac({layout:s},t[s.property]);return 0};let r=0;return n.layout.fields.forEach(s=>{r+=e(s)}),r}function _r(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 Mr(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 xe(n,t){if(!n)throw new Error(t||"Assertion failed")}class Vi{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,s=o=>{const a=o.toBase58();let l=r.get(a);return l===void 0&&(l={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,l)),l},i=s(e);i.isSigner=!0,i.isWritable=!0;for(const o of t){s(o.programId).isInvoked=!0;for(const a of o.keys){const l=s(a.pubkey);l.isSigner||(l.isSigner=a.isSigner),l.isWritable||(l.isWritable=a.isWritable)}}return new Vi(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];xe(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,l])=>l.isSigner&&l.isWritable),r=t.filter(([,l])=>l.isSigner&&!l.isWritable),s=t.filter(([,l])=>!l.isSigner&&l.isWritable),i=t.filter(([,l])=>!l.isSigner&&!l.isWritable),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{xe(e.length>0,"Expected at least one writable signer key");const[l]=e[0];xe(l===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...e.map(([l])=>new gt(l)),...r.map(([l])=>new gt(l)),...s.map(([l])=>new gt(l)),...i.map(([l])=>new gt(l))];return[o,a]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&s.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(t,e){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const a=new gt(i),l=t.findIndex(y=>y.equals(a));l>=0&&(xe(l<256,"Max lookup table index exceeded"),r.push(l),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const cc="Reached end of buffer unexpectedly";function Jr(n){if(n.length===0)throw new Error(cc);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(cc);return n.splice(...t)}class Wr{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 gt(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:ar.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new gi(this.staticAccountKeys)}static compile(t){const e=Vi.compile(t.instructions,t.payerKey),[r,s]=e.getMessageComponents(),o=new gi(s).compileInstructions(t.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:ar.encode(a.data)}));return new Wr({header:r,accountKeys:s,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,i=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return r<i}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=[];Mr(e,t);const r=this.instructions.map(E=>{const{accounts:L,programIdIndex:C}=E,N=Array.from(ar.decode(E.data));let M=[];Mr(M,L.length);let O=[];return Mr(O,N.length),{programIdIndex:C,keyIndicesCount:Ct.Buffer.from(M),keyIndices:L,dataLength:Ct.Buffer.from(O),data:N}});let s=[];Mr(s,r.length);let i=Ct.Buffer.alloc(yn);Ct.Buffer.from(s).copy(i);let o=s.length;r.forEach(E=>{const C=At([ge("programIdIndex"),Ke(E.keyIndicesCount.length,"keyIndicesCount"),dr(ge("keyIndex"),E.keyIndices.length,"keyIndices"),Ke(E.dataLength.length,"dataLength"),dr(ge("userdatum"),E.data.length,"data")]).encode(E,i,o);o+=C}),i=i.slice(0,o);const a=At([Ke(1,"numRequiredSignatures"),Ke(1,"numReadonlySignedAccounts"),Ke(1,"numReadonlyUnsignedAccounts"),Ke(e.length,"keyCount"),dr(oe("key"),t,"keys"),oe("recentBlockhash")]),l={numRequiredSignatures:Ct.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Ct.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Ct.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Ct.Buffer.from(e),keys:this.accountKeys.map(E=>te(E.toBytes())),recentBlockhash:ar.decode(this.recentBlockhash)};let y=Ct.Buffer.alloc(2048);const x=a.encode(l,y);return i.copy(y,x),y.slice(0,x+i.length)}static from(t){let e=[...t];const r=Jr(e);if(r!==(r&Hi))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Jr(e),i=Jr(e),o=_r(e);let a=[];for(let L=0;L<o;L++){const C=Ir(e,0,Zr);a.push(new gt(Ct.Buffer.from(C)))}const l=Ir(e,0,Zr),y=_r(e);let x=[];for(let L=0;L<y;L++){const C=Jr(e),N=_r(e),M=Ir(e,0,N),O=_r(e),K=Ir(e,0,O),Q=ar.encode(Ct.Buffer.from(K));x.push({programIdIndex:C,accounts:M,data:Q})}const E={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:ar.encode(Ct.Buffer.from(l)),accountKeys:a,instructions:x};return new Wr(E)}}class Tn{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 gi(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 s=t-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(t>=this.header.numRequiredSignatures){const s=t-e,o=r-e-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=e-this.header.numReadonlySignedAccounts;return t<s}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=t.find(i=>i.key.equals(r.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const i of r.writableIndexes)if(i<s.state.addresses.length)e.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`);for(const i of r.readonlyIndexes)if(i<s.state.addresses.length)e.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`)}return e}static compile(t){const e=Vi.compile(t.instructions,t.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=t.addressLookupTableAccounts||[];for(const x of i){const E=e.extractTableLookup(x);if(E!==void 0){const[L,{writable:C,readonly:N}]=E;r.push(L),s.writable.push(...C),s.readonly.push(...N)}}const[o,a]=e.getMessageComponents(),y=new gi(a,s).compileInstructions(t.instructions);return new Tn({header:o,staticAccountKeys:a,recentBlockhash:t.recentBlockhash,compiledInstructions:y,addressTableLookups:r})}serialize(){const t=Array();Mr(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),r=Array();Mr(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Mr(i,this.addressTableLookups.length);const o=At([ge("prefix"),At([ge("numRequiredSignatures"),ge("numReadonlySignedAccounts"),ge("numReadonlyUnsignedAccounts")],"header"),Ke(t.length,"staticAccountKeysLength"),dr(oe(),this.staticAccountKeys.length,"staticAccountKeys"),oe("recentBlockhash"),Ke(r.length,"instructionsLength"),Ke(e.length,"serializedInstructions"),Ke(i.length,"addressTableLookupsLength"),Ke(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(yn),y=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(x=>x.toBytes()),recentBlockhash:ar.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,y)}serializeInstructions(){let t=0;const e=new Uint8Array(yn);for(const r of this.compiledInstructions){const s=Array();Mr(s,r.accountKeyIndexes.length);const i=Array();Mr(i,r.data.length);const o=At([ge("programIdIndex"),Ke(s.length,"encodedAccountKeyIndexesLength"),dr(ge(),r.accountKeyIndexes.length,"accountKeyIndexes"),Ke(i.length,"encodedDataLength"),Ke(r.data.length,"data")]);t+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(yn);for(const r of this.addressTableLookups){const s=Array();Mr(s,r.writableIndexes.length);const i=Array();Mr(i,r.readonlyIndexes.length);const o=At([oe("accountKey"),Ke(s.length,"encodedWritableIndexesLength"),dr(ge(),r.writableIndexes.length,"writableIndexes"),Ke(i.length,"encodedReadonlyIndexesLength"),dr(ge(),r.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const r=Jr(e),s=r&Hi;xe(r!==s,"Expected versioned message but received legacy message");const i=s;xe(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:Jr(e),numReadonlySignedAccounts:Jr(e),numReadonlyUnsignedAccounts:Jr(e)},a=[],l=_r(e);for(let N=0;N<l;N++)a.push(new gt(Ir(e,0,Zr)));const y=ar.encode(Ir(e,0,Zr)),x=_r(e),E=[];for(let N=0;N<x;N++){const M=Jr(e),O=_r(e),K=Ir(e,0,O),Q=_r(e),j=new Uint8Array(Ir(e,0,Q));E.push({programIdIndex:M,accountKeyIndexes:K,data:j})}const L=_r(e),C=[];for(let N=0;N<L;N++){const M=new gt(Ir(e,0,Zr)),O=_r(e),K=Ir(e,0,O),Q=_r(e),j=Ir(e,0,Q);C.push({accountKey:M,writableIndexes:K,readonlyIndexes:j})}return new Tn({header:o,staticAccountKeys:a,recentBlockhash:y,compiledInstructions:E,addressTableLookups:C})}}const to={deserializeMessageVersion(n){const t=n[0],e=t&Hi;return e===t?"legacy":e},deserialize:n=>{const t=to.deserializeMessageVersion(n);if(t==="legacy")return Wr.from(n);if(t===0)return Tn.deserialize(n);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let on=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 Ql=Ct.Buffer.alloc(pi).fill(0);class Ue{constructor(t){this.keys=void 0,this.programId=void 0,this.data=Ct.Buffer.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]}}}class ye{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 Ue(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 M=0;M<e.length;M++)if(e[M].programId===void 0)throw new Error(`Transaction instruction index ${M} has undefined program id`);const s=[],i=[];e.forEach(M=>{M.keys.forEach(K=>{i.push({...K})});const O=M.programId.toString();s.includes(O)||s.push(O)}),s.forEach(M=>{i.push({pubkey:new gt(M),isSigner:!1,isWritable:!1})});const o=[];i.forEach(M=>{const O=M.pubkey.toString(),K=o.findIndex(Q=>Q.pubkey.toString()===O);K>-1?(o[K].isWritable=o[K].isWritable||M.isWritable,o[K].isSigner=o[K].isSigner||M.isSigner):o.push(M)}),o.sort(function(M,O){if(M.isSigner!==O.isSigner)return M.isSigner?-1:1;if(M.isWritable!==O.isWritable)return M.isWritable?-1:1;const K={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return M.pubkey.toBase58().localeCompare(O.pubkey.toBase58(),"en",K)});const a=o.findIndex(M=>M.pubkey.equals(r));if(a>-1){const[M]=o.splice(a,1);M.isSigner=!0,M.isWritable=!0,o.unshift(M)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const M of this.signatures){const O=o.findIndex(K=>K.pubkey.equals(M.publicKey));if(O>-1)o[O].isSigner||(o[O].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: ${M.publicKey.toString()}`)}let l=0,y=0,x=0;const E=[],L=[];o.forEach(({pubkey:M,isSigner:O,isWritable:K})=>{O?(E.push(M.toString()),l+=1,K||(y+=1)):(L.push(M.toString()),K||(x+=1))});const C=E.concat(L),N=e.map(M=>{const{data:O,programId:K}=M;return{programIdIndex:C.indexOf(K.toString()),accounts:M.keys.map(Q=>C.indexOf(Q.pubkey.toString())),data:ar.encode(O)}});return N.forEach(M=>{xe(M.programIdIndex>=0),M.accounts.forEach(O=>xe(O>=0))}),new Wr({header:{numRequiredSignatures:l,numReadonlySignedAccounts:y,numReadonlyUnsignedAccounts:x},accountKeys:C,recentBlockhash:t,instructions:N})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((s,i)=>e[i].equals(s.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 s=r.toString();return e.has(s)?!1:(e.add(s),!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 i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach(s=>{const i=Zs(r,s.secretKey);this._addSignature(s.publicKey,te(i))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){xe(e.length===64);const r=this.signatures.findIndex(s=>t.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=Ct.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?e&&(r.missing||(r.missing=[])).push(i):$l(s,t,i.toBytes())||(r.invalid||(r.invalid=[])).push(i);return r.invalid||r.missing?r:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,e);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
6
+ */var vs;function qn(){return vs||(vs=1,function(n){const t=Ua(),e=Na(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=$,n.INSPECT_MAX_BYTES=50;const s=2147483647;n.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.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 i(){try{const b=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(b,f),b.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(b){if(b>s)throw new RangeError('The value "'+b+'" is invalid for option "size"');const f=new Uint8Array(b);return Object.setPrototypeOf(f,a.prototype),f}function a(b,f,d){if(typeof b=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return k(b)}return h(b,f,d)}a.poolSize=8192;function h(b,f,d){if(typeof b=="string")return M(b,f);if(ArrayBuffer.isView(b))return C(b);if(b==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b);if(xe(b,ArrayBuffer)||b&&xe(b.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(xe(b,SharedArrayBuffer)||b&&xe(b.buffer,SharedArrayBuffer)))return B(b,f,d);if(typeof b=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const _=b.valueOf&&b.valueOf();if(_!=null&&_!==b)return a.from(_,f,d);const N=T(b);if(N)return N;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof b[Symbol.toPrimitive]=="function")return a.from(b[Symbol.toPrimitive]("string"),f,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b)}a.from=function(b,f,d){return h(b,f,d)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(b){if(typeof b!="number")throw new TypeError('"size" argument must be of type number');if(b<0)throw new RangeError('The value "'+b+'" is invalid for option "size"')}function w(b,f,d){return g(b),b<=0?o(b):f!==void 0?typeof d=="string"?o(b).fill(f,d):o(b).fill(f):o(b)}a.alloc=function(b,f,d){return w(b,f,d)};function k(b){return g(b),o(b<0?0:O(b)|0)}a.allocUnsafe=function(b){return k(b)},a.allocUnsafeSlow=function(b){return k(b)};function M(b,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const d=q(b,f)|0;let _=o(d);const N=_.write(b,f);return N!==d&&(_=_.slice(0,N)),_}function R(b){const f=b.length<0?0:O(b.length)|0,d=o(f);for(let _=0;_<f;_+=1)d[_]=b[_]&255;return d}function C(b){if(xe(b,Uint8Array)){const f=new Uint8Array(b);return B(f.buffer,f.byteOffset,f.byteLength)}return R(b)}function B(b,f,d){if(f<0||b.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(b.byteLength<f+(d||0))throw new RangeError('"length" is outside of buffer bounds');let _;return f===void 0&&d===void 0?_=new Uint8Array(b):d===void 0?_=new Uint8Array(b,f):_=new Uint8Array(b,f,d),Object.setPrototypeOf(_,a.prototype),_}function T(b){if(a.isBuffer(b)){const f=O(b.length)|0,d=o(f);return d.length===0||b.copy(d,0,0,f),d}if(b.length!==void 0)return typeof b.length!="number"||Ot(b.length)?o(0):R(b);if(b.type==="Buffer"&&Array.isArray(b.data))return R(b.data)}function O(b){if(b>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return b|0}function $(b){return+b!=b&&(b=0),a.alloc(+b)}a.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==a.prototype},a.compare=function(f,d){if(xe(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),xe(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),!a.isBuffer(f)||!a.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===d)return 0;let _=f.length,N=d.length;for(let z=0,G=Math.min(_,N);z<G;++z)if(f[z]!==d[z]){_=f[z],N=d[z];break}return _<N?-1:N<_?1:0},a.isEncoding=function(f){switch(String(f).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}},a.concat=function(f,d){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return a.alloc(0);let _;if(d===void 0)for(d=0,_=0;_<f.length;++_)d+=f[_].length;const N=a.allocUnsafe(d);let z=0;for(_=0;_<f.length;++_){let G=f[_];if(xe(G,Uint8Array))z+G.length>N.length?(a.isBuffer(G)||(G=a.from(G)),G.copy(N,z)):Uint8Array.prototype.set.call(N,G,z);else if(a.isBuffer(G))G.copy(N,z);else throw new TypeError('"list" argument must be an Array of Buffers');z+=G.length}return N};function q(b,f){if(a.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||xe(b,ArrayBuffer))return b.byteLength;if(typeof b!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof b);const d=b.length,_=arguments.length>2&&arguments[2]===!0;if(!_&&d===0)return 0;let N=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return Ct(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return zt(b).length;default:if(N)return _?-1:Ct(b).length;f=(""+f).toLowerCase(),N=!0}}a.byteLength=q;function X(b,f,d){let _=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,f>>>=0,d<=f))return"";for(b||(b="utf8");;)switch(b){case"hex":return I(this,f,d);case"utf8":case"utf-8":return u(this,f,d);case"ascii":return E(this,f,d);case"latin1":case"binary":return S(this,f,d);case"base64":return x(this,f,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,f,d);default:if(_)throw new TypeError("Unknown encoding: "+b);b=(b+"").toLowerCase(),_=!0}}a.prototype._isBuffer=!0;function D(b,f,d){const _=b[f];b[f]=b[d],b[d]=_}a.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;d<f;d+=2)D(this,d,d+1);return this},a.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let d=0;d<f;d+=4)D(this,d,d+3),D(this,d+1,d+2);return this},a.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let d=0;d<f;d+=8)D(this,d,d+7),D(this,d+1,d+6),D(this,d+2,d+5),D(this,d+3,d+4);return this},a.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?u(this,0,f):X.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(f){if(!a.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:a.compare(this,f)===0},a.prototype.inspect=function(){let f="";const d=n.INSPECT_MAX_BYTES;return f=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(f+=" ... "),"<Buffer "+f+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(f,d,_,N,z){if(xe(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),!a.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(d===void 0&&(d=0),_===void 0&&(_=f?f.length:0),N===void 0&&(N=0),z===void 0&&(z=this.length),d<0||_>f.length||N<0||z>this.length)throw new RangeError("out of range index");if(N>=z&&d>=_)return 0;if(N>=z)return-1;if(d>=_)return 1;if(d>>>=0,_>>>=0,N>>>=0,z>>>=0,this===f)return 0;let G=z-N,bt=_-d;const gt=Math.min(G,bt),dt=this.slice(N,z),Kt=f.slice(d,_);for(let ht=0;ht<gt;++ht)if(dt[ht]!==Kt[ht]){G=dt[ht],bt=Kt[ht];break}return G<bt?-1:bt<G?1:0};function F(b,f,d,_,N){if(b.length===0)return-1;if(typeof d=="string"?(_=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,Ot(d)&&(d=N?0:b.length-1),d<0&&(d=b.length+d),d>=b.length){if(N)return-1;d=b.length-1}else if(d<0)if(N)d=0;else return-1;if(typeof f=="string"&&(f=a.from(f,_)),a.isBuffer(f))return f.length===0?-1:Y(b,f,d,_,N);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?N?Uint8Array.prototype.indexOf.call(b,f,d):Uint8Array.prototype.lastIndexOf.call(b,f,d):Y(b,[f],d,_,N);throw new TypeError("val must be string, number or Buffer")}function Y(b,f,d,_,N){let z=1,G=b.length,bt=f.length;if(_!==void 0&&(_=String(_).toLowerCase(),_==="ucs2"||_==="ucs-2"||_==="utf16le"||_==="utf-16le")){if(b.length<2||f.length<2)return-1;z=2,G/=2,bt/=2,d/=2}function gt(Kt,ht){return z===1?Kt[ht]:Kt.readUInt16BE(ht*z)}let dt;if(N){let Kt=-1;for(dt=d;dt<G;dt++)if(gt(b,dt)===gt(f,Kt===-1?0:dt-Kt)){if(Kt===-1&&(Kt=dt),dt-Kt+1===bt)return Kt*z}else Kt!==-1&&(dt-=dt-Kt),Kt=-1}else for(d+bt>G&&(d=G-bt),dt=d;dt>=0;dt--){let Kt=!0;for(let ht=0;ht<bt;ht++)if(gt(b,dt+ht)!==gt(f,ht)){Kt=!1;break}if(Kt)return dt}return-1}a.prototype.includes=function(f,d,_){return this.indexOf(f,d,_)!==-1},a.prototype.indexOf=function(f,d,_){return F(this,f,d,_,!0)},a.prototype.lastIndexOf=function(f,d,_){return F(this,f,d,_,!1)};function Z(b,f,d,_){d=Number(d)||0;const N=b.length-d;_?(_=Number(_),_>N&&(_=N)):_=N;const z=f.length;_>z/2&&(_=z/2);let G;for(G=0;G<_;++G){const bt=parseInt(f.substr(G*2,2),16);if(Ot(bt))return G;b[d+G]=bt}return G}function J(b,f,d,_){return Lt(Ct(f,b.length-d),b,d,_)}function K(b,f,d,_){return Lt(Dt(f),b,d,_)}function V(b,f,d,_){return Lt(zt(f),b,d,_)}function Q(b,f,d,_){return Lt(Ur(f,b.length-d),b,d,_)}a.prototype.write=function(f,d,_,N){if(d===void 0)N="utf8",_=this.length,d=0;else if(_===void 0&&typeof d=="string")N=d,_=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(_)?(_=_>>>0,N===void 0&&(N="utf8")):(N=_,_=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const z=this.length-d;if((_===void 0||_>z)&&(_=z),f.length>0&&(_<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");N||(N="utf8");let G=!1;for(;;)switch(N){case"hex":return Z(this,f,d,_);case"utf8":case"utf-8":return J(this,f,d,_);case"ascii":case"latin1":case"binary":return K(this,f,d,_);case"base64":return V(this,f,d,_);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,f,d,_);default:if(G)throw new TypeError("Unknown encoding: "+N);N=(""+N).toLowerCase(),G=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(b,f,d){return f===0&&d===b.length?t.fromByteArray(b):t.fromByteArray(b.slice(f,d))}function u(b,f,d){d=Math.min(b.length,d);const _=[];let N=f;for(;N<d;){const z=b[N];let G=null,bt=z>239?4:z>223?3:z>191?2:1;if(N+bt<=d){let gt,dt,Kt,ht;switch(bt){case 1:z<128&&(G=z);break;case 2:gt=b[N+1],(gt&192)===128&&(ht=(z&31)<<6|gt&63,ht>127&&(G=ht));break;case 3:gt=b[N+1],dt=b[N+2],(gt&192)===128&&(dt&192)===128&&(ht=(z&15)<<12|(gt&63)<<6|dt&63,ht>2047&&(ht<55296||ht>57343)&&(G=ht));break;case 4:gt=b[N+1],dt=b[N+2],Kt=b[N+3],(gt&192)===128&&(dt&192)===128&&(Kt&192)===128&&(ht=(z&15)<<18|(gt&63)<<12|(dt&63)<<6|Kt&63,ht>65535&&ht<1114112&&(G=ht))}}G===null?(G=65533,bt=1):G>65535&&(G-=65536,_.push(G>>>10&1023|55296),G=56320|G&1023),_.push(G),N+=bt}return m(_)}const p=4096;function m(b){const f=b.length;if(f<=p)return String.fromCharCode.apply(String,b);let d="",_=0;for(;_<f;)d+=String.fromCharCode.apply(String,b.slice(_,_+=p));return d}function E(b,f,d){let _="";d=Math.min(b.length,d);for(let N=f;N<d;++N)_+=String.fromCharCode(b[N]&127);return _}function S(b,f,d){let _="";d=Math.min(b.length,d);for(let N=f;N<d;++N)_+=String.fromCharCode(b[N]);return _}function I(b,f,d){const _=b.length;(!f||f<0)&&(f=0),(!d||d<0||d>_)&&(d=_);let N="";for(let z=f;z<d;++z)N+=Ft[b[z]];return N}function L(b,f,d){const _=b.slice(f,d);let N="";for(let z=0;z<_.length-1;z+=2)N+=String.fromCharCode(_[z]+_[z+1]*256);return N}a.prototype.slice=function(f,d){const _=this.length;f=~~f,d=d===void 0?_:~~d,f<0?(f+=_,f<0&&(f=0)):f>_&&(f=_),d<0?(d+=_,d<0&&(d=0)):d>_&&(d=_),d<f&&(d=f);const N=this.subarray(f,d);return Object.setPrototypeOf(N,a.prototype),N};function v(b,f,d){if(b%1!==0||b<0)throw new RangeError("offset is not uint");if(b+f>d)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(f,d,_){f=f>>>0,d=d>>>0,_||v(f,d,this.length);let N=this[f],z=1,G=0;for(;++G<d&&(z*=256);)N+=this[f+G]*z;return N},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,d,_){f=f>>>0,d=d>>>0,_||v(f,d,this.length);let N=this[f+--d],z=1;for(;d>0&&(z*=256);)N+=this[f+--d]*z;return N},a.prototype.readUint8=a.prototype.readUInt8=function(f,d){return f=f>>>0,d||v(f,1,this.length),this[f]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(f,d){return f=f>>>0,d||v(f,2,this.length),this[f]|this[f+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(f,d){return f=f>>>0,d||v(f,2,this.length),this[f]<<8|this[f+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(f,d){return f=f>>>0,d||v(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(f,d){return f=f>>>0,d||v(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},a.prototype.readBigUInt64LE=Be(function(f){f=f>>>0,At(f,"offset");const d=this[f],_=this[f+7];(d===void 0||_===void 0)&&St(f,this.length-8);const N=d+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,z=this[++f]+this[++f]*2**8+this[++f]*2**16+_*2**24;return BigInt(N)+(BigInt(z)<<BigInt(32))}),a.prototype.readBigUInt64BE=Be(function(f){f=f>>>0,At(f,"offset");const d=this[f],_=this[f+7];(d===void 0||_===void 0)&&St(f,this.length-8);const N=d*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],z=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+_;return(BigInt(N)<<BigInt(32))+BigInt(z)}),a.prototype.readIntLE=function(f,d,_){f=f>>>0,d=d>>>0,_||v(f,d,this.length);let N=this[f],z=1,G=0;for(;++G<d&&(z*=256);)N+=this[f+G]*z;return z*=128,N>=z&&(N-=Math.pow(2,8*d)),N},a.prototype.readIntBE=function(f,d,_){f=f>>>0,d=d>>>0,_||v(f,d,this.length);let N=d,z=1,G=this[f+--N];for(;N>0&&(z*=256);)G+=this[f+--N]*z;return z*=128,G>=z&&(G-=Math.pow(2,8*d)),G},a.prototype.readInt8=function(f,d){return f=f>>>0,d||v(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,d){f=f>>>0,d||v(f,2,this.length);const _=this[f]|this[f+1]<<8;return _&32768?_|4294901760:_},a.prototype.readInt16BE=function(f,d){f=f>>>0,d||v(f,2,this.length);const _=this[f+1]|this[f]<<8;return _&32768?_|4294901760:_},a.prototype.readInt32LE=function(f,d){return f=f>>>0,d||v(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},a.prototype.readInt32BE=function(f,d){return f=f>>>0,d||v(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},a.prototype.readBigInt64LE=Be(function(f){f=f>>>0,At(f,"offset");const d=this[f],_=this[f+7];(d===void 0||_===void 0)&&St(f,this.length-8);const N=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(_<<24);return(BigInt(N)<<BigInt(32))+BigInt(d+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24)}),a.prototype.readBigInt64BE=Be(function(f){f=f>>>0,At(f,"offset");const d=this[f],_=this[f+7];(d===void 0||_===void 0)&&St(f,this.length-8);const N=(d<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(N)<<BigInt(32))+BigInt(this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+_)}),a.prototype.readFloatLE=function(f,d){return f=f>>>0,d||v(f,4,this.length),e.read(this,f,!0,23,4)},a.prototype.readFloatBE=function(f,d){return f=f>>>0,d||v(f,4,this.length),e.read(this,f,!1,23,4)},a.prototype.readDoubleLE=function(f,d){return f=f>>>0,d||v(f,8,this.length),e.read(this,f,!0,52,8)},a.prototype.readDoubleBE=function(f,d){return f=f>>>0,d||v(f,8,this.length),e.read(this,f,!1,52,8)};function c(b,f,d,_,N,z){if(!a.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>N||f<z)throw new RangeError('"value" argument is out of bounds');if(d+_>b.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,d,_,N){if(f=+f,d=d>>>0,_=_>>>0,!N){const bt=Math.pow(2,8*_)-1;c(this,f,d,_,bt,0)}let z=1,G=0;for(this[d]=f&255;++G<_&&(z*=256);)this[d+G]=f/z&255;return d+_},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,d,_,N){if(f=+f,d=d>>>0,_=_>>>0,!N){const bt=Math.pow(2,8*_)-1;c(this,f,d,_,bt,0)}let z=_-1,G=1;for(this[d+z]=f&255;--z>=0&&(G*=256);)this[d+z]=f/G&255;return d+_},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,d,_){return f=+f,d=d>>>0,_||c(this,f,d,1,255,0),this[d]=f&255,d+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,d,_){return f=+f,d=d>>>0,_||c(this,f,d,2,65535,0),this[d]=f&255,this[d+1]=f>>>8,d+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(f,d,_){return f=+f,d=d>>>0,_||c(this,f,d,2,65535,0),this[d]=f>>>8,this[d+1]=f&255,d+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(f,d,_){return f=+f,d=d>>>0,_||c(this,f,d,4,4294967295,0),this[d+3]=f>>>24,this[d+2]=f>>>16,this[d+1]=f>>>8,this[d]=f&255,d+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(f,d,_){return f=+f,d=d>>>0,_||c(this,f,d,4,4294967295,0),this[d]=f>>>24,this[d+1]=f>>>16,this[d+2]=f>>>8,this[d+3]=f&255,d+4};function l(b,f,d,_,N){vt(f,_,N,b,d,7);let z=Number(f&BigInt(4294967295));b[d++]=z,z=z>>8,b[d++]=z,z=z>>8,b[d++]=z,z=z>>8,b[d++]=z;let G=Number(f>>BigInt(32)&BigInt(4294967295));return b[d++]=G,G=G>>8,b[d++]=G,G=G>>8,b[d++]=G,G=G>>8,b[d++]=G,d}function y(b,f,d,_,N){vt(f,_,N,b,d,7);let z=Number(f&BigInt(4294967295));b[d+7]=z,z=z>>8,b[d+6]=z,z=z>>8,b[d+5]=z,z=z>>8,b[d+4]=z;let G=Number(f>>BigInt(32)&BigInt(4294967295));return b[d+3]=G,G=G>>8,b[d+2]=G,G=G>>8,b[d+1]=G,G=G>>8,b[d]=G,d+8}a.prototype.writeBigUInt64LE=Be(function(f,d=0){return l(this,f,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Be(function(f,d=0){return y(this,f,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(f,d,_,N){if(f=+f,d=d>>>0,!N){const gt=Math.pow(2,8*_-1);c(this,f,d,_,gt-1,-gt)}let z=0,G=1,bt=0;for(this[d]=f&255;++z<_&&(G*=256);)f<0&&bt===0&&this[d+z-1]!==0&&(bt=1),this[d+z]=(f/G>>0)-bt&255;return d+_},a.prototype.writeIntBE=function(f,d,_,N){if(f=+f,d=d>>>0,!N){const gt=Math.pow(2,8*_-1);c(this,f,d,_,gt-1,-gt)}let z=_-1,G=1,bt=0;for(this[d+z]=f&255;--z>=0&&(G*=256);)f<0&&bt===0&&this[d+z+1]!==0&&(bt=1),this[d+z]=(f/G>>0)-bt&255;return d+_},a.prototype.writeInt8=function(f,d,_){return f=+f,d=d>>>0,_||c(this,f,d,1,127,-128),f<0&&(f=255+f+1),this[d]=f&255,d+1},a.prototype.writeInt16LE=function(f,d,_){return f=+f,d=d>>>0,_||c(this,f,d,2,32767,-32768),this[d]=f&255,this[d+1]=f>>>8,d+2},a.prototype.writeInt16BE=function(f,d,_){return f=+f,d=d>>>0,_||c(this,f,d,2,32767,-32768),this[d]=f>>>8,this[d+1]=f&255,d+2},a.prototype.writeInt32LE=function(f,d,_){return f=+f,d=d>>>0,_||c(this,f,d,4,2147483647,-2147483648),this[d]=f&255,this[d+1]=f>>>8,this[d+2]=f>>>16,this[d+3]=f>>>24,d+4},a.prototype.writeInt32BE=function(f,d,_){return f=+f,d=d>>>0,_||c(this,f,d,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[d]=f>>>24,this[d+1]=f>>>16,this[d+2]=f>>>8,this[d+3]=f&255,d+4},a.prototype.writeBigInt64LE=Be(function(f,d=0){return l(this,f,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Be(function(f,d=0){return y(this,f,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function A(b,f,d,_,N,z){if(d+_>b.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function U(b,f,d,_,N){return f=+f,d=d>>>0,N||A(b,f,d,4),e.write(b,f,d,_,23,4),d+4}a.prototype.writeFloatLE=function(f,d,_){return U(this,f,d,!0,_)},a.prototype.writeFloatBE=function(f,d,_){return U(this,f,d,!1,_)};function j(b,f,d,_,N){return f=+f,d=d>>>0,N||A(b,f,d,8),e.write(b,f,d,_,52,8),d+8}a.prototype.writeDoubleLE=function(f,d,_){return j(this,f,d,!0,_)},a.prototype.writeDoubleBE=function(f,d,_){return j(this,f,d,!1,_)},a.prototype.copy=function(f,d,_,N){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(_||(_=0),!N&&N!==0&&(N=this.length),d>=f.length&&(d=f.length),d||(d=0),N>0&&N<_&&(N=_),N===_||f.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(_<0||_>=this.length)throw new RangeError("Index out of range");if(N<0)throw new RangeError("sourceEnd out of bounds");N>this.length&&(N=this.length),f.length-d<N-_&&(N=f.length-d+_);const z=N-_;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,_,N):Uint8Array.prototype.set.call(f,this.subarray(_,N),d),z},a.prototype.fill=function(f,d,_,N){if(typeof f=="string"){if(typeof d=="string"?(N=d,d=0,_=this.length):typeof _=="string"&&(N=_,_=this.length),N!==void 0&&typeof N!="string")throw new TypeError("encoding must be a string");if(typeof N=="string"&&!a.isEncoding(N))throw new TypeError("Unknown encoding: "+N);if(f.length===1){const G=f.charCodeAt(0);(N==="utf8"&&G<128||N==="latin1")&&(f=G)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(d<0||this.length<d||this.length<_)throw new RangeError("Out of range index");if(_<=d)return this;d=d>>>0,_=_===void 0?this.length:_>>>0,f||(f=0);let z;if(typeof f=="number")for(z=d;z<_;++z)this[z]=f;else{const G=a.isBuffer(f)?f:a.from(f,N),bt=G.length;if(bt===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for(z=0;z<_-d;++z)this[z+d]=G[z%bt]}return this};const nt={};function ct(b,f,d){nt[b]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${b}]`,this.stack,delete this.name}get code(){return b}set code(N){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:N,writable:!0})}toString(){return`${this.name} [${b}]: ${this.message}`}}}ct("ERR_BUFFER_OUT_OF_BOUNDS",function(b){return b?`${b} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ct("ERR_INVALID_ARG_TYPE",function(b,f){return`The "${b}" argument must be of type number. Received type ${typeof f}`},TypeError),ct("ERR_OUT_OF_RANGE",function(b,f,d){let _=`The value of "${b}" is out of range.`,N=d;return Number.isInteger(d)&&Math.abs(d)>2**32?N=_t(String(d)):typeof d=="bigint"&&(N=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(N=_t(N)),N+="n"),_+=` It must be ${f}. Received ${N}`,_},RangeError);function _t(b){let f="",d=b.length;const _=b[0]==="-"?1:0;for(;d>=_+4;d-=3)f=`_${b.slice(d-3,d)}${f}`;return`${b.slice(0,d)}${f}`}function pt(b,f,d){At(f,"offset"),(b[f]===void 0||b[f+d]===void 0)&&St(f,b.length-(d+1))}function vt(b,f,d,_,N,z){if(b>d||b<f){const G=typeof f=="bigint"?"n":"";let bt;throw f===0||f===BigInt(0)?bt=`>= 0${G} and < 2${G} ** ${(z+1)*8}${G}`:bt=`>= -(2${G} ** ${(z+1)*8-1}${G}) and < 2 ** ${(z+1)*8-1}${G}`,new nt.ERR_OUT_OF_RANGE("value",bt,b)}pt(_,N,z)}function At(b,f){if(typeof b!="number")throw new nt.ERR_INVALID_ARG_TYPE(f,"number",b)}function St(b,f,d){throw Math.floor(b)!==b?(At(b,d),new nt.ERR_OUT_OF_RANGE("offset","an integer",b)):f<0?new nt.ERR_BUFFER_OUT_OF_BOUNDS:new nt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,b)}const Tt=/[^+/0-9A-Za-z-_]/g;function $e(b){if(b=b.split("=")[0],b=b.trim().replace(Tt,""),b.length<2)return"";for(;b.length%4!==0;)b=b+"=";return b}function Ct(b,f){f=f||1/0;let d;const _=b.length;let N=null;const z=[];for(let G=0;G<_;++G){if(d=b.charCodeAt(G),d>55295&&d<57344){if(!N){if(d>56319){(f-=3)>-1&&z.push(239,191,189);continue}else if(G+1===_){(f-=3)>-1&&z.push(239,191,189);continue}N=d;continue}if(d<56320){(f-=3)>-1&&z.push(239,191,189),N=d;continue}d=(N-55296<<10|d-56320)+65536}else N&&(f-=3)>-1&&z.push(239,191,189);if(N=null,d<128){if((f-=1)<0)break;z.push(d)}else if(d<2048){if((f-=2)<0)break;z.push(d>>6|192,d&63|128)}else if(d<65536){if((f-=3)<0)break;z.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((f-=4)<0)break;z.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return z}function Dt(b){const f=[];for(let d=0;d<b.length;++d)f.push(b.charCodeAt(d)&255);return f}function Ur(b,f){let d,_,N;const z=[];for(let G=0;G<b.length&&!((f-=2)<0);++G)d=b.charCodeAt(G),_=d>>8,N=d%256,z.push(N),z.push(_);return z}function zt(b){return t.toByteArray($e(b))}function Lt(b,f,d,_){let N;for(N=0;N<_&&!(N+d>=f.length||N>=b.length);++N)f[N+d]=b[N];return N}function xe(b,f){return b instanceof f||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===f.name}function Ot(b){return b!==b}const Ft=function(){const b="0123456789abcdef",f=new Array(256);for(let d=0;d<16;++d){const _=d*16;for(let N=0;N<16;++N)f[_+N]=b[d]+b[N]}return f}();function Be(b){return typeof BigInt>"u"?qt:b}function qt(){throw new Error("BigInt not supported")}}(zn)),zn}var lt=qn();function en(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`positive integer expected, not ${n}`)}function Fa(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function zr(n,...t){if(!Fa(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${n.length}`)}function za(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");en(n.outputLen),en(n.blockLen)}function kr(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 Ss(n,t){zr(n);const e=t.outputLen;if(n.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}const Kn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qa=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Wn=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Oe=(n,t)=>n<<32-t|n>>>t,xs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Ka=n=>n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255;function Is(n){for(let t=0;t<n.length;t++)n[t]=Ka(n[t])}function Wa(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function rn(n){return typeof n=="string"&&(n=Wa(n)),zr(n),n}function Da(...n){let t=0;for(let r=0;r<n.length;r++){const s=n[r];zr(s),t+=s.length}const e=new Uint8Array(t);for(let r=0,s=0;r<n.length;r++){const i=n[r];e.set(i,s),s+=i.length}return e}class Dn{clone(){return this._cloneInto()}}function $n(n){const t=r=>n().update(rn(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function Es(n=32){if(Kn&&typeof Kn.getRandomValues=="function")return Kn.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}function $a(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(e>>s&i),a=Number(e&i),h=r?4:0,g=r?0:4;n.setUint32(t+h,o,r),n.setUint32(t+g,a,r)}const Ha=(n,t,e)=>n&t^~n&e,Va=(n,t,e)=>n&t^n&e^t&e;class _s extends Dn{constructor(t,e,r,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Wn(this.buffer)}update(t){kr(this);const{view:e,buffer:r,blockLen:s}=this;t=rn(t);const i=t.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const h=Wn(t);for(;s<=i-o;o+=s)this.process(h,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){kr(this),Ss(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let k=o;k<s;k++)e[k]=0;$a(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Wn(t),h=this.outputLen;if(h%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=h/4,w=this.get();if(g>w.length)throw new Error("_sha2: outputLen bigger than state");for(let k=0;k<g;k++)a.setUint32(4*k,w[k],i)}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:s,finished:i,destroyed:o,pos:a}=this;return t.length=s,t.pos=a,t.finished=i,t.destroyed=o,s%e&&t.buffer.set(r),t}}const nn=BigInt(2**32-1),Hn=BigInt(32);function Bs(n,t=!1){return t?{h:Number(n&nn),l:Number(n>>Hn&nn)}:{h:Number(n>>Hn&nn)|0,l:Number(n&nn)|0}}function As(n,t=!1){let e=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=Bs(n[s],t);[e[s],r[s]]=[i,o]}return[e,r]}const ja=(n,t)=>BigInt(n>>>0)<<Hn|BigInt(t>>>0),Ga=(n,t,e)=>n>>>e,Za=(n,t,e)=>n<<32-e|t>>>e,Ya=(n,t,e)=>n>>>e|t<<32-e,Ja=(n,t,e)=>n<<32-e|t>>>e,Xa=(n,t,e)=>n<<64-e|t>>>e-32,Qa=(n,t,e)=>n>>>e-32|t<<64-e,tc=(n,t)=>t,ec=(n,t)=>n,Rs=(n,t,e)=>n<<e|t>>>32-e,Ts=(n,t,e)=>t<<e|n>>>32-e,Ms=(n,t,e)=>t<<e-32|n>>>64-e,Ps=(n,t,e)=>n<<e-32|t>>>64-e;function rc(n,t,e,r){const s=(t>>>0)+(r>>>0);return{h:n+e+(s/2**32|0)|0,l:s|0}}const yt={fromBig:Bs,split:As,toBig:ja,shrSH:Ga,shrSL:Za,rotrSH:Ya,rotrSL:Ja,rotrBH:Xa,rotrBL:Qa,rotr32H:tc,rotr32L:ec,rotlSH:Rs,rotlSL:Ts,rotlBH:Ms,rotlBL:Ps,add:rc,add3L:(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),add3H:(n,t,e,r)=>t+e+r+(n/2**32|0)|0,add4L:(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),add4H:(n,t,e,r,s)=>t+e+r+s+(n/2**32|0)|0,add5H:(n,t,e,r,s,i)=>t+e+r+s+i+(n/2**32|0)|0,add5L:(n,t,e,r,s)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(s>>>0)},[nc,ic]=yt.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))),Ye=new Uint32Array(80),Je=new Uint32Array(80);class sc extends _s{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:s,Ch:i,Cl:o,Dh:a,Dl:h,Eh:g,El:w,Fh:k,Fl:M,Gh:R,Gl:C,Hh:B,Hl:T}=this;return[t,e,r,s,i,o,a,h,g,w,k,M,R,C,B,T]}set(t,e,r,s,i,o,a,h,g,w,k,M,R,C,B,T){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=h|0,this.Eh=g|0,this.El=w|0,this.Fh=k|0,this.Fl=M|0,this.Gh=R|0,this.Gl=C|0,this.Hh=B|0,this.Hl=T|0}process(t,e){for(let q=0;q<16;q++,e+=4)Ye[q]=t.getUint32(e),Je[q]=t.getUint32(e+=4);for(let q=16;q<80;q++){const X=Ye[q-15]|0,D=Je[q-15]|0,F=yt.rotrSH(X,D,1)^yt.rotrSH(X,D,8)^yt.shrSH(X,D,7),Y=yt.rotrSL(X,D,1)^yt.rotrSL(X,D,8)^yt.shrSL(X,D,7),Z=Ye[q-2]|0,J=Je[q-2]|0,K=yt.rotrSH(Z,J,19)^yt.rotrBH(Z,J,61)^yt.shrSH(Z,J,6),V=yt.rotrSL(Z,J,19)^yt.rotrBL(Z,J,61)^yt.shrSL(Z,J,6),Q=yt.add4L(Y,V,Je[q-7],Je[q-16]),x=yt.add4H(Q,F,K,Ye[q-7],Ye[q-16]);Ye[q]=x|0,Je[q]=Q|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:h,Dh:g,Dl:w,Eh:k,El:M,Fh:R,Fl:C,Gh:B,Gl:T,Hh:O,Hl:$}=this;for(let q=0;q<80;q++){const X=yt.rotrSH(k,M,14)^yt.rotrSH(k,M,18)^yt.rotrBH(k,M,41),D=yt.rotrSL(k,M,14)^yt.rotrSL(k,M,18)^yt.rotrBL(k,M,41),F=k&R^~k&B,Y=M&C^~M&T,Z=yt.add5L($,D,Y,ic[q],Je[q]),J=yt.add5H(Z,O,X,F,nc[q],Ye[q]),K=Z|0,V=yt.rotrSH(r,s,28)^yt.rotrBH(r,s,34)^yt.rotrBH(r,s,39),Q=yt.rotrSL(r,s,28)^yt.rotrBL(r,s,34)^yt.rotrBL(r,s,39),x=r&i^r&a^i&a,u=s&o^s&h^o&h;O=B|0,$=T|0,B=R|0,T=C|0,R=k|0,C=M|0,{h:k,l:M}=yt.add(g|0,w|0,J|0,K|0),g=a|0,w=h|0,a=i|0,h=o|0,i=r|0,o=s|0;const p=yt.add3L(K,Q,u);r=yt.add3H(p,J,V,x),s=p|0}({h:r,l:s}=yt.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=yt.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:h}=yt.add(this.Ch|0,this.Cl|0,a|0,h|0),{h:g,l:w}=yt.add(this.Dh|0,this.Dl|0,g|0,w|0),{h:k,l:M}=yt.add(this.Eh|0,this.El|0,k|0,M|0),{h:R,l:C}=yt.add(this.Fh|0,this.Fl|0,R|0,C|0),{h:B,l:T}=yt.add(this.Gh|0,this.Gl|0,B|0,T|0),{h:O,l:$}=yt.add(this.Hh|0,this.Hl|0,O|0,$|0),this.set(r,s,i,o,a,h,g,w,k,M,R,C,B,T,O,$)}roundClean(){Ye.fill(0),Je.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 oc=$n(()=>new sc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Cs=BigInt(0),sn=BigInt(1),ac=BigInt(2);function sr(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function qr(n){if(!sr(n))throw new Error("Uint8Array expected")}const cc=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function or(n){qr(n);let t="";for(let e=0;e<n.length;e++)t+=cc[n[e]];return t}function Ls(n){const t=n.toString(16);return t.length&1?`0${t}`:t}function Vn(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}const He={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Os(n){if(n>=He._0&&n<=He._9)return n-He._0;if(n>=He._A&&n<=He._F)return n-(He._A-10);if(n>=He._a&&n<=He._f)return n-(He._a-10)}function vr(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("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(e);for(let s=0,i=0;s<e;s++,i+=2){const o=Os(n.charCodeAt(i)),a=Os(n.charCodeAt(i+1));if(o===void 0||a===void 0){const h=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+h+'" at index '+i)}r[s]=o*16+a}return r}function ar(n){return Vn(or(n))}function Sr(n){return qr(n),Vn(or(Uint8Array.from(n).reverse()))}function xr(n,t){return vr(n.toString(16).padStart(t*2,"0"))}function Kr(n,t){return xr(n,t).reverse()}function uc(n){return vr(Ls(n))}function de(n,t,e){let r;if(typeof t=="string")try{r=vr(t)}catch(i){throw new Error(`${n} must be valid hex string, got "${t}". Cause: ${i}`)}else if(sr(t))r=Uint8Array.from(t);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof e=="number"&&s!==e)throw new Error(`${n} expected ${e} bytes, got ${s}`);return r}function cr(...n){let t=0;for(let r=0;r<n.length;r++){const s=n[r];qr(s),t+=s.length}const e=new Uint8Array(t);for(let r=0,s=0;r<n.length;r++){const i=n[r];e.set(i,s),s+=i.length}return e}function lc(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 fc(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function hc(n){let t;for(t=0;n>Cs;n>>=sn,t+=1);return t}function dc(n,t){return n>>BigInt(t)&sn}function pc(n,t,e){return n|(e?sn:Cs)<<BigInt(t)}const jn=n=>(ac<<BigInt(n-1))-sn,Gn=n=>new Uint8Array(n),Us=n=>Uint8Array.from(n);function Ns(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=Gn(n),s=Gn(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...k)=>e(s,r,...k),h=(k=Gn())=>{s=a(Us([0]),k),r=a(),k.length!==0&&(s=a(Us([1]),k),r=a())},g=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let k=0;const M=[];for(;k<t;){r=a();const R=r.slice();M.push(R),k+=r.length}return cr(...M)};return(k,M)=>{o(),h(k);let R;for(;!(R=M(g()));)h();return o(),R}}const gc={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"||sr(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 Ir(n,t,e={}){const r=(s,i,o)=>{const a=gc[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const h=n[s];if(!(o&&h===void 0)&&!a(h,n))throw new Error(`Invalid param ${String(s)}=${h} (${typeof h}), expected ${i}`)};for(const[s,i]of Object.entries(t))r(s,i,!1);for(const[s,i]of Object.entries(e))r(s,i,!0);return n}const yc=Object.freeze(Object.defineProperty({__proto__:null,abytes:qr,bitGet:dc,bitLen:hc,bitMask:jn,bitSet:pc,bytesToHex:or,bytesToNumberBE:ar,bytesToNumberLE:Sr,concatBytes:cr,createHmacDrbg:Ns,ensureBytes:de,equalBytes:lc,hexToBytes:vr,hexToNumber:Vn,isBytes:sr,numberToBytesBE:xr,numberToBytesLE:Kr,numberToHexUnpadded:Ls,numberToVarBytesBE:uc,utf8ToBytes:fc,validateObject:Ir},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const pe=BigInt(0),$t=BigInt(1),ur=BigInt(2),mc=BigInt(3),Zn=BigInt(4),Fs=BigInt(5),zs=BigInt(8);BigInt(9),BigInt(16);function Wt(n,t){const e=n%t;return e>=pe?e:t+e}function wc(n,t,e){if(e<=pe||t<pe)throw new Error("Expected power/modulo > 0");if(e===$t)return pe;let r=$t;for(;t>pe;)t&$t&&(r=r*n%e),n=n*n%e,t>>=$t;return r}function jt(n,t,e){let r=n;for(;t-- >pe;)r*=r,r%=e;return r}function Yn(n,t){if(n===pe||t<=pe)throw new Error(`invert: expected positive integers, got n=${n} mod=${t}`);let e=Wt(n,t),r=t,s=pe,i=$t;for(;e!==pe;){const a=r/e,h=r%e,g=s-i*a;r=e,e=h,s=i,i=g}if(r!==$t)throw new Error("invert: does not exist");return Wt(s,t)}function bc(n){const t=(n-$t)/ur;let e,r,s;for(e=n-$t,r=0;e%ur===pe;e/=ur,r++);for(s=ur;s<n&&wc(s,t,n)!==n-$t;s++);if(r===1){const o=(n+$t)/Zn;return function(h,g){const w=h.pow(g,o);if(!h.eql(h.sqr(w),g))throw new Error("Cannot find square root");return w}}const i=(e+$t)/ur;return function(a,h){if(a.pow(h,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let g=r,w=a.pow(a.mul(a.ONE,s),e),k=a.pow(h,i),M=a.pow(h,e);for(;!a.eql(M,a.ONE);){if(a.eql(M,a.ZERO))return a.ZERO;let R=1;for(let B=a.sqr(M);R<g&&!a.eql(B,a.ONE);R++)B=a.sqr(B);const C=a.pow(w,$t<<BigInt(g-R-1));w=a.sqr(C),k=a.mul(k,C),M=a.mul(M,w),g=R}return k}}function kc(n){if(n%Zn===mc){const t=(n+$t)/Zn;return function(r,s){const i=r.pow(s,t);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%zs===Fs){const t=(n-Fs)/zs;return function(r,s){const i=r.mul(s,ur),o=r.pow(i,t),a=r.mul(s,o),h=r.mul(r.mul(a,ur),o),g=r.mul(a,r.sub(h,r.ONE));if(!r.eql(r.sqr(g),s))throw new Error("Cannot find square root");return g}}return bc(n)}const vc=(n,t)=>(Wt(n,t)&$t)===$t,Sc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xc(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Sc.reduce((r,s)=>(r[s]="function",r),t);return Ir(n,e)}function Ic(n,t,e){if(e<pe)throw new Error("Expected power > 0");if(e===pe)return n.ONE;if(e===$t)return t;let r=n.ONE,s=t;for(;e>pe;)e&$t&&(r=n.mul(r,s)),s=n.sqr(s),e>>=$t;return r}function Ec(n,t){const e=new Array(t.length),r=t.reduce((i,o,a)=>n.is0(o)?i:(e[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return t.reduceRight((i,o,a)=>n.is0(o)?i:(e[a]=n.mul(i,e[a]),n.mul(i,o)),s),e}function qs(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function Ks(n,t,e=!1,r={}){if(n<=pe)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=qs(n,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=kc(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:jn(s),ZERO:pe,ONE:$t,create:h=>Wt(h,n),isValid:h=>{if(typeof h!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof h}`);return pe<=h&&h<n},is0:h=>h===pe,isOdd:h=>(h&$t)===$t,neg:h=>Wt(-h,n),eql:(h,g)=>h===g,sqr:h=>Wt(h*h,n),add:(h,g)=>Wt(h+g,n),sub:(h,g)=>Wt(h-g,n),mul:(h,g)=>Wt(h*g,n),pow:(h,g)=>Ic(a,h,g),div:(h,g)=>Wt(h*Yn(g,n),n),sqrN:h=>h*h,addN:(h,g)=>h+g,subN:(h,g)=>h-g,mulN:(h,g)=>h*g,inv:h=>Yn(h,n),sqrt:r.sqrt||(h=>o(a,h)),invertBatch:h=>Ec(a,h),cmov:(h,g,w)=>w?g:h,toBytes:h=>e?Kr(h,i):xr(h,i),fromBytes:h=>{if(h.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${h.length}`);return e?Sr(h):ar(h)}});return Object.freeze(a)}function Ws(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 Ds(n){const t=Ws(n);return t+Math.ceil(t/2)}function _c(n,t,e=!1){const r=n.length,s=Ws(t),i=Ds(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=e?ar(n):Sr(n),a=Wt(o,t-$t)+$t;return e?Kr(a,s):xr(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Bc=BigInt(0),Jn=BigInt(1);function $s(n,t){const e=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(t/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:e,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>Bc;)i&Jn&&(o=o.add(a)),a=a.double(),i>>=Jn;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),h=[];let g=s,w=g;for(let k=0;k<o;k++){w=g,h.push(w);for(let M=1;M<a;M++)w=w.add(g),h.push(w);g=w.double()}return h},wNAF(s,i,o){const{windows:a,windowSize:h}=r(s);let g=n.ZERO,w=n.BASE;const k=BigInt(2**s-1),M=2**s,R=BigInt(s);for(let C=0;C<a;C++){const B=C*h;let T=Number(o&k);o>>=R,T>h&&(T-=M,o+=Jn);const O=B,$=B+Math.abs(T)-1,q=C%2!==0,X=T<0;T===0?w=w.add(e(q,i[O])):g=g.add(e(X,i[$]))}return{p:g,f:w}},wNAFCached(s,i,o,a){const h=s._WINDOW_SIZE||1;let g=i.get(s);return g||(g=this.precomputeWindow(s,h),h!==1&&i.set(s,a(g))),this.wNAF(h,g,o)}}}function Xn(n){return xc(n.Fp),Ir(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...qs(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Me=BigInt(0),Ae=BigInt(1),on=BigInt(2),Ac=BigInt(8),Rc={zip215:!0};function Tc(n){const t=Xn(n);return Ir(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Mc(n){const t=Tc(n),{Fp:e,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h}=t,g=on<<BigInt(a*8)-Ae,w=e.create,k=t.uvRatio||((S,I)=>{try{return{isValid:!0,value:e.sqrt(S*e.inv(I))}}catch{return{isValid:!1,value:Me}}}),M=t.adjustScalarBytes||(S=>S),R=t.domain||((S,I,L)=>{if(I.length||L)throw new Error("Contexts/pre-hash are not supported");return S}),C=S=>typeof S=="bigint"&&Me<S,B=(S,I)=>C(S)&&C(I)&&S<I,T=S=>S===Me||B(S,g);function O(S,I){if(B(S,I))return S;throw new Error(`Expected valid scalar < ${I}, got ${typeof S} ${S}`)}function $(S){return S===Me?S:O(S,r)}const q=new Map;function X(S){if(!(S instanceof D))throw new Error("ExtendedPoint expected")}class D{constructor(I,L,v,c){if(this.ex=I,this.ey=L,this.ez=v,this.et=c,!T(I))throw new Error("x required");if(!T(L))throw new Error("y required");if(!T(v))throw new Error("z required");if(!T(c))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof D)throw new Error("extended point not allowed");const{x:L,y:v}=I||{};if(!T(L)||!T(v))throw new Error("invalid affine point");return new D(L,v,Ae,w(L*v))}static normalizeZ(I){const L=e.invertBatch(I.map(v=>v.ez));return I.map((v,c)=>v.toAffine(L[c])).map(D.fromAffine)}_setWindowSize(I){this._WINDOW_SIZE=I,q.delete(this)}assertValidity(){const{a:I,d:L}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:v,ey:c,ez:l,et:y}=this,A=w(v*v),U=w(c*c),j=w(l*l),nt=w(j*j),ct=w(A*I),_t=w(j*w(ct+U)),pt=w(nt+w(L*w(A*U)));if(_t!==pt)throw new Error("bad point: equation left != right (1)");const vt=w(v*c),At=w(l*y);if(vt!==At)throw new Error("bad point: equation left != right (2)")}equals(I){X(I);const{ex:L,ey:v,ez:c}=this,{ex:l,ey:y,ez:A}=I,U=w(L*A),j=w(l*c),nt=w(v*A),ct=w(y*c);return U===j&&nt===ct}is0(){return this.equals(D.ZERO)}negate(){return new D(w(-this.ex),this.ey,this.ez,w(-this.et))}double(){const{a:I}=t,{ex:L,ey:v,ez:c}=this,l=w(L*L),y=w(v*v),A=w(on*w(c*c)),U=w(I*l),j=L+v,nt=w(w(j*j)-l-y),ct=U+y,_t=ct-A,pt=U-y,vt=w(nt*_t),At=w(ct*pt),St=w(nt*pt),Tt=w(_t*ct);return new D(vt,At,Tt,St)}add(I){X(I);const{a:L,d:v}=t,{ex:c,ey:l,ez:y,et:A}=this,{ex:U,ey:j,ez:nt,et:ct}=I;if(L===BigInt(-1)){const xe=w((l-c)*(j+U)),Ot=w((l+c)*(j-U)),Ft=w(Ot-xe);if(Ft===Me)return this.double();const Be=w(y*on*ct),qt=w(A*on*nt),b=qt+Be,f=Ot+xe,d=qt-Be,_=w(b*Ft),N=w(f*d),z=w(b*d),G=w(Ft*f);return new D(_,N,G,z)}const _t=w(c*U),pt=w(l*j),vt=w(A*v*ct),At=w(y*nt),St=w((c+l)*(U+j)-_t-pt),Tt=At-vt,$e=At+vt,Ct=w(pt-L*_t),Dt=w(St*Tt),Ur=w($e*Ct),zt=w(St*Ct),Lt=w(Tt*$e);return new D(Dt,Ur,Lt,zt)}subtract(I){return this.add(I.negate())}wNAF(I){return Z.wNAFCached(this,q,I,D.normalizeZ)}multiply(I){const{p:L,f:v}=this.wNAF(O(I,r));return D.normalizeZ([L,v])[0]}multiplyUnsafe(I){let L=$(I);return L===Me?Y:this.equals(Y)||L===Ae?this:this.equals(F)?this.wNAF(L).p:Z.unsafeLadder(this,L)}isSmallOrder(){return this.multiplyUnsafe(h).is0()}isTorsionFree(){return Z.unsafeLadder(this,r).is0()}toAffine(I){const{ex:L,ey:v,ez:c}=this,l=this.is0();I==null&&(I=l?Ac:e.inv(c));const y=w(L*I),A=w(v*I),U=w(c*I);if(l)return{x:Me,y:Ae};if(U!==Ae)throw new Error("invZ was invalid");return{x:y,y:A}}clearCofactor(){const{h:I}=t;return I===Ae?this:this.multiplyUnsafe(I)}static fromHex(I,L=!1){const{d:v,a:c}=t,l=e.BYTES;I=de("pointHex",I,l);const y=I.slice(),A=I[l-1];y[l-1]=A&-129;const U=Sr(y);U===Me||(L?O(U,g):O(U,e.ORDER));const j=w(U*U),nt=w(j-Ae),ct=w(v*j-c);let{isValid:_t,value:pt}=k(nt,ct);if(!_t)throw new Error("Point.fromHex: invalid y coordinate");const vt=(pt&Ae)===Ae,At=(A&128)!==0;if(!L&&pt===Me&&At)throw new Error("Point.fromHex: x=0 and x_0=1");return At!==vt&&(pt=w(-pt)),D.fromAffine({x:pt,y:U})}static fromPrivateKey(I){return V(I).point}toRawBytes(){const{x:I,y:L}=this.toAffine(),v=Kr(L,e.BYTES);return v[v.length-1]|=I&Ae?128:0,v}toHex(){return or(this.toRawBytes())}}D.BASE=new D(t.Gx,t.Gy,Ae,w(t.Gx*t.Gy)),D.ZERO=new D(Me,Ae,Ae,Me);const{BASE:F,ZERO:Y}=D,Z=$s(D,a*8);function J(S){return Wt(S,r)}function K(S){return J(Sr(S))}function V(S){const I=a;S=de("private key",S,I);const L=de("hashed private key",i(S),2*I),v=M(L.slice(0,I)),c=L.slice(I,2*I),l=K(v),y=F.multiply(l),A=y.toRawBytes();return{head:v,prefix:c,scalar:l,point:y,pointBytes:A}}function Q(S){return V(S).pointBytes}function x(S=new Uint8Array,...I){const L=cr(...I);return K(i(R(L,de("context",S),!!s)))}function u(S,I,L={}){S=de("message",S),s&&(S=s(S));const{prefix:v,scalar:c,pointBytes:l}=V(I),y=x(L.context,v,S),A=F.multiply(y).toRawBytes(),U=x(L.context,A,l,S),j=J(y+U*c);$(j);const nt=cr(A,Kr(j,e.BYTES));return de("result",nt,a*2)}const p=Rc;function m(S,I,L,v=p){const{context:c,zip215:l}=v,y=e.BYTES;S=de("signature",S,2*y),I=de("message",I),s&&(I=s(I));const A=Sr(S.slice(y,2*y));let U,j,nt;try{U=D.fromHex(L,l),j=D.fromHex(S.slice(0,y),l),nt=F.multiplyUnsafe(A)}catch{return!1}if(!l&&U.isSmallOrder())return!1;const ct=x(c,j.toRawBytes(),U.toRawBytes(),I);return j.add(U.multiplyUnsafe(ct)).subtract(nt).clearCofactor().equals(D.ZERO)}return F._setWindowSize(8),{CURVE:t,getPublicKey:Q,sign:u,verify:m,ExtendedPoint:D,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>o(e.BYTES),precompute(S=8,I=D.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Hs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Pc=BigInt(1),Vs=BigInt(2);BigInt(3);const Cc=BigInt(5),Lc=BigInt(8);function Oc(n){const t=BigInt(10),e=BigInt(20),r=BigInt(40),s=BigInt(80),i=Qn,a=n*n%i*n%i,h=jt(a,Vs,i)*a%i,g=jt(h,Pc,i)*n%i,w=jt(g,Cc,i)*g%i,k=jt(w,t,i)*w%i,M=jt(k,e,i)*k%i,R=jt(M,r,i)*M%i,C=jt(R,s,i)*R%i,B=jt(C,s,i)*R%i,T=jt(B,t,i)*w%i;return{pow_p_5_8:jt(T,Vs,i)*n%i,b2:a}}function Uc(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function Nc(n,t){const e=Qn,r=Wt(t*t*t,e),s=Wt(r*r*t,e),i=Oc(n*s).pow_p_5_8;let o=Wt(n*r*i,e);const a=Wt(t*o*o,e),h=o,g=Wt(o*Hs,e),w=a===n,k=a===Wt(-n,e),M=a===Wt(-n*Hs,e);return w&&(o=h),(k||M)&&(o=g),vc(o,e)&&(o=Wt(-o,e)),{isValid:w||k,value:o}}const Fc=Ks(Qn,void 0,!0),zc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Fc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Lc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:oc,randomBytes:Es,adjustScalarBytes:Uc,uvRatio:Nc},Er=Mc(zc);var an={exports:{}};const qc=Fn(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Kc=an.exports,js;function Gs(){return js||(js=1,function(n){(function(t,e){function r(x,u){if(!x)throw new Error(u||"Assertion failed")}function s(x,u){x.super_=u;var p=function(){};p.prototype=u.prototype,x.prototype=new p,x.prototype.constructor=x}function i(x,u,p){if(i.isBN(x))return x;this.negative=0,this.words=null,this.length=0,this.red=null,x!==null&&((u==="le"||u==="be")&&(p=u,u=10),this._init(x||0,u||10,p||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=qc.Buffer}catch{}i.isBN=function(u){return u instanceof i?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===i.wordSize&&Array.isArray(u.words)},i.max=function(u,p){return u.cmp(p)>0?u:p},i.min=function(u,p){return u.cmp(p)<0?u:p},i.prototype._init=function(u,p,m){if(typeof u=="number")return this._initNumber(u,p,m);if(typeof u=="object")return this._initArray(u,p,m);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),u=u.toString().replace(/\s+/g,"");var E=0;u[0]==="-"&&(E++,this.negative=1),E<u.length&&(p===16?this._parseHex(u,E,m):(this._parseBase(u,p,E),m==="le"&&this._initArray(this.toArray(),p,m)))},i.prototype._initNumber=function(u,p,m){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(r(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),m==="le"&&this._initArray(this.toArray(),p,m)},i.prototype._initArray=function(u,p,m){if(r(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var S,I,L=0;if(m==="be")for(E=u.length-1,S=0;E>=0;E-=3)I=u[E]|u[E-1]<<8|u[E-2]<<16,this.words[S]|=I<<L&67108863,this.words[S+1]=I>>>26-L&67108863,L+=24,L>=26&&(L-=26,S++);else if(m==="le")for(E=0,S=0;E<u.length;E+=3)I=u[E]|u[E+1]<<8|u[E+2]<<16,this.words[S]|=I<<L&67108863,this.words[S+1]=I>>>26-L&67108863,L+=24,L>=26&&(L-=26,S++);return this._strip()};function a(x,u){var p=x.charCodeAt(u);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+x)}function h(x,u,p){var m=a(x,p);return p-1>=u&&(m|=a(x,p-1)<<4),m}i.prototype._parseHex=function(u,p,m){this.length=Math.ceil((u.length-p)/6),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var S=0,I=0,L;if(m==="be")for(E=u.length-1;E>=p;E-=2)L=h(u,p,E)<<S,this.words[I]|=L&67108863,S>=18?(S-=18,I+=1,this.words[I]|=L>>>26):S+=8;else{var v=u.length-p;for(E=v%2===0?p+1:p;E<u.length;E+=2)L=h(u,p,E)<<S,this.words[I]|=L&67108863,S>=18?(S-=18,I+=1,this.words[I]|=L>>>26):S+=8}this._strip()};function g(x,u,p,m){for(var E=0,S=0,I=Math.min(x.length,p),L=u;L<I;L++){var v=x.charCodeAt(L)-48;E*=m,v>=49?S=v-49+10:v>=17?S=v-17+10:S=v,r(v>=0&&S<m,"Invalid character"),E+=S}return E}i.prototype._parseBase=function(u,p,m){this.words=[0],this.length=1;for(var E=0,S=1;S<=67108863;S*=p)E++;E--,S=S/p|0;for(var I=u.length-m,L=I%E,v=Math.min(I,I-L)+m,c=0,l=m;l<v;l+=E)c=g(u,l,l+E,p),this.imuln(S),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(L!==0){var y=1;for(c=g(u,l,u.length,p),l=0;l<L;l++)y*=p;this.imuln(y),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(u){u.words=new Array(this.length);for(var p=0;p<this.length;p++)u.words[p]=this.words[p];u.length=this.length,u.negative=this.negative,u.red=this.red};function w(x,u){x.words=u.words,x.length=u.length,x.negative=u.negative,x.red=u.red}if(i.prototype._move=function(u){w(u,this)},i.prototype.clone=function(){var u=new i(null);return this.copy(u),u},i.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=k}catch{i.prototype.inspect=k}else i.prototype.inspect=k;function k(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var M=["","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"],R=[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],C=[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];i.prototype.toString=function(u,p){u=u||10,p=p|0||1;var m;if(u===16||u==="hex"){m="";for(var E=0,S=0,I=0;I<this.length;I++){var L=this.words[I],v=((L<<E|S)&16777215).toString(16);S=L>>>24-E&16777215,E+=2,E>=26&&(E-=26,I--),S!==0||I!==this.length-1?m=M[6-v.length]+v+m:m=v+m}for(S!==0&&(m=S.toString(16)+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(u===(u|0)&&u>=2&&u<=36){var c=R[u],l=C[u];m="";var y=this.clone();for(y.negative=0;!y.isZero();){var A=y.modrn(l).toString(u);y=y.idivn(l),y.isZero()?m=A+m:m=M[c-A.length]+A+m}for(this.isZero()&&(m="0"+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(u,p){return this.toArrayLike(o,u,p)}),i.prototype.toArray=function(u,p){return this.toArrayLike(Array,u,p)};var B=function(u,p){return u.allocUnsafe?u.allocUnsafe(p):new u(p)};i.prototype.toArrayLike=function(u,p,m){this._strip();var E=this.byteLength(),S=m||Math.max(1,E);r(E<=S,"byte array longer than desired length"),r(S>0,"Requested array length <= 0");var I=B(u,S),L=p==="le"?"LE":"BE";return this["_toArrayLike"+L](I,E),I},i.prototype._toArrayLikeLE=function(u,p){for(var m=0,E=0,S=0,I=0;S<this.length;S++){var L=this.words[S]<<I|E;u[m++]=L&255,m<u.length&&(u[m++]=L>>8&255),m<u.length&&(u[m++]=L>>16&255),I===6?(m<u.length&&(u[m++]=L>>24&255),E=0,I=0):(E=L>>>24,I+=2)}if(m<u.length)for(u[m++]=E;m<u.length;)u[m++]=0},i.prototype._toArrayLikeBE=function(u,p){for(var m=u.length-1,E=0,S=0,I=0;S<this.length;S++){var L=this.words[S]<<I|E;u[m--]=L&255,m>=0&&(u[m--]=L>>8&255),m>=0&&(u[m--]=L>>16&255),I===6?(m>=0&&(u[m--]=L>>24&255),E=0,I=0):(E=L>>>24,I+=2)}if(m>=0)for(u[m--]=E;m>=0;)u[m--]=0},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var p=u,m=0;return p>=4096&&(m+=13,p>>>=13),p>=64&&(m+=7,p>>>=7),p>=8&&(m+=4,p>>>=4),p>=2&&(m+=2,p>>>=2),m+p},i.prototype._zeroBits=function(u){if(u===0)return 26;var p=u,m=0;return p&8191||(m+=13,p>>>=13),p&127||(m+=7,p>>>=7),p&15||(m+=4,p>>>=4),p&3||(m+=2,p>>>=2),p&1||m++,m},i.prototype.bitLength=function(){var u=this.words[this.length-1],p=this._countBits(u);return(this.length-1)*26+p};function T(x){for(var u=new Array(x.bitLength()),p=0;p<u.length;p++){var m=p/26|0,E=p%26;u[p]=x.words[m]>>>E&1}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,p=0;p<this.length;p++){var m=this._zeroBits(this.words[p]);if(u+=m,m!==26)break}return u},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},i.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var p=0;p<u.length;p++)this.words[p]=this.words[p]|u.words[p];return this._strip()},i.prototype.ior=function(u){return r((this.negative|u.negative)===0),this.iuor(u)},i.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},i.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},i.prototype.iuand=function(u){var p;this.length>u.length?p=u:p=this;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]&u.words[m];return this.length=p.length,this._strip()},i.prototype.iand=function(u){return r((this.negative|u.negative)===0),this.iuand(u)},i.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},i.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},i.prototype.iuxor=function(u){var p,m;this.length>u.length?(p=this,m=u):(p=u,m=this);for(var E=0;E<m.length;E++)this.words[E]=p.words[E]^m.words[E];if(this!==p)for(;E<p.length;E++)this.words[E]=p.words[E];return this.length=p.length,this._strip()},i.prototype.ixor=function(u){return r((this.negative|u.negative)===0),this.iuxor(u)},i.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},i.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},i.prototype.inotn=function(u){r(typeof u=="number"&&u>=0);var p=Math.ceil(u/26)|0,m=u%26;this._expand(p),m>0&&p--;for(var E=0;E<p;E++)this.words[E]=~this.words[E]&67108863;return m>0&&(this.words[E]=~this.words[E]&67108863>>26-m),this._strip()},i.prototype.notn=function(u){return this.clone().inotn(u)},i.prototype.setn=function(u,p){r(typeof u=="number"&&u>=0);var m=u/26|0,E=u%26;return this._expand(m+1),p?this.words[m]=this.words[m]|1<<E:this.words[m]=this.words[m]&~(1<<E),this._strip()},i.prototype.iadd=function(u){var p;if(this.negative!==0&&u.negative===0)return this.negative=0,p=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,p=this.isub(u),u.negative=1,p._normSign();var m,E;this.length>u.length?(m=this,E=u):(m=u,E=this);for(var S=0,I=0;I<E.length;I++)p=(m.words[I]|0)+(E.words[I]|0)+S,this.words[I]=p&67108863,S=p>>>26;for(;S!==0&&I<m.length;I++)p=(m.words[I]|0)+S,this.words[I]=p&67108863,S=p>>>26;if(this.length=m.length,S!==0)this.words[this.length]=S,this.length++;else if(m!==this)for(;I<m.length;I++)this.words[I]=m.words[I];return this},i.prototype.add=function(u){var p;return u.negative!==0&&this.negative===0?(u.negative=0,p=this.sub(u),u.negative^=1,p):u.negative===0&&this.negative!==0?(this.negative=0,p=u.sub(this),this.negative=1,p):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},i.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var p=this.iadd(u);return u.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var m=this.cmp(u);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var E,S;m>0?(E=this,S=u):(E=u,S=this);for(var I=0,L=0;L<S.length;L++)p=(E.words[L]|0)-(S.words[L]|0)+I,I=p>>26,this.words[L]=p&67108863;for(;I!==0&&L<E.length;L++)p=(E.words[L]|0)+I,I=p>>26,this.words[L]=p&67108863;if(I===0&&L<E.length&&E!==this)for(;L<E.length;L++)this.words[L]=E.words[L];return this.length=Math.max(this.length,L),E!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function O(x,u,p){p.negative=u.negative^x.negative;var m=x.length+u.length|0;p.length=m,m=m-1|0;var E=x.words[0]|0,S=u.words[0]|0,I=E*S,L=I&67108863,v=I/67108864|0;p.words[0]=L;for(var c=1;c<m;c++){for(var l=v>>>26,y=v&67108863,A=Math.min(c,u.length-1),U=Math.max(0,c-x.length+1);U<=A;U++){var j=c-U|0;E=x.words[j]|0,S=u.words[U]|0,I=E*S+y,l+=I/67108864|0,y=I&67108863}p.words[c]=y|0,v=l|0}return v!==0?p.words[c]=v|0:p.length--,p._strip()}var $=function(u,p,m){var E=u.words,S=p.words,I=m.words,L=0,v,c,l,y=E[0]|0,A=y&8191,U=y>>>13,j=E[1]|0,nt=j&8191,ct=j>>>13,_t=E[2]|0,pt=_t&8191,vt=_t>>>13,At=E[3]|0,St=At&8191,Tt=At>>>13,$e=E[4]|0,Ct=$e&8191,Dt=$e>>>13,Ur=E[5]|0,zt=Ur&8191,Lt=Ur>>>13,xe=E[6]|0,Ot=xe&8191,Ft=xe>>>13,Be=E[7]|0,qt=Be&8191,b=Be>>>13,f=E[8]|0,d=f&8191,_=f>>>13,N=E[9]|0,z=N&8191,G=N>>>13,bt=S[0]|0,gt=bt&8191,dt=bt>>>13,Kt=S[1]|0,ht=Kt&8191,Zt=Kt>>>13,Aa=S[2]|0,Yt=Aa&8191,Jt=Aa>>>13,Ra=S[3]|0,Xt=Ra&8191,Qt=Ra>>>13,Ta=S[4]|0,te=Ta&8191,ee=Ta>>>13,Ma=S[5]|0,re=Ma&8191,ne=Ma>>>13,Pa=S[6]|0,ie=Pa&8191,se=Pa>>>13,Ca=S[7]|0,oe=Ca&8191,ae=Ca>>>13,La=S[8]|0,ce=La&8191,ue=La>>>13,Oa=S[9]|0,le=Oa&8191,fe=Oa>>>13;m.negative=u.negative^p.negative,m.length=19,v=Math.imul(A,gt),c=Math.imul(A,dt),c=c+Math.imul(U,gt)|0,l=Math.imul(U,dt);var Xi=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(Xi>>>26)|0,Xi&=67108863,v=Math.imul(nt,gt),c=Math.imul(nt,dt),c=c+Math.imul(ct,gt)|0,l=Math.imul(ct,dt),v=v+Math.imul(A,ht)|0,c=c+Math.imul(A,Zt)|0,c=c+Math.imul(U,ht)|0,l=l+Math.imul(U,Zt)|0;var Qi=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,v=Math.imul(pt,gt),c=Math.imul(pt,dt),c=c+Math.imul(vt,gt)|0,l=Math.imul(vt,dt),v=v+Math.imul(nt,ht)|0,c=c+Math.imul(nt,Zt)|0,c=c+Math.imul(ct,ht)|0,l=l+Math.imul(ct,Zt)|0,v=v+Math.imul(A,Yt)|0,c=c+Math.imul(A,Jt)|0,c=c+Math.imul(U,Yt)|0,l=l+Math.imul(U,Jt)|0;var ts=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(ts>>>26)|0,ts&=67108863,v=Math.imul(St,gt),c=Math.imul(St,dt),c=c+Math.imul(Tt,gt)|0,l=Math.imul(Tt,dt),v=v+Math.imul(pt,ht)|0,c=c+Math.imul(pt,Zt)|0,c=c+Math.imul(vt,ht)|0,l=l+Math.imul(vt,Zt)|0,v=v+Math.imul(nt,Yt)|0,c=c+Math.imul(nt,Jt)|0,c=c+Math.imul(ct,Yt)|0,l=l+Math.imul(ct,Jt)|0,v=v+Math.imul(A,Xt)|0,c=c+Math.imul(A,Qt)|0,c=c+Math.imul(U,Xt)|0,l=l+Math.imul(U,Qt)|0;var es=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(es>>>26)|0,es&=67108863,v=Math.imul(Ct,gt),c=Math.imul(Ct,dt),c=c+Math.imul(Dt,gt)|0,l=Math.imul(Dt,dt),v=v+Math.imul(St,ht)|0,c=c+Math.imul(St,Zt)|0,c=c+Math.imul(Tt,ht)|0,l=l+Math.imul(Tt,Zt)|0,v=v+Math.imul(pt,Yt)|0,c=c+Math.imul(pt,Jt)|0,c=c+Math.imul(vt,Yt)|0,l=l+Math.imul(vt,Jt)|0,v=v+Math.imul(nt,Xt)|0,c=c+Math.imul(nt,Qt)|0,c=c+Math.imul(ct,Xt)|0,l=l+Math.imul(ct,Qt)|0,v=v+Math.imul(A,te)|0,c=c+Math.imul(A,ee)|0,c=c+Math.imul(U,te)|0,l=l+Math.imul(U,ee)|0;var rs=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(rs>>>26)|0,rs&=67108863,v=Math.imul(zt,gt),c=Math.imul(zt,dt),c=c+Math.imul(Lt,gt)|0,l=Math.imul(Lt,dt),v=v+Math.imul(Ct,ht)|0,c=c+Math.imul(Ct,Zt)|0,c=c+Math.imul(Dt,ht)|0,l=l+Math.imul(Dt,Zt)|0,v=v+Math.imul(St,Yt)|0,c=c+Math.imul(St,Jt)|0,c=c+Math.imul(Tt,Yt)|0,l=l+Math.imul(Tt,Jt)|0,v=v+Math.imul(pt,Xt)|0,c=c+Math.imul(pt,Qt)|0,c=c+Math.imul(vt,Xt)|0,l=l+Math.imul(vt,Qt)|0,v=v+Math.imul(nt,te)|0,c=c+Math.imul(nt,ee)|0,c=c+Math.imul(ct,te)|0,l=l+Math.imul(ct,ee)|0,v=v+Math.imul(A,re)|0,c=c+Math.imul(A,ne)|0,c=c+Math.imul(U,re)|0,l=l+Math.imul(U,ne)|0;var ns=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(ns>>>26)|0,ns&=67108863,v=Math.imul(Ot,gt),c=Math.imul(Ot,dt),c=c+Math.imul(Ft,gt)|0,l=Math.imul(Ft,dt),v=v+Math.imul(zt,ht)|0,c=c+Math.imul(zt,Zt)|0,c=c+Math.imul(Lt,ht)|0,l=l+Math.imul(Lt,Zt)|0,v=v+Math.imul(Ct,Yt)|0,c=c+Math.imul(Ct,Jt)|0,c=c+Math.imul(Dt,Yt)|0,l=l+Math.imul(Dt,Jt)|0,v=v+Math.imul(St,Xt)|0,c=c+Math.imul(St,Qt)|0,c=c+Math.imul(Tt,Xt)|0,l=l+Math.imul(Tt,Qt)|0,v=v+Math.imul(pt,te)|0,c=c+Math.imul(pt,ee)|0,c=c+Math.imul(vt,te)|0,l=l+Math.imul(vt,ee)|0,v=v+Math.imul(nt,re)|0,c=c+Math.imul(nt,ne)|0,c=c+Math.imul(ct,re)|0,l=l+Math.imul(ct,ne)|0,v=v+Math.imul(A,ie)|0,c=c+Math.imul(A,se)|0,c=c+Math.imul(U,ie)|0,l=l+Math.imul(U,se)|0;var is=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(is>>>26)|0,is&=67108863,v=Math.imul(qt,gt),c=Math.imul(qt,dt),c=c+Math.imul(b,gt)|0,l=Math.imul(b,dt),v=v+Math.imul(Ot,ht)|0,c=c+Math.imul(Ot,Zt)|0,c=c+Math.imul(Ft,ht)|0,l=l+Math.imul(Ft,Zt)|0,v=v+Math.imul(zt,Yt)|0,c=c+Math.imul(zt,Jt)|0,c=c+Math.imul(Lt,Yt)|0,l=l+Math.imul(Lt,Jt)|0,v=v+Math.imul(Ct,Xt)|0,c=c+Math.imul(Ct,Qt)|0,c=c+Math.imul(Dt,Xt)|0,l=l+Math.imul(Dt,Qt)|0,v=v+Math.imul(St,te)|0,c=c+Math.imul(St,ee)|0,c=c+Math.imul(Tt,te)|0,l=l+Math.imul(Tt,ee)|0,v=v+Math.imul(pt,re)|0,c=c+Math.imul(pt,ne)|0,c=c+Math.imul(vt,re)|0,l=l+Math.imul(vt,ne)|0,v=v+Math.imul(nt,ie)|0,c=c+Math.imul(nt,se)|0,c=c+Math.imul(ct,ie)|0,l=l+Math.imul(ct,se)|0,v=v+Math.imul(A,oe)|0,c=c+Math.imul(A,ae)|0,c=c+Math.imul(U,oe)|0,l=l+Math.imul(U,ae)|0;var ss=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(ss>>>26)|0,ss&=67108863,v=Math.imul(d,gt),c=Math.imul(d,dt),c=c+Math.imul(_,gt)|0,l=Math.imul(_,dt),v=v+Math.imul(qt,ht)|0,c=c+Math.imul(qt,Zt)|0,c=c+Math.imul(b,ht)|0,l=l+Math.imul(b,Zt)|0,v=v+Math.imul(Ot,Yt)|0,c=c+Math.imul(Ot,Jt)|0,c=c+Math.imul(Ft,Yt)|0,l=l+Math.imul(Ft,Jt)|0,v=v+Math.imul(zt,Xt)|0,c=c+Math.imul(zt,Qt)|0,c=c+Math.imul(Lt,Xt)|0,l=l+Math.imul(Lt,Qt)|0,v=v+Math.imul(Ct,te)|0,c=c+Math.imul(Ct,ee)|0,c=c+Math.imul(Dt,te)|0,l=l+Math.imul(Dt,ee)|0,v=v+Math.imul(St,re)|0,c=c+Math.imul(St,ne)|0,c=c+Math.imul(Tt,re)|0,l=l+Math.imul(Tt,ne)|0,v=v+Math.imul(pt,ie)|0,c=c+Math.imul(pt,se)|0,c=c+Math.imul(vt,ie)|0,l=l+Math.imul(vt,se)|0,v=v+Math.imul(nt,oe)|0,c=c+Math.imul(nt,ae)|0,c=c+Math.imul(ct,oe)|0,l=l+Math.imul(ct,ae)|0,v=v+Math.imul(A,ce)|0,c=c+Math.imul(A,ue)|0,c=c+Math.imul(U,ce)|0,l=l+Math.imul(U,ue)|0;var os=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(os>>>26)|0,os&=67108863,v=Math.imul(z,gt),c=Math.imul(z,dt),c=c+Math.imul(G,gt)|0,l=Math.imul(G,dt),v=v+Math.imul(d,ht)|0,c=c+Math.imul(d,Zt)|0,c=c+Math.imul(_,ht)|0,l=l+Math.imul(_,Zt)|0,v=v+Math.imul(qt,Yt)|0,c=c+Math.imul(qt,Jt)|0,c=c+Math.imul(b,Yt)|0,l=l+Math.imul(b,Jt)|0,v=v+Math.imul(Ot,Xt)|0,c=c+Math.imul(Ot,Qt)|0,c=c+Math.imul(Ft,Xt)|0,l=l+Math.imul(Ft,Qt)|0,v=v+Math.imul(zt,te)|0,c=c+Math.imul(zt,ee)|0,c=c+Math.imul(Lt,te)|0,l=l+Math.imul(Lt,ee)|0,v=v+Math.imul(Ct,re)|0,c=c+Math.imul(Ct,ne)|0,c=c+Math.imul(Dt,re)|0,l=l+Math.imul(Dt,ne)|0,v=v+Math.imul(St,ie)|0,c=c+Math.imul(St,se)|0,c=c+Math.imul(Tt,ie)|0,l=l+Math.imul(Tt,se)|0,v=v+Math.imul(pt,oe)|0,c=c+Math.imul(pt,ae)|0,c=c+Math.imul(vt,oe)|0,l=l+Math.imul(vt,ae)|0,v=v+Math.imul(nt,ce)|0,c=c+Math.imul(nt,ue)|0,c=c+Math.imul(ct,ce)|0,l=l+Math.imul(ct,ue)|0,v=v+Math.imul(A,le)|0,c=c+Math.imul(A,fe)|0,c=c+Math.imul(U,le)|0,l=l+Math.imul(U,fe)|0;var as=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(as>>>26)|0,as&=67108863,v=Math.imul(z,ht),c=Math.imul(z,Zt),c=c+Math.imul(G,ht)|0,l=Math.imul(G,Zt),v=v+Math.imul(d,Yt)|0,c=c+Math.imul(d,Jt)|0,c=c+Math.imul(_,Yt)|0,l=l+Math.imul(_,Jt)|0,v=v+Math.imul(qt,Xt)|0,c=c+Math.imul(qt,Qt)|0,c=c+Math.imul(b,Xt)|0,l=l+Math.imul(b,Qt)|0,v=v+Math.imul(Ot,te)|0,c=c+Math.imul(Ot,ee)|0,c=c+Math.imul(Ft,te)|0,l=l+Math.imul(Ft,ee)|0,v=v+Math.imul(zt,re)|0,c=c+Math.imul(zt,ne)|0,c=c+Math.imul(Lt,re)|0,l=l+Math.imul(Lt,ne)|0,v=v+Math.imul(Ct,ie)|0,c=c+Math.imul(Ct,se)|0,c=c+Math.imul(Dt,ie)|0,l=l+Math.imul(Dt,se)|0,v=v+Math.imul(St,oe)|0,c=c+Math.imul(St,ae)|0,c=c+Math.imul(Tt,oe)|0,l=l+Math.imul(Tt,ae)|0,v=v+Math.imul(pt,ce)|0,c=c+Math.imul(pt,ue)|0,c=c+Math.imul(vt,ce)|0,l=l+Math.imul(vt,ue)|0,v=v+Math.imul(nt,le)|0,c=c+Math.imul(nt,fe)|0,c=c+Math.imul(ct,le)|0,l=l+Math.imul(ct,fe)|0;var cs=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(cs>>>26)|0,cs&=67108863,v=Math.imul(z,Yt),c=Math.imul(z,Jt),c=c+Math.imul(G,Yt)|0,l=Math.imul(G,Jt),v=v+Math.imul(d,Xt)|0,c=c+Math.imul(d,Qt)|0,c=c+Math.imul(_,Xt)|0,l=l+Math.imul(_,Qt)|0,v=v+Math.imul(qt,te)|0,c=c+Math.imul(qt,ee)|0,c=c+Math.imul(b,te)|0,l=l+Math.imul(b,ee)|0,v=v+Math.imul(Ot,re)|0,c=c+Math.imul(Ot,ne)|0,c=c+Math.imul(Ft,re)|0,l=l+Math.imul(Ft,ne)|0,v=v+Math.imul(zt,ie)|0,c=c+Math.imul(zt,se)|0,c=c+Math.imul(Lt,ie)|0,l=l+Math.imul(Lt,se)|0,v=v+Math.imul(Ct,oe)|0,c=c+Math.imul(Ct,ae)|0,c=c+Math.imul(Dt,oe)|0,l=l+Math.imul(Dt,ae)|0,v=v+Math.imul(St,ce)|0,c=c+Math.imul(St,ue)|0,c=c+Math.imul(Tt,ce)|0,l=l+Math.imul(Tt,ue)|0,v=v+Math.imul(pt,le)|0,c=c+Math.imul(pt,fe)|0,c=c+Math.imul(vt,le)|0,l=l+Math.imul(vt,fe)|0;var us=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(us>>>26)|0,us&=67108863,v=Math.imul(z,Xt),c=Math.imul(z,Qt),c=c+Math.imul(G,Xt)|0,l=Math.imul(G,Qt),v=v+Math.imul(d,te)|0,c=c+Math.imul(d,ee)|0,c=c+Math.imul(_,te)|0,l=l+Math.imul(_,ee)|0,v=v+Math.imul(qt,re)|0,c=c+Math.imul(qt,ne)|0,c=c+Math.imul(b,re)|0,l=l+Math.imul(b,ne)|0,v=v+Math.imul(Ot,ie)|0,c=c+Math.imul(Ot,se)|0,c=c+Math.imul(Ft,ie)|0,l=l+Math.imul(Ft,se)|0,v=v+Math.imul(zt,oe)|0,c=c+Math.imul(zt,ae)|0,c=c+Math.imul(Lt,oe)|0,l=l+Math.imul(Lt,ae)|0,v=v+Math.imul(Ct,ce)|0,c=c+Math.imul(Ct,ue)|0,c=c+Math.imul(Dt,ce)|0,l=l+Math.imul(Dt,ue)|0,v=v+Math.imul(St,le)|0,c=c+Math.imul(St,fe)|0,c=c+Math.imul(Tt,le)|0,l=l+Math.imul(Tt,fe)|0;var ls=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(ls>>>26)|0,ls&=67108863,v=Math.imul(z,te),c=Math.imul(z,ee),c=c+Math.imul(G,te)|0,l=Math.imul(G,ee),v=v+Math.imul(d,re)|0,c=c+Math.imul(d,ne)|0,c=c+Math.imul(_,re)|0,l=l+Math.imul(_,ne)|0,v=v+Math.imul(qt,ie)|0,c=c+Math.imul(qt,se)|0,c=c+Math.imul(b,ie)|0,l=l+Math.imul(b,se)|0,v=v+Math.imul(Ot,oe)|0,c=c+Math.imul(Ot,ae)|0,c=c+Math.imul(Ft,oe)|0,l=l+Math.imul(Ft,ae)|0,v=v+Math.imul(zt,ce)|0,c=c+Math.imul(zt,ue)|0,c=c+Math.imul(Lt,ce)|0,l=l+Math.imul(Lt,ue)|0,v=v+Math.imul(Ct,le)|0,c=c+Math.imul(Ct,fe)|0,c=c+Math.imul(Dt,le)|0,l=l+Math.imul(Dt,fe)|0;var fs=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(fs>>>26)|0,fs&=67108863,v=Math.imul(z,re),c=Math.imul(z,ne),c=c+Math.imul(G,re)|0,l=Math.imul(G,ne),v=v+Math.imul(d,ie)|0,c=c+Math.imul(d,se)|0,c=c+Math.imul(_,ie)|0,l=l+Math.imul(_,se)|0,v=v+Math.imul(qt,oe)|0,c=c+Math.imul(qt,ae)|0,c=c+Math.imul(b,oe)|0,l=l+Math.imul(b,ae)|0,v=v+Math.imul(Ot,ce)|0,c=c+Math.imul(Ot,ue)|0,c=c+Math.imul(Ft,ce)|0,l=l+Math.imul(Ft,ue)|0,v=v+Math.imul(zt,le)|0,c=c+Math.imul(zt,fe)|0,c=c+Math.imul(Lt,le)|0,l=l+Math.imul(Lt,fe)|0;var hs=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(hs>>>26)|0,hs&=67108863,v=Math.imul(z,ie),c=Math.imul(z,se),c=c+Math.imul(G,ie)|0,l=Math.imul(G,se),v=v+Math.imul(d,oe)|0,c=c+Math.imul(d,ae)|0,c=c+Math.imul(_,oe)|0,l=l+Math.imul(_,ae)|0,v=v+Math.imul(qt,ce)|0,c=c+Math.imul(qt,ue)|0,c=c+Math.imul(b,ce)|0,l=l+Math.imul(b,ue)|0,v=v+Math.imul(Ot,le)|0,c=c+Math.imul(Ot,fe)|0,c=c+Math.imul(Ft,le)|0,l=l+Math.imul(Ft,fe)|0;var ds=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(ds>>>26)|0,ds&=67108863,v=Math.imul(z,oe),c=Math.imul(z,ae),c=c+Math.imul(G,oe)|0,l=Math.imul(G,ae),v=v+Math.imul(d,ce)|0,c=c+Math.imul(d,ue)|0,c=c+Math.imul(_,ce)|0,l=l+Math.imul(_,ue)|0,v=v+Math.imul(qt,le)|0,c=c+Math.imul(qt,fe)|0,c=c+Math.imul(b,le)|0,l=l+Math.imul(b,fe)|0;var ps=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(ps>>>26)|0,ps&=67108863,v=Math.imul(z,ce),c=Math.imul(z,ue),c=c+Math.imul(G,ce)|0,l=Math.imul(G,ue),v=v+Math.imul(d,le)|0,c=c+Math.imul(d,fe)|0,c=c+Math.imul(_,le)|0,l=l+Math.imul(_,fe)|0;var gs=(L+v|0)+((c&8191)<<13)|0;L=(l+(c>>>13)|0)+(gs>>>26)|0,gs&=67108863,v=Math.imul(z,le),c=Math.imul(z,fe),c=c+Math.imul(G,le)|0,l=Math.imul(G,fe);var ys=(L+v|0)+((c&8191)<<13)|0;return L=(l+(c>>>13)|0)+(ys>>>26)|0,ys&=67108863,I[0]=Xi,I[1]=Qi,I[2]=ts,I[3]=es,I[4]=rs,I[5]=ns,I[6]=is,I[7]=ss,I[8]=os,I[9]=as,I[10]=cs,I[11]=us,I[12]=ls,I[13]=fs,I[14]=hs,I[15]=ds,I[16]=ps,I[17]=gs,I[18]=ys,L!==0&&(I[19]=L,m.length++),m};Math.imul||($=O);function q(x,u,p){p.negative=u.negative^x.negative,p.length=x.length+u.length;for(var m=0,E=0,S=0;S<p.length-1;S++){var I=E;E=0;for(var L=m&67108863,v=Math.min(S,u.length-1),c=Math.max(0,S-x.length+1);c<=v;c++){var l=S-c,y=x.words[l]|0,A=u.words[c]|0,U=y*A,j=U&67108863;I=I+(U/67108864|0)|0,j=j+L|0,L=j&67108863,I=I+(j>>>26)|0,E+=I>>>26,I&=67108863}p.words[S]=L,m=I,I=E}return m!==0?p.words[S]=m:p.length--,p._strip()}function X(x,u,p){return q(x,u,p)}i.prototype.mulTo=function(u,p){var m,E=this.length+u.length;return this.length===10&&u.length===10?m=$(this,u,p):E<63?m=O(this,u,p):E<1024?m=q(this,u,p):m=X(this,u,p),m},i.prototype.mul=function(u){var p=new i(null);return p.words=new Array(this.length+u.length),this.mulTo(u,p)},i.prototype.mulf=function(u){var p=new i(null);return p.words=new Array(this.length+u.length),X(this,u,p)},i.prototype.imul=function(u){return this.clone().mulTo(u,this)},i.prototype.imuln=function(u){var p=u<0;p&&(u=-u),r(typeof u=="number"),r(u<67108864);for(var m=0,E=0;E<this.length;E++){var S=(this.words[E]|0)*u,I=(S&67108863)+(m&67108863);m>>=26,m+=S/67108864|0,m+=I>>>26,this.words[E]=I&67108863}return m!==0&&(this.words[E]=m,this.length++),p?this.ineg():this},i.prototype.muln=function(u){return this.clone().imuln(u)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(u){var p=T(u);if(p.length===0)return new i(1);for(var m=this,E=0;E<p.length&&p[E]===0;E++,m=m.sqr());if(++E<p.length)for(var S=m.sqr();E<p.length;E++,S=S.sqr())p[E]!==0&&(m=m.mul(S));return m},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var p=u%26,m=(u-p)/26,E=67108863>>>26-p<<26-p,S;if(p!==0){var I=0;for(S=0;S<this.length;S++){var L=this.words[S]&E,v=(this.words[S]|0)-L<<p;this.words[S]=v|I,I=L>>>26-p}I&&(this.words[S]=I,this.length++)}if(m!==0){for(S=this.length-1;S>=0;S--)this.words[S+m]=this.words[S];for(S=0;S<m;S++)this.words[S]=0;this.length+=m}return this._strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,p,m){r(typeof u=="number"&&u>=0);var E;p?E=(p-p%26)/26:E=0;var S=u%26,I=Math.min((u-S)/26,this.length),L=67108863^67108863>>>S<<S,v=m;if(E-=I,E=Math.max(0,E),v){for(var c=0;c<I;c++)v.words[c]=this.words[c];v.length=I}if(I!==0)if(this.length>I)for(this.length-=I,c=0;c<this.length;c++)this.words[c]=this.words[c+I];else this.words[0]=0,this.length=1;var l=0;for(c=this.length-1;c>=0&&(l!==0||c>=E);c--){var y=this.words[c]|0;this.words[c]=l<<26-S|y>>>S,l=y&L}return v&&l!==0&&(v.words[v.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(u,p,m){return r(this.negative===0),this.iushrn(u,p,m)},i.prototype.shln=function(u){return this.clone().ishln(u)},i.prototype.ushln=function(u){return this.clone().iushln(u)},i.prototype.shrn=function(u){return this.clone().ishrn(u)},i.prototype.ushrn=function(u){return this.clone().iushrn(u)},i.prototype.testn=function(u){r(typeof u=="number"&&u>=0);var p=u%26,m=(u-p)/26,E=1<<p;if(this.length<=m)return!1;var S=this.words[m];return!!(S&E)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var p=u%26,m=(u-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(p!==0&&m++,this.length=Math.min(m,this.length),p!==0){var E=67108863^67108863>>>p<<p;this.words[this.length-1]&=E}return this._strip()},i.prototype.maskn=function(u){return this.clone().imaskn(u)},i.prototype.iaddn=function(u){return r(typeof u=="number"),r(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<=u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},i.prototype._iaddn=function(u){this.words[0]+=u;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(u){if(r(typeof u=="number"),r(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(u){return this.clone().iaddn(u)},i.prototype.subn=function(u){return this.clone().isubn(u)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(u,p,m){var E=u.length+m,S;this._expand(E);var I,L=0;for(S=0;S<u.length;S++){I=(this.words[S+m]|0)+L;var v=(u.words[S]|0)*p;I-=v&67108863,L=(I>>26)-(v/67108864|0),this.words[S+m]=I&67108863}for(;S<this.length-m;S++)I=(this.words[S+m]|0)+L,L=I>>26,this.words[S+m]=I&67108863;if(L===0)return this._strip();for(r(L===-1),L=0,S=0;S<this.length;S++)I=-(this.words[S]|0)+L,L=I>>26,this.words[S]=I&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(u,p){var m=this.length-u.length,E=this.clone(),S=u,I=S.words[S.length-1]|0,L=this._countBits(I);m=26-L,m!==0&&(S=S.ushln(m),E.iushln(m),I=S.words[S.length-1]|0);var v=E.length-S.length,c;if(p!=="mod"){c=new i(null),c.length=v+1,c.words=new Array(c.length);for(var l=0;l<c.length;l++)c.words[l]=0}var y=E.clone()._ishlnsubmul(S,1,v);y.negative===0&&(E=y,c&&(c.words[v]=1));for(var A=v-1;A>=0;A--){var U=(E.words[S.length+A]|0)*67108864+(E.words[S.length+A-1]|0);for(U=Math.min(U/I|0,67108863),E._ishlnsubmul(S,U,A);E.negative!==0;)U--,E.negative=0,E._ishlnsubmul(S,1,A),E.isZero()||(E.negative^=1);c&&(c.words[A]=U)}return c&&c._strip(),E._strip(),p!=="div"&&m!==0&&E.iushrn(m),{div:c||null,mod:E}},i.prototype.divmod=function(u,p,m){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var E,S,I;return this.negative!==0&&u.negative===0?(I=this.neg().divmod(u,p),p!=="mod"&&(E=I.div.neg()),p!=="div"&&(S=I.mod.neg(),m&&S.negative!==0&&S.iadd(u)),{div:E,mod:S}):this.negative===0&&u.negative!==0?(I=this.divmod(u.neg(),p),p!=="mod"&&(E=I.div.neg()),{div:E,mod:I.mod}):this.negative&u.negative?(I=this.neg().divmod(u.neg(),p),p!=="div"&&(S=I.mod.neg(),m&&S.negative!==0&&S.isub(u)),{div:I.div,mod:S}):u.length>this.length||this.cmp(u)<0?{div:new i(0),mod:this}:u.length===1?p==="div"?{div:this.divn(u.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new i(this.modrn(u.words[0]))}:this._wordDiv(u,p)},i.prototype.div=function(u){return this.divmod(u,"div",!1).div},i.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},i.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},i.prototype.divRound=function(u){var p=this.divmod(u);if(p.mod.isZero())return p.div;var m=p.div.negative!==0?p.mod.isub(u):p.mod,E=u.ushrn(1),S=u.andln(1),I=m.cmp(E);return I<0||S===1&&I===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(u){var p=u<0;p&&(u=-u),r(u<=67108863);for(var m=(1<<26)%u,E=0,S=this.length-1;S>=0;S--)E=(m*E+(this.words[S]|0))%u;return p?-E:E},i.prototype.modn=function(u){return this.modrn(u)},i.prototype.idivn=function(u){var p=u<0;p&&(u=-u),r(u<=67108863);for(var m=0,E=this.length-1;E>=0;E--){var S=(this.words[E]|0)+m*67108864;this.words[E]=S/u|0,m=S%u}return this._strip(),p?this.ineg():this},i.prototype.divn=function(u){return this.clone().idivn(u)},i.prototype.egcd=function(u){r(u.negative===0),r(!u.isZero());var p=this,m=u.clone();p.negative!==0?p=p.umod(u):p=p.clone();for(var E=new i(1),S=new i(0),I=new i(0),L=new i(1),v=0;p.isEven()&&m.isEven();)p.iushrn(1),m.iushrn(1),++v;for(var c=m.clone(),l=p.clone();!p.isZero();){for(var y=0,A=1;!(p.words[0]&A)&&y<26;++y,A<<=1);if(y>0)for(p.iushrn(y);y-- >0;)(E.isOdd()||S.isOdd())&&(E.iadd(c),S.isub(l)),E.iushrn(1),S.iushrn(1);for(var U=0,j=1;!(m.words[0]&j)&&U<26;++U,j<<=1);if(U>0)for(m.iushrn(U);U-- >0;)(I.isOdd()||L.isOdd())&&(I.iadd(c),L.isub(l)),I.iushrn(1),L.iushrn(1);p.cmp(m)>=0?(p.isub(m),E.isub(I),S.isub(L)):(m.isub(p),I.isub(E),L.isub(S))}return{a:I,b:L,gcd:m.iushln(v)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var p=this,m=u.clone();p.negative!==0?p=p.umod(u):p=p.clone();for(var E=new i(1),S=new i(0),I=m.clone();p.cmpn(1)>0&&m.cmpn(1)>0;){for(var L=0,v=1;!(p.words[0]&v)&&L<26;++L,v<<=1);if(L>0)for(p.iushrn(L);L-- >0;)E.isOdd()&&E.iadd(I),E.iushrn(1);for(var c=0,l=1;!(m.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(m.iushrn(c);c-- >0;)S.isOdd()&&S.iadd(I),S.iushrn(1);p.cmp(m)>=0?(p.isub(m),E.isub(S)):(m.isub(p),S.isub(E))}var y;return p.cmpn(1)===0?y=E:y=S,y.cmpn(0)<0&&y.iadd(u),y},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var p=this.clone(),m=u.clone();p.negative=0,m.negative=0;for(var E=0;p.isEven()&&m.isEven();E++)p.iushrn(1),m.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;m.isEven();)m.iushrn(1);var S=p.cmp(m);if(S<0){var I=p;p=m,m=I}else if(S===0||m.cmpn(1)===0)break;p.isub(m)}while(!0);return m.iushln(E)},i.prototype.invm=function(u){return this.egcd(u).a.umod(u)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(u){return this.words[0]&u},i.prototype.bincn=function(u){r(typeof u=="number");var p=u%26,m=(u-p)/26,E=1<<p;if(this.length<=m)return this._expand(m+1),this.words[m]|=E,this;for(var S=E,I=m;S!==0&&I<this.length;I++){var L=this.words[I]|0;L+=S,S=L>>>26,L&=67108863,this.words[I]=L}return S!==0&&(this.words[I]=S,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(u){var p=u<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var m;if(this.length>1)m=1;else{p&&(u=-u),r(u<=67108863,"Number is too big");var E=this.words[0]|0;m=E===u?0:E<u?-1:1}return this.negative!==0?-m|0:m},i.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var p=this.ucmp(u);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var p=0,m=this.length-1;m>=0;m--){var E=this.words[m]|0,S=u.words[m]|0;if(E!==S){E<S?p=-1:E>S&&(p=1);break}}return p},i.prototype.gtn=function(u){return this.cmpn(u)===1},i.prototype.gt=function(u){return this.cmp(u)===1},i.prototype.gten=function(u){return this.cmpn(u)>=0},i.prototype.gte=function(u){return this.cmp(u)>=0},i.prototype.ltn=function(u){return this.cmpn(u)===-1},i.prototype.lt=function(u){return this.cmp(u)===-1},i.prototype.lten=function(u){return this.cmpn(u)<=0},i.prototype.lte=function(u){return this.cmp(u)<=0},i.prototype.eqn=function(u){return this.cmpn(u)===0},i.prototype.eq=function(u){return this.cmp(u)===0},i.red=function(u){return new V(u)},i.prototype.toRed=function(u){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(u){return this.red=u,this},i.prototype.forceRed=function(u){return r(!this.red,"Already a number in reduction context"),this._forceRed(u)},i.prototype.redAdd=function(u){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},i.prototype.redIAdd=function(u){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},i.prototype.redSub=function(u){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},i.prototype.redISub=function(u){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},i.prototype.redShl=function(u){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},i.prototype.redMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},i.prototype.redIMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(u){return r(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var D={k256:null,p224:null,p192:null,p25519:null};function F(x,u){this.name=x,this.p=new i(u,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}F.prototype._tmp=function(){var u=new i(null);return u.words=new Array(Math.ceil(this.n/13)),u},F.prototype.ireduce=function(u){var p=u,m;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),m=p.bitLength();while(m>this.n);var E=m<this.n?-1:p.ucmp(this.p);return E===0?(p.words[0]=0,p.length=1):E>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},F.prototype.split=function(u,p){u.iushrn(this.n,0,p)},F.prototype.imulK=function(u){return u.imul(this.k)};function Y(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(Y,F),Y.prototype.split=function(u,p){for(var m=4194303,E=Math.min(u.length,9),S=0;S<E;S++)p.words[S]=u.words[S];if(p.length=E,u.length<=9){u.words[0]=0,u.length=1;return}var I=u.words[9];for(p.words[p.length++]=I&m,S=10;S<u.length;S++){var L=u.words[S]|0;u.words[S-10]=(L&m)<<4|I>>>22,I=L}I>>>=22,u.words[S-10]=I,I===0&&u.length>10?u.length-=10:u.length-=9},Y.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var p=0,m=0;m<u.length;m++){var E=u.words[m]|0;p+=E*977,u.words[m]=p&67108863,p=E*64+(p/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function Z(){F.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(Z,F);function J(){F.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(J,F);function K(){F.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(K,F),K.prototype.imulK=function(u){for(var p=0,m=0;m<u.length;m++){var E=(u.words[m]|0)*19+p,S=E&67108863;E>>>=26,u.words[m]=S,p=E}return p!==0&&(u.words[u.length++]=p),u},i._prime=function(u){if(D[u])return D[u];var p;if(u==="k256")p=new Y;else if(u==="p224")p=new Z;else if(u==="p192")p=new J;else if(u==="p25519")p=new K;else throw new Error("Unknown prime "+u);return D[u]=p,p};function V(x){if(typeof x=="string"){var u=i._prime(x);this.m=u.p,this.prime=u}else r(x.gtn(1),"modulus must be greater than 1"),this.m=x,this.prime=null}V.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},V.prototype._verify2=function(u,p){r((u.negative|p.negative)===0,"red works only with positives"),r(u.red&&u.red===p.red,"red works only with red numbers")},V.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):(w(u,u.umod(this.m)._forceRed(this)),u)},V.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},V.prototype.add=function(u,p){this._verify2(u,p);var m=u.add(p);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},V.prototype.iadd=function(u,p){this._verify2(u,p);var m=u.iadd(p);return m.cmp(this.m)>=0&&m.isub(this.m),m},V.prototype.sub=function(u,p){this._verify2(u,p);var m=u.sub(p);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},V.prototype.isub=function(u,p){this._verify2(u,p);var m=u.isub(p);return m.cmpn(0)<0&&m.iadd(this.m),m},V.prototype.shl=function(u,p){return this._verify1(u),this.imod(u.ushln(p))},V.prototype.imul=function(u,p){return this._verify2(u,p),this.imod(u.imul(p))},V.prototype.mul=function(u,p){return this._verify2(u,p),this.imod(u.mul(p))},V.prototype.isqr=function(u){return this.imul(u,u.clone())},V.prototype.sqr=function(u){return this.mul(u,u)},V.prototype.sqrt=function(u){if(u.isZero())return u.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var m=this.m.add(new i(1)).iushrn(2);return this.pow(u,m)}for(var E=this.m.subn(1),S=0;!E.isZero()&&E.andln(1)===0;)S++,E.iushrn(1);r(!E.isZero());var I=new i(1).toRed(this),L=I.redNeg(),v=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);this.pow(c,v).cmp(L)!==0;)c.redIAdd(L);for(var l=this.pow(c,E),y=this.pow(u,E.addn(1).iushrn(1)),A=this.pow(u,E),U=S;A.cmp(I)!==0;){for(var j=A,nt=0;j.cmp(I)!==0;nt++)j=j.redSqr();r(nt<U);var ct=this.pow(l,new i(1).iushln(U-nt-1));y=y.redMul(ct),l=ct.redSqr(),A=A.redMul(l),U=nt}return y},V.prototype.invm=function(u){var p=u._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},V.prototype.pow=function(u,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return u.clone();var m=4,E=new Array(1<<m);E[0]=new i(1).toRed(this),E[1]=u;for(var S=2;S<E.length;S++)E[S]=this.mul(E[S-1],u);var I=E[0],L=0,v=0,c=p.bitLength()%26;for(c===0&&(c=26),S=p.length-1;S>=0;S--){for(var l=p.words[S],y=c-1;y>=0;y--){var A=l>>y&1;if(I!==E[0]&&(I=this.sqr(I)),A===0&&L===0){v=0;continue}L<<=1,L|=A,v++,!(v!==m&&(S!==0||y!==0))&&(I=this.mul(I,E[L]),v=0,L=0)}c=26}return I},V.prototype.convertTo=function(u){var p=u.umod(this.m);return p===u?p.clone():p},V.prototype.convertFrom=function(u){var p=u.clone();return p.red=null,p},i.mont=function(u){return new Q(u)};function Q(x){V.call(this,x),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(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)}s(Q,V),Q.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},Q.prototype.convertFrom=function(u){var p=this.imod(u.mul(this.rinv));return p.red=null,p},Q.prototype.imul=function(u,p){if(u.isZero()||p.isZero())return u.words[0]=0,u.length=1,u;var m=u.imul(p),E=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=m.isub(E).iushrn(this.shift),I=S;return S.cmp(this.m)>=0?I=S.isub(this.m):S.cmpn(0)<0&&(I=S.iadd(this.m)),I._forceRed(this)},Q.prototype.mul=function(u,p){if(u.isZero()||p.isZero())return new i(0)._forceRed(this);var m=u.mul(p),E=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=m.isub(E).iushrn(this.shift),I=S;return S.cmp(this.m)>=0?I=S.isub(this.m):S.cmpn(0)<0&&(I=S.iadd(this.m)),I._forceRed(this)},Q.prototype.invm=function(u){var p=this.imod(u._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(n,Kc)}(an)),an.exports}var Wc=Gs();const Zs=Nr(Wc);var cn={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Ys;function Dc(){return Ys||(Ys=1,function(n,t){var e=qn(),r=e.Buffer;function s(o,a){for(var h in o)a[h]=o[h]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(s(e,t),t.Buffer=i);function i(o,a,h){return r(o,a,h)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,h){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,h)},i.alloc=function(o,a,h){if(typeof o!="number")throw new TypeError("Argument must be a number");var g=r(o);return a!==void 0?typeof h=="string"?g.fill(a,h):g.fill(a):g.fill(0),g},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}}(cn,cn.exports)),cn.exports}var ti,Js;function $c(){if(Js)return ti;Js=1;var n=Dc().Buffer;function t(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),a=o.charCodeAt(0);if(r[a]!==255)throw new TypeError(o+" is ambiguous");r[a]=i}var h=e.length,g=e.charAt(0),w=Math.log(h)/Math.log(256),k=Math.log(256)/Math.log(h);function M(B){if((Array.isArray(B)||B instanceof Uint8Array)&&(B=n.from(B)),!n.isBuffer(B))throw new TypeError("Expected Buffer");if(B.length===0)return"";for(var T=0,O=0,$=0,q=B.length;$!==q&&B[$]===0;)$++,T++;for(var X=(q-$)*k+1>>>0,D=new Uint8Array(X);$!==q;){for(var F=B[$],Y=0,Z=X-1;(F!==0||Y<O)&&Z!==-1;Z--,Y++)F+=256*D[Z]>>>0,D[Z]=F%h>>>0,F=F/h>>>0;if(F!==0)throw new Error("Non-zero carry");O=Y,$++}for(var J=X-O;J!==X&&D[J]===0;)J++;for(var K=g.repeat(T);J<X;++J)K+=e.charAt(D[J]);return K}function R(B){if(typeof B!="string")throw new TypeError("Expected String");if(B.length===0)return n.alloc(0);for(var T=0,O=0,$=0;B[T]===g;)O++,T++;for(var q=(B.length-T)*w+1>>>0,X=new Uint8Array(q);B[T];){var D=r[B.charCodeAt(T)];if(D===255)return;for(var F=0,Y=q-1;(D!==0||F<$)&&Y!==-1;Y--,F++)D+=h*X[Y]>>>0,X[Y]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");$=F,T++}for(var Z=q-$;Z!==q&&X[Z]===0;)Z++;var J=n.allocUnsafe(O+(q-Z));J.fill(0,0,O);for(var K=O;Z!==q;)J[K++]=X[Z++];return J}function C(B){var T=R(B);if(T)return T;throw new Error("Non-base"+h+" character")}return{encode:M,decodeUnsafe:R,decode:C}}return ti=t,ti}var ei,Xs;function Qs(){if(Xs)return ei;Xs=1;var n=$c(),t="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return ei=n(t),ei}var Hc=Qs();const ge=Nr(Hc),Vc=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]),Xe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Qe=new Uint32Array(64);class jc extends _s{constructor(){super(64,32,8,!1),this.A=Xe[0]|0,this.B=Xe[1]|0,this.C=Xe[2]|0,this.D=Xe[3]|0,this.E=Xe[4]|0,this.F=Xe[5]|0,this.G=Xe[6]|0,this.H=Xe[7]|0}get(){const{A:t,B:e,C:r,D:s,E:i,F:o,G:a,H:h}=this;return[t,e,r,s,i,o,a,h]}set(t,e,r,s,i,o,a,h){this.A=t|0,this.B=e|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=h|0}process(t,e){for(let k=0;k<16;k++,e+=4)Qe[k]=t.getUint32(e,!1);for(let k=16;k<64;k++){const M=Qe[k-15],R=Qe[k-2],C=Oe(M,7)^Oe(M,18)^M>>>3,B=Oe(R,17)^Oe(R,19)^R>>>10;Qe[k]=B+Qe[k-7]+C+Qe[k-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:h,G:g,H:w}=this;for(let k=0;k<64;k++){const M=Oe(a,6)^Oe(a,11)^Oe(a,25),R=w+M+Ha(a,h,g)+Vc[k]+Qe[k]|0,B=(Oe(r,2)^Oe(r,13)^Oe(r,22))+Va(r,s,i)|0;w=g,g=h,h=a,a=o+R|0,o=i,i=s,s=r,r=R+B|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,h=h+this.F|0,g=g+this.G|0,w=w+this.H|0,this.set(r,s,i,o,a,h,g,w)}roundClean(){Qe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ri=$n(()=>new jc);var Mt={};function Ve(n,t,e){return t<=n&&n<=e}function un(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function Gc(n){for(var t=String(n),e=t.length,r=0,s=[];r<e;){var i=t.charCodeAt(r);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(r===e-1)s.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,h=o&1023;s.push(65536+(a<<10)+h),r+=1}else s.push(65533)}r+=1}return s}function Zc(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 ln=-1;function ni(n){this.tokens=[].slice.call(n)}ni.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():ln},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 _r=-1;function ii(n,t){if(n)throw TypeError("Decoder error");return t||65533}var fn="utf-8";function hn(n,t){if(!(this instanceof hn))return new hn(n,t);if(n=n!==void 0?String(n).toLowerCase():fn,n!==fn)throw new Error("Encoding not supported. Only utf-8 is supported");t=un(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})}hn.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=un(e),this._streaming||(this._decoder=new Yc({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var s=new ni(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==_r);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===_r)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),Zc(i)}};function dn(n,t){if(!(this instanceof dn))return new dn(n,t);if(n=n!==void 0?String(n).toLowerCase():fn,n!==fn)throw new Error("Encoding not supported. Only utf-8 is supported");t=un(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}dn.prototype={encode:function(t,e){t=t?String(t):"",e=un(e),this._streaming||(this._encoder=new Jc(this._options)),this._streaming=!!e.stream;for(var r=[],s=new ni(Gc(t)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==_r);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==_r;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function Yc(n){var t=n.fatal,e=0,r=0,s=0,i=128,o=191;this.handler=function(a,h){if(h===ln&&s!==0)return s=0,ii(t);if(h===ln)return _r;if(s===0){if(Ve(h,0,127))return h;if(Ve(h,194,223))s=1,e=h-192;else if(Ve(h,224,239))h===224&&(i=160),h===237&&(o=159),s=2,e=h-224;else if(Ve(h,240,244))h===240&&(i=144),h===244&&(o=143),s=3,e=h-240;else return ii(t);return e=e<<6*s,null}if(!Ve(h,i,o))return e=s=r=0,i=128,o=191,a.prepend(h),ii(t);if(i=128,o=191,r+=1,e+=h-128<<6*(s-r),r!==s)return null;var g=e;return e=s=r=0,g}}function Jc(n){n.fatal,this.handler=function(t,e){if(e===ln)return _r;if(Ve(e,0,127))return e;var r,s;Ve(e,128,2047)?(r=1,s=192):Ve(e,2048,65535)?(r=2,s=224):Ve(e,65536,1114111)&&(r=3,s=240);for(var i=[(e>>6*r)+s];r>0;){var o=e>>6*(r-1);i.push(128|o&63),r-=1}return i}}const Xc=Fn(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:hn,TextEncoder:dn},Symbol.toStringTag,{value:"Module"})));var to;function Qc(){if(to)return Mt;to=1;var n=Mt&&Mt.__createBinding||(Object.create?function(J,K,V,Q){Q===void 0&&(Q=V),Object.defineProperty(J,Q,{enumerable:!0,get:function(){return K[V]}})}:function(J,K,V,Q){Q===void 0&&(Q=V),J[Q]=K[V]}),t=Mt&&Mt.__setModuleDefault||(Object.create?function(J,K){Object.defineProperty(J,"default",{enumerable:!0,value:K})}:function(J,K){J.default=K}),e=Mt&&Mt.__decorate||function(J,K,V,Q){var x=arguments.length,u=x<3?K:Q===null?Q=Object.getOwnPropertyDescriptor(K,V):Q,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(J,K,V,Q);else for(var m=J.length-1;m>=0;m--)(p=J[m])&&(u=(x<3?p(u):x>3?p(K,V,u):p(K,V))||u);return x>3&&u&&Object.defineProperty(K,V,u),u},r=Mt&&Mt.__importStar||function(J){if(J&&J.__esModule)return J;var K={};if(J!=null)for(var V in J)V!=="default"&&Object.hasOwnProperty.call(J,V)&&n(K,J,V);return t(K,J),K},s=Mt&&Mt.__importDefault||function(J){return J&&J.__esModule?J:{default:J}};Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.deserializeUnchecked=Mt.deserialize=Mt.serialize=Mt.BinaryReader=Mt.BinaryWriter=Mt.BorshError=Mt.baseDecode=Mt.baseEncode=void 0;const i=s(Gs()),o=s(Qs()),a=r(Xc),h=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,g=new h("utf-8",{fatal:!0});function w(J){return typeof J=="string"&&(J=Buffer.from(J,"utf8")),o.default.encode(Buffer.from(J))}Mt.baseEncode=w;function k(J){return Buffer.from(o.default.decode(J))}Mt.baseDecode=k;const M=1024;class R extends Error{constructor(K){super(K),this.fieldPath=[],this.originalMessage=K}addToFieldPath(K){this.fieldPath.splice(0,0,K),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Mt.BorshError=R;class C{constructor(){this.buf=Buffer.alloc(M),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(M)]))}writeU8(K){this.maybeResize(),this.buf.writeUInt8(K,this.length),this.length+=1}writeU16(K){this.maybeResize(),this.buf.writeUInt16LE(K,this.length),this.length+=2}writeU32(K){this.maybeResize(),this.buf.writeUInt32LE(K,this.length),this.length+=4}writeU64(K){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(K).toArray("le",8)))}writeU128(K){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(K).toArray("le",16)))}writeU256(K){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(K).toArray("le",32)))}writeU512(K){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(K).toArray("le",64)))}writeBuffer(K){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),K,Buffer.alloc(M)]),this.length+=K.length}writeString(K){this.maybeResize();const V=Buffer.from(K,"utf8");this.writeU32(V.length),this.writeBuffer(V)}writeFixedArray(K){this.writeBuffer(Buffer.from(K))}writeArray(K,V){this.maybeResize(),this.writeU32(K.length);for(const Q of K)this.maybeResize(),V(Q)}toArray(){return this.buf.subarray(0,this.length)}}Mt.BinaryWriter=C;function B(J,K,V){const Q=V.value;V.value=function(...x){try{return Q.apply(this,x)}catch(u){if(u instanceof RangeError){const p=u.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(p)>=0)throw new R("Reached the end of buffer when deserializing")}throw u}}}class T{constructor(K){this.buf=K,this.offset=0}readU8(){const K=this.buf.readUInt8(this.offset);return this.offset+=1,K}readU16(){const K=this.buf.readUInt16LE(this.offset);return this.offset+=2,K}readU32(){const K=this.buf.readUInt32LE(this.offset);return this.offset+=4,K}readU64(){const K=this.readBuffer(8);return new i.default(K,"le")}readU128(){const K=this.readBuffer(16);return new i.default(K,"le")}readU256(){const K=this.readBuffer(32);return new i.default(K,"le")}readU512(){const K=this.readBuffer(64);return new i.default(K,"le")}readBuffer(K){if(this.offset+K>this.buf.length)throw new R(`Expected buffer length ${K} isn't within bounds`);const V=this.buf.slice(this.offset,this.offset+K);return this.offset+=K,V}readString(){const K=this.readU32(),V=this.readBuffer(K);try{return g.decode(V)}catch(Q){throw new R(`Error decoding UTF-8 string: ${Q}`)}}readFixedArray(K){return new Uint8Array(this.readBuffer(K))}readArray(K){const V=this.readU32(),Q=Array();for(let x=0;x<V;++x)Q.push(K());return Q}}e([B],T.prototype,"readU8",null),e([B],T.prototype,"readU16",null),e([B],T.prototype,"readU32",null),e([B],T.prototype,"readU64",null),e([B],T.prototype,"readU128",null),e([B],T.prototype,"readU256",null),e([B],T.prototype,"readU512",null),e([B],T.prototype,"readString",null),e([B],T.prototype,"readFixedArray",null),e([B],T.prototype,"readArray",null),Mt.BinaryReader=T;function O(J){return J.charAt(0).toUpperCase()+J.slice(1)}function $(J,K,V,Q,x){try{if(typeof Q=="string")x[`write${O(Q)}`](V);else if(Q instanceof Array)if(typeof Q[0]=="number"){if(V.length!==Q[0])throw new R(`Expecting byte array of length ${Q[0]}, but got ${V.length} bytes`);x.writeFixedArray(V)}else if(Q.length===2&&typeof Q[1]=="number"){if(V.length!==Q[1])throw new R(`Expecting byte array of length ${Q[1]}, but got ${V.length} bytes`);for(let u=0;u<Q[1];u++)$(J,null,V[u],Q[0],x)}else x.writeArray(V,u=>{$(J,K,u,Q[0],x)});else if(Q.kind!==void 0)switch(Q.kind){case"option":{V==null?x.writeU8(0):(x.writeU8(1),$(J,K,V,Q.type,x));break}case"map":{x.writeU32(V.size),V.forEach((u,p)=>{$(J,K,p,Q.key,x),$(J,K,u,Q.value,x)});break}default:throw new R(`FieldType ${Q} unrecognized`)}else q(J,V,x)}catch(u){throw u instanceof R&&u.addToFieldPath(K),u}}function q(J,K,V){if(typeof K.borshSerialize=="function"){K.borshSerialize(V);return}const Q=J.get(K.constructor);if(!Q)throw new R(`Class ${K.constructor.name} is missing in schema`);if(Q.kind==="struct")Q.fields.map(([x,u])=>{$(J,x,K[x],u,V)});else if(Q.kind==="enum"){const x=K[Q.field];for(let u=0;u<Q.values.length;++u){const[p,m]=Q.values[u];if(p===x){V.writeU8(u),$(J,p,K[p],m,V);break}}}else throw new R(`Unexpected schema kind: ${Q.kind} for ${K.constructor.name}`)}function X(J,K,V=C){const Q=new V;return q(J,K,Q),Q.toArray()}Mt.serialize=X;function D(J,K,V,Q){try{if(typeof V=="string")return Q[`read${O(V)}`]();if(V instanceof Array){if(typeof V[0]=="number")return Q.readFixedArray(V[0]);if(typeof V[1]=="number"){const x=[];for(let u=0;u<V[1];u++)x.push(D(J,null,V[0],Q));return x}else return Q.readArray(()=>D(J,K,V[0],Q))}if(V.kind==="option")return Q.readU8()?D(J,K,V.type,Q):void 0;if(V.kind==="map"){let x=new Map;const u=Q.readU32();for(let p=0;p<u;p++){const m=D(J,K,V.key,Q),E=D(J,K,V.value,Q);x.set(m,E)}return x}return F(J,V,Q)}catch(x){throw x instanceof R&&x.addToFieldPath(K),x}}function F(J,K,V){if(typeof K.borshDeserialize=="function")return K.borshDeserialize(V);const Q=J.get(K);if(!Q)throw new R(`Class ${K.name} is missing in schema`);if(Q.kind==="struct"){const x={};for(const[u,p]of J.get(K).fields)x[u]=D(J,u,p,V);return new K(x)}if(Q.kind==="enum"){const x=V.readU8();if(x>=Q.values.length)throw new R(`Enum index: ${x} is out of range`);const[u,p]=Q.values[x],m=D(J,u,p,V);return new K({[u]:m})}throw new R(`Unexpected schema kind: ${Q.kind} for ${K.constructor.name}`)}function Y(J,K,V,Q=T){const x=new Q(V),u=F(J,K,x);if(x.offset<V.length)throw new R(`Unexpected ${V.length-x.offset} bytes after deserialized data`);return u}Mt.deserialize=Y;function Z(J,K,V,Q=T){const x=new Q(V);return F(J,K,x)}return Mt.deserializeUnchecked=Z,Mt}var si=Qc(),H={},eo;function tu(){if(eo)return H;eo=1,Object.defineProperty(H,"__esModule",{value:!0}),H.s16=H.s8=H.nu64be=H.u48be=H.u40be=H.u32be=H.u24be=H.u16be=H.nu64=H.u48=H.u40=H.u32=H.u24=H.u16=H.u8=H.offset=H.greedy=H.Constant=H.UTF8=H.CString=H.Blob=H.Boolean=H.BitField=H.BitStructure=H.VariantLayout=H.Union=H.UnionLayoutDiscriminator=H.UnionDiscriminator=H.Structure=H.Sequence=H.DoubleBE=H.Double=H.FloatBE=H.Float=H.NearInt64BE=H.NearInt64=H.NearUInt64BE=H.NearUInt64=H.IntBE=H.Int=H.UIntBE=H.UInt=H.OffsetLayout=H.GreedyCount=H.ExternalLayout=H.bindConstructorLayout=H.nameWithProperty=H.Layout=H.uint8ArrayToBuffer=H.checkUint8Array=void 0,H.constant=H.utf8=H.cstr=H.blob=H.unionLayoutDiscriminator=H.union=H.seq=H.bits=H.struct=H.f64be=H.f64=H.f32be=H.f32=H.ns64be=H.s48be=H.s40be=H.s32be=H.s24be=H.s16be=H.ns64=H.s48=H.s40=H.s32=H.s24=void 0;const n=qn();function t(c){if(!(c instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}H.checkUint8Array=t;function e(c){return t(c),n.Buffer.from(c.buffer,c.byteOffset,c.length)}H.uint8ArrayToBuffer=e;let r=class{constructor(l,y){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=y}makeDestinationObject(){return{}}getSpan(l,y){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const y=Object.create(this.constructor.prototype);return Object.assign(y,this),y.property=l,y}fromArray(l){}};H.Layout=r;function s(c,l){return l.property?c+"["+l.property+"]":c}H.nameWithProperty=s;function i(c,l){if(typeof c!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(c,"layout_"))throw new Error("Class is already bound to a layout");if(!(l&&l instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(l,"boundConstructor_"))throw new Error("layout is already bound to a constructor");c.layout_=l,l.boundConstructor_=c,l.makeDestinationObject=()=>new c,Object.defineProperty(c.prototype,"encode",{value(y,A){return l.encode(this,y,A)},writable:!0}),Object.defineProperty(c,"decode",{value(y,A){return l.decode(y,A)},writable:!0})}H.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}H.ExternalLayout=o;class a extends o{constructor(l=1,y){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,y),this.elementSpan=l}isCount(){return!0}decode(l,y=0){t(l);const A=l.length-y;return Math.floor(A/this.elementSpan)}encode(l,y,A){return 0}}H.GreedyCount=a;class h extends o{constructor(l,y=0,A){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(y))throw new TypeError("offset must be integer or undefined");super(l.span,A||l.property),this.layout=l,this.offset=y}isCount(){return this.layout instanceof g||this.layout instanceof w}decode(l,y=0){return this.layout.decode(l,y+this.offset)}encode(l,y,A=0){return this.layout.encode(l,y,A+this.offset)}}H.OffsetLayout=h;class g extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return e(l).readUIntLE(y,this.span)}encode(l,y,A=0){return e(y).writeUIntLE(l,A,this.span),this.span}}H.UInt=g;class w extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return e(l).readUIntBE(y,this.span)}encode(l,y,A=0){return e(y).writeUIntBE(l,A,this.span),this.span}}H.UIntBE=w;class k extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return e(l).readIntLE(y,this.span)}encode(l,y,A=0){return e(y).writeIntLE(l,A,this.span),this.span}}H.Int=k;class M extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return e(l).readIntBE(y,this.span)}encode(l,y,A=0){return e(y).writeIntBE(l,A,this.span),this.span}}H.IntBE=M;const R=Math.pow(2,32);function C(c){const l=Math.floor(c/R),y=c-l*R;return{hi32:l,lo32:y}}function B(c,l){return c*R+l}class T extends r{constructor(l){super(8,l)}decode(l,y=0){const A=e(l),U=A.readUInt32LE(y),j=A.readUInt32LE(y+4);return B(j,U)}encode(l,y,A=0){const U=C(l),j=e(y);return j.writeUInt32LE(U.lo32,A),j.writeUInt32LE(U.hi32,A+4),8}}H.NearUInt64=T;class O extends r{constructor(l){super(8,l)}decode(l,y=0){const A=e(l),U=A.readUInt32BE(y),j=A.readUInt32BE(y+4);return B(U,j)}encode(l,y,A=0){const U=C(l),j=e(y);return j.writeUInt32BE(U.hi32,A),j.writeUInt32BE(U.lo32,A+4),8}}H.NearUInt64BE=O;class $ extends r{constructor(l){super(8,l)}decode(l,y=0){const A=e(l),U=A.readUInt32LE(y),j=A.readInt32LE(y+4);return B(j,U)}encode(l,y,A=0){const U=C(l),j=e(y);return j.writeUInt32LE(U.lo32,A),j.writeInt32LE(U.hi32,A+4),8}}H.NearInt64=$;class q extends r{constructor(l){super(8,l)}decode(l,y=0){const A=e(l),U=A.readInt32BE(y),j=A.readUInt32BE(y+4);return B(U,j)}encode(l,y,A=0){const U=C(l),j=e(y);return j.writeInt32BE(U.hi32,A),j.writeUInt32BE(U.lo32,A+4),8}}H.NearInt64BE=q;class X extends r{constructor(l){super(4,l)}decode(l,y=0){return e(l).readFloatLE(y)}encode(l,y,A=0){return e(y).writeFloatLE(l,A),4}}H.Float=X;class D extends r{constructor(l){super(4,l)}decode(l,y=0){return e(l).readFloatBE(y)}encode(l,y,A=0){return e(y).writeFloatBE(l,A),4}}H.FloatBE=D;class F extends r{constructor(l){super(8,l)}decode(l,y=0){return e(l).readDoubleLE(y)}encode(l,y,A=0){return e(y).writeDoubleLE(l,A),8}}H.Double=F;class Y extends r{constructor(l){super(8,l)}decode(l,y=0){return e(l).readDoubleBE(y)}encode(l,y,A=0){return e(y).writeDoubleBE(l,A),8}}H.DoubleBE=Y;class Z extends r{constructor(l,y,A){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(y instanceof o&&y.isCount()||Number.isInteger(y)&&0<=y))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let U=-1;!(y instanceof o)&&0<l.span&&(U=y*l.span),super(U,A),this.elementLayout=l,this.count=y}getSpan(l,y=0){if(0<=this.span)return this.span;let A=0,U=this.count;if(U instanceof o&&(U=U.decode(l,y)),0<this.elementLayout.span)A=U*this.elementLayout.span;else{let j=0;for(;j<U;)A+=this.elementLayout.getSpan(l,y+A),++j}return A}decode(l,y=0){const A=[];let U=0,j=this.count;for(j instanceof o&&(j=j.decode(l,y));U<j;)A.push(this.elementLayout.decode(l,y)),y+=this.elementLayout.getSpan(l,y),U+=1;return A}encode(l,y,A=0){const U=this.elementLayout,j=l.reduce((nt,ct)=>nt+U.encode(ct,y,A+nt),0);return this.count instanceof o&&this.count.encode(l.length,y,A),j}}H.Sequence=Z;class J extends r{constructor(l,y,A){if(!(Array.isArray(l)&&l.reduce((j,nt)=>j&&nt instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof y=="boolean"&&A===void 0&&(A=y,y=void 0);for(const j of l)if(0>j.span&&j.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let U=-1;try{U=l.reduce((j,nt)=>j+nt.getSpan(),0)}catch{}super(U,y),this.fields=l,this.decodePrefixes=!!A}getSpan(l,y=0){if(0<=this.span)return this.span;let A=0;try{A=this.fields.reduce((U,j)=>{const nt=j.getSpan(l,y);return y+=nt,U+nt},0)}catch{throw new RangeError("indeterminate span")}return A}decode(l,y=0){t(l);const A=this.makeDestinationObject();for(const U of this.fields)if(U.property!==void 0&&(A[U.property]=U.decode(l,y)),y+=U.getSpan(l,y),this.decodePrefixes&&l.length===y)break;return A}encode(l,y,A=0){const U=A;let j=0,nt=0;for(const ct of this.fields){let _t=ct.span;if(nt=0<_t?_t:0,ct.property!==void 0){const pt=l[ct.property];pt!==void 0&&(nt=ct.encode(pt,y,A),0>_t&&(_t=ct.getSpan(y,A)))}j=A,A+=_t}return j+nt-U}fromArray(l){const y=this.makeDestinationObject();for(const A of this.fields)A.property!==void 0&&0<l.length&&(y[A.property]=l.shift());return y}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const y of this.fields)if(y.property===l)return y}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let y=0;for(const A of this.fields){if(A.property===l)return y;0>A.span?y=-1:0<=y&&(y+=A.span)}}}H.Structure=J;class K{constructor(l){this.property=l}decode(l,y){throw new Error("UnionDiscriminator is abstract")}encode(l,y,A){throw new Error("UnionDiscriminator is abstract")}}H.UnionDiscriminator=K;class V extends K{constructor(l,y){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(y||l.property||"variant"),this.layout=l}decode(l,y){return this.layout.decode(l,y)}encode(l,y,A){return this.layout.encode(l,y,A)}}H.UnionLayoutDiscriminator=V;class Q extends r{constructor(l,y,A){let U;if(l instanceof g||l instanceof w)U=new V(new h(l));else if(l instanceof o&&l.isCount())U=new V(l);else if(l instanceof K)U=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(y===void 0&&(y=null),!(y===null||y instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(y!==null){if(0>y.span)throw new Error("defaultLayout must have constant span");y.property===void 0&&(y=y.replicate("content"))}let j=-1;y&&(j=y.span,0<=j&&(l instanceof g||l instanceof w)&&(j+=U.layout.span)),super(j,A),this.discriminator=U,this.usesPrefixDiscriminator=l instanceof g||l instanceof w,this.defaultLayout=y,this.registry={};let nt=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(ct){return nt(ct)},this.configGetSourceVariant=function(ct){nt=ct.bind(this)}}getSpan(l,y=0){if(0<=this.span)return this.span;const A=this.getVariant(l,y);if(!A)throw new Error("unable to determine span for unrecognized variant");return A.getSpan(l,y)}defaultGetSourceVariant(l){if(Object.prototype.hasOwnProperty.call(l,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(l,this.defaultLayout.property))return;const y=this.registry[l[this.discriminator.property]];if(y&&(!y.layout||y.property&&Object.prototype.hasOwnProperty.call(l,y.property)))return y}else for(const y in this.registry){const A=this.registry[y];if(A.property&&Object.prototype.hasOwnProperty.call(l,A.property))return A}throw new Error("unable to infer src variant")}decode(l,y=0){let A;const U=this.discriminator,j=U.decode(l,y),nt=this.registry[j];if(nt===void 0){const ct=this.defaultLayout;let _t=0;this.usesPrefixDiscriminator&&(_t=U.layout.span),A=this.makeDestinationObject(),A[U.property]=j,A[ct.property]=ct.decode(l,y+_t)}else A=nt.decode(l,y);return A}encode(l,y,A=0){const U=this.getSourceVariant(l);if(U===void 0){const j=this.discriminator,nt=this.defaultLayout;let ct=0;return this.usesPrefixDiscriminator&&(ct=j.layout.span),j.encode(l[j.property],y,A),ct+nt.encode(l[nt.property],y,A+ct)}return U.encode(l,y,A)}addVariant(l,y,A){const U=new x(this,l,y,A);return this.registry[l]=U,U}getVariant(l,y=0){let A;return l instanceof Uint8Array?A=this.discriminator.decode(l,y):A=l,this.registry[A]}}H.Union=Q;class x extends r{constructor(l,y,A,U){if(!(l instanceof Q))throw new TypeError("union must be a Union");if(!Number.isInteger(y)||0>y)throw new TypeError("variant must be a (non-negative) integer");if(typeof A=="string"&&U===void 0&&(U=A,A=null),A){if(!(A instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=A.span&&A.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof U!="string")throw new TypeError("variant must have a String property")}let j=l.span;0>l.span&&(j=A?A.span:0,0<=j&&l.usesPrefixDiscriminator&&(j+=l.discriminator.layout.span)),super(j,U),this.union=l,this.variant=y,this.layout=A||null}getSpan(l,y=0){if(0<=this.span)return this.span;let A=0;this.union.usesPrefixDiscriminator&&(A=this.union.discriminator.layout.span);let U=0;return this.layout&&(U=this.layout.getSpan(l,y+A)),A+U}decode(l,y=0){const A=this.makeDestinationObject();if(this!==this.union.getVariant(l,y))throw new Error("variant mismatch");let U=0;return this.union.usesPrefixDiscriminator&&(U=this.union.discriminator.layout.span),this.layout?A[this.property]=this.layout.decode(l,y+U):this.property?A[this.property]=!0:this.union.usesPrefixDiscriminator&&(A[this.union.discriminator.property]=this.variant),A}encode(l,y,A=0){let U=0;if(this.union.usesPrefixDiscriminator&&(U=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(l,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,y,A);let j=U;if(this.layout&&(this.layout.encode(l[this.property],y,A+U),j+=this.layout.getSpan(y,A+U),0<=this.union.span&&j>this.union.span))throw new Error("encoded variant overruns containing union");return j}fromArray(l){if(this.layout)return this.layout.fromArray(l)}}H.VariantLayout=x;function u(c){return 0>c&&(c+=4294967296),c}class p extends r{constructor(l,y,A){if(!(l instanceof g||l instanceof w))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof y=="string"&&A===void 0&&(A=y,y=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,A),this.word=l,this.msb=!!y,this.fields=[];let U=0;this._packedSetValue=function(j){return U=u(j),this},this._packedGetValue=function(){return U}}decode(l,y=0){const A=this.makeDestinationObject(),U=this.word.decode(l,y);this._packedSetValue(U);for(const j of this.fields)j.property!==void 0&&(A[j.property]=j.decode(l));return A}encode(l,y,A=0){const U=this.word.decode(y,A);this._packedSetValue(U);for(const j of this.fields)if(j.property!==void 0){const nt=l[j.property];nt!==void 0&&j.encode(nt)}return this.word.encode(this._packedGetValue(),y,A)}addField(l,y){const A=new m(this,l,y);return this.fields.push(A),A}addBoolean(l){const y=new E(this,l);return this.fields.push(y),y}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const y of this.fields)if(y.property===l)return y}}H.BitStructure=p;class m{constructor(l,y,A){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(y)||0>=y)throw new TypeError("bits must be positive integer");const U=8*l.span,j=l.fields.reduce((nt,ct)=>nt+ct.bits,0);if(y+j>U)throw new Error("bits too long for span remainder ("+(U-j)+" of "+U+" remain)");this.container=l,this.bits=y,this.valueMask=(1<<y)-1,y===32&&(this.valueMask=4294967295),this.start=j,this.container.msb&&(this.start=U-j-y),this.wordMask=u(this.valueMask<<this.start),this.property=A}decode(l,y){const A=this.container._packedGetValue();return u(A&this.wordMask)>>>this.start}encode(l){if(typeof l!="number"||!Number.isInteger(l)||l!==u(l&this.valueMask))throw new TypeError(s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const y=this.container._packedGetValue(),A=u(l<<this.start);this.container._packedSetValue(u(y&~this.wordMask)|A)}}H.BitField=m;class E extends m{constructor(l,y){super(l,1,y)}decode(l,y){return!!super.decode(l,y)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}H.Boolean=E;class S extends r{constructor(l,y){if(!(l instanceof o&&l.isCount()||Number.isInteger(l)&&0<=l))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let A=-1;l instanceof o||(A=l),super(A,y),this.length=l}getSpan(l,y){let A=this.span;return 0>A&&(A=this.length.decode(l,y)),A}decode(l,y=0){let A=this.span;return 0>A&&(A=this.length.decode(l,y)),e(l).slice(y,y+A)}encode(l,y,A){let U=this.length;if(this.length instanceof o&&(U=l.length),!(l instanceof Uint8Array&&U===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+U+") Uint8Array as src");if(A+U>y.length)throw new RangeError("encoding overruns Uint8Array");const j=e(l);return e(y).write(j.toString("hex"),A,U,"hex"),this.length instanceof o&&this.length.encode(U,y,A),U}}H.Blob=S;class I extends r{constructor(l){super(-1,l)}getSpan(l,y=0){t(l);let A=y;for(;A<l.length&&l[A]!==0;)A+=1;return 1+A-y}decode(l,y=0){const A=this.getSpan(l,y);return e(l).slice(y,y+A-1).toString("utf-8")}encode(l,y,A=0){typeof l!="string"&&(l=String(l));const U=n.Buffer.from(l,"utf8"),j=U.length;if(A+j>y.length)throw new RangeError("encoding overruns Buffer");const nt=e(y);return U.copy(nt,A),nt[A+j]=0,j+1}}H.CString=I;class L extends r{constructor(l,y){if(typeof l=="string"&&y===void 0&&(y=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,y),this.maxSpan=l}getSpan(l,y=0){return t(l),l.length-y}decode(l,y=0){const A=this.getSpan(l,y);if(0<=this.maxSpan&&this.maxSpan<A)throw new RangeError("text length exceeds maxSpan");return e(l).slice(y,y+A).toString("utf-8")}encode(l,y,A=0){typeof l!="string"&&(l=String(l));const U=n.Buffer.from(l,"utf8"),j=U.length;if(0<=this.maxSpan&&this.maxSpan<j)throw new RangeError("text length exceeds maxSpan");if(A+j>y.length)throw new RangeError("encoding overruns Buffer");return U.copy(e(y),A),j}}H.UTF8=L;class v extends r{constructor(l,y){super(0,y),this.value=l}decode(l,y){return this.value}encode(l,y,A){return 0}}return H.Constant=v,H.greedy=(c,l)=>new a(c,l),H.offset=(c,l,y)=>new h(c,l,y),H.u8=c=>new g(1,c),H.u16=c=>new g(2,c),H.u24=c=>new g(3,c),H.u32=c=>new g(4,c),H.u40=c=>new g(5,c),H.u48=c=>new g(6,c),H.nu64=c=>new T(c),H.u16be=c=>new w(2,c),H.u24be=c=>new w(3,c),H.u32be=c=>new w(4,c),H.u40be=c=>new w(5,c),H.u48be=c=>new w(6,c),H.nu64be=c=>new O(c),H.s8=c=>new k(1,c),H.s16=c=>new k(2,c),H.s24=c=>new k(3,c),H.s32=c=>new k(4,c),H.s40=c=>new k(5,c),H.s48=c=>new k(6,c),H.ns64=c=>new $(c),H.s16be=c=>new M(2,c),H.s24be=c=>new M(3,c),H.s32be=c=>new M(4,c),H.s40be=c=>new M(5,c),H.s48be=c=>new M(6,c),H.ns64be=c=>new q(c),H.f32=c=>new X(c),H.f32be=c=>new D(c),H.f64=c=>new F(c),H.f64be=c=>new Y(c),H.struct=(c,l,y)=>new J(c,l,y),H.bits=(c,l,y)=>new p(c,l,y),H.seq=(c,l,y)=>new Z(c,l,y),H.union=(c,l,y)=>new Q(c,l,y),H.unionLayoutDiscriminator=(c,l)=>new V(c,l),H.blob=(c,l)=>new S(c,l),H.cstr=c=>new I(c),H.utf8=(c,l)=>new L(c,l),H.constant=(c,l)=>new v(c,l),H}var P=tu(),lr={},ro;function eu(){if(ro)return lr;ro=1,Object.defineProperty(lr,"__esModule",{value:!0});function n(s){{const i=Buffer.from(s);i.reverse();const o=i.toString("hex");return o.length===0?BigInt(0):BigInt(`0x${o}`)}}lr.toBigIntLE=n;function t(s){{const i=s.toString("hex");return i.length===0?BigInt(0):BigInt(`0x${i}`)}}lr.toBigIntBE=t;function e(s,i){{const o=s.toString(16),a=Buffer.from(o.padStart(i*2,"0").slice(0,i*2),"hex");return a.reverse(),a}}lr.toBufferLE=e;function r(s,i){{const o=s.toString(16);return Buffer.from(o.padStart(i*2,"0").slice(0,i*2),"hex")}}return lr.toBufferBE=r,lr}var oi=eu();class ru extends TypeError{constructor(t,e){let r;const{message:s,explanation:i,...o}=t,{path:a}=t,h=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??h),i!=null&&(this.cause=h),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}}function nu(n){return Wr(n)&&typeof n[Symbol.iterator]=="function"}function Wr(n){return typeof n=="object"&&n!=null}function pn(n){return Wr(n)&&!Array.isArray(n)}function Pe(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function iu(n){const{done:t,value:e}=n.next();return t?void 0:e}function su(n,t,e,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:s,branch:i}=t,{type:o}=e,{refinement:a,message:h=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Pe(r)}\``}=n;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...n,message:h}}function*no(n,t,e,r){nu(n)||(n=[n]);for(const s of n){const i=su(s,t,e,r);i&&(yield i)}}function*ai(n,t,e={}){const{path:r=[],branch:s=[n],coerce:i=!1,mask:o=!1}=e,a={path:r,branch:s,mask:o};i&&(n=t.coercer(n,a));let h="valid";for(const g of t.validator(n,a))g.explanation=e.message,h="not_valid",yield[g,void 0];for(let[g,w,k]of t.entries(n,a)){const M=ai(w,k,{path:g===void 0?r:[...r,g],branch:g===void 0?s:[...s,w],coerce:i,mask:o,message:e.message});for(const R of M)R[0]?(h=R[0].refinement!=null?"not_refined":"not_valid",yield[R[0],void 0]):i&&(w=R[1],g===void 0?n=w:n instanceof Map?n.set(g,w):n instanceof Set?n.add(w):Wr(n)&&(w!==void 0||g in n)&&(n[g]=w))}if(h!=="not_valid")for(const g of t.refiner(n,a))g.explanation=e.message,h="not_refined",yield[g,void 0];h==="valid"&&(yield[void 0,n])}let Ue=class{constructor(t){const{type:e,schema:r,validator:s,refiner:i,coercer:o=h=>h,entries:a=function*(){}}=t;this.type=e,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(h,g)=>{const w=s(h,g);return no(w,g,this,h)}:this.validator=()=>[],i?this.refiner=(h,g)=>{const w=i(h,g);return no(w,g,this,h)}:this.refiner=()=>[]}assert(t,e){return io(t,this,e)}create(t,e){return st(t,this,e)}is(t){return so(t,this)}mask(t,e){return ou(t,this,e)}validate(t,e={}){return Dr(t,this,e)}};function io(n,t,e){const r=Dr(n,t,{message:e});if(r[0])throw r[0]}function st(n,t,e){const r=Dr(n,t,{coerce:!0,message:e});if(r[0])throw r[0];return r[1]}function ou(n,t,e){const r=Dr(n,t,{coerce:!0,mask:!0,message:e});if(r[0])throw r[0];return r[1]}function so(n,t){return!Dr(n,t)[0]}function Dr(n,t,e={}){const r=ai(n,t,e),s=iu(r);return s[0]?[new ru(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function fr(n,t){return new Ue({type:n,schema:null,validator:t})}function au(){return fr("any",()=>!0)}function ot(n){return new Ue({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: ${Pe(t)}`}})}function Ne(){return fr("boolean",n=>typeof n=="boolean")}function ci(n){return fr("instance",t=>t instanceof n||`Expected a \`${n.name}\` instance, but received: ${Pe(t)}`)}function Ht(n){const t=Pe(n),e=typeof n;return new Ue({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${t}\`, but received: ${Pe(r)}`}})}function cu(){return fr("never",()=>!1)}function at(n){return new Ue({...n,validator:(t,e)=>t===null||n.validator(t,e),refiner:(t,e)=>t===null||n.refiner(t,e)})}function W(){return fr("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${Pe(n)}`)}function ft(n){return new Ue({...n,validator:(t,e)=>t===void 0||n.validator(t,e),refiner:(t,e)=>t===void 0||n.refiner(t,e)})}function oo(n,t){return new Ue({type:"record",schema:null,*entries(e){if(Wr(e))for(const r in e){const s=e[r];yield[r,r,n],yield[r,s,t]}},validator(e){return pn(e)||`Expected an object, but received: ${Pe(e)}`},coercer(e){return pn(e)?{...e}:e}})}function rt(){return fr("string",n=>typeof n=="string"||`Expected a string, but received: ${Pe(n)}`)}function ui(n){const t=cu();return new Ue({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const r=Math.max(n.length,e.length);for(let s=0;s<r;s++)yield[s,e[s],n[s]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Pe(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function tt(n){const t=Object.keys(n);return new Ue({type:"type",schema:n,*entries(e){if(Wr(e))for(const r of t)yield[r,e[r],n[r]]},validator(e){return pn(e)||`Expected an object, but received: ${Pe(e)}`},coercer(e){return pn(e)?{...e}:e}})}function Ie(n){const t=n.map(e=>e.type).join(" | ");return new Ue({type:"union",schema:null,coercer(e,r){for(const s of n){const[i,o]=s.validate(e,{coerce:!0,mask:r.mask});if(!i)return o}return e},validator(e,r){const s=[];for(const i of n){const[...o]=ai(e,i,r),[a]=o;if(a[0])for(const[h]of o)h&&s.push(h);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Pe(e)}`,...s]}})}function Br(){return fr("unknown",()=>!0)}function $r(n,t,e){return new Ue({...n,coercer:(r,s)=>so(r,t)?n.coercer(e(r,s),s):n.coercer(r,s)})}var gn,uu=new Uint8Array(16);function ao(){if(!gn&&(gn=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!gn))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return gn(uu)}const lu=/^(?:[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 yn(n){return typeof n=="string"&&lu.test(n)}for(var we=[],li=0;li<256;++li)we.push((li+256).toString(16).substr(1));function mn(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(we[n[t+0]]+we[n[t+1]]+we[n[t+2]]+we[n[t+3]]+"-"+we[n[t+4]]+we[n[t+5]]+"-"+we[n[t+6]]+we[n[t+7]]+"-"+we[n[t+8]]+we[n[t+9]]+"-"+we[n[t+10]]+we[n[t+11]]+we[n[t+12]]+we[n[t+13]]+we[n[t+14]]+we[n[t+15]]).toLowerCase();if(!yn(e))throw TypeError("Stringified UUID is invalid");return e}var co,fi,hi=0,di=0;function fu(n,t,e){var r=t&&e||0,s=t||new Array(16);n=n||{};var i=n.node||co,o=n.clockseq!==void 0?n.clockseq:fi;if(i==null||o==null){var a=n.random||(n.rng||ao)();i==null&&(i=co=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=fi=(a[6]<<8|a[7])&16383)}var h=n.msecs!==void 0?n.msecs:Date.now(),g=n.nsecs!==void 0?n.nsecs:di+1,w=h-hi+(g-di)/1e4;if(w<0&&n.clockseq===void 0&&(o=o+1&16383),(w<0||h>hi)&&n.nsecs===void 0&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");hi=h,di=g,fi=o,h+=122192928e5;var k=((h&268435455)*1e4+g)%4294967296;s[r++]=k>>>24&255,s[r++]=k>>>16&255,s[r++]=k>>>8&255,s[r++]=k&255;var M=h/4294967296*1e4&268435455;s[r++]=M>>>8&255,s[r++]=M&255,s[r++]=M>>>24&15|16,s[r++]=M>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var R=0;R<6;++R)s[r+R]=i[R];return t||mn(s)}function uo(n){if(!yn(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 hu(n){n=unescape(encodeURIComponent(n));for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var du="6ba7b810-9dad-11d1-80b4-00c04fd430c8",pu="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function lo(n,t,e){function r(s,i,o,a){if(typeof s=="string"&&(s=hu(s)),typeof i=="string"&&(i=uo(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var h=new Uint8Array(16+s.length);if(h.set(i),h.set(s,i.length),h=e(h),h[6]=h[6]&15|t,h[8]=h[8]&63|128,o){a=a||0;for(var g=0;g<16;++g)o[a+g]=h[g];return o}return mn(h)}try{r.name=n}catch{}return r.DNS=du,r.URL=pu,r}function gu(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 yu(mu(wu(n),n.length*8))}function yu(n){for(var t=[],e=n.length*32,r="0123456789abcdef",s=0;s<e;s+=8){var i=n[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);t.push(o)}return t}function fo(n){return(n+64>>>9<<4)+14+1}function mu(n,t){n[t>>5]|=128<<t%32,n[fo(t)-1]=t;for(var e=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<n.length;o+=16){var a=e,h=r,g=s,w=i;e=be(e,r,s,i,n[o],7,-680876936),i=be(i,e,r,s,n[o+1],12,-389564586),s=be(s,i,e,r,n[o+2],17,606105819),r=be(r,s,i,e,n[o+3],22,-1044525330),e=be(e,r,s,i,n[o+4],7,-176418897),i=be(i,e,r,s,n[o+5],12,1200080426),s=be(s,i,e,r,n[o+6],17,-1473231341),r=be(r,s,i,e,n[o+7],22,-45705983),e=be(e,r,s,i,n[o+8],7,1770035416),i=be(i,e,r,s,n[o+9],12,-1958414417),s=be(s,i,e,r,n[o+10],17,-42063),r=be(r,s,i,e,n[o+11],22,-1990404162),e=be(e,r,s,i,n[o+12],7,1804603682),i=be(i,e,r,s,n[o+13],12,-40341101),s=be(s,i,e,r,n[o+14],17,-1502002290),r=be(r,s,i,e,n[o+15],22,1236535329),e=ke(e,r,s,i,n[o+1],5,-165796510),i=ke(i,e,r,s,n[o+6],9,-1069501632),s=ke(s,i,e,r,n[o+11],14,643717713),r=ke(r,s,i,e,n[o],20,-373897302),e=ke(e,r,s,i,n[o+5],5,-701558691),i=ke(i,e,r,s,n[o+10],9,38016083),s=ke(s,i,e,r,n[o+15],14,-660478335),r=ke(r,s,i,e,n[o+4],20,-405537848),e=ke(e,r,s,i,n[o+9],5,568446438),i=ke(i,e,r,s,n[o+14],9,-1019803690),s=ke(s,i,e,r,n[o+3],14,-187363961),r=ke(r,s,i,e,n[o+8],20,1163531501),e=ke(e,r,s,i,n[o+13],5,-1444681467),i=ke(i,e,r,s,n[o+2],9,-51403784),s=ke(s,i,e,r,n[o+7],14,1735328473),r=ke(r,s,i,e,n[o+12],20,-1926607734),e=ve(e,r,s,i,n[o+5],4,-378558),i=ve(i,e,r,s,n[o+8],11,-2022574463),s=ve(s,i,e,r,n[o+11],16,1839030562),r=ve(r,s,i,e,n[o+14],23,-35309556),e=ve(e,r,s,i,n[o+1],4,-1530992060),i=ve(i,e,r,s,n[o+4],11,1272893353),s=ve(s,i,e,r,n[o+7],16,-155497632),r=ve(r,s,i,e,n[o+10],23,-1094730640),e=ve(e,r,s,i,n[o+13],4,681279174),i=ve(i,e,r,s,n[o],11,-358537222),s=ve(s,i,e,r,n[o+3],16,-722521979),r=ve(r,s,i,e,n[o+6],23,76029189),e=ve(e,r,s,i,n[o+9],4,-640364487),i=ve(i,e,r,s,n[o+12],11,-421815835),s=ve(s,i,e,r,n[o+15],16,530742520),r=ve(r,s,i,e,n[o+2],23,-995338651),e=Se(e,r,s,i,n[o],6,-198630844),i=Se(i,e,r,s,n[o+7],10,1126891415),s=Se(s,i,e,r,n[o+14],15,-1416354905),r=Se(r,s,i,e,n[o+5],21,-57434055),e=Se(e,r,s,i,n[o+12],6,1700485571),i=Se(i,e,r,s,n[o+3],10,-1894986606),s=Se(s,i,e,r,n[o+10],15,-1051523),r=Se(r,s,i,e,n[o+1],21,-2054922799),e=Se(e,r,s,i,n[o+8],6,1873313359),i=Se(i,e,r,s,n[o+15],10,-30611744),s=Se(s,i,e,r,n[o+6],15,-1560198380),r=Se(r,s,i,e,n[o+13],21,1309151649),e=Se(e,r,s,i,n[o+4],6,-145523070),i=Se(i,e,r,s,n[o+11],10,-1120210379),s=Se(s,i,e,r,n[o+2],15,718787259),r=Se(r,s,i,e,n[o+9],21,-343485551),e=tr(e,a),r=tr(r,h),s=tr(s,g),i=tr(i,w)}return[e,r,s,i]}function wu(n){if(n.length===0)return[];for(var t=n.length*8,e=new Uint32Array(fo(t)),r=0;r<t;r+=8)e[r>>5]|=(n[r/8]&255)<<r%32;return e}function tr(n,t){var e=(n&65535)+(t&65535),r=(n>>16)+(t>>16)+(e>>16);return r<<16|e&65535}function bu(n,t){return n<<t|n>>>32-t}function wn(n,t,e,r,s,i){return tr(bu(tr(tr(t,n),tr(r,i)),s),e)}function be(n,t,e,r,s,i,o){return wn(t&e|~t&r,n,t,s,i,o)}function ke(n,t,e,r,s,i,o){return wn(t&r|e&~r,n,t,s,i,o)}function ve(n,t,e,r,s,i,o){return wn(t^e^r,n,t,s,i,o)}function Se(n,t,e,r,s,i,o){return wn(e^(t|~r),n,t,s,i,o)}var ku=lo("v3",48,gu);function vu(n,t,e){n=n||{};var r=n.random||(n.rng||ao)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){e=e||0;for(var s=0;s<16;++s)t[e+s]=r[s];return t}return mn(r)}function Su(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 pi(n,t){return n<<t|n>>>32-t}function xu(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 s=0;s<r.length;++s)n.push(r.charCodeAt(s))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var i=n.length/4+2,o=Math.ceil(i/16),a=new Array(o),h=0;h<o;++h){for(var g=new Uint32Array(16),w=0;w<16;++w)g[w]=n[h*64+w*4]<<24|n[h*64+w*4+1]<<16|n[h*64+w*4+2]<<8|n[h*64+w*4+3];a[h]=g}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 k=0;k<o;++k){for(var M=new Uint32Array(80),R=0;R<16;++R)M[R]=a[k][R];for(var C=16;C<80;++C)M[C]=pi(M[C-3]^M[C-8]^M[C-14]^M[C-16],1);for(var B=e[0],T=e[1],O=e[2],$=e[3],q=e[4],X=0;X<80;++X){var D=Math.floor(X/20),F=pi(B,5)+Su(D,T,O,$)+q+t[D]+M[X]>>>0;q=$,$=O,O=pi(T,30)>>>0,T=B,B=F}e[0]=e[0]+B>>>0,e[1]=e[1]+T>>>0,e[2]=e[2]+O>>>0,e[3]=e[3]+$>>>0,e[4]=e[4]+q>>>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 Iu=lo("v5",80,xu);const Eu="00000000-0000-0000-0000-000000000000";function _u(n){if(!yn(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const ho=Fn(Object.freeze(Object.defineProperty({__proto__:null,NIL:Eu,parse:uo,stringify:mn,v1:fu,v3:ku,v4:vu,v5:Iu,validate:yn,version:_u},Symbol.toStringTag,{value:"Module"})));var gi,po;function Bu(){if(po)return gi;po=1;const n=ho.v4;return gi=function(e,r,s,i){if(typeof e!="string")throw new TypeError(e+" must be a string");i=i||{};const o=typeof i.version=="number"?i.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const a={method:e};if(o===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof s>"u"){const h=typeof i.generator=="function"?i.generator:function(){return n()};a.id=h(a,i)}else o===2&&s===null?i.notificationIdNull&&(a.id=null):a.id=s;return a},gi}var yi,go;function Au(){if(go)return yi;go=1;const n=ho.v4,t=Bu(),e=function(r,s){if(!(this instanceof e))return new e(r,s);s||(s={}),this.options={reviver:typeof s.reviver<"u"?s.reviver:null,replacer:typeof s.replacer<"u"?s.replacer:null,generator:typeof s.generator<"u"?s.generator:function(){return n()},version:typeof s.version<"u"?s.version:2,notificationIdNull:typeof s.notificationIdNull=="boolean"?s.notificationIdNull:!1},this.callServer=r};return yi=e,e.prototype.request=function(r,s,i,o){const a=this;let h=null;const g=Array.isArray(r)&&typeof s=="function";if(this.options.version===1&&g)throw new TypeError("JSON-RPC 1.0 does not support batching");if(g||!g&&r&&typeof r=="object"&&typeof s=="function")o=s,h=r;else{typeof i=="function"&&(o=i,i=void 0);const M=typeof o=="function";try{h=t(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(R){if(M)return o(R);throw R}if(!M)return h}let k;try{k=JSON.stringify(h,this.options.replacer)}catch(M){return o(M)}return this.callServer(k,function(M,R){a._parseResponse(M,R,o)}),h},e.prototype._parseResponse=function(r,s,i){if(r){i(r);return}if(!s)return i();let o;try{o=JSON.parse(s,this.options.reviver)}catch(a){return i(a)}if(i.length===3)if(Array.isArray(o)){const a=function(g){return typeof g.error<"u"},h=function(g){return!a(g)};return i(null,o.filter(a),o.filter(h))}else return i(null,o.error,o.result);i(null,o)},yi}var Ru=Au();const Tu=Nr(Ru);var mi={exports:{}},yo;function Mu(){return yo||(yo=1,function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function s(h,g,w){this.fn=h,this.context=g,this.once=w||!1}function i(h,g,w,k,M){if(typeof w!="function")throw new TypeError("The listener must be a function");var R=new s(w,k||h,M),C=e?e+g:g;return h._events[C]?h._events[C].fn?h._events[C]=[h._events[C],R]:h._events[C].push(R):(h._events[C]=R,h._eventsCount++),h}function o(h,g){--h._eventsCount===0?h._events=new r:delete h._events[g]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var g=[],w,k;if(this._eventsCount===0)return g;for(k in w=this._events)t.call(w,k)&&g.push(e?k.slice(1):k);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(w)):g},a.prototype.listeners=function(g){var w=e?e+g:g,k=this._events[w];if(!k)return[];if(k.fn)return[k.fn];for(var M=0,R=k.length,C=new Array(R);M<R;M++)C[M]=k[M].fn;return C},a.prototype.listenerCount=function(g){var w=e?e+g:g,k=this._events[w];return k?k.fn?1:k.length:0},a.prototype.emit=function(g,w,k,M,R,C){var B=e?e+g:g;if(!this._events[B])return!1;var T=this._events[B],O=arguments.length,$,q;if(T.fn){switch(T.once&&this.removeListener(g,T.fn,void 0,!0),O){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,w),!0;case 3:return T.fn.call(T.context,w,k),!0;case 4:return T.fn.call(T.context,w,k,M),!0;case 5:return T.fn.call(T.context,w,k,M,R),!0;case 6:return T.fn.call(T.context,w,k,M,R,C),!0}for(q=1,$=new Array(O-1);q<O;q++)$[q-1]=arguments[q];T.fn.apply(T.context,$)}else{var X=T.length,D;for(q=0;q<X;q++)switch(T[q].once&&this.removeListener(g,T[q].fn,void 0,!0),O){case 1:T[q].fn.call(T[q].context);break;case 2:T[q].fn.call(T[q].context,w);break;case 3:T[q].fn.call(T[q].context,w,k);break;case 4:T[q].fn.call(T[q].context,w,k,M);break;default:if(!$)for(D=1,$=new Array(O-1);D<O;D++)$[D-1]=arguments[D];T[q].fn.apply(T[q].context,$)}}return!0},a.prototype.on=function(g,w,k){return i(this,g,w,k,!1)},a.prototype.once=function(g,w,k){return i(this,g,w,k,!0)},a.prototype.removeListener=function(g,w,k,M){var R=e?e+g:g;if(!this._events[R])return this;if(!w)return o(this,R),this;var C=this._events[R];if(C.fn)C.fn===w&&(!M||C.once)&&(!k||C.context===k)&&o(this,R);else{for(var B=0,T=[],O=C.length;B<O;B++)(C[B].fn!==w||M&&!C[B].once||k&&C[B].context!==k)&&T.push(C[B]);T.length?this._events[R]=T.length===1?T[0]:T:o(this,R)}return this},a.prototype.removeAllListeners=function(g){var w;return g?(w=e?e+g:g,this._events[w]&&o(this,w)):(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}(mi)),mi.exports}var Pu=Mu();const mo=Nr(Pu);var Cu=class extends mo{constructor(t,e,r){super();he(this,"socket");this.socket=new window.WebSocket(t,r),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=s=>this.emit("message",s.data),this.socket.onerror=s=>this.emit("error",s),this.socket.onclose=s=>{this.emit("close",s.code,s.reason)}}send(t,e,r){const s=r||e;try{this.socket.send(t),s()}catch(i){s(i)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,r){this.socket.addEventListener(t,e,r)}};function Lu(n,t){return new Cu(n,t)}var Ou=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},Uu=class extends mo{constructor(t,e="ws://localhost:8080",{autoconnect:r=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...a}={},h,g){super();he(this,"address");he(this,"rpc_id");he(this,"queue");he(this,"options");he(this,"autoconnect");he(this,"ready");he(this,"reconnect");he(this,"reconnect_timer_id");he(this,"reconnect_interval");he(this,"max_reconnects");he(this,"rest_options");he(this,"current_reconnects");he(this,"generate_request_id");he(this,"socket");he(this,"webSocketFactory");he(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=r,this.ready=!1,this.reconnect=s,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=h||(()=>++this.rpc_id),g?this.dataPack=g:this.dataPack=new Ou,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,s){return!s&&typeof r=="object"&&(s=r,r=null),new Promise((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(t,e),h={jsonrpc:"2.0",method:t,params:e||void 0,id:a};this.socket.send(this.dataPack.encode(h),s,g=>{if(g)return o(g);this.queue[a]={promise:[i,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,s)=>{if(!this.ready)return s(new Error("socket not ready"));const i={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(i),o=>{if(o)return s(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=lt.Buffer.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 s=[r.notification];if(r.params.constructor===Object)s.push(r.params);else for(let i=0;i<r.params.length;i++)s.push(r.params[i]);return Promise.resolve().then(()=>{this.emit.apply(this,s)})}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:s})=>{this.ready&&setTimeout(()=>this.emit("close",r,s),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 wo=[],bo=[],ko=[],Nu=BigInt(0),Hr=BigInt(1),Fu=BigInt(2),zu=BigInt(7),qu=BigInt(256),Ku=BigInt(113);for(let n=0,t=Hr,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],wo.push(2*(5*r+e)),bo.push((n+1)*(n+2)/2%64);let s=Nu;for(let i=0;i<7;i++)t=(t<<Hr^(t>>zu)*Ku)%qu,t&Fu&&(s^=Hr<<(Hr<<BigInt(i))-Hr);ko.push(s)}const[Wu,Du]=As(ko,!0),vo=(n,t,e)=>e>32?Ms(n,t,e):Rs(n,t,e),So=(n,t,e)=>e>32?Ps(n,t,e):Ts(n,t,e);function $u(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,h=(o+2)%10,g=e[h],w=e[h+1],k=vo(g,w,1)^e[a],M=So(g,w,1)^e[a+1];for(let R=0;R<50;R+=10)n[o+R]^=k,n[o+R+1]^=M}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=bo[o],h=vo(s,i,a),g=So(s,i,a),w=wo[o];s=n[w],i=n[w+1],n[w]=h,n[w+1]=g}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]^=Wu[r],n[1]^=Du[r]}e.fill(0)}class wi extends Dn{constructor(t,e,r,s=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,en(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=qa(this.state)}keccak(){xs||Is(this.state32),$u(this.state32,this.rounds),xs||Is(this.state32),this.posOut=0,this.pos=0}update(t){kr(this);const{blockLen:e,state:r}=this;t=rn(t);const s=t.length;for(let i=0;i<s;){const o=Math.min(e-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:s}=this;t[r]^=e,e&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){kr(this,!1),zr(t),this.finish();const e=this.state,{blockLen:r}=this;for(let s=0,i=t.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);t.set(e.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=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 en(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ss(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:s,rounds:i,enableXOF:o}=this;return t||(t=new wi(e,r,s,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=s,t.enableXOF=o,t.destroyed=this.destroyed,t}}const xo=((n,t,e)=>$n(()=>new wi(t,n,e)))(1,136,256/8);class Io extends Dn{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,za(t);const r=rn(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 s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(t){return kr(this),this.iHash.update(t),this}digestInto(t){kr(this),zr(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:s,destroyed:i,blockLen:o,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=i,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 Eo=(n,t,e)=>new Io(n,t).update(e).digest();Eo.create=(n,t)=>new Io(n,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Hu(n){const t=Xn(n);Ir(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:s}=t;if(e){if(!r.eql(s,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:Vu,hexToBytes:ju}=yc,hr={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(n){const{Err:t}=hr;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:Vu(r),l:n.subarray(e+2)}},toSig(n){const{Err:t}=hr,e=typeof n=="string"?ju(n):n;qr(e);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:s,l:i}=hr._parseInt(e.subarray(2)),{d:o,l:a}=hr._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const t=g=>Number.parseInt(g[0],16)&8?"00"+g:g,e=g=>{const w=g.toString(16);return w.length&1?`0${w}`:w},r=t(e(n.s)),s=t(e(n.r)),i=r.length/2,o=s.length/2,a=e(i),h=e(o);return`30${e(o+i+4)}02${h}${s}02${a}${r}`}},je=BigInt(0),Te=BigInt(1);BigInt(2);const _o=BigInt(3);BigInt(4);function Gu(n){const t=Hu(n),{Fp:e}=t,r=t.toBytes||((C,B,T)=>{const O=B.toAffine();return cr(Uint8Array.from([4]),e.toBytes(O.x),e.toBytes(O.y))}),s=t.fromBytes||(C=>{const B=C.subarray(1),T=e.fromBytes(B.subarray(0,e.BYTES)),O=e.fromBytes(B.subarray(e.BYTES,2*e.BYTES));return{x:T,y:O}});function i(C){const{a:B,b:T}=t,O=e.sqr(C),$=e.mul(O,C);return e.add(e.add($,e.mul(C,B)),T)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function o(C){return typeof C=="bigint"&&je<C&&C<t.n}function a(C){if(!o(C))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function h(C){const{allowedPrivateKeyLengths:B,nByteLength:T,wrapPrivateKey:O,n:$}=t;if(B&&typeof C!="bigint"){if(sr(C)&&(C=or(C)),typeof C!="string"||!B.includes(C.length))throw new Error("Invalid key");C=C.padStart(T*2,"0")}let q;try{q=typeof C=="bigint"?C:ar(de("private key",C,T))}catch{throw new Error(`private key must be ${T} bytes, hex or bigint, not ${typeof C}`)}return O&&(q=Wt(q,$)),a(q),q}const g=new Map;function w(C){if(!(C instanceof k))throw new Error("ProjectivePoint expected")}class k{constructor(B,T,O){if(this.px=B,this.py=T,this.pz=O,B==null||!e.isValid(B))throw new Error("x required");if(T==null||!e.isValid(T))throw new Error("y required");if(O==null||!e.isValid(O))throw new Error("z required")}static fromAffine(B){const{x:T,y:O}=B||{};if(!B||!e.isValid(T)||!e.isValid(O))throw new Error("invalid affine point");if(B instanceof k)throw new Error("projective point not allowed");const $=q=>e.eql(q,e.ZERO);return $(T)&&$(O)?k.ZERO:new k(T,O,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(B){const T=e.invertBatch(B.map(O=>O.pz));return B.map((O,$)=>O.toAffine(T[$])).map(k.fromAffine)}static fromHex(B){const T=k.fromAffine(s(de("pointHex",B)));return T.assertValidity(),T}static fromPrivateKey(B){return k.BASE.multiply(h(B))}_setWindowSize(B){this._WINDOW_SIZE=B,g.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:B,y:T}=this.toAffine();if(!e.isValid(B)||!e.isValid(T))throw new Error("bad point: x or y not FE");const O=e.sqr(T),$=i(B);if(!e.eql(O,$))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:B}=this.toAffine();if(e.isOdd)return!e.isOdd(B);throw new Error("Field doesn't support isOdd")}equals(B){w(B);const{px:T,py:O,pz:$}=this,{px:q,py:X,pz:D}=B,F=e.eql(e.mul(T,D),e.mul(q,$)),Y=e.eql(e.mul(O,D),e.mul(X,$));return F&&Y}negate(){return new k(this.px,e.neg(this.py),this.pz)}double(){const{a:B,b:T}=t,O=e.mul(T,_o),{px:$,py:q,pz:X}=this;let D=e.ZERO,F=e.ZERO,Y=e.ZERO,Z=e.mul($,$),J=e.mul(q,q),K=e.mul(X,X),V=e.mul($,q);return V=e.add(V,V),Y=e.mul($,X),Y=e.add(Y,Y),D=e.mul(B,Y),F=e.mul(O,K),F=e.add(D,F),D=e.sub(J,F),F=e.add(J,F),F=e.mul(D,F),D=e.mul(V,D),Y=e.mul(O,Y),K=e.mul(B,K),V=e.sub(Z,K),V=e.mul(B,V),V=e.add(V,Y),Y=e.add(Z,Z),Z=e.add(Y,Z),Z=e.add(Z,K),Z=e.mul(Z,V),F=e.add(F,Z),K=e.mul(q,X),K=e.add(K,K),Z=e.mul(K,V),D=e.sub(D,Z),Y=e.mul(K,J),Y=e.add(Y,Y),Y=e.add(Y,Y),new k(D,F,Y)}add(B){w(B);const{px:T,py:O,pz:$}=this,{px:q,py:X,pz:D}=B;let F=e.ZERO,Y=e.ZERO,Z=e.ZERO;const J=t.a,K=e.mul(t.b,_o);let V=e.mul(T,q),Q=e.mul(O,X),x=e.mul($,D),u=e.add(T,O),p=e.add(q,X);u=e.mul(u,p),p=e.add(V,Q),u=e.sub(u,p),p=e.add(T,$);let m=e.add(q,D);return p=e.mul(p,m),m=e.add(V,x),p=e.sub(p,m),m=e.add(O,$),F=e.add(X,D),m=e.mul(m,F),F=e.add(Q,x),m=e.sub(m,F),Z=e.mul(J,p),F=e.mul(K,x),Z=e.add(F,Z),F=e.sub(Q,Z),Z=e.add(Q,Z),Y=e.mul(F,Z),Q=e.add(V,V),Q=e.add(Q,V),x=e.mul(J,x),p=e.mul(K,p),Q=e.add(Q,x),x=e.sub(V,x),x=e.mul(J,x),p=e.add(p,x),V=e.mul(Q,p),Y=e.add(Y,V),V=e.mul(m,p),F=e.mul(u,F),F=e.sub(F,V),V=e.mul(u,Q),Z=e.mul(m,Z),Z=e.add(Z,V),new k(F,Y,Z)}subtract(B){return this.add(B.negate())}is0(){return this.equals(k.ZERO)}wNAF(B){return R.wNAFCached(this,g,B,T=>{const O=e.invertBatch(T.map($=>$.pz));return T.map(($,q)=>$.toAffine(O[q])).map(k.fromAffine)})}multiplyUnsafe(B){const T=k.ZERO;if(B===je)return T;if(a(B),B===Te)return this;const{endo:O}=t;if(!O)return R.unsafeLadder(this,B);let{k1neg:$,k1:q,k2neg:X,k2:D}=O.splitScalar(B),F=T,Y=T,Z=this;for(;q>je||D>je;)q&Te&&(F=F.add(Z)),D&Te&&(Y=Y.add(Z)),Z=Z.double(),q>>=Te,D>>=Te;return $&&(F=F.negate()),X&&(Y=Y.negate()),Y=new k(e.mul(Y.px,O.beta),Y.py,Y.pz),F.add(Y)}multiply(B){a(B);let T=B,O,$;const{endo:q}=t;if(q){const{k1neg:X,k1:D,k2neg:F,k2:Y}=q.splitScalar(T);let{p:Z,f:J}=this.wNAF(D),{p:K,f:V}=this.wNAF(Y);Z=R.constTimeNegate(X,Z),K=R.constTimeNegate(F,K),K=new k(e.mul(K.px,q.beta),K.py,K.pz),O=Z.add(K),$=J.add(V)}else{const{p:X,f:D}=this.wNAF(T);O=X,$=D}return k.normalizeZ([O,$])[0]}multiplyAndAddUnsafe(B,T,O){const $=k.BASE,q=(D,F)=>F===je||F===Te||!D.equals($)?D.multiplyUnsafe(F):D.multiply(F),X=q(this,T).add(q(B,O));return X.is0()?void 0:X}toAffine(B){const{px:T,py:O,pz:$}=this,q=this.is0();B==null&&(B=q?e.ONE:e.inv($));const X=e.mul(T,B),D=e.mul(O,B),F=e.mul($,B);if(q)return{x:e.ZERO,y:e.ZERO};if(!e.eql(F,e.ONE))throw new Error("invZ was invalid");return{x:X,y:D}}isTorsionFree(){const{h:B,isTorsionFree:T}=t;if(B===Te)return!0;if(T)return T(k,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:B,clearCofactor:T}=t;return B===Te?this:T?T(k,this):this.multiplyUnsafe(t.h)}toRawBytes(B=!0){return this.assertValidity(),r(k,this,B)}toHex(B=!0){return or(this.toRawBytes(B))}}k.BASE=new k(t.Gx,t.Gy,e.ONE),k.ZERO=new k(e.ZERO,e.ONE,e.ZERO);const M=t.nBitLength,R=$s(k,t.endo?Math.ceil(M/2):M);return{CURVE:t,ProjectivePoint:k,normPrivateKeyToScalar:h,weierstrassEquation:i,isWithinCurveOrder:o}}function Zu(n){const t=Xn(n);return Ir(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Yu(n){const t=Zu(n),{Fp:e,n:r}=t,s=e.BYTES+1,i=2*e.BYTES+1;function o(p){return je<p&&p<e.ORDER}function a(p){return Wt(p,r)}function h(p){return Yn(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:w,weierstrassEquation:k,isWithinCurveOrder:M}=Gu({...t,toBytes(p,m,E){const S=m.toAffine(),I=e.toBytes(S.x),L=cr;return E?L(Uint8Array.from([m.hasEvenY()?2:3]),I):L(Uint8Array.from([4]),I,e.toBytes(S.y))},fromBytes(p){const m=p.length,E=p[0],S=p.subarray(1);if(m===s&&(E===2||E===3)){const I=ar(S);if(!o(I))throw new Error("Point is not on curve");const L=k(I);let v;try{v=e.sqrt(L)}catch(y){const A=y instanceof Error?": "+y.message:"";throw new Error("Point is not on curve"+A)}const c=(v&Te)===Te;return(E&1)===1!==c&&(v=e.neg(v)),{x:I,y:v}}else if(m===i&&E===4){const I=e.fromBytes(S.subarray(0,e.BYTES)),L=e.fromBytes(S.subarray(e.BYTES,2*e.BYTES));return{x:I,y:L}}else throw new Error(`Point of length ${m} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),R=p=>or(xr(p,t.nByteLength));function C(p){const m=r>>Te;return p>m}function B(p){return C(p)?a(-p):p}const T=(p,m,E)=>ar(p.slice(m,E));class O{constructor(m,E,S){this.r=m,this.s=E,this.recovery=S,this.assertValidity()}static fromCompact(m){const E=t.nByteLength;return m=de("compactSignature",m,E*2),new O(T(m,0,E),T(m,E,2*E))}static fromDER(m){const{r:E,s:S}=hr.toSig(de("DER",m));return new O(E,S)}assertValidity(){if(!M(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!M(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(m){return new O(this.r,this.s,m)}recoverPublicKey(m){const{r:E,s:S,recovery:I}=this,L=Y(de("msgHash",m));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");const v=I===2||I===3?E+t.n:E;if(v>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=I&1?"03":"02",l=g.fromHex(c+R(v)),y=h(v),A=a(-L*y),U=a(S*y),j=g.BASE.multiplyAndAddUnsafe(l,A,U);if(!j)throw new Error("point at infinify");return j.assertValidity(),j}hasHighS(){return C(this.s)}normalizeS(){return this.hasHighS()?new O(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return vr(this.toDERHex())}toDERHex(){return hr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return vr(this.toCompactHex())}toCompactHex(){return R(this.r)+R(this.s)}}const $={isValidPrivateKey(p){try{return w(p),!0}catch{return!1}},normPrivateKeyToScalar:w,randomPrivateKey:()=>{const p=Ds(t.n);return _c(t.randomBytes(p),t.n)},precompute(p=8,m=g.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function q(p,m=!0){return g.fromPrivateKey(p).toRawBytes(m)}function X(p){const m=sr(p),E=typeof p=="string",S=(m||E)&&p.length;return m?S===s||S===i:E?S===2*s||S===2*i:p instanceof g}function D(p,m,E=!0){if(X(p))throw new Error("first arg must be private key");if(!X(m))throw new Error("second arg must be public key");return g.fromHex(m).multiply(w(p)).toRawBytes(E)}const F=t.bits2int||function(p){const m=ar(p),E=p.length*8-t.nBitLength;return E>0?m>>BigInt(E):m},Y=t.bits2int_modN||function(p){return a(F(p))},Z=jn(t.nBitLength);function J(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(je<=p&&p<Z))throw new Error(`bigint expected < 2^${t.nBitLength}`);return xr(p,t.nByteLength)}function K(p,m,E=V){if(["recovered","canonical"].some(ct=>ct in E))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:I}=t;let{lowS:L,prehash:v,extraEntropy:c}=E;L==null&&(L=!0),p=de("msgHash",p),v&&(p=de("prehashed msgHash",S(p)));const l=Y(p),y=w(m),A=[J(y),J(l)];if(c!=null&&c!==!1){const ct=c===!0?I(e.BYTES):c;A.push(de("extraEntropy",ct))}const U=cr(...A),j=l;function nt(ct){const _t=F(ct);if(!M(_t))return;const pt=h(_t),vt=g.BASE.multiply(_t).toAffine(),At=a(vt.x);if(At===je)return;const St=a(pt*a(j+At*y));if(St===je)return;let Tt=(vt.x===At?0:2)|Number(vt.y&Te),$e=St;return L&&C(St)&&($e=B(St),Tt^=1),new O(At,$e,Tt)}return{seed:U,k2sig:nt}}const V={lowS:t.lowS,prehash:!1},Q={lowS:t.lowS,prehash:!1};function x(p,m,E=V){const{seed:S,k2sig:I}=K(p,m,E),L=t;return Ns(L.hash.outputLen,L.nByteLength,L.hmac)(S,I)}g.BASE._setWindowSize(8);function u(p,m,E,S=Q){var vt;const I=p;if(m=de("msgHash",m),E=de("publicKey",E),"strict"in S)throw new Error("options.strict was renamed to lowS");const{lowS:L,prehash:v}=S;let c,l;try{if(typeof I=="string"||sr(I))try{c=O.fromDER(I)}catch(At){if(!(At instanceof hr.Err))throw At;c=O.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:At,s:St}=I;c=new O(At,St)}else throw new Error("PARSE");l=g.fromHex(E)}catch(At){if(At.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(L&&c.hasHighS())return!1;v&&(m=t.hash(m));const{r:y,s:A}=c,U=Y(m),j=h(A),nt=a(U*j),ct=a(y*j),_t=(vt=g.BASE.multiplyAndAddUnsafe(l,nt,ct))==null?void 0:vt.toAffine();return _t?a(_t.x)===y:!1}return{CURVE:t,getPublicKey:q,getSharedSecret:D,sign:x,verify:u,ProjectivePoint:g,Signature:O,utils:$}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ju(n){return{hash:n,hmac:(t,...e)=>Eo(n,t,Da(...e)),randomBytes:Es}}function Xu(n,t){const e=r=>Yu({...n,...Ju(r)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Bo=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ao=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Qu=BigInt(1),bi=BigInt(2),Ro=(n,t)=>(n+t/bi)/t;function tl(n){const t=Bo,e=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),h=BigInt(88),g=n*n*n%t,w=g*g*n%t,k=jt(w,e,t)*w%t,M=jt(k,e,t)*w%t,R=jt(M,bi,t)*g%t,C=jt(R,s,t)*R%t,B=jt(C,i,t)*C%t,T=jt(B,a,t)*B%t,O=jt(T,h,t)*T%t,$=jt(O,a,t)*B%t,q=jt($,e,t)*w%t,X=jt(q,o,t)*C%t,D=jt(X,r,t)*g%t,F=jt(D,bi,t);if(!ki.eql(ki.sqr(F),n))throw new Error("Cannot find square root");return F}const ki=Ks(Bo,void 0,void 0,{sqrt:tl}),bn=Xu({a:BigInt(0),b:BigInt(7),Fp:ki,n:Ao,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=Ao,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Qu*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,o=BigInt("0x100000000000000000000000000000000"),a=Ro(i*n,t),h=Ro(-r*n,t);let g=Wt(n-a*e-h*s,t),w=Wt(-a*r-h*i,t);const k=g>o,M=w>o;if(k&&(g=t-g),M&&(w=t-w),g>o||w>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:k,k1:g,k2neg:M,k2:w}}}},ri);BigInt(0),bn.ProjectivePoint;const el=Er.utils.randomPrivateKey,To=()=>{const n=Er.utils.randomPrivateKey(),t=kn(n),e=new Uint8Array(64);return e.set(n),e.set(t,32),{publicKey:t,secretKey:e}},kn=Er.getPublicKey;function Mo(n){try{return Er.ExtendedPoint.fromHex(n),!0}catch{return!1}}const vi=(n,t)=>Er.sign(n,t.slice(0,32)),rl=Er.verify,mt=n=>lt.Buffer.isBuffer(n)?n:n instanceof Uint8Array?lt.Buffer.from(n.buffer,n.byteOffset,n.byteLength):lt.Buffer.from(n);class Si{constructor(t){Object.assign(this,t)}encode(){return lt.Buffer.from(si.serialize(Vr,this))}static decode(t){return si.deserialize(Vr,this,t)}static decodeUnchecked(t){return si.deserializeUnchecked(Vr,this,t)}}class nl extends Si{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 Vr=new Map;var Po;const Co=32,Fe=32;function il(n){return n._bn!==void 0}let Lo=1;class it extends Si{constructor(t){if(super({}),this._bn=void 0,il(t))this._bn=t._bn;else{if(typeof t=="string"){const e=ge.decode(t);if(e.length!=Fe)throw new Error("Invalid public key input");this._bn=new Zs(e)}else this._bn=new Zs(t);if(this._bn.byteLength()>Fe)throw new Error("Invalid public key input")}}static unique(){const t=new it(Lo);return Lo+=1,new it(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return ge.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(lt.Buffer);if(t.length===Fe)return t;const e=lt.Buffer.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 s=lt.Buffer.concat([t.toBuffer(),lt.Buffer.from(e),r.toBuffer()]),i=ri(s);return new it(i)}static createProgramAddressSync(t,e){let r=lt.Buffer.alloc(0);t.forEach(function(i){if(i.length>Co)throw new TypeError("Max seed length exceeded");r=lt.Buffer.concat([r,mt(i)])}),r=lt.Buffer.concat([r,e.toBuffer(),lt.Buffer.from("ProgramDerivedAddress")]);const s=ri(r);if(Mo(s))throw new Error("Invalid seeds, address must fall off the curve");return new it(s)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r=255,s;for(;r!=0;){try{const i=t.concat(lt.Buffer.from([r]));s=this.createProgramAddressSync(i,e)}catch(i){if(i instanceof TypeError)throw i;r--;continue}return[s,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 it(t);return Mo(e.toBytes())}}Po=it,it.default=new Po("11111111111111111111111111111111"),Vr.set(it,{kind:"struct",fields:[["_bn","u256"]]});class sl{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=mt(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=mt(el()),this._publicKey=mt(kn(this._secretKey))}get publicKey(){return new it(this._publicKey)}get secretKey(){return lt.Buffer.concat([this._secretKey,this._publicKey],64)}}const ol=new it("BPFLoader1111111111111111111111111111111111"),er=1232,vn=127,jr=64;class xi extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(xi.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Ii 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(Ii.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Ar extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Ar.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Gr{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((i,o)=>{r.set(i.toBase58(),o)});const s=i=>{const o=r.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const xt=(n="publicKey")=>P.blob(32,n),al=(n="signature")=>P.blob(64,n),dr=(n="string")=>{const t=P.struct([P.u32("length"),P.u32("lengthPadding"),P.blob(P.offset(P.u32(),-8),"chars")],n),e=t.decode.bind(t),r=t.encode.bind(t),s=t;return s.decode=(i,o)=>e(i,o).chars.toString(),s.encode=(i,o,a)=>{const h={chars:lt.Buffer.from(i,"utf8")};return r(h,o,a)},s.alloc=i=>P.u32().span+P.u32().span+lt.Buffer.from(i,"utf8").length,s},cl=(n="authorized")=>P.struct([xt("staker"),xt("withdrawer")],n),ul=(n="lockup")=>P.struct([P.ns64("unixTimestamp"),P.ns64("epoch"),xt("custodian")],n),ll=(n="voteInit")=>P.struct([xt("nodePubkey"),xt("authorizedVoter"),xt("authorizedWithdrawer"),P.u8("commission")],n),fl=(n="voteAuthorizeWithSeedArgs")=>P.struct([P.u32("voteAuthorizationType"),xt("currentAuthorityDerivedKeyOwnerPubkey"),dr("currentAuthorityDerivedKeySeed"),xt("newAuthorized")],n);function Oo(n,t){const e=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(t[s.property]);if("count"in s&&"elementLayout"in s){const i=t[s.property];if(Array.isArray(i))return i.length*e(s.elementLayout)}else if("fields"in s)return Oo({layout:s},t[s.property]);return 0};let r=0;return n.layout.fields.forEach(s=>{r+=e(s)}),r}function Ee(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 Re(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 Et(n,t){if(!n)throw new Error(t||"Assertion failed")}class Sn{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,s=o=>{const a=o.toBase58();let h=r.get(a);return h===void 0&&(h={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,h)),h},i=s(e);i.isSigner=!0,i.isWritable=!0;for(const o of t){s(o.programId).isInvoked=!0;for(const a of o.keys){const h=s(a.pubkey);h.isSigner||(h.isSigner=a.isSigner),h.isWritable||(h.isWritable=a.isWritable)}}return new Sn(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];Et(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,h])=>h.isSigner&&h.isWritable),r=t.filter(([,h])=>h.isSigner&&!h.isWritable),s=t.filter(([,h])=>!h.isSigner&&h.isWritable),i=t.filter(([,h])=>!h.isSigner&&!h.isWritable),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{Et(e.length>0,"Expected at least one writable signer key");const[h]=e[0];Et(h===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...e.map(([h])=>new it(h)),...r.map(([h])=>new it(h)),...s.map(([h])=>new it(h)),...i.map(([h])=>new it(h))];return[o,a]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&s.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(t,e){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const a=new it(i),h=t.findIndex(g=>g.equals(a));h>=0&&(Et(h<256,"Max lookup table index exceeded"),r.push(h),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const Uo="Reached end of buffer unexpectedly";function ze(n){if(n.length===0)throw new Error(Uo);return n.shift()}function _e(n,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>n.length:e>=n.length)throw new Error(Uo);return n.splice(...t)}class Ce{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 it(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:ge.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Gr(this.staticAccountKeys)}static compile(t){const e=Sn.compile(t.instructions,t.payerKey),[r,s]=e.getMessageComponents(),o=new Gr(s).compileInstructions(t.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:ge.encode(a.data)}));return new Ce({header:r,accountKeys:s,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,i=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return r<i}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=[];Re(e,t);const r=this.instructions.map(k=>{const{accounts:M,programIdIndex:R}=k,C=Array.from(ge.decode(k.data));let B=[];Re(B,M.length);let T=[];return Re(T,C.length),{programIdIndex:R,keyIndicesCount:lt.Buffer.from(B),keyIndices:M,dataLength:lt.Buffer.from(T),data:C}});let s=[];Re(s,r.length);let i=lt.Buffer.alloc(er);lt.Buffer.from(s).copy(i);let o=s.length;r.forEach(k=>{const R=P.struct([P.u8("programIdIndex"),P.blob(k.keyIndicesCount.length,"keyIndicesCount"),P.seq(P.u8("keyIndex"),k.keyIndices.length,"keyIndices"),P.blob(k.dataLength.length,"dataLength"),P.seq(P.u8("userdatum"),k.data.length,"data")]).encode(k,i,o);o+=R}),i=i.slice(0,o);const a=P.struct([P.blob(1,"numRequiredSignatures"),P.blob(1,"numReadonlySignedAccounts"),P.blob(1,"numReadonlyUnsignedAccounts"),P.blob(e.length,"keyCount"),P.seq(xt("key"),t,"keys"),xt("recentBlockhash")]),h={numRequiredSignatures:lt.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:lt.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:lt.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:lt.Buffer.from(e),keys:this.accountKeys.map(k=>mt(k.toBytes())),recentBlockhash:ge.decode(this.recentBlockhash)};let g=lt.Buffer.alloc(2048);const w=a.encode(h,g);return i.copy(g,w),g.slice(0,w+i.length)}static from(t){let e=[...t];const r=ze(e);if(r!==(r&vn))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=ze(e),i=ze(e),o=Ee(e);let a=[];for(let M=0;M<o;M++){const R=_e(e,0,Fe);a.push(new it(lt.Buffer.from(R)))}const h=_e(e,0,Fe),g=Ee(e);let w=[];for(let M=0;M<g;M++){const R=ze(e),C=Ee(e),B=_e(e,0,C),T=Ee(e),O=_e(e,0,T),$=ge.encode(lt.Buffer.from(O));w.push({programIdIndex:R,accounts:B,data:$})}const k={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:ge.encode(lt.Buffer.from(h)),accountKeys:a,instructions:w};return new Ce(k)}}class pr{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 Gr(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 s=t-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(t>=this.header.numRequiredSignatures){const s=t-e,o=r-e-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=e-this.header.numReadonlySignedAccounts;return t<s}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=t.find(i=>i.key.equals(r.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const i of r.writableIndexes)if(i<s.state.addresses.length)e.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`);for(const i of r.readonlyIndexes)if(i<s.state.addresses.length)e.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`)}return e}static compile(t){const e=Sn.compile(t.instructions,t.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=t.addressLookupTableAccounts||[];for(const w of i){const k=e.extractTableLookup(w);if(k!==void 0){const[M,{writable:R,readonly:C}]=k;r.push(M),s.writable.push(...R),s.readonly.push(...C)}}const[o,a]=e.getMessageComponents(),g=new Gr(a,s).compileInstructions(t.instructions);return new pr({header:o,staticAccountKeys:a,recentBlockhash:t.recentBlockhash,compiledInstructions:g,addressTableLookups:r})}serialize(){const t=Array();Re(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),r=Array();Re(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Re(i,this.addressTableLookups.length);const o=P.struct([P.u8("prefix"),P.struct([P.u8("numRequiredSignatures"),P.u8("numReadonlySignedAccounts"),P.u8("numReadonlyUnsignedAccounts")],"header"),P.blob(t.length,"staticAccountKeysLength"),P.seq(xt(),this.staticAccountKeys.length,"staticAccountKeys"),xt("recentBlockhash"),P.blob(r.length,"instructionsLength"),P.blob(e.length,"serializedInstructions"),P.blob(i.length,"addressTableLookupsLength"),P.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(er),g=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(w=>w.toBytes()),recentBlockhash:ge.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,g)}serializeInstructions(){let t=0;const e=new Uint8Array(er);for(const r of this.compiledInstructions){const s=Array();Re(s,r.accountKeyIndexes.length);const i=Array();Re(i,r.data.length);const o=P.struct([P.u8("programIdIndex"),P.blob(s.length,"encodedAccountKeyIndexesLength"),P.seq(P.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),P.blob(i.length,"encodedDataLength"),P.blob(r.data.length,"data")]);t+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(er);for(const r of this.addressTableLookups){const s=Array();Re(s,r.writableIndexes.length);const i=Array();Re(i,r.readonlyIndexes.length);const o=P.struct([xt("accountKey"),P.blob(s.length,"encodedWritableIndexesLength"),P.seq(P.u8(),r.writableIndexes.length,"writableIndexes"),P.blob(i.length,"encodedReadonlyIndexesLength"),P.seq(P.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const r=ze(e),s=r&vn;Et(r!==s,"Expected versioned message but received legacy message");const i=s;Et(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:ze(e),numReadonlySignedAccounts:ze(e),numReadonlyUnsignedAccounts:ze(e)},a=[],h=Ee(e);for(let C=0;C<h;C++)a.push(new it(_e(e,0,Fe)));const g=ge.encode(_e(e,0,Fe)),w=Ee(e),k=[];for(let C=0;C<w;C++){const B=ze(e),T=Ee(e),O=_e(e,0,T),$=Ee(e),q=new Uint8Array(_e(e,0,$));k.push({programIdIndex:B,accountKeyIndexes:O,data:q})}const M=Ee(e),R=[];for(let C=0;C<M;C++){const B=new it(_e(e,0,Fe)),T=Ee(e),O=_e(e,0,T),$=Ee(e),q=_e(e,0,$);R.push({accountKey:B,writableIndexes:O,readonlyIndexes:q})}return new pr({header:o,staticAccountKeys:a,recentBlockhash:g,compiledInstructions:k,addressTableLookups:R})}}const Ei={deserializeMessageVersion(n){const t=n[0],e=t&vn;return e===t?"legacy":e},deserialize:n=>{const t=Ei.deserializeMessageVersion(n);if(t==="legacy")return Ce.from(n);if(t===0)return pr.deserialize(n);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let Ge=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 hl=lt.Buffer.alloc(jr).fill(0);class Pt{constructor(t){this.keys=void 0,this.programId=void 0,this.data=lt.Buffer.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]}}}class Bt{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 Pt(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 B=0;B<e.length;B++)if(e[B].programId===void 0)throw new Error(`Transaction instruction index ${B} has undefined program id`);const s=[],i=[];e.forEach(B=>{B.keys.forEach(O=>{i.push({...O})});const T=B.programId.toString();s.includes(T)||s.push(T)}),s.forEach(B=>{i.push({pubkey:new it(B),isSigner:!1,isWritable:!1})});const o=[];i.forEach(B=>{const T=B.pubkey.toString(),O=o.findIndex($=>$.pubkey.toString()===T);O>-1?(o[O].isWritable=o[O].isWritable||B.isWritable,o[O].isSigner=o[O].isSigner||B.isSigner):o.push(B)}),o.sort(function(B,T){if(B.isSigner!==T.isSigner)return B.isSigner?-1:1;if(B.isWritable!==T.isWritable)return B.isWritable?-1:1;const O={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return B.pubkey.toBase58().localeCompare(T.pubkey.toBase58(),"en",O)});const a=o.findIndex(B=>B.pubkey.equals(r));if(a>-1){const[B]=o.splice(a,1);B.isSigner=!0,B.isWritable=!0,o.unshift(B)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const B of this.signatures){const T=o.findIndex(O=>O.pubkey.equals(B.publicKey));if(T>-1)o[T].isSigner||(o[T].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: ${B.publicKey.toString()}`)}let h=0,g=0,w=0;const k=[],M=[];o.forEach(({pubkey:B,isSigner:T,isWritable:O})=>{T?(k.push(B.toString()),h+=1,O||(g+=1)):(M.push(B.toString()),O||(w+=1))});const R=k.concat(M),C=e.map(B=>{const{data:T,programId:O}=B;return{programIdIndex:R.indexOf(O.toString()),accounts:B.keys.map($=>R.indexOf($.pubkey.toString())),data:ge.encode(T)}});return C.forEach(B=>{Et(B.programIdIndex>=0),B.accounts.forEach(T=>Et(T>=0))}),new Ce({header:{numRequiredSignatures:h,numReadonlySignedAccounts:g,numReadonlyUnsignedAccounts:w},accountKeys:R,recentBlockhash:t,instructions:C})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((s,i)=>e[i].equals(s.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 s=r.toString();return e.has(s)?!1:(e.add(s),!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 i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,r=[];for(const i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach(s=>{const i=vi(r,s.secretKey);this._addSignature(s.publicKey,mt(i))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){Et(e.length===64);const r=this.signatures.findIndex(s=>t.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=lt.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?e&&(r.missing||(r.missing=[])).push(i):rl(s,t,i.toBytes())||(r.invalid||(r.invalid=[])).push(i);return r.invalid||r.missing?r:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,e);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
7
7
  Invalid signature for public key${i.invalid.length===1?"":"(s)"} [\`${i.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
8
- Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(t){const{signatures:e}=this,r=[];Mr(r,e.length);const s=r.length+e.length*64+t.length,i=Ct.Buffer.alloc(s);return xe(e.length<256),Ct.Buffer.from(r).copy(i,0),e.forEach(({signature:o},a)=>{o!==null&&(xe(o.length===64,"signature has invalid length"),Ct.Buffer.from(o).copy(i,r.length+a*64))}),t.copy(i,r.length+e.length*64),xe(i.length<=yn,`Transaction too large: ${i.length} > ${yn}`),i}get keys(){return xe(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return xe(this.instructions.length===1),this.instructions[0].programId}get data(){return xe(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const r=_r(e);let s=[];for(let i=0;i<r;i++){const o=Ir(e,0,pi);s.push(ar.encode(Ct.Buffer.from(o)))}return ye.populate(Wr.from(e),s)}static populate(t,e=[]){const r=new ye;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach((s,i)=>{const o={signature:s==ar.encode(Ql)?null:ar.decode(s),publicKey:t.accountKeys[i]};r.signatures.push(o)}),t.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=t.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(l=>l.publicKey.toString()===a.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});r.instructions.push(new Ue({keys:i,programId:t.accountKeys[s.programIdIndex],data:ar.decode(s.data)}))}),r._message=t,r._json=r.toJSON(),r}}class eo{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:s,recentBlockhash:i}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:l}=r,y=o-a;xe(y>0,"Message header is invalid");const x=t.staticAccountKeys.length-o-l;xe(x>=0,"Message header is invalid");const E=t.getAccountKeys(e),L=E.get(0);if(L===void 0)throw new Error("Failed to decompile message because no account keys were found");const C=[];for(const N of s){const M=[];for(const K of N.accountKeyIndexes){const Q=E.get(K);if(Q===void 0)throw new Error(`Failed to find key for account key index ${K}`);const j=K<o;let it;j?it=K<y:K<E.staticAccountKeys.length?it=K-o<x:it=K-E.staticAccountKeys.length<E.accountKeysFromLookups.writable.length,M.push({pubkey:Q,isSigner:K<r.numRequiredSignatures,isWritable:it})}const O=E.get(N.programIdIndex);if(O===void 0)throw new Error(`Failed to find program id for program id index ${N.programIdIndex}`);C.push(new Ue({programId:O,data:te(N.data),keys:M}))}return new eo({payerKey:L,instructions:C,recentBlockhash:i})}compileToLegacyMessage(){return Wr.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return Tn.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class ro{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)xe(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 s=0;s<t.header.numRequiredSignatures;s++)r.push(new Uint8Array(pi));this.signatures=r}this.message=t}serialize(){const t=this.message.serialize(),e=Array();Mr(e,this.signatures.length);const r=At([Ke(e.length,"encodedSignaturesLength"),dr(Gl(),this.signatures.length,"signatures"),Ke(t.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},s);return s.slice(0,i)}static deserialize(t){let e=[...t];const r=[],s=_r(e);for(let o=0;o<s;o++)r.push(new Uint8Array(Ir(e,0,pi)));const i=to.deserialize(new Uint8Array(e));return new ro(i,r)}sign(t){const e=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of t){const i=r.findIndex(o=>o.equals(s.publicKey));xe(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=Zs(e,s.secretKey)}}addSignature(t,e){xe(e.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(t));xe(s>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=e}}const uc=1e3/(160/64),Xr=new gt("SysvarC1ock11111111111111111111111111111111"),th=new gt("SysvarEpochSchedu1e111111111111111111111111"),eh=new gt("Sysvar1nstructions1111111111111111111111111"),ji=new gt("SysvarRecentB1ockHashes11111111111111111111"),Zn=new gt("SysvarRent111111111111111111111111111111111"),rh=new gt("SysvarRewards111111111111111111111111111111"),nh=new gt("SysvarS1otHashes111111111111111111111111111"),ih=new gt("SysvarS1otHistory11111111111111111111111111"),Gi=new gt("SysvarStakeHistory1111111111111111111111111");class yi extends Error{constructor({action:t,signature:e,transactionMessage:r,logs:s}){const i=s?`Logs:
8
+ Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(t){const{signatures:e}=this,r=[];Re(r,e.length);const s=r.length+e.length*64+t.length,i=lt.Buffer.alloc(s);return Et(e.length<256),lt.Buffer.from(r).copy(i,0),e.forEach(({signature:o},a)=>{o!==null&&(Et(o.length===64,"signature has invalid length"),lt.Buffer.from(o).copy(i,r.length+a*64))}),t.copy(i,r.length+e.length*64),Et(i.length<=er,`Transaction too large: ${i.length} > ${er}`),i}get keys(){return Et(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return Et(this.instructions.length===1),this.instructions[0].programId}get data(){return Et(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const r=Ee(e);let s=[];for(let i=0;i<r;i++){const o=_e(e,0,jr);s.push(ge.encode(lt.Buffer.from(o)))}return Bt.populate(Ce.from(e),s)}static populate(t,e=[]){const r=new Bt;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach((s,i)=>{const o={signature:s==ge.encode(hl)?null:ge.decode(s),publicKey:t.accountKeys[i]};r.signatures.push(o)}),t.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=t.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(h=>h.publicKey.toString()===a.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});r.instructions.push(new Pt({keys:i,programId:t.accountKeys[s.programIdIndex],data:ge.decode(s.data)}))}),r._message=t,r._json=r.toJSON(),r}}class _i{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:s,recentBlockhash:i}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:h}=r,g=o-a;Et(g>0,"Message header is invalid");const w=t.staticAccountKeys.length-o-h;Et(w>=0,"Message header is invalid");const k=t.getAccountKeys(e),M=k.get(0);if(M===void 0)throw new Error("Failed to decompile message because no account keys were found");const R=[];for(const C of s){const B=[];for(const O of C.accountKeyIndexes){const $=k.get(O);if($===void 0)throw new Error(`Failed to find key for account key index ${O}`);const q=O<o;let X;q?X=O<g:O<k.staticAccountKeys.length?X=O-o<w:X=O-k.staticAccountKeys.length<k.accountKeysFromLookups.writable.length,B.push({pubkey:$,isSigner:O<r.numRequiredSignatures,isWritable:X})}const T=k.get(C.programIdIndex);if(T===void 0)throw new Error(`Failed to find program id for program id index ${C.programIdIndex}`);R.push(new Pt({programId:T,data:mt(C.data),keys:B}))}return new _i({payerKey:M,instructions:R,recentBlockhash:i})}compileToLegacyMessage(){return Ce.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return pr.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class Bi{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)Et(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 s=0;s<t.header.numRequiredSignatures;s++)r.push(new Uint8Array(jr));this.signatures=r}this.message=t}serialize(){const t=this.message.serialize(),e=Array();Re(e,this.signatures.length);const r=P.struct([P.blob(e.length,"encodedSignaturesLength"),P.seq(al(),this.signatures.length,"signatures"),P.blob(t.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},s);return s.slice(0,i)}static deserialize(t){let e=[...t];const r=[],s=Ee(e);for(let o=0;o<s;o++)r.push(new Uint8Array(_e(e,0,jr)));const i=Ei.deserialize(new Uint8Array(e));return new Bi(i,r)}sign(t){const e=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of t){const i=r.findIndex(o=>o.equals(s.publicKey));Et(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=vi(e,s.secretKey)}}addSignature(t,e){Et(e.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(t));Et(s>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=e}}const No=1e3/(160/64),qe=new it("SysvarC1ock11111111111111111111111111111111"),dl=new it("SysvarEpochSchedu1e111111111111111111111111"),pl=new it("Sysvar1nstructions1111111111111111111111111"),xn=new it("SysvarRecentB1ockHashes11111111111111111111"),Rr=new it("SysvarRent111111111111111111111111111111111"),gl=new it("SysvarRewards111111111111111111111111111111"),yl=new it("SysvarS1otHashes111111111111111111111111111"),ml=new it("SysvarS1otHistory11111111111111111111111111"),In=new it("SysvarStakeHistory1111111111111111111111111");class Zr extends Error{constructor({action:t,signature:e,transactionMessage:r,logs:s}){const i=s?`Logs:
9
9
  ${JSON.stringify(s.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.
10
10
  ${r}. `+i+o;break;case"simulate":a=`Simulation failed.
11
11
  Message: ${r}.
12
- `+i+o;break;default:a=`Unknown action '${(l=>l)(t)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=r,this.transactionLogs=s||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(s=>{if(s&&s.meta&&s.meta.logMessages){const i=s.meta.logMessages;this.transactionLogs=i,e(i)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const sh={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 Rt extends Error{constructor({code:t,message:e,data:r},s){super(s!=null?`${s}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=r,this.name="SolanaJSONRPCError"}}async function no(n,t,e,r){const s=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},i=await n.sendTransaction(t,e,s);let o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,signature:i,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:a}=t.nonceInfo,l=a.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:l,nonceValue:t.nonceInfo.nonce,signature:i},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(i,r&&r.commitment)).value;if(o.err)throw i!=null?new yi({action:"send",signature:i,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${i} failed (${JSON.stringify(o)})`);return i}function Mn(n){return new Promise(t=>setTimeout(t,n))}function fe(n,t){const e=n.layout.span>=0?n.layout.span:ac(n,t),r=Ct.Buffer.alloc(e),s=Object.assign({instruction:n.index},t);return n.layout.encode(s,r),r}function Ee(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 fc=hr("lamportsPerSignature"),lc=At([It("version"),It("state"),oe("authorizedPubkey"),oe("nonce"),At([fc],"feeCalculator")]),io=lc.span;class Yi{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=lc.decode(te(t),0);return new Yi({authorizedPubkey:new gt(e.authorizedPubkey),nonce:new gt(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const oh=n=>{const t=n.decode.bind(n),e=n.encode.bind(n);return{decode:t,encode:e}},Jn=(n=>t=>{const e=Ke(n,t),{encode:r,decode:s}=oh(e),i=e;return i.decode=(o,a)=>{const l=s(o,a);return Of(Ct.Buffer.from(l))},i.encode=(o,a,l)=>{const y=Ma(o,n);return r(y,a,l)},i})(8);class ah{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(Ne))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:r,programId:s}=Ee(Ne.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:r,programId:new gt(s)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Ee(Ne.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:s}=Ee(Ne.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 gt(s)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Ee(Ne.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:s,programId:i}=Ee(Ne.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new gt(e),seed:r,space:s,programId:new gt(i)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Ee(Ne.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new gt(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,programId:s}=Ee(Ne.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new gt(e),seed:r,programId:new gt(s)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:r,lamports:s,space:i,programId:o}=Ee(Ne.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new gt(e),seed:r,lamports:s,space:i,programId:new gt(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Ee(Ne.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new gt(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ee(Ne.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}=Ee(Ne.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}=Ee(Ne.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new gt(e)}}static checkProgramId(t){if(!t.equals(cr.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 Ne=Object.freeze({Create:{index:0,layout:At([It("instruction"),Tr("lamports"),Tr("space"),oe("programId")])},Assign:{index:1,layout:At([It("instruction"),oe("programId")])},Transfer:{index:2,layout:At([It("instruction"),Jn("lamports")])},CreateWithSeed:{index:3,layout:At([It("instruction"),oe("base"),Rn("seed"),Tr("lamports"),Tr("space"),oe("programId")])},AdvanceNonceAccount:{index:4,layout:At([It("instruction")])},WithdrawNonceAccount:{index:5,layout:At([It("instruction"),Tr("lamports")])},InitializeNonceAccount:{index:6,layout:At([It("instruction"),oe("authorized")])},AuthorizeNonceAccount:{index:7,layout:At([It("instruction"),oe("authorized")])},Allocate:{index:8,layout:At([It("instruction"),Tr("space")])},AllocateWithSeed:{index:9,layout:At([It("instruction"),oe("base"),Rn("seed"),Tr("space"),oe("programId")])},AssignWithSeed:{index:10,layout:At([It("instruction"),oe("base"),Rn("seed"),oe("programId")])},TransferWithSeed:{index:11,layout:At([It("instruction"),Jn("lamports"),Rn("seed"),oe("programId")])},UpgradeNonceAccount:{index:12,layout:At([It("instruction")])}});class cr{constructor(){}static createAccount(t){const e=Ne.Create,r=fe(e,{lamports:t.lamports,space:t.space,programId:te(t.programId.toBuffer())});return new Ue({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 s=Ne.TransferWithSeed;e=fe(s,{lamports:BigInt(t.lamports),seed:t.seed,programId:te(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 s=Ne.Transfer;e=fe(s,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Ue({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;if("basePubkey"in t){const s=Ne.AssignWithSeed;e=fe(s,{base:te(t.basePubkey.toBuffer()),seed:t.seed,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Ne.Assign;e=fe(s,{programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ue({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=Ne.CreateWithSeed,r=fe(e,{base:te(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:te(t.programId.toBuffer())});let s=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||s.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Ue({keys:s,programId:this.programId,data:r})}static createNonceAccount(t){const e=new ye;"basePubkey"in t&&"seed"in t?e.add(cr.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:io,programId:this.programId})):e.add(cr.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:io,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=Ne.InitializeNonceAccount,r=fe(e,{authorized:te(t.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ji,isSigner:!1,isWritable:!1},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Ue(s)}static nonceAdvance(t){const e=Ne.AdvanceNonceAccount,r=fe(e),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ji,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Ue(s)}static nonceWithdraw(t){const e=Ne.WithdrawNonceAccount,r=fe(e,{lamports:t.lamports});return new Ue({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ji,isSigner:!1,isWritable:!1},{pubkey:Zn,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(t){const e=Ne.AuthorizeNonceAccount,r=fe(e,{authorized:te(t.newAuthorizedPubkey.toBuffer())});return new Ue({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 s=Ne.AllocateWithSeed;e=fe(s,{base:te(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:te(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Ne.Allocate;e=fe(s,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Ue({keys:r,programId:this.programId,data:e})}}cr.programId=new gt("11111111111111111111111111111111");const ch=yn-300;class Pn{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/Pn.chunkSize)+1+1)}static async load(t,e,r,s,i){{const E=await t.getMinimumBalanceForRentExemption(i.length),L=await t.getAccountInfo(r.publicKey,"confirmed");let C=null;if(L!==null){if(L.executable)return console.error("Program load failed, account is already executable"),!1;L.data.length!==i.length&&(C=C||new ye,C.add(cr.allocate({accountPubkey:r.publicKey,space:i.length}))),L.owner.equals(s)||(C=C||new ye,C.add(cr.assign({accountPubkey:r.publicKey,programId:s}))),L.lamports<E&&(C=C||new ye,C.add(cr.transfer({fromPubkey:e.publicKey,toPubkey:r.publicKey,lamports:E-L.lamports})))}else C=new ye().add(cr.createAccount({fromPubkey:e.publicKey,newAccountPubkey:r.publicKey,lamports:E>0?E:1,space:i.length,programId:s}));C!==null&&await no(t,C,[e,r],{commitment:"confirmed"})}const o=At([It("instruction"),It("offset"),It("bytesLength"),It("bytesLengthPadding"),dr(ge("byte"),pn(It(),-8),"bytes")]),a=Pn.chunkSize;let l=0,y=i,x=[];for(;y.length>0;){const E=y.slice(0,a),L=Ct.Buffer.alloc(a+16);o.encode({instruction:0,offset:l,bytes:E,bytesLength:0,bytesLengthPadding:0},L);const C=new ye().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:L});x.push(no(t,C,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await Mn(1e3/4),l+=a,y=y.slice(a)}await Promise.all(x);{const E=At([It("instruction")]),L=Ct.Buffer.alloc(E.span);E.encode({instruction:1},L);const C=new ye().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:s,data:L}),N="processed",M=await t.sendTransaction(C,[e,r],{preflightCommitment:N}),{context:O,value:K}=await t.confirmTransaction({signature:M,lastValidBlockHeight:C.lastValidBlockHeight,blockhash:C.recentBlockhash},N);if(K.err)throw new Error(`Transaction ${M} failed (${JSON.stringify(K)})`);for(;;){try{if(await t.getSlot({commitment:N})>O.slot)break}catch{}await new Promise(Q=>setTimeout(Q,Math.round(uc/2)))}}return!0}}Pn.chunkSize=ch;const uh=new gt("BPFLoader2111111111111111111111111111111111");class fh{static getMinNumSignatures(t){return Pn.getMinNumSignatures(t)}static load(t,e,r,s,i){return Pn.load(t,e,r,i,s)}}function lh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var so,hc;function hh(){if(hc)return so;hc=1;var n=Object.prototype.toString,t=Object.keys||function(r){var s=[];for(var i in r)s.push(i);return s};function e(r,s){var i,o,a,l,y,x,E;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(),s);if(E=n.call(r),E==="[object Array]"){for(a="[",o=r.length-1,i=0;i<o;i++)a+=e(r[i],!0)+",";return o>-1&&(a+=e(r[i],!0)),a+"]"}else if(E==="[object Object]"){for(l=t(r).sort(),o=l.length,a="",i=0;i<o;)y=l[i],x=e(r[y],!1),x!==void 0&&(a&&(a+=","),a+=JSON.stringify(y)+":"+x),i++;return"{"+a+"}"}else return JSON.stringify(r);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return so=function(r){var s=e(r,!1);if(s!==void 0)return""+s},so}var dh=hh(),dc=lh(dh);const mi=32;function oo(n){let t=0;for(;n>1;)n/=2,t++;return t}function ph(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 pc{constructor(t,e,r,s,i){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=s,this.firstNormalSlot=i}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=oo(ph(t+mi+1))-oo(mi)-1,r=this.getSlotsInEpoch(e),s=t-(r-mi);return[e,s]}else{const e=t-this.firstNormalSlot,r=Math.floor(e/this.slotsPerEpoch),s=this.firstNormalEpoch+r,i=e%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*mi:(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+oo(mi)):this.slotsPerEpoch}}var gh=globalThis.fetch;class yh extends Sl{constructor(t,e,r){const s=i=>{const o=vl(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,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 mh(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 gc=56;class ao{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=mh(wh,t),r=t.length-gc;xe(r>=0,"lookup table is invalid"),xe(r%32===0,"lookup table is invalid");const s=r/32,{addresses:i}=At([dr(oe(),s,"addresses")]).decode(t.slice(gc));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new gt(e.authority[0]):void 0,addresses:i.map(o=>new gt(o))}}}const wh={index:1,layout:At([It("typeIndex"),Jn("deactivationSlot"),hr("lastExtendedSlot"),ge("lastExtendedStartIndex"),ge(),dr(oe(),pn(ge(),-1),"authority")])},bh=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function xh(n){const t=n.match(bh);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[e,r,s,i]=t,o=n.startsWith("https:")?"wss:":"ws:",a=s==null?null:parseInt(s.slice(1),10),l=a==null?"":`:${a+1}`;return`${o}//${r}${l}${i}`}const Ve=fi(Ks(gt),dt(),n=>new gt(n)),yc=Ws([dt(),He("base64")]),co=fi(Ks(Ct.Buffer),yc,n=>Ct.Buffer.from(n[0],"base64")),mc=30*1e3;function vh(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,...s}=n;t=r,e=s}return{commitment:t,config:e}}function wc(n){return n.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function bc(n){return Sr([ot({jsonrpc:He("2.0"),id:dt(),result:n}),ot({jsonrpc:He("2.0"),id:dt(),error:ot({code:Gn(),message:dt(),data:Ot(Hf())})})])}const kh=bc(Gn());function ee(n){return fi(bc(n),kh,t=>"error"in t?t:{...t,result:yt(t.result,n)})}function Ye(n){return ee(ot({context:ot({slot:q()}),value:n}))}function Zi(n){return ot({context:ot({slot:q()}),value:n})}function uo(n,t){return n===0?new Tn({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new gt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:ar.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Wr(t)}const Sh=ot({foundation:q(),foundationTerm:q(),initial:q(),taper:q(),terminal:q()}),Eh=ee(wt(bt(ot({epoch:q(),effectiveSlot:q(),amount:q(),postBalance:q(),commission:Ot(bt(q()))})))),_h=wt(ot({slot:q(),prioritizationFee:q()})),Ih=ot({total:q(),validator:q(),foundation:q(),epoch:q()}),Ah=ot({epoch:q(),slotIndex:q(),slotsInEpoch:q(),absoluteSlot:q(),blockHeight:Ot(q()),transactionCount:Ot(q())}),Bh=ot({slotsPerEpoch:q(),leaderScheduleSlotOffset:q(),warmup:Yr(),firstNormalEpoch:q(),firstNormalSlot:q()}),Rh=Ua(dt(),wt(q())),Cn=bt(Sr([ot({}),dt()])),Th=ot({err:Cn}),Mh=He("receivedSignature"),Ph=ot({"solana-core":dt(),"feature-set":Ot(q())}),Ch=ot({program:dt(),programId:Ve,parsed:Gn()}),Lh=ot({programId:Ve,accounts:wt(Ve),data:dt()}),xc=Ye(ot({err:bt(Sr([ot({}),dt()])),logs:bt(wt(dt())),accounts:Ot(bt(wt(bt(ot({executable:Yr(),owner:dt(),lamports:q(),data:wt(dt()),rentEpoch:Ot(q())}))))),unitsConsumed:Ot(q()),returnData:Ot(bt(ot({programId:dt(),data:Ws([dt(),He("base64")])}))),innerInstructions:Ot(bt(wt(ot({index:q(),instructions:wt(Sr([Ch,Lh]))}))))})),Uh=Ye(ot({byIdentity:Ua(dt(),wt(q())),range:ot({firstSlot:q(),lastSlot:q()})}));function Oh(n,t,e,r,s,i){const o=e||gh;let a;i!=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 l;return r&&(l=async(x,E)=>{const L=await new Promise((C,N)=>{try{r(x,E,(M,O)=>C([M,O]))}catch(M){N(M)}});return await o(...L)}),new wl(async(x,E)=>{const L={method:"POST",body:x,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},N0)};try{let C=5,N,M=500;for(;l?N=await l(n,L):N=await o(n,L),!(N.status!==429||s===!0||(C-=1,C===0));)console.error(`Server responded with ${N.status} ${N.statusText}. Retrying after ${M}ms delay...`),await Mn(M),M*=2;const O=await N.text();N.ok?E(null,O):E(new Error(`${N.status} ${N.statusText}: ${O}`))}catch(C){C instanceof Error&&E(C)}},{})}function Nh(n){return(t,e)=>new Promise((r,s)=>{n.request(t,e,(i,o)=>{if(i){s(i);return}r(o)})})}function Fh(n){return t=>new Promise((e,r)=>{t.length===0&&e([]);const s=t.map(i=>n.request(i.methodName,i.args));n.request(s,(i,o)=>{if(i){r(i);return}e(o)})})}const zh=ee(Sh),Kh=ee(Ih),Wh=ee(_h),Dh=ee(Ah),$h=ee(Bh),qh=ee(Rh),Hh=ee(q()),Vh=Ye(ot({total:q(),circulating:q(),nonCirculating:q(),nonCirculatingAccounts:wt(Ve)})),fo=ot({amount:dt(),uiAmount:bt(q()),decimals:q(),uiAmountString:Ot(dt())}),jh=Ye(wt(ot({address:Ve,amount:dt(),uiAmount:bt(q()),decimals:q(),uiAmountString:Ot(dt())}))),Gh=Ye(wt(ot({pubkey:Ve,account:ot({executable:Yr(),owner:Ve,lamports:q(),data:co,rentEpoch:q()})}))),lo=ot({program:dt(),parsed:Gn(),space:q()}),Yh=Ye(wt(ot({pubkey:Ve,account:ot({executable:Yr(),owner:Ve,lamports:q(),data:lo,rentEpoch:q()})}))),Zh=Ye(wt(ot({lamports:q(),address:Ve}))),wi=ot({executable:Yr(),owner:Ve,lamports:q(),data:co,rentEpoch:q()}),Jh=ot({pubkey:Ve,account:wi}),Xh=fi(Sr([Ks(Ct.Buffer),lo]),Sr([yc,lo]),n=>Array.isArray(n)?yt(n,co):n),ho=ot({executable:Yr(),owner:Ve,lamports:q(),data:Xh,rentEpoch:q()}),Qh=ot({pubkey:Ve,account:ho}),t0=ot({state:Sr([He("active"),He("inactive"),He("activating"),He("deactivating")]),active:q(),inactive:q()}),e0=ee(wt(ot({signature:dt(),slot:q(),err:Cn,memo:bt(dt()),blockTime:Ot(bt(q()))}))),r0=ee(wt(ot({signature:dt(),slot:q(),err:Cn,memo:bt(dt()),blockTime:Ot(bt(q()))}))),n0=ot({subscription:q(),result:Zi(wi)}),i0=ot({pubkey:Ve,account:wi}),s0=ot({subscription:q(),result:Zi(i0)}),o0=ot({parent:q(),slot:q(),root:q()}),a0=ot({subscription:q(),result:o0}),c0=Sr([ot({type:Sr([He("firstShredReceived"),He("completed"),He("optimisticConfirmation"),He("root")]),slot:q(),timestamp:q()}),ot({type:He("createdBank"),parent:q(),slot:q(),timestamp:q()}),ot({type:He("frozen"),slot:q(),timestamp:q(),stats:ot({numTransactionEntries:q(),numSuccessfulTransactions:q(),numFailedTransactions:q(),maxTransactionsPerEntry:q()})}),ot({type:He("dead"),slot:q(),timestamp:q(),err:dt()})]),u0=ot({subscription:q(),result:c0}),f0=ot({subscription:q(),result:Zi(Sr([Th,Mh]))}),l0=ot({subscription:q(),result:q()}),h0=ot({pubkey:dt(),gossip:bt(dt()),tpu:bt(dt()),rpc:bt(dt()),version:bt(dt())}),vc=ot({votePubkey:dt(),nodePubkey:dt(),activatedStake:q(),epochVoteAccount:Yr(),epochCredits:wt(Ws([q(),q(),q()])),commission:q(),lastVote:q(),rootSlot:bt(q())}),d0=ee(ot({current:wt(vc),delinquent:wt(vc)})),p0=Sr([He("processed"),He("confirmed"),He("finalized")]),g0=ot({slot:q(),confirmations:bt(q()),err:Cn,confirmationStatus:Ot(p0)}),y0=Ye(wt(bt(g0))),m0=ee(q()),kc=ot({accountKey:Ve,writableIndexes:wt(q()),readonlyIndexes:wt(q())}),po=ot({signatures:wt(dt()),message:ot({accountKeys:wt(dt()),header:ot({numRequiredSignatures:q(),numReadonlySignedAccounts:q(),numReadonlyUnsignedAccounts:q()}),instructions:wt(ot({accounts:wt(q()),data:dt(),programIdIndex:q()})),recentBlockhash:dt(),addressTableLookups:Ot(wt(kc))})}),Sc=ot({pubkey:Ve,signer:Yr(),writable:Yr(),source:Ot(Sr([He("transaction"),He("lookupTable")]))}),Ec=ot({accountKeys:wt(Sc),signatures:wt(dt())}),_c=ot({parsed:Gn(),program:dt(),programId:Ve}),Ic=ot({accounts:wt(Ve),data:dt(),programId:Ve}),w0=Sr([Ic,_c]),b0=Sr([ot({parsed:Gn(),program:dt(),programId:dt()}),ot({accounts:wt(dt()),data:dt(),programId:dt()})]),Ac=fi(w0,b0,n=>"accounts"in n?yt(n,Ic):yt(n,_c)),Bc=ot({signatures:wt(dt()),message:ot({accountKeys:wt(Sc),instructions:wt(Ac),recentBlockhash:dt(),addressTableLookups:Ot(bt(wt(kc)))})}),Ji=ot({accountIndex:q(),mint:dt(),owner:Ot(dt()),uiTokenAmount:fo}),Rc=ot({writable:wt(Ve),readonly:wt(Ve)}),Xi=ot({err:Cn,fee:q(),innerInstructions:Ot(bt(wt(ot({index:q(),instructions:wt(ot({accounts:wt(q()),data:dt(),programIdIndex:q()}))})))),preBalances:wt(q()),postBalances:wt(q()),logMessages:Ot(bt(wt(dt()))),preTokenBalances:Ot(bt(wt(Ji))),postTokenBalances:Ot(bt(wt(Ji))),loadedAddresses:Ot(Rc),computeUnitsConsumed:Ot(q())}),go=ot({err:Cn,fee:q(),innerInstructions:Ot(bt(wt(ot({index:q(),instructions:wt(Ac)})))),preBalances:wt(q()),postBalances:wt(q()),logMessages:Ot(bt(wt(dt()))),preTokenBalances:Ot(bt(wt(Ji))),postTokenBalances:Ot(bt(wt(Ji))),loadedAddresses:Ot(Rc),computeUnitsConsumed:Ot(q())}),Xn=Sr([He(0),He("legacy")]),Ln=ot({pubkey:dt(),lamports:q(),postBalance:bt(q()),rewardType:bt(dt()),commission:Ot(bt(q()))}),x0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(ot({transaction:po,meta:bt(Xi),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),v0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),k0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(ot({transaction:Ec,meta:bt(Xi),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),S0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(ot({transaction:Bc,meta:bt(go),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),E0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(ot({transaction:Ec,meta:bt(go),version:Ot(Xn)})),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),_0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),rewards:Ot(wt(Ln)),blockTime:bt(q()),blockHeight:bt(q())}))),I0=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),transactions:wt(ot({transaction:po,meta:bt(Xi)})),rewards:Ot(wt(Ln)),blockTime:bt(q())}))),Tc=ee(bt(ot({blockhash:dt(),previousBlockhash:dt(),parentSlot:q(),signatures:wt(dt()),blockTime:bt(q())}))),yo=ee(bt(ot({slot:q(),meta:bt(Xi),blockTime:Ot(bt(q())),transaction:po,version:Ot(Xn)}))),Qi=ee(bt(ot({slot:q(),transaction:Bc,meta:bt(go),blockTime:Ot(bt(q())),version:Ot(Xn)}))),A0=Ye(ot({blockhash:dt(),feeCalculator:ot({lamportsPerSignature:q()})})),B0=Ye(ot({blockhash:dt(),lastValidBlockHeight:q()})),R0=Ye(Yr()),T0=ot({slot:q(),numTransactions:q(),numSlots:q(),samplePeriodSecs:q()}),M0=ee(wt(T0)),P0=Ye(bt(ot({feeCalculator:ot({lamportsPerSignature:q()})}))),C0=ee(dt()),L0=ee(dt()),U0=ot({err:Cn,logs:wt(dt()),signature:dt()}),O0=ot({result:Zi(U0),subscription:q()}),N0={"solana-client":"js/1.0.0-maintenance"};class F0{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 y={};return async x=>{const{commitment:E,config:L}=Fe(x),C=this._buildArgs([],E,void 0,L),N=dc(C);return y[N]=y[N]??(async()=>{try{const M=await this._rpcRequest("getBlockHeight",C),O=yt(M,ee(q()));if("error"in O)throw new Rt(O.error,"failed to get block height information");return O.result}finally{delete y[N]}})(),await y[N]}})();let r,s,i,o,a,l;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,r=e.wsEndpoint,s=e.httpHeaders,i=e.fetch,o=e.fetchMiddleware,a=e.disableRetryOnRateLimit,l=e.httpAgent),this._rpcEndpoint=vh(t),this._rpcWsEndpoint=r||xh(t),this._rpcClient=Oh(t,s,i,o,a,l),this._rpcRequest=Nh(this._rpcClient),this._rpcBatchRequest=Fh(this._rpcClient),this._rpcWebSocket=new yh(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:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,void 0,s),o=await this._rpcRequest("getBalance",i),a=yt(o,Ye(q()));if("error"in a)throw new Rt(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=yt(e,ee(bt(q())));if("error"in r)throw new Rt(r.error,`failed to get block time for slot ${t}`);return r.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=yt(t,ee(q()));if("error"in e)throw new Rt(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=yt(t,Hh);if("error"in e)throw new Rt(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]),s=yt(r,Vh);if("error"in s)throw new Rt(s.error,"failed to get supply");return s.result}async getTokenSupply(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenSupply",r),i=yt(s,Ye(fo));if("error"in i)throw new Rt(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenAccountBalance",r),i=yt(s,Ye(fo));if("error"in i)throw new Rt(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(t,e,r){const{commitment:s,config:i}=Fe(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,s,"base64",i),l=await this._rpcRequest("getTokenAccountsByOwner",a),y=yt(l,Gh);if("error"in y)throw new Rt(y.error,`failed to get token accounts owned by account ${t.toBase58()}`);return y.result}async getParsedTokenAccountsByOwner(t,e,r){let s=[t.toBase58()];"mint"in e?s.push({mint:e.mint.toBase58()}):s.push({programId:e.programId.toBase58()});const i=this._buildArgs(s,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),a=yt(o,Yh);if("error"in a)throw new Rt(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]:[],s=await this._rpcRequest("getLargestAccounts",r),i=yt(s,Zh);if("error"in i)throw new Rt(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenLargestAccounts",r),i=yt(s,jh);if("error"in i)throw new Rt(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,"base64",s),o=await this._rpcRequest("getAccountInfo",i),a=yt(o,Ye(bt(wi)));if("error"in a)throw new Rt(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getParsedAccountInfo(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),a=yt(o,Ye(bt(ho)));if("error"in a)throw new Rt(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:s}=Fe(e),i=t.map(y=>y.toBase58()),o=this._buildArgs([i],r,"jsonParsed",s),a=await this._rpcRequest("getMultipleAccounts",o),l=yt(a,Ye(wt(bt(ho))));if("error"in l)throw new Rt(l.error,`failed to get info for accounts ${i}`);return l.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(y=>y.toBase58()),o=this._buildArgs([i],r,"base64",s),a=await this._rpcRequest("getMultipleAccounts",o),l=yt(a,Ye(wt(bt(wi))));if("error"in l)throw new Rt(l.error,`failed to get info for accounts ${i}`);return l.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,r){const{commitment:s,config:i}=Fe(e),o=this._buildArgs([t.toBase58()],s,void 0,{...i,epoch:r??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getStakeActivation",o),l=yt(a,ee(t0));if("error"in l)throw new Rt(l.error,`failed to get Stake Activation ${t.toBase58()}`);return l.result}async getProgramAccounts(t,e){const{commitment:r,config:s}=Fe(e),{encoding:i,...o}=s||{},a=this._buildArgs([t.toBase58()],r,i||"base64",{...o,...o.filters?{filters:wc(o.filters)}:null}),l=await this._rpcRequest("getProgramAccounts",a),y=wt(Jh),x=o.withContext===!0?yt(l,Ye(y)):yt(l,ee(y));if("error"in x)throw new Rt(x.error,`failed to get accounts owned by program ${t.toBase58()}`);return x.result}async getParsedProgramAccounts(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),a=yt(o,ee(wt(Qh)));if("error"in a)throw new Rt(a.error,`failed to get accounts owned by program ${t.toBase58()}`);return a.result}async confirmTransaction(t,e){var i;let r;if(typeof t=="string")r=t;else{const o=t;if((i=o.abortSignal)!=null&&i.aborted)return Promise.reject(o.abortSignal.reason);r=o.signature}let s;try{s=ar.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return xe(s.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,s,i=!1;const o=new Promise((l,y)=>{try{r=this.onSignature(e,(E,L)=>{r=void 0;const C={context:L,value:E};l({__type:on.PROCESSED,response:C})},t);const x=new Promise(E=>{r==null?E():s=this._onSubscriptionStateChange(r,L=>{L==="subscribed"&&E()})});(async()=>{if(await x,i)return;const E=await this.getSignatureStatus(e);if(i||E==null)return;const{context:L,value:C}=E;if(C!=null)if(C!=null&&C.err)y(C.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(C.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(C.confirmationStatus==="processed"||C.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,l({__type:on.PROCESSED,response:{context:L,value:C}})}})()}catch(x){y(x)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:r,signature:s}}){let i=!1;const o=new Promise(E=>{const L=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let C=await L();if(!i){for(;C<=r;)if(await Mn(1e3),i||(C=await L(),i))return;E({__type:on.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),y=this.getCancellationPromise(e);let x;try{const E=await Promise.race([y,l,o]);if(E.__type===on.PROCESSED)x=E.response;else throw new Xs(s)}finally{i=!0,a()}return x}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let a=!1;const l=new Promise(C=>{let N=i,M=null;const O=async()=>{try{const{context:K,value:Q}=await this.getNonceAndContext(s,{commitment:t,minContextSlot:r});return M=K.slot,Q==null?void 0:Q.nonce}catch{return N}};(async()=>{if(N=await O(),!a)for(;;){if(i!==N){C({__type:on.NONCE_INVALID,slotInWhichNonceDidAdvance:M});return}if(await Mn(2e3),a||(N=await O(),a))return}})()}),{abortConfirmation:y,confirmationPromise:x}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),E=this.getCancellationPromise(e);let L;try{const C=await Promise.race([E,x,l]);if(C.__type===on.PROCESSED)L=C.response;else{let N;for(;;){const M=await this.getSignatureStatus(o);if(M==null)break;if(M.context.slot<(C.slotInWhichNonceDidAdvance??r)){await Mn(400);continue}N=M;break}if(N!=null&&N.value){const M=t||"finalized",{confirmationStatus:O}=N.value;switch(M){case"processed":case"recent":if(O!=="processed"&&O!=="confirmed"&&O!=="finalized")throw new Yn(o);break;case"confirmed":case"single":case"singleGossip":if(O!=="confirmed"&&O!=="finalized")throw new Yn(o);break;case"finalized":case"max":case"root":if(O!=="finalized")throw new Yn(o);break;default:}L={context:N.context,value:{err:N.value.err}}}else throw new Yn(o)}}finally{a=!0,y()}return L}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const s=new Promise(l=>{let y=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{y=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>l({__type:on.TIMED_OUT,timeoutMs:y}),y)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let a;try{const l=await Promise.race([o,s]);if(l.__type===on.PROCESSED)a=l.response;else throw new Qs(e,l.timeoutMs/1e3)}finally{clearTimeout(r),i()}return a}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=yt(t,ee(wt(h0)));if("error"in e)throw new Rt(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getVoteAccounts",e),s=yt(r,d0);if("error"in s)throw new Rt(s.error,"failed to get vote accounts");return s.result}async getSlot(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getSlot",s),o=yt(i,ee(q()));if("error"in o)throw new Rt(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getSlotLeader",s),o=yt(i,ee(dt()));if("error"in o)throw new Rt(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const r=[t,e],s=await this._rpcRequest("getSlotLeaders",r),i=yt(s,ee(wt(Ve)));if("error"in i)throw new Rt(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(t,e){const{context:r,value:s}=await this.getSignatureStatuses([t],e);xe(s.length===1);const i=s[0];return{context:r,value:i}}async getSignatureStatuses(t,e){const r=[t];e&&r.push(e);const s=await this._rpcRequest("getSignatureStatuses",r),i=yt(s,y0);if("error"in i)throw new Rt(i.error,"failed to get signature status");return i.result}async getTransactionCount(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getTransactionCount",s),o=yt(i,ee(q()));if("error"in o)throw new Rt(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),s=yt(r,zh);if("error"in s)throw new Rt(s.error,"failed to get inflation");return s.result}async getInflationReward(t,e,r){const{commitment:s,config:i}=Fe(r),o=this._buildArgs([t.map(y=>y.toBase58())],s,void 0,{...i,epoch:e??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getInflationReward",o),l=yt(a,Eh);if("error"in l)throw new Rt(l.error,"failed to get inflation reward");return l.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=yt(t,Kh);if("error"in e)throw new Rt(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:r}=Fe(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getEpochInfo",s),o=yt(i,Dh);if("error"in o)throw new Rt(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=yt(t,$h);if("error"in e)throw new Rt(e.error,"failed to get epoch schedule");const r=e.result;return new pc(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=yt(t,qh);if("error"in e)throw new Rt(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const r=this._buildArgs([t],e),s=await this._rpcRequest("getMinimumBalanceForRentExemption",r),i=yt(s,m0);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getRecentBlockhash",e),s=yt(r,A0);if("error"in s)throw new Rt(s.error,"failed to get recent blockhash");return s.result}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),r=yt(e,M0);if("error"in r)throw new Rt(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(t,e){const r=this._buildArgs([t],e),s=await this._rpcRequest("getFeeCalculatorForBlockhash",r),i=yt(s,P0);if("error"in i)throw new Rt(i.error,"failed to get fee calculator");const{context:o,value:a}=i.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(t,e){const r=te(t.serialize()).toString("base64"),s=this._buildArgs([r],e),i=await this._rpcRequest("getFeeForMessage",s),o=yt(i,Ye(bt(q())));if("error"in o)throw new Rt(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]:[],s=await this._rpcRequest("getRecentPrioritizationFees",r),i=yt(s,Wh);if("error"in i)throw new Rt(i.error,"failed to get recent prioritization fees");return i.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),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getLatestBlockhash",s),o=yt(i,B0);if("error"in o)throw new Rt(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgs([t],r,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),a=yt(o,R0);if("error"in a)throw new Rt(a.error,"failed to determine if the blockhash `"+t+"`is valid");return a.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=yt(t,ee(Ph));if("error"in e)throw new Rt(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=yt(t,ee(dt()));if("error"in e)throw new Rt(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=yt(o,k0);if("error"in a)throw a.error;return a.result}case"none":{const a=yt(o,v0);if("error"in a)throw a.error;return a.result}default:{const a=yt(o,x0);if("error"in a)throw a.error;const{result:l}=a;return l?{...l,transactions:l.transactions.map(({transaction:y,meta:x,version:E})=>({meta:x,transaction:{...y,message:uo(E,y.message)},version:E}))}:null}}}catch(a){throw new Rt(a,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=yt(o,E0);if("error"in a)throw a.error;return a.result}case"none":{const a=yt(o,_0);if("error"in a)throw a.error;return a.result}default:{const a=yt(o,S0);if("error"in a)throw a.error;return a.result}}}catch(a){throw new Rt(a,"failed to get block")}}async getBlockProduction(t){let e,r;if(typeof t=="string")r=t;else if(t){const{commitment:a,...l}=t;r=a,e=l}const s=this._buildArgs([],r,"base64",e),i=await this._rpcRequest("getBlockProduction",s),o=yt(i,Uh);if("error"in o)throw new Rt(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,s),o=await this._rpcRequest("getTransaction",i),a=yt(o,yo);if("error"in a)throw new Rt(a.error,"failed to get transaction");const l=a.result;return l&&{...l,transaction:{...l.transaction,message:uo(l.version,l.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:r,config:s}=Fe(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),a=yt(o,Qi);if("error"in a)throw new Rt(a.error,"failed to get transaction");return a.result}async getParsedTransactions(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(l=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([l],r,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(l=>{const y=yt(l,Qi);if("error"in y)throw new Rt(y.error,"failed to get transactions");return y.result})}async getTransactions(t,e){const{commitment:r,config:s}=Fe(e),i=t.map(l=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([l],r,void 0,s)}));return(await this._rpcBatchRequest(i)).map(l=>{const y=yt(l,yo);if("error"in y)throw new Rt(y.error,"failed to get transactions");const x=y.result;return x&&{...x,transaction:{...x.transaction,message:uo(x.version,x.transaction.message)}}})}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedBlock",r),i=yt(s,I0);if("error"in i)throw new Rt(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");const a={...o,transactions:o.transactions.map(({transaction:l,meta:y})=>{const x=new Wr(l.message);return{meta:y,transaction:{...l,message:x}}})};return{...a,transactions:a.transactions.map(({transaction:l,meta:y})=>({meta:y,transaction:ye.populate(l.message,l.signatures)}))}}async getBlocks(t,e,r){const s=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],r),i=await this._rpcRequest("getBlocks",s),o=yt(i,ee(wt(q())));if("error"in o)throw new Rt(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}),s=await this._rpcRequest("getBlock",r),i=yt(s,Tc);if("error"in i)throw new Rt(i.error,"failed to get block");const o=i.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}),s=await this._rpcRequest("getConfirmedBlock",r),i=yt(s,Tc);if("error"in i)throw new Rt(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedTransaction",r),i=yt(s,yo);if("error"in i)throw new Rt(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const a=new Wr(o.transaction.message),l=o.transaction.signatures;return{...o,transaction:ye.populate(a,l)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=await this._rpcRequest("getConfirmedTransaction",r),i=yt(s,Qi);if("error"in i)throw new Rt(i.error,"failed to get confirmed transaction");return i.result}async getParsedConfirmedTransactions(t,e){const r=t.map(o=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const a=yt(o,Qi);if("error"in a)throw new Rt(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(t,e,r){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<i));)try{const l=await this.getConfirmedBlockSignatures(e,"finalized");l.signatures.length>0&&(s.until=l.signatures[l.signatures.length-1].toString())}catch(l){if(l instanceof Error&&l.message.includes("skipped"))continue;throw l}let o=await this.getSlot("finalized");for(;!("before"in s)&&(r++,!(r>o));)try{const l=await this.getConfirmedBlockSignatures(r);l.signatures.length>0&&(s.before=l.signatures[l.signatures.length-1].toString())}catch(l){if(l instanceof Error&&l.message.includes("skipped"))continue;throw l}return(await this.getConfirmedSignaturesForAddress2(t,s)).map(l=>l.signature)}async getConfirmedSignaturesForAddress2(t,e,r){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=yt(i,e0);if("error"in o)throw new Rt(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,r){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=await this._rpcRequest("getSignaturesForAddress",s),o=yt(i,r0);if("error"in o)throw new Rt(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:r,value:s}=await this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=new ao({key:t,state:ao.deserialize(s.data)})),{context:r,value:i}}async getNonceAndContext(t,e){const{context:r,value:s}=await this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=Yi.fromAccountData(s.data)),{context:r,value:i}}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]),s=yt(r,C0);if("error"in s)throw new Rt(s.error,`airdrop to ${t.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Mn(100);const r=Date.now()-this._blockhashInfo.lastFetch>=mc;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 s=0;s<50;s++){const i=await this.getLatestBlockhash("finalized");if(r!==i.blockhash)return this._blockhashInfo={latestBlockhash:i,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},i;await Mn(uc/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),s=this._buildArgs([],e,"base64",r),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=yt(i,Ye(q()));if("error"in o)throw new Rt(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,r){if("message"in t){const M=t.serialize(),O=Ct.Buffer.from(M).toString("base64");if(Array.isArray(e)||r!==void 0)throw new Error("Invalid arguments");const K=e||{};K.encoding="base64","commitment"in K||(K.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(K.innerInstructions=e.innerInstructions);const Q=[O,K],j=await this._rpcRequest("simulateTransaction",Q),it=yt(j,xc);if("error"in it)throw new Error("failed to simulate transaction: "+it.error.message);return it.result}let s;if(t instanceof ye){let N=t;s=new ye,s.feePayer=N.feePayer,s.instructions=t.instructions,s.nonceInfo=N.nonceInfo,s.signatures=N.signatures}else s=ye.populate(t),s._message=s._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(s.nonceInfo&&i)s.sign(...i);else{let N=this._disableBlockhashCaching;for(;;){const M=await this._blockhashWithExpiryBlockHeight(N);if(s.lastValidBlockHeight=M.lastValidBlockHeight,s.recentBlockhash=M.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const O=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(O)&&!this._blockhashInfo.transactionSignatures.includes(O)){this._blockhashInfo.simulatedSignatures.push(O);break}else N=!0}}const o=s._compile(),a=o.serialize(),y=s._serialize(a).toString("base64"),x={encoding:"base64",commitment:this.commitment};if(r){const N=(Array.isArray(r)?r:o.nonProgramIds()).map(M=>M.toBase58());x.accounts={encoding:"base64",addresses:N}}i&&(x.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(x.innerInstructions=e.innerInstructions);const E=[y,x],L=await this._rpcRequest("simulateTransaction",E),C=yt(L,xc);if("error"in C){let N;if("data"in C.error&&(N=C.error.data.logs,N&&Array.isArray(N))){const M=`
13
- `,O=M+N.join(M);console.error(C.error.message,O)}throw new yi({action:"simulate",signature:"",transactionMessage:C.error.message,logs:N})}return C.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 s=e;if(t.nonceInfo)t.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=a.lastValidBlockHeight,t.recentBlockhash=a.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const l=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(l))o=!0;else{this._blockhashInfo.transactionSignatures.push(l);break}}}const i=t.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(t,e){const r=te(t).toString("base64");return await this.sendEncodedTransaction(r,e)}async sendEncodedTransaction(t,e){const r={encoding:"base64"},s=e&&e.skipPreflight,i=s===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(r.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(r.minContextSlot=e.minContextSlot),s&&(r.skipPreflight=s),i&&(r.preflightCommitment=i);const o=[t,r],a=await this._rpcRequest("sendTransaction",o),l=yt(a,L0);if("error"in l){let y;throw"data"in l.error&&(y=l.error.data.logs),new yi({action:s?"send":"simulate",signature:"",transactionMessage:l.error.message,logs:y})}return l.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 s;const r=(s=this._subscriptionsByHash[t])==null?void 0:s.state;if(this._subscriptionsByHash[t]=e,r!==e.state){const i=this._subscriptionStateChangeCallbacksByHash[t];i&&i.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var i;const r=this._subscriptionHashByClientSubscriptionId[t];if(r==null)return()=>{};const s=(i=this._subscriptionStateChangeCallbacksByHash)[r]||(i[r]=new Set);return s.add(e),()=>{s.delete(e),s.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 s=this._subscriptionsByHash[r];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[r],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:i,method:o}=s;try{this._setSubscription(r,{...s,state:"subscribing"});const a=await this._rpcWebSocket.call(o,i);this._setSubscription(r,{...s,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=s.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:a}),!e())return;this._setSubscription(r,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(r,{...s,state:"unsubscribing"}),this._setSubscription(r,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!e())return;this._setSubscription(r,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const r=this._subscriptionCallbacksByServerSubscriptionId[t];r!==void 0&&r.forEach(s=>{try{s(...e)}catch(i){console.error(i)}})}_wsOnAccountNotification(t){const{result:e,subscription:r}=yt(t,n0);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,s=dc([t.method,e]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:i.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[s];xe(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:s,config:i}=Fe(r),o=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",i);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}=yt(t,s0);this._handleServerNotification(r,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,r,s){const{commitment:i,config:o}=Fe(r),a=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:wc(s)}: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 s=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],r||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:r}=yt(t,O0);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=yt(t,a0);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}=yt(t,u0);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,s){const i=e||this._commitment;if(i||r||s){let o={};r&&(o.encoding=r),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,r,s){const i=e||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,r,s)}_wsOnSignatureNotification(t){const{result:e,subscription:r}=yt(t,f0);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 s=this._buildArgs([t],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){e(o.result,a);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(t,e,r){const{commitment:s,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([t],s,void 0,i),a=this._makeSubscription({callback:(l,y)=>{e(l,y);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}=yt(t,l0);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 Un{constructor(t){this._keypair=void 0,this._keypair=t??rc()}static generate(){return new Un(rc())}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 s=t.slice(0,32),i=qi(s);for(let o=0;o<32;o++)if(r[o]!==i[o])throw new Error("provided secretKey is invalid")}return new Un({publicKey:r,secretKey:t})}static fromSeed(t){const e=qi(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),new Un({publicKey:e,secretKey:r})}get publicKey(){return new gt(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const an=Object.freeze({CreateLookupTable:{index:0,layout:At([It("instruction"),Jn("recentSlot"),ge("bumpSeed")])},FreezeLookupTable:{index:1,layout:At([It("instruction")])},ExtendLookupTable:{index:2,layout:At([It("instruction"),Jn(),dr(oe(),pn(It(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:At([It("instruction")])},CloseLookupTable:{index:4,layout:At([It("instruction")])}});class z0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(an))if(o.index==r){s=i;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Ee(an.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}=Ee(an.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 gt(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(mo.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 mo{constructor(){}static createLookupTable(t){const[e,r]=gt.findProgramAddressSync([t.authority.toBuffer(),Ma(BigInt(t.recentSlot),8)],this.programId),s=an.CreateLookupTable,i=fe(s,{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:cr.programId,isSigner:!1,isWritable:!1}];return[new Ue({programId:this.programId,keys:o,data:i}),e]}static freezeLookupTable(t){const e=an.FreezeLookupTable,r=fe(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ue({programId:this.programId,keys:s,data:r})}static extendLookupTable(t){const e=an.ExtendLookupTable,r=fe(e,{addresses:t.addresses.map(i=>i.toBytes())}),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&s.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:cr.programId,isSigner:!1,isWritable:!1}),new Ue({programId:this.programId,keys:s,data:r})}static deactivateLookupTable(t){const e=an.DeactivateLookupTable,r=fe(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Ue({programId:this.programId,keys:s,data:r})}static closeLookupTable(t){const e=an.CloseLookupTable,r=fe(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Ue({programId:this.programId,keys:s,data:r})}}mo.programId=new gt("AddressLookupTab1e1111111111111111111111111");class K0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=ge("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(Qr))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:r}=Ee(Qr.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Ee(Qr.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Ee(Qr.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Ee(Qr.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(wo.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Qr=Object.freeze({RequestUnits:{index:0,layout:At([ge("instruction"),It("units"),It("additionalFee")])},RequestHeapFrame:{index:1,layout:At([ge("instruction"),It("bytes")])},SetComputeUnitLimit:{index:2,layout:At([ge("instruction"),It("units")])},SetComputeUnitPrice:{index:3,layout:At([ge("instruction"),Jn("microLamports")])}});class wo{constructor(){}static requestUnits(t){const e=Qr.RequestUnits,r=fe(e,t);return new Ue({keys:[],programId:this.programId,data:r})}static requestHeapFrame(t){const e=Qr.RequestHeapFrame,r=fe(e,t);return new Ue({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(t){const e=Qr.SetComputeUnitLimit,r=fe(e,t);return new Ue({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(t){const e=Qr.SetComputeUnitPrice,r=fe(e,{microLamports:BigInt(t.microLamports)});return new Ue({keys:[],programId:this.programId,data:r})}}wo.programId=new gt("ComputeBudget111111111111111111111111111111");const Mc=64,Pc=32,Cc=64,Lc=At([ge("numSignatures"),ge("padding"),Lr("signatureOffset"),Lr("signatureInstructionIndex"),Lr("publicKeyOffset"),Lr("publicKeyInstructionIndex"),Lr("messageDataOffset"),Lr("messageDataSize"),Lr("messageInstructionIndex")]);class ts{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:s,instructionIndex:i}=t;xe(e.length===Pc,`Public Key must be ${Pc} bytes but received ${e.length} bytes`),xe(s.length===Cc,`Signature must be ${Cc} bytes but received ${s.length} bytes`);const o=Lc.span,a=o+e.length,l=a+s.length,y=1,x=Ct.Buffer.alloc(l+r.length),E=i??65535;return Lc.encode({numSignatures:y,padding:0,signatureOffset:a,signatureInstructionIndex:E,publicKeyOffset:o,publicKeyInstructionIndex:E,messageDataOffset:l,messageDataSize:r.length,messageInstructionIndex:E},x),x.fill(e,o),x.fill(s,a),x.fill(r,l),new Ue({keys:[],programId:ts.programId,data:x})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;xe(e.length===Mc,`Private key must be ${Mc} bytes but received ${e.length} bytes`);try{const i=Un.fromSecretKey(e),o=i.publicKey.toBytes(),a=Zs(r,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}ts.programId=new gt("Ed25519SigVerify111111111111111111111111111");const W0=(n,t)=>{const e=$i.sign(n,t);return[e.toCompactRawBytes(),e.recovery]};$i.utils.isValidPrivateKey;const D0=$i.getPublicKey,Uc=32,bo=20,Oc=64,$0=11,xo=At([ge("numSignatures"),Lr("signatureOffset"),ge("signatureInstructionIndex"),Lr("ethAddressOffset"),ge("ethAddressInstructionIndex"),Lr("messageDataOffset"),Lr("messageDataSize"),ge("messageInstructionIndex"),Ke(20,"ethAddress"),Ke(64,"signature"),ge("recoveryId")]);class Qn{constructor(){}static publicKeyToEthAddress(t){xe(t.length===Oc,`Public key must be ${Oc} bytes but received ${t.length} bytes`);try{return Ct.Buffer.from(Ya(te(t))).slice(-bo)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:s,recoveryId:i,instructionIndex:o}=t;return Qn.createInstructionWithEthAddress({ethAddress:Qn.publicKeyToEthAddress(e),message:r,signature:s,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:r,signature:s,recoveryId:i,instructionIndex:o=0}=t;let a;typeof e=="string"?e.startsWith("0x")?a=Ct.Buffer.from(e.substr(2),"hex"):a=Ct.Buffer.from(e,"hex"):a=e,xe(a.length===bo,`Address must be ${bo} bytes but received ${a.length} bytes`);const l=1+$0,y=l,x=l+a.length,E=x+s.length+1,L=1,C=Ct.Buffer.alloc(xo.span+r.length);return xo.encode({numSignatures:L,signatureOffset:x,signatureInstructionIndex:o,ethAddressOffset:y,ethAddressInstructionIndex:o,messageDataOffset:E,messageDataSize:r.length,messageInstructionIndex:o,signature:te(s),ethAddress:te(a),recoveryId:i},C),C.fill(te(r),xo.span),new Ue({keys:[],programId:Qn.programId,data:C})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;xe(e.length===Uc,`Private key must be ${Uc} bytes but received ${e.length} bytes`);try{const i=te(e),o=D0(i,!1).slice(1),a=Ct.Buffer.from(Ya(te(r))),[l,y]=W0(a,i);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:l,recoveryId:y,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Qn.programId=new gt("KeccakSecp256k11111111111111111111111111111");var Nc;const Fc=new gt("StakeConfig11111111111111111111111111111111");class zc{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class bi{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}}Nc=bi,bi.default=new Nc(0,0,gt.default);class q0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(ur))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:r}=Ee(ur.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new zc(new gt(e.staker),new gt(e.withdrawer)),lockup:new bi(r.unixTimestamp,r.epoch,new gt(r.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Ee(ur.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}=Ee(ur.Authorize,t.data),s={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new gt(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(s.custodianPubkey=t.keys[3].pubkey),s}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:r,authoritySeed:s,authorityOwner:i}=Ee(ur.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:s,authorityOwner:new gt(i),newAuthorizedPubkey:new gt(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}=Ee(ur.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),Ee(ur.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}=Ee(ur.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),Ee(ur.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(es.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 ur=Object.freeze({Initialize:{index:0,layout:At([It("instruction"),Yl(),Zl()])},Authorize:{index:1,layout:At([It("instruction"),oe("newAuthorized"),It("stakeAuthorizationType")])},Delegate:{index:2,layout:At([It("instruction")])},Split:{index:3,layout:At([It("instruction"),Tr("lamports")])},Withdraw:{index:4,layout:At([It("instruction"),Tr("lamports")])},Deactivate:{index:5,layout:At([It("instruction")])},Merge:{index:7,layout:At([It("instruction")])},AuthorizeWithSeed:{index:8,layout:At([It("instruction"),oe("newAuthorized"),It("stakeAuthorizationType"),Rn("authoritySeed"),oe("authorityOwner")])}}),H0=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class es{constructor(){}static initialize(t){const{stakePubkey:e,authorized:r,lockup:s}=t,i=s||bi.default,o=ur.Initialize,a=fe(o,{authorized:{staker:te(r.staker.toBuffer()),withdrawer:te(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:te(i.custodian.toBuffer())}}),l={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Ue(l)}static createAccountWithSeed(t){const e=new ye;e.add(cr.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:s,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static createAccount(t){const e=new ye;e.add(cr.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:r,votePubkey:s}=t,i=ur.Delegate,o=fe(i);return new ye().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Gi,isSigner:!1,isWritable:!1},{pubkey:Fc,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(t){const{stakePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:s,stakeAuthorizationType:i,custodianPubkey:o}=t,a=ur.Authorize,l=fe(a,{newAuthorized:te(s.toBuffer()),stakeAuthorizationType:i.index}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&y.push({pubkey:o,isSigner:!0,isWritable:!1}),new ye().add({keys:y,programId:this.programId,data:l})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:l}=t,y=ur.AuthorizeWithSeed,x=fe(y,{newAuthorized:te(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:s,authorityOwner:te(i.toBuffer())}),E=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1}];return l&&E.push({pubkey:l,isSigner:!0,isWritable:!1}),new ye().add({keys:E,programId:this.programId,data:x})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:s,lamports:i}=t,o=ur.Split,a=fe(o,{lamports:i});return new Ue({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(t,e){const r=new ye;return r.add(cr.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:s,splitStakePubkey:i,basePubkey:o,seed:a,lamports:l}=t,y=new ye;return y.add(cr.allocate({accountPubkey:i,basePubkey:o,seed:a,space:this.space,programId:this.programId})),e&&e>0&&y.add(cr.transfer({fromPubkey:t.authorizedPubkey,toPubkey:i,lamports:e})),y.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,lamports:l}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:r,authorizedPubkey:s}=t,i=ur.Merge,o=fe(i);return new ye().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Gi,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:r,toPubkey:s,lamports:i,custodianPubkey:o}=t,a=ur.Withdraw,l=fe(a,{lamports:i}),y=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:Gi,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&y.push({pubkey:o,isSigner:!0,isWritable:!1}),new ye().add({keys:y,programId:this.programId,data:l})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:r}=t,s=ur.Deactivate,i=fe(s);return new ye().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}es.programId=new gt("Stake11111111111111111111111111111111111111"),es.space=200;class Kc{constructor(t,e,r,s){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=s}}class V0{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=It("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(tn))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Ee(tn.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new Kc(new gt(e.nodePubkey),new gt(e.authorizedVoter),new gt(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:r}=Ee(tn.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new gt(e),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:r,newAuthorized:s,voteAuthorizationType:i}}=Ee(tn.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new gt(e),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new gt(s),voteAuthorizationType:{index:i},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ee(tn.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(ti.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 tn=Object.freeze({InitializeAccount:{index:0,layout:At([It("instruction"),Jl()])},Authorize:{index:1,layout:At([It("instruction"),oe("newAuthorized"),It("voteAuthorizationType")])},Withdraw:{index:3,layout:At([It("instruction"),Tr("lamports")])},UpdateValidatorIdentity:{index:4,layout:At([It("instruction")])},AuthorizeWithSeed:{index:10,layout:At([It("instruction"),Xl()])}}),j0=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class ti{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:s}=t,i=tn.InitializeAccount,o=fe(i,{voteInit:{nodePubkey:te(s.nodePubkey.toBuffer()),authorizedVoter:te(s.authorizedVoter.toBuffer()),authorizedWithdrawer:te(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),a={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Ue(a)}static createAccount(t){const e=new ye;return e.add(cr.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:s,voteAuthorizationType:i}=t,o=tn.Authorize,a=fe(o,{newAuthorized:te(s.toBuffer()),voteAuthorizationType:i.index}),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new ye().add({keys:l,programId:this.programId,data:a})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:a}=t,l=tn.AuthorizeWithSeed,y=fe(l,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:te(r.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:te(i.toBuffer()),voteAuthorizationType:o.index}}),x=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Xr,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new ye().add({keys:x,programId:this.programId,data:y})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,lamports:s,toPubkey:i}=t,o=tn.Withdraw,a=fe(o,{lamports:s}),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new ye().add({keys:l,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 ti.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,nodePubkey:s}=t,i=tn.UpdateValidatorIdentity,o=fe(i),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new ye().add({keys:a,programId:this.programId,data:o})}}ti.programId=new gt("Vote111111111111111111111111111111111111111"),ti.space=3762;const Wc=new gt("Va1idator1nfo111111111111111111111111111111"),G0=ot({name:dt(),website:Ot(dt()),details:Ot(dt()),iconUrl:Ot(dt()),keybaseUsername:Ot(dt())});class vo{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(_r(e)!==2)return null;const s=[];for(let i=0;i<2;i++){const o=new gt(Ir(e,0,Zr)),a=Jr(e)===1;s.push({publicKey:o,isSigner:a})}if(s[0].publicKey.equals(Wc)&&s[1].isSigner){const i=Rn().decode(Ct.Buffer.from(e)),o=JSON.parse(i);return Ca(o,G0),new vo(s[1].publicKey,o)}return null}}const Y0=new gt("Vote111111111111111111111111111111111111111"),Z0=At([oe("nodePubkey"),oe("authorizedWithdrawer"),ge("commission"),hr(),dr(At([hr("slot"),It("confirmationCount")]),pn(It(),-8),"votes"),ge("rootSlotValid"),hr("rootSlot"),hr(),dr(At([hr("epoch"),oe("authorizedVoter")]),pn(It(),-8),"authorizedVoters"),At([dr(At([oe("authorizedPubkey"),hr("epochOfLastAuthorizedSwitch"),hr("targetEpoch")]),32,"buf"),hr("idx"),ge("isEmpty")],"priorVoters"),hr(),dr(At([hr("epoch"),hr("credits"),hr("prevCredits")]),pn(It(),-8),"epochCredits"),At([hr("slot"),hr("timestamp")],"lastTimestamp")]);class ko{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=Z0.decode(te(t),4);let s=r.rootSlot;return r.rootSlotValid||(s=null),new ko({nodePubkey:new gt(r.nodePubkey),authorizedWithdrawer:new gt(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:s,authorizedVoters:r.authorizedVoters.map(J0),priorVoters:X0(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function J0({authorizedVoter:n,epoch:t}){return{epoch:t,authorizedVoter:new gt(n)}}function Dc({authorizedPubkey:n,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new gt(n),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function X0({buf:n,idx:t,isEmpty:e}){return e?[]:[...n.slice(t+1).map(Dc),...n.slice(0,t).map(Dc)]}const $c={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 Q0(n,t){const e=t===!1?"http":"https";if(!n)return $c[e].devnet;const r=$c[e][n];if(!r)throw new Error(`Unknown ${e} cluster: ${n}`);return r}async function td(n,t,e,r){let s,i;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(s=e,i=r):i=e;const o=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,minContextSlot:i.minContextSlot},a=await n.sendRawTransaction(t,o),l=i&&i.commitment,x=(await(s?n.confirmTransaction(s,l):n.confirmTransaction(a,l))).value;if(x.err)throw a!=null?new yi({action:o!=null&&o.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(x)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(x)})`);return a}const rs=Object.freeze(Object.defineProperty({__proto__:null,Account:Vl,AddressLookupTableAccount:ao,AddressLookupTableInstruction:z0,AddressLookupTableProgram:mo,Authorized:zc,BLOCKHASH_CACHE_TIMEOUT_MS:mc,BPF_LOADER_DEPRECATED_PROGRAM_ID:jl,BPF_LOADER_PROGRAM_ID:uh,BpfLoader:fh,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Qr,ComputeBudgetInstruction:K0,ComputeBudgetProgram:wo,Connection:F0,Ed25519Program:ts,Enum:ql,EpochSchedule:pc,FeeCalculatorLayout:fc,Keypair:Un,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:an,Loader:Pn,Lockup:bi,MAX_SEED_LENGTH:sc,Message:Wr,MessageAccountKeys:gi,MessageV0:Tn,NONCE_ACCOUNT_LENGTH:io,NonceAccount:Yi,PACKET_DATA_SIZE:yn,PUBLIC_KEY_LENGTH:Zr,PublicKey:gt,SIGNATURE_LENGTH_IN_BYTES:pi,SOLANA_SCHEMA:di,STAKE_CONFIG_ID:Fc,STAKE_INSTRUCTION_LAYOUTS:ur,SYSTEM_INSTRUCTION_LAYOUTS:Ne,SYSVAR_CLOCK_PUBKEY:Xr,SYSVAR_EPOCH_SCHEDULE_PUBKEY:th,SYSVAR_INSTRUCTIONS_PUBKEY:eh,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:ji,SYSVAR_RENT_PUBKEY:Zn,SYSVAR_REWARDS_PUBKEY:rh,SYSVAR_SLOT_HASHES_PUBKEY:nh,SYSVAR_SLOT_HISTORY_PUBKEY:ih,SYSVAR_STAKE_HISTORY_PUBKEY:Gi,Secp256k1Program:Qn,SendTransactionError:yi,SolanaJSONRPCError:Rt,SolanaJSONRPCErrorCode:sh,StakeAuthorizationLayout:H0,StakeInstruction:q0,StakeProgram:es,Struct:Js,SystemInstruction:ah,SystemProgram:cr,Transaction:ye,TransactionExpiredBlockheightExceededError:Xs,TransactionExpiredNonceInvalidError:Yn,TransactionExpiredTimeoutError:Qs,TransactionInstruction:Ue,TransactionMessage:eo,TransactionStatus:on,VALIDATOR_INFO_KEY:Wc,VERSION_PREFIX_MASK:Hi,VOTE_PROGRAM_ID:Y0,ValidatorInfo:vo,VersionedMessage:to,VersionedTransaction:ro,VoteAccount:ko,VoteAuthorizationLayout:j0,VoteInit:Kc,VoteInstruction:V0,VoteProgram:ti,clusterApiUrl:Q0,sendAndConfirmRawTransaction:td,sendAndConfirmTransaction:no},Symbol.toStringTag,{value:"Module"})),Dr=ar;var So={exports:{}};So.exports,function(n){var t=function(){var e=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(l,y){if(!i[l]){i[l]={};for(var x=0;x<l.length;x++)i[l][l.charAt(x)]=x}return i[l][y]}var a={compressToBase64:function(l){if(l==null)return"";var y=a._compress(l,6,function(x){return r.charAt(x)});switch(y.length%4){default:case 0:return y;case 1:return y+"===";case 2:return y+"==";case 3:return y+"="}},decompressFromBase64:function(l){return l==null?"":l==""?null:a._decompress(l.length,32,function(y){return o(r,l.charAt(y))})},compressToUTF16:function(l){return l==null?"":a._compress(l,15,function(y){return e(y+32)})+" "},decompressFromUTF16:function(l){return l==null?"":l==""?null:a._decompress(l.length,16384,function(y){return l.charCodeAt(y)-32})},compressToUint8Array:function(l){for(var y=a.compress(l),x=new Uint8Array(y.length*2),E=0,L=y.length;E<L;E++){var C=y.charCodeAt(E);x[E*2]=C>>>8,x[E*2+1]=C%256}return x},decompressFromUint8Array:function(l){if(l==null)return a.decompress(l);for(var y=new Array(l.length/2),x=0,E=y.length;x<E;x++)y[x]=l[x*2]*256+l[x*2+1];var L=[];return y.forEach(function(C){L.push(e(C))}),a.decompress(L.join(""))},compressToEncodedURIComponent:function(l){return l==null?"":a._compress(l,6,function(y){return s.charAt(y)})},decompressFromEncodedURIComponent:function(l){return l==null?"":l==""?null:(l=l.replace(/ /g,"+"),a._decompress(l.length,32,function(y){return o(s,l.charAt(y))}))},compress:function(l){return a._compress(l,16,function(y){return e(y)})},_compress:function(l,y,x){if(l==null)return"";var E,L,C={},N={},M="",O="",K="",Q=2,j=3,it=2,J=[],D=0,tt=0,rt;for(rt=0;rt<l.length;rt+=1)if(M=l.charAt(rt),Object.prototype.hasOwnProperty.call(C,M)||(C[M]=j++,N[M]=!0),O=K+M,Object.prototype.hasOwnProperty.call(C,O))K=O;else{if(Object.prototype.hasOwnProperty.call(N,K)){if(K.charCodeAt(0)<256){for(E=0;E<it;E++)D=D<<1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++;for(L=K.charCodeAt(0),E=0;E<8;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1}else{for(L=1,E=0;E<it;E++)D=D<<1|L,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=0;for(L=K.charCodeAt(0),E=0;E<16;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1}Q--,Q==0&&(Q=Math.pow(2,it),it++),delete N[K]}else for(L=C[K],E=0;E<it;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1;Q--,Q==0&&(Q=Math.pow(2,it),it++),C[O]=j++,K=String(M)}if(K!==""){if(Object.prototype.hasOwnProperty.call(N,K)){if(K.charCodeAt(0)<256){for(E=0;E<it;E++)D=D<<1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++;for(L=K.charCodeAt(0),E=0;E<8;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1}else{for(L=1,E=0;E<it;E++)D=D<<1|L,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=0;for(L=K.charCodeAt(0),E=0;E<16;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1}Q--,Q==0&&(Q=Math.pow(2,it),it++),delete N[K]}else for(L=C[K],E=0;E<it;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1;Q--,Q==0&&(Q=Math.pow(2,it),it++)}for(L=2,E=0;E<it;E++)D=D<<1|L&1,tt==y-1?(tt=0,J.push(x(D)),D=0):tt++,L=L>>1;for(;;)if(D=D<<1,tt==y-1){J.push(x(D));break}else tt++;return J.join("")},decompress:function(l){return l==null?"":l==""?null:a._decompress(l.length,32768,function(y){return l.charCodeAt(y)})},_decompress:function(l,y,x){var E=[],L=4,C=4,N=3,M="",O=[],K,Q,j,it,J,D,tt,rt={val:x(0),position:y,index:1};for(K=0;K<3;K+=1)E[K]=K;for(j=0,J=Math.pow(2,2),D=1;D!=J;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),j|=(it>0?1:0)*D,D<<=1;switch(j){case 0:for(j=0,J=Math.pow(2,8),D=1;D!=J;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),j|=(it>0?1:0)*D,D<<=1;tt=e(j);break;case 1:for(j=0,J=Math.pow(2,16),D=1;D!=J;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),j|=(it>0?1:0)*D,D<<=1;tt=e(j);break;case 2:return""}for(E[3]=tt,Q=tt,O.push(tt);;){if(rt.index>l)return"";for(j=0,J=Math.pow(2,N),D=1;D!=J;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),j|=(it>0?1:0)*D,D<<=1;switch(tt=j){case 0:for(j=0,J=Math.pow(2,8),D=1;D!=J;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),j|=(it>0?1:0)*D,D<<=1;E[C++]=e(j),tt=C-1,L--;break;case 1:for(j=0,J=Math.pow(2,16),D=1;D!=J;)it=rt.val&rt.position,rt.position>>=1,rt.position==0&&(rt.position=y,rt.val=x(rt.index++)),j|=(it>0?1:0)*D,D<<=1;E[C++]=e(j),tt=C-1,L--;break;case 2:return O.join("")}if(L==0&&(L=Math.pow(2,N),N++),E[tt])M=E[tt];else if(tt===C)M=Q+Q.charAt(0);else return null;O.push(M),E[C++]=Q+M.charAt(0),L--,Q=M,L==0&&(L=Math.pow(2,N),N++)}}};return a}();n!=null?n.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(So);var ed=So.exports;const $r=ni(ed);function rd(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var qc={exports:{}};(function(n){(function(t){var e=function(g){var b,v=new Float64Array(16);if(g)for(b=0;b<g.length;b++)v[b]=g[b];return v},r=function(){throw new Error("no PRNG")},s=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var o=e(),a=e([1]),l=e([56129,1]),y=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),x=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),E=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),L=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),C=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function N(g,b,v,c){g[b]=v>>24&255,g[b+1]=v>>16&255,g[b+2]=v>>8&255,g[b+3]=v&255,g[b+4]=c>>24&255,g[b+5]=c>>16&255,g[b+6]=c>>8&255,g[b+7]=c&255}function M(g,b,v,c,S){var W,z=0;for(W=0;W<S;W++)z|=g[b+W]^v[c+W];return(1&z-1>>>8)-1}function O(g,b,v,c){return M(g,b,v,c,16)}function K(g,b,v,c){return M(g,b,v,c,32)}function Q(g,b,v,c){for(var S=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,W=v[0]&255|(v[1]&255)<<8|(v[2]&255)<<16|(v[3]&255)<<24,z=v[4]&255|(v[5]&255)<<8|(v[6]&255)<<16|(v[7]&255)<<24,X=v[8]&255|(v[9]&255)<<8|(v[10]&255)<<16|(v[11]&255)<<24,lt=v[12]&255|(v[13]&255)<<8|(v[14]&255)<<16|(v[15]&255)<<24,pt=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,ht=b[0]&255|(b[1]&255)<<8|(b[2]&255)<<16|(b[3]&255)<<24,ae=b[4]&255|(b[5]&255)<<8|(b[6]&255)<<16|(b[7]&255)<<24,vt=b[8]&255|(b[9]&255)<<8|(b[10]&255)<<16|(b[11]&255)<<24,Ft=b[12]&255|(b[13]&255)<<8|(b[14]&255)<<16|(b[15]&255)<<24,Kt=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,Vt=v[16]&255|(v[17]&255)<<8|(v[18]&255)<<16|(v[19]&255)<<24,qt=v[20]&255|(v[21]&255)<<8|(v[22]&255)<<16|(v[23]&255)<<24,Wt=v[24]&255|(v[25]&255)<<8|(v[26]&255)<<16|(v[27]&255)<<24,$t=v[28]&255|(v[29]&255)<<8|(v[30]&255)<<16|(v[31]&255)<<24,Dt=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,St=S,Bt=W,xt=z,Et=X,_t=lt,mt=pt,G=ht,Y=ae,st=vt,et=Ft,nt=Kt,ut=Vt,Ut=qt,Zt=Wt,Xt=$t,Jt=Dt,P,ie=0;ie<20;ie+=2)P=St+Ut|0,_t^=P<<7|P>>>25,P=_t+St|0,st^=P<<9|P>>>23,P=st+_t|0,Ut^=P<<13|P>>>19,P=Ut+st|0,St^=P<<18|P>>>14,P=mt+Bt|0,et^=P<<7|P>>>25,P=et+mt|0,Zt^=P<<9|P>>>23,P=Zt+et|0,Bt^=P<<13|P>>>19,P=Bt+Zt|0,mt^=P<<18|P>>>14,P=nt+G|0,Xt^=P<<7|P>>>25,P=Xt+nt|0,xt^=P<<9|P>>>23,P=xt+Xt|0,G^=P<<13|P>>>19,P=G+xt|0,nt^=P<<18|P>>>14,P=Jt+ut|0,Et^=P<<7|P>>>25,P=Et+Jt|0,Y^=P<<9|P>>>23,P=Y+Et|0,ut^=P<<13|P>>>19,P=ut+Y|0,Jt^=P<<18|P>>>14,P=St+Et|0,Bt^=P<<7|P>>>25,P=Bt+St|0,xt^=P<<9|P>>>23,P=xt+Bt|0,Et^=P<<13|P>>>19,P=Et+xt|0,St^=P<<18|P>>>14,P=mt+_t|0,G^=P<<7|P>>>25,P=G+mt|0,Y^=P<<9|P>>>23,P=Y+G|0,_t^=P<<13|P>>>19,P=_t+Y|0,mt^=P<<18|P>>>14,P=nt+et|0,ut^=P<<7|P>>>25,P=ut+nt|0,st^=P<<9|P>>>23,P=st+ut|0,et^=P<<13|P>>>19,P=et+st|0,nt^=P<<18|P>>>14,P=Jt+Xt|0,Ut^=P<<7|P>>>25,P=Ut+Jt|0,Zt^=P<<9|P>>>23,P=Zt+Ut|0,Xt^=P<<13|P>>>19,P=Xt+Zt|0,Jt^=P<<18|P>>>14;St=St+S|0,Bt=Bt+W|0,xt=xt+z|0,Et=Et+X|0,_t=_t+lt|0,mt=mt+pt|0,G=G+ht|0,Y=Y+ae|0,st=st+vt|0,et=et+Ft|0,nt=nt+Kt|0,ut=ut+Vt|0,Ut=Ut+qt|0,Zt=Zt+Wt|0,Xt=Xt+$t|0,Jt=Jt+Dt|0,g[0]=St>>>0&255,g[1]=St>>>8&255,g[2]=St>>>16&255,g[3]=St>>>24&255,g[4]=Bt>>>0&255,g[5]=Bt>>>8&255,g[6]=Bt>>>16&255,g[7]=Bt>>>24&255,g[8]=xt>>>0&255,g[9]=xt>>>8&255,g[10]=xt>>>16&255,g[11]=xt>>>24&255,g[12]=Et>>>0&255,g[13]=Et>>>8&255,g[14]=Et>>>16&255,g[15]=Et>>>24&255,g[16]=_t>>>0&255,g[17]=_t>>>8&255,g[18]=_t>>>16&255,g[19]=_t>>>24&255,g[20]=mt>>>0&255,g[21]=mt>>>8&255,g[22]=mt>>>16&255,g[23]=mt>>>24&255,g[24]=G>>>0&255,g[25]=G>>>8&255,g[26]=G>>>16&255,g[27]=G>>>24&255,g[28]=Y>>>0&255,g[29]=Y>>>8&255,g[30]=Y>>>16&255,g[31]=Y>>>24&255,g[32]=st>>>0&255,g[33]=st>>>8&255,g[34]=st>>>16&255,g[35]=st>>>24&255,g[36]=et>>>0&255,g[37]=et>>>8&255,g[38]=et>>>16&255,g[39]=et>>>24&255,g[40]=nt>>>0&255,g[41]=nt>>>8&255,g[42]=nt>>>16&255,g[43]=nt>>>24&255,g[44]=ut>>>0&255,g[45]=ut>>>8&255,g[46]=ut>>>16&255,g[47]=ut>>>24&255,g[48]=Ut>>>0&255,g[49]=Ut>>>8&255,g[50]=Ut>>>16&255,g[51]=Ut>>>24&255,g[52]=Zt>>>0&255,g[53]=Zt>>>8&255,g[54]=Zt>>>16&255,g[55]=Zt>>>24&255,g[56]=Xt>>>0&255,g[57]=Xt>>>8&255,g[58]=Xt>>>16&255,g[59]=Xt>>>24&255,g[60]=Jt>>>0&255,g[61]=Jt>>>8&255,g[62]=Jt>>>16&255,g[63]=Jt>>>24&255}function j(g,b,v,c){for(var S=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,W=v[0]&255|(v[1]&255)<<8|(v[2]&255)<<16|(v[3]&255)<<24,z=v[4]&255|(v[5]&255)<<8|(v[6]&255)<<16|(v[7]&255)<<24,X=v[8]&255|(v[9]&255)<<8|(v[10]&255)<<16|(v[11]&255)<<24,lt=v[12]&255|(v[13]&255)<<8|(v[14]&255)<<16|(v[15]&255)<<24,pt=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,ht=b[0]&255|(b[1]&255)<<8|(b[2]&255)<<16|(b[3]&255)<<24,ae=b[4]&255|(b[5]&255)<<8|(b[6]&255)<<16|(b[7]&255)<<24,vt=b[8]&255|(b[9]&255)<<8|(b[10]&255)<<16|(b[11]&255)<<24,Ft=b[12]&255|(b[13]&255)<<8|(b[14]&255)<<16|(b[15]&255)<<24,Kt=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,Vt=v[16]&255|(v[17]&255)<<8|(v[18]&255)<<16|(v[19]&255)<<24,qt=v[20]&255|(v[21]&255)<<8|(v[22]&255)<<16|(v[23]&255)<<24,Wt=v[24]&255|(v[25]&255)<<8|(v[26]&255)<<16|(v[27]&255)<<24,$t=v[28]&255|(v[29]&255)<<8|(v[30]&255)<<16|(v[31]&255)<<24,Dt=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,St=S,Bt=W,xt=z,Et=X,_t=lt,mt=pt,G=ht,Y=ae,st=vt,et=Ft,nt=Kt,ut=Vt,Ut=qt,Zt=Wt,Xt=$t,Jt=Dt,P,ie=0;ie<20;ie+=2)P=St+Ut|0,_t^=P<<7|P>>>25,P=_t+St|0,st^=P<<9|P>>>23,P=st+_t|0,Ut^=P<<13|P>>>19,P=Ut+st|0,St^=P<<18|P>>>14,P=mt+Bt|0,et^=P<<7|P>>>25,P=et+mt|0,Zt^=P<<9|P>>>23,P=Zt+et|0,Bt^=P<<13|P>>>19,P=Bt+Zt|0,mt^=P<<18|P>>>14,P=nt+G|0,Xt^=P<<7|P>>>25,P=Xt+nt|0,xt^=P<<9|P>>>23,P=xt+Xt|0,G^=P<<13|P>>>19,P=G+xt|0,nt^=P<<18|P>>>14,P=Jt+ut|0,Et^=P<<7|P>>>25,P=Et+Jt|0,Y^=P<<9|P>>>23,P=Y+Et|0,ut^=P<<13|P>>>19,P=ut+Y|0,Jt^=P<<18|P>>>14,P=St+Et|0,Bt^=P<<7|P>>>25,P=Bt+St|0,xt^=P<<9|P>>>23,P=xt+Bt|0,Et^=P<<13|P>>>19,P=Et+xt|0,St^=P<<18|P>>>14,P=mt+_t|0,G^=P<<7|P>>>25,P=G+mt|0,Y^=P<<9|P>>>23,P=Y+G|0,_t^=P<<13|P>>>19,P=_t+Y|0,mt^=P<<18|P>>>14,P=nt+et|0,ut^=P<<7|P>>>25,P=ut+nt|0,st^=P<<9|P>>>23,P=st+ut|0,et^=P<<13|P>>>19,P=et+st|0,nt^=P<<18|P>>>14,P=Jt+Xt|0,Ut^=P<<7|P>>>25,P=Ut+Jt|0,Zt^=P<<9|P>>>23,P=Zt+Ut|0,Xt^=P<<13|P>>>19,P=Xt+Zt|0,Jt^=P<<18|P>>>14;g[0]=St>>>0&255,g[1]=St>>>8&255,g[2]=St>>>16&255,g[3]=St>>>24&255,g[4]=mt>>>0&255,g[5]=mt>>>8&255,g[6]=mt>>>16&255,g[7]=mt>>>24&255,g[8]=nt>>>0&255,g[9]=nt>>>8&255,g[10]=nt>>>16&255,g[11]=nt>>>24&255,g[12]=Jt>>>0&255,g[13]=Jt>>>8&255,g[14]=Jt>>>16&255,g[15]=Jt>>>24&255,g[16]=G>>>0&255,g[17]=G>>>8&255,g[18]=G>>>16&255,g[19]=G>>>24&255,g[20]=Y>>>0&255,g[21]=Y>>>8&255,g[22]=Y>>>16&255,g[23]=Y>>>24&255,g[24]=st>>>0&255,g[25]=st>>>8&255,g[26]=st>>>16&255,g[27]=st>>>24&255,g[28]=et>>>0&255,g[29]=et>>>8&255,g[30]=et>>>16&255,g[31]=et>>>24&255}function it(g,b,v,c){Q(g,b,v,c)}function J(g,b,v,c){j(g,b,v,c)}var D=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function tt(g,b,v,c,S,W,z){var X=new Uint8Array(16),lt=new Uint8Array(64),pt,ht;for(ht=0;ht<16;ht++)X[ht]=0;for(ht=0;ht<8;ht++)X[ht]=W[ht];for(;S>=64;){for(it(lt,X,z,D),ht=0;ht<64;ht++)g[b+ht]=v[c+ht]^lt[ht];for(pt=1,ht=8;ht<16;ht++)pt=pt+(X[ht]&255)|0,X[ht]=pt&255,pt>>>=8;S-=64,b+=64,c+=64}if(S>0)for(it(lt,X,z,D),ht=0;ht<S;ht++)g[b+ht]=v[c+ht]^lt[ht];return 0}function rt(g,b,v,c,S){var W=new Uint8Array(16),z=new Uint8Array(64),X,lt;for(lt=0;lt<16;lt++)W[lt]=0;for(lt=0;lt<8;lt++)W[lt]=c[lt];for(;v>=64;){for(it(z,W,S,D),lt=0;lt<64;lt++)g[b+lt]=z[lt];for(X=1,lt=8;lt<16;lt++)X=X+(W[lt]&255)|0,W[lt]=X&255,X>>>=8;v-=64,b+=64}if(v>0)for(it(z,W,S,D),lt=0;lt<v;lt++)g[b+lt]=z[lt];return 0}function ue(g,b,v,c,S){var W=new Uint8Array(32);J(W,c,S,D);for(var z=new Uint8Array(8),X=0;X<8;X++)z[X]=c[X+16];return rt(g,b,v,z,W)}function jt(g,b,v,c,S,W,z){var X=new Uint8Array(32);J(X,W,z,D);for(var lt=new Uint8Array(8),pt=0;pt<8;pt++)lt[pt]=W[pt+16];return tt(g,b,v,c,S,lt,X)}var kt=function(g){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var b,v,c,S,W,z,X,lt;b=g[0]&255|(g[1]&255)<<8,this.r[0]=b&8191,v=g[2]&255|(g[3]&255)<<8,this.r[1]=(b>>>13|v<<3)&8191,c=g[4]&255|(g[5]&255)<<8,this.r[2]=(v>>>10|c<<6)&7939,S=g[6]&255|(g[7]&255)<<8,this.r[3]=(c>>>7|S<<9)&8191,W=g[8]&255|(g[9]&255)<<8,this.r[4]=(S>>>4|W<<12)&255,this.r[5]=W>>>1&8190,z=g[10]&255|(g[11]&255)<<8,this.r[6]=(W>>>14|z<<2)&8191,X=g[12]&255|(g[13]&255)<<8,this.r[7]=(z>>>11|X<<5)&8065,lt=g[14]&255|(g[15]&255)<<8,this.r[8]=(X>>>8|lt<<8)&8191,this.r[9]=lt>>>5&127,this.pad[0]=g[16]&255|(g[17]&255)<<8,this.pad[1]=g[18]&255|(g[19]&255)<<8,this.pad[2]=g[20]&255|(g[21]&255)<<8,this.pad[3]=g[22]&255|(g[23]&255)<<8,this.pad[4]=g[24]&255|(g[25]&255)<<8,this.pad[5]=g[26]&255|(g[27]&255)<<8,this.pad[6]=g[28]&255|(g[29]&255)<<8,this.pad[7]=g[30]&255|(g[31]&255)<<8};kt.prototype.blocks=function(g,b,v){for(var c=this.fin?0:2048,S,W,z,X,lt,pt,ht,ae,vt,Ft,Kt,Vt,qt,Wt,$t,Dt,St,Bt,xt,Et=this.h[0],_t=this.h[1],mt=this.h[2],G=this.h[3],Y=this.h[4],st=this.h[5],et=this.h[6],nt=this.h[7],ut=this.h[8],Ut=this.h[9],Zt=this.r[0],Xt=this.r[1],Jt=this.r[2],P=this.r[3],ie=this.r[4],me=this.r[5],we=this.r[6],ne=this.r[7],de=this.r[8],pe=this.r[9];v>=16;)S=g[b+0]&255|(g[b+1]&255)<<8,Et+=S&8191,W=g[b+2]&255|(g[b+3]&255)<<8,_t+=(S>>>13|W<<3)&8191,z=g[b+4]&255|(g[b+5]&255)<<8,mt+=(W>>>10|z<<6)&8191,X=g[b+6]&255|(g[b+7]&255)<<8,G+=(z>>>7|X<<9)&8191,lt=g[b+8]&255|(g[b+9]&255)<<8,Y+=(X>>>4|lt<<12)&8191,st+=lt>>>1&8191,pt=g[b+10]&255|(g[b+11]&255)<<8,et+=(lt>>>14|pt<<2)&8191,ht=g[b+12]&255|(g[b+13]&255)<<8,nt+=(pt>>>11|ht<<5)&8191,ae=g[b+14]&255|(g[b+15]&255)<<8,ut+=(ht>>>8|ae<<8)&8191,Ut+=ae>>>5|c,vt=0,Ft=vt,Ft+=Et*Zt,Ft+=_t*(5*pe),Ft+=mt*(5*de),Ft+=G*(5*ne),Ft+=Y*(5*we),vt=Ft>>>13,Ft&=8191,Ft+=st*(5*me),Ft+=et*(5*ie),Ft+=nt*(5*P),Ft+=ut*(5*Jt),Ft+=Ut*(5*Xt),vt+=Ft>>>13,Ft&=8191,Kt=vt,Kt+=Et*Xt,Kt+=_t*Zt,Kt+=mt*(5*pe),Kt+=G*(5*de),Kt+=Y*(5*ne),vt=Kt>>>13,Kt&=8191,Kt+=st*(5*we),Kt+=et*(5*me),Kt+=nt*(5*ie),Kt+=ut*(5*P),Kt+=Ut*(5*Jt),vt+=Kt>>>13,Kt&=8191,Vt=vt,Vt+=Et*Jt,Vt+=_t*Xt,Vt+=mt*Zt,Vt+=G*(5*pe),Vt+=Y*(5*de),vt=Vt>>>13,Vt&=8191,Vt+=st*(5*ne),Vt+=et*(5*we),Vt+=nt*(5*me),Vt+=ut*(5*ie),Vt+=Ut*(5*P),vt+=Vt>>>13,Vt&=8191,qt=vt,qt+=Et*P,qt+=_t*Jt,qt+=mt*Xt,qt+=G*Zt,qt+=Y*(5*pe),vt=qt>>>13,qt&=8191,qt+=st*(5*de),qt+=et*(5*ne),qt+=nt*(5*we),qt+=ut*(5*me),qt+=Ut*(5*ie),vt+=qt>>>13,qt&=8191,Wt=vt,Wt+=Et*ie,Wt+=_t*P,Wt+=mt*Jt,Wt+=G*Xt,Wt+=Y*Zt,vt=Wt>>>13,Wt&=8191,Wt+=st*(5*pe),Wt+=et*(5*de),Wt+=nt*(5*ne),Wt+=ut*(5*we),Wt+=Ut*(5*me),vt+=Wt>>>13,Wt&=8191,$t=vt,$t+=Et*me,$t+=_t*ie,$t+=mt*P,$t+=G*Jt,$t+=Y*Xt,vt=$t>>>13,$t&=8191,$t+=st*Zt,$t+=et*(5*pe),$t+=nt*(5*de),$t+=ut*(5*ne),$t+=Ut*(5*we),vt+=$t>>>13,$t&=8191,Dt=vt,Dt+=Et*we,Dt+=_t*me,Dt+=mt*ie,Dt+=G*P,Dt+=Y*Jt,vt=Dt>>>13,Dt&=8191,Dt+=st*Xt,Dt+=et*Zt,Dt+=nt*(5*pe),Dt+=ut*(5*de),Dt+=Ut*(5*ne),vt+=Dt>>>13,Dt&=8191,St=vt,St+=Et*ne,St+=_t*we,St+=mt*me,St+=G*ie,St+=Y*P,vt=St>>>13,St&=8191,St+=st*Jt,St+=et*Xt,St+=nt*Zt,St+=ut*(5*pe),St+=Ut*(5*de),vt+=St>>>13,St&=8191,Bt=vt,Bt+=Et*de,Bt+=_t*ne,Bt+=mt*we,Bt+=G*me,Bt+=Y*ie,vt=Bt>>>13,Bt&=8191,Bt+=st*P,Bt+=et*Jt,Bt+=nt*Xt,Bt+=ut*Zt,Bt+=Ut*(5*pe),vt+=Bt>>>13,Bt&=8191,xt=vt,xt+=Et*pe,xt+=_t*de,xt+=mt*ne,xt+=G*we,xt+=Y*me,vt=xt>>>13,xt&=8191,xt+=st*ie,xt+=et*P,xt+=nt*Jt,xt+=ut*Xt,xt+=Ut*Zt,vt+=xt>>>13,xt&=8191,vt=(vt<<2)+vt|0,vt=vt+Ft|0,Ft=vt&8191,vt=vt>>>13,Kt+=vt,Et=Ft,_t=Kt,mt=Vt,G=qt,Y=Wt,st=$t,et=Dt,nt=St,ut=Bt,Ut=xt,b+=16,v-=16;this.h[0]=Et,this.h[1]=_t,this.h[2]=mt,this.h[3]=G,this.h[4]=Y,this.h[5]=st,this.h[6]=et,this.h[7]=nt,this.h[8]=ut,this.h[9]=Ut},kt.prototype.finish=function(g,b){var v=new Uint16Array(10),c,S,W,z;if(this.leftover){for(z=this.leftover,this.buffer[z++]=1;z<16;z++)this.buffer[z]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(c=this.h[1]>>>13,this.h[1]&=8191,z=2;z<10;z++)this.h[z]+=c,c=this.h[z]>>>13,this.h[z]&=8191;for(this.h[0]+=c*5,c=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=c,c=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=c,v[0]=this.h[0]+5,c=v[0]>>>13,v[0]&=8191,z=1;z<10;z++)v[z]=this.h[z]+c,c=v[z]>>>13,v[z]&=8191;for(v[9]-=8192,S=(c^1)-1,z=0;z<10;z++)v[z]&=S;for(S=~S,z=0;z<10;z++)this.h[z]=this.h[z]&S|v[z];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,W=this.h[0]+this.pad[0],this.h[0]=W&65535,z=1;z<8;z++)W=(this.h[z]+this.pad[z]|0)+(W>>>16)|0,this.h[z]=W&65535;g[b+0]=this.h[0]>>>0&255,g[b+1]=this.h[0]>>>8&255,g[b+2]=this.h[1]>>>0&255,g[b+3]=this.h[1]>>>8&255,g[b+4]=this.h[2]>>>0&255,g[b+5]=this.h[2]>>>8&255,g[b+6]=this.h[3]>>>0&255,g[b+7]=this.h[3]>>>8&255,g[b+8]=this.h[4]>>>0&255,g[b+9]=this.h[4]>>>8&255,g[b+10]=this.h[5]>>>0&255,g[b+11]=this.h[5]>>>8&255,g[b+12]=this.h[6]>>>0&255,g[b+13]=this.h[6]>>>8&255,g[b+14]=this.h[7]>>>0&255,g[b+15]=this.h[7]>>>8&255},kt.prototype.update=function(g,b,v){var c,S;if(this.leftover){for(S=16-this.leftover,S>v&&(S=v),c=0;c<S;c++)this.buffer[this.leftover+c]=g[b+c];if(v-=S,b+=S,this.leftover+=S,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(v>=16&&(S=v-v%16,this.blocks(g,b,S),b+=S,v-=S),v){for(c=0;c<v;c++)this.buffer[this.leftover+c]=g[b+c];this.leftover+=v}};function ce(g,b,v,c,S,W){var z=new kt(W);return z.update(v,c,S),z.finish(g,b),0}function T(g,b,v,c,S,W){var z=new Uint8Array(16);return ce(z,0,v,c,S,W),O(g,b,z,0)}function u(g,b,v,c,S){var W;if(v<32)return-1;for(jt(g,0,b,0,v,c,S),ce(g,16,g,32,v-32,g),W=0;W<16;W++)g[W]=0;return 0}function p(g,b,v,c,S){var W,z=new Uint8Array(32);if(v<32||(ue(z,0,32,c,S),T(b,16,b,32,v-32,z)!==0))return-1;for(jt(g,0,b,0,v,c,S),W=0;W<32;W++)g[W]=0;return 0}function m(g,b){var v;for(v=0;v<16;v++)g[v]=b[v]|0}function R(g){var b,v,c=1;for(b=0;b<16;b++)v=g[b]+c+65535,c=Math.floor(v/65536),g[b]=v-c*65536;g[0]+=c-1+37*(c-1)}function _(g,b,v){for(var c,S=~(v-1),W=0;W<16;W++)c=S&(g[W]^b[W]),g[W]^=c,b[W]^=c}function I(g,b){var v,c,S,W=e(),z=e();for(v=0;v<16;v++)z[v]=b[v];for(R(z),R(z),R(z),c=0;c<2;c++){for(W[0]=z[0]-65517,v=1;v<15;v++)W[v]=z[v]-65535-(W[v-1]>>16&1),W[v-1]&=65535;W[15]=z[15]-32767-(W[14]>>16&1),S=W[15]>>16&1,W[14]&=65535,_(z,W,1-S)}for(v=0;v<16;v++)g[2*v]=z[v]&255,g[2*v+1]=z[v]>>8}function U(g,b){var v=new Uint8Array(32),c=new Uint8Array(32);return I(v,g),I(c,b),K(v,0,c,0)}function k(g){var b=new Uint8Array(32);return I(b,g),b[0]&1}function h(g,b){var v;for(v=0;v<16;v++)g[v]=b[2*v]+(b[2*v+1]<<8);g[15]&=32767}function A(g,b,v){for(var c=0;c<16;c++)g[c]=b[c]+v[c]}function at(g,b,v){for(var c=0;c<16;c++)g[c]=b[c]-v[c]}function H(g,b,v){var c,S,W=0,z=0,X=0,lt=0,pt=0,ht=0,ae=0,vt=0,Ft=0,Kt=0,Vt=0,qt=0,Wt=0,$t=0,Dt=0,St=0,Bt=0,xt=0,Et=0,_t=0,mt=0,G=0,Y=0,st=0,et=0,nt=0,ut=0,Ut=0,Zt=0,Xt=0,Jt=0,P=v[0],ie=v[1],me=v[2],we=v[3],ne=v[4],de=v[5],pe=v[6],er=v[7],Pe=v[8],Xe=v[9],Qe=v[10],tr=v[11],sr=v[12],br=v[13],xr=v[14],vr=v[15];c=b[0],W+=c*P,z+=c*ie,X+=c*me,lt+=c*we,pt+=c*ne,ht+=c*de,ae+=c*pe,vt+=c*er,Ft+=c*Pe,Kt+=c*Xe,Vt+=c*Qe,qt+=c*tr,Wt+=c*sr,$t+=c*br,Dt+=c*xr,St+=c*vr,c=b[1],z+=c*P,X+=c*ie,lt+=c*me,pt+=c*we,ht+=c*ne,ae+=c*de,vt+=c*pe,Ft+=c*er,Kt+=c*Pe,Vt+=c*Xe,qt+=c*Qe,Wt+=c*tr,$t+=c*sr,Dt+=c*br,St+=c*xr,Bt+=c*vr,c=b[2],X+=c*P,lt+=c*ie,pt+=c*me,ht+=c*we,ae+=c*ne,vt+=c*de,Ft+=c*pe,Kt+=c*er,Vt+=c*Pe,qt+=c*Xe,Wt+=c*Qe,$t+=c*tr,Dt+=c*sr,St+=c*br,Bt+=c*xr,xt+=c*vr,c=b[3],lt+=c*P,pt+=c*ie,ht+=c*me,ae+=c*we,vt+=c*ne,Ft+=c*de,Kt+=c*pe,Vt+=c*er,qt+=c*Pe,Wt+=c*Xe,$t+=c*Qe,Dt+=c*tr,St+=c*sr,Bt+=c*br,xt+=c*xr,Et+=c*vr,c=b[4],pt+=c*P,ht+=c*ie,ae+=c*me,vt+=c*we,Ft+=c*ne,Kt+=c*de,Vt+=c*pe,qt+=c*er,Wt+=c*Pe,$t+=c*Xe,Dt+=c*Qe,St+=c*tr,Bt+=c*sr,xt+=c*br,Et+=c*xr,_t+=c*vr,c=b[5],ht+=c*P,ae+=c*ie,vt+=c*me,Ft+=c*we,Kt+=c*ne,Vt+=c*de,qt+=c*pe,Wt+=c*er,$t+=c*Pe,Dt+=c*Xe,St+=c*Qe,Bt+=c*tr,xt+=c*sr,Et+=c*br,_t+=c*xr,mt+=c*vr,c=b[6],ae+=c*P,vt+=c*ie,Ft+=c*me,Kt+=c*we,Vt+=c*ne,qt+=c*de,Wt+=c*pe,$t+=c*er,Dt+=c*Pe,St+=c*Xe,Bt+=c*Qe,xt+=c*tr,Et+=c*sr,_t+=c*br,mt+=c*xr,G+=c*vr,c=b[7],vt+=c*P,Ft+=c*ie,Kt+=c*me,Vt+=c*we,qt+=c*ne,Wt+=c*de,$t+=c*pe,Dt+=c*er,St+=c*Pe,Bt+=c*Xe,xt+=c*Qe,Et+=c*tr,_t+=c*sr,mt+=c*br,G+=c*xr,Y+=c*vr,c=b[8],Ft+=c*P,Kt+=c*ie,Vt+=c*me,qt+=c*we,Wt+=c*ne,$t+=c*de,Dt+=c*pe,St+=c*er,Bt+=c*Pe,xt+=c*Xe,Et+=c*Qe,_t+=c*tr,mt+=c*sr,G+=c*br,Y+=c*xr,st+=c*vr,c=b[9],Kt+=c*P,Vt+=c*ie,qt+=c*me,Wt+=c*we,$t+=c*ne,Dt+=c*de,St+=c*pe,Bt+=c*er,xt+=c*Pe,Et+=c*Xe,_t+=c*Qe,mt+=c*tr,G+=c*sr,Y+=c*br,st+=c*xr,et+=c*vr,c=b[10],Vt+=c*P,qt+=c*ie,Wt+=c*me,$t+=c*we,Dt+=c*ne,St+=c*de,Bt+=c*pe,xt+=c*er,Et+=c*Pe,_t+=c*Xe,mt+=c*Qe,G+=c*tr,Y+=c*sr,st+=c*br,et+=c*xr,nt+=c*vr,c=b[11],qt+=c*P,Wt+=c*ie,$t+=c*me,Dt+=c*we,St+=c*ne,Bt+=c*de,xt+=c*pe,Et+=c*er,_t+=c*Pe,mt+=c*Xe,G+=c*Qe,Y+=c*tr,st+=c*sr,et+=c*br,nt+=c*xr,ut+=c*vr,c=b[12],Wt+=c*P,$t+=c*ie,Dt+=c*me,St+=c*we,Bt+=c*ne,xt+=c*de,Et+=c*pe,_t+=c*er,mt+=c*Pe,G+=c*Xe,Y+=c*Qe,st+=c*tr,et+=c*sr,nt+=c*br,ut+=c*xr,Ut+=c*vr,c=b[13],$t+=c*P,Dt+=c*ie,St+=c*me,Bt+=c*we,xt+=c*ne,Et+=c*de,_t+=c*pe,mt+=c*er,G+=c*Pe,Y+=c*Xe,st+=c*Qe,et+=c*tr,nt+=c*sr,ut+=c*br,Ut+=c*xr,Zt+=c*vr,c=b[14],Dt+=c*P,St+=c*ie,Bt+=c*me,xt+=c*we,Et+=c*ne,_t+=c*de,mt+=c*pe,G+=c*er,Y+=c*Pe,st+=c*Xe,et+=c*Qe,nt+=c*tr,ut+=c*sr,Ut+=c*br,Zt+=c*xr,Xt+=c*vr,c=b[15],St+=c*P,Bt+=c*ie,xt+=c*me,Et+=c*we,_t+=c*ne,mt+=c*de,G+=c*pe,Y+=c*er,st+=c*Pe,et+=c*Xe,nt+=c*Qe,ut+=c*tr,Ut+=c*sr,Zt+=c*br,Xt+=c*xr,Jt+=c*vr,W+=38*Bt,z+=38*xt,X+=38*Et,lt+=38*_t,pt+=38*mt,ht+=38*G,ae+=38*Y,vt+=38*st,Ft+=38*et,Kt+=38*nt,Vt+=38*ut,qt+=38*Ut,Wt+=38*Zt,$t+=38*Xt,Dt+=38*Jt,S=1,c=W+S+65535,S=Math.floor(c/65536),W=c-S*65536,c=z+S+65535,S=Math.floor(c/65536),z=c-S*65536,c=X+S+65535,S=Math.floor(c/65536),X=c-S*65536,c=lt+S+65535,S=Math.floor(c/65536),lt=c-S*65536,c=pt+S+65535,S=Math.floor(c/65536),pt=c-S*65536,c=ht+S+65535,S=Math.floor(c/65536),ht=c-S*65536,c=ae+S+65535,S=Math.floor(c/65536),ae=c-S*65536,c=vt+S+65535,S=Math.floor(c/65536),vt=c-S*65536,c=Ft+S+65535,S=Math.floor(c/65536),Ft=c-S*65536,c=Kt+S+65535,S=Math.floor(c/65536),Kt=c-S*65536,c=Vt+S+65535,S=Math.floor(c/65536),Vt=c-S*65536,c=qt+S+65535,S=Math.floor(c/65536),qt=c-S*65536,c=Wt+S+65535,S=Math.floor(c/65536),Wt=c-S*65536,c=$t+S+65535,S=Math.floor(c/65536),$t=c-S*65536,c=Dt+S+65535,S=Math.floor(c/65536),Dt=c-S*65536,c=St+S+65535,S=Math.floor(c/65536),St=c-S*65536,W+=S-1+37*(S-1),S=1,c=W+S+65535,S=Math.floor(c/65536),W=c-S*65536,c=z+S+65535,S=Math.floor(c/65536),z=c-S*65536,c=X+S+65535,S=Math.floor(c/65536),X=c-S*65536,c=lt+S+65535,S=Math.floor(c/65536),lt=c-S*65536,c=pt+S+65535,S=Math.floor(c/65536),pt=c-S*65536,c=ht+S+65535,S=Math.floor(c/65536),ht=c-S*65536,c=ae+S+65535,S=Math.floor(c/65536),ae=c-S*65536,c=vt+S+65535,S=Math.floor(c/65536),vt=c-S*65536,c=Ft+S+65535,S=Math.floor(c/65536),Ft=c-S*65536,c=Kt+S+65535,S=Math.floor(c/65536),Kt=c-S*65536,c=Vt+S+65535,S=Math.floor(c/65536),Vt=c-S*65536,c=qt+S+65535,S=Math.floor(c/65536),qt=c-S*65536,c=Wt+S+65535,S=Math.floor(c/65536),Wt=c-S*65536,c=$t+S+65535,S=Math.floor(c/65536),$t=c-S*65536,c=Dt+S+65535,S=Math.floor(c/65536),Dt=c-S*65536,c=St+S+65535,S=Math.floor(c/65536),St=c-S*65536,W+=S-1+37*(S-1),g[0]=W,g[1]=z,g[2]=X,g[3]=lt,g[4]=pt,g[5]=ht,g[6]=ae,g[7]=vt,g[8]=Ft,g[9]=Kt,g[10]=Vt,g[11]=qt,g[12]=Wt,g[13]=$t,g[14]=Dt,g[15]=St}function ct(g,b){H(g,b,b)}function Tt(g,b){var v=e(),c;for(c=0;c<16;c++)v[c]=b[c];for(c=253;c>=0;c--)ct(v,v),c!==2&&c!==4&&H(v,v,b);for(c=0;c<16;c++)g[c]=v[c]}function Mt(g,b){var v=e(),c;for(c=0;c<16;c++)v[c]=b[c];for(c=250;c>=0;c--)ct(v,v),c!==1&&H(v,v,b);for(c=0;c<16;c++)g[c]=v[c]}function Pt(g,b,v){var c=new Uint8Array(32),S=new Float64Array(80),W,z,X=e(),lt=e(),pt=e(),ht=e(),ae=e(),vt=e();for(z=0;z<31;z++)c[z]=b[z];for(c[31]=b[31]&127|64,c[0]&=248,h(S,v),z=0;z<16;z++)lt[z]=S[z],ht[z]=X[z]=pt[z]=0;for(X[0]=ht[0]=1,z=254;z>=0;--z)W=c[z>>>3]>>>(z&7)&1,_(X,lt,W),_(pt,ht,W),A(ae,X,pt),at(X,X,pt),A(pt,lt,ht),at(lt,lt,ht),ct(ht,ae),ct(vt,X),H(X,pt,X),H(pt,lt,ae),A(ae,X,pt),at(X,X,pt),ct(lt,X),at(pt,ht,vt),H(X,pt,l),A(X,X,ht),H(pt,pt,X),H(X,ht,vt),H(ht,lt,S),ct(lt,ae),_(X,lt,W),_(pt,ht,W);for(z=0;z<16;z++)S[z+16]=X[z],S[z+32]=pt[z],S[z+48]=lt[z],S[z+64]=ht[z];var Ft=S.subarray(32),Kt=S.subarray(16);return Tt(Ft,Ft),H(Kt,Kt,Ft),I(g,Kt),0}function Ce(g,b){return Pt(g,b,i)}function Yt(g,b){return r(b,32),Ce(g,b)}function Gt(g,b,v){var c=new Uint8Array(32);return Pt(c,v,b),J(g,s,c,D)}var le=u,re=p;function ve(g,b,v,c,S,W){var z=new Uint8Array(32);return Gt(z,S,W),le(g,b,v,c,z)}function Or(g,b,v,c,S,W){var z=new Uint8Array(32);return Gt(z,S,W),re(g,b,v,c,z)}var _e=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Oe(g,b,v,c){for(var S=new Int32Array(16),W=new Int32Array(16),z,X,lt,pt,ht,ae,vt,Ft,Kt,Vt,qt,Wt,$t,Dt,St,Bt,xt,Et,_t,mt,G,Y,st,et,nt,ut,Ut=g[0],Zt=g[1],Xt=g[2],Jt=g[3],P=g[4],ie=g[5],me=g[6],we=g[7],ne=b[0],de=b[1],pe=b[2],er=b[3],Pe=b[4],Xe=b[5],Qe=b[6],tr=b[7],sr=0;c>=128;){for(_t=0;_t<16;_t++)mt=8*_t+sr,S[_t]=v[mt+0]<<24|v[mt+1]<<16|v[mt+2]<<8|v[mt+3],W[_t]=v[mt+4]<<24|v[mt+5]<<16|v[mt+6]<<8|v[mt+7];for(_t=0;_t<80;_t++)if(z=Ut,X=Zt,lt=Xt,pt=Jt,ht=P,ae=ie,vt=me,Ft=we,Kt=ne,Vt=de,qt=pe,Wt=er,$t=Pe,Dt=Xe,St=Qe,Bt=tr,G=we,Y=tr,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=(P>>>14|Pe<<18)^(P>>>18|Pe<<14)^(Pe>>>9|P<<23),Y=(Pe>>>14|P<<18)^(Pe>>>18|P<<14)^(P>>>9|Pe<<23),st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,G=P&ie^~P&me,Y=Pe&Xe^~Pe&Qe,st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,G=_e[_t*2],Y=_e[_t*2+1],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,G=S[_t%16],Y=W[_t%16],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,xt=nt&65535|ut<<16,Et=st&65535|et<<16,G=xt,Y=Et,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=(Ut>>>28|ne<<4)^(ne>>>2|Ut<<30)^(ne>>>7|Ut<<25),Y=(ne>>>28|Ut<<4)^(Ut>>>2|ne<<30)^(Ut>>>7|ne<<25),st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,G=Ut&Zt^Ut&Xt^Zt&Xt,Y=ne&de^ne&pe^de&pe,st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,Ft=nt&65535|ut<<16,Bt=st&65535|et<<16,G=pt,Y=Wt,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=xt,Y=Et,st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,pt=nt&65535|ut<<16,Wt=st&65535|et<<16,Zt=z,Xt=X,Jt=lt,P=pt,ie=ht,me=ae,we=vt,Ut=Ft,de=Kt,pe=Vt,er=qt,Pe=Wt,Xe=$t,Qe=Dt,tr=St,ne=Bt,_t%16===15)for(mt=0;mt<16;mt++)G=S[mt],Y=W[mt],st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=S[(mt+9)%16],Y=W[(mt+9)%16],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,xt=S[(mt+1)%16],Et=W[(mt+1)%16],G=(xt>>>1|Et<<31)^(xt>>>8|Et<<24)^xt>>>7,Y=(Et>>>1|xt<<31)^(Et>>>8|xt<<24)^(Et>>>7|xt<<25),st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,xt=S[(mt+14)%16],Et=W[(mt+14)%16],G=(xt>>>19|Et<<13)^(Et>>>29|xt<<3)^xt>>>6,Y=(Et>>>19|xt<<13)^(xt>>>29|Et<<3)^(Et>>>6|xt<<26),st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,S[mt]=nt&65535|ut<<16,W[mt]=st&65535|et<<16;G=Ut,Y=ne,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=g[0],Y=b[0],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[0]=Ut=nt&65535|ut<<16,b[0]=ne=st&65535|et<<16,G=Zt,Y=de,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=g[1],Y=b[1],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[1]=Zt=nt&65535|ut<<16,b[1]=de=st&65535|et<<16,G=Xt,Y=pe,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=g[2],Y=b[2],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[2]=Xt=nt&65535|ut<<16,b[2]=pe=st&65535|et<<16,G=Jt,Y=er,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=g[3],Y=b[3],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[3]=Jt=nt&65535|ut<<16,b[3]=er=st&65535|et<<16,G=P,Y=Pe,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=g[4],Y=b[4],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[4]=P=nt&65535|ut<<16,b[4]=Pe=st&65535|et<<16,G=ie,Y=Xe,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=g[5],Y=b[5],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[5]=ie=nt&65535|ut<<16,b[5]=Xe=st&65535|et<<16,G=me,Y=Qe,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=g[6],Y=b[6],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[6]=me=nt&65535|ut<<16,b[6]=Qe=st&65535|et<<16,G=we,Y=tr,st=Y&65535,et=Y>>>16,nt=G&65535,ut=G>>>16,G=g[7],Y=b[7],st+=Y&65535,et+=Y>>>16,nt+=G&65535,ut+=G>>>16,et+=st>>>16,nt+=et>>>16,ut+=nt>>>16,g[7]=we=nt&65535|ut<<16,b[7]=tr=st&65535|et<<16,sr+=128,c-=128}return c}function Ar(g,b,v){var c=new Int32Array(8),S=new Int32Array(8),W=new Uint8Array(256),z,X=v;for(c[0]=1779033703,c[1]=3144134277,c[2]=1013904242,c[3]=2773480762,c[4]=1359893119,c[5]=2600822924,c[6]=528734635,c[7]=1541459225,S[0]=4089235720,S[1]=2227873595,S[2]=4271175723,S[3]=1595750129,S[4]=2917565137,S[5]=725511199,S[6]=4215389547,S[7]=327033209,Oe(c,S,b,v),v%=128,z=0;z<v;z++)W[z]=b[X-v+z];for(W[v]=128,v=256-128*(v<112?1:0),W[v-9]=0,N(W,v-8,X/536870912|0,X<<3),Oe(c,S,W,v),z=0;z<8;z++)N(g,8*z,c[z],S[z]);return 0}function Ie(g,b){var v=e(),c=e(),S=e(),W=e(),z=e(),X=e(),lt=e(),pt=e(),ht=e();at(v,g[1],g[0]),at(ht,b[1],b[0]),H(v,v,ht),A(c,g[0],g[1]),A(ht,b[0],b[1]),H(c,c,ht),H(S,g[3],b[3]),H(S,S,x),H(W,g[2],b[2]),A(W,W,W),at(z,c,v),at(X,W,S),A(lt,W,S),A(pt,c,v),H(g[0],z,X),H(g[1],pt,lt),H(g[2],lt,X),H(g[3],z,pt)}function Ae(g,b,v){var c;for(c=0;c<4;c++)_(g[c],b[c],v)}function rr(g,b){var v=e(),c=e(),S=e();Tt(S,b[2]),H(v,b[0],S),H(c,b[1],S),I(g,c),g[31]^=k(v)<<7}function ke(g,b,v){var c,S;for(m(g[0],o),m(g[1],a),m(g[2],a),m(g[3],o),S=255;S>=0;--S)c=v[S/8|0]>>(S&7)&1,Ae(g,b,c),Ie(b,g),Ie(g,g),Ae(g,b,c)}function Se(g,b){var v=[e(),e(),e(),e()];m(v[0],E),m(v[1],L),m(v[2],a),H(v[3],E,L),ke(g,v,b)}function fr(g,b,v){var c=new Uint8Array(64),S=[e(),e(),e(),e()],W;for(v||r(b,32),Ar(c,b,32),c[0]&=248,c[31]&=127,c[31]|=64,Se(S,c),rr(g,S),W=0;W<32;W++)b[W+32]=g[W];return 0}var Be=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function w(g,b){var v,c,S,W;for(c=63;c>=32;--c){for(v=0,S=c-32,W=c-12;S<W;++S)b[S]+=v-16*b[c]*Be[S-(c-32)],v=Math.floor((b[S]+128)/256),b[S]-=v*256;b[S]+=v,b[c]=0}for(v=0,S=0;S<32;S++)b[S]+=v-(b[31]>>4)*Be[S],v=b[S]>>8,b[S]&=255;for(S=0;S<32;S++)b[S]-=v*Be[S];for(c=0;c<32;c++)b[c+1]+=b[c]>>8,g[c]=b[c]&255}function f(g){var b=new Float64Array(64),v;for(v=0;v<64;v++)b[v]=g[v];for(v=0;v<64;v++)g[v]=0;w(g,b)}function d(g,b,v,c){var S=new Uint8Array(64),W=new Uint8Array(64),z=new Uint8Array(64),X,lt,pt=new Float64Array(64),ht=[e(),e(),e(),e()];Ar(S,c,32),S[0]&=248,S[31]&=127,S[31]|=64;var ae=v+64;for(X=0;X<v;X++)g[64+X]=b[X];for(X=0;X<32;X++)g[32+X]=S[32+X];for(Ar(z,g.subarray(32),v+32),f(z),Se(ht,z),rr(g,ht),X=32;X<64;X++)g[X]=c[X];for(Ar(W,g,v+64),f(W),X=0;X<64;X++)pt[X]=0;for(X=0;X<32;X++)pt[X]=z[X];for(X=0;X<32;X++)for(lt=0;lt<32;lt++)pt[X+lt]+=W[X]*S[lt];return w(g.subarray(32),pt),ae}function B(g,b){var v=e(),c=e(),S=e(),W=e(),z=e(),X=e(),lt=e();return m(g[2],a),h(g[1],b),ct(S,g[1]),H(W,S,y),at(S,S,g[2]),A(W,g[2],W),ct(z,W),ct(X,z),H(lt,X,z),H(v,lt,S),H(v,v,W),Mt(v,v),H(v,v,S),H(v,v,W),H(v,v,W),H(g[0],v,W),ct(c,g[0]),H(c,c,W),U(c,S)&&H(g[0],g[0],C),ct(c,g[0]),H(c,c,W),U(c,S)?-1:(k(g[0])===b[31]>>7&&at(g[0],o,g[0]),H(g[3],g[0],g[1]),0)}function F(g,b,v,c){var S,W=new Uint8Array(32),z=new Uint8Array(64),X=[e(),e(),e(),e()],lt=[e(),e(),e(),e()];if(v<64||B(lt,c))return-1;for(S=0;S<v;S++)g[S]=b[S];for(S=0;S<32;S++)g[S+32]=c[S];if(Ar(z,g,v),f(z),ke(X,lt,z),Se(lt,b.subarray(32)),Ie(X,lt),rr(W,X),v-=64,K(b,0,W,0)){for(S=0;S<v;S++)g[S]=0;return-1}for(S=0;S<v;S++)g[S]=b[S+64];return v}var $=32,Z=24,Ht=32,zt=16,Nt=32,Re=32,Lt=32,ze=32,ri=32,je=Z,Ze=Ht,as=zt,Te=64,Le=32,cn=64,De=32,$e=64;t.lowlevel={crypto_core_hsalsa20:J,crypto_stream_xor:jt,crypto_stream:ue,crypto_stream_salsa20_xor:tt,crypto_stream_salsa20:rt,crypto_onetimeauth:ce,crypto_onetimeauth_verify:T,crypto_verify_16:O,crypto_verify_32:K,crypto_secretbox:u,crypto_secretbox_open:p,crypto_scalarmult:Pt,crypto_scalarmult_base:Ce,crypto_box_beforenm:Gt,crypto_box_afternm:le,crypto_box:ve,crypto_box_open:Or,crypto_box_keypair:Yt,crypto_hash:Ar,crypto_sign:d,crypto_sign_keypair:fr,crypto_sign_open:F,crypto_secretbox_KEYBYTES:$,crypto_secretbox_NONCEBYTES:Z,crypto_secretbox_ZEROBYTES:Ht,crypto_secretbox_BOXZEROBYTES:zt,crypto_scalarmult_BYTES:Nt,crypto_scalarmult_SCALARBYTES:Re,crypto_box_PUBLICKEYBYTES:Lt,crypto_box_SECRETKEYBYTES:ze,crypto_box_BEFORENMBYTES:ri,crypto_box_NONCEBYTES:je,crypto_box_ZEROBYTES:Ze,crypto_box_BOXZEROBYTES:as,crypto_sign_BYTES:Te,crypto_sign_PUBLICKEYBYTES:Le,crypto_sign_SECRETKEYBYTES:cn,crypto_sign_SEEDBYTES:De,crypto_hash_BYTES:$e,gf:e,D:y,L:Be,pack25519:I,unpack25519:h,M:H,A,S:ct,Z:at,pow2523:Mt,add:Ie,set25519:m,modL:w,scalarmult:ke,scalarbase:Se};function vi(g,b){if(g.length!==$)throw new Error("bad key size");if(b.length!==Z)throw new Error("bad nonce size")}function Je(g,b){if(g.length!==Lt)throw new Error("bad public key size");if(b.length!==ze)throw new Error("bad secret key size")}function he(){for(var g=0;g<arguments.length;g++)if(!(arguments[g]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ki(g){for(var b=0;b<g.length;b++)g[b]=0}t.randomBytes=function(g){var b=new Uint8Array(g);return r(b,g),b},t.secretbox=function(g,b,v){he(g,b,v),vi(v,b);for(var c=new Uint8Array(Ht+g.length),S=new Uint8Array(c.length),W=0;W<g.length;W++)c[W+Ht]=g[W];return u(S,c,c.length,b,v),S.subarray(zt)},t.secretbox.open=function(g,b,v){he(g,b,v),vi(v,b);for(var c=new Uint8Array(zt+g.length),S=new Uint8Array(c.length),W=0;W<g.length;W++)c[W+zt]=g[W];return c.length<32||p(S,c,c.length,b,v)!==0?null:S.subarray(Ht)},t.secretbox.keyLength=$,t.secretbox.nonceLength=Z,t.secretbox.overheadLength=zt,t.scalarMult=function(g,b){if(he(g,b),g.length!==Re)throw new Error("bad n size");if(b.length!==Nt)throw new Error("bad p size");var v=new Uint8Array(Nt);return Pt(v,g,b),v},t.scalarMult.base=function(g){if(he(g),g.length!==Re)throw new Error("bad n size");var b=new Uint8Array(Nt);return Ce(b,g),b},t.scalarMult.scalarLength=Re,t.scalarMult.groupElementLength=Nt,t.box=function(g,b,v,c){var S=t.box.before(v,c);return t.secretbox(g,b,S)},t.box.before=function(g,b){he(g,b),Je(g,b);var v=new Uint8Array(ri);return Gt(v,g,b),v},t.box.after=t.secretbox,t.box.open=function(g,b,v,c){var S=t.box.before(v,c);return t.secretbox.open(g,b,S)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var g=new Uint8Array(Lt),b=new Uint8Array(ze);return Yt(g,b),{publicKey:g,secretKey:b}},t.box.keyPair.fromSecretKey=function(g){if(he(g),g.length!==ze)throw new Error("bad secret key size");var b=new Uint8Array(Lt);return Ce(b,g),{publicKey:b,secretKey:new Uint8Array(g)}},t.box.publicKeyLength=Lt,t.box.secretKeyLength=ze,t.box.sharedKeyLength=ri,t.box.nonceLength=je,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(g,b){if(he(g,b),b.length!==cn)throw new Error("bad secret key size");var v=new Uint8Array(Te+g.length);return d(v,g,g.length,b),v},t.sign.open=function(g,b){if(he(g,b),b.length!==Le)throw new Error("bad public key size");var v=new Uint8Array(g.length),c=F(v,g,g.length,b);if(c<0)return null;for(var S=new Uint8Array(c),W=0;W<S.length;W++)S[W]=v[W];return S},t.sign.detached=function(g,b){for(var v=t.sign(g,b),c=new Uint8Array(Te),S=0;S<c.length;S++)c[S]=v[S];return c},t.sign.detached.verify=function(g,b,v){if(he(g,b,v),b.length!==Te)throw new Error("bad signature size");if(v.length!==Le)throw new Error("bad public key size");var c=new Uint8Array(Te+g.length),S=new Uint8Array(Te+g.length),W;for(W=0;W<Te;W++)c[W]=b[W];for(W=0;W<g.length;W++)c[W+Te]=g[W];return F(S,c,c.length,v)>=0},t.sign.keyPair=function(){var g=new Uint8Array(Le),b=new Uint8Array(cn);return fr(g,b),{publicKey:g,secretKey:b}},t.sign.keyPair.fromSecretKey=function(g){if(he(g),g.length!==cn)throw new Error("bad secret key size");for(var b=new Uint8Array(Le),v=0;v<b.length;v++)b[v]=g[32+v];return{publicKey:b,secretKey:new Uint8Array(g)}},t.sign.keyPair.fromSeed=function(g){if(he(g),g.length!==De)throw new Error("bad seed size");for(var b=new Uint8Array(Le),v=new Uint8Array(cn),c=0;c<32;c++)v[c]=g[c];return fr(b,v,!0),{publicKey:b,secretKey:v}},t.sign.publicKeyLength=Le,t.sign.secretKeyLength=cn,t.sign.seedLength=De,t.sign.signatureLength=Te,t.hash=function(g){he(g);var b=new Uint8Array($e);return Ar(b,g,g.length),b},t.hash.hashLength=$e,t.verify=function(g,b){return he(g,b),g.length===0||b.length===0||g.length!==b.length?!1:M(g,0,b,0,g.length)===0},t.setPRNG=function(g){r=g},function(){var g=typeof self<"u"?self.crypto||self.msCrypto:null;if(g&&g.getRandomValues){var b=65536;t.setPRNG(function(v,c){var S,W=new Uint8Array(c);for(S=0;S<c;S+=b)g.getRandomValues(W.subarray(S,S+Math.min(c-S,b)));for(S=0;S<c;S++)v[S]=W[S];ki(W)})}else typeof rd<"u"&&(g=ra,g&&g.randomBytes&&t.setPRNG(function(v,c){var S,W=g.randomBytes(c);for(S=0;S<c;S++)v[S]=W[S];ki(W)}))}()})(n.exports?n.exports:self.nacl=self.nacl||{})})(qc);var nd=qc.exports;class en{constructor(t){nr(this,"env");nr(this,"url");this.env=t??"prod",this.env==="prod"?this.url="https://api.coinflow.cash":this.env==="local"?this.url="http://localhost:5000":this.url=`https://api-${this.env}.coinflow.cash`}async getNSurePartnerId(t){return fetch(this.url+`/merchant/view/${t}`).then(e=>e.json()).then(e=>{var r;return((r=e.nSureSettings)==null?void 0:r.nSurePartnerId)||e.nSurePartnerId}).catch(e=>{console.error(e)})}async getCreditBalance(t,e,r){const s=await fetch(this.url+`/api/customer/balances/${e}`,{method:"GET",headers:{"x-coinflow-auth-wallet":t,"x-coinflow-auth-blockchain":r}}),{credits:i}=await s.json();return i}static getCoinflowBaseUrl(t){return!t||t==="prod"?"https://coinflow.cash":t==="local"?"http://localhost:3000":`https://${t}.coinflow.cash`}static getCoinflowApiUrl(t){return!t||t==="prod"?"https://api.coinflow.cash":t==="local"?"http://localhost:5000":`https://api-${t}.coinflow.cash`}static getCoinflowUrl({walletPubkey:t,sessionKey:e,route:r,routePrefix:s,env:i,amount:o,transaction:a,blockchain:l="solana",webhookInfo:y,email:x,loaderBackground:E,handleHeightChange:L,bankAccountLinkRedirect:C,additionalWallets:N,nearDeposit:M,chargebackProtectionData:O,merchantCss:K,color:Q,rent:j,lockDefaultToken:it,token:J,tokens:D,planCode:tt,disableApplePay:rt,disableGooglePay:ue,customerInfo:jt,settlementType:kt,lockAmount:ce,nativeSolToConvert:T,theme:u,usePermit:p,transactionSigner:m,authOnly:R,deviceId:_,jwtToken:I,origins:U,threeDsChallengePreference:k,supportEmail:h,destinationAuthKey:A}){var ct;const at=s?`/${s}/${l}`:`/${l}`,H=new URL(at+r,en.getCoinflowBaseUrl(i));if(t&&H.searchParams.append("pubkey",t),e&&H.searchParams.append("sessionKey",e),a&&H.searchParams.append("transaction",a),o&&H.searchParams.append("amount",o.toString()),y&&H.searchParams.append("webhookInfo",$r.compressToEncodedURIComponent(JSON.stringify(y))),u&&H.searchParams.append("theme",$r.compressToEncodedURIComponent(JSON.stringify(u))),jt&&H.searchParams.append("customerInfo",$r.compressToEncodedURIComponent(JSON.stringify(jt))),x&&H.searchParams.append("email",x),h&&H.searchParams.append("supportEmail",h),J&&H.searchParams.append("token",J.toString()),D&&H.searchParams.append("tokens",D.toString()),E&&H.searchParams.append("loaderBackground",E),L&&H.searchParams.append("useHeightChange","true"),C&&H.searchParams.append("bankAccountLinkRedirect",C),N&&H.searchParams.append("additionalWallets",$r.compressToEncodedURIComponent(JSON.stringify(N))),M&&H.searchParams.append("nearDeposit",M),O&&H.searchParams.append("chargebackProtectionData",$r.compressToEncodedURIComponent(JSON.stringify(O))),_)H.searchParams.append("deviceId",_);else if(typeof window<"u"){const Tt=(ct=window==null?void 0:window.nSureSDK)==null?void 0:ct.getDeviceId();Tt&&H.searchParams.append("deviceId",Tt)}return K&&H.searchParams.append("merchantCss",K),Q&&H.searchParams.append("color",Q),j&&H.searchParams.append("rent",j.lamports.toString()),T&&H.searchParams.append("nativeSolToConvert",T.lamports.toString()),it&&H.searchParams.append("lockDefaultToken","true"),tt&&H.searchParams.append("planCode",tt),rt&&H.searchParams.append("disableApplePay","true"),ue&&H.searchParams.append("disableGooglePay","true"),kt&&H.searchParams.append("settlementType",kt),ce&&H.searchParams.append("lockAmount","true"),p===!1&&H.searchParams.append("usePermit","false"),m&&H.searchParams.append("transactionSigner",m),R===!0&&H.searchParams.append("authOnly","true"),I&&H.searchParams.append("jwtToken",I),U&&H.searchParams.append("origins",$r.compressToEncodedURIComponent(JSON.stringify(U))),k&&H.searchParams.append("threeDsChallengePreference",k),A&&H.searchParams.append("destinationAuthKey",A),H.toString()}static getTransaction(t){if(t.blockchain)return this.byBlockchain(t.blockchain,{solana:()=>{if(!("transaction"in t))return;const{transaction:e}=t;if(!rs)throw new Error("@solana/web3.js dependency is required for Solana");if(!Dr)throw new Error("bs58 dependency is required for Solana");if(e)return Dr.encode(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},eth:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},base:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},arbitrum:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},near:()=>{if(!("action"in t))return;const{action:e}=t;return $r.compressToEncodedURIComponent(JSON.stringify(e))},user:()=>{}})()}static byBlockchain(t,e){switch(t){case"solana":return e.solana;case"near":return e.near;case"polygon":return e.polygon;case"eth":return e.eth;case"base":return e.base;case"arbitrum":return e.arbitrum;case"user":return e.user;default:throw new Error("blockchain not supported!")}}static async getWalletFromUserId({userId:t,merchantId:e,env:r}){return this.getWalletFromEmail({email:t,merchantId:e,env:r})}static async getWalletFromEmail({email:t,merchantId:e,env:r}){const s=new TextEncoder().encode(t),o=await window.crypto.subtle.digest("SHA-256",s),a=new Uint8Array(o),l=Un.fromSeed(a);return{publicKey:l.publicKey,signMessage:y=>Promise.resolve(nd.sign.detached(y,l.secretKey)),signTransaction:async y=>y instanceof ye?(y.sign(l),y):(y.sign([l]),y),sendTransaction:async y=>{y instanceof ye?y.sign(l):y.sign([l]);const x=this.getCoinflowApiUrl(r),E={method:"POST",headers:{"content-type":"application/json","x-coinflow-auth-wallet":l.publicKey.toString(),"x-coinflow-auth-blockchain":"solana"},body:JSON.stringify({merchantId:e,signedTransaction:Dr==null?void 0:Dr.encode(y.serialize())})},{signature:L}=await fetch(x+"/api/utils/send-coinflow-tx",E).then(C=>C.json());return L}}}}var Hc=(n=>(n.SignMessage="signMessage",n.SignTransaction="signTransaction",n.SendTransaction="sendTransaction",n.HeightChange="heightChange",n.Success="success",n.Loaded="loaded",n))(Hc||{});function ns(n){let t;if("signer"in n&&typeof n.signer=="object"&&n.signer&&"wallet"in n.signer?t=n.signer.wallet:"wallet"in n&&n.wallet&&(t=n.wallet),!!t){if(typeof t=="string")return t;if(typeof t=="object"){if("publicKey"in t)return t.publicKey?t.publicKey.toString():void 0;if("address"in t)return t.address?t.address:void 0;if("accountId"in t)return t.accountId?t.accountId:void 0}return null}}function Vc(n,t){let e;try{if(e=JSON.parse(n),!("method"in e)||!("data"in e))return}catch(i){console.error("handleIFrameMessage JSON parse",i);return}const{data:r,method:s}=e;switch(s){case"signMessage":return t.handleSignMessage?t.handleSignMessage(r):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(r):void 0;case"sendTransaction":return t.handleSendTransaction(r);case"heightChange":return t.handleHeightChange?t.handleHeightChange(r):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(e.info);return;case"loaded":return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${s} is not one of ${Object.values(Hc)}`)}function is(n){let t,e;return"signer"in n&&typeof n.signer=="object"&&n.signer&&"blockchain"in n.signer&&"wallet"in n.signer?(t=n.signer.blockchain,e=n.signer.wallet):"blockchain"in n&&n.blockchain&&(t=n.blockchain,e=n.wallet),t?en.byBlockchain(t,{solana:()=>id({wallet:e,onSuccess:n.onSuccess}),near:()=>sd({wallet:e,onSuccess:n.onSuccess}),eth:()=>ss({wallet:e,onSuccess:n.onSuccess}),polygon:()=>ss({wallet:e,onSuccess:n.onSuccess}),base:()=>ss({wallet:e,onSuccess:n.onSuccess}),arbitrum:()=>ss({wallet:e,onSuccess:n.onSuccess}),user:()=>od(n)})():{handleSendTransaction:()=>{throw new Error("handleSendTransaction Not Implemented")},handleSignMessage:()=>{throw new Error("handleSendTransaction Not Implemented")},handleSignTransaction:()=>{throw new Error("handleSendTransaction Not Implemented")},onSuccess:n.onSuccess}}function id({wallet:n,onSuccess:t}){return{handleSendTransaction:async e=>{const r=jc(e);return await n.sendTransaction(r)},handleSignMessage:async e=>{const r=n.signMessage;if(!r)throw new Error("signMessage is not supported by this wallet");const s=await r(new TextEncoder().encode(e));if(!Dr)throw new Error("bs58 dependency is required");return Dr.encode(s)},handleSignTransaction:async e=>{const r=n.signTransaction;if(!r)throw new Error("signTransaction is not supported by this wallet");const s=jc(e),i=await r(s);if(!Dr)throw new Error("bs58 dependency is required");return Dr.encode(i.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t}}function jc(n){if(!rs)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!Dr)throw new Error("bs58 is not defined. Please install bs58 into your project");const t=Dr.decode(n),e=rs.VersionedTransaction.deserialize(t);return e.version==="legacy"?rs.Transaction.from(t):e}function sd({wallet:n,onSuccess:t}){return{handleSendTransaction:async e=>{const r=JSON.parse(Buffer.from(e,"base64").toString()),s=await n.signAndSendTransaction(r);if(!s)throw new Error("Transaction did not send");const{transaction:i}=s;return i.hash},onSuccess:t}}function ss({wallet:n,onSuccess:t}){return{handleSendTransaction:async e=>{const r=JSON.parse(Buffer.from(e,"base64").toString()),{hash:s}=await n.sendTransaction(r);return s},handleSignMessage:async e=>n.signMessage(e),onSuccess:t}}function od({onSuccess:n}){return{handleSendTransaction:async()=>Promise.resolve(""),onSuccess:n}}const xi="tokenExCardNumber",ei="tokenExCardCvv",Gc={[On.VISA]:"visa",[On.MASTERCARD]:"masterCard",[On.AMEX]:"americanExpress",[On.DISCOVER]:"discover"};async function Yc({token:n,origins:t,env:e}){return new Promise((r,s)=>{fetch(new en(e).url+"/api/checkout/authentication-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:[...t??[],window.location.origin],token:n})}).then(async i=>{r(await i.json())}).catch(i=>s(i))})}function Eo({env:n,setTokenExScriptLoaded:t}){const e="tokenex-script";if(document.head.querySelector(`#${e}`))return;const r=document.createElement("script");r.src=n==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",r.id=e,document.head.appendChild(r),document.getElementById(e).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),t(!0)})}function ad({iframe:n,setCachedToken:t,setLoaded:e}){const r=async()=>(n.tokenize(),await new Promise((s,i)=>{n.on("tokenize",o=>{t(o.token),s(o)}),n.on("validate",o=>{(!o.isValid||o.isCvvValid===!1)&&i(o)})}));return n.on("change",()=>t(void 0)),n.on("cvvChange",()=>t(void 0)),n.on("load",()=>{setTimeout(()=>e(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),n.on("focus",()=>{n.focus()}),n.on("cvvFocus",()=>{n.cvvFocus()}),e(!1),n.load(),{...n,tokenize:r}}async function Zc(n){const{token:t,cardType:e}=n;return await _o(ei,n,{cvvOnly:!0,cvv:!0,cvvContainerID:ei,placeholder:"CVV",token:t,cardType:Gc[e]})}async function Jc(n){return await _o(xi,n,{cvv:!0,cvvContainerID:ei,cvvPlaceholder:"CVV"})}async function Xc(n){return await _o(xi,n,{cvv:!1})}async function _o(n,{tokenExScriptLoaded:t,origins:e,env:r,css:s,debug:i,font:o,setCachedToken:a,setLoaded:l},y){if(!t&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const x=await Yc({token:y.token,origins:e,env:r}),{styles:E}=cd(s),L={...x,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:E,font:o,debug:i??!1,...y},C=TokenEx.Iframe(n,L);return ad({iframe:C,setCachedToken:a,setLoaded:l})}function cd(n){var r,s,i;const t=JSON.parse(n);return{styles:{base:mn(t.base),focus:mn(t.focus),error:mn(t.error),placeholder:mn(t.placeholder),cvv:{base:mn((r=t.cvv)==null?void 0:r.base),focus:mn((s=t.cvv)==null?void 0:s.focus),error:mn((i=t.cvv)==null?void 0:i.error),placeholder:mn(t==null?void 0:t.placeholder)}}}}function mn(n){if(!n)return"";if(typeof n=="string")return n;let t="";for(const[e,r]of Object.entries(n)){let s="";e.split("").forEach(i=>{i.toUpperCase()===i?s+="-"+i.toLowerCase():s+=i}),t+=s+":"+r+";"}return t}const ud=ft.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return en.getCoinflowUrl(this.args)}},emits:{onMessage(n){return!0}},methods:{sendMessage(n){const t=this.$refs.iframeRef;if(!(t!=null&&t.contentWindow))throw new Error("Iframe not defined");t.contentWindow.postMessage(n,"*")},handleIframeMessages({data:n,origin:t}){if(!t.includes(en.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:n,origin:t});const e=Vc(n,this.args);e&&e.then(this.sendMessage).catch(r=>{console.error(r),this.sendMessage("ERROR "+r.message)})},async listenForMessage(n){let t;return new Promise((e,r)=>{if(t=({data:s,origin:i})=>{if(i.includes(en.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){r(new Error(s.replace("ERROR","")));return}n(s)&&e(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",t)}).finally(()=>{window.removeEventListener("message",t)})},async sendAndReceiveMessage(n,t){return this.sendMessage(n),this.listenForMessage(t)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Io=(n,t)=>{const e=n.__vccOpts||n;for(const[r,s]of t)e[r]=s;return e},fd=["src","scrolling"];function ld(n,t,e,r,s,i){return ft.openBlock(),ft.createElementBlock("iframe",{style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera",title:"withdraw",frameBorder:"0",src:n.url,scrolling:n.args.handleHeightChange?"no":"yes",onLoad:t[0]||(t[0]=()=>{const o=n.$refs.iframeRef;o&&(o.style.opacity="1")})},null,40,fd)}const os=Io(ud,[["render",ld]]),hd=ft.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:os},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const n=ns(this.args);return{...this.args,walletPubkey:n,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...is(this.args),handleHeightChange:this.args.handleHeightChange}}}});function dd(n,t,e,r,s,i){const o=ft.resolveComponent("coinflow-i-frame");return ft.openBlock(),ft.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers}},null,8,["args"])}const pd=Io(hd,[["render",dd]]),gd=ft.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:os},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const n=ns(this.args);return{...this.args,walletPubkey:n,route:`/purchase-v2/${this.args.merchantId}`,transaction:en.getTransaction(this.args)}},messageHandlers(){return{...is(this.args),handleHeightChange:this.args.handleHeightChange}}}});function yd(n,t,e,r,s,i){const o=ft.resolveComponent("coinflow-i-frame");return ft.openBlock(),ft.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers}},null,8,["args"])}const md=Io(gd,[["render",yd]]),Ao=n=>{const t=ft.ref(!1),e=ft.ref(!1),r=ft.ref(void 0),s=ft.ref(void 0);ft.onMounted(()=>{Eo({env:n,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),e.value=!0}})});const i=E=>s.value=E,o=()=>t.value=!0,a=E=>r.value=E,l=async E=>{const L=await Zc({...E,tokenExScriptLoaded:e.value,env:n,setCachedToken:i,setLoaded:o});return a(L),L},y=async E=>{const L=await Jc({...E,tokenExScriptLoaded:e.value,env:n,setCachedToken:i,setLoaded:o});return a(L),L},x=async E=>{const L=await Xc({...E,tokenExScriptLoaded:e.value,env:n,setCachedToken:i,setLoaded:o});return a(L),L};return ft.watchEffect(E=>{r.value&&(r.value.load(),E(()=>{var L;return(L=r.value)==null?void 0:L.remove()}))}),{tokenExIframe:r,initializeTokenExIframe:y,initializeCvvOnlyTokenExIframe:l,initializeTokenExCardOnlyIframe:x,loaded:t,cachedToken:s,setTokenExScriptTag:Eo,tokenExScriptLoaded:e}},wd=["id"],bd=ft.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{initializeTokenExIframe:e,tokenExIframe:r}=Ao(n.args.env);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return ft.watchEffect(()=>{e({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(xi)},null,8,wd))}}),xd=["id"],vd=ft.defineComponent({__name:"CoinflowCvvInput",setup(n){return(t,e)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(ei)},null,8,xd))}}),kd=["id"],Sd=ft.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{initializeCvvOnlyTokenExIframe:e,tokenExIframe:r}=Ao(n.args.env);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return ft.watchEffect(()=>{e({...n.args,origins:n.args.origins??[],css:i(),font:n.args.font})},{}),(o,a)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(ei)},null,8,kd))}}),Ed=ft.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(n){const t=ft.ref(void 0);ft.onMounted(()=>new en(n.args.env).getNSurePartnerId(n.args.merchantId).then(s=>t.value=s));function e(){return n.args.env==="prod"?"9JBW2RHC7JNJN8ZQ":"SANDBOX_CTCE4XK53ZW0R7V1"}function r(){return n.args.env==="prod"?"https://sdk.nsureapi.com/sdk.js":"https://sdk.nsureapi.com/sdk-sandbox.js"}return ft.watchEffect(s=>{if(!t.value)return;const i=document.createElement("script");i.src=r(),document.head.appendChild(i);const o=`window.nSureAsyncInit = function(deviceId) {
12
+ `+i+o;break;default:a=`Unknown action '${(h=>h)(t)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=r,this.transactionLogs=s||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(s=>{if(s&&s.meta&&s.meta.logMessages){const i=s.meta.logMessages;this.transactionLogs=i,e(i)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const wl={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 ut extends Error{constructor({code:t,message:e,data:r},s){super(s!=null?`${s}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=r,this.name="SolanaJSONRPCError"}}async function Ai(n,t,e,r){const s=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},i=await n.sendTransaction(t,e,s);let o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,signature:i,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){const{nonceInstruction:a}=t.nonceInfo,h=a.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:h,nonceValue:t.nonceInfo.nonce,signature:i},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(i,r&&r.commitment)).value;if(o.err)throw i!=null?new Zr({action:"send",signature:i,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${i} failed (${JSON.stringify(o)})`);return i}function gr(n){return new Promise(t=>setTimeout(t,n))}function It(n,t){const e=n.layout.span>=0?n.layout.span:Oo(n,t),r=lt.Buffer.alloc(e),s=Object.assign({instruction:n.index},t);return n.layout.encode(s,r),r}function Rt(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 Fo=P.nu64("lamportsPerSignature"),zo=P.struct([P.u32("version"),P.u32("state"),xt("authorizedPubkey"),xt("nonce"),P.struct([Fo],"feeCalculator")]),Ri=zo.span;class En{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=zo.decode(mt(t),0);return new En({authorizedPubkey:new it(e.authorizedPubkey),nonce:new it(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const bl=n=>{const t=n.decode.bind(n),e=n.encode.bind(n);return{decode:t,encode:e}},Tr=(n=>t=>{const e=P.blob(n,t),{encode:r,decode:s}=bl(e),i=e;return i.decode=(o,a)=>{const h=s(o,a);return oi.toBigIntLE(lt.Buffer.from(h))},i.encode=(o,a,h)=>{const g=oi.toBufferLE(o,n);return r(g,a,h)},i})(8);class kl{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=P.u32("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(Ut))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:r,programId:s}=Rt(Ut.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:r,programId:new it(s)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Rt(Ut.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:s}=Rt(Ut.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 it(s)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Rt(Ut.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:s,programId:i}=Rt(Ut.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new it(e),seed:r,space:s,programId:new it(i)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Rt(Ut.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new it(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,programId:s}=Rt(Ut.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new it(e),seed:r,programId:new it(s)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:r,lamports:s,space:i,programId:o}=Rt(Ut.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new it(e),seed:r,lamports:s,space:i,programId:new it(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Rt(Ut.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new it(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Rt(Ut.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}=Rt(Ut.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}=Rt(Ut.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new it(e)}}static checkProgramId(t){if(!t.equals(ye.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 Ut=Object.freeze({Create:{index:0,layout:P.struct([P.u32("instruction"),P.ns64("lamports"),P.ns64("space"),xt("programId")])},Assign:{index:1,layout:P.struct([P.u32("instruction"),xt("programId")])},Transfer:{index:2,layout:P.struct([P.u32("instruction"),Tr("lamports")])},CreateWithSeed:{index:3,layout:P.struct([P.u32("instruction"),xt("base"),dr("seed"),P.ns64("lamports"),P.ns64("space"),xt("programId")])},AdvanceNonceAccount:{index:4,layout:P.struct([P.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:P.struct([P.u32("instruction"),P.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:P.struct([P.u32("instruction"),xt("authorized")])},AuthorizeNonceAccount:{index:7,layout:P.struct([P.u32("instruction"),xt("authorized")])},Allocate:{index:8,layout:P.struct([P.u32("instruction"),P.ns64("space")])},AllocateWithSeed:{index:9,layout:P.struct([P.u32("instruction"),xt("base"),dr("seed"),P.ns64("space"),xt("programId")])},AssignWithSeed:{index:10,layout:P.struct([P.u32("instruction"),xt("base"),dr("seed"),xt("programId")])},TransferWithSeed:{index:11,layout:P.struct([P.u32("instruction"),Tr("lamports"),dr("seed"),xt("programId")])},UpgradeNonceAccount:{index:12,layout:P.struct([P.u32("instruction")])}});class ye{constructor(){}static createAccount(t){const e=Ut.Create,r=It(e,{lamports:t.lamports,space:t.space,programId:mt(t.programId.toBuffer())});return new Pt({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 s=Ut.TransferWithSeed;e=It(s,{lamports:BigInt(t.lamports),seed:t.seed,programId:mt(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 s=Ut.Transfer;e=It(s,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Pt({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;if("basePubkey"in t){const s=Ut.AssignWithSeed;e=It(s,{base:mt(t.basePubkey.toBuffer()),seed:t.seed,programId:mt(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Ut.Assign;e=It(s,{programId:mt(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Pt({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=Ut.CreateWithSeed,r=It(e,{base:mt(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:mt(t.programId.toBuffer())});let s=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||s.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Pt({keys:s,programId:this.programId,data:r})}static createNonceAccount(t){const e=new Bt;"basePubkey"in t&&"seed"in t?e.add(ye.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:Ri,programId:this.programId})):e.add(ye.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:Ri,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=Ut.InitializeNonceAccount,r=It(e,{authorized:mt(t.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:xn,isSigner:!1,isWritable:!1},{pubkey:Rr,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Pt(s)}static nonceAdvance(t){const e=Ut.AdvanceNonceAccount,r=It(e),s={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:xn,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Pt(s)}static nonceWithdraw(t){const e=Ut.WithdrawNonceAccount,r=It(e,{lamports:t.lamports});return new Pt({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:xn,isSigner:!1,isWritable:!1},{pubkey:Rr,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(t){const e=Ut.AuthorizeNonceAccount,r=It(e,{authorized:mt(t.newAuthorizedPubkey.toBuffer())});return new Pt({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 s=Ut.AllocateWithSeed;e=It(s,{base:mt(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:mt(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Ut.Allocate;e=It(s,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Pt({keys:r,programId:this.programId,data:e})}}ye.programId=new it("11111111111111111111111111111111");const vl=er-300;class yr{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/yr.chunkSize)+1+1)}static async load(t,e,r,s,i){{const k=await t.getMinimumBalanceForRentExemption(i.length),M=await t.getAccountInfo(r.publicKey,"confirmed");let R=null;if(M!==null){if(M.executable)return console.error("Program load failed, account is already executable"),!1;M.data.length!==i.length&&(R=R||new Bt,R.add(ye.allocate({accountPubkey:r.publicKey,space:i.length}))),M.owner.equals(s)||(R=R||new Bt,R.add(ye.assign({accountPubkey:r.publicKey,programId:s}))),M.lamports<k&&(R=R||new Bt,R.add(ye.transfer({fromPubkey:e.publicKey,toPubkey:r.publicKey,lamports:k-M.lamports})))}else R=new Bt().add(ye.createAccount({fromPubkey:e.publicKey,newAccountPubkey:r.publicKey,lamports:k>0?k:1,space:i.length,programId:s}));R!==null&&await Ai(t,R,[e,r],{commitment:"confirmed"})}const o=P.struct([P.u32("instruction"),P.u32("offset"),P.u32("bytesLength"),P.u32("bytesLengthPadding"),P.seq(P.u8("byte"),P.offset(P.u32(),-8),"bytes")]),a=yr.chunkSize;let h=0,g=i,w=[];for(;g.length>0;){const k=g.slice(0,a),M=lt.Buffer.alloc(a+16);o.encode({instruction:0,offset:h,bytes:k,bytesLength:0,bytesLengthPadding:0},M);const R=new Bt().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:M});w.push(Ai(t,R,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await gr(1e3/4),h+=a,g=g.slice(a)}await Promise.all(w);{const k=P.struct([P.u32("instruction")]),M=lt.Buffer.alloc(k.span);k.encode({instruction:1},M);const R=new Bt().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:Rr,isSigner:!1,isWritable:!1}],programId:s,data:M}),C="processed",B=await t.sendTransaction(R,[e,r],{preflightCommitment:C}),{context:T,value:O}=await t.confirmTransaction({signature:B,lastValidBlockHeight:R.lastValidBlockHeight,blockhash:R.recentBlockhash},C);if(O.err)throw new Error(`Transaction ${B} failed (${JSON.stringify(O)})`);for(;;){try{if(await t.getSlot({commitment:C})>T.slot)break}catch{}await new Promise($=>setTimeout($,Math.round(No/2)))}}return!0}}yr.chunkSize=vl;const Sl=new it("BPFLoader2111111111111111111111111111111111");class xl{static getMinNumSignatures(t){return yr.getMinNumSignatures(t)}static load(t,e,r,s,i){return yr.load(t,e,r,i,s)}}function Il(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ti,qo;function El(){if(qo)return Ti;qo=1;var n=Object.prototype.toString,t=Object.keys||function(r){var s=[];for(var i in r)s.push(i);return s};function e(r,s){var i,o,a,h,g,w,k;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(),s);if(k=n.call(r),k==="[object Array]"){for(a="[",o=r.length-1,i=0;i<o;i++)a+=e(r[i],!0)+",";return o>-1&&(a+=e(r[i],!0)),a+"]"}else if(k==="[object Object]"){for(h=t(r).sort(),o=h.length,a="",i=0;i<o;)g=h[i],w=e(r[g],!1),w!==void 0&&(a&&(a+=","),a+=JSON.stringify(g)+":"+w),i++;return"{"+a+"}"}else return JSON.stringify(r);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return Ti=function(r){var s=e(r,!1);if(s!==void 0)return""+s},Ti}var _l=El(),Ko=Il(_l);const Yr=32;function Mi(n){let t=0;for(;n>1;)n/=2,t++;return t}function Bl(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 Wo{constructor(t,e,r,s,i){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=s,this.firstNormalSlot=i}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=Mi(Bl(t+Yr+1))-Mi(Yr)-1,r=this.getSlotsInEpoch(e),s=t-(r-Yr);return[e,s]}else{const e=t-this.firstNormalSlot,r=Math.floor(e/this.slotsPerEpoch),s=this.firstNormalEpoch+r,i=e%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*Yr:(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+Mi(Yr)):this.slotsPerEpoch}}var Al=globalThis.fetch;class Rl extends Uu{constructor(t,e,r){const s=i=>{const o=Lu(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,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 Tl(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 Do=56;class Pi{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=Tl(Ml,t),r=t.length-Do;Et(r>=0,"lookup table is invalid"),Et(r%32===0,"lookup table is invalid");const s=r/32,{addresses:i}=P.struct([P.seq(xt(),s,"addresses")]).decode(t.slice(Do));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new it(e.authority[0]):void 0,addresses:i.map(o=>new it(o))}}}const Ml={index:1,layout:P.struct([P.u32("typeIndex"),Tr("deactivationSlot"),P.nu64("lastExtendedSlot"),P.u8("lastExtendedStartIndex"),P.u8(),P.seq(xt(),P.offset(P.u8(),-1),"authority")])},Pl=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function Cl(n){const t=n.match(Pl);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[e,r,s,i]=t,o=n.startsWith("https:")?"wss:":"ws:",a=s==null?null:parseInt(s.slice(1),10),h=a==null?"":`:${a+1}`;return`${o}//${r}${h}${i}`}const Vt=$r(ci(it),rt(),n=>new it(n)),$o=ui([rt(),Ht("base64")]),Ci=$r(ci(lt.Buffer),$o,n=>lt.Buffer.from(n[0],"base64")),Ho=30*1e3;function Ll(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function Nt(n){let t,e;if(typeof n=="string")t=n;else if(n){const{commitment:r,...s}=n;t=r,e=s}return{commitment:t,config:e}}function Vo(n){return n.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function jo(n){return Ie([tt({jsonrpc:Ht("2.0"),id:rt(),result:n}),tt({jsonrpc:Ht("2.0"),id:rt(),error:tt({code:Br(),message:rt(),data:ft(au())})})])}const Ol=jo(Br());function wt(n){return $r(jo(n),Ol,t=>"error"in t?t:{...t,result:st(t.result,n)})}function Gt(n){return wt(tt({context:tt({slot:W()}),value:n}))}function _n(n){return tt({context:tt({slot:W()}),value:n})}function Li(n,t){return n===0?new pr({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new it(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:ge.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Ce(t)}const Ul=tt({foundation:W(),foundationTerm:W(),initial:W(),taper:W(),terminal:W()}),Nl=wt(ot(at(tt({epoch:W(),effectiveSlot:W(),amount:W(),postBalance:W(),commission:ft(at(W()))})))),Fl=ot(tt({slot:W(),prioritizationFee:W()})),zl=tt({total:W(),validator:W(),foundation:W(),epoch:W()}),ql=tt({epoch:W(),slotIndex:W(),slotsInEpoch:W(),absoluteSlot:W(),blockHeight:ft(W()),transactionCount:ft(W())}),Kl=tt({slotsPerEpoch:W(),leaderScheduleSlotOffset:W(),warmup:Ne(),firstNormalEpoch:W(),firstNormalSlot:W()}),Wl=oo(rt(),ot(W())),mr=at(Ie([tt({}),rt()])),Dl=tt({err:mr}),$l=Ht("receivedSignature"),Hl=tt({"solana-core":rt(),"feature-set":ft(W())}),Vl=tt({program:rt(),programId:Vt,parsed:Br()}),jl=tt({programId:Vt,accounts:ot(Vt),data:rt()}),Go=Gt(tt({err:at(Ie([tt({}),rt()])),logs:at(ot(rt())),accounts:ft(at(ot(at(tt({executable:Ne(),owner:rt(),lamports:W(),data:ot(rt()),rentEpoch:ft(W())}))))),unitsConsumed:ft(W()),returnData:ft(at(tt({programId:rt(),data:ui([rt(),Ht("base64")])}))),innerInstructions:ft(at(ot(tt({index:W(),instructions:ot(Ie([Vl,jl]))}))))})),Gl=Gt(tt({byIdentity:oo(rt(),ot(W())),range:tt({firstSlot:W(),lastSlot:W()})}));function Zl(n,t,e,r,s,i){const o=e||Al;let a;i!=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 h;return r&&(h=async(w,k)=>{const M=await new Promise((R,C)=>{try{r(w,k,(B,T)=>R([B,T]))}catch(B){C(B)}});return await o(...M)}),new Tu(async(w,k)=>{const M={method:"POST",body:w,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},Jf)};try{let R=5,C,B=500;for(;h?C=await h(n,M):C=await o(n,M),!(C.status!==429||s===!0||(R-=1,R===0));)console.error(`Server responded with ${C.status} ${C.statusText}. Retrying after ${B}ms delay...`),await gr(B),B*=2;const T=await C.text();C.ok?k(null,T):k(new Error(`${C.status} ${C.statusText}: ${T}`))}catch(R){R instanceof Error&&k(R)}},{})}function Yl(n){return(t,e)=>new Promise((r,s)=>{n.request(t,e,(i,o)=>{if(i){s(i);return}r(o)})})}function Jl(n){return t=>new Promise((e,r)=>{t.length===0&&e([]);const s=t.map(i=>n.request(i.methodName,i.args));n.request(s,(i,o)=>{if(i){r(i);return}e(o)})})}const Xl=wt(Ul),Ql=wt(zl),tf=wt(Fl),ef=wt(ql),rf=wt(Kl),nf=wt(Wl),sf=wt(W()),of=Gt(tt({total:W(),circulating:W(),nonCirculating:W(),nonCirculatingAccounts:ot(Vt)})),Oi=tt({amount:rt(),uiAmount:at(W()),decimals:W(),uiAmountString:ft(rt())}),af=Gt(ot(tt({address:Vt,amount:rt(),uiAmount:at(W()),decimals:W(),uiAmountString:ft(rt())}))),cf=Gt(ot(tt({pubkey:Vt,account:tt({executable:Ne(),owner:Vt,lamports:W(),data:Ci,rentEpoch:W()})}))),Ui=tt({program:rt(),parsed:Br(),space:W()}),uf=Gt(ot(tt({pubkey:Vt,account:tt({executable:Ne(),owner:Vt,lamports:W(),data:Ui,rentEpoch:W()})}))),lf=Gt(ot(tt({lamports:W(),address:Vt}))),Jr=tt({executable:Ne(),owner:Vt,lamports:W(),data:Ci,rentEpoch:W()}),ff=tt({pubkey:Vt,account:Jr}),hf=$r(Ie([ci(lt.Buffer),Ui]),Ie([$o,Ui]),n=>Array.isArray(n)?st(n,Ci):n),Ni=tt({executable:Ne(),owner:Vt,lamports:W(),data:hf,rentEpoch:W()}),df=tt({pubkey:Vt,account:Ni}),pf=tt({state:Ie([Ht("active"),Ht("inactive"),Ht("activating"),Ht("deactivating")]),active:W(),inactive:W()}),gf=wt(ot(tt({signature:rt(),slot:W(),err:mr,memo:at(rt()),blockTime:ft(at(W()))}))),yf=wt(ot(tt({signature:rt(),slot:W(),err:mr,memo:at(rt()),blockTime:ft(at(W()))}))),mf=tt({subscription:W(),result:_n(Jr)}),wf=tt({pubkey:Vt,account:Jr}),bf=tt({subscription:W(),result:_n(wf)}),kf=tt({parent:W(),slot:W(),root:W()}),vf=tt({subscription:W(),result:kf}),Sf=Ie([tt({type:Ie([Ht("firstShredReceived"),Ht("completed"),Ht("optimisticConfirmation"),Ht("root")]),slot:W(),timestamp:W()}),tt({type:Ht("createdBank"),parent:W(),slot:W(),timestamp:W()}),tt({type:Ht("frozen"),slot:W(),timestamp:W(),stats:tt({numTransactionEntries:W(),numSuccessfulTransactions:W(),numFailedTransactions:W(),maxTransactionsPerEntry:W()})}),tt({type:Ht("dead"),slot:W(),timestamp:W(),err:rt()})]),xf=tt({subscription:W(),result:Sf}),If=tt({subscription:W(),result:_n(Ie([Dl,$l]))}),Ef=tt({subscription:W(),result:W()}),_f=tt({pubkey:rt(),gossip:at(rt()),tpu:at(rt()),rpc:at(rt()),version:at(rt())}),Zo=tt({votePubkey:rt(),nodePubkey:rt(),activatedStake:W(),epochVoteAccount:Ne(),epochCredits:ot(ui([W(),W(),W()])),commission:W(),lastVote:W(),rootSlot:at(W())}),Bf=wt(tt({current:ot(Zo),delinquent:ot(Zo)})),Af=Ie([Ht("processed"),Ht("confirmed"),Ht("finalized")]),Rf=tt({slot:W(),confirmations:at(W()),err:mr,confirmationStatus:ft(Af)}),Tf=Gt(ot(at(Rf))),Mf=wt(W()),Yo=tt({accountKey:Vt,writableIndexes:ot(W()),readonlyIndexes:ot(W())}),Fi=tt({signatures:ot(rt()),message:tt({accountKeys:ot(rt()),header:tt({numRequiredSignatures:W(),numReadonlySignedAccounts:W(),numReadonlyUnsignedAccounts:W()}),instructions:ot(tt({accounts:ot(W()),data:rt(),programIdIndex:W()})),recentBlockhash:rt(),addressTableLookups:ft(ot(Yo))})}),Jo=tt({pubkey:Vt,signer:Ne(),writable:Ne(),source:ft(Ie([Ht("transaction"),Ht("lookupTable")]))}),Xo=tt({accountKeys:ot(Jo),signatures:ot(rt())}),Qo=tt({parsed:Br(),program:rt(),programId:Vt}),ta=tt({accounts:ot(Vt),data:rt(),programId:Vt}),Pf=Ie([ta,Qo]),Cf=Ie([tt({parsed:Br(),program:rt(),programId:rt()}),tt({accounts:ot(rt()),data:rt(),programId:rt()})]),ea=$r(Pf,Cf,n=>"accounts"in n?st(n,ta):st(n,Qo)),ra=tt({signatures:ot(rt()),message:tt({accountKeys:ot(Jo),instructions:ot(ea),recentBlockhash:rt(),addressTableLookups:ft(at(ot(Yo)))})}),Bn=tt({accountIndex:W(),mint:rt(),owner:ft(rt()),uiTokenAmount:Oi}),na=tt({writable:ot(Vt),readonly:ot(Vt)}),An=tt({err:mr,fee:W(),innerInstructions:ft(at(ot(tt({index:W(),instructions:ot(tt({accounts:ot(W()),data:rt(),programIdIndex:W()}))})))),preBalances:ot(W()),postBalances:ot(W()),logMessages:ft(at(ot(rt()))),preTokenBalances:ft(at(ot(Bn))),postTokenBalances:ft(at(ot(Bn))),loadedAddresses:ft(na),computeUnitsConsumed:ft(W())}),zi=tt({err:mr,fee:W(),innerInstructions:ft(at(ot(tt({index:W(),instructions:ot(ea)})))),preBalances:ot(W()),postBalances:ot(W()),logMessages:ft(at(ot(rt()))),preTokenBalances:ft(at(ot(Bn))),postTokenBalances:ft(at(ot(Bn))),loadedAddresses:ft(na),computeUnitsConsumed:ft(W())}),Mr=Ie([Ht(0),Ht("legacy")]),wr=tt({pubkey:rt(),lamports:W(),postBalance:at(W()),rewardType:at(rt()),commission:ft(at(W()))}),Lf=wt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:W(),transactions:ot(tt({transaction:Fi,meta:at(An),version:ft(Mr)})),rewards:ft(ot(wr)),blockTime:at(W()),blockHeight:at(W())}))),Of=wt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:W(),rewards:ft(ot(wr)),blockTime:at(W()),blockHeight:at(W())}))),Uf=wt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:W(),transactions:ot(tt({transaction:Xo,meta:at(An),version:ft(Mr)})),rewards:ft(ot(wr)),blockTime:at(W()),blockHeight:at(W())}))),Nf=wt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:W(),transactions:ot(tt({transaction:ra,meta:at(zi),version:ft(Mr)})),rewards:ft(ot(wr)),blockTime:at(W()),blockHeight:at(W())}))),Ff=wt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:W(),transactions:ot(tt({transaction:Xo,meta:at(zi),version:ft(Mr)})),rewards:ft(ot(wr)),blockTime:at(W()),blockHeight:at(W())}))),zf=wt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:W(),rewards:ft(ot(wr)),blockTime:at(W()),blockHeight:at(W())}))),qf=wt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:W(),transactions:ot(tt({transaction:Fi,meta:at(An)})),rewards:ft(ot(wr)),blockTime:at(W())}))),ia=wt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:W(),signatures:ot(rt()),blockTime:at(W())}))),qi=wt(at(tt({slot:W(),meta:at(An),blockTime:ft(at(W())),transaction:Fi,version:ft(Mr)}))),Rn=wt(at(tt({slot:W(),transaction:ra,meta:at(zi),blockTime:ft(at(W())),version:ft(Mr)}))),Kf=Gt(tt({blockhash:rt(),feeCalculator:tt({lamportsPerSignature:W()})})),Wf=Gt(tt({blockhash:rt(),lastValidBlockHeight:W()})),Df=Gt(Ne()),$f=tt({slot:W(),numTransactions:W(),numSlots:W(),samplePeriodSecs:W()}),Hf=wt(ot($f)),Vf=Gt(at(tt({feeCalculator:tt({lamportsPerSignature:W()})}))),jf=wt(rt()),Gf=wt(rt()),Zf=tt({err:mr,logs:ot(rt()),signature:rt()}),Yf=tt({result:_n(Zf),subscription:W()}),Jf={"solana-client":"js/1.0.0-maintenance"};class Xf{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 g={};return async w=>{const{commitment:k,config:M}=Nt(w),R=this._buildArgs([],k,void 0,M),C=Ko(R);return g[C]=g[C]??(async()=>{try{const B=await this._rpcRequest("getBlockHeight",R),T=st(B,wt(W()));if("error"in T)throw new ut(T.error,"failed to get block height information");return T.result}finally{delete g[C]}})(),await g[C]}})();let r,s,i,o,a,h;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,r=e.wsEndpoint,s=e.httpHeaders,i=e.fetch,o=e.fetchMiddleware,a=e.disableRetryOnRateLimit,h=e.httpAgent),this._rpcEndpoint=Ll(t),this._rpcWsEndpoint=r||Cl(t),this._rpcClient=Zl(t,s,i,o,a,h),this._rpcRequest=Yl(this._rpcClient),this._rpcBatchRequest=Jl(this._rpcClient),this._rpcWebSocket=new Rl(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:s}=Nt(e),i=this._buildArgs([t.toBase58()],r,void 0,s),o=await this._rpcRequest("getBalance",i),a=st(o,Gt(W()));if("error"in a)throw new ut(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=st(e,wt(at(W())));if("error"in r)throw new ut(r.error,`failed to get block time for slot ${t}`);return r.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=st(t,wt(W()));if("error"in e)throw new ut(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=st(t,sf);if("error"in e)throw new ut(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]),s=st(r,of);if("error"in s)throw new ut(s.error,"failed to get supply");return s.result}async getTokenSupply(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenSupply",r),i=st(s,Gt(Oi));if("error"in i)throw new ut(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenAccountBalance",r),i=st(s,Gt(Oi));if("error"in i)throw new ut(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(t,e,r){const{commitment:s,config:i}=Nt(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,s,"base64",i),h=await this._rpcRequest("getTokenAccountsByOwner",a),g=st(h,cf);if("error"in g)throw new ut(g.error,`failed to get token accounts owned by account ${t.toBase58()}`);return g.result}async getParsedTokenAccountsByOwner(t,e,r){let s=[t.toBase58()];"mint"in e?s.push({mint:e.mint.toBase58()}):s.push({programId:e.programId.toBase58()});const i=this._buildArgs(s,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),a=st(o,uf);if("error"in a)throw new ut(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]:[],s=await this._rpcRequest("getLargestAccounts",r),i=st(s,lf);if("error"in i)throw new ut(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(t,e){const r=this._buildArgs([t.toBase58()],e),s=await this._rpcRequest("getTokenLargestAccounts",r),i=st(s,af);if("error"in i)throw new ut(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(t,e){const{commitment:r,config:s}=Nt(e),i=this._buildArgs([t.toBase58()],r,"base64",s),o=await this._rpcRequest("getAccountInfo",i),a=st(o,Gt(at(Jr)));if("error"in a)throw new ut(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getParsedAccountInfo(t,e){const{commitment:r,config:s}=Nt(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),a=st(o,Gt(at(Ni)));if("error"in a)throw new ut(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:s}=Nt(e),i=t.map(g=>g.toBase58()),o=this._buildArgs([i],r,"jsonParsed",s),a=await this._rpcRequest("getMultipleAccounts",o),h=st(a,Gt(ot(at(Ni))));if("error"in h)throw new ut(h.error,`failed to get info for accounts ${i}`);return h.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:r,config:s}=Nt(e),i=t.map(g=>g.toBase58()),o=this._buildArgs([i],r,"base64",s),a=await this._rpcRequest("getMultipleAccounts",o),h=st(a,Gt(ot(at(Jr))));if("error"in h)throw new ut(h.error,`failed to get info for accounts ${i}`);return h.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,r){const{commitment:s,config:i}=Nt(e),o=this._buildArgs([t.toBase58()],s,void 0,{...i,epoch:r??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getStakeActivation",o),h=st(a,wt(pf));if("error"in h)throw new ut(h.error,`failed to get Stake Activation ${t.toBase58()}`);return h.result}async getProgramAccounts(t,e){const{commitment:r,config:s}=Nt(e),{encoding:i,...o}=s||{},a=this._buildArgs([t.toBase58()],r,i||"base64",{...o,...o.filters?{filters:Vo(o.filters)}:null}),h=await this._rpcRequest("getProgramAccounts",a),g=ot(ff),w=o.withContext===!0?st(h,Gt(g)):st(h,wt(g));if("error"in w)throw new ut(w.error,`failed to get accounts owned by program ${t.toBase58()}`);return w.result}async getParsedProgramAccounts(t,e){const{commitment:r,config:s}=Nt(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),a=st(o,wt(ot(df)));if("error"in a)throw new ut(a.error,`failed to get accounts owned by program ${t.toBase58()}`);return a.result}async confirmTransaction(t,e){var i;let r;if(typeof t=="string")r=t;else{const o=t;if((i=o.abortSignal)!=null&&i.aborted)return Promise.reject(o.abortSignal.reason);r=o.signature}let s;try{s=ge.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return Et(s.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,s,i=!1;const o=new Promise((h,g)=>{try{r=this.onSignature(e,(k,M)=>{r=void 0;const R={context:M,value:k};h({__type:Ge.PROCESSED,response:R})},t);const w=new Promise(k=>{r==null?k():s=this._onSubscriptionStateChange(r,M=>{M==="subscribed"&&k()})});(async()=>{if(await w,i)return;const k=await this.getSignatureStatus(e);if(i||k==null)return;const{context:M,value:R}=k;if(R!=null)if(R!=null&&R.err)g(R.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(R.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(R.confirmationStatus==="processed"||R.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,h({__type:Ge.PROCESSED,response:{context:M,value:R}})}})()}catch(w){g(w)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:r,signature:s}}){let i=!1;const o=new Promise(k=>{const M=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let R=await M();if(!i){for(;R<=r;)if(await gr(1e3),i||(R=await M(),i))return;k({__type:Ge.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:h}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),g=this.getCancellationPromise(e);let w;try{const k=await Promise.race([g,h,o]);if(k.__type===Ge.PROCESSED)w=k.response;else throw new xi(s)}finally{i=!0,a()}return w}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let a=!1;const h=new Promise(R=>{let C=i,B=null;const T=async()=>{try{const{context:O,value:$}=await this.getNonceAndContext(s,{commitment:t,minContextSlot:r});return B=O.slot,$==null?void 0:$.nonce}catch{return C}};(async()=>{if(C=await T(),!a)for(;;){if(i!==C){R({__type:Ge.NONCE_INVALID,slotInWhichNonceDidAdvance:B});return}if(await gr(2e3),a||(C=await T(),a))return}})()}),{abortConfirmation:g,confirmationPromise:w}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),k=this.getCancellationPromise(e);let M;try{const R=await Promise.race([k,w,h]);if(R.__type===Ge.PROCESSED)M=R.response;else{let C;for(;;){const B=await this.getSignatureStatus(o);if(B==null)break;if(B.context.slot<(R.slotInWhichNonceDidAdvance??r)){await gr(400);continue}C=B;break}if(C!=null&&C.value){const B=t||"finalized",{confirmationStatus:T}=C.value;switch(B){case"processed":case"recent":if(T!=="processed"&&T!=="confirmed"&&T!=="finalized")throw new Ar(o);break;case"confirmed":case"single":case"singleGossip":if(T!=="confirmed"&&T!=="finalized")throw new Ar(o);break;case"finalized":case"max":case"root":if(T!=="finalized")throw new Ar(o);break;default:}M={context:C.context,value:{err:C.value.err}}}else throw new Ar(o)}}finally{a=!0,g()}return M}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const s=new Promise(h=>{let g=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{g=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>h({__type:Ge.TIMED_OUT,timeoutMs:g}),g)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let a;try{const h=await Promise.race([o,s]);if(h.__type===Ge.PROCESSED)a=h.response;else throw new Ii(e,h.timeoutMs/1e3)}finally{clearTimeout(r),i()}return a}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=st(t,wt(ot(_f)));if("error"in e)throw new ut(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getVoteAccounts",e),s=st(r,Bf);if("error"in s)throw new ut(s.error,"failed to get vote accounts");return s.result}async getSlot(t){const{commitment:e,config:r}=Nt(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getSlot",s),o=st(i,wt(W()));if("error"in o)throw new ut(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:r}=Nt(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getSlotLeader",s),o=st(i,wt(rt()));if("error"in o)throw new ut(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const r=[t,e],s=await this._rpcRequest("getSlotLeaders",r),i=st(s,wt(ot(Vt)));if("error"in i)throw new ut(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(t,e){const{context:r,value:s}=await this.getSignatureStatuses([t],e);Et(s.length===1);const i=s[0];return{context:r,value:i}}async getSignatureStatuses(t,e){const r=[t];e&&r.push(e);const s=await this._rpcRequest("getSignatureStatuses",r),i=st(s,Tf);if("error"in i)throw new ut(i.error,"failed to get signature status");return i.result}async getTransactionCount(t){const{commitment:e,config:r}=Nt(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getTransactionCount",s),o=st(i,wt(W()));if("error"in o)throw new ut(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),s=st(r,Xl);if("error"in s)throw new ut(s.error,"failed to get inflation");return s.result}async getInflationReward(t,e,r){const{commitment:s,config:i}=Nt(r),o=this._buildArgs([t.map(g=>g.toBase58())],s,void 0,{...i,epoch:e??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getInflationReward",o),h=st(a,Nl);if("error"in h)throw new ut(h.error,"failed to get inflation reward");return h.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=st(t,Ql);if("error"in e)throw new ut(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:r}=Nt(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getEpochInfo",s),o=st(i,ef);if("error"in o)throw new ut(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=st(t,rf);if("error"in e)throw new ut(e.error,"failed to get epoch schedule");const r=e.result;return new Wo(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=st(t,nf);if("error"in e)throw new ut(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const r=this._buildArgs([t],e),s=await this._rpcRequest("getMinimumBalanceForRentExemption",r),i=st(s,Mf);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(t){const e=this._buildArgs([],t),r=await this._rpcRequest("getRecentBlockhash",e),s=st(r,Kf);if("error"in s)throw new ut(s.error,"failed to get recent blockhash");return s.result}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),r=st(e,Hf);if("error"in r)throw new ut(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(t,e){const r=this._buildArgs([t],e),s=await this._rpcRequest("getFeeCalculatorForBlockhash",r),i=st(s,Vf);if("error"in i)throw new ut(i.error,"failed to get fee calculator");const{context:o,value:a}=i.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(t,e){const r=mt(t.serialize()).toString("base64"),s=this._buildArgs([r],e),i=await this._rpcRequest("getFeeForMessage",s),o=st(i,Gt(at(W())));if("error"in o)throw new ut(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]:[],s=await this._rpcRequest("getRecentPrioritizationFees",r),i=st(s,tf);if("error"in i)throw new ut(i.error,"failed to get recent prioritization fees");return i.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}=Nt(t),s=this._buildArgs([],e,void 0,r),i=await this._rpcRequest("getLatestBlockhash",s),o=st(i,Wf);if("error"in o)throw new ut(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:r,config:s}=Nt(e),i=this._buildArgs([t],r,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),a=st(o,Df);if("error"in a)throw new ut(a.error,"failed to determine if the blockhash `"+t+"`is valid");return a.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=st(t,wt(Hl));if("error"in e)throw new ut(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=st(t,wt(rt()));if("error"in e)throw new ut(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:r,config:s}=Nt(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=st(o,Uf);if("error"in a)throw a.error;return a.result}case"none":{const a=st(o,Of);if("error"in a)throw a.error;return a.result}default:{const a=st(o,Lf);if("error"in a)throw a.error;const{result:h}=a;return h?{...h,transactions:h.transactions.map(({transaction:g,meta:w,version:k})=>({meta:w,transaction:{...g,message:Li(k,g.message)},version:k}))}:null}}}catch(a){throw new ut(a,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:r,config:s}=Nt(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=st(o,Ff);if("error"in a)throw a.error;return a.result}case"none":{const a=st(o,zf);if("error"in a)throw a.error;return a.result}default:{const a=st(o,Nf);if("error"in a)throw a.error;return a.result}}}catch(a){throw new ut(a,"failed to get block")}}async getBlockProduction(t){let e,r;if(typeof t=="string")r=t;else if(t){const{commitment:a,...h}=t;r=a,e=h}const s=this._buildArgs([],r,"base64",e),i=await this._rpcRequest("getBlockProduction",s),o=st(i,Gl);if("error"in o)throw new ut(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:r,config:s}=Nt(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,s),o=await this._rpcRequest("getTransaction",i),a=st(o,qi);if("error"in a)throw new ut(a.error,"failed to get transaction");const h=a.result;return h&&{...h,transaction:{...h.transaction,message:Li(h.version,h.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:r,config:s}=Nt(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),a=st(o,Rn);if("error"in a)throw new ut(a.error,"failed to get transaction");return a.result}async getParsedTransactions(t,e){const{commitment:r,config:s}=Nt(e),i=t.map(h=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([h],r,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(h=>{const g=st(h,Rn);if("error"in g)throw new ut(g.error,"failed to get transactions");return g.result})}async getTransactions(t,e){const{commitment:r,config:s}=Nt(e),i=t.map(h=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([h],r,void 0,s)}));return(await this._rpcBatchRequest(i)).map(h=>{const g=st(h,qi);if("error"in g)throw new ut(g.error,"failed to get transactions");const w=g.result;return w&&{...w,transaction:{...w.transaction,message:Li(w.version,w.transaction.message)}}})}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedBlock",r),i=st(s,qf);if("error"in i)throw new ut(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");const a={...o,transactions:o.transactions.map(({transaction:h,meta:g})=>{const w=new Ce(h.message);return{meta:g,transaction:{...h,message:w}}})};return{...a,transactions:a.transactions.map(({transaction:h,meta:g})=>({meta:g,transaction:Bt.populate(h.message,h.signatures)}))}}async getBlocks(t,e,r){const s=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],r),i=await this._rpcRequest("getBlocks",s),o=st(i,wt(ot(W())));if("error"in o)throw new ut(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}),s=await this._rpcRequest("getBlock",r),i=st(s,ia);if("error"in i)throw new ut(i.error,"failed to get block");const o=i.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}),s=await this._rpcRequest("getConfirmedBlock",r),i=st(s,ia);if("error"in i)throw new ut(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getConfirmedTransaction",r),i=st(s,qi);if("error"in i)throw new ut(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const a=new Ce(o.transaction.message),h=o.transaction.signatures;return{...o,transaction:Bt.populate(a,h)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=await this._rpcRequest("getConfirmedTransaction",r),i=st(s,Rn);if("error"in i)throw new ut(i.error,"failed to get confirmed transaction");return i.result}async getParsedConfirmedTransactions(t,e){const r=t.map(o=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const a=st(o,Rn);if("error"in a)throw new ut(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(t,e,r){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<i));)try{const h=await this.getConfirmedBlockSignatures(e,"finalized");h.signatures.length>0&&(s.until=h.signatures[h.signatures.length-1].toString())}catch(h){if(h instanceof Error&&h.message.includes("skipped"))continue;throw h}let o=await this.getSlot("finalized");for(;!("before"in s)&&(r++,!(r>o));)try{const h=await this.getConfirmedBlockSignatures(r);h.signatures.length>0&&(s.before=h.signatures[h.signatures.length-1].toString())}catch(h){if(h instanceof Error&&h.message.includes("skipped"))continue;throw h}return(await this.getConfirmedSignaturesForAddress2(t,s)).map(h=>h.signature)}async getConfirmedSignaturesForAddress2(t,e,r){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=st(i,gf);if("error"in o)throw new ut(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,r){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=await this._rpcRequest("getSignaturesForAddress",s),o=st(i,yf);if("error"in o)throw new ut(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:r,value:s}=await this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=new Pi({key:t,state:Pi.deserialize(s.data)})),{context:r,value:i}}async getNonceAndContext(t,e){const{context:r,value:s}=await this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=En.fromAccountData(s.data)),{context:r,value:i}}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]),s=st(r,jf);if("error"in s)throw new ut(s.error,`airdrop to ${t.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await gr(100);const r=Date.now()-this._blockhashInfo.lastFetch>=Ho;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 s=0;s<50;s++){const i=await this.getLatestBlockhash("finalized");if(r!==i.blockhash)return this._blockhashInfo={latestBlockhash:i,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},i;await gr(No/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}=Nt(t),s=this._buildArgs([],e,"base64",r),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=st(i,Gt(W()));if("error"in o)throw new ut(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,r){if("message"in t){const B=t.serialize(),T=lt.Buffer.from(B).toString("base64");if(Array.isArray(e)||r!==void 0)throw new Error("Invalid arguments");const O=e||{};O.encoding="base64","commitment"in O||(O.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(O.innerInstructions=e.innerInstructions);const $=[T,O],q=await this._rpcRequest("simulateTransaction",$),X=st(q,Go);if("error"in X)throw new Error("failed to simulate transaction: "+X.error.message);return X.result}let s;if(t instanceof Bt){let C=t;s=new Bt,s.feePayer=C.feePayer,s.instructions=t.instructions,s.nonceInfo=C.nonceInfo,s.signatures=C.signatures}else s=Bt.populate(t),s._message=s._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(s.nonceInfo&&i)s.sign(...i);else{let C=this._disableBlockhashCaching;for(;;){const B=await this._blockhashWithExpiryBlockHeight(C);if(s.lastValidBlockHeight=B.lastValidBlockHeight,s.recentBlockhash=B.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const T=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(T)&&!this._blockhashInfo.transactionSignatures.includes(T)){this._blockhashInfo.simulatedSignatures.push(T);break}else C=!0}}const o=s._compile(),a=o.serialize(),g=s._serialize(a).toString("base64"),w={encoding:"base64",commitment:this.commitment};if(r){const C=(Array.isArray(r)?r:o.nonProgramIds()).map(B=>B.toBase58());w.accounts={encoding:"base64",addresses:C}}i&&(w.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(w.innerInstructions=e.innerInstructions);const k=[g,w],M=await this._rpcRequest("simulateTransaction",k),R=st(M,Go);if("error"in R){let C;if("data"in R.error&&(C=R.error.data.logs,C&&Array.isArray(C))){const B=`
13
+ `,T=B+C.join(B);console.error(R.error.message,T)}throw new Zr({action:"simulate",signature:"",transactionMessage:R.error.message,logs:C})}return R.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 s=e;if(t.nonceInfo)t.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=a.lastValidBlockHeight,t.recentBlockhash=a.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const h=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(h))o=!0;else{this._blockhashInfo.transactionSignatures.push(h);break}}}const i=t.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(t,e){const r=mt(t).toString("base64");return await this.sendEncodedTransaction(r,e)}async sendEncodedTransaction(t,e){const r={encoding:"base64"},s=e&&e.skipPreflight,i=s===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(r.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(r.minContextSlot=e.minContextSlot),s&&(r.skipPreflight=s),i&&(r.preflightCommitment=i);const o=[t,r],a=await this._rpcRequest("sendTransaction",o),h=st(a,Gf);if("error"in h){let g;throw"data"in h.error&&(g=h.error.data.logs),new Zr({action:s?"send":"simulate",signature:"",transactionMessage:h.error.message,logs:g})}return h.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 s;const r=(s=this._subscriptionsByHash[t])==null?void 0:s.state;if(this._subscriptionsByHash[t]=e,r!==e.state){const i=this._subscriptionStateChangeCallbacksByHash[t];i&&i.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var i;const r=this._subscriptionHashByClientSubscriptionId[t];if(r==null)return()=>{};const s=(i=this._subscriptionStateChangeCallbacksByHash)[r]||(i[r]=new Set);return s.add(e),()=>{s.delete(e),s.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 s=this._subscriptionsByHash[r];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[r],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:i,method:o}=s;try{this._setSubscription(r,{...s,state:"subscribing"});const a=await this._rpcWebSocket.call(o,i);this._setSubscription(r,{...s,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=s.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:a}),!e())return;this._setSubscription(r,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(r,{...s,state:"unsubscribing"}),this._setSubscription(r,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!e())return;this._setSubscription(r,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const r=this._subscriptionCallbacksByServerSubscriptionId[t];r!==void 0&&r.forEach(s=>{try{s(...e)}catch(i){console.error(i)}})}_wsOnAccountNotification(t){const{result:e,subscription:r}=st(t,mf);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,s=Ko([t.method,e]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:i.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[s];Et(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:s,config:i}=Nt(r),o=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",i);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}=st(t,bf);this._handleServerNotification(r,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,r,s){const{commitment:i,config:o}=Nt(r),a=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:Vo(s)}: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 s=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],r||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:r}=st(t,Yf);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=st(t,vf);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}=st(t,xf);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,s){const i=e||this._commitment;if(i||r||s){let o={};r&&(o.encoding=r),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,r,s){const i=e||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,r,s)}_wsOnSignatureNotification(t){const{result:e,subscription:r}=st(t,If);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 s=this._buildArgs([t],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){e(o.result,a);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(t,e,r){const{commitment:s,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([t],s,void 0,i),a=this._makeSubscription({callback:(h,g)=>{e(h,g);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}=st(t,Ef);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 Pr{constructor(t){this._keypair=void 0,this._keypair=t??To()}static generate(){return new Pr(To())}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 s=t.slice(0,32),i=kn(s);for(let o=0;o<32;o++)if(r[o]!==i[o])throw new Error("provided secretKey is invalid")}return new Pr({publicKey:r,secretKey:t})}static fromSeed(t){const e=kn(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),new Pr({publicKey:e,secretKey:r})}get publicKey(){return new it(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const Ze=Object.freeze({CreateLookupTable:{index:0,layout:P.struct([P.u32("instruction"),Tr("recentSlot"),P.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:P.struct([P.u32("instruction")])},ExtendLookupTable:{index:2,layout:P.struct([P.u32("instruction"),Tr(),P.seq(xt(),P.offset(P.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:P.struct([P.u32("instruction")])},CloseLookupTable:{index:4,layout:P.struct([P.u32("instruction")])}});class Qf{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=P.u32("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(Ze))if(o.index==r){s=i;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Rt(Ze.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}=Rt(Ze.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 it(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(Ki.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 Ki{constructor(){}static createLookupTable(t){const[e,r]=it.findProgramAddressSync([t.authority.toBuffer(),oi.toBufferLE(BigInt(t.recentSlot),8)],this.programId),s=Ze.CreateLookupTable,i=It(s,{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:ye.programId,isSigner:!1,isWritable:!1}];return[new Pt({programId:this.programId,keys:o,data:i}),e]}static freezeLookupTable(t){const e=Ze.FreezeLookupTable,r=It(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Pt({programId:this.programId,keys:s,data:r})}static extendLookupTable(t){const e=Ze.ExtendLookupTable,r=It(e,{addresses:t.addresses.map(i=>i.toBytes())}),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&s.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:ye.programId,isSigner:!1,isWritable:!1}),new Pt({programId:this.programId,keys:s,data:r})}static deactivateLookupTable(t){const e=Ze.DeactivateLookupTable,r=It(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Pt({programId:this.programId,keys:s,data:r})}static closeLookupTable(t){const e=Ze.CloseLookupTable,r=It(e),s=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Pt({programId:this.programId,keys:s,data:r})}}Ki.programId=new it("AddressLookupTab1e1111111111111111111111111");class th{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=P.u8("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(Ke))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:r}=Rt(Ke.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Rt(Ke.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Rt(Ke.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Rt(Ke.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(Wi.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Ke=Object.freeze({RequestUnits:{index:0,layout:P.struct([P.u8("instruction"),P.u32("units"),P.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:P.struct([P.u8("instruction"),P.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:P.struct([P.u8("instruction"),P.u32("units")])},SetComputeUnitPrice:{index:3,layout:P.struct([P.u8("instruction"),Tr("microLamports")])}});class Wi{constructor(){}static requestUnits(t){const e=Ke.RequestUnits,r=It(e,t);return new Pt({keys:[],programId:this.programId,data:r})}static requestHeapFrame(t){const e=Ke.RequestHeapFrame,r=It(e,t);return new Pt({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(t){const e=Ke.SetComputeUnitLimit,r=It(e,t);return new Pt({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(t){const e=Ke.SetComputeUnitPrice,r=It(e,{microLamports:BigInt(t.microLamports)});return new Pt({keys:[],programId:this.programId,data:r})}}Wi.programId=new it("ComputeBudget111111111111111111111111111111");const sa=64,oa=32,aa=64,ca=P.struct([P.u8("numSignatures"),P.u8("padding"),P.u16("signatureOffset"),P.u16("signatureInstructionIndex"),P.u16("publicKeyOffset"),P.u16("publicKeyInstructionIndex"),P.u16("messageDataOffset"),P.u16("messageDataSize"),P.u16("messageInstructionIndex")]);class Tn{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:s,instructionIndex:i}=t;Et(e.length===oa,`Public Key must be ${oa} bytes but received ${e.length} bytes`),Et(s.length===aa,`Signature must be ${aa} bytes but received ${s.length} bytes`);const o=ca.span,a=o+e.length,h=a+s.length,g=1,w=lt.Buffer.alloc(h+r.length),k=i??65535;return ca.encode({numSignatures:g,padding:0,signatureOffset:a,signatureInstructionIndex:k,publicKeyOffset:o,publicKeyInstructionIndex:k,messageDataOffset:h,messageDataSize:r.length,messageInstructionIndex:k},w),w.fill(e,o),w.fill(s,a),w.fill(r,h),new Pt({keys:[],programId:Tn.programId,data:w})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;Et(e.length===sa,`Private key must be ${sa} bytes but received ${e.length} bytes`);try{const i=Pr.fromSecretKey(e),o=i.publicKey.toBytes(),a=vi(r,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Tn.programId=new it("Ed25519SigVerify111111111111111111111111111");const eh=(n,t)=>{const e=bn.sign(n,t);return[e.toCompactRawBytes(),e.recovery]};bn.utils.isValidPrivateKey;const rh=bn.getPublicKey,ua=32,Di=20,la=64,nh=11,$i=P.struct([P.u8("numSignatures"),P.u16("signatureOffset"),P.u8("signatureInstructionIndex"),P.u16("ethAddressOffset"),P.u8("ethAddressInstructionIndex"),P.u16("messageDataOffset"),P.u16("messageDataSize"),P.u8("messageInstructionIndex"),P.blob(20,"ethAddress"),P.blob(64,"signature"),P.u8("recoveryId")]);class Cr{constructor(){}static publicKeyToEthAddress(t){Et(t.length===la,`Public key must be ${la} bytes but received ${t.length} bytes`);try{return lt.Buffer.from(xo(mt(t))).slice(-Di)}catch(e){throw new Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:s,recoveryId:i,instructionIndex:o}=t;return Cr.createInstructionWithEthAddress({ethAddress:Cr.publicKeyToEthAddress(e),message:r,signature:s,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:r,signature:s,recoveryId:i,instructionIndex:o=0}=t;let a;typeof e=="string"?e.startsWith("0x")?a=lt.Buffer.from(e.substr(2),"hex"):a=lt.Buffer.from(e,"hex"):a=e,Et(a.length===Di,`Address must be ${Di} bytes but received ${a.length} bytes`);const h=1+nh,g=h,w=h+a.length,k=w+s.length+1,M=1,R=lt.Buffer.alloc($i.span+r.length);return $i.encode({numSignatures:M,signatureOffset:w,signatureInstructionIndex:o,ethAddressOffset:g,ethAddressInstructionIndex:o,messageDataOffset:k,messageDataSize:r.length,messageInstructionIndex:o,signature:mt(s),ethAddress:mt(a),recoveryId:i},R),R.fill(mt(r),$i.span),new Pt({keys:[],programId:Cr.programId,data:R})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;Et(e.length===ua,`Private key must be ${ua} bytes but received ${e.length} bytes`);try{const i=mt(e),o=rh(i,!1).slice(1),a=lt.Buffer.from(xo(mt(r))),[h,g]=eh(a,i);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:h,recoveryId:g,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Cr.programId=new it("KeccakSecp256k11111111111111111111111111111");var fa;const ha=new it("StakeConfig11111111111111111111111111111111");class da{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class Xr{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}}fa=Xr,Xr.default=new fa(0,0,it.default);class ih{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=P.u32("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(me))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:r}=Rt(me.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new da(new it(e.staker),new it(e.withdrawer)),lockup:new Xr(r.unixTimestamp,r.epoch,new it(r.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Rt(me.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}=Rt(me.Authorize,t.data),s={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new it(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(s.custodianPubkey=t.keys[3].pubkey),s}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:r,authoritySeed:s,authorityOwner:i}=Rt(me.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:s,authorityOwner:new it(i),newAuthorizedPubkey:new it(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}=Rt(me.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),Rt(me.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}=Rt(me.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),Rt(me.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(Mn.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 me=Object.freeze({Initialize:{index:0,layout:P.struct([P.u32("instruction"),cl(),ul()])},Authorize:{index:1,layout:P.struct([P.u32("instruction"),xt("newAuthorized"),P.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:P.struct([P.u32("instruction")])},Split:{index:3,layout:P.struct([P.u32("instruction"),P.ns64("lamports")])},Withdraw:{index:4,layout:P.struct([P.u32("instruction"),P.ns64("lamports")])},Deactivate:{index:5,layout:P.struct([P.u32("instruction")])},Merge:{index:7,layout:P.struct([P.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:P.struct([P.u32("instruction"),xt("newAuthorized"),P.u32("stakeAuthorizationType"),dr("authoritySeed"),xt("authorityOwner")])}}),sh=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Mn{constructor(){}static initialize(t){const{stakePubkey:e,authorized:r,lockup:s}=t,i=s||Xr.default,o=me.Initialize,a=It(o,{authorized:{staker:mt(r.staker.toBuffer()),withdrawer:mt(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:mt(i.custodian.toBuffer())}}),h={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Rr,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Pt(h)}static createAccountWithSeed(t){const e=new Bt;e.add(ye.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:s,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static createAccount(t){const e=new Bt;e.add(ye.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:r,votePubkey:s}=t,i=me.Delegate,o=It(i);return new Bt().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:qe,isSigner:!1,isWritable:!1},{pubkey:In,isSigner:!1,isWritable:!1},{pubkey:ha,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(t){const{stakePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:s,stakeAuthorizationType:i,custodianPubkey:o}=t,a=me.Authorize,h=It(a,{newAuthorized:mt(s.toBuffer()),stakeAuthorizationType:i.index}),g=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:qe,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&g.push({pubkey:o,isSigner:!0,isWritable:!1}),new Bt().add({keys:g,programId:this.programId,data:h})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:h}=t,g=me.AuthorizeWithSeed,w=It(g,{newAuthorized:mt(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:s,authorityOwner:mt(i.toBuffer())}),k=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:qe,isSigner:!1,isWritable:!1}];return h&&k.push({pubkey:h,isSigner:!0,isWritable:!1}),new Bt().add({keys:k,programId:this.programId,data:w})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:s,lamports:i}=t,o=me.Split,a=It(o,{lamports:i});return new Pt({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(t,e){const r=new Bt;return r.add(ye.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:s,splitStakePubkey:i,basePubkey:o,seed:a,lamports:h}=t,g=new Bt;return g.add(ye.allocate({accountPubkey:i,basePubkey:o,seed:a,space:this.space,programId:this.programId})),e&&e>0&&g.add(ye.transfer({fromPubkey:t.authorizedPubkey,toPubkey:i,lamports:e})),g.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,lamports:h}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:r,authorizedPubkey:s}=t,i=me.Merge,o=It(i);return new Bt().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:qe,isSigner:!1,isWritable:!1},{pubkey:In,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:r,toPubkey:s,lamports:i,custodianPubkey:o}=t,a=me.Withdraw,h=It(a,{lamports:i}),g=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:qe,isSigner:!1,isWritable:!1},{pubkey:In,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&g.push({pubkey:o,isSigner:!0,isWritable:!1}),new Bt().add({keys:g,programId:this.programId,data:h})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:r}=t,s=me.Deactivate,i=It(s);return new Bt().add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:qe,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}Mn.programId=new it("Stake11111111111111111111111111111111111111"),Mn.space=200;class pa{constructor(t,e,r,s){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=s}}class oh{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const r=P.u32("instruction").decode(t.data);let s;for(const[i,o]of Object.entries(We))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Rt(We.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new pa(new it(e.nodePubkey),new it(e.authorizedVoter),new it(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:r}=Rt(We.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new it(e),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:r,newAuthorized:s,voteAuthorizationType:i}}=Rt(We.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new it(e),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new it(s),voteAuthorizationType:{index:i},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Rt(We.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(Lr.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 We=Object.freeze({InitializeAccount:{index:0,layout:P.struct([P.u32("instruction"),ll()])},Authorize:{index:1,layout:P.struct([P.u32("instruction"),xt("newAuthorized"),P.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:P.struct([P.u32("instruction"),P.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:P.struct([P.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:P.struct([P.u32("instruction"),fl()])}}),ah=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Lr{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:s}=t,i=We.InitializeAccount,o=It(i,{voteInit:{nodePubkey:mt(s.nodePubkey.toBuffer()),authorizedVoter:mt(s.authorizedVoter.toBuffer()),authorizedWithdrawer:mt(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),a={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Rr,isSigner:!1,isWritable:!1},{pubkey:qe,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Pt(a)}static createAccount(t){const e=new Bt;return e.add(ye.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:s,voteAuthorizationType:i}=t,o=We.Authorize,a=It(o,{newAuthorized:mt(s.toBuffer()),voteAuthorizationType:i.index}),h=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:qe,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Bt().add({keys:h,programId:this.programId,data:a})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:a}=t,h=We.AuthorizeWithSeed,g=It(h,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:mt(r.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:mt(i.toBuffer()),voteAuthorizationType:o.index}}),w=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:qe,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return new Bt().add({keys:w,programId:this.programId,data:g})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,lamports:s,toPubkey:i}=t,o=We.Withdraw,a=It(o,{lamports:s}),h=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Bt().add({keys:h,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 Lr.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,nodePubkey:s}=t,i=We.UpdateValidatorIdentity,o=It(i),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Bt().add({keys:a,programId:this.programId,data:o})}}Lr.programId=new it("Vote111111111111111111111111111111111111111"),Lr.space=3762;const ga=new it("Va1idator1nfo111111111111111111111111111111"),ch=tt({name:rt(),website:ft(rt()),details:ft(rt()),iconUrl:ft(rt()),keybaseUsername:ft(rt())});class Hi{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(Ee(e)!==2)return null;const s=[];for(let i=0;i<2;i++){const o=new it(_e(e,0,Fe)),a=ze(e)===1;s.push({publicKey:o,isSigner:a})}if(s[0].publicKey.equals(ga)&&s[1].isSigner){const i=dr().decode(lt.Buffer.from(e)),o=JSON.parse(i);return io(o,ch),new Hi(s[1].publicKey,o)}return null}}const uh=new it("Vote111111111111111111111111111111111111111"),lh=P.struct([xt("nodePubkey"),xt("authorizedWithdrawer"),P.u8("commission"),P.nu64(),P.seq(P.struct([P.nu64("slot"),P.u32("confirmationCount")]),P.offset(P.u32(),-8),"votes"),P.u8("rootSlotValid"),P.nu64("rootSlot"),P.nu64(),P.seq(P.struct([P.nu64("epoch"),xt("authorizedVoter")]),P.offset(P.u32(),-8),"authorizedVoters"),P.struct([P.seq(P.struct([xt("authorizedPubkey"),P.nu64("epochOfLastAuthorizedSwitch"),P.nu64("targetEpoch")]),32,"buf"),P.nu64("idx"),P.u8("isEmpty")],"priorVoters"),P.nu64(),P.seq(P.struct([P.nu64("epoch"),P.nu64("credits"),P.nu64("prevCredits")]),P.offset(P.u32(),-8),"epochCredits"),P.struct([P.nu64("slot"),P.nu64("timestamp")],"lastTimestamp")]);class Vi{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=lh.decode(mt(t),4);let s=r.rootSlot;return r.rootSlotValid||(s=null),new Vi({nodePubkey:new it(r.nodePubkey),authorizedWithdrawer:new it(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:s,authorizedVoters:r.authorizedVoters.map(fh),priorVoters:hh(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function fh({authorizedVoter:n,epoch:t}){return{epoch:t,authorizedVoter:new it(n)}}function ya({authorizedPubkey:n,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new it(n),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function hh({buf:n,idx:t,isEmpty:e}){return e?[]:[...n.slice(t+1).map(ya),...n.slice(0,t).map(ya)]}const ma={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 dh(n,t){const e=t===!1?"http":"https";if(!n)return ma[e].devnet;const r=ma[e][n];if(!r)throw new Error(`Unknown ${e} cluster: ${n}`);return r}async function ph(n,t,e,r){let s,i;e&&Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")||e&&Object.prototype.hasOwnProperty.call(e,"nonceValue")?(s=e,i=r):i=e;const o=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,minContextSlot:i.minContextSlot},a=await n.sendRawTransaction(t,o),h=i&&i.commitment,w=(await(s?n.confirmTransaction(s,h):n.confirmTransaction(a,h))).value;if(w.err)throw a!=null?new Zr({action:o!=null&&o.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(w)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(w)})`);return a}const Pn=Object.freeze(Object.defineProperty({__proto__:null,Account:sl,AddressLookupTableAccount:Pi,AddressLookupTableInstruction:Qf,AddressLookupTableProgram:Ki,Authorized:da,BLOCKHASH_CACHE_TIMEOUT_MS:Ho,BPF_LOADER_DEPRECATED_PROGRAM_ID:ol,BPF_LOADER_PROGRAM_ID:Sl,BpfLoader:xl,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Ke,ComputeBudgetInstruction:th,ComputeBudgetProgram:Wi,Connection:Xf,Ed25519Program:Tn,Enum:nl,EpochSchedule:Wo,FeeCalculatorLayout:Fo,Keypair:Pr,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Ze,Loader:yr,Lockup:Xr,MAX_SEED_LENGTH:Co,Message:Ce,MessageAccountKeys:Gr,MessageV0:pr,NONCE_ACCOUNT_LENGTH:Ri,NonceAccount:En,PACKET_DATA_SIZE:er,PUBLIC_KEY_LENGTH:Fe,PublicKey:it,SIGNATURE_LENGTH_IN_BYTES:jr,SOLANA_SCHEMA:Vr,STAKE_CONFIG_ID:ha,STAKE_INSTRUCTION_LAYOUTS:me,SYSTEM_INSTRUCTION_LAYOUTS:Ut,SYSVAR_CLOCK_PUBKEY:qe,SYSVAR_EPOCH_SCHEDULE_PUBKEY:dl,SYSVAR_INSTRUCTIONS_PUBKEY:pl,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:xn,SYSVAR_RENT_PUBKEY:Rr,SYSVAR_REWARDS_PUBKEY:gl,SYSVAR_SLOT_HASHES_PUBKEY:yl,SYSVAR_SLOT_HISTORY_PUBKEY:ml,SYSVAR_STAKE_HISTORY_PUBKEY:In,Secp256k1Program:Cr,SendTransactionError:Zr,SolanaJSONRPCError:ut,SolanaJSONRPCErrorCode:wl,StakeAuthorizationLayout:sh,StakeInstruction:ih,StakeProgram:Mn,Struct:Si,SystemInstruction:kl,SystemProgram:ye,Transaction:Bt,TransactionExpiredBlockheightExceededError:xi,TransactionExpiredNonceInvalidError:Ar,TransactionExpiredTimeoutError:Ii,TransactionInstruction:Pt,TransactionMessage:_i,TransactionStatus:Ge,VALIDATOR_INFO_KEY:ga,VERSION_PREFIX_MASK:vn,VOTE_PROGRAM_ID:uh,ValidatorInfo:Hi,VersionedMessage:Ei,VersionedTransaction:Bi,VoteAccount:Vi,VoteAuthorizationLayout:ah,VoteInit:pa,VoteInstruction:oh,VoteProgram:Lr,clusterApiUrl:dh,sendAndConfirmRawTransaction:ph,sendAndConfirmTransaction:Ai},Symbol.toStringTag,{value:"Module"})),rr=ge;var Cn={exports:{}};Cn.exports;var wa;function gh(){return wa||(wa=1,function(n){var t=function(){var e=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(h,g){if(!i[h]){i[h]={};for(var w=0;w<h.length;w++)i[h][h.charAt(w)]=w}return i[h][g]}var a={compressToBase64:function(h){if(h==null)return"";var g=a._compress(h,6,function(w){return r.charAt(w)});switch(g.length%4){default:case 0:return g;case 1:return g+"===";case 2:return g+"==";case 3:return g+"="}},decompressFromBase64:function(h){return h==null?"":h==""?null:a._decompress(h.length,32,function(g){return o(r,h.charAt(g))})},compressToUTF16:function(h){return h==null?"":a._compress(h,15,function(g){return e(g+32)})+" "},decompressFromUTF16:function(h){return h==null?"":h==""?null:a._decompress(h.length,16384,function(g){return h.charCodeAt(g)-32})},compressToUint8Array:function(h){for(var g=a.compress(h),w=new Uint8Array(g.length*2),k=0,M=g.length;k<M;k++){var R=g.charCodeAt(k);w[k*2]=R>>>8,w[k*2+1]=R%256}return w},decompressFromUint8Array:function(h){if(h==null)return a.decompress(h);for(var g=new Array(h.length/2),w=0,k=g.length;w<k;w++)g[w]=h[w*2]*256+h[w*2+1];var M=[];return g.forEach(function(R){M.push(e(R))}),a.decompress(M.join(""))},compressToEncodedURIComponent:function(h){return h==null?"":a._compress(h,6,function(g){return s.charAt(g)})},decompressFromEncodedURIComponent:function(h){return h==null?"":h==""?null:(h=h.replace(/ /g,"+"),a._decompress(h.length,32,function(g){return o(s,h.charAt(g))}))},compress:function(h){return a._compress(h,16,function(g){return e(g)})},_compress:function(h,g,w){if(h==null)return"";var k,M,R={},C={},B="",T="",O="",$=2,q=3,X=2,D=[],F=0,Y=0,Z;for(Z=0;Z<h.length;Z+=1)if(B=h.charAt(Z),Object.prototype.hasOwnProperty.call(R,B)||(R[B]=q++,C[B]=!0),T=O+B,Object.prototype.hasOwnProperty.call(R,T))O=T;else{if(Object.prototype.hasOwnProperty.call(C,O)){if(O.charCodeAt(0)<256){for(k=0;k<X;k++)F=F<<1,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++;for(M=O.charCodeAt(0),k=0;k<8;k++)F=F<<1|M&1,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++,M=M>>1}else{for(M=1,k=0;k<X;k++)F=F<<1|M,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++,M=0;for(M=O.charCodeAt(0),k=0;k<16;k++)F=F<<1|M&1,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++,M=M>>1}$--,$==0&&($=Math.pow(2,X),X++),delete C[O]}else for(M=R[O],k=0;k<X;k++)F=F<<1|M&1,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++,M=M>>1;$--,$==0&&($=Math.pow(2,X),X++),R[T]=q++,O=String(B)}if(O!==""){if(Object.prototype.hasOwnProperty.call(C,O)){if(O.charCodeAt(0)<256){for(k=0;k<X;k++)F=F<<1,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++;for(M=O.charCodeAt(0),k=0;k<8;k++)F=F<<1|M&1,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++,M=M>>1}else{for(M=1,k=0;k<X;k++)F=F<<1|M,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++,M=0;for(M=O.charCodeAt(0),k=0;k<16;k++)F=F<<1|M&1,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++,M=M>>1}$--,$==0&&($=Math.pow(2,X),X++),delete C[O]}else for(M=R[O],k=0;k<X;k++)F=F<<1|M&1,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++,M=M>>1;$--,$==0&&($=Math.pow(2,X),X++)}for(M=2,k=0;k<X;k++)F=F<<1|M&1,Y==g-1?(Y=0,D.push(w(F)),F=0):Y++,M=M>>1;for(;;)if(F=F<<1,Y==g-1){D.push(w(F));break}else Y++;return D.join("")},decompress:function(h){return h==null?"":h==""?null:a._decompress(h.length,32768,function(g){return h.charCodeAt(g)})},_decompress:function(h,g,w){var k=[],M=4,R=4,C=3,B="",T=[],O,$,q,X,D,F,Y,Z={val:w(0),position:g,index:1};for(O=0;O<3;O+=1)k[O]=O;for(q=0,D=Math.pow(2,2),F=1;F!=D;)X=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),q|=(X>0?1:0)*F,F<<=1;switch(q){case 0:for(q=0,D=Math.pow(2,8),F=1;F!=D;)X=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),q|=(X>0?1:0)*F,F<<=1;Y=e(q);break;case 1:for(q=0,D=Math.pow(2,16),F=1;F!=D;)X=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),q|=(X>0?1:0)*F,F<<=1;Y=e(q);break;case 2:return""}for(k[3]=Y,$=Y,T.push(Y);;){if(Z.index>h)return"";for(q=0,D=Math.pow(2,C),F=1;F!=D;)X=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),q|=(X>0?1:0)*F,F<<=1;switch(Y=q){case 0:for(q=0,D=Math.pow(2,8),F=1;F!=D;)X=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),q|=(X>0?1:0)*F,F<<=1;k[R++]=e(q),Y=R-1,M--;break;case 1:for(q=0,D=Math.pow(2,16),F=1;F!=D;)X=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),q|=(X>0?1:0)*F,F<<=1;k[R++]=e(q),Y=R-1,M--;break;case 2:return T.join("")}if(M==0&&(M=Math.pow(2,C),C++),k[Y])B=k[Y];else if(Y===R)B=$+$.charAt(0);else return null;T.push(B),k[R++]=$+B.charAt(0),M--,$=B,M==0&&(M=Math.pow(2,C),C++)}}};return a}();n!=null?n.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(Cn)),Cn.exports}var yh=gh();const Le=Nr(yh);var ji=(n=>(n.USD="USD",n.EUR="EUR",n.GBP="GBP",n.BRL="BRL",n))(ji||{});class De{constructor(t){he(this,"env");he(this,"url");this.env=t??"prod",this.env==="prod"?this.url="https://api.coinflow.cash":this.env==="local"?this.url="http://localhost:5000":this.url=`https://api-${this.env}.coinflow.cash`}async getNSurePartnerId(t){return fetch(this.url+`/merchant/view/${t}`).then(e=>e.json()).then(e=>{var r;return((r=e.nSureSettings)==null?void 0:r.nSurePartnerId)||e.nSurePartnerId}).catch(e=>{console.error(e)})}static getCoinflowBaseUrl(t){return!t||t==="prod"?"https://coinflow.cash":t==="local"?"http://localhost:3000":`https://${t}.coinflow.cash`}static getCoinflowApiUrl(t){return!t||t==="prod"?"https://api.coinflow.cash":t==="local"?"http://localhost:5000":`https://api-${t}.coinflow.cash`}static getCoinflowUrl({walletPubkey:t,sessionKey:e,route:r,routePrefix:s,env:i,subtotal:o,transaction:a,blockchain:h="solana",webhookInfo:g,email:w,loaderBackground:k,handleHeightChange:M,bankAccountLinkRedirect:R,additionalWallets:C,nearDeposit:B,chargebackProtectionData:T,merchantCss:O,color:$,rent:q,lockDefaultToken:X,tokens:D,planCode:F,disableApplePay:Y,disableGooglePay:Z,customerInfo:J,settlementType:K,lockAmount:V,nativeSolToConvert:Q,theme:x,usePermit:u,transactionSigner:p,authOnly:m,deviceId:E,jwtToken:S,origins:I,threeDsChallengePreference:L,supportEmail:v,destinationAuthKey:c}){var A;const l=s?`/${s}/${h}`:`/${h}`,y=new URL(l+r,De.getCoinflowBaseUrl(i));if(t&&y.searchParams.append("pubkey",t),e&&y.searchParams.append("sessionKey",e),a&&y.searchParams.append("transaction",a),o&&("cents"in o?(y.searchParams.append("cents",o.cents.toString()),"currency"in o?y.searchParams.append("currency",o.currency.toString()):y.searchParams.append("currency",ji.USD)):(y.searchParams.append("token",o.address.toString()),y.searchParams.append("amount",o.amount.toString()))),g&&y.searchParams.append("webhookInfo",Le.compressToEncodedURIComponent(JSON.stringify(g))),x&&y.searchParams.append("theme",Le.compressToEncodedURIComponent(JSON.stringify(x))),J&&y.searchParams.append("customerInfo",Le.compressToEncodedURIComponent(JSON.stringify(J))),w&&y.searchParams.append("email",w),v&&y.searchParams.append("supportEmail",v),D&&y.searchParams.append("tokens",D.toString()),k&&y.searchParams.append("loaderBackground",k),M&&y.searchParams.append("useHeightChange","true"),R&&y.searchParams.append("bankAccountLinkRedirect",R),C&&y.searchParams.append("additionalWallets",Le.compressToEncodedURIComponent(JSON.stringify(C))),B&&y.searchParams.append("nearDeposit",B),T&&y.searchParams.append("chargebackProtectionData",Le.compressToEncodedURIComponent(JSON.stringify(T))),E)y.searchParams.append("deviceId",E);else if(typeof window<"u"){const U=(A=window==null?void 0:window.nSureSDK)==null?void 0:A.getDeviceId();U&&y.searchParams.append("deviceId",U)}return O&&y.searchParams.append("merchantCss",O),$&&y.searchParams.append("color",$),q&&y.searchParams.append("rent",q.lamports.toString()),Q&&y.searchParams.append("nativeSolToConvert",Q.lamports.toString()),X&&y.searchParams.append("lockDefaultToken","true"),F&&y.searchParams.append("planCode",F),Y&&y.searchParams.append("disableApplePay","true"),Z&&y.searchParams.append("disableGooglePay","true"),K&&y.searchParams.append("settlementType",K),V&&y.searchParams.append("lockAmount","true"),u===!1&&y.searchParams.append("usePermit","false"),p&&y.searchParams.append("transactionSigner",p),m===!0&&y.searchParams.append("authOnly","true"),S&&y.searchParams.append("jwtToken",S),I&&y.searchParams.append("origins",Le.compressToEncodedURIComponent(JSON.stringify(I))),L&&y.searchParams.append("threeDsChallengePreference",L),c&&y.searchParams.append("destinationAuthKey",c),y.toString()}static getTransaction(t){if(t.blockchain)return this.byBlockchain(t.blockchain,{solana:()=>{if(!("transaction"in t))return;const{transaction:e}=t;if(!Pn)throw new Error("@solana/web3.js dependency is required for Solana");if(!rr)throw new Error("bs58 dependency is required for Solana");if(e)return rr.encode(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Le.compressToEncodedURIComponent(JSON.stringify(e))},eth:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Le.compressToEncodedURIComponent(JSON.stringify(e))},base:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Le.compressToEncodedURIComponent(JSON.stringify(e))},arbitrum:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Le.compressToEncodedURIComponent(JSON.stringify(e))},near:()=>{if(!("action"in t))return;const{action:e}=t;return Le.compressToEncodedURIComponent(JSON.stringify(e))},user:()=>{}})()}static byBlockchain(t,e){switch(t){case"solana":return e.solana;case"near":return e.near;case"polygon":return e.polygon;case"eth":return e.eth;case"base":return e.base;case"arbitrum":return e.arbitrum;case"user":return e.user;default:throw new Error("blockchain not supported!")}}}var ba=(n=>(n.SignMessage="signMessage",n.SignTransaction="signTransaction",n.SendTransaction="sendTransaction",n.HeightChange="heightChange",n.Success="success",n.Loaded="loaded",n))(ba||{});function Ln(n){let t;if("signer"in n&&typeof n.signer=="object"&&n.signer&&"wallet"in n.signer?t=n.signer.wallet:"wallet"in n&&n.wallet&&(t=n.wallet),!!t){if(typeof t=="string")return t;if(typeof t=="object"){if("publicKey"in t)return t.publicKey?t.publicKey.toString():void 0;if("address"in t)return t.address?t.address:void 0;if("accountId"in t)return t.accountId?t.accountId:void 0}return null}}function ka(n,t){let e;try{if(e=JSON.parse(n),!("method"in e)||!("data"in e))return}catch(i){console.error("handleIFrameMessage JSON parse",i);return}const{data:r,method:s}=e;switch(s){case"signMessage":return t.handleSignMessage?t.handleSignMessage(r):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(r):void 0;case"sendTransaction":return t.handleSendTransaction(r);case"heightChange":return t.handleHeightChange?t.handleHeightChange(r):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(e.info);return;case"loaded":return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${s} is not one of ${Object.values(ba)}`)}function On(n){let t,e;return"signer"in n&&typeof n.signer=="object"&&n.signer&&"blockchain"in n.signer&&"wallet"in n.signer?(t=n.signer.blockchain,e=n.signer.wallet):"blockchain"in n&&n.blockchain&&(t=n.blockchain,e=n.wallet),t?De.byBlockchain(t,{solana:()=>mh({wallet:e,onSuccess:n.onSuccess}),near:()=>wh({wallet:e,onSuccess:n.onSuccess}),eth:()=>Un({wallet:e,onSuccess:n.onSuccess}),polygon:()=>Un({wallet:e,onSuccess:n.onSuccess}),base:()=>Un({wallet:e,onSuccess:n.onSuccess}),arbitrum:()=>Un({wallet:e,onSuccess:n.onSuccess}),user:()=>bh(n)})():{handleSendTransaction:()=>{throw new Error("handleSendTransaction Not Implemented")},handleSignMessage:()=>{throw new Error("handleSendTransaction Not Implemented")},handleSignTransaction:()=>{throw new Error("handleSendTransaction Not Implemented")},onSuccess:n.onSuccess}}function mh({wallet:n,onSuccess:t}){return{handleSendTransaction:async e=>{const r=va(e);return await n.sendTransaction(r)},handleSignMessage:async e=>{const r=n.signMessage;if(!r)throw new Error("signMessage is not supported by this wallet");const s=await r(new TextEncoder().encode(e));if(!rr)throw new Error("bs58 dependency is required");return rr.encode(s)},handleSignTransaction:async e=>{const r=n.signTransaction;if(!r)throw new Error("signTransaction is not supported by this wallet");const s=va(e),i=await r(s);if(!rr)throw new Error("bs58 dependency is required");return rr.encode(i.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t}}function va(n){if(!Pn)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!rr)throw new Error("bs58 is not defined. Please install bs58 into your project");const t=rr.decode(n),e=Pn.VersionedTransaction.deserialize(t);return e.version==="legacy"?Pn.Transaction.from(t):e}function wh({wallet:n,onSuccess:t}){return{handleSendTransaction:async e=>{const r=JSON.parse(Buffer.from(e,"base64").toString()),s=await n.signAndSendTransaction(r);if(!s)throw new Error("Transaction did not send");const{transaction:i}=s;return i.hash},onSuccess:t}}function Un({wallet:n,onSuccess:t}){return{handleSendTransaction:async e=>{const r=JSON.parse(Buffer.from(e,"base64").toString()),{hash:s}=await n.sendTransaction(r);return s},handleSignMessage:async e=>n.signMessage(e),onSuccess:t}}function bh({onSuccess:n}){return{handleSendTransaction:async()=>Promise.resolve(""),onSuccess:n}}const Qr="tokenExCardNumber",Or="tokenExCardCvv",Sa={[br.VISA]:"visa",[br.MASTERCARD]:"masterCard",[br.AMEX]:"americanExpress",[br.DISCOVER]:"discover"};async function xa(n){const{token:t,origins:e,env:r}=n;return new Promise((s,i)=>{fetch(new De(r).url+"/api/checkout/v2/authentication-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:e,token:t,merchantId:"merchantId"in n?n.merchantId:void 0,checkoutJwt:"checkoutJwt"in n?n.checkoutJwt:void 0})}).then(async o=>{s(await o.json())}).catch(o=>i(o))})}function Gi({env:n,setTokenExScriptLoaded:t}){const e="tokenex-script";document.head.querySelector(`#${e}`)&&t(!0);const r=document.createElement("script");r.src=n==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",r.id=e,document.head.appendChild(r),document.getElementById(e).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),t(!0)})}function kh({iframe:n,setCachedToken:t,setLoaded:e}){const r=async()=>(n.tokenize(),await new Promise((s,i)=>{n.on("tokenize",o=>{t(o.token),s(o)}),n.on("validate",o=>{(!o.isValid||o.isCvvValid===!1)&&i(o)})}));return n.on("change",()=>t(void 0)),n.on("cvvChange",()=>t(void 0)),n.on("load",()=>{setTimeout(()=>e(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),n.on("focus",()=>{n.focus()}),n.on("cvvFocus",()=>{n.cvvFocus()}),e(!1),n.load(),{...n,tokenize:r}}async function Ia(n){const{token:t,cardType:e}=n;return await Zi(Or,n,{cvvOnly:!0,cvv:!0,cvvContainerID:Or,placeholder:"CVV",token:t,cardType:Sa[e]})}async function Ea(n){return await Zi(Qr,n,{cvv:!0,cvvContainerID:Or,cvvPlaceholder:"CVV"})}async function _a(n){return await Zi(Qr,n,{cvv:!1})}async function Zi(n,t,e){const{tokenExScriptLoaded:r,css:s,debug:i,font:o,setCachedToken:a,setLoaded:h}=t;if(!r&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const g=await xa({...t,token:e.token}),{styles:w}=vh(s),k={...g,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:w,font:o,debug:i??!1,...e},M=TokenEx.Iframe(n,k);return kh({iframe:M,setCachedToken:a,setLoaded:h})}function vh(n){var r,s,i;const t=JSON.parse(n);return{styles:{base:nr(t.base),focus:nr(t.focus),error:nr(t.error),placeholder:nr(t.placeholder),cvv:{base:nr((r=t.cvv)==null?void 0:r.base),focus:nr((s=t.cvv)==null?void 0:s.focus),error:nr((i=t.cvv)==null?void 0:i.error),placeholder:nr(t==null?void 0:t.placeholder)}}}}function nr(n){if(!n)return"";if(typeof n=="string")return n;let t="";for(const[e,r]of Object.entries(n)){let s="";e.split("").forEach(i=>{i.toUpperCase()===i?s+="-"+i.toLowerCase():s+=i}),t+=s+":"+r+";"}return t}const Sh=et.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return De.getCoinflowUrl(this.args)}},emits:{onMessage(n){return!0}},methods:{sendMessage(n){const t=this.$refs.iframeRef;if(!(t!=null&&t.contentWindow))throw new Error("Iframe not defined");t.contentWindow.postMessage(n,"*")},handleIframeMessages({data:n,origin:t}){if(!t.includes(De.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:n,origin:t});const e=ka(n,this.args);e&&e.then(this.sendMessage).catch(r=>{console.error(r),this.sendMessage("ERROR "+r.message)})},async listenForMessage(n){let t;return new Promise((e,r)=>{if(t=({data:s,origin:i})=>{if(i.includes(De.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){r(new Error(s.replace("ERROR","")));return}n(s)&&e(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",t)}).finally(()=>{window.removeEventListener("message",t)})},async sendAndReceiveMessage(n,t){return this.sendMessage(n),this.listenForMessage(t)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Yi=(n,t)=>{const e=n.__vccOpts||n;for(const[r,s]of t)e[r]=s;return e},xh=["src","scrolling"];function Ih(n,t,e,r,s,i){return et.openBlock(),et.createElementBlock("iframe",{style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera;clipboard-write",title:"withdraw",frameBorder:"0",src:n.url,scrolling:n.args.handleHeightChange?"no":"yes",onLoad:t[0]||(t[0]=()=>{const o=n.$refs.iframeRef;o&&(o.style.opacity="1")})},null,40,xh)}const Nn=Yi(Sh,[["render",Ih]]),Eh=et.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:Nn},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const n=Ln(this.args);return{...this.args,walletPubkey:n,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...On(this.args),handleHeightChange:this.args.handleHeightChange}}}});function _h(n,t,e,r,s,i){const o=et.resolveComponent("coinflow-i-frame");return et.openBlock(),et.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers}},null,8,["args"])}const Bh=Yi(Eh,[["render",_h]]),Ah=et.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:Nn},props:{args:{type:Object,required:!0}},computed:{iframeProps(){const n=Ln(this.args);return{...this.args,walletPubkey:n,route:`/purchase-v2/${this.args.merchantId}`,transaction:De.getTransaction(this.args)}},messageHandlers(){return{...On(this.args),handleHeightChange:this.args.handleHeightChange}}}});function Rh(n,t,e,r,s,i){const o=et.resolveComponent("coinflow-i-frame");return et.openBlock(),et.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers}},null,8,["args"])}const Th=Yi(Ah,[["render",Rh]]),Ji=n=>{const t=et.ref(!1),e=et.ref(!1),r=et.ref(void 0),s=et.ref(void 0);et.onMounted(()=>{Gi({env:n.env,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),e.value=!0}})});const i=k=>s.value=k,o=()=>t.value=!0,a=k=>r.value=k,h=async k=>{const M=await Ia({...n,...k,tokenExScriptLoaded:e.value,setCachedToken:i,setLoaded:o});return a(M),M},g=async k=>{const M=await Ea({...n,...k,tokenExScriptLoaded:e.value,setCachedToken:i,setLoaded:o});return a(M),M},w=async k=>{const M=await _a({...n,...k,tokenExScriptLoaded:e.value,setCachedToken:i,setLoaded:o});return a(M),M};return et.watchEffect(k=>{r.value&&(r.value.load(),k(()=>{var M;return(M=r.value)==null?void 0:M.remove()}))}),{tokenExIframe:r,initializeTokenExIframe:g,initializeCvvOnlyTokenExIframe:h,initializeTokenExCardOnlyIframe:w,loaded:t,cachedToken:s,setTokenExScriptTag:Gi,tokenExScriptLoaded:e}},Mh=["id"],Ph=et.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{initializeTokenExIframe:e,tokenExIframe:r}=Ji(n.args);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return et.watchEffect(()=>{e({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Qr)},null,8,Mh))}}),Ch=["id"],Lh=et.defineComponent({__name:"CoinflowCvvInput",setup(n){return(t,e)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Or)},null,8,Ch))}}),Oh=["id"],Uh=et.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{initializeCvvOnlyTokenExIframe:e,tokenExIframe:r}=Ji(n.args);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return et.watchEffect(()=>{e({...n.args,origins:n.args.origins??[],css:i(),font:n.args.font})},{}),(o,a)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Or)},null,8,Oh))}}),Nh=et.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(n){const t=et.ref(void 0);et.onMounted(()=>new De(n.args.env).getNSurePartnerId(n.args.merchantId).then(s=>t.value=s));function e(){return n.args.env==="prod"?"9JBW2RHC7JNJN8ZQ":"SANDBOX_CTCE4XK53ZW0R7V1"}function r(){return n.args.env==="prod"?"https://sdk.nsureapi.com/sdk.js":"https://sdk.nsureapi.com/sdk-sandbox.js"}return et.watchEffect(s=>{if(!t.value)return;const i=document.createElement("script");i.src=r(),document.head.appendChild(i);const o=`window.nSureAsyncInit = function(deviceId) {
14
14
  window.nSureSDK.init({
15
15
  appId: '${e()}',
16
16
  partnerId: '${t.value}',
17
17
  });
18
- };`,a=document.createElement("script");a.innerHTML=o,document.head.appendChild(a),s(()=>{document.head.removeChild(i),document.head.removeChild(a)})}),(s,i)=>null}}),_d=["id"],Id=ft.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{tokenExIframe:e,initializeTokenExCardOnlyIframe:r}=Ao(n.args.env);async function s(){if(!e.value)throw new Error("Unable to get token");return e.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return ft.watchEffect(()=>{r({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(ft.openBlock(),ft.createElementBlock("div",{id:ft.unref(xi)},null,8,_d))}}),Ad={style:{position:"relative",height:"100%"}},Bd={style:{position:"relative",zIndex:10,height:"100%"}},Qc=ft.defineComponent({__name:"MobileWalletButton",props:{args:{type:Object,required:!0},route:{type:String,required:!0},overlayDisplayOverride:{type:String,required:!1},alignItems:{type:String,required:!1}},setup(n){const{onSuccess:t}=n.args;function e(){const a=ns(n.args);return{...n.args,walletPubkey:a,transaction:void 0,routePrefix:"form",route:`/${n.route}/${n.args.merchantId}`}}function r(){return{...is(n.args),handleHeightChange:n.args.handleHeightChange}}const s=ft.ref(.8),i=ft.ref("flex");function o({data:a}){var l,y;try{const x=JSON.parse(a);if("method"in x&&x.method==="loaded"&&(s.value=1,setTimeout(()=>{i.value="none"},2e3)),"method"in x&&x.data.startsWith("ERROR"))return(y=(l=n.args)==null?void 0:l.onError)==null||y.call(l,x.info),!1;if(!("method"in x)||x.method!=="getToken")return}catch{return}t==null||t(a)}return(a,l)=>(ft.openBlock(),ft.createElementBlock("div",Ad,[ft.createElementVNode("div",{style:ft.normalizeStyle({backgroundColor:n.args.color,display:n.overlayDisplayOverride??i.value,opacity:s.value,alignItems:n.alignItems,width:"100%",height:"40px",position:"absolute",top:0,bottom:0,left:0,zIndex:20,justifyContent:"center",pointerEvents:"none"})},[ft.renderSlot(a.$slots,"default")],4),ft.createElementVNode("div",Bd,[ft.createVNode(os,{onOnMessage:o,args:{...e(),...r()}},null,8,["args"])])]))}}),Rd={id:"svg-logo",viewBox:"0 0 35 15"},Td={id:"svg-logo",x:"0",y:"3.85",height:"7.3",width:"35",className:"logo",viewBox:"0 0 105 43",version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},Md={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},Pd=["fill"],Cd=ft.defineComponent({__name:"ApplePayOverlay",props:{color:{type:String,required:!0}},setup(n){const t=n.color==="white"?"#000":"#FFF";return(e,r)=>(ft.openBlock(),ft.createElementBlock("svg",Rd,[(ft.openBlock(),ft.createElementBlock("svg",Td,[r[1]||(r[1]=ft.createElementVNode("title",null,"Apple Logo",-1)),ft.createElementVNode("g",Md,[ft.createElementVNode("g",{fill:ft.unref(t)},r[0]||(r[0]=[ft.createStaticVNode('<path d="M19.4028,5.5674 C20.6008,4.0684 21.4138,2.0564 21.1998,0.0004 C19.4458,0.0874 17.3058,1.1574 16.0668,2.6564 C14.9538,3.9414 13.9688,6.0374 14.2258,8.0074 C16.1948,8.1784 18.1618,7.0244 19.4028,5.5674"></path><path d="M21.1772,8.3926 C18.3182,8.2226 15.8872,10.0156 14.5212,10.0156 C13.1552,10.0156 11.0642,8.4786 8.8022,8.5196 C5.8592,8.5626 3.1282,10.2276 1.6342,12.8746 C-1.4378,18.1696 0.8232,26.0246 3.8112,30.3376 C5.2622,32.4716 7.0102,34.8206 9.3142,34.7366 C11.4912,34.6506 12.3442,33.3266 14.9902,33.3266 C17.6352,33.3266 18.4042,34.7366 20.7082,34.6936 C23.0972,34.6506 24.5922,32.5586 26.0422,30.4226 C27.7072,27.9906 28.3882,25.6426 28.4312,25.5126 C28.3882,25.4706 23.8232,23.7186 23.7812,18.4676 C23.7382,14.0706 27.3652,11.9786 27.5362,11.8496 C25.4882,8.8196 22.2872,8.4786 21.1772,8.3926"></path><path d="M85.5508,43.0381 L85.5508,39.1991 C85.8628,39.2421 86.6158,39.2871 87.0158,39.2871 C89.2138,39.2871 90.4558,38.3551 91.2108,35.9581 L91.6548,34.5371 L83.2428,11.2321 L88.4368,11.2321 L94.2958,30.1421 L94.4068,30.1421 L100.2668,11.2321 L105.3278,11.2321 L96.6048,35.7141 C94.6078,41.3291 92.3208,43.1721 87.4828,43.1721 C87.1048,43.1721 85.8838,43.1271 85.5508,43.0381"></path><path d="M42.6499,19.3555 L48.3549,19.3555 C52.6829,19.3555 55.1469,17.0255 55.1469,12.9855 C55.1469,8.9455 52.6829,6.6375 48.3769,6.6375 L42.6499,6.6375 L42.6499,19.3555 Z M49.6869,2.4425 C55.9009,2.4425 60.2289,6.7265 60.2289,12.9625 C60.2289,19.2225 55.8129,23.5285 49.5309,23.5285 L42.6499,23.5285 L42.6499,34.4705 L37.6779,34.4705 L37.6779,2.4425 L49.6869,2.4425 Z"></path><path d="M76.5547,25.7705 L76.5547,23.9715 L71.0287,24.3275 C67.9207,24.5275 66.3007,25.6815 66.3007,27.7015 C66.3007,29.6545 67.9887,30.9195 70.6287,30.9195 C74.0027,30.9195 76.5547,28.7665 76.5547,25.7705 M61.4617,27.8345 C61.4617,23.7285 64.5917,21.3755 70.3627,21.0205 L76.5547,20.6425 L76.5547,18.8675 C76.5547,16.2705 74.8457,14.8495 71.8057,14.8495 C69.2967,14.8495 67.4777,16.1375 67.0997,18.1125 L62.6167,18.1125 C62.7497,13.9615 66.6567,10.9435 71.9387,10.9435 C77.6207,10.9435 81.3267,13.9175 81.3267,18.5345 L81.3267,34.4705 L76.7327,34.4705 L76.7327,30.6305 L76.6217,30.6305 C75.3127,33.1395 72.4267,34.7145 69.2967,34.7145 C64.6807,34.7145 61.4617,31.9625 61.4617,27.8345"></path>',5)]),8,Pd)])]))]))}}),Ld=ft.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(ft.openBlock(),ft.createBlock(Qc,{route:"apple-pay",args:n.args},{default:ft.withCtx(()=>[ft.createVNode(Cd,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}}),Ud={key:0,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Od={key:1,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Nd=ft.defineComponent({__name:"GooglePayOverlay",props:{color:{type:String,required:!0}},setup(n){return(t,e)=>(ft.openBlock(),ft.createElementBlock(ft.Fragment,null,[n.color==="white"?(ft.openBlock(),ft.createElementBlock("svg",Ud,e[0]||(e[0]=[ft.createStaticVNode('<g fill="none" fill-rule="evenodd"><path d="M19.526 2.635v4.083h2.518c.6 0 1.096-.202 1.488-.605.403-.402.605-.882.605-1.437 0-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0 5.52v4.736h-1.504V1.198h3.99c1.013 0 1.873.337 2.582 1.012.72.675 1.08 1.497 1.08 2.466 0 .991-.36 1.819-1.08 2.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668 2.287c0 .392.166.718.499.98.332.26.722.391 1.168.391.633 0 1.196-.234 1.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61 0-1.12.148-1.528.442-.409.294-.613.657-.613 1.093m1.946-5.815c1.112 0 1.989.297 2.633.89.642.594.964 1.408.964 2.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45 1.372-2.486 1.372-.882 0-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96 0-.828.313-1.486.94-1.976s1.463-.735 2.51-.735c.892 0 1.629.163 2.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132 2.132 0 0 0-1.455-.547c-.84 0-1.504.353-1.995 1.062l-1.324-.834c.73-1.045 1.81-1.568 3.238-1.568m11.853.262l-5.02 11.53H34.42l1.864-4.034-3.302-7.496h1.635l2.387 5.749h.032l2.322-5.75z" fill="#5F6368"></path><path d="M13.448 7.134c0-.473-.04-.93-.116-1.366H6.988v2.588h3.634a3.11 3.11 0 0 1-1.344 2.042v1.68h2.169c1.27-1.17 2.001-2.9 2.001-4.944" fill="#4285F4"></path><path d="M6.988 13.7c1.816 0 3.344-.595 4.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754 0-3.244-1.182-3.776-2.774H.978v1.731a6.728 6.728 0 0 0 6.01 3.703" fill="#34A853"></path><path d="M3.212 8.267a4.034 4.034 0 0 1 0-2.572V3.964H.978A6.678 6.678 0 0 0 .261 6.98c0 1.085.26 2.11.717 3.017l2.234-1.731z" fill="#FABB05"></path><path d="M6.988 2.921c.992 0 1.88.34 2.58 1.008v.001l1.92-1.918C10.324.928 8.804.262 6.989.262a6.728 6.728 0 0 0-6.01 3.702l2.234 1.731c.532-1.592 2.022-2.774 3.776-2.774" fill="#E94235"></path><path d="M0 0h41.285v18H0z"></path></g>',1)]))):ft.createCommentVNode("",!0),n.color==="black"?(ft.openBlock(),ft.createElementBlock("svg",Od,e[1]||(e[1]=[ft.createStaticVNode('<g fill="none" fill-rule="evenodd"><path d="M19.526 2.635v4.083h2.518c.6 0 1.096-.202 1.488-.605.403-.402.605-.882.605-1.437 0-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0 5.52v4.736h-1.504V1.198h3.99c1.013 0 1.873.337 2.582 1.012.72.675 1.08 1.497 1.08 2.466 0 .991-.36 1.819-1.08 2.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668 2.287c0 .392.166.718.499.98.332.26.722.391 1.168.391.633 0 1.196-.234 1.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61 0-1.12.148-1.528.442-.409.294-.613.657-.613 1.093m1.946-5.815c1.112 0 1.989.297 2.633.89.642.594.964 1.408.964 2.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45 1.372-2.486 1.372-.882 0-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96 0-.828.313-1.486.94-1.976s1.463-.735 2.51-.735c.892 0 1.629.163 2.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132 2.132 0 0 0-1.455-.547c-.84 0-1.504.353-1.995 1.062l-1.324-.834c.73-1.045 1.81-1.568 3.238-1.568m11.853.262l-5.02 11.53H34.42l1.864-4.034-3.302-7.496h1.635l2.387 5.749h.032l2.322-5.75z" fill="#FFF"></path><path d="M13.448 7.134c0-.473-.04-.93-.116-1.366H6.988v2.588h3.634a3.11 3.11 0 0 1-1.344 2.042v1.68h2.169c1.27-1.17 2.001-2.9 2.001-4.944" fill="#4285F4"></path><path d="M6.988 13.7c1.816 0 3.344-.595 4.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754 0-3.244-1.182-3.776-2.774H.978v1.731a6.728 6.728 0 0 0 6.01 3.703" fill="#34A853"></path><path d="M3.212 8.267a4.034 4.034 0 0 1 0-2.572V3.964H.978A6.678 6.678 0 0 0 .261 6.98c0 1.085.26 2.11.717 3.017l2.234-1.731z" fill="#FABB05"></path><path d="M6.988 2.921c.992 0 1.88.34 2.58 1.008v.001l1.92-1.918C10.324.928 8.804.262 6.989.262a6.728 6.728 0 0 0-6.01 3.702l2.234 1.731c.532-1.592 2.022-2.774 3.776-2.774" fill="#E94235"></path></g>',1)]))):ft.createCommentVNode("",!0)],64))}}),Fd=ft.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(ft.openBlock(),ft.createBlock(Qc,{route:"google-pay",args:n.args,overlayDisplayOverride:"flex",alignItems:"center"},{default:ft.withCtx(()=>[ft.createVNode(Nd,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}});se.CARD_TYPE_MAPPING=Gc,se.CardType=On,se.CoinflowApplePayButton=Ld,se.CoinflowCardNumberInput=bd,se.CoinflowCardNumberOnlyInput=Id,se.CoinflowCvvInput=vd,se.CoinflowCvvOnlyInput=Sd,se.CoinflowGooglePayButton=Fd,se.CoinflowIframe=os,se.CoinflowPurchase=md,se.CoinflowPurchaseProtection=Ed,se.CoinflowUtils=en,se.CoinflowWithdraw=pd,se.MerchantStyle=Bo,se.SettlementType=wn,se.ThreeDsChallengePreference=Ro,se.TokenExCardNumberIframeId=xi,se.TokenExCvvContainerID=ei,se.doInitializeCvvOnlyTokenExIframe=Zc,se.doInitializeTokenExCardOnlyIframe=Xc,se.doInitializeTokenExIframe=Jc,se.getHandlers=is,se.getIframeConfig=Yc,se.getWalletPubkey=ns,se.handleIFrameMessage=Vc,se.setTokenExScriptTag=Eo,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})});
18
+ };`,a=document.createElement("script");a.innerHTML=o,document.head.appendChild(a),s(()=>{document.head.removeChild(i),document.head.removeChild(a)})}),(s,i)=>null}}),Fh=["id"],zh=et.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{tokenExIframe:e,initializeTokenExCardOnlyIframe:r}=Ji(n.args);async function s(){if(!e.value)throw new Error("Unable to get token");return e.value.tokenize()}t({getToken:s});function i(){return JSON.stringify(n.args.css)}return et.watchEffect(()=>{r({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Qr)},null,8,Fh))}}),qh={style:{position:"relative",height:"100%"}},Kh={style:{position:"relative",zIndex:10,height:"100%"}},Ba=et.defineComponent({__name:"MobileWalletButton",props:{args:{type:Object,required:!0},route:{type:String,required:!0},overlayDisplayOverride:{type:String,required:!1},alignItems:{type:String,required:!1}},setup(n){const{onSuccess:t}=n.args;function e(){const a=Ln(n.args);return{...n.args,walletPubkey:a,transaction:void 0,routePrefix:"form",route:`/${n.route}/${n.args.merchantId}`}}function r(){return{...On(n.args),handleHeightChange:n.args.handleHeightChange}}const s=et.ref(.8),i=et.ref("flex");function o({data:a}){var h,g;try{const w=JSON.parse(a);if("method"in w&&w.method==="loaded"&&(s.value=1,setTimeout(()=>{i.value="none"},2e3)),"method"in w&&w.data.startsWith("ERROR"))return(g=(h=n.args)==null?void 0:h.onError)==null||g.call(h,w.info),!1;if(!("method"in w)||w.method!=="getToken")return}catch{return}t==null||t(a)}return(a,h)=>(et.openBlock(),et.createElementBlock("div",qh,[et.createElementVNode("div",{style:et.normalizeStyle({backgroundColor:n.args.color,display:n.overlayDisplayOverride??i.value,opacity:s.value,alignItems:n.alignItems,width:"100%",height:"40px",position:"absolute",top:0,bottom:0,left:0,zIndex:20,justifyContent:"center",pointerEvents:"none"})},[et.renderSlot(a.$slots,"default")],4),et.createElementVNode("div",Kh,[et.createVNode(Nn,{onOnMessage:o,args:{...e(),...r()}},null,8,["args"])])]))}}),Wh={id:"svg-logo",viewBox:"0 0 35 15"},Dh={id:"svg-logo",x:"0",y:"3.85",height:"7.3",width:"35",className:"logo",viewBox:"0 0 105 43",version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},$h={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},Hh=["fill"],Vh=et.defineComponent({__name:"ApplePayOverlay",props:{color:{type:String,required:!0}},setup(n){const t=n.color==="white"?"#000":"#FFF";return(e,r)=>(et.openBlock(),et.createElementBlock("svg",Wh,[(et.openBlock(),et.createElementBlock("svg",Dh,[r[1]||(r[1]=et.createElementVNode("title",null,"Apple Logo",-1)),et.createElementVNode("g",$h,[et.createElementVNode("g",{fill:et.unref(t)},r[0]||(r[0]=[et.createStaticVNode('<path d="M19.4028,5.5674 C20.6008,4.0684 21.4138,2.0564 21.1998,0.0004 C19.4458,0.0874 17.3058,1.1574 16.0668,2.6564 C14.9538,3.9414 13.9688,6.0374 14.2258,8.0074 C16.1948,8.1784 18.1618,7.0244 19.4028,5.5674"></path><path d="M21.1772,8.3926 C18.3182,8.2226 15.8872,10.0156 14.5212,10.0156 C13.1552,10.0156 11.0642,8.4786 8.8022,8.5196 C5.8592,8.5626 3.1282,10.2276 1.6342,12.8746 C-1.4378,18.1696 0.8232,26.0246 3.8112,30.3376 C5.2622,32.4716 7.0102,34.8206 9.3142,34.7366 C11.4912,34.6506 12.3442,33.3266 14.9902,33.3266 C17.6352,33.3266 18.4042,34.7366 20.7082,34.6936 C23.0972,34.6506 24.5922,32.5586 26.0422,30.4226 C27.7072,27.9906 28.3882,25.6426 28.4312,25.5126 C28.3882,25.4706 23.8232,23.7186 23.7812,18.4676 C23.7382,14.0706 27.3652,11.9786 27.5362,11.8496 C25.4882,8.8196 22.2872,8.4786 21.1772,8.3926"></path><path d="M85.5508,43.0381 L85.5508,39.1991 C85.8628,39.2421 86.6158,39.2871 87.0158,39.2871 C89.2138,39.2871 90.4558,38.3551 91.2108,35.9581 L91.6548,34.5371 L83.2428,11.2321 L88.4368,11.2321 L94.2958,30.1421 L94.4068,30.1421 L100.2668,11.2321 L105.3278,11.2321 L96.6048,35.7141 C94.6078,41.3291 92.3208,43.1721 87.4828,43.1721 C87.1048,43.1721 85.8838,43.1271 85.5508,43.0381"></path><path d="M42.6499,19.3555 L48.3549,19.3555 C52.6829,19.3555 55.1469,17.0255 55.1469,12.9855 C55.1469,8.9455 52.6829,6.6375 48.3769,6.6375 L42.6499,6.6375 L42.6499,19.3555 Z M49.6869,2.4425 C55.9009,2.4425 60.2289,6.7265 60.2289,12.9625 C60.2289,19.2225 55.8129,23.5285 49.5309,23.5285 L42.6499,23.5285 L42.6499,34.4705 L37.6779,34.4705 L37.6779,2.4425 L49.6869,2.4425 Z"></path><path d="M76.5547,25.7705 L76.5547,23.9715 L71.0287,24.3275 C67.9207,24.5275 66.3007,25.6815 66.3007,27.7015 C66.3007,29.6545 67.9887,30.9195 70.6287,30.9195 C74.0027,30.9195 76.5547,28.7665 76.5547,25.7705 M61.4617,27.8345 C61.4617,23.7285 64.5917,21.3755 70.3627,21.0205 L76.5547,20.6425 L76.5547,18.8675 C76.5547,16.2705 74.8457,14.8495 71.8057,14.8495 C69.2967,14.8495 67.4777,16.1375 67.0997,18.1125 L62.6167,18.1125 C62.7497,13.9615 66.6567,10.9435 71.9387,10.9435 C77.6207,10.9435 81.3267,13.9175 81.3267,18.5345 L81.3267,34.4705 L76.7327,34.4705 L76.7327,30.6305 L76.6217,30.6305 C75.3127,33.1395 72.4267,34.7145 69.2967,34.7145 C64.6807,34.7145 61.4617,31.9625 61.4617,27.8345"></path>',5)]),8,Hh)])]))]))}}),jh=et.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(et.openBlock(),et.createBlock(Ba,{route:"apple-pay",args:n.args},{default:et.withCtx(()=>[et.createVNode(Vh,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}}),Gh={key:0,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Zh={key:1,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Yh=et.defineComponent({__name:"GooglePayOverlay",props:{color:{type:String,required:!0}},setup(n){return(t,e)=>(et.openBlock(),et.createElementBlock(et.Fragment,null,[n.color==="white"?(et.openBlock(),et.createElementBlock("svg",Gh,e[0]||(e[0]=[et.createStaticVNode('<g fill="none" fill-rule="evenodd"><path d="M19.526 2.635v4.083h2.518c.6 0 1.096-.202 1.488-.605.403-.402.605-.882.605-1.437 0-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0 5.52v4.736h-1.504V1.198h3.99c1.013 0 1.873.337 2.582 1.012.72.675 1.08 1.497 1.08 2.466 0 .991-.36 1.819-1.08 2.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668 2.287c0 .392.166.718.499.98.332.26.722.391 1.168.391.633 0 1.196-.234 1.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61 0-1.12.148-1.528.442-.409.294-.613.657-.613 1.093m1.946-5.815c1.112 0 1.989.297 2.633.89.642.594.964 1.408.964 2.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45 1.372-2.486 1.372-.882 0-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96 0-.828.313-1.486.94-1.976s1.463-.735 2.51-.735c.892 0 1.629.163 2.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132 2.132 0 0 0-1.455-.547c-.84 0-1.504.353-1.995 1.062l-1.324-.834c.73-1.045 1.81-1.568 3.238-1.568m11.853.262l-5.02 11.53H34.42l1.864-4.034-3.302-7.496h1.635l2.387 5.749h.032l2.322-5.75z" fill="#5F6368"></path><path d="M13.448 7.134c0-.473-.04-.93-.116-1.366H6.988v2.588h3.634a3.11 3.11 0 0 1-1.344 2.042v1.68h2.169c1.27-1.17 2.001-2.9 2.001-4.944" fill="#4285F4"></path><path d="M6.988 13.7c1.816 0 3.344-.595 4.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754 0-3.244-1.182-3.776-2.774H.978v1.731a6.728 6.728 0 0 0 6.01 3.703" fill="#34A853"></path><path d="M3.212 8.267a4.034 4.034 0 0 1 0-2.572V3.964H.978A6.678 6.678 0 0 0 .261 6.98c0 1.085.26 2.11.717 3.017l2.234-1.731z" fill="#FABB05"></path><path d="M6.988 2.921c.992 0 1.88.34 2.58 1.008v.001l1.92-1.918C10.324.928 8.804.262 6.989.262a6.728 6.728 0 0 0-6.01 3.702l2.234 1.731c.532-1.592 2.022-2.774 3.776-2.774" fill="#E94235"></path><path d="M0 0h41.285v18H0z"></path></g>',1)]))):et.createCommentVNode("",!0),n.color==="black"?(et.openBlock(),et.createElementBlock("svg",Zh,e[1]||(e[1]=[et.createStaticVNode('<g fill="none" fill-rule="evenodd"><path d="M19.526 2.635v4.083h2.518c.6 0 1.096-.202 1.488-.605.403-.402.605-.882.605-1.437 0-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0 5.52v4.736h-1.504V1.198h3.99c1.013 0 1.873.337 2.582 1.012.72.675 1.08 1.497 1.08 2.466 0 .991-.36 1.819-1.08 2.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668 2.287c0 .392.166.718.499.98.332.26.722.391 1.168.391.633 0 1.196-.234 1.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61 0-1.12.148-1.528.442-.409.294-.613.657-.613 1.093m1.946-5.815c1.112 0 1.989.297 2.633.89.642.594.964 1.408.964 2.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45 1.372-2.486 1.372-.882 0-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96 0-.828.313-1.486.94-1.976s1.463-.735 2.51-.735c.892 0 1.629.163 2.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132 2.132 0 0 0-1.455-.547c-.84 0-1.504.353-1.995 1.062l-1.324-.834c.73-1.045 1.81-1.568 3.238-1.568m11.853.262l-5.02 11.53H34.42l1.864-4.034-3.302-7.496h1.635l2.387 5.749h.032l2.322-5.75z" fill="#FFF"></path><path d="M13.448 7.134c0-.473-.04-.93-.116-1.366H6.988v2.588h3.634a3.11 3.11 0 0 1-1.344 2.042v1.68h2.169c1.27-1.17 2.001-2.9 2.001-4.944" fill="#4285F4"></path><path d="M6.988 13.7c1.816 0 3.344-.595 4.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754 0-3.244-1.182-3.776-2.774H.978v1.731a6.728 6.728 0 0 0 6.01 3.703" fill="#34A853"></path><path d="M3.212 8.267a4.034 4.034 0 0 1 0-2.572V3.964H.978A6.678 6.678 0 0 0 .261 6.98c0 1.085.26 2.11.717 3.017l2.234-1.731z" fill="#FABB05"></path><path d="M6.988 2.921c.992 0 1.88.34 2.58 1.008v.001l1.92-1.918C10.324.928 8.804.262 6.989.262a6.728 6.728 0 0 0-6.01 3.702l2.234 1.731c.532-1.592 2.022-2.774 3.776-2.774" fill="#E94235"></path></g>',1)]))):et.createCommentVNode("",!0)],64))}}),Jh=et.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(et.openBlock(),et.createBlock(Ba,{route:"google-pay",args:n.args,overlayDisplayOverride:"flex",alignItems:"center"},{default:et.withCtx(()=>[et.createVNode(Yh,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}});kt.CARD_TYPE_MAPPING=Sa,kt.CardType=br,kt.CoinflowApplePayButton=jh,kt.CoinflowCardNumberInput=Ph,kt.CoinflowCardNumberOnlyInput=zh,kt.CoinflowCvvInput=Lh,kt.CoinflowCvvOnlyInput=Uh,kt.CoinflowGooglePayButton=Jh,kt.CoinflowIframe=Nn,kt.CoinflowPurchase=Th,kt.CoinflowPurchaseProtection=Nh,kt.CoinflowUtils=De,kt.CoinflowWithdraw=Bh,kt.Currency=ji,kt.MerchantStyle=ms,kt.SettlementType=ir,kt.ThreeDsChallengePreference=ws,kt.TokenExCardNumberIframeId=Qr,kt.TokenExCvvContainerID=Or,kt.doInitializeCvvOnlyTokenExIframe=Ia,kt.doInitializeTokenExCardOnlyIframe=_a,kt.doInitializeTokenExIframe=Ea,kt.getHandlers=On,kt.getIframeConfig=xa,kt.getWalletPubkey=Ln,kt.handleIFrameMessage=ka,kt.setTokenExScriptTag=Gi,Object.defineProperty(kt,Symbol.toStringTag,{value:"Module"})});