@coinflowlabs/vue 1.0.7 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/coinflow-vue.js +2314 -2298
- package/dist/coinflow-vue.umd.cjs +6 -6
- package/dist/components/CoinflowPurchase.vue.d.ts +7 -0
- package/dist/lib/common/CoinflowLibMessageHandlers.d.ts +3 -2
- package/dist/lib/common/CoinflowTypes.d.ts +3 -2
- package/dist/lib/common/CoinflowUtils.d.ts +1 -1
- package/dist/lib/common/Subtotal.d.ts +53 -4
- package/package.json +4 -4
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(pt,et){typeof exports=="object"&&typeof module<"u"?et(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],et):(pt=typeof globalThis<"u"?globalThis:pt||self,et(pt.VueTypeWriter={},pt.Vue))})(this,function(pt,et){"use strict";var ed=Object.defineProperty;var rd=(pt,et,ir)=>et in pt?ed(pt,et,{enumerable:!0,configurable:!0,writable:!0,value:ir}):pt[et]=ir;var fe=(pt,et,ir)=>rd(pt,typeof et!="symbol"?et+"":et,ir);var ir=(n=>(n.Credits="Credits",n.USDC="USDC",n.Bank="Bank",n))(ir||{}),ws=(n=>(n.Rounded="rounded",n.Sharp="sharp",n.Pill="pill",n))(ws||{}),bs=(n=>(n.NoPreference="NoPreference",n.Frictionless="Frictionless",n.Challenge="Challenge",n))(bs||{}),ks=(n=>(n.card="card",n.ach="ach",n.fasterPayments="fasterPayments",n.sepa="sepa",n.pix="pix",n.usdc="usdc",n.googlePay="googlePay",n.applePay="applePay",n.credits="credits",n.crypto="crypto",n))(ks||{}),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 Nn(n){if(Object.prototype.hasOwnProperty.call(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 Fn={},Fr={},vs;function Fa(){if(vs)return Fr;vs=1,Fr.byteLength=u,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 u(R){var C=o(R),B=C[0],T=C[1];return(B+T)*3/4-T}function f(R,C,B){return(C+B)*3/4-B}function g(R){var C,B=o(R),T=B[0],U=B[1],W=new e(f(R,T,U)),D=0,J=U>0?T-4:T,$;for($=0;$<J;$+=4)C=t[R.charCodeAt($)]<<18|t[R.charCodeAt($+1)]<<12|t[R.charCodeAt($+2)]<<6|t[R.charCodeAt($+3)],W[D++]=C>>16&255,W[D++]=C>>8&255,W[D++]=C&255;return U===2&&(C=t[R.charCodeAt($)]<<2|t[R.charCodeAt($+1)]>>4,W[D++]=C&255),U===1&&(C=t[R.charCodeAt($)]<<10|t[R.charCodeAt($+1)]<<4|t[R.charCodeAt($+2)]>>2,W[D++]=C>>8&255,W[D++]=C&255),W}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,U=[],W=C;W<B;W+=3)T=(R[W]<<16&16711680)+(R[W+1]<<8&65280)+(R[W+2]&255),U.push(w(T));return U.join("")}function M(R){for(var C,B=R.length,T=B%3,U=[],W=16383,D=0,J=B-T;D<J;D+=W)U.push(k(R,D,D+W>J?J:D+W));return T===1?(C=R[B-1],U.push(n[C>>2]+n[C<<4&63]+"==")):T===2&&(C=(R[B-2]<<8)+R[B-1],U.push(n[C>>10]+n[C>>4&63]+n[C<<2&63]+"=")),U.join("")}return Fr}var tn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var Ss;function za(){return Ss||(Ss=1,tn.read=function(n,t,e,r,s){var i,o,u=s*8-r-1,f=(1<<u)-1,g=f>>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+=u;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===f)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,u,f,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?(u=isNaN(t)?1:0,o=w):(o=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-o))<1&&(o--,f*=2),o+k>=1?t+=M/f:t+=M*Math.pow(2,1-k),t*f>=2&&(o++,f/=2),o+k>=w?(u=0,o=w):o+k>=1?(u=(t*f-1)*Math.pow(2,s),o=o+k):(u=t*Math.pow(2,k-1)*Math.pow(2,s),o=0));s>=8;n[e+R]=u&255,R+=C,u/=256,s-=8);for(o=o<<s|u,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
|
-
*/var Ss;function zn(){return Ss||(Ss=1,function(n){const t=Na(),e=Fa(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=u,n.SlowBuffer=$,n.INSPECT_MAX_BYTES=50;const s=2147483647;n.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=i(),!u.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 m=new Uint8Array(1),h={foo:function(){return 42}};return Object.setPrototypeOf(h,Uint8Array.prototype),Object.setPrototypeOf(m,h),m.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function o(m){if(m>s)throw new RangeError('The value "'+m+'" is invalid for option "size"');const h=new Uint8Array(m);return Object.setPrototypeOf(h,u.prototype),h}function u(m,h,d){if(typeof m=="number"){if(typeof h=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return k(m)}return f(m,h,d)}u.poolSize=8192;function f(m,h,d){if(typeof m=="string")return M(m,h);if(ArrayBuffer.isView(m))return C(m);if(m==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m);if(xe(m,ArrayBuffer)||m&&xe(m.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(xe(m,SharedArrayBuffer)||m&&xe(m.buffer,SharedArrayBuffer)))return _(m,h,d);if(typeof m=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const B=m.valueOf&&m.valueOf();if(B!=null&&B!==m)return u.from(B,h,d);const N=T(m);if(N)return N;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof m[Symbol.toPrimitive]=="function")return u.from(m[Symbol.toPrimitive]("string"),h,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m)}u.from=function(m,h,d){return f(m,h,d)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function g(m){if(typeof m!="number")throw new TypeError('"size" argument must be of type number');if(m<0)throw new RangeError('The value "'+m+'" is invalid for option "size"')}function w(m,h,d){return g(m),m<=0?o(m):h!==void 0?typeof d=="string"?o(m).fill(h,d):o(m).fill(h):o(m)}u.alloc=function(m,h,d){return w(m,h,d)};function k(m){return g(m),o(m<0?0:O(m)|0)}u.allocUnsafe=function(m){return k(m)},u.allocUnsafeSlow=function(m){return k(m)};function M(m,h){if((typeof h!="string"||h==="")&&(h="utf8"),!u.isEncoding(h))throw new TypeError("Unknown encoding: "+h);const d=q(m,h)|0;let B=o(d);const N=B.write(m,h);return N!==d&&(B=B.slice(0,N)),B}function R(m){const h=m.length<0?0:O(m.length)|0,d=o(h);for(let B=0;B<h;B+=1)d[B]=m[B]&255;return d}function C(m){if(xe(m,Uint8Array)){const h=new Uint8Array(m);return _(h.buffer,h.byteOffset,h.byteLength)}return R(m)}function _(m,h,d){if(h<0||m.byteLength<h)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<h+(d||0))throw new RangeError('"length" is outside of buffer bounds');let B;return h===void 0&&d===void 0?B=new Uint8Array(m):d===void 0?B=new Uint8Array(m,h):B=new Uint8Array(m,h,d),Object.setPrototypeOf(B,u.prototype),B}function T(m){if(u.isBuffer(m)){const h=O(m.length)|0,d=o(h);return d.length===0||m.copy(d,0,0,h),d}if(m.length!==void 0)return typeof m.length!="number"||Ot(m.length)?o(0):R(m);if(m.type==="Buffer"&&Array.isArray(m.data))return R(m.data)}function O(m){if(m>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return m|0}function $(m){return+m!=m&&(m=0),u.alloc(+m)}u.isBuffer=function(h){return h!=null&&h._isBuffer===!0&&h!==u.prototype},u.compare=function(h,d){if(xe(h,Uint8Array)&&(h=u.from(h,h.offset,h.byteLength)),xe(d,Uint8Array)&&(d=u.from(d,d.offset,d.byteLength)),!u.isBuffer(h)||!u.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(h===d)return 0;let B=h.length,N=d.length;for(let z=0,G=Math.min(B,N);z<G;++z)if(h[z]!==d[z]){B=h[z],N=d[z];break}return B<N?-1:N<B?1:0},u.isEncoding=function(h){switch(String(h).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}},u.concat=function(h,d){if(!Array.isArray(h))throw new TypeError('"list" argument must be an Array of Buffers');if(h.length===0)return u.alloc(0);let B;if(d===void 0)for(d=0,B=0;B<h.length;++B)d+=h[B].length;const N=u.allocUnsafe(d);let z=0;for(B=0;B<h.length;++B){let G=h[B];if(xe(G,Uint8Array))z+G.length>N.length?(u.isBuffer(G)||(G=u.from(G)),G.copy(N,z)):Uint8Array.prototype.set.call(N,G,z);else if(u.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(m,h){if(u.isBuffer(m))return m.length;if(ArrayBuffer.isView(m)||xe(m,ArrayBuffer))return m.byteLength;if(typeof m!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof m);const d=m.length,B=arguments.length>2&&arguments[2]===!0;if(!B&&d===0)return 0;let N=!1;for(;;)switch(h){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return Ct(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return zt(m).length;default:if(N)return B?-1:Ct(m).length;h=(""+h).toLowerCase(),N=!0}}u.byteLength=q;function X(m,h,d){let B=!1;if((h===void 0||h<0)&&(h=0),h>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,h>>>=0,d<=h))return"";for(m||(m="utf8");;)switch(m){case"hex":return E(this,h,d);case"utf8":case"utf-8":return c(this,h,d);case"ascii":return A(this,h,d);case"latin1":case"binary":return x(this,h,d);case"base64":return I(this,h,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,h,d);default:if(B)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),B=!0}}u.prototype._isBuffer=!0;function W(m,h,d){const B=m[h];m[h]=m[d],m[d]=B}u.prototype.swap16=function(){const h=this.length;if(h%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;d<h;d+=2)W(this,d,d+1);return this},u.prototype.swap32=function(){const h=this.length;if(h%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let d=0;d<h;d+=4)W(this,d,d+3),W(this,d+1,d+2);return this},u.prototype.swap64=function(){const h=this.length;if(h%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let d=0;d<h;d+=8)W(this,d,d+7),W(this,d+1,d+6),W(this,d+2,d+5),W(this,d+3,d+4);return this},u.prototype.toString=function(){const h=this.length;return h===0?"":arguments.length===0?c(this,0,h):X.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(h){if(!u.isBuffer(h))throw new TypeError("Argument must be a Buffer");return this===h?!0:u.compare(this,h)===0},u.prototype.inspect=function(){let h="";const d=n.INSPECT_MAX_BYTES;return h=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(h+=" ... "),"<Buffer "+h+">"},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(h,d,B,N,z){if(xe(h,Uint8Array)&&(h=u.from(h,h.offset,h.byteLength)),!u.isBuffer(h))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof h);if(d===void 0&&(d=0),B===void 0&&(B=h?h.length:0),N===void 0&&(N=0),z===void 0&&(z=this.length),d<0||B>h.length||N<0||z>this.length)throw new RangeError("out of range index");if(N>=z&&d>=B)return 0;if(N>=z)return-1;if(d>=B)return 1;if(d>>>=0,B>>>=0,N>>>=0,z>>>=0,this===h)return 0;let G=z-N,kt=B-d;const gt=Math.min(G,kt),dt=this.slice(N,z),Dt=h.slice(d,B);for(let ft=0;ft<gt;++ft)if(dt[ft]!==Dt[ft]){G=dt[ft],kt=Dt[ft];break}return G<kt?-1:kt<G?1:0};function F(m,h,d,B,N){if(m.length===0)return-1;if(typeof d=="string"?(B=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,Ot(d)&&(d=N?0:m.length-1),d<0&&(d=m.length+d),d>=m.length){if(N)return-1;d=m.length-1}else if(d<0)if(N)d=0;else return-1;if(typeof h=="string"&&(h=u.from(h,B)),u.isBuffer(h))return h.length===0?-1:Y(m,h,d,B,N);if(typeof h=="number")return h=h&255,typeof Uint8Array.prototype.indexOf=="function"?N?Uint8Array.prototype.indexOf.call(m,h,d):Uint8Array.prototype.lastIndexOf.call(m,h,d):Y(m,[h],d,B,N);throw new TypeError("val must be string, number or Buffer")}function Y(m,h,d,B,N){let z=1,G=m.length,kt=h.length;if(B!==void 0&&(B=String(B).toLowerCase(),B==="ucs2"||B==="ucs-2"||B==="utf16le"||B==="utf-16le")){if(m.length<2||h.length<2)return-1;z=2,G/=2,kt/=2,d/=2}function gt(Dt,ft){return z===1?Dt[ft]:Dt.readUInt16BE(ft*z)}let dt;if(N){let Dt=-1;for(dt=d;dt<G;dt++)if(gt(m,dt)===gt(h,Dt===-1?0:dt-Dt)){if(Dt===-1&&(Dt=dt),dt-Dt+1===kt)return Dt*z}else Dt!==-1&&(dt-=dt-Dt),Dt=-1}else for(d+kt>G&&(d=G-kt),dt=d;dt>=0;dt--){let Dt=!0;for(let ft=0;ft<kt;ft++)if(gt(m,dt+ft)!==gt(h,ft)){Dt=!1;break}if(Dt)return dt}return-1}u.prototype.includes=function(h,d,B){return this.indexOf(h,d,B)!==-1},u.prototype.indexOf=function(h,d,B){return F(this,h,d,B,!0)},u.prototype.lastIndexOf=function(h,d,B){return F(this,h,d,B,!1)};function Z(m,h,d,B){d=Number(d)||0;const N=m.length-d;B?(B=Number(B),B>N&&(B=N)):B=N;const z=h.length;B>z/2&&(B=z/2);let G;for(G=0;G<B;++G){const kt=parseInt(h.substr(G*2,2),16);if(Ot(kt))return G;m[d+G]=kt}return G}function J(m,h,d,B){return Lt(Ct(h,m.length-d),m,d,B)}function D(m,h,d,B){return Lt(Wt(h),m,d,B)}function V(m,h,d,B){return Lt(zt(h),m,d,B)}function Q(m,h,d,B){return Lt(Ur(h,m.length-d),m,d,B)}u.prototype.write=function(h,d,B,N){if(d===void 0)N="utf8",B=this.length,d=0;else if(B===void 0&&typeof d=="string")N=d,B=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(B)?(B=B>>>0,N===void 0&&(N="utf8")):(N=B,B=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const z=this.length-d;if((B===void 0||B>z)&&(B=z),h.length>0&&(B<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,h,d,B);case"utf8":case"utf-8":return J(this,h,d,B);case"ascii":case"latin1":case"binary":return D(this,h,d,B);case"base64":return V(this,h,d,B);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,h,d,B);default:if(G)throw new TypeError("Unknown encoding: "+N);N=(""+N).toLowerCase(),G=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(m,h,d){return h===0&&d===m.length?t.fromByteArray(m):t.fromByteArray(m.slice(h,d))}function c(m,h,d){d=Math.min(m.length,d);const B=[];let N=h;for(;N<d;){const z=m[N];let G=null,kt=z>239?4:z>223?3:z>191?2:1;if(N+kt<=d){let gt,dt,Dt,ft;switch(kt){case 1:z<128&&(G=z);break;case 2:gt=m[N+1],(gt&192)===128&&(ft=(z&31)<<6|gt&63,ft>127&&(G=ft));break;case 3:gt=m[N+1],dt=m[N+2],(gt&192)===128&&(dt&192)===128&&(ft=(z&15)<<12|(gt&63)<<6|dt&63,ft>2047&&(ft<55296||ft>57343)&&(G=ft));break;case 4:gt=m[N+1],dt=m[N+2],Dt=m[N+3],(gt&192)===128&&(dt&192)===128&&(Dt&192)===128&&(ft=(z&15)<<18|(gt&63)<<12|(dt&63)<<6|Dt&63,ft>65535&&ft<1114112&&(G=ft))}}G===null?(G=65533,kt=1):G>65535&&(G-=65536,B.push(G>>>10&1023|55296),G=56320|G&1023),B.push(G),N+=kt}return y(B)}const p=4096;function y(m){const h=m.length;if(h<=p)return String.fromCharCode.apply(String,m);let d="",B=0;for(;B<h;)d+=String.fromCharCode.apply(String,m.slice(B,B+=p));return d}function A(m,h,d){let B="";d=Math.min(m.length,d);for(let N=h;N<d;++N)B+=String.fromCharCode(m[N]&127);return B}function x(m,h,d){let B="";d=Math.min(m.length,d);for(let N=h;N<d;++N)B+=String.fromCharCode(m[N]);return B}function E(m,h,d){const B=m.length;(!h||h<0)&&(h=0),(!d||d<0||d>B)&&(d=B);let N="";for(let z=h;z<d;++z)N+=Ft[m[z]];return N}function L(m,h,d){const B=m.slice(h,d);let N="";for(let z=0;z<B.length-1;z+=2)N+=String.fromCharCode(B[z]+B[z+1]*256);return N}u.prototype.slice=function(h,d){const B=this.length;h=~~h,d=d===void 0?B:~~d,h<0?(h+=B,h<0&&(h=0)):h>B&&(h=B),d<0?(d+=B,d<0&&(d=0)):d>B&&(d=B),d<h&&(d=h);const N=this.subarray(h,d);return Object.setPrototypeOf(N,u.prototype),N};function v(m,h,d){if(m%1!==0||m<0)throw new RangeError("offset is not uint");if(m+h>d)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(h,d,B){h=h>>>0,d=d>>>0,B||v(h,d,this.length);let N=this[h],z=1,G=0;for(;++G<d&&(z*=256);)N+=this[h+G]*z;return N},u.prototype.readUintBE=u.prototype.readUIntBE=function(h,d,B){h=h>>>0,d=d>>>0,B||v(h,d,this.length);let N=this[h+--d],z=1;for(;d>0&&(z*=256);)N+=this[h+--d]*z;return N},u.prototype.readUint8=u.prototype.readUInt8=function(h,d){return h=h>>>0,d||v(h,1,this.length),this[h]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(h,d){return h=h>>>0,d||v(h,2,this.length),this[h]|this[h+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(h,d){return h=h>>>0,d||v(h,2,this.length),this[h]<<8|this[h+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(h,d){return h=h>>>0,d||v(h,4,this.length),(this[h]|this[h+1]<<8|this[h+2]<<16)+this[h+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(h,d){return h=h>>>0,d||v(h,4,this.length),this[h]*16777216+(this[h+1]<<16|this[h+2]<<8|this[h+3])},u.prototype.readBigUInt64LE=Be(function(h){h=h>>>0,_t(h,"offset");const d=this[h],B=this[h+7];(d===void 0||B===void 0)&&St(h,this.length-8);const N=d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24,z=this[++h]+this[++h]*2**8+this[++h]*2**16+B*2**24;return BigInt(N)+(BigInt(z)<<BigInt(32))}),u.prototype.readBigUInt64BE=Be(function(h){h=h>>>0,_t(h,"offset");const d=this[h],B=this[h+7];(d===void 0||B===void 0)&&St(h,this.length-8);const N=d*2**24+this[++h]*2**16+this[++h]*2**8+this[++h],z=this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+B;return(BigInt(N)<<BigInt(32))+BigInt(z)}),u.prototype.readIntLE=function(h,d,B){h=h>>>0,d=d>>>0,B||v(h,d,this.length);let N=this[h],z=1,G=0;for(;++G<d&&(z*=256);)N+=this[h+G]*z;return z*=128,N>=z&&(N-=Math.pow(2,8*d)),N},u.prototype.readIntBE=function(h,d,B){h=h>>>0,d=d>>>0,B||v(h,d,this.length);let N=d,z=1,G=this[h+--N];for(;N>0&&(z*=256);)G+=this[h+--N]*z;return z*=128,G>=z&&(G-=Math.pow(2,8*d)),G},u.prototype.readInt8=function(h,d){return h=h>>>0,d||v(h,1,this.length),this[h]&128?(255-this[h]+1)*-1:this[h]},u.prototype.readInt16LE=function(h,d){h=h>>>0,d||v(h,2,this.length);const B=this[h]|this[h+1]<<8;return B&32768?B|4294901760:B},u.prototype.readInt16BE=function(h,d){h=h>>>0,d||v(h,2,this.length);const B=this[h+1]|this[h]<<8;return B&32768?B|4294901760:B},u.prototype.readInt32LE=function(h,d){return h=h>>>0,d||v(h,4,this.length),this[h]|this[h+1]<<8|this[h+2]<<16|this[h+3]<<24},u.prototype.readInt32BE=function(h,d){return h=h>>>0,d||v(h,4,this.length),this[h]<<24|this[h+1]<<16|this[h+2]<<8|this[h+3]},u.prototype.readBigInt64LE=Be(function(h){h=h>>>0,_t(h,"offset");const d=this[h],B=this[h+7];(d===void 0||B===void 0)&&St(h,this.length-8);const N=this[h+4]+this[h+5]*2**8+this[h+6]*2**16+(B<<24);return(BigInt(N)<<BigInt(32))+BigInt(d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24)}),u.prototype.readBigInt64BE=Be(function(h){h=h>>>0,_t(h,"offset");const d=this[h],B=this[h+7];(d===void 0||B===void 0)&&St(h,this.length-8);const N=(d<<24)+this[++h]*2**16+this[++h]*2**8+this[++h];return(BigInt(N)<<BigInt(32))+BigInt(this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+B)}),u.prototype.readFloatLE=function(h,d){return h=h>>>0,d||v(h,4,this.length),e.read(this,h,!0,23,4)},u.prototype.readFloatBE=function(h,d){return h=h>>>0,d||v(h,4,this.length),e.read(this,h,!1,23,4)},u.prototype.readDoubleLE=function(h,d){return h=h>>>0,d||v(h,8,this.length),e.read(this,h,!0,52,8)},u.prototype.readDoubleBE=function(h,d){return h=h>>>0,d||v(h,8,this.length),e.read(this,h,!1,52,8)};function a(m,h,d,B,N,z){if(!u.isBuffer(m))throw new TypeError('"buffer" argument must be a Buffer instance');if(h>N||h<z)throw new RangeError('"value" argument is out of bounds');if(d+B>m.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(h,d,B,N){if(h=+h,d=d>>>0,B=B>>>0,!N){const kt=Math.pow(2,8*B)-1;a(this,h,d,B,kt,0)}let z=1,G=0;for(this[d]=h&255;++G<B&&(z*=256);)this[d+G]=h/z&255;return d+B},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(h,d,B,N){if(h=+h,d=d>>>0,B=B>>>0,!N){const kt=Math.pow(2,8*B)-1;a(this,h,d,B,kt,0)}let z=B-1,G=1;for(this[d+z]=h&255;--z>=0&&(G*=256);)this[d+z]=h/G&255;return d+B},u.prototype.writeUint8=u.prototype.writeUInt8=function(h,d,B){return h=+h,d=d>>>0,B||a(this,h,d,1,255,0),this[d]=h&255,d+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(h,d,B){return h=+h,d=d>>>0,B||a(this,h,d,2,65535,0),this[d]=h&255,this[d+1]=h>>>8,d+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(h,d,B){return h=+h,d=d>>>0,B||a(this,h,d,2,65535,0),this[d]=h>>>8,this[d+1]=h&255,d+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(h,d,B){return h=+h,d=d>>>0,B||a(this,h,d,4,4294967295,0),this[d+3]=h>>>24,this[d+2]=h>>>16,this[d+1]=h>>>8,this[d]=h&255,d+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(h,d,B){return h=+h,d=d>>>0,B||a(this,h,d,4,4294967295,0),this[d]=h>>>24,this[d+1]=h>>>16,this[d+2]=h>>>8,this[d+3]=h&255,d+4};function l(m,h,d,B,N){vt(h,B,N,m,d,7);let z=Number(h&BigInt(4294967295));m[d++]=z,z=z>>8,m[d++]=z,z=z>>8,m[d++]=z,z=z>>8,m[d++]=z;let G=Number(h>>BigInt(32)&BigInt(4294967295));return m[d++]=G,G=G>>8,m[d++]=G,G=G>>8,m[d++]=G,G=G>>8,m[d++]=G,d}function b(m,h,d,B,N){vt(h,B,N,m,d,7);let z=Number(h&BigInt(4294967295));m[d+7]=z,z=z>>8,m[d+6]=z,z=z>>8,m[d+5]=z,z=z>>8,m[d+4]=z;let G=Number(h>>BigInt(32)&BigInt(4294967295));return m[d+3]=G,G=G>>8,m[d+2]=G,G=G>>8,m[d+1]=G,G=G>>8,m[d]=G,d+8}u.prototype.writeBigUInt64LE=Be(function(h,d=0){return l(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Be(function(h,d=0){return b(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(h,d,B,N){if(h=+h,d=d>>>0,!N){const gt=Math.pow(2,8*B-1);a(this,h,d,B,gt-1,-gt)}let z=0,G=1,kt=0;for(this[d]=h&255;++z<B&&(G*=256);)h<0&&kt===0&&this[d+z-1]!==0&&(kt=1),this[d+z]=(h/G>>0)-kt&255;return d+B},u.prototype.writeIntBE=function(h,d,B,N){if(h=+h,d=d>>>0,!N){const gt=Math.pow(2,8*B-1);a(this,h,d,B,gt-1,-gt)}let z=B-1,G=1,kt=0;for(this[d+z]=h&255;--z>=0&&(G*=256);)h<0&&kt===0&&this[d+z+1]!==0&&(kt=1),this[d+z]=(h/G>>0)-kt&255;return d+B},u.prototype.writeInt8=function(h,d,B){return h=+h,d=d>>>0,B||a(this,h,d,1,127,-128),h<0&&(h=255+h+1),this[d]=h&255,d+1},u.prototype.writeInt16LE=function(h,d,B){return h=+h,d=d>>>0,B||a(this,h,d,2,32767,-32768),this[d]=h&255,this[d+1]=h>>>8,d+2},u.prototype.writeInt16BE=function(h,d,B){return h=+h,d=d>>>0,B||a(this,h,d,2,32767,-32768),this[d]=h>>>8,this[d+1]=h&255,d+2},u.prototype.writeInt32LE=function(h,d,B){return h=+h,d=d>>>0,B||a(this,h,d,4,2147483647,-2147483648),this[d]=h&255,this[d+1]=h>>>8,this[d+2]=h>>>16,this[d+3]=h>>>24,d+4},u.prototype.writeInt32BE=function(h,d,B){return h=+h,d=d>>>0,B||a(this,h,d,4,2147483647,-2147483648),h<0&&(h=4294967295+h+1),this[d]=h>>>24,this[d+1]=h>>>16,this[d+2]=h>>>8,this[d+3]=h&255,d+4},u.prototype.writeBigInt64LE=Be(function(h,d=0){return l(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Be(function(h,d=0){return b(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function S(m,h,d,B,N,z){if(d+B>m.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function U(m,h,d,B,N){return h=+h,d=d>>>0,N||S(m,h,d,4),e.write(m,h,d,B,23,4),d+4}u.prototype.writeFloatLE=function(h,d,B){return U(this,h,d,!0,B)},u.prototype.writeFloatBE=function(h,d,B){return U(this,h,d,!1,B)};function j(m,h,d,B,N){return h=+h,d=d>>>0,N||S(m,h,d,8),e.write(m,h,d,B,52,8),d+8}u.prototype.writeDoubleLE=function(h,d,B){return j(this,h,d,!0,B)},u.prototype.writeDoubleBE=function(h,d,B){return j(this,h,d,!1,B)},u.prototype.copy=function(h,d,B,N){if(!u.isBuffer(h))throw new TypeError("argument should be a Buffer");if(B||(B=0),!N&&N!==0&&(N=this.length),d>=h.length&&(d=h.length),d||(d=0),N>0&&N<B&&(N=B),N===B||h.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(N<0)throw new RangeError("sourceEnd out of bounds");N>this.length&&(N=this.length),h.length-d<N-B&&(N=h.length-d+B);const z=N-B;return this===h&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,B,N):Uint8Array.prototype.set.call(h,this.subarray(B,N),d),z},u.prototype.fill=function(h,d,B,N){if(typeof h=="string"){if(typeof d=="string"?(N=d,d=0,B=this.length):typeof B=="string"&&(N=B,B=this.length),N!==void 0&&typeof N!="string")throw new TypeError("encoding must be a string");if(typeof N=="string"&&!u.isEncoding(N))throw new TypeError("Unknown encoding: "+N);if(h.length===1){const G=h.charCodeAt(0);(N==="utf8"&&G<128||N==="latin1")&&(h=G)}}else typeof h=="number"?h=h&255:typeof h=="boolean"&&(h=Number(h));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,h||(h=0);let z;if(typeof h=="number")for(z=d;z<B;++z)this[z]=h;else{const G=u.isBuffer(h)?h:u.from(h,N),kt=G.length;if(kt===0)throw new TypeError('The value "'+h+'" is invalid for argument "value"');for(z=0;z<B-d;++z)this[z+d]=G[z%kt]}return this};const nt={};function ct(m,h,d){nt[m]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:h.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${m}]`,this.stack,delete this.name}get code(){return m}set code(N){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:N,writable:!0})}toString(){return`${this.name} [${m}]: ${this.message}`}}}ct("ERR_BUFFER_OUT_OF_BOUNDS",function(m){return m?`${m} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ct("ERR_INVALID_ARG_TYPE",function(m,h){return`The "${m}" argument must be of type number. Received type ${typeof h}`},TypeError),ct("ERR_OUT_OF_RANGE",function(m,h,d){let B=`The value of "${m}" is out of range.`,N=d;return Number.isInteger(d)&&Math.abs(d)>2**32?N=At(String(d)):typeof d=="bigint"&&(N=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(N=At(N)),N+="n"),B+=` It must be ${h}. Received ${N}`,B},RangeError);function At(m){let h="",d=m.length;const B=m[0]==="-"?1:0;for(;d>=B+4;d-=3)h=`_${m.slice(d-3,d)}${h}`;return`${m.slice(0,d)}${h}`}function pt(m,h,d){_t(h,"offset"),(m[h]===void 0||m[h+d]===void 0)&&St(h,m.length-(d+1))}function vt(m,h,d,B,N,z){if(m>d||m<h){const G=typeof h=="bigint"?"n":"";let kt;throw h===0||h===BigInt(0)?kt=`>= 0${G} and < 2${G} ** ${(z+1)*8}${G}`:kt=`>= -(2${G} ** ${(z+1)*8-1}${G}) and < 2 ** ${(z+1)*8-1}${G}`,new nt.ERR_OUT_OF_RANGE("value",kt,m)}pt(B,N,z)}function _t(m,h){if(typeof m!="number")throw new nt.ERR_INVALID_ARG_TYPE(h,"number",m)}function St(m,h,d){throw Math.floor(m)!==m?(_t(m,d),new nt.ERR_OUT_OF_RANGE("offset","an integer",m)):h<0?new nt.ERR_BUFFER_OUT_OF_BOUNDS:new nt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${h}`,m)}const Tt=/[^+/0-9A-Za-z-_]/g;function $e(m){if(m=m.split("=")[0],m=m.trim().replace(Tt,""),m.length<2)return"";for(;m.length%4!==0;)m=m+"=";return m}function Ct(m,h){h=h||1/0;let d;const B=m.length;let N=null;const z=[];for(let G=0;G<B;++G){if(d=m.charCodeAt(G),d>55295&&d<57344){if(!N){if(d>56319){(h-=3)>-1&&z.push(239,191,189);continue}else if(G+1===B){(h-=3)>-1&&z.push(239,191,189);continue}N=d;continue}if(d<56320){(h-=3)>-1&&z.push(239,191,189),N=d;continue}d=(N-55296<<10|d-56320)+65536}else N&&(h-=3)>-1&&z.push(239,191,189);if(N=null,d<128){if((h-=1)<0)break;z.push(d)}else if(d<2048){if((h-=2)<0)break;z.push(d>>6|192,d&63|128)}else if(d<65536){if((h-=3)<0)break;z.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((h-=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 Wt(m){const h=[];for(let d=0;d<m.length;++d)h.push(m.charCodeAt(d)&255);return h}function Ur(m,h){let d,B,N;const z=[];for(let G=0;G<m.length&&!((h-=2)<0);++G)d=m.charCodeAt(G),B=d>>8,N=d%256,z.push(N),z.push(B);return z}function zt(m){return t.toByteArray($e(m))}function Lt(m,h,d,B){let N;for(N=0;N<B&&!(N+d>=h.length||N>=m.length);++N)h[N+d]=m[N];return N}function xe(m,h){return m instanceof h||m!=null&&m.constructor!=null&&m.constructor.name!=null&&m.constructor.name===h.name}function Ot(m){return m!==m}const Ft=function(){const m="0123456789abcdef",h=new Array(256);for(let d=0;d<16;++d){const B=d*16;for(let N=0;N<16;++N)h[B+N]=m[d]+m[N]}return h}();function Be(m){return typeof BigInt>"u"?qt:m}function qt(){throw new Error("BigInt not supported")}}(Fn)),Fn}var ht=zn();function en(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`positive integer expected, not ${n}`)}function za(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function zr(n,...t){if(!za(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 qa(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 xs(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 qn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Da=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Dn=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Oe=(n,t)=>n<<32-t|n>>>t,Is=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Ka=n=>n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255;function Es(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 $a(...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 Kn{clone(){return this._cloneInto()}}function Wn(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 As(n=32){if(qn&&typeof qn.getRandomValues=="function")return qn.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}function Ha(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),u=Number(e&i),f=r?4:0,g=r?0:4;n.setUint32(t+f,o,r),n.setUint32(t+g,u,r)}const Va=(n,t,e)=>n&t^~n&e,ja=(n,t,e)=>n&t^n&e^t&e;class Bs extends Kn{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=Dn(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 u=Math.min(s-this.pos,i-o);if(u===s){const f=Dn(t);for(;s<=i-o;o+=s)this.process(f,o);continue}r.set(t.subarray(o,o+u),this.pos),this.pos+=u,o+=u,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){kr(this),xs(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;Ha(r,s-8,BigInt(this.length*8),i),this.process(r,0);const u=Dn(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=f/4,w=this.get();if(g>w.length)throw new Error("_sha2: outputLen bigger than state");for(let k=0;k<g;k++)u.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:u}=this;return t.length=s,t.pos=u,t.finished=i,t.destroyed=o,s%e&&t.buffer.set(r),t}}const nn=BigInt(2**32-1),$n=BigInt(32);function _s(n,t=!1){return t?{h:Number(n&nn),l:Number(n>>$n&nn)}:{h:Number(n>>$n&nn)|0,l:Number(n&nn)|0}}function Rs(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}=_s(n[s],t);[e[s],r[s]]=[i,o]}return[e,r]}const Ga=(n,t)=>BigInt(n>>>0)<<$n|BigInt(t>>>0),Za=(n,t,e)=>n>>>e,Ya=(n,t,e)=>n<<32-e|t>>>e,Ja=(n,t,e)=>n>>>e|t<<32-e,Xa=(n,t,e)=>n<<32-e|t>>>e,Qa=(n,t,e)=>n<<64-e|t>>>e-32,tc=(n,t,e)=>n>>>e-32|t<<64-e,ec=(n,t)=>t,rc=(n,t)=>n,Ts=(n,t,e)=>n<<e|t>>>32-e,Ms=(n,t,e)=>t<<e|n>>>32-e,Ps=(n,t,e)=>t<<e-32|n>>>64-e,Cs=(n,t,e)=>n<<e-32|t>>>64-e;function nc(n,t,e,r){const s=(t>>>0)+(r>>>0);return{h:n+e+(s/2**32|0)|0,l:s|0}}const mt={fromBig:_s,split:Rs,toBig:Ga,shrSH:Za,shrSL:Ya,rotrSH:Ja,rotrSL:Xa,rotrBH:Qa,rotrBL:tc,rotr32H:ec,rotr32L:rc,rotlSH:Ts,rotlSL:Ms,rotlBH:Ps,rotlBL:Cs,add:nc,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)},[ic,sc]=mt.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 oc extends Bs{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:u,Dl:f,Eh:g,El:w,Fh:k,Fl:M,Gh:R,Gl:C,Hh:_,Hl:T}=this;return[t,e,r,s,i,o,u,f,g,w,k,M,R,C,_,T]}set(t,e,r,s,i,o,u,f,g,w,k,M,R,C,_,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=u|0,this.Dl=f|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=_|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,W=Je[q-15]|0,F=mt.rotrSH(X,W,1)^mt.rotrSH(X,W,8)^mt.shrSH(X,W,7),Y=mt.rotrSL(X,W,1)^mt.rotrSL(X,W,8)^mt.shrSL(X,W,7),Z=Ye[q-2]|0,J=Je[q-2]|0,D=mt.rotrSH(Z,J,19)^mt.rotrBH(Z,J,61)^mt.shrSH(Z,J,6),V=mt.rotrSL(Z,J,19)^mt.rotrBL(Z,J,61)^mt.shrSL(Z,J,6),Q=mt.add4L(Y,V,Je[q-7],Je[q-16]),I=mt.add4H(Q,F,D,Ye[q-7],Ye[q-16]);Ye[q]=I|0,Je[q]=Q|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:u,Cl:f,Dh:g,Dl:w,Eh:k,El:M,Fh:R,Fl:C,Gh:_,Gl:T,Hh:O,Hl:$}=this;for(let q=0;q<80;q++){const X=mt.rotrSH(k,M,14)^mt.rotrSH(k,M,18)^mt.rotrBH(k,M,41),W=mt.rotrSL(k,M,14)^mt.rotrSL(k,M,18)^mt.rotrBL(k,M,41),F=k&R^~k&_,Y=M&C^~M&T,Z=mt.add5L($,W,Y,sc[q],Je[q]),J=mt.add5H(Z,O,X,F,ic[q],Ye[q]),D=Z|0,V=mt.rotrSH(r,s,28)^mt.rotrBH(r,s,34)^mt.rotrBH(r,s,39),Q=mt.rotrSL(r,s,28)^mt.rotrBL(r,s,34)^mt.rotrBL(r,s,39),I=r&i^r&u^i&u,c=s&o^s&f^o&f;O=_|0,$=T|0,_=R|0,T=C|0,R=k|0,C=M|0,{h:k,l:M}=mt.add(g|0,w|0,J|0,D|0),g=u|0,w=f|0,u=i|0,f=o|0,i=r|0,o=s|0;const p=mt.add3L(D,Q,c);r=mt.add3H(p,J,V,I),s=p|0}({h:r,l:s}=mt.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=mt.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:u,l:f}=mt.add(this.Ch|0,this.Cl|0,u|0,f|0),{h:g,l:w}=mt.add(this.Dh|0,this.Dl|0,g|0,w|0),{h:k,l:M}=mt.add(this.Eh|0,this.El|0,k|0,M|0),{h:R,l:C}=mt.add(this.Fh|0,this.Fl|0,R|0,C|0),{h:_,l:T}=mt.add(this.Gh|0,this.Gl|0,_|0,T|0),{h:O,l:$}=mt.add(this.Hh|0,this.Hl|0,O|0,$|0),this.set(r,s,i,o,u,f,g,w,k,M,R,C,_,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 ac=Wn(()=>new oc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ls=BigInt(0),sn=BigInt(1),cc=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 uc=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+=uc[n[e]];return t}function Os(n){const t=n.toString(16);return t.length&1?`0${t}`:t}function Hn(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 Us(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=Us(n.charCodeAt(i)),u=Us(n.charCodeAt(i+1));if(o===void 0||u===void 0){const f=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[s]=o*16+u}return r}function ar(n){return Hn(or(n))}function Sr(n){return qr(n),Hn(or(Uint8Array.from(n).reverse()))}function xr(n,t){return vr(n.toString(16).padStart(t*2,"0"))}function Dr(n,t){return xr(n,t).reverse()}function lc(n){return vr(Os(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 hc(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 dc(n){let t;for(t=0;n>Ls;n>>=sn,t+=1);return t}function pc(n,t){return n>>BigInt(t)&sn}function gc(n,t,e){return n|(e?sn:Ls)<<BigInt(t)}const Vn=n=>(cc<<BigInt(n-1))-sn,jn=n=>new Uint8Array(n),Ns=n=>Uint8Array.from(n);function Fs(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=jn(n),s=jn(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},u=(...k)=>e(s,r,...k),f=(k=jn())=>{s=u(Ns([0]),k),r=u(),k.length!==0&&(s=u(Ns([1]),k),r=u())},g=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let k=0;const M=[];for(;k<t;){r=u();const R=r.slice();M.push(R),k+=r.length}return cr(...M)};return(k,M)=>{o(),f(k);let R;for(;!(R=M(g()));)f();return o(),R}}const yc={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 u=yc[i];if(typeof u!="function")throw new Error(`Invalid validator "${i}", expected function`);const f=n[s];if(!(o&&f===void 0)&&!u(f,n))throw new Error(`Invalid param ${String(s)}=${f} (${typeof f}), 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 mc=Object.freeze(Object.defineProperty({__proto__:null,abytes:qr,bitGet:pc,bitLen:dc,bitMask:Vn,bitSet:gc,bytesToHex:or,bytesToNumberBE:ar,bytesToNumberLE:Sr,concatBytes:cr,createHmacDrbg:Fs,ensureBytes:de,equalBytes:hc,hexToBytes:vr,hexToNumber:Hn,isBytes:sr,numberToBytesBE:xr,numberToBytesLE:Dr,numberToHexUnpadded:Os,numberToVarBytesBE:lc,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),wc=BigInt(3),Gn=BigInt(4),zs=BigInt(5),qs=BigInt(8);BigInt(9),BigInt(16);function Kt(n,t){const e=n%t;return e>=pe?e:t+e}function bc(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 Zn(n,t){if(n===pe||t<=pe)throw new Error(`invert: expected positive integers, got n=${n} mod=${t}`);let e=Kt(n,t),r=t,s=pe,i=$t;for(;e!==pe;){const u=r/e,f=r%e,g=s-i*u;r=e,e=f,s=i,i=g}if(r!==$t)throw new Error("invert: does not exist");return Kt(s,t)}function kc(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&&bc(s,t,n)!==n-$t;s++);if(r===1){const o=(n+$t)/Gn;return function(f,g){const w=f.pow(g,o);if(!f.eql(f.sqr(w),g))throw new Error("Cannot find square root");return w}}const i=(e+$t)/ur;return function(u,f){if(u.pow(f,t)===u.neg(u.ONE))throw new Error("Cannot find square root");let g=r,w=u.pow(u.mul(u.ONE,s),e),k=u.pow(f,i),M=u.pow(f,e);for(;!u.eql(M,u.ONE);){if(u.eql(M,u.ZERO))return u.ZERO;let R=1;for(let _=u.sqr(M);R<g&&!u.eql(_,u.ONE);R++)_=u.sqr(_);const C=u.pow(w,$t<<BigInt(g-R-1));w=u.sqr(C),k=u.mul(k,C),M=u.mul(M,w),g=R}return k}}function vc(n){if(n%Gn===wc){const t=(n+$t)/Gn;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%qs===zs){const t=(n-zs)/qs;return function(r,s){const i=r.mul(s,ur),o=r.pow(i,t),u=r.mul(s,o),f=r.mul(r.mul(u,ur),o),g=r.mul(u,r.sub(f,r.ONE));if(!r.eql(r.sqr(g),s))throw new Error("Cannot find square root");return g}}return kc(n)}const Sc=(n,t)=>(Kt(n,t)&$t)===$t,xc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ic(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=xc.reduce((r,s)=>(r[s]="function",r),t);return Ir(n,e)}function Ec(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 Ac(n,t){const e=new Array(t.length),r=t.reduce((i,o,u)=>n.is0(o)?i:(e[u]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return t.reduceRight((i,o,u)=>n.is0(o)?i:(e[u]=n.mul(i,e[u]),n.mul(i,o)),s),e}function Ds(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}=Ds(n,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=vc(n),u=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:Vn(s),ZERO:pe,ONE:$t,create:f=>Kt(f,n),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return pe<=f&&f<n},is0:f=>f===pe,isOdd:f=>(f&$t)===$t,neg:f=>Kt(-f,n),eql:(f,g)=>f===g,sqr:f=>Kt(f*f,n),add:(f,g)=>Kt(f+g,n),sub:(f,g)=>Kt(f-g,n),mul:(f,g)=>Kt(f*g,n),pow:(f,g)=>Ec(u,f,g),div:(f,g)=>Kt(f*Zn(g,n),n),sqrN:f=>f*f,addN:(f,g)=>f+g,subN:(f,g)=>f-g,mulN:(f,g)=>f*g,inv:f=>Zn(f,n),sqrt:r.sqrt||(f=>o(u,f)),invertBatch:f=>Ac(u,f),cmov:(f,g,w)=>w?g:f,toBytes:f=>e?Dr(f,i):xr(f,i),fromBytes:f=>{if(f.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${f.length}`);return e?Sr(f):ar(f)}});return Object.freeze(u)}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 $s(n){const t=Ws(n);return t+Math.ceil(t/2)}function Bc(n,t,e=!1){const r=n.length,s=Ws(t),i=$s(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),u=Kt(o,t-$t)+$t;return e?Dr(u,s):xr(u,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _c=BigInt(0),Yn=BigInt(1);function Hs(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,u=s;for(;i>_c;)i&Yn&&(o=o.add(u)),u=u.double(),i>>=Yn;return o},precomputeWindow(s,i){const{windows:o,windowSize:u}=r(i),f=[];let g=s,w=g;for(let k=0;k<o;k++){w=g,f.push(w);for(let M=1;M<u;M++)w=w.add(g),f.push(w);g=w.double()}return f},wNAF(s,i,o){const{windows:u,windowSize:f}=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<u;C++){const _=C*f;let T=Number(o&k);o>>=R,T>f&&(T-=M,o+=Yn);const O=_,$=_+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,u){const f=s._WINDOW_SIZE||1;let g=i.get(s);return g||(g=this.precomputeWindow(s,f),f!==1&&i.set(s,u(g))),this.wNAF(f,g,o)}}}function Jn(n){return Ic(n.Fp),Ir(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ds(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Me=BigInt(0),_e=BigInt(1),on=BigInt(2),Rc=BigInt(8),Tc={zip215:!0};function Mc(n){const t=Jn(n);return Ir(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Pc(n){const t=Mc(n),{Fp:e,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:u,h:f}=t,g=on<<BigInt(u*8)-_e,w=e.create,k=t.uvRatio||((x,E)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(E))}}catch{return{isValid:!1,value:Me}}}),M=t.adjustScalarBytes||(x=>x),R=t.domain||((x,E,L)=>{if(E.length||L)throw new Error("Contexts/pre-hash are not supported");return x}),C=x=>typeof x=="bigint"&&Me<x,_=(x,E)=>C(x)&&C(E)&&x<E,T=x=>x===Me||_(x,g);function O(x,E){if(_(x,E))return x;throw new Error(`Expected valid scalar < ${E}, got ${typeof x} ${x}`)}function $(x){return x===Me?x:O(x,r)}const q=new Map;function X(x){if(!(x instanceof W))throw new Error("ExtendedPoint expected")}class W{constructor(E,L,v,a){if(this.ex=E,this.ey=L,this.ez=v,this.et=a,!T(E))throw new Error("x required");if(!T(L))throw new Error("y required");if(!T(v))throw new Error("z required");if(!T(a))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(E){if(E instanceof W)throw new Error("extended point not allowed");const{x:L,y:v}=E||{};if(!T(L)||!T(v))throw new Error("invalid affine point");return new W(L,v,_e,w(L*v))}static normalizeZ(E){const L=e.invertBatch(E.map(v=>v.ez));return E.map((v,a)=>v.toAffine(L[a])).map(W.fromAffine)}_setWindowSize(E){this._WINDOW_SIZE=E,q.delete(this)}assertValidity(){const{a:E,d:L}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:v,ey:a,ez:l,et:b}=this,S=w(v*v),U=w(a*a),j=w(l*l),nt=w(j*j),ct=w(S*E),At=w(j*w(ct+U)),pt=w(nt+w(L*w(S*U)));if(At!==pt)throw new Error("bad point: equation left != right (1)");const vt=w(v*a),_t=w(l*b);if(vt!==_t)throw new Error("bad point: equation left != right (2)")}equals(E){X(E);const{ex:L,ey:v,ez:a}=this,{ex:l,ey:b,ez:S}=E,U=w(L*S),j=w(l*a),nt=w(v*S),ct=w(b*a);return U===j&&nt===ct}is0(){return this.equals(W.ZERO)}negate(){return new W(w(-this.ex),this.ey,this.ez,w(-this.et))}double(){const{a:E}=t,{ex:L,ey:v,ez:a}=this,l=w(L*L),b=w(v*v),S=w(on*w(a*a)),U=w(E*l),j=L+v,nt=w(w(j*j)-l-b),ct=U+b,At=ct-S,pt=U-b,vt=w(nt*At),_t=w(ct*pt),St=w(nt*pt),Tt=w(At*ct);return new W(vt,_t,Tt,St)}add(E){X(E);const{a:L,d:v}=t,{ex:a,ey:l,ez:b,et:S}=this,{ex:U,ey:j,ez:nt,et:ct}=E;if(L===BigInt(-1)){const xe=w((l-a)*(j+U)),Ot=w((l+a)*(j-U)),Ft=w(Ot-xe);if(Ft===Me)return this.double();const Be=w(b*on*ct),qt=w(S*on*nt),m=qt+Be,h=Ot+xe,d=qt-Be,B=w(m*Ft),N=w(h*d),z=w(m*d),G=w(Ft*h);return new W(B,N,G,z)}const At=w(a*U),pt=w(l*j),vt=w(S*v*ct),_t=w(b*nt),St=w((a+l)*(U+j)-At-pt),Tt=_t-vt,$e=_t+vt,Ct=w(pt-L*At),Wt=w(St*Tt),Ur=w($e*Ct),zt=w(St*Ct),Lt=w(Tt*$e);return new W(Wt,Ur,Lt,zt)}subtract(E){return this.add(E.negate())}wNAF(E){return Z.wNAFCached(this,q,E,W.normalizeZ)}multiply(E){const{p:L,f:v}=this.wNAF(O(E,r));return W.normalizeZ([L,v])[0]}multiplyUnsafe(E){let L=$(E);return L===Me?Y:this.equals(Y)||L===_e?this:this.equals(F)?this.wNAF(L).p:Z.unsafeLadder(this,L)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return Z.unsafeLadder(this,r).is0()}toAffine(E){const{ex:L,ey:v,ez:a}=this,l=this.is0();E==null&&(E=l?Rc:e.inv(a));const b=w(L*E),S=w(v*E),U=w(a*E);if(l)return{x:Me,y:_e};if(U!==_e)throw new Error("invZ was invalid");return{x:b,y:S}}clearCofactor(){const{h:E}=t;return E===_e?this:this.multiplyUnsafe(E)}static fromHex(E,L=!1){const{d:v,a}=t,l=e.BYTES;E=de("pointHex",E,l);const b=E.slice(),S=E[l-1];b[l-1]=S&-129;const U=Sr(b);U===Me||(L?O(U,g):O(U,e.ORDER));const j=w(U*U),nt=w(j-_e),ct=w(v*j-a);let{isValid:At,value:pt}=k(nt,ct);if(!At)throw new Error("Point.fromHex: invalid y coordinate");const vt=(pt&_e)===_e,_t=(S&128)!==0;if(!L&&pt===Me&&_t)throw new Error("Point.fromHex: x=0 and x_0=1");return _t!==vt&&(pt=w(-pt)),W.fromAffine({x:pt,y:U})}static fromPrivateKey(E){return V(E).point}toRawBytes(){const{x:E,y:L}=this.toAffine(),v=Dr(L,e.BYTES);return v[v.length-1]|=E&_e?128:0,v}toHex(){return or(this.toRawBytes())}}W.BASE=new W(t.Gx,t.Gy,_e,w(t.Gx*t.Gy)),W.ZERO=new W(Me,_e,_e,Me);const{BASE:F,ZERO:Y}=W,Z=Hs(W,u*8);function J(x){return Kt(x,r)}function D(x){return J(Sr(x))}function V(x){const E=u;x=de("private key",x,E);const L=de("hashed private key",i(x),2*E),v=M(L.slice(0,E)),a=L.slice(E,2*E),l=D(v),b=F.multiply(l),S=b.toRawBytes();return{head:v,prefix:a,scalar:l,point:b,pointBytes:S}}function Q(x){return V(x).pointBytes}function I(x=new Uint8Array,...E){const L=cr(...E);return D(i(R(L,de("context",x),!!s)))}function c(x,E,L={}){x=de("message",x),s&&(x=s(x));const{prefix:v,scalar:a,pointBytes:l}=V(E),b=I(L.context,v,x),S=F.multiply(b).toRawBytes(),U=I(L.context,S,l,x),j=J(b+U*a);$(j);const nt=cr(S,Dr(j,e.BYTES));return de("result",nt,u*2)}const p=Tc;function y(x,E,L,v=p){const{context:a,zip215:l}=v,b=e.BYTES;x=de("signature",x,2*b),E=de("message",E),s&&(E=s(E));const S=Sr(x.slice(b,2*b));let U,j,nt;try{U=W.fromHex(L,l),j=W.fromHex(x.slice(0,b),l),nt=F.multiplyUnsafe(S)}catch{return!1}if(!l&&U.isSmallOrder())return!1;const ct=I(a,j.toRawBytes(),U.toRawBytes(),E);return j.add(U.multiplyUnsafe(ct)).subtract(nt).clearCofactor().equals(W.ZERO)}return F._setWindowSize(8),{CURVE:t,getPublicKey:Q,sign:c,verify:y,ExtendedPoint:W,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>o(e.BYTES),precompute(x=8,E=W.BASE){return E._setWindowSize(x),E.multiply(BigInt(3)),E}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Xn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Vs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Cc=BigInt(1),js=BigInt(2);BigInt(3);const Lc=BigInt(5),Oc=BigInt(8);function Uc(n){const t=BigInt(10),e=BigInt(20),r=BigInt(40),s=BigInt(80),i=Xn,u=n*n%i*n%i,f=jt(u,js,i)*u%i,g=jt(f,Cc,i)*n%i,w=jt(g,Lc,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,_=jt(C,s,i)*R%i,T=jt(_,t,i)*w%i;return{pow_p_5_8:jt(T,js,i)*n%i,b2:u}}function Nc(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function Fc(n,t){const e=Xn,r=Kt(t*t*t,e),s=Kt(r*r*t,e),i=Uc(n*s).pow_p_5_8;let o=Kt(n*r*i,e);const u=Kt(t*o*o,e),f=o,g=Kt(o*Vs,e),w=u===n,k=u===Kt(-n,e),M=u===Kt(-n*Vs,e);return w&&(o=f),(k||M)&&(o=g),Sc(o,e)&&(o=Kt(-o,e)),{isValid:w||k,value:o}}const zc=Ks(Xn,void 0,!0),qc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:zc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Oc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ac,randomBytes:As,adjustScalarBytes:Nc,uvRatio:Fc},Er=Pc(qc);var an={exports:{}};const Dc=Nn(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Kc=an.exports,Gs;function Zs(){return Gs||(Gs=1,function(n){(function(t,e){function r(I,c){if(!I)throw new Error(c||"Assertion failed")}function s(I,c){I.super_=c;var p=function(){};p.prototype=c.prototype,I.prototype=new p,I.prototype.constructor=I}function i(I,c,p){if(i.isBN(I))return I;this.negative=0,this.words=null,this.length=0,this.red=null,I!==null&&((c==="le"||c==="be")&&(p=c,c=10),this._init(I||0,c||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=Dc.Buffer}catch{}i.isBN=function(c){return c instanceof i?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===i.wordSize&&Array.isArray(c.words)},i.max=function(c,p){return c.cmp(p)>0?c:p},i.min=function(c,p){return c.cmp(p)<0?c:p},i.prototype._init=function(c,p,y){if(typeof c=="number")return this._initNumber(c,p,y);if(typeof c=="object")return this._initArray(c,p,y);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),c=c.toString().replace(/\s+/g,"");var A=0;c[0]==="-"&&(A++,this.negative=1),A<c.length&&(p===16?this._parseHex(c,A,y):(this._parseBase(c,p,A),y==="le"&&this._initArray(this.toArray(),p,y)))},i.prototype._initNumber=function(c,p,y){c<0&&(this.negative=1,c=-c),c<67108864?(this.words=[c&67108863],this.length=1):c<4503599627370496?(this.words=[c&67108863,c/67108864&67108863],this.length=2):(r(c<9007199254740992),this.words=[c&67108863,c/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),p,y)},i.prototype._initArray=function(c,p,y){if(r(typeof c.length=="number"),c.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(c.length/3),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var x,E,L=0;if(y==="be")for(A=c.length-1,x=0;A>=0;A-=3)E=c[A]|c[A-1]<<8|c[A-2]<<16,this.words[x]|=E<<L&67108863,this.words[x+1]=E>>>26-L&67108863,L+=24,L>=26&&(L-=26,x++);else if(y==="le")for(A=0,x=0;A<c.length;A+=3)E=c[A]|c[A+1]<<8|c[A+2]<<16,this.words[x]|=E<<L&67108863,this.words[x+1]=E>>>26-L&67108863,L+=24,L>=26&&(L-=26,x++);return this._strip()};function u(I,c){var p=I.charCodeAt(c);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 "+I)}function f(I,c,p){var y=u(I,p);return p-1>=c&&(y|=u(I,p-1)<<4),y}i.prototype._parseHex=function(c,p,y){this.length=Math.ceil((c.length-p)/6),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var x=0,E=0,L;if(y==="be")for(A=c.length-1;A>=p;A-=2)L=f(c,p,A)<<x,this.words[E]|=L&67108863,x>=18?(x-=18,E+=1,this.words[E]|=L>>>26):x+=8;else{var v=c.length-p;for(A=v%2===0?p+1:p;A<c.length;A+=2)L=f(c,p,A)<<x,this.words[E]|=L&67108863,x>=18?(x-=18,E+=1,this.words[E]|=L>>>26):x+=8}this._strip()};function g(I,c,p,y){for(var A=0,x=0,E=Math.min(I.length,p),L=c;L<E;L++){var v=I.charCodeAt(L)-48;A*=y,v>=49?x=v-49+10:v>=17?x=v-17+10:x=v,r(v>=0&&x<y,"Invalid character"),A+=x}return A}i.prototype._parseBase=function(c,p,y){this.words=[0],this.length=1;for(var A=0,x=1;x<=67108863;x*=p)A++;A--,x=x/p|0;for(var E=c.length-y,L=E%A,v=Math.min(E,E-L)+y,a=0,l=y;l<v;l+=A)a=g(c,l,l+A,p),this.imuln(x),this.words[0]+a<67108864?this.words[0]+=a:this._iaddn(a);if(L!==0){var b=1;for(a=g(c,l,c.length,p),l=0;l<L;l++)b*=p;this.imuln(b),this.words[0]+a<67108864?this.words[0]+=a:this._iaddn(a)}this._strip()},i.prototype.copy=function(c){c.words=new Array(this.length);for(var p=0;p<this.length;p++)c.words[p]=this.words[p];c.length=this.length,c.negative=this.negative,c.red=this.red};function w(I,c){I.words=c.words,I.length=c.length,I.negative=c.negative,I.red=c.red}if(i.prototype._move=function(c){w(c,this)},i.prototype.clone=function(){var c=new i(null);return this.copy(c),c},i.prototype._expand=function(c){for(;this.length<c;)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(c,p){c=c||10,p=p|0||1;var y;if(c===16||c==="hex"){y="";for(var A=0,x=0,E=0;E<this.length;E++){var L=this.words[E],v=((L<<A|x)&16777215).toString(16);x=L>>>24-A&16777215,A+=2,A>=26&&(A-=26,E--),x!==0||E!==this.length-1?y=M[6-v.length]+v+y:y=v+y}for(x!==0&&(y=x.toString(16)+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(c===(c|0)&&c>=2&&c<=36){var a=R[c],l=C[c];y="";var b=this.clone();for(b.negative=0;!b.isZero();){var S=b.modrn(l).toString(c);b=b.idivn(l),b.isZero()?y=S+y:y=M[a-S.length]+S+y}for(this.isZero()&&(y="0"+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(c,p){return this.toArrayLike(o,c,p)}),i.prototype.toArray=function(c,p){return this.toArrayLike(Array,c,p)};var _=function(c,p){return c.allocUnsafe?c.allocUnsafe(p):new c(p)};i.prototype.toArrayLike=function(c,p,y){this._strip();var A=this.byteLength(),x=y||Math.max(1,A);r(A<=x,"byte array longer than desired length"),r(x>0,"Requested array length <= 0");var E=_(c,x),L=p==="le"?"LE":"BE";return this["_toArrayLike"+L](E,A),E},i.prototype._toArrayLikeLE=function(c,p){for(var y=0,A=0,x=0,E=0;x<this.length;x++){var L=this.words[x]<<E|A;c[y++]=L&255,y<c.length&&(c[y++]=L>>8&255),y<c.length&&(c[y++]=L>>16&255),E===6?(y<c.length&&(c[y++]=L>>24&255),A=0,E=0):(A=L>>>24,E+=2)}if(y<c.length)for(c[y++]=A;y<c.length;)c[y++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var y=c.length-1,A=0,x=0,E=0;x<this.length;x++){var L=this.words[x]<<E|A;c[y--]=L&255,y>=0&&(c[y--]=L>>8&255),y>=0&&(c[y--]=L>>16&255),E===6?(y>=0&&(c[y--]=L>>24&255),A=0,E=0):(A=L>>>24,E+=2)}if(y>=0)for(c[y--]=A;y>=0;)c[y--]=0},Math.clz32?i.prototype._countBits=function(c){return 32-Math.clz32(c)}:i.prototype._countBits=function(c){var p=c,y=0;return p>=4096&&(y+=13,p>>>=13),p>=64&&(y+=7,p>>>=7),p>=8&&(y+=4,p>>>=4),p>=2&&(y+=2,p>>>=2),y+p},i.prototype._zeroBits=function(c){if(c===0)return 26;var p=c,y=0;return(p&8191)===0&&(y+=13,p>>>=13),(p&127)===0&&(y+=7,p>>>=7),(p&15)===0&&(y+=4,p>>>=4),(p&3)===0&&(y+=2,p>>>=2),(p&1)===0&&y++,y},i.prototype.bitLength=function(){var c=this.words[this.length-1],p=this._countBits(c);return(this.length-1)*26+p};function T(I){for(var c=new Array(I.bitLength()),p=0;p<c.length;p++){var y=p/26|0,A=p%26;c[p]=I.words[y]>>>A&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,p=0;p<this.length;p++){var y=this._zeroBits(this.words[p]);if(c+=y,y!==26)break}return c},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(c){return this.negative!==0?this.abs().inotn(c).iaddn(1):this.clone()},i.prototype.fromTwos=function(c){return this.testn(c-1)?this.notn(c).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(c){for(;this.length<c.length;)this.words[this.length++]=0;for(var p=0;p<c.length;p++)this.words[p]=this.words[p]|c.words[p];return this._strip()},i.prototype.ior=function(c){return r((this.negative|c.negative)===0),this.iuor(c)},i.prototype.or=function(c){return this.length>c.length?this.clone().ior(c):c.clone().ior(this)},i.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},i.prototype.iuand=function(c){var p;this.length>c.length?p=c:p=this;for(var y=0;y<p.length;y++)this.words[y]=this.words[y]&c.words[y];return this.length=p.length,this._strip()},i.prototype.iand=function(c){return r((this.negative|c.negative)===0),this.iuand(c)},i.prototype.and=function(c){return this.length>c.length?this.clone().iand(c):c.clone().iand(this)},i.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},i.prototype.iuxor=function(c){var p,y;this.length>c.length?(p=this,y=c):(p=c,y=this);for(var A=0;A<y.length;A++)this.words[A]=p.words[A]^y.words[A];if(this!==p)for(;A<p.length;A++)this.words[A]=p.words[A];return this.length=p.length,this._strip()},i.prototype.ixor=function(c){return r((this.negative|c.negative)===0),this.iuxor(c)},i.prototype.xor=function(c){return this.length>c.length?this.clone().ixor(c):c.clone().ixor(this)},i.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},i.prototype.inotn=function(c){r(typeof c=="number"&&c>=0);var p=Math.ceil(c/26)|0,y=c%26;this._expand(p),y>0&&p--;for(var A=0;A<p;A++)this.words[A]=~this.words[A]&67108863;return y>0&&(this.words[A]=~this.words[A]&67108863>>26-y),this._strip()},i.prototype.notn=function(c){return this.clone().inotn(c)},i.prototype.setn=function(c,p){r(typeof c=="number"&&c>=0);var y=c/26|0,A=c%26;return this._expand(y+1),p?this.words[y]=this.words[y]|1<<A:this.words[y]=this.words[y]&~(1<<A),this._strip()},i.prototype.iadd=function(c){var p;if(this.negative!==0&&c.negative===0)return this.negative=0,p=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,p=this.isub(c),c.negative=1,p._normSign();var y,A;this.length>c.length?(y=this,A=c):(y=c,A=this);for(var x=0,E=0;E<A.length;E++)p=(y.words[E]|0)+(A.words[E]|0)+x,this.words[E]=p&67108863,x=p>>>26;for(;x!==0&&E<y.length;E++)p=(y.words[E]|0)+x,this.words[E]=p&67108863,x=p>>>26;if(this.length=y.length,x!==0)this.words[this.length]=x,this.length++;else if(y!==this)for(;E<y.length;E++)this.words[E]=y.words[E];return this},i.prototype.add=function(c){var p;return c.negative!==0&&this.negative===0?(c.negative=0,p=this.sub(c),c.negative^=1,p):c.negative===0&&this.negative!==0?(this.negative=0,p=c.sub(this),this.negative=1,p):this.length>c.length?this.clone().iadd(c):c.clone().iadd(this)},i.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var p=this.iadd(c);return c.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var y=this.cmp(c);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,x;y>0?(A=this,x=c):(A=c,x=this);for(var E=0,L=0;L<x.length;L++)p=(A.words[L]|0)-(x.words[L]|0)+E,E=p>>26,this.words[L]=p&67108863;for(;E!==0&&L<A.length;L++)p=(A.words[L]|0)+E,E=p>>26,this.words[L]=p&67108863;if(E===0&&L<A.length&&A!==this)for(;L<A.length;L++)this.words[L]=A.words[L];return this.length=Math.max(this.length,L),A!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function O(I,c,p){p.negative=c.negative^I.negative;var y=I.length+c.length|0;p.length=y,y=y-1|0;var A=I.words[0]|0,x=c.words[0]|0,E=A*x,L=E&67108863,v=E/67108864|0;p.words[0]=L;for(var a=1;a<y;a++){for(var l=v>>>26,b=v&67108863,S=Math.min(a,c.length-1),U=Math.max(0,a-I.length+1);U<=S;U++){var j=a-U|0;A=I.words[j]|0,x=c.words[U]|0,E=A*x+b,l+=E/67108864|0,b=E&67108863}p.words[a]=b|0,v=l|0}return v!==0?p.words[a]=v|0:p.length--,p._strip()}var $=function(c,p,y){var A=c.words,x=p.words,E=y.words,L=0,v,a,l,b=A[0]|0,S=b&8191,U=b>>>13,j=A[1]|0,nt=j&8191,ct=j>>>13,At=A[2]|0,pt=At&8191,vt=At>>>13,_t=A[3]|0,St=_t&8191,Tt=_t>>>13,$e=A[4]|0,Ct=$e&8191,Wt=$e>>>13,Ur=A[5]|0,zt=Ur&8191,Lt=Ur>>>13,xe=A[6]|0,Ot=xe&8191,Ft=xe>>>13,Be=A[7]|0,qt=Be&8191,m=Be>>>13,h=A[8]|0,d=h&8191,B=h>>>13,N=A[9]|0,z=N&8191,G=N>>>13,kt=x[0]|0,gt=kt&8191,dt=kt>>>13,Dt=x[1]|0,ft=Dt&8191,Zt=Dt>>>13,Ra=x[2]|0,Yt=Ra&8191,Jt=Ra>>>13,Ta=x[3]|0,Xt=Ta&8191,Qt=Ta>>>13,Ma=x[4]|0,te=Ma&8191,ee=Ma>>>13,Pa=x[5]|0,re=Pa&8191,ne=Pa>>>13,Ca=x[6]|0,ie=Ca&8191,se=Ca>>>13,La=x[7]|0,oe=La&8191,ae=La>>>13,Oa=x[8]|0,ce=Oa&8191,ue=Oa>>>13,Ua=x[9]|0,le=Ua&8191,he=Ua>>>13;y.negative=c.negative^p.negative,y.length=19,v=Math.imul(S,gt),a=Math.imul(S,dt),a=a+Math.imul(U,gt)|0,l=Math.imul(U,dt);var Xi=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(Xi>>>26)|0,Xi&=67108863,v=Math.imul(nt,gt),a=Math.imul(nt,dt),a=a+Math.imul(ct,gt)|0,l=Math.imul(ct,dt),v=v+Math.imul(S,ft)|0,a=a+Math.imul(S,Zt)|0,a=a+Math.imul(U,ft)|0,l=l+Math.imul(U,Zt)|0;var Qi=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,v=Math.imul(pt,gt),a=Math.imul(pt,dt),a=a+Math.imul(vt,gt)|0,l=Math.imul(vt,dt),v=v+Math.imul(nt,ft)|0,a=a+Math.imul(nt,Zt)|0,a=a+Math.imul(ct,ft)|0,l=l+Math.imul(ct,Zt)|0,v=v+Math.imul(S,Yt)|0,a=a+Math.imul(S,Jt)|0,a=a+Math.imul(U,Yt)|0,l=l+Math.imul(U,Jt)|0;var ts=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(ts>>>26)|0,ts&=67108863,v=Math.imul(St,gt),a=Math.imul(St,dt),a=a+Math.imul(Tt,gt)|0,l=Math.imul(Tt,dt),v=v+Math.imul(pt,ft)|0,a=a+Math.imul(pt,Zt)|0,a=a+Math.imul(vt,ft)|0,l=l+Math.imul(vt,Zt)|0,v=v+Math.imul(nt,Yt)|0,a=a+Math.imul(nt,Jt)|0,a=a+Math.imul(ct,Yt)|0,l=l+Math.imul(ct,Jt)|0,v=v+Math.imul(S,Xt)|0,a=a+Math.imul(S,Qt)|0,a=a+Math.imul(U,Xt)|0,l=l+Math.imul(U,Qt)|0;var es=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(es>>>26)|0,es&=67108863,v=Math.imul(Ct,gt),a=Math.imul(Ct,dt),a=a+Math.imul(Wt,gt)|0,l=Math.imul(Wt,dt),v=v+Math.imul(St,ft)|0,a=a+Math.imul(St,Zt)|0,a=a+Math.imul(Tt,ft)|0,l=l+Math.imul(Tt,Zt)|0,v=v+Math.imul(pt,Yt)|0,a=a+Math.imul(pt,Jt)|0,a=a+Math.imul(vt,Yt)|0,l=l+Math.imul(vt,Jt)|0,v=v+Math.imul(nt,Xt)|0,a=a+Math.imul(nt,Qt)|0,a=a+Math.imul(ct,Xt)|0,l=l+Math.imul(ct,Qt)|0,v=v+Math.imul(S,te)|0,a=a+Math.imul(S,ee)|0,a=a+Math.imul(U,te)|0,l=l+Math.imul(U,ee)|0;var rs=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(rs>>>26)|0,rs&=67108863,v=Math.imul(zt,gt),a=Math.imul(zt,dt),a=a+Math.imul(Lt,gt)|0,l=Math.imul(Lt,dt),v=v+Math.imul(Ct,ft)|0,a=a+Math.imul(Ct,Zt)|0,a=a+Math.imul(Wt,ft)|0,l=l+Math.imul(Wt,Zt)|0,v=v+Math.imul(St,Yt)|0,a=a+Math.imul(St,Jt)|0,a=a+Math.imul(Tt,Yt)|0,l=l+Math.imul(Tt,Jt)|0,v=v+Math.imul(pt,Xt)|0,a=a+Math.imul(pt,Qt)|0,a=a+Math.imul(vt,Xt)|0,l=l+Math.imul(vt,Qt)|0,v=v+Math.imul(nt,te)|0,a=a+Math.imul(nt,ee)|0,a=a+Math.imul(ct,te)|0,l=l+Math.imul(ct,ee)|0,v=v+Math.imul(S,re)|0,a=a+Math.imul(S,ne)|0,a=a+Math.imul(U,re)|0,l=l+Math.imul(U,ne)|0;var ns=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(ns>>>26)|0,ns&=67108863,v=Math.imul(Ot,gt),a=Math.imul(Ot,dt),a=a+Math.imul(Ft,gt)|0,l=Math.imul(Ft,dt),v=v+Math.imul(zt,ft)|0,a=a+Math.imul(zt,Zt)|0,a=a+Math.imul(Lt,ft)|0,l=l+Math.imul(Lt,Zt)|0,v=v+Math.imul(Ct,Yt)|0,a=a+Math.imul(Ct,Jt)|0,a=a+Math.imul(Wt,Yt)|0,l=l+Math.imul(Wt,Jt)|0,v=v+Math.imul(St,Xt)|0,a=a+Math.imul(St,Qt)|0,a=a+Math.imul(Tt,Xt)|0,l=l+Math.imul(Tt,Qt)|0,v=v+Math.imul(pt,te)|0,a=a+Math.imul(pt,ee)|0,a=a+Math.imul(vt,te)|0,l=l+Math.imul(vt,ee)|0,v=v+Math.imul(nt,re)|0,a=a+Math.imul(nt,ne)|0,a=a+Math.imul(ct,re)|0,l=l+Math.imul(ct,ne)|0,v=v+Math.imul(S,ie)|0,a=a+Math.imul(S,se)|0,a=a+Math.imul(U,ie)|0,l=l+Math.imul(U,se)|0;var is=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(is>>>26)|0,is&=67108863,v=Math.imul(qt,gt),a=Math.imul(qt,dt),a=a+Math.imul(m,gt)|0,l=Math.imul(m,dt),v=v+Math.imul(Ot,ft)|0,a=a+Math.imul(Ot,Zt)|0,a=a+Math.imul(Ft,ft)|0,l=l+Math.imul(Ft,Zt)|0,v=v+Math.imul(zt,Yt)|0,a=a+Math.imul(zt,Jt)|0,a=a+Math.imul(Lt,Yt)|0,l=l+Math.imul(Lt,Jt)|0,v=v+Math.imul(Ct,Xt)|0,a=a+Math.imul(Ct,Qt)|0,a=a+Math.imul(Wt,Xt)|0,l=l+Math.imul(Wt,Qt)|0,v=v+Math.imul(St,te)|0,a=a+Math.imul(St,ee)|0,a=a+Math.imul(Tt,te)|0,l=l+Math.imul(Tt,ee)|0,v=v+Math.imul(pt,re)|0,a=a+Math.imul(pt,ne)|0,a=a+Math.imul(vt,re)|0,l=l+Math.imul(vt,ne)|0,v=v+Math.imul(nt,ie)|0,a=a+Math.imul(nt,se)|0,a=a+Math.imul(ct,ie)|0,l=l+Math.imul(ct,se)|0,v=v+Math.imul(S,oe)|0,a=a+Math.imul(S,ae)|0,a=a+Math.imul(U,oe)|0,l=l+Math.imul(U,ae)|0;var ss=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(ss>>>26)|0,ss&=67108863,v=Math.imul(d,gt),a=Math.imul(d,dt),a=a+Math.imul(B,gt)|0,l=Math.imul(B,dt),v=v+Math.imul(qt,ft)|0,a=a+Math.imul(qt,Zt)|0,a=a+Math.imul(m,ft)|0,l=l+Math.imul(m,Zt)|0,v=v+Math.imul(Ot,Yt)|0,a=a+Math.imul(Ot,Jt)|0,a=a+Math.imul(Ft,Yt)|0,l=l+Math.imul(Ft,Jt)|0,v=v+Math.imul(zt,Xt)|0,a=a+Math.imul(zt,Qt)|0,a=a+Math.imul(Lt,Xt)|0,l=l+Math.imul(Lt,Qt)|0,v=v+Math.imul(Ct,te)|0,a=a+Math.imul(Ct,ee)|0,a=a+Math.imul(Wt,te)|0,l=l+Math.imul(Wt,ee)|0,v=v+Math.imul(St,re)|0,a=a+Math.imul(St,ne)|0,a=a+Math.imul(Tt,re)|0,l=l+Math.imul(Tt,ne)|0,v=v+Math.imul(pt,ie)|0,a=a+Math.imul(pt,se)|0,a=a+Math.imul(vt,ie)|0,l=l+Math.imul(vt,se)|0,v=v+Math.imul(nt,oe)|0,a=a+Math.imul(nt,ae)|0,a=a+Math.imul(ct,oe)|0,l=l+Math.imul(ct,ae)|0,v=v+Math.imul(S,ce)|0,a=a+Math.imul(S,ue)|0,a=a+Math.imul(U,ce)|0,l=l+Math.imul(U,ue)|0;var os=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(os>>>26)|0,os&=67108863,v=Math.imul(z,gt),a=Math.imul(z,dt),a=a+Math.imul(G,gt)|0,l=Math.imul(G,dt),v=v+Math.imul(d,ft)|0,a=a+Math.imul(d,Zt)|0,a=a+Math.imul(B,ft)|0,l=l+Math.imul(B,Zt)|0,v=v+Math.imul(qt,Yt)|0,a=a+Math.imul(qt,Jt)|0,a=a+Math.imul(m,Yt)|0,l=l+Math.imul(m,Jt)|0,v=v+Math.imul(Ot,Xt)|0,a=a+Math.imul(Ot,Qt)|0,a=a+Math.imul(Ft,Xt)|0,l=l+Math.imul(Ft,Qt)|0,v=v+Math.imul(zt,te)|0,a=a+Math.imul(zt,ee)|0,a=a+Math.imul(Lt,te)|0,l=l+Math.imul(Lt,ee)|0,v=v+Math.imul(Ct,re)|0,a=a+Math.imul(Ct,ne)|0,a=a+Math.imul(Wt,re)|0,l=l+Math.imul(Wt,ne)|0,v=v+Math.imul(St,ie)|0,a=a+Math.imul(St,se)|0,a=a+Math.imul(Tt,ie)|0,l=l+Math.imul(Tt,se)|0,v=v+Math.imul(pt,oe)|0,a=a+Math.imul(pt,ae)|0,a=a+Math.imul(vt,oe)|0,l=l+Math.imul(vt,ae)|0,v=v+Math.imul(nt,ce)|0,a=a+Math.imul(nt,ue)|0,a=a+Math.imul(ct,ce)|0,l=l+Math.imul(ct,ue)|0,v=v+Math.imul(S,le)|0,a=a+Math.imul(S,he)|0,a=a+Math.imul(U,le)|0,l=l+Math.imul(U,he)|0;var as=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(as>>>26)|0,as&=67108863,v=Math.imul(z,ft),a=Math.imul(z,Zt),a=a+Math.imul(G,ft)|0,l=Math.imul(G,Zt),v=v+Math.imul(d,Yt)|0,a=a+Math.imul(d,Jt)|0,a=a+Math.imul(B,Yt)|0,l=l+Math.imul(B,Jt)|0,v=v+Math.imul(qt,Xt)|0,a=a+Math.imul(qt,Qt)|0,a=a+Math.imul(m,Xt)|0,l=l+Math.imul(m,Qt)|0,v=v+Math.imul(Ot,te)|0,a=a+Math.imul(Ot,ee)|0,a=a+Math.imul(Ft,te)|0,l=l+Math.imul(Ft,ee)|0,v=v+Math.imul(zt,re)|0,a=a+Math.imul(zt,ne)|0,a=a+Math.imul(Lt,re)|0,l=l+Math.imul(Lt,ne)|0,v=v+Math.imul(Ct,ie)|0,a=a+Math.imul(Ct,se)|0,a=a+Math.imul(Wt,ie)|0,l=l+Math.imul(Wt,se)|0,v=v+Math.imul(St,oe)|0,a=a+Math.imul(St,ae)|0,a=a+Math.imul(Tt,oe)|0,l=l+Math.imul(Tt,ae)|0,v=v+Math.imul(pt,ce)|0,a=a+Math.imul(pt,ue)|0,a=a+Math.imul(vt,ce)|0,l=l+Math.imul(vt,ue)|0,v=v+Math.imul(nt,le)|0,a=a+Math.imul(nt,he)|0,a=a+Math.imul(ct,le)|0,l=l+Math.imul(ct,he)|0;var cs=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(cs>>>26)|0,cs&=67108863,v=Math.imul(z,Yt),a=Math.imul(z,Jt),a=a+Math.imul(G,Yt)|0,l=Math.imul(G,Jt),v=v+Math.imul(d,Xt)|0,a=a+Math.imul(d,Qt)|0,a=a+Math.imul(B,Xt)|0,l=l+Math.imul(B,Qt)|0,v=v+Math.imul(qt,te)|0,a=a+Math.imul(qt,ee)|0,a=a+Math.imul(m,te)|0,l=l+Math.imul(m,ee)|0,v=v+Math.imul(Ot,re)|0,a=a+Math.imul(Ot,ne)|0,a=a+Math.imul(Ft,re)|0,l=l+Math.imul(Ft,ne)|0,v=v+Math.imul(zt,ie)|0,a=a+Math.imul(zt,se)|0,a=a+Math.imul(Lt,ie)|0,l=l+Math.imul(Lt,se)|0,v=v+Math.imul(Ct,oe)|0,a=a+Math.imul(Ct,ae)|0,a=a+Math.imul(Wt,oe)|0,l=l+Math.imul(Wt,ae)|0,v=v+Math.imul(St,ce)|0,a=a+Math.imul(St,ue)|0,a=a+Math.imul(Tt,ce)|0,l=l+Math.imul(Tt,ue)|0,v=v+Math.imul(pt,le)|0,a=a+Math.imul(pt,he)|0,a=a+Math.imul(vt,le)|0,l=l+Math.imul(vt,he)|0;var us=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(us>>>26)|0,us&=67108863,v=Math.imul(z,Xt),a=Math.imul(z,Qt),a=a+Math.imul(G,Xt)|0,l=Math.imul(G,Qt),v=v+Math.imul(d,te)|0,a=a+Math.imul(d,ee)|0,a=a+Math.imul(B,te)|0,l=l+Math.imul(B,ee)|0,v=v+Math.imul(qt,re)|0,a=a+Math.imul(qt,ne)|0,a=a+Math.imul(m,re)|0,l=l+Math.imul(m,ne)|0,v=v+Math.imul(Ot,ie)|0,a=a+Math.imul(Ot,se)|0,a=a+Math.imul(Ft,ie)|0,l=l+Math.imul(Ft,se)|0,v=v+Math.imul(zt,oe)|0,a=a+Math.imul(zt,ae)|0,a=a+Math.imul(Lt,oe)|0,l=l+Math.imul(Lt,ae)|0,v=v+Math.imul(Ct,ce)|0,a=a+Math.imul(Ct,ue)|0,a=a+Math.imul(Wt,ce)|0,l=l+Math.imul(Wt,ue)|0,v=v+Math.imul(St,le)|0,a=a+Math.imul(St,he)|0,a=a+Math.imul(Tt,le)|0,l=l+Math.imul(Tt,he)|0;var ls=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(ls>>>26)|0,ls&=67108863,v=Math.imul(z,te),a=Math.imul(z,ee),a=a+Math.imul(G,te)|0,l=Math.imul(G,ee),v=v+Math.imul(d,re)|0,a=a+Math.imul(d,ne)|0,a=a+Math.imul(B,re)|0,l=l+Math.imul(B,ne)|0,v=v+Math.imul(qt,ie)|0,a=a+Math.imul(qt,se)|0,a=a+Math.imul(m,ie)|0,l=l+Math.imul(m,se)|0,v=v+Math.imul(Ot,oe)|0,a=a+Math.imul(Ot,ae)|0,a=a+Math.imul(Ft,oe)|0,l=l+Math.imul(Ft,ae)|0,v=v+Math.imul(zt,ce)|0,a=a+Math.imul(zt,ue)|0,a=a+Math.imul(Lt,ce)|0,l=l+Math.imul(Lt,ue)|0,v=v+Math.imul(Ct,le)|0,a=a+Math.imul(Ct,he)|0,a=a+Math.imul(Wt,le)|0,l=l+Math.imul(Wt,he)|0;var hs=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(hs>>>26)|0,hs&=67108863,v=Math.imul(z,re),a=Math.imul(z,ne),a=a+Math.imul(G,re)|0,l=Math.imul(G,ne),v=v+Math.imul(d,ie)|0,a=a+Math.imul(d,se)|0,a=a+Math.imul(B,ie)|0,l=l+Math.imul(B,se)|0,v=v+Math.imul(qt,oe)|0,a=a+Math.imul(qt,ae)|0,a=a+Math.imul(m,oe)|0,l=l+Math.imul(m,ae)|0,v=v+Math.imul(Ot,ce)|0,a=a+Math.imul(Ot,ue)|0,a=a+Math.imul(Ft,ce)|0,l=l+Math.imul(Ft,ue)|0,v=v+Math.imul(zt,le)|0,a=a+Math.imul(zt,he)|0,a=a+Math.imul(Lt,le)|0,l=l+Math.imul(Lt,he)|0;var fs=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(fs>>>26)|0,fs&=67108863,v=Math.imul(z,ie),a=Math.imul(z,se),a=a+Math.imul(G,ie)|0,l=Math.imul(G,se),v=v+Math.imul(d,oe)|0,a=a+Math.imul(d,ae)|0,a=a+Math.imul(B,oe)|0,l=l+Math.imul(B,ae)|0,v=v+Math.imul(qt,ce)|0,a=a+Math.imul(qt,ue)|0,a=a+Math.imul(m,ce)|0,l=l+Math.imul(m,ue)|0,v=v+Math.imul(Ot,le)|0,a=a+Math.imul(Ot,he)|0,a=a+Math.imul(Ft,le)|0,l=l+Math.imul(Ft,he)|0;var ds=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(ds>>>26)|0,ds&=67108863,v=Math.imul(z,oe),a=Math.imul(z,ae),a=a+Math.imul(G,oe)|0,l=Math.imul(G,ae),v=v+Math.imul(d,ce)|0,a=a+Math.imul(d,ue)|0,a=a+Math.imul(B,ce)|0,l=l+Math.imul(B,ue)|0,v=v+Math.imul(qt,le)|0,a=a+Math.imul(qt,he)|0,a=a+Math.imul(m,le)|0,l=l+Math.imul(m,he)|0;var ps=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(ps>>>26)|0,ps&=67108863,v=Math.imul(z,ce),a=Math.imul(z,ue),a=a+Math.imul(G,ce)|0,l=Math.imul(G,ue),v=v+Math.imul(d,le)|0,a=a+Math.imul(d,he)|0,a=a+Math.imul(B,le)|0,l=l+Math.imul(B,he)|0;var gs=(L+v|0)+((a&8191)<<13)|0;L=(l+(a>>>13)|0)+(gs>>>26)|0,gs&=67108863,v=Math.imul(z,le),a=Math.imul(z,he),a=a+Math.imul(G,le)|0,l=Math.imul(G,he);var ys=(L+v|0)+((a&8191)<<13)|0;return L=(l+(a>>>13)|0)+(ys>>>26)|0,ys&=67108863,E[0]=Xi,E[1]=Qi,E[2]=ts,E[3]=es,E[4]=rs,E[5]=ns,E[6]=is,E[7]=ss,E[8]=os,E[9]=as,E[10]=cs,E[11]=us,E[12]=ls,E[13]=hs,E[14]=fs,E[15]=ds,E[16]=ps,E[17]=gs,E[18]=ys,L!==0&&(E[19]=L,y.length++),y};Math.imul||($=O);function q(I,c,p){p.negative=c.negative^I.negative,p.length=I.length+c.length;for(var y=0,A=0,x=0;x<p.length-1;x++){var E=A;A=0;for(var L=y&67108863,v=Math.min(x,c.length-1),a=Math.max(0,x-I.length+1);a<=v;a++){var l=x-a,b=I.words[l]|0,S=c.words[a]|0,U=b*S,j=U&67108863;E=E+(U/67108864|0)|0,j=j+L|0,L=j&67108863,E=E+(j>>>26)|0,A+=E>>>26,E&=67108863}p.words[x]=L,y=E,E=A}return y!==0?p.words[x]=y:p.length--,p._strip()}function X(I,c,p){return q(I,c,p)}i.prototype.mulTo=function(c,p){var y,A=this.length+c.length;return this.length===10&&c.length===10?y=$(this,c,p):A<63?y=O(this,c,p):A<1024?y=q(this,c,p):y=X(this,c,p),y},i.prototype.mul=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),this.mulTo(c,p)},i.prototype.mulf=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),X(this,c,p)},i.prototype.imul=function(c){return this.clone().mulTo(c,this)},i.prototype.imuln=function(c){var p=c<0;p&&(c=-c),r(typeof c=="number"),r(c<67108864);for(var y=0,A=0;A<this.length;A++){var x=(this.words[A]|0)*c,E=(x&67108863)+(y&67108863);y>>=26,y+=x/67108864|0,y+=E>>>26,this.words[A]=E&67108863}return y!==0&&(this.words[A]=y,this.length++),p?this.ineg():this},i.prototype.muln=function(c){return this.clone().imuln(c)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(c){var p=T(c);if(p.length===0)return new i(1);for(var y=this,A=0;A<p.length&&p[A]===0;A++,y=y.sqr());if(++A<p.length)for(var x=y.sqr();A<p.length;A++,x=x.sqr())p[A]!==0&&(y=y.mul(x));return y},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=67108863>>>26-p<<26-p,x;if(p!==0){var E=0;for(x=0;x<this.length;x++){var L=this.words[x]&A,v=(this.words[x]|0)-L<<p;this.words[x]=v|E,E=L>>>26-p}E&&(this.words[x]=E,this.length++)}if(y!==0){for(x=this.length-1;x>=0;x--)this.words[x+y]=this.words[x];for(x=0;x<y;x++)this.words[x]=0;this.length+=y}return this._strip()},i.prototype.ishln=function(c){return r(this.negative===0),this.iushln(c)},i.prototype.iushrn=function(c,p,y){r(typeof c=="number"&&c>=0);var A;p?A=(p-p%26)/26:A=0;var x=c%26,E=Math.min((c-x)/26,this.length),L=67108863^67108863>>>x<<x,v=y;if(A-=E,A=Math.max(0,A),v){for(var a=0;a<E;a++)v.words[a]=this.words[a];v.length=E}if(E!==0)if(this.length>E)for(this.length-=E,a=0;a<this.length;a++)this.words[a]=this.words[a+E];else this.words[0]=0,this.length=1;var l=0;for(a=this.length-1;a>=0&&(l!==0||a>=A);a--){var b=this.words[a]|0;this.words[a]=l<<26-x|b>>>x,l=b&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(c,p,y){return r(this.negative===0),this.iushrn(c,p,y)},i.prototype.shln=function(c){return this.clone().ishln(c)},i.prototype.ushln=function(c){return this.clone().iushln(c)},i.prototype.shrn=function(c){return this.clone().ishrn(c)},i.prototype.ushrn=function(c){return this.clone().iushrn(c)},i.prototype.testn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return!1;var x=this.words[y];return!!(x&A)},i.prototype.imaskn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(p!==0&&y++,this.length=Math.min(y,this.length),p!==0){var A=67108863^67108863>>>p<<p;this.words[this.length-1]&=A}return this._strip()},i.prototype.maskn=function(c){return this.clone().imaskn(c)},i.prototype.iaddn=function(c){return r(typeof c=="number"),r(c<67108864),c<0?this.isubn(-c):this.negative!==0?this.length===1&&(this.words[0]|0)<=c?(this.words[0]=c-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(c),this.negative=1,this):this._iaddn(c)},i.prototype._iaddn=function(c){this.words[0]+=c;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(c){if(r(typeof c=="number"),r(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,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(c){return this.clone().iaddn(c)},i.prototype.subn=function(c){return this.clone().isubn(c)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(c,p,y){var A=c.length+y,x;this._expand(A);var E,L=0;for(x=0;x<c.length;x++){E=(this.words[x+y]|0)+L;var v=(c.words[x]|0)*p;E-=v&67108863,L=(E>>26)-(v/67108864|0),this.words[x+y]=E&67108863}for(;x<this.length-y;x++)E=(this.words[x+y]|0)+L,L=E>>26,this.words[x+y]=E&67108863;if(L===0)return this._strip();for(r(L===-1),L=0,x=0;x<this.length;x++)E=-(this.words[x]|0)+L,L=E>>26,this.words[x]=E&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var y=this.length-c.length,A=this.clone(),x=c,E=x.words[x.length-1]|0,L=this._countBits(E);y=26-L,y!==0&&(x=x.ushln(y),A.iushln(y),E=x.words[x.length-1]|0);var v=A.length-x.length,a;if(p!=="mod"){a=new i(null),a.length=v+1,a.words=new Array(a.length);for(var l=0;l<a.length;l++)a.words[l]=0}var b=A.clone()._ishlnsubmul(x,1,v);b.negative===0&&(A=b,a&&(a.words[v]=1));for(var S=v-1;S>=0;S--){var U=(A.words[x.length+S]|0)*67108864+(A.words[x.length+S-1]|0);for(U=Math.min(U/E|0,67108863),A._ishlnsubmul(x,U,S);A.negative!==0;)U--,A.negative=0,A._ishlnsubmul(x,1,S),A.isZero()||(A.negative^=1);a&&(a.words[S]=U)}return a&&a._strip(),A._strip(),p!=="div"&&y!==0&&A.iushrn(y),{div:a||null,mod:A}},i.prototype.divmod=function(c,p,y){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var A,x,E;return this.negative!==0&&c.negative===0?(E=this.neg().divmod(c,p),p!=="mod"&&(A=E.div.neg()),p!=="div"&&(x=E.mod.neg(),y&&x.negative!==0&&x.iadd(c)),{div:A,mod:x}):this.negative===0&&c.negative!==0?(E=this.divmod(c.neg(),p),p!=="mod"&&(A=E.div.neg()),{div:A,mod:E.mod}):(this.negative&c.negative)!==0?(E=this.neg().divmod(c.neg(),p),p!=="div"&&(x=E.mod.neg(),y&&x.negative!==0&&x.isub(c)),{div:E.div,mod:x}):c.length>this.length||this.cmp(c)<0?{div:new i(0),mod:this}:c.length===1?p==="div"?{div:this.divn(c.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new i(this.modrn(c.words[0]))}:this._wordDiv(c,p)},i.prototype.div=function(c){return this.divmod(c,"div",!1).div},i.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},i.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},i.prototype.divRound=function(c){var p=this.divmod(c);if(p.mod.isZero())return p.div;var y=p.div.negative!==0?p.mod.isub(c):p.mod,A=c.ushrn(1),x=c.andln(1),E=y.cmp(A);return E<0||x===1&&E===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=(1<<26)%c,A=0,x=this.length-1;x>=0;x--)A=(y*A+(this.words[x]|0))%c;return p?-A:A},i.prototype.modn=function(c){return this.modrn(c)},i.prototype.idivn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=0,A=this.length-1;A>=0;A--){var x=(this.words[A]|0)+y*67108864;this.words[A]=x/c|0,y=x%c}return this._strip(),p?this.ineg():this},i.prototype.divn=function(c){return this.clone().idivn(c)},i.prototype.egcd=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),x=new i(0),E=new i(0),L=new i(1),v=0;p.isEven()&&y.isEven();)p.iushrn(1),y.iushrn(1),++v;for(var a=y.clone(),l=p.clone();!p.isZero();){for(var b=0,S=1;(p.words[0]&S)===0&&b<26;++b,S<<=1);if(b>0)for(p.iushrn(b);b-- >0;)(A.isOdd()||x.isOdd())&&(A.iadd(a),x.isub(l)),A.iushrn(1),x.iushrn(1);for(var U=0,j=1;(y.words[0]&j)===0&&U<26;++U,j<<=1);if(U>0)for(y.iushrn(U);U-- >0;)(E.isOdd()||L.isOdd())&&(E.iadd(a),L.isub(l)),E.iushrn(1),L.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(E),x.isub(L)):(y.isub(p),E.isub(A),L.isub(x))}return{a:E,b:L,gcd:y.iushln(v)}},i.prototype._invmp=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),x=new i(0),E=y.clone();p.cmpn(1)>0&&y.cmpn(1)>0;){for(var L=0,v=1;(p.words[0]&v)===0&&L<26;++L,v<<=1);if(L>0)for(p.iushrn(L);L-- >0;)A.isOdd()&&A.iadd(E),A.iushrn(1);for(var a=0,l=1;(y.words[0]&l)===0&&a<26;++a,l<<=1);if(a>0)for(y.iushrn(a);a-- >0;)x.isOdd()&&x.iadd(E),x.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(x)):(y.isub(p),x.isub(A))}var b;return p.cmpn(1)===0?b=A:b=x,b.cmpn(0)<0&&b.iadd(c),b},i.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var p=this.clone(),y=c.clone();p.negative=0,y.negative=0;for(var A=0;p.isEven()&&y.isEven();A++)p.iushrn(1),y.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;y.isEven();)y.iushrn(1);var x=p.cmp(y);if(x<0){var E=p;p=y,y=E}else if(x===0||y.cmpn(1)===0)break;p.isub(y)}while(!0);return y.iushln(A)},i.prototype.invm=function(c){return this.egcd(c).a.umod(c)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(c){return this.words[0]&c},i.prototype.bincn=function(c){r(typeof c=="number");var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return this._expand(y+1),this.words[y]|=A,this;for(var x=A,E=y;x!==0&&E<this.length;E++){var L=this.words[E]|0;L+=x,x=L>>>26,L&=67108863,this.words[E]=L}return x!==0&&(this.words[E]=x,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(c){var p=c<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var y;if(this.length>1)y=1;else{p&&(c=-c),r(c<=67108863,"Number is too big");var A=this.words[0]|0;y=A===c?0:A<c?-1:1}return this.negative!==0?-y|0:y},i.prototype.cmp=function(c){if(this.negative!==0&&c.negative===0)return-1;if(this.negative===0&&c.negative!==0)return 1;var p=this.ucmp(c);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var p=0,y=this.length-1;y>=0;y--){var A=this.words[y]|0,x=c.words[y]|0;if(A!==x){A<x?p=-1:A>x&&(p=1);break}}return p},i.prototype.gtn=function(c){return this.cmpn(c)===1},i.prototype.gt=function(c){return this.cmp(c)===1},i.prototype.gten=function(c){return this.cmpn(c)>=0},i.prototype.gte=function(c){return this.cmp(c)>=0},i.prototype.ltn=function(c){return this.cmpn(c)===-1},i.prototype.lt=function(c){return this.cmp(c)===-1},i.prototype.lten=function(c){return this.cmpn(c)<=0},i.prototype.lte=function(c){return this.cmp(c)<=0},i.prototype.eqn=function(c){return this.cmpn(c)===0},i.prototype.eq=function(c){return this.cmp(c)===0},i.red=function(c){return new V(c)},i.prototype.toRed=function(c){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(c){return this.red=c,this},i.prototype.forceRed=function(c){return r(!this.red,"Already a number in reduction context"),this._forceRed(c)},i.prototype.redAdd=function(c){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},i.prototype.redIAdd=function(c){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},i.prototype.redSub=function(c){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},i.prototype.redISub=function(c){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},i.prototype.redShl=function(c){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},i.prototype.redMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},i.prototype.redIMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},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(c){return r(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var W={k256:null,p224:null,p192:null,p25519:null};function F(I,c){this.name=I,this.p=new i(c,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 c=new i(null);return c.words=new Array(Math.ceil(this.n/13)),c},F.prototype.ireduce=function(c){var p=c,y;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),y=p.bitLength();while(y>this.n);var A=y<this.n?-1:p.ucmp(this.p);return A===0?(p.words[0]=0,p.length=1):A>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},F.prototype.split=function(c,p){c.iushrn(this.n,0,p)},F.prototype.imulK=function(c){return c.imul(this.k)};function Y(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(Y,F),Y.prototype.split=function(c,p){for(var y=4194303,A=Math.min(c.length,9),x=0;x<A;x++)p.words[x]=c.words[x];if(p.length=A,c.length<=9){c.words[0]=0,c.length=1;return}var E=c.words[9];for(p.words[p.length++]=E&y,x=10;x<c.length;x++){var L=c.words[x]|0;c.words[x-10]=(L&y)<<4|E>>>22,E=L}E>>>=22,c.words[x-10]=E,E===0&&c.length>10?c.length-=10:c.length-=9},Y.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var p=0,y=0;y<c.length;y++){var A=c.words[y]|0;p+=A*977,c.words[y]=p&67108863,p=A*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};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 D(){F.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(D,F),D.prototype.imulK=function(c){for(var p=0,y=0;y<c.length;y++){var A=(c.words[y]|0)*19+p,x=A&67108863;A>>>=26,c.words[y]=x,p=A}return p!==0&&(c.words[c.length++]=p),c},i._prime=function(c){if(W[c])return W[c];var p;if(c==="k256")p=new Y;else if(c==="p224")p=new Z;else if(c==="p192")p=new J;else if(c==="p25519")p=new D;else throw new Error("Unknown prime "+c);return W[c]=p,p};function V(I){if(typeof I=="string"){var c=i._prime(I);this.m=c.p,this.prime=c}else r(I.gtn(1),"modulus must be greater than 1"),this.m=I,this.prime=null}V.prototype._verify1=function(c){r(c.negative===0,"red works only with positives"),r(c.red,"red works only with red numbers")},V.prototype._verify2=function(c,p){r((c.negative|p.negative)===0,"red works only with positives"),r(c.red&&c.red===p.red,"red works only with red numbers")},V.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(w(c,c.umod(this.m)._forceRed(this)),c)},V.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},V.prototype.add=function(c,p){this._verify2(c,p);var y=c.add(p);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},V.prototype.iadd=function(c,p){this._verify2(c,p);var y=c.iadd(p);return y.cmp(this.m)>=0&&y.isub(this.m),y},V.prototype.sub=function(c,p){this._verify2(c,p);var y=c.sub(p);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},V.prototype.isub=function(c,p){this._verify2(c,p);var y=c.isub(p);return y.cmpn(0)<0&&y.iadd(this.m),y},V.prototype.shl=function(c,p){return this._verify1(c),this.imod(c.ushln(p))},V.prototype.imul=function(c,p){return this._verify2(c,p),this.imod(c.imul(p))},V.prototype.mul=function(c,p){return this._verify2(c,p),this.imod(c.mul(p))},V.prototype.isqr=function(c){return this.imul(c,c.clone())},V.prototype.sqr=function(c){return this.mul(c,c)},V.prototype.sqrt=function(c){if(c.isZero())return c.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var y=this.m.add(new i(1)).iushrn(2);return this.pow(c,y)}for(var A=this.m.subn(1),x=0;!A.isZero()&&A.andln(1)===0;)x++,A.iushrn(1);r(!A.isZero());var E=new i(1).toRed(this),L=E.redNeg(),v=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new i(2*a*a).toRed(this);this.pow(a,v).cmp(L)!==0;)a.redIAdd(L);for(var l=this.pow(a,A),b=this.pow(c,A.addn(1).iushrn(1)),S=this.pow(c,A),U=x;S.cmp(E)!==0;){for(var j=S,nt=0;j.cmp(E)!==0;nt++)j=j.redSqr();r(nt<U);var ct=this.pow(l,new i(1).iushln(U-nt-1));b=b.redMul(ct),l=ct.redSqr(),S=S.redMul(l),U=nt}return b},V.prototype.invm=function(c){var p=c._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},V.prototype.pow=function(c,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return c.clone();var y=4,A=new Array(1<<y);A[0]=new i(1).toRed(this),A[1]=c;for(var x=2;x<A.length;x++)A[x]=this.mul(A[x-1],c);var E=A[0],L=0,v=0,a=p.bitLength()%26;for(a===0&&(a=26),x=p.length-1;x>=0;x--){for(var l=p.words[x],b=a-1;b>=0;b--){var S=l>>b&1;if(E!==A[0]&&(E=this.sqr(E)),S===0&&L===0){v=0;continue}L<<=1,L|=S,v++,!(v!==y&&(x!==0||b!==0))&&(E=this.mul(E,A[L]),v=0,L=0)}a=26}return E},V.prototype.convertTo=function(c){var p=c.umod(this.m);return p===c?p.clone():p},V.prototype.convertFrom=function(c){var p=c.clone();return p.red=null,p},i.mont=function(c){return new Q(c)};function Q(I){V.call(this,I),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(c){return this.imod(c.ushln(this.shift))},Q.prototype.convertFrom=function(c){var p=this.imod(c.mul(this.rinv));return p.red=null,p},Q.prototype.imul=function(c,p){if(c.isZero()||p.isZero())return c.words[0]=0,c.length=1,c;var y=c.imul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=y.isub(A).iushrn(this.shift),E=x;return x.cmp(this.m)>=0?E=x.isub(this.m):x.cmpn(0)<0&&(E=x.iadd(this.m)),E._forceRed(this)},Q.prototype.mul=function(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var y=c.mul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=y.isub(A).iushrn(this.shift),E=x;return x.cmp(this.m)>=0?E=x.isub(this.m):x.cmpn(0)<0&&(E=x.iadd(this.m)),E._forceRed(this)},Q.prototype.invm=function(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(n,Kc)}(an)),an.exports}var Wc=Zs();const Ys=Nr(Wc);var cn={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Js;function $c(){return Js||(Js=1,function(n,t){var e=zn(),r=e.Buffer;function s(o,u){for(var f in o)u[f]=o[f]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(s(e,t),t.Buffer=i);function i(o,u,f){return r(o,u,f)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,u,f){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,u,f)},i.alloc=function(o,u,f){if(typeof o!="number")throw new TypeError("Argument must be a number");var g=r(o);return u!==void 0?typeof f=="string"?g.fill(u,f):g.fill(u):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 Qn,Xs;function Hc(){if(Xs)return Qn;Xs=1;var n=$c().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),u=o.charCodeAt(0);if(r[u]!==255)throw new TypeError(o+" is ambiguous");r[u]=i}var f=e.length,g=e.charAt(0),w=Math.log(f)/Math.log(256),k=Math.log(256)/Math.log(f);function M(_){if((Array.isArray(_)||_ instanceof Uint8Array)&&(_=n.from(_)),!n.isBuffer(_))throw new TypeError("Expected Buffer");if(_.length===0)return"";for(var T=0,O=0,$=0,q=_.length;$!==q&&_[$]===0;)$++,T++;for(var X=(q-$)*k+1>>>0,W=new Uint8Array(X);$!==q;){for(var F=_[$],Y=0,Z=X-1;(F!==0||Y<O)&&Z!==-1;Z--,Y++)F+=256*W[Z]>>>0,W[Z]=F%f>>>0,F=F/f>>>0;if(F!==0)throw new Error("Non-zero carry");O=Y,$++}for(var J=X-O;J!==X&&W[J]===0;)J++;for(var D=g.repeat(T);J<X;++J)D+=e.charAt(W[J]);return D}function R(_){if(typeof _!="string")throw new TypeError("Expected String");if(_.length===0)return n.alloc(0);for(var T=0,O=0,$=0;_[T]===g;)O++,T++;for(var q=(_.length-T)*w+1>>>0,X=new Uint8Array(q);_[T];){var W=r[_.charCodeAt(T)];if(W===255)return;for(var F=0,Y=q-1;(W!==0||F<$)&&Y!==-1;Y--,F++)W+=f*X[Y]>>>0,X[Y]=W%256>>>0,W=W/256>>>0;if(W!==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 D=O;Z!==q;)J[D++]=X[Z++];return J}function C(_){var T=R(_);if(T)return T;throw new Error("Non-base"+f+" character")}return{encode:M,decodeUnsafe:R,decode:C}}return Qn=t,Qn}var ti,Qs;function to(){if(Qs)return ti;Qs=1;var n=Hc(),t="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return ti=n(t),ti}var Vc=to();const ge=Nr(Vc),jc=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 Gc extends Bs{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:u,H:f}=this;return[t,e,r,s,i,o,u,f]}set(t,e,r,s,i,o,u,f){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=u|0,this.H=f|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,_=Oe(R,17)^Oe(R,19)^R>>>10;Qe[k]=_+Qe[k-7]+C+Qe[k-16]|0}let{A:r,B:s,C:i,D:o,E:u,F:f,G:g,H:w}=this;for(let k=0;k<64;k++){const M=Oe(u,6)^Oe(u,11)^Oe(u,25),R=w+M+Va(u,f,g)+jc[k]+Qe[k]|0,_=(Oe(r,2)^Oe(r,13)^Oe(r,22))+ja(r,s,i)|0;w=g,g=f,f=u,u=o+R|0,o=i,i=s,s=r,r=R+_|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,u=u+this.E|0,f=f+this.F|0,g=g+this.G|0,w=w+this.H|0,this.set(r,s,i,o,u,f,g,w)}roundClean(){Qe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ei=Wn(()=>new Gc);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 Zc(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 u=i&1023,f=o&1023;s.push(65536+(u<<10)+f),r+=1}else s.push(65533)}r+=1}return s}function Yc(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 ri(n){this.tokens=[].slice.call(n)}ri.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 Ar=-1;function ni(n,t){if(n)throw TypeError("Decoder error");return t||65533}var hn="utf-8";function fn(n,t){if(!(this instanceof fn))return new fn(n,t);if(n=n!==void 0?String(n).toLowerCase():hn,n!==hn)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})}fn.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 Jc({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var s=new ri(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Ar);)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===Ar)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),Yc(i)}};function dn(n,t){if(!(this instanceof dn))return new dn(n,t);if(n=n!==void 0?String(n).toLowerCase():hn,n!==hn)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 Xc(this._options)),this._streaming=!!e.stream;for(var r=[],s=new ri(Zc(t)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Ar);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Ar;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function Jc(n){var t=n.fatal,e=0,r=0,s=0,i=128,o=191;this.handler=function(u,f){if(f===ln&&s!==0)return s=0,ni(t);if(f===ln)return Ar;if(s===0){if(Ve(f,0,127))return f;if(Ve(f,194,223))s=1,e=f-192;else if(Ve(f,224,239))f===224&&(i=160),f===237&&(o=159),s=2,e=f-224;else if(Ve(f,240,244))f===240&&(i=144),f===244&&(o=143),s=3,e=f-240;else return ni(t);return e=e<<6*s,null}if(!Ve(f,i,o))return e=s=r=0,i=128,o=191,u.prepend(f),ni(t);if(i=128,o=191,r+=1,e+=f-128<<6*(s-r),r!==s)return null;var g=e;return e=s=r=0,g}}function Xc(n){n.fatal,this.handler=function(t,e){if(e===ln)return Ar;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 Qc=Nn(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:fn,TextEncoder:dn},Symbol.toStringTag,{value:"Module"})));var eo;function tu(){if(eo)return Mt;eo=1;var n=Mt&&Mt.__createBinding||(Object.create?function(J,D,V,Q){Q===void 0&&(Q=V),Object.defineProperty(J,Q,{enumerable:!0,get:function(){return D[V]}})}:function(J,D,V,Q){Q===void 0&&(Q=V),J[Q]=D[V]}),t=Mt&&Mt.__setModuleDefault||(Object.create?function(J,D){Object.defineProperty(J,"default",{enumerable:!0,value:D})}:function(J,D){J.default=D}),e=Mt&&Mt.__decorate||function(J,D,V,Q){var I=arguments.length,c=I<3?D:Q===null?Q=Object.getOwnPropertyDescriptor(D,V):Q,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(J,D,V,Q);else for(var y=J.length-1;y>=0;y--)(p=J[y])&&(c=(I<3?p(c):I>3?p(D,V,c):p(D,V))||c);return I>3&&c&&Object.defineProperty(D,V,c),c},r=Mt&&Mt.__importStar||function(J){if(J&&J.__esModule)return J;var D={};if(J!=null)for(var V in J)V!=="default"&&Object.hasOwnProperty.call(J,V)&&n(D,J,V);return t(D,J),D},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(Zs()),o=s(to()),u=r(Qc),f=typeof TextDecoder!="function"?u.TextDecoder:TextDecoder,g=new f("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(D){super(D),this.fieldPath=[],this.originalMessage=D}addToFieldPath(D){this.fieldPath.splice(0,0,D),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(D){this.maybeResize(),this.buf.writeUInt8(D,this.length),this.length+=1}writeU16(D){this.maybeResize(),this.buf.writeUInt16LE(D,this.length),this.length+=2}writeU32(D){this.maybeResize(),this.buf.writeUInt32LE(D,this.length),this.length+=4}writeU64(D){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(D).toArray("le",8)))}writeU128(D){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(D).toArray("le",16)))}writeU256(D){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(D).toArray("le",32)))}writeU512(D){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(D).toArray("le",64)))}writeBuffer(D){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),D,Buffer.alloc(M)]),this.length+=D.length}writeString(D){this.maybeResize();const V=Buffer.from(D,"utf8");this.writeU32(V.length),this.writeBuffer(V)}writeFixedArray(D){this.writeBuffer(Buffer.from(D))}writeArray(D,V){this.maybeResize(),this.writeU32(D.length);for(const Q of D)this.maybeResize(),V(Q)}toArray(){return this.buf.subarray(0,this.length)}}Mt.BinaryWriter=C;function _(J,D,V){const Q=V.value;V.value=function(...I){try{return Q.apply(this,I)}catch(c){if(c instanceof RangeError){const p=c.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 c}}}class T{constructor(D){this.buf=D,this.offset=0}readU8(){const D=this.buf.readUInt8(this.offset);return this.offset+=1,D}readU16(){const D=this.buf.readUInt16LE(this.offset);return this.offset+=2,D}readU32(){const D=this.buf.readUInt32LE(this.offset);return this.offset+=4,D}readU64(){const D=this.readBuffer(8);return new i.default(D,"le")}readU128(){const D=this.readBuffer(16);return new i.default(D,"le")}readU256(){const D=this.readBuffer(32);return new i.default(D,"le")}readU512(){const D=this.readBuffer(64);return new i.default(D,"le")}readBuffer(D){if(this.offset+D>this.buf.length)throw new R(`Expected buffer length ${D} isn't within bounds`);const V=this.buf.slice(this.offset,this.offset+D);return this.offset+=D,V}readString(){const D=this.readU32(),V=this.readBuffer(D);try{return g.decode(V)}catch(Q){throw new R(`Error decoding UTF-8 string: ${Q}`)}}readFixedArray(D){return new Uint8Array(this.readBuffer(D))}readArray(D){const V=this.readU32(),Q=Array();for(let I=0;I<V;++I)Q.push(D());return Q}}e([_],T.prototype,"readU8",null),e([_],T.prototype,"readU16",null),e([_],T.prototype,"readU32",null),e([_],T.prototype,"readU64",null),e([_],T.prototype,"readU128",null),e([_],T.prototype,"readU256",null),e([_],T.prototype,"readU512",null),e([_],T.prototype,"readString",null),e([_],T.prototype,"readFixedArray",null),e([_],T.prototype,"readArray",null),Mt.BinaryReader=T;function O(J){return J.charAt(0).toUpperCase()+J.slice(1)}function $(J,D,V,Q,I){try{if(typeof Q=="string")I[`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`);I.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 c=0;c<Q[1];c++)$(J,null,V[c],Q[0],I)}else I.writeArray(V,c=>{$(J,D,c,Q[0],I)});else if(Q.kind!==void 0)switch(Q.kind){case"option":{V==null?I.writeU8(0):(I.writeU8(1),$(J,D,V,Q.type,I));break}case"map":{I.writeU32(V.size),V.forEach((c,p)=>{$(J,D,p,Q.key,I),$(J,D,c,Q.value,I)});break}default:throw new R(`FieldType ${Q} unrecognized`)}else q(J,V,I)}catch(c){throw c instanceof R&&c.addToFieldPath(D),c}}function q(J,D,V){if(typeof D.borshSerialize=="function"){D.borshSerialize(V);return}const Q=J.get(D.constructor);if(!Q)throw new R(`Class ${D.constructor.name} is missing in schema`);if(Q.kind==="struct")Q.fields.map(([I,c])=>{$(J,I,D[I],c,V)});else if(Q.kind==="enum"){const I=D[Q.field];for(let c=0;c<Q.values.length;++c){const[p,y]=Q.values[c];if(p===I){V.writeU8(c),$(J,p,D[p],y,V);break}}}else throw new R(`Unexpected schema kind: ${Q.kind} for ${D.constructor.name}`)}function X(J,D,V=C){const Q=new V;return q(J,D,Q),Q.toArray()}Mt.serialize=X;function W(J,D,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 I=[];for(let c=0;c<V[1];c++)I.push(W(J,null,V[0],Q));return I}else return Q.readArray(()=>W(J,D,V[0],Q))}if(V.kind==="option")return Q.readU8()?W(J,D,V.type,Q):void 0;if(V.kind==="map"){let I=new Map;const c=Q.readU32();for(let p=0;p<c;p++){const y=W(J,D,V.key,Q),A=W(J,D,V.value,Q);I.set(y,A)}return I}return F(J,V,Q)}catch(I){throw I instanceof R&&I.addToFieldPath(D),I}}function F(J,D,V){if(typeof D.borshDeserialize=="function")return D.borshDeserialize(V);const Q=J.get(D);if(!Q)throw new R(`Class ${D.name} is missing in schema`);if(Q.kind==="struct"){const I={};for(const[c,p]of J.get(D).fields)I[c]=W(J,c,p,V);return new D(I)}if(Q.kind==="enum"){const I=V.readU8();if(I>=Q.values.length)throw new R(`Enum index: ${I} is out of range`);const[c,p]=Q.values[I],y=W(J,c,p,V);return new D({[c]:y})}throw new R(`Unexpected schema kind: ${Q.kind} for ${D.constructor.name}`)}function Y(J,D,V,Q=T){const I=new Q(V),c=F(J,D,I);if(I.offset<V.length)throw new R(`Unexpected ${V.length-I.offset} bytes after deserialized data`);return c}Mt.deserialize=Y;function Z(J,D,V,Q=T){const I=new Q(V);return F(J,D,I)}return Mt.deserializeUnchecked=Z,Mt}var ii=tu(),H={},ro;function eu(){if(ro)return H;ro=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=zn();function t(a){if(!(a instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}H.checkUint8Array=t;function e(a){return t(a),n.Buffer.from(a.buffer,a.byteOffset,a.length)}H.uint8ArrayToBuffer=e;let r=class{constructor(l,b){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=b}makeDestinationObject(){return{}}getSpan(l,b){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const b=Object.create(this.constructor.prototype);return Object.assign(b,this),b.property=l,b}fromArray(l){}};H.Layout=r;function s(a,l){return l.property?a+"["+l.property+"]":a}H.nameWithProperty=s;function i(a,l){if(typeof a!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(a,"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");a.layout_=l,l.boundConstructor_=a,l.makeDestinationObject=()=>new a,Object.defineProperty(a.prototype,"encode",{value(b,S){return l.encode(this,b,S)},writable:!0}),Object.defineProperty(a,"decode",{value(b,S){return l.decode(b,S)},writable:!0})}H.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}H.ExternalLayout=o;class u extends o{constructor(l=1,b){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,b),this.elementSpan=l}isCount(){return!0}decode(l,b=0){t(l);const S=l.length-b;return Math.floor(S/this.elementSpan)}encode(l,b,S){return 0}}H.GreedyCount=u;class f extends o{constructor(l,b=0,S){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(b))throw new TypeError("offset must be integer or undefined");super(l.span,S||l.property),this.layout=l,this.offset=b}isCount(){return this.layout instanceof g||this.layout instanceof w}decode(l,b=0){return this.layout.decode(l,b+this.offset)}encode(l,b,S=0){return this.layout.encode(l,b,S+this.offset)}}H.OffsetLayout=f;class g extends r{constructor(l,b){if(super(l,b),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,b=0){return e(l).readUIntLE(b,this.span)}encode(l,b,S=0){return e(b).writeUIntLE(l,S,this.span),this.span}}H.UInt=g;class w extends r{constructor(l,b){if(super(l,b),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,b=0){return e(l).readUIntBE(b,this.span)}encode(l,b,S=0){return e(b).writeUIntBE(l,S,this.span),this.span}}H.UIntBE=w;class k extends r{constructor(l,b){if(super(l,b),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,b=0){return e(l).readIntLE(b,this.span)}encode(l,b,S=0){return e(b).writeIntLE(l,S,this.span),this.span}}H.Int=k;class M extends r{constructor(l,b){if(super(l,b),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,b=0){return e(l).readIntBE(b,this.span)}encode(l,b,S=0){return e(b).writeIntBE(l,S,this.span),this.span}}H.IntBE=M;const R=Math.pow(2,32);function C(a){const l=Math.floor(a/R),b=a-l*R;return{hi32:l,lo32:b}}function _(a,l){return a*R+l}class T extends r{constructor(l){super(8,l)}decode(l,b=0){const S=e(l),U=S.readUInt32LE(b),j=S.readUInt32LE(b+4);return _(j,U)}encode(l,b,S=0){const U=C(l),j=e(b);return j.writeUInt32LE(U.lo32,S),j.writeUInt32LE(U.hi32,S+4),8}}H.NearUInt64=T;class O extends r{constructor(l){super(8,l)}decode(l,b=0){const S=e(l),U=S.readUInt32BE(b),j=S.readUInt32BE(b+4);return _(U,j)}encode(l,b,S=0){const U=C(l),j=e(b);return j.writeUInt32BE(U.hi32,S),j.writeUInt32BE(U.lo32,S+4),8}}H.NearUInt64BE=O;class $ extends r{constructor(l){super(8,l)}decode(l,b=0){const S=e(l),U=S.readUInt32LE(b),j=S.readInt32LE(b+4);return _(j,U)}encode(l,b,S=0){const U=C(l),j=e(b);return j.writeUInt32LE(U.lo32,S),j.writeInt32LE(U.hi32,S+4),8}}H.NearInt64=$;class q extends r{constructor(l){super(8,l)}decode(l,b=0){const S=e(l),U=S.readInt32BE(b),j=S.readUInt32BE(b+4);return _(U,j)}encode(l,b,S=0){const U=C(l),j=e(b);return j.writeInt32BE(U.hi32,S),j.writeUInt32BE(U.lo32,S+4),8}}H.NearInt64BE=q;class X extends r{constructor(l){super(4,l)}decode(l,b=0){return e(l).readFloatLE(b)}encode(l,b,S=0){return e(b).writeFloatLE(l,S),4}}H.Float=X;class W extends r{constructor(l){super(4,l)}decode(l,b=0){return e(l).readFloatBE(b)}encode(l,b,S=0){return e(b).writeFloatBE(l,S),4}}H.FloatBE=W;class F extends r{constructor(l){super(8,l)}decode(l,b=0){return e(l).readDoubleLE(b)}encode(l,b,S=0){return e(b).writeDoubleLE(l,S),8}}H.Double=F;class Y extends r{constructor(l){super(8,l)}decode(l,b=0){return e(l).readDoubleBE(b)}encode(l,b,S=0){return e(b).writeDoubleBE(l,S),8}}H.DoubleBE=Y;class Z extends r{constructor(l,b,S){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(b instanceof o&&b.isCount()||Number.isInteger(b)&&0<=b))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let U=-1;!(b instanceof o)&&0<l.span&&(U=b*l.span),super(U,S),this.elementLayout=l,this.count=b}getSpan(l,b=0){if(0<=this.span)return this.span;let S=0,U=this.count;if(U instanceof o&&(U=U.decode(l,b)),0<this.elementLayout.span)S=U*this.elementLayout.span;else{let j=0;for(;j<U;)S+=this.elementLayout.getSpan(l,b+S),++j}return S}decode(l,b=0){const S=[];let U=0,j=this.count;for(j instanceof o&&(j=j.decode(l,b));U<j;)S.push(this.elementLayout.decode(l,b)),b+=this.elementLayout.getSpan(l,b),U+=1;return S}encode(l,b,S=0){const U=this.elementLayout,j=l.reduce((nt,ct)=>nt+U.encode(ct,b,S+nt),0);return this.count instanceof o&&this.count.encode(l.length,b,S),j}}H.Sequence=Z;class J extends r{constructor(l,b,S){if(!(Array.isArray(l)&&l.reduce((j,nt)=>j&&nt instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof b=="boolean"&&S===void 0&&(S=b,b=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,b),this.fields=l,this.decodePrefixes=!!S}getSpan(l,b=0){if(0<=this.span)return this.span;let S=0;try{S=this.fields.reduce((U,j)=>{const nt=j.getSpan(l,b);return b+=nt,U+nt},0)}catch{throw new RangeError("indeterminate span")}return S}decode(l,b=0){t(l);const S=this.makeDestinationObject();for(const U of this.fields)if(U.property!==void 0&&(S[U.property]=U.decode(l,b)),b+=U.getSpan(l,b),this.decodePrefixes&&l.length===b)break;return S}encode(l,b,S=0){const U=S;let j=0,nt=0;for(const ct of this.fields){let At=ct.span;if(nt=0<At?At:0,ct.property!==void 0){const pt=l[ct.property];pt!==void 0&&(nt=ct.encode(pt,b,S),0>At&&(At=ct.getSpan(b,S)))}j=S,S+=At}return j+nt-U}fromArray(l){const b=this.makeDestinationObject();for(const S of this.fields)S.property!==void 0&&0<l.length&&(b[S.property]=l.shift());return b}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const b of this.fields)if(b.property===l)return b}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let b=0;for(const S of this.fields){if(S.property===l)return b;0>S.span?b=-1:0<=b&&(b+=S.span)}}}H.Structure=J;class D{constructor(l){this.property=l}decode(l,b){throw new Error("UnionDiscriminator is abstract")}encode(l,b,S){throw new Error("UnionDiscriminator is abstract")}}H.UnionDiscriminator=D;class V extends D{constructor(l,b){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(b||l.property||"variant"),this.layout=l}decode(l,b){return this.layout.decode(l,b)}encode(l,b,S){return this.layout.encode(l,b,S)}}H.UnionLayoutDiscriminator=V;class Q extends r{constructor(l,b,S){let U;if(l instanceof g||l instanceof w)U=new V(new f(l));else if(l instanceof o&&l.isCount())U=new V(l);else if(l instanceof D)U=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(b===void 0&&(b=null),!(b===null||b instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(b!==null){if(0>b.span)throw new Error("defaultLayout must have constant span");b.property===void 0&&(b=b.replicate("content"))}let j=-1;b&&(j=b.span,0<=j&&(l instanceof g||l instanceof w)&&(j+=U.layout.span)),super(j,S),this.discriminator=U,this.usesPrefixDiscriminator=l instanceof g||l instanceof w,this.defaultLayout=b,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,b=0){if(0<=this.span)return this.span;const S=this.getVariant(l,b);if(!S)throw new Error("unable to determine span for unrecognized variant");return S.getSpan(l,b)}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 b=this.registry[l[this.discriminator.property]];if(b&&(!b.layout||b.property&&Object.prototype.hasOwnProperty.call(l,b.property)))return b}else for(const b in this.registry){const S=this.registry[b];if(S.property&&Object.prototype.hasOwnProperty.call(l,S.property))return S}throw new Error("unable to infer src variant")}decode(l,b=0){let S;const U=this.discriminator,j=U.decode(l,b),nt=this.registry[j];if(nt===void 0){const ct=this.defaultLayout;let At=0;this.usesPrefixDiscriminator&&(At=U.layout.span),S=this.makeDestinationObject(),S[U.property]=j,S[ct.property]=ct.decode(l,b+At)}else S=nt.decode(l,b);return S}encode(l,b,S=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],b,S),ct+nt.encode(l[nt.property],b,S+ct)}return U.encode(l,b,S)}addVariant(l,b,S){const U=new I(this,l,b,S);return this.registry[l]=U,U}getVariant(l,b=0){let S;return l instanceof Uint8Array?S=this.discriminator.decode(l,b):S=l,this.registry[S]}}H.Union=Q;class I extends r{constructor(l,b,S,U){if(!(l instanceof Q))throw new TypeError("union must be a Union");if(!Number.isInteger(b)||0>b)throw new TypeError("variant must be a (non-negative) integer");if(typeof S=="string"&&U===void 0&&(U=S,S=null),S){if(!(S instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=S.span&&S.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=S?S.span:0,0<=j&&l.usesPrefixDiscriminator&&(j+=l.discriminator.layout.span)),super(j,U),this.union=l,this.variant=b,this.layout=S||null}getSpan(l,b=0){if(0<=this.span)return this.span;let S=0;this.union.usesPrefixDiscriminator&&(S=this.union.discriminator.layout.span);let U=0;return this.layout&&(U=this.layout.getSpan(l,b+S)),S+U}decode(l,b=0){const S=this.makeDestinationObject();if(this!==this.union.getVariant(l,b))throw new Error("variant mismatch");let U=0;return this.union.usesPrefixDiscriminator&&(U=this.union.discriminator.layout.span),this.layout?S[this.property]=this.layout.decode(l,b+U):this.property?S[this.property]=!0:this.union.usesPrefixDiscriminator&&(S[this.union.discriminator.property]=this.variant),S}encode(l,b,S=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,b,S);let j=U;if(this.layout&&(this.layout.encode(l[this.property],b,S+U),j+=this.layout.getSpan(b,S+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=I;function c(a){return 0>a&&(a+=4294967296),a}class p extends r{constructor(l,b,S){if(!(l instanceof g||l instanceof w))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof b=="string"&&S===void 0&&(S=b,b=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,S),this.word=l,this.msb=!!b,this.fields=[];let U=0;this._packedSetValue=function(j){return U=c(j),this},this._packedGetValue=function(){return U}}decode(l,b=0){const S=this.makeDestinationObject(),U=this.word.decode(l,b);this._packedSetValue(U);for(const j of this.fields)j.property!==void 0&&(S[j.property]=j.decode(l));return S}encode(l,b,S=0){const U=this.word.decode(b,S);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(),b,S)}addField(l,b){const S=new y(this,l,b);return this.fields.push(S),S}addBoolean(l){const b=new A(this,l);return this.fields.push(b),b}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const b of this.fields)if(b.property===l)return b}}H.BitStructure=p;class y{constructor(l,b,S){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(b)||0>=b)throw new TypeError("bits must be positive integer");const U=8*l.span,j=l.fields.reduce((nt,ct)=>nt+ct.bits,0);if(b+j>U)throw new Error("bits too long for span remainder ("+(U-j)+" of "+U+" remain)");this.container=l,this.bits=b,this.valueMask=(1<<b)-1,b===32&&(this.valueMask=4294967295),this.start=j,this.container.msb&&(this.start=U-j-b),this.wordMask=c(this.valueMask<<this.start),this.property=S}decode(l,b){const S=this.container._packedGetValue();return c(S&this.wordMask)>>>this.start}encode(l){if(typeof l!="number"||!Number.isInteger(l)||l!==c(l&this.valueMask))throw new TypeError(s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const b=this.container._packedGetValue(),S=c(l<<this.start);this.container._packedSetValue(c(b&~this.wordMask)|S)}}H.BitField=y;class A extends y{constructor(l,b){super(l,1,b)}decode(l,b){return!!super.decode(l,b)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}H.Boolean=A;class x extends r{constructor(l,b){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 S=-1;l instanceof o||(S=l),super(S,b),this.length=l}getSpan(l,b){let S=this.span;return 0>S&&(S=this.length.decode(l,b)),S}decode(l,b=0){let S=this.span;return 0>S&&(S=this.length.decode(l,b)),e(l).slice(b,b+S)}encode(l,b,S){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(S+U>b.length)throw new RangeError("encoding overruns Uint8Array");const j=e(l);return e(b).write(j.toString("hex"),S,U,"hex"),this.length instanceof o&&this.length.encode(U,b,S),U}}H.Blob=x;class E extends r{constructor(l){super(-1,l)}getSpan(l,b=0){t(l);let S=b;for(;S<l.length&&l[S]!==0;)S+=1;return 1+S-b}decode(l,b=0){const S=this.getSpan(l,b);return e(l).slice(b,b+S-1).toString("utf-8")}encode(l,b,S=0){typeof l!="string"&&(l=String(l));const U=n.Buffer.from(l,"utf8"),j=U.length;if(S+j>b.length)throw new RangeError("encoding overruns Buffer");const nt=e(b);return U.copy(nt,S),nt[S+j]=0,j+1}}H.CString=E;class L extends r{constructor(l,b){if(typeof l=="string"&&b===void 0&&(b=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,b),this.maxSpan=l}getSpan(l,b=0){return t(l),l.length-b}decode(l,b=0){const S=this.getSpan(l,b);if(0<=this.maxSpan&&this.maxSpan<S)throw new RangeError("text length exceeds maxSpan");return e(l).slice(b,b+S).toString("utf-8")}encode(l,b,S=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(S+j>b.length)throw new RangeError("encoding overruns Buffer");return U.copy(e(b),S),j}}H.UTF8=L;class v extends r{constructor(l,b){super(0,b),this.value=l}decode(l,b){return this.value}encode(l,b,S){return 0}}return H.Constant=v,H.greedy=(a,l)=>new u(a,l),H.offset=(a,l,b)=>new f(a,l,b),H.u8=a=>new g(1,a),H.u16=a=>new g(2,a),H.u24=a=>new g(3,a),H.u32=a=>new g(4,a),H.u40=a=>new g(5,a),H.u48=a=>new g(6,a),H.nu64=a=>new T(a),H.u16be=a=>new w(2,a),H.u24be=a=>new w(3,a),H.u32be=a=>new w(4,a),H.u40be=a=>new w(5,a),H.u48be=a=>new w(6,a),H.nu64be=a=>new O(a),H.s8=a=>new k(1,a),H.s16=a=>new k(2,a),H.s24=a=>new k(3,a),H.s32=a=>new k(4,a),H.s40=a=>new k(5,a),H.s48=a=>new k(6,a),H.ns64=a=>new $(a),H.s16be=a=>new M(2,a),H.s24be=a=>new M(3,a),H.s32be=a=>new M(4,a),H.s40be=a=>new M(5,a),H.s48be=a=>new M(6,a),H.ns64be=a=>new q(a),H.f32=a=>new X(a),H.f32be=a=>new W(a),H.f64=a=>new F(a),H.f64be=a=>new Y(a),H.struct=(a,l,b)=>new J(a,l,b),H.bits=(a,l,b)=>new p(a,l,b),H.seq=(a,l,b)=>new Z(a,l,b),H.union=(a,l,b)=>new Q(a,l,b),H.unionLayoutDiscriminator=(a,l)=>new V(a,l),H.blob=(a,l)=>new x(a,l),H.cstr=a=>new E(a),H.utf8=(a,l)=>new L(a,l),H.constant=(a,l)=>new v(a,l),H}var P=eu(),lr={},no;function ru(){if(no)return lr;no=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),u=Buffer.from(o.padStart(i*2,"0").slice(0,i*2),"hex");return u.reverse(),u}}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 si=ru();class nu extends TypeError{constructor(t,e){let r;const{message:s,explanation:i,...o}=t,{path:u}=t,f=u.length===0?s:`At path: ${u.join(".")} -- ${s}`;super(i??f),i!=null&&(this.cause=f),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}}function iu(n){return Kr(n)&&typeof n[Symbol.iterator]=="function"}function Kr(n){return typeof n=="object"&&n!=null}function pn(n){return Kr(n)&&!Array.isArray(n)}function Pe(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function su(n){const{done:t,value:e}=n.next();return t?void 0:e}function ou(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:u,message:f=`Expected a value of type \`${o}\`${u?` with refinement \`${u}\``:""}, but received: \`${Pe(r)}\``}=n;return{value:r,type:o,refinement:u,key:s[s.length-1],path:s,branch:i,...n,message:f}}function*io(n,t,e,r){iu(n)||(n=[n]);for(const s of n){const i=ou(s,t,e,r);i&&(yield i)}}function*oi(n,t,e={}){const{path:r=[],branch:s=[n],coerce:i=!1,mask:o=!1}=e,u={path:r,branch:s,mask:o};i&&(n=t.coercer(n,u));let f="valid";for(const g of t.validator(n,u))g.explanation=e.message,f="not_valid",yield[g,void 0];for(let[g,w,k]of t.entries(n,u)){const M=oi(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]?(f=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):Kr(n)&&(w!==void 0||g in n)&&(n[g]=w))}if(f!=="not_valid")for(const g of t.refiner(n,u))g.explanation=e.message,f="not_refined",yield[g,void 0];f==="valid"&&(yield[void 0,n])}let Ue=class{constructor(t){const{type:e,schema:r,validator:s,refiner:i,coercer:o=f=>f,entries:u=function*(){}}=t;this.type=e,this.schema=r,this.entries=u,this.coercer=o,s?this.validator=(f,g)=>{const w=s(f,g);return io(w,g,this,f)}:this.validator=()=>[],i?this.refiner=(f,g)=>{const w=i(f,g);return io(w,g,this,f)}:this.refiner=()=>[]}assert(t,e){return so(t,this,e)}create(t,e){return st(t,this,e)}is(t){return oo(t,this)}mask(t,e){return au(t,this,e)}validate(t,e={}){return Wr(t,this,e)}};function so(n,t,e){const r=Wr(n,t,{message:e});if(r[0])throw r[0]}function st(n,t,e){const r=Wr(n,t,{coerce:!0,message:e});if(r[0])throw r[0];return r[1]}function au(n,t,e){const r=Wr(n,t,{coerce:!0,mask:!0,message:e});if(r[0])throw r[0];return r[1]}function oo(n,t){return!Wr(n,t)[0]}function Wr(n,t,e={}){const r=oi(n,t,e),s=su(r);return s[0]?[new nu(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function hr(n,t){return new Ue({type:n,schema:null,validator:t})}function cu(){return hr("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 hr("boolean",n=>typeof n=="boolean")}function ai(n){return hr("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 uu(){return hr("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 K(){return hr("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${Pe(n)}`)}function lt(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 ao(n,t){return new Ue({type:"record",schema:null,*entries(e){if(Kr(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 hr("string",n=>typeof n=="string"||`Expected a string, but received: ${Pe(n)}`)}function ci(n){const t=uu();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(Kr(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]=oi(e,i,r),[u]=o;if(u[0])for(const[f]of o)f&&s.push(f);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Pe(e)}`,...s]}})}function Br(){return hr("unknown",()=>!0)}function $r(n,t,e){return new Ue({...n,coercer:(r,s)=>oo(r,t)?n.coercer(e(r,s),s):n.coercer(r,s)})}var gn,lu=new Uint8Array(16);function co(){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(lu)}const hu=/^(?:[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"&&hu.test(n)}for(var we=[],ui=0;ui<256;++ui)we.push((ui+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 uo,li,hi=0,fi=0;function fu(n,t,e){var r=t&&e||0,s=t||new Array(16);n=n||{};var i=n.node||uo,o=n.clockseq!==void 0?n.clockseq:li;if(i==null||o==null){var u=n.random||(n.rng||co)();i==null&&(i=uo=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),o==null&&(o=li=(u[6]<<8|u[7])&16383)}var f=n.msecs!==void 0?n.msecs:Date.now(),g=n.nsecs!==void 0?n.nsecs:fi+1,w=f-hi+(g-fi)/1e4;if(w<0&&n.clockseq===void 0&&(o=o+1&16383),(w<0||f>hi)&&n.nsecs===void 0&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");hi=f,fi=g,li=o,f+=122192928e5;var k=((f&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=f/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 lo(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 du(n){n=unescape(encodeURIComponent(n));for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var pu="6ba7b810-9dad-11d1-80b4-00c04fd430c8",gu="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ho(n,t,e){function r(s,i,o,u){if(typeof s=="string"&&(s=du(s)),typeof i=="string"&&(i=lo(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var f=new Uint8Array(16+s.length);if(f.set(i),f.set(s,i.length),f=e(f),f[6]=f[6]&15|t,f[8]=f[8]&63|128,o){u=u||0;for(var g=0;g<16;++g)o[u+g]=f[g];return o}return mn(f)}try{r.name=n}catch{}return r.DNS=pu,r.URL=gu,r}function yu(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 mu(wu(bu(n),n.length*8))}function mu(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 wu(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 u=e,f=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,u),r=tr(r,f),s=tr(s,g),i=tr(i,w)}return[e,r,s,i]}function bu(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 ku(n,t){return n<<t|n>>>32-t}function wn(n,t,e,r,s,i){return tr(ku(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 vu=ho("v3",48,yu);function Su(n,t,e){n=n||{};var r=n.random||(n.rng||co)();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 xu(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 di(n,t){return n<<t|n>>>32-t}function Iu(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),u=new Array(o),f=0;f<o;++f){for(var g=new Uint32Array(16),w=0;w<16;++w)g[w]=n[f*64+w*4]<<24|n[f*64+w*4+1]<<16|n[f*64+w*4+2]<<8|n[f*64+w*4+3];u[f]=g}u[o-1][14]=(n.length-1)*8/Math.pow(2,32),u[o-1][14]=Math.floor(u[o-1][14]),u[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]=u[k][R];for(var C=16;C<80;++C)M[C]=di(M[C-3]^M[C-8]^M[C-14]^M[C-16],1);for(var _=e[0],T=e[1],O=e[2],$=e[3],q=e[4],X=0;X<80;++X){var W=Math.floor(X/20),F=di(_,5)+xu(W,T,O,$)+q+t[W]+M[X]>>>0;q=$,$=O,O=di(T,30)>>>0,T=_,_=F}e[0]=e[0]+_>>>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 Eu=ho("v5",80,Iu);const Au="00000000-0000-0000-0000-000000000000";function Bu(n){if(!yn(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const po=Nn(Object.freeze(Object.defineProperty({__proto__:null,NIL:Au,parse:lo,stringify:mn,v1:fu,v3:vu,v4:Su,v5:Eu,validate:yn,version:Bu},Symbol.toStringTag,{value:"Module"})));var pi,go;function _u(){if(go)return pi;go=1;const n=po.v4;return pi=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 u={method:e};if(o===2&&(u.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");u.params=r}if(typeof s>"u"){const f=typeof i.generator=="function"?i.generator:function(){return n()};u.id=f(u,i)}else o===2&&s===null?i.notificationIdNull&&(u.id=null):u.id=s;return u},pi}var gi,yo;function Ru(){if(yo)return gi;yo=1;const n=po.v4,t=_u(),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 gi=e,e.prototype.request=function(r,s,i,o){const u=this;let f=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,f=r;else{typeof i=="function"&&(o=i,i=void 0);const M=typeof o=="function";try{f=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 f}let k;try{k=JSON.stringify(f,this.options.replacer)}catch(M){return o(M)}return this.callServer(k,function(M,R){u._parseResponse(M,R,o)}),f},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(u){return i(u)}if(i.length===3)if(Array.isArray(o)){const u=function(g){return typeof g.error<"u"},f=function(g){return!u(g)};return i(null,o.filter(u),o.filter(f))}else return i(null,o.error,o.result);i(null,o)},gi}var Tu=Ru();const Mu=Nr(Tu);var yi={exports:{}},mo;function Pu(){return mo||(mo=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(f,g,w){this.fn=f,this.context=g,this.once=w||!1}function i(f,g,w,k,M){if(typeof w!="function")throw new TypeError("The listener must be a function");var R=new s(w,k||f,M),C=e?e+g:g;return f._events[C]?f._events[C].fn?f._events[C]=[f._events[C],R]:f._events[C].push(R):(f._events[C]=R,f._eventsCount++),f}function o(f,g){--f._eventsCount===0?f._events=new r:delete f._events[g]}function u(){this._events=new r,this._eventsCount=0}u.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},u.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},u.prototype.listenerCount=function(g){var w=e?e+g:g,k=this._events[w];return k?k.fn?1:k.length:0},u.prototype.emit=function(g,w,k,M,R,C){var _=e?e+g:g;if(!this._events[_])return!1;var T=this._events[_],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,W;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(W=1,$=new Array(O-1);W<O;W++)$[W-1]=arguments[W];T[q].fn.apply(T[q].context,$)}}return!0},u.prototype.on=function(g,w,k){return i(this,g,w,k,!1)},u.prototype.once=function(g,w,k){return i(this,g,w,k,!0)},u.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 _=0,T=[],O=C.length;_<O;_++)(C[_].fn!==w||M&&!C[_].once||k&&C[_].context!==k)&&T.push(C[_]);T.length?this._events[R]=T.length===1?T[0]:T:o(this,R)}return this},u.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},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,n.exports=u}(yi)),yi.exports}var Cu=Pu();const wo=Nr(Cu);var Lu=class extends wo{constructor(t,e,r){super();fe(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 Ou(n,t){return new Lu(n,t)}var Uu=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},Nu=class extends wo{constructor(t,e="ws://localhost:8080",{autoconnect:r=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...u}={},f,g){super();fe(this,"address");fe(this,"rpc_id");fe(this,"queue");fe(this,"options");fe(this,"autoconnect");fe(this,"ready");fe(this,"reconnect");fe(this,"reconnect_timer_id");fe(this,"reconnect_interval");fe(this,"max_reconnects");fe(this,"rest_options");fe(this,"current_reconnects");fe(this,"generate_request_id");fe(this,"socket");fe(this,"webSocketFactory");fe(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=u,this.current_reconnects=0,this.generate_request_id=f||(()=>++this.rpc_id),g?this.dataPack=g:this.dataPack=new Uu,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 u=this.generate_request_id(t,e),f={jsonrpc:"2.0",method:t,params:e||void 0,id:u};this.socket.send(this.dataPack.encode(f),s,g=>{if(g)return o(g);this.queue[u]={promise:[i,o]},r&&(this.queue[u].timeout=setTimeout(()=>{delete this.queue[u],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=ht.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 bo=[],ko=[],vo=[],Fu=BigInt(0),Hr=BigInt(1),zu=BigInt(2),qu=BigInt(7),Du=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],bo.push(2*(5*r+e)),ko.push((n+1)*(n+2)/2%64);let s=Fu;for(let i=0;i<7;i++)t=(t<<Hr^(t>>qu)*Ku)%Du,t&zu&&(s^=Hr<<(Hr<<BigInt(i))-Hr);vo.push(s)}const[Wu,$u]=Rs(vo,!0),So=(n,t,e)=>e>32?Ps(n,t,e):Ts(n,t,e),xo=(n,t,e)=>e>32?Cs(n,t,e):Ms(n,t,e);function Hu(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 u=(o+8)%10,f=(o+2)%10,g=e[f],w=e[f+1],k=So(g,w,1)^e[u],M=xo(g,w,1)^e[u+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 u=ko[o],f=So(s,i,u),g=xo(s,i,u),w=bo[o];s=n[w],i=n[w+1],n[w]=f,n[w+1]=g}for(let o=0;o<50;o+=10){for(let u=0;u<10;u++)e[u]=n[o+u];for(let u=0;u<10;u++)n[o+u]^=~e[(u+2)%10]&e[(u+4)%10]}n[0]^=Wu[r],n[1]^=$u[r]}e.fill(0)}class mi extends Kn{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=Da(this.state)}keccak(){Is||Es(this.state32),Hu(this.state32,this.rounds),Is||Es(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 u=0;u<o;u++)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)!==0&&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(xs(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 mi(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 Io=((n,t,e)=>Wn(()=>new mi(t,n,e)))(1,136,256/8);class Eo extends Kn{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,qa(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:u}=this;return t=t,t.finished=s,t.destroyed=i,t.blockLen=o,t.outputLen=u,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ao=(n,t,e)=>new Eo(n,t).update(e).digest();Ao.create=(n,t)=>new Eo(n,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Vu(n){const t=Jn(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:ju,hexToBytes:Gu}=mc,fr={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(n){const{Err:t}=fr;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:ju(r),l:n.subarray(e+2)}},toSig(n){const{Err:t}=fr,e=typeof n=="string"?Gu(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}=fr._parseInt(e.subarray(2)),{d:o,l:u}=fr._parseInt(i);if(u.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,u=e(i),f=e(o);return`30${e(o+i+4)}02${f}${s}02${u}${r}`}},je=BigInt(0),Te=BigInt(1);BigInt(2);const Bo=BigInt(3);BigInt(4);function Zu(n){const t=Vu(n),{Fp:e}=t,r=t.toBytes||((C,_,T)=>{const O=_.toAffine();return cr(Uint8Array.from([4]),e.toBytes(O.x),e.toBytes(O.y))}),s=t.fromBytes||(C=>{const _=C.subarray(1),T=e.fromBytes(_.subarray(0,e.BYTES)),O=e.fromBytes(_.subarray(e.BYTES,2*e.BYTES));return{x:T,y:O}});function i(C){const{a:_,b:T}=t,O=e.sqr(C),$=e.mul(O,C);return e.add(e.add($,e.mul(C,_)),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 u(C){if(!o(C))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function f(C){const{allowedPrivateKeyLengths:_,nByteLength:T,wrapPrivateKey:O,n:$}=t;if(_&&typeof C!="bigint"){if(sr(C)&&(C=or(C)),typeof C!="string"||!_.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=Kt(q,$)),u(q),q}const g=new Map;function w(C){if(!(C instanceof k))throw new Error("ProjectivePoint expected")}class k{constructor(_,T,O){if(this.px=_,this.py=T,this.pz=O,_==null||!e.isValid(_))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(_){const{x:T,y:O}=_||{};if(!_||!e.isValid(T)||!e.isValid(O))throw new Error("invalid affine point");if(_ 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(_){const T=e.invertBatch(_.map(O=>O.pz));return _.map((O,$)=>O.toAffine(T[$])).map(k.fromAffine)}static fromHex(_){const T=k.fromAffine(s(de("pointHex",_)));return T.assertValidity(),T}static fromPrivateKey(_){return k.BASE.multiply(f(_))}_setWindowSize(_){this._WINDOW_SIZE=_,g.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:_,y:T}=this.toAffine();if(!e.isValid(_)||!e.isValid(T))throw new Error("bad point: x or y not FE");const O=e.sqr(T),$=i(_);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:_}=this.toAffine();if(e.isOdd)return!e.isOdd(_);throw new Error("Field doesn't support isOdd")}equals(_){w(_);const{px:T,py:O,pz:$}=this,{px:q,py:X,pz:W}=_,F=e.eql(e.mul(T,W),e.mul(q,$)),Y=e.eql(e.mul(O,W),e.mul(X,$));return F&&Y}negate(){return new k(this.px,e.neg(this.py),this.pz)}double(){const{a:_,b:T}=t,O=e.mul(T,Bo),{px:$,py:q,pz:X}=this;let W=e.ZERO,F=e.ZERO,Y=e.ZERO,Z=e.mul($,$),J=e.mul(q,q),D=e.mul(X,X),V=e.mul($,q);return V=e.add(V,V),Y=e.mul($,X),Y=e.add(Y,Y),W=e.mul(_,Y),F=e.mul(O,D),F=e.add(W,F),W=e.sub(J,F),F=e.add(J,F),F=e.mul(W,F),W=e.mul(V,W),Y=e.mul(O,Y),D=e.mul(_,D),V=e.sub(Z,D),V=e.mul(_,V),V=e.add(V,Y),Y=e.add(Z,Z),Z=e.add(Y,Z),Z=e.add(Z,D),Z=e.mul(Z,V),F=e.add(F,Z),D=e.mul(q,X),D=e.add(D,D),Z=e.mul(D,V),W=e.sub(W,Z),Y=e.mul(D,J),Y=e.add(Y,Y),Y=e.add(Y,Y),new k(W,F,Y)}add(_){w(_);const{px:T,py:O,pz:$}=this,{px:q,py:X,pz:W}=_;let F=e.ZERO,Y=e.ZERO,Z=e.ZERO;const J=t.a,D=e.mul(t.b,Bo);let V=e.mul(T,q),Q=e.mul(O,X),I=e.mul($,W),c=e.add(T,O),p=e.add(q,X);c=e.mul(c,p),p=e.add(V,Q),c=e.sub(c,p),p=e.add(T,$);let y=e.add(q,W);return p=e.mul(p,y),y=e.add(V,I),p=e.sub(p,y),y=e.add(O,$),F=e.add(X,W),y=e.mul(y,F),F=e.add(Q,I),y=e.sub(y,F),Z=e.mul(J,p),F=e.mul(D,I),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),I=e.mul(J,I),p=e.mul(D,p),Q=e.add(Q,I),I=e.sub(V,I),I=e.mul(J,I),p=e.add(p,I),V=e.mul(Q,p),Y=e.add(Y,V),V=e.mul(y,p),F=e.mul(c,F),F=e.sub(F,V),V=e.mul(c,Q),Z=e.mul(y,Z),Z=e.add(Z,V),new k(F,Y,Z)}subtract(_){return this.add(_.negate())}is0(){return this.equals(k.ZERO)}wNAF(_){return R.wNAFCached(this,g,_,T=>{const O=e.invertBatch(T.map($=>$.pz));return T.map(($,q)=>$.toAffine(O[q])).map(k.fromAffine)})}multiplyUnsafe(_){const T=k.ZERO;if(_===je)return T;if(u(_),_===Te)return this;const{endo:O}=t;if(!O)return R.unsafeLadder(this,_);let{k1neg:$,k1:q,k2neg:X,k2:W}=O.splitScalar(_),F=T,Y=T,Z=this;for(;q>je||W>je;)q&Te&&(F=F.add(Z)),W&Te&&(Y=Y.add(Z)),Z=Z.double(),q>>=Te,W>>=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(_){u(_);let T=_,O,$;const{endo:q}=t;if(q){const{k1neg:X,k1:W,k2neg:F,k2:Y}=q.splitScalar(T);let{p:Z,f:J}=this.wNAF(W),{p:D,f:V}=this.wNAF(Y);Z=R.constTimeNegate(X,Z),D=R.constTimeNegate(F,D),D=new k(e.mul(D.px,q.beta),D.py,D.pz),O=Z.add(D),$=J.add(V)}else{const{p:X,f:W}=this.wNAF(T);O=X,$=W}return k.normalizeZ([O,$])[0]}multiplyAndAddUnsafe(_,T,O){const $=k.BASE,q=(W,F)=>F===je||F===Te||!W.equals($)?W.multiplyUnsafe(F):W.multiply(F),X=q(this,T).add(q(_,O));return X.is0()?void 0:X}toAffine(_){const{px:T,py:O,pz:$}=this,q=this.is0();_==null&&(_=q?e.ONE:e.inv($));const X=e.mul(T,_),W=e.mul(O,_),F=e.mul($,_);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:W}}isTorsionFree(){const{h:_,isTorsionFree:T}=t;if(_===Te)return!0;if(T)return T(k,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:_,clearCofactor:T}=t;return _===Te?this:T?T(k,this):this.multiplyUnsafe(t.h)}toRawBytes(_=!0){return this.assertValidity(),r(k,this,_)}toHex(_=!0){return or(this.toRawBytes(_))}}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=Hs(k,t.endo?Math.ceil(M/2):M);return{CURVE:t,ProjectivePoint:k,normPrivateKeyToScalar:f,weierstrassEquation:i,isWithinCurveOrder:o}}function Yu(n){const t=Jn(n);return Ir(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ju(n){const t=Yu(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 u(p){return Kt(p,r)}function f(p){return Zn(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:w,weierstrassEquation:k,isWithinCurveOrder:M}=Zu({...t,toBytes(p,y,A){const x=y.toAffine(),E=e.toBytes(x.x),L=cr;return A?L(Uint8Array.from([y.hasEvenY()?2:3]),E):L(Uint8Array.from([4]),E,e.toBytes(x.y))},fromBytes(p){const y=p.length,A=p[0],x=p.subarray(1);if(y===s&&(A===2||A===3)){const E=ar(x);if(!o(E))throw new Error("Point is not on curve");const L=k(E);let v;try{v=e.sqrt(L)}catch(b){const S=b instanceof Error?": "+b.message:"";throw new Error("Point is not on curve"+S)}const a=(v&Te)===Te;return(A&1)===1!==a&&(v=e.neg(v)),{x:E,y:v}}else if(y===i&&A===4){const E=e.fromBytes(x.subarray(0,e.BYTES)),L=e.fromBytes(x.subarray(e.BYTES,2*e.BYTES));return{x:E,y:L}}else throw new Error(`Point of length ${y} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),R=p=>or(xr(p,t.nByteLength));function C(p){const y=r>>Te;return p>y}function _(p){return C(p)?u(-p):p}const T=(p,y,A)=>ar(p.slice(y,A));class O{constructor(y,A,x){this.r=y,this.s=A,this.recovery=x,this.assertValidity()}static fromCompact(y){const A=t.nByteLength;return y=de("compactSignature",y,A*2),new O(T(y,0,A),T(y,A,2*A))}static fromDER(y){const{r:A,s:x}=fr.toSig(de("DER",y));return new O(A,x)}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(y){return new O(this.r,this.s,y)}recoverPublicKey(y){const{r:A,s:x,recovery:E}=this,L=Y(de("msgHash",y));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");const v=E===2||E===3?A+t.n:A;if(v>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const a=(E&1)===0?"02":"03",l=g.fromHex(a+R(v)),b=f(v),S=u(-L*b),U=u(x*b),j=g.BASE.multiplyAndAddUnsafe(l,S,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,u(-this.s),this.recovery):this}toDERRawBytes(){return vr(this.toDERHex())}toDERHex(){return fr.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=$s(t.n);return Bc(t.randomBytes(p),t.n)},precompute(p=8,y=g.BASE){return y._setWindowSize(p),y.multiply(BigInt(3)),y}};function q(p,y=!0){return g.fromPrivateKey(p).toRawBytes(y)}function X(p){const y=sr(p),A=typeof p=="string",x=(y||A)&&p.length;return y?x===s||x===i:A?x===2*s||x===2*i:p instanceof g}function W(p,y,A=!0){if(X(p))throw new Error("first arg must be private key");if(!X(y))throw new Error("second arg must be public key");return g.fromHex(y).multiply(w(p)).toRawBytes(A)}const F=t.bits2int||function(p){const y=ar(p),A=p.length*8-t.nBitLength;return A>0?y>>BigInt(A):y},Y=t.bits2int_modN||function(p){return u(F(p))},Z=Vn(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 D(p,y,A=V){if(["recovered","canonical"].some(ct=>ct in A))throw new Error("sign() legacy options not supported");const{hash:x,randomBytes:E}=t;let{lowS:L,prehash:v,extraEntropy:a}=A;L==null&&(L=!0),p=de("msgHash",p),v&&(p=de("prehashed msgHash",x(p)));const l=Y(p),b=w(y),S=[J(b),J(l)];if(a!=null&&a!==!1){const ct=a===!0?E(e.BYTES):a;S.push(de("extraEntropy",ct))}const U=cr(...S),j=l;function nt(ct){const At=F(ct);if(!M(At))return;const pt=f(At),vt=g.BASE.multiply(At).toAffine(),_t=u(vt.x);if(_t===je)return;const St=u(pt*u(j+_t*b));if(St===je)return;let Tt=(vt.x===_t?0:2)|Number(vt.y&Te),$e=St;return L&&C(St)&&($e=_(St),Tt^=1),new O(_t,$e,Tt)}return{seed:U,k2sig:nt}}const V={lowS:t.lowS,prehash:!1},Q={lowS:t.lowS,prehash:!1};function I(p,y,A=V){const{seed:x,k2sig:E}=D(p,y,A),L=t;return Fs(L.hash.outputLen,L.nByteLength,L.hmac)(x,E)}g.BASE._setWindowSize(8);function c(p,y,A,x=Q){var vt;const E=p;if(y=de("msgHash",y),A=de("publicKey",A),"strict"in x)throw new Error("options.strict was renamed to lowS");const{lowS:L,prehash:v}=x;let a,l;try{if(typeof E=="string"||sr(E))try{a=O.fromDER(E)}catch(_t){if(!(_t instanceof fr.Err))throw _t;a=O.fromCompact(E)}else if(typeof E=="object"&&typeof E.r=="bigint"&&typeof E.s=="bigint"){const{r:_t,s:St}=E;a=new O(_t,St)}else throw new Error("PARSE");l=g.fromHex(A)}catch(_t){if(_t.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(L&&a.hasHighS())return!1;v&&(y=t.hash(y));const{r:b,s:S}=a,U=Y(y),j=f(S),nt=u(U*j),ct=u(b*j),At=(vt=g.BASE.multiplyAndAddUnsafe(l,nt,ct))==null?void 0:vt.toAffine();return At?u(At.x)===b:!1}return{CURVE:t,getPublicKey:q,getSharedSecret:W,sign:I,verify:c,ProjectivePoint:g,Signature:O,utils:$}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Xu(n){return{hash:n,hmac:(t,...e)=>Ao(n,t,$a(...e)),randomBytes:As}}function Qu(n,t){const e=r=>Ju({...n,...Xu(r)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _o=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ro=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),tl=BigInt(1),wi=BigInt(2),To=(n,t)=>(n+t/wi)/t;function el(n){const t=_o,e=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),u=BigInt(44),f=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,wi,t)*g%t,C=jt(R,s,t)*R%t,_=jt(C,i,t)*C%t,T=jt(_,u,t)*_%t,O=jt(T,f,t)*T%t,$=jt(O,u,t)*_%t,q=jt($,e,t)*w%t,X=jt(q,o,t)*C%t,W=jt(X,r,t)*g%t,F=jt(W,wi,t);if(!bi.eql(bi.sqr(F),n))throw new Error("Cannot find square root");return F}const bi=Ks(_o,void 0,void 0,{sqrt:el}),bn=Qu({a:BigInt(0),b:BigInt(7),Fp:bi,n:Ro,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=Ro,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-tl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,o=BigInt("0x100000000000000000000000000000000"),u=To(i*n,t),f=To(-r*n,t);let g=Kt(n-u*e-f*s,t),w=Kt(-u*r-f*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}}}},ei);BigInt(0),bn.ProjectivePoint;const rl=Er.utils.randomPrivateKey,Mo=()=>{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 Po(n){try{return Er.ExtendedPoint.fromHex(n),!0}catch{return!1}}const ki=(n,t)=>Er.sign(n,t.slice(0,32)),nl=Er.verify,wt=n=>ht.Buffer.isBuffer(n)?n:n instanceof Uint8Array?ht.Buffer.from(n.buffer,n.byteOffset,n.byteLength):ht.Buffer.from(n);class vi{constructor(t){Object.assign(this,t)}encode(){return ht.Buffer.from(ii.serialize(Vr,this))}static decode(t){return ii.deserialize(Vr,this,t)}static decodeUnchecked(t){return ii.deserializeUnchecked(Vr,this,t)}}class il extends vi{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 Co;const Lo=32,Fe=32;function sl(n){return n._bn!==void 0}let Oo=1;class it extends vi{constructor(t){if(super({}),this._bn=void 0,sl(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 Ys(e)}else this._bn=new Ys(t);if(this._bn.byteLength()>Fe)throw new Error("Invalid public key input")}}static unique(){const t=new it(Oo);return Oo+=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(ht.Buffer);if(t.length===Fe)return t;const e=ht.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=ht.Buffer.concat([t.toBuffer(),ht.Buffer.from(e),r.toBuffer()]),i=ei(s);return new it(i)}static createProgramAddressSync(t,e){let r=ht.Buffer.alloc(0);t.forEach(function(i){if(i.length>Lo)throw new TypeError("Max seed length exceeded");r=ht.Buffer.concat([r,wt(i)])}),r=ht.Buffer.concat([r,e.toBuffer(),ht.Buffer.from("ProgramDerivedAddress")]);const s=ei(r);if(Po(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(ht.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 Po(e.toBytes())}}Co=it,it.default=new Co("11111111111111111111111111111111"),Vr.set(it,{kind:"struct",fields:[["_bn","u256"]]});class ol{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=wt(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=wt(rl()),this._publicKey=wt(kn(this._secretKey))}get publicKey(){return new it(this._publicKey)}get secretKey(){return ht.Buffer.concat([this._secretKey,this._publicKey],64)}}const al=new it("BPFLoader1111111111111111111111111111111111"),er=1232,vn=127,jr=64;class Si extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Si.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class xi 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(xi.prototype,"name",{value:"TransactionExpiredTimeoutError"});class _r extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(_r.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),cl=(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,u)=>{const f={chars:ht.Buffer.from(i,"utf8")};return r(f,o,u)},s.alloc=i=>P.u32().span+P.u32().span+ht.Buffer.from(i,"utf8").length,s},ul=(n="authorized")=>P.struct([xt("staker"),xt("withdrawer")],n),ll=(n="lockup")=>P.struct([P.ns64("unixTimestamp"),P.ns64("epoch"),xt("custodian")],n),hl=(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 Uo(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 Uo({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)===0)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 u=o.toBase58();let f=r.get(u);return f===void 0&&(f={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(u,f)),f},i=s(e);i.isSigner=!0,i.isWritable=!0;for(const o of t){s(o.programId).isInvoked=!0;for(const u of o.keys){const f=s(u.pubkey);f.isSigner||(f.isSigner=u.isSigner),f.isWritable||(f.isWritable=u.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(([,f])=>f.isSigner&&f.isWritable),r=t.filter(([,f])=>f.isSigner&&!f.isWritable),s=t.filter(([,f])=>!f.isSigner&&f.isWritable),i=t.filter(([,f])=>!f.isSigner&&!f.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[f]=e[0];Et(f===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const u=[...e.map(([f])=>new it(f)),...r.map(([f])=>new it(f)),...s.map(([f])=>new it(f)),...i.map(([f])=>new it(f))];return[o,u]}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 u=new it(i),f=t.findIndex(g=>g.equals(u));f>=0&&(Et(f<256,"Max lookup table index exceeded"),r.push(f),s.push(u),this.keyMetaMap.delete(i))}return[r,s]}}const No="Reached end of buffer unexpectedly";function ze(n){if(n.length===0)throw new Error(No);return n.shift()}function Ae(n,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>n.length:e>=n.length)throw new Error(No);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(u=>({programIdIndex:u.programIdIndex,accounts:u.accountKeyIndexes,data:ge.encode(u.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 _=[];Re(_,M.length);let T=[];return Re(T,C.length),{programIdIndex:R,keyIndicesCount:ht.Buffer.from(_),keyIndices:M,dataLength:ht.Buffer.from(T),data:C}});let s=[];Re(s,r.length);let i=ht.Buffer.alloc(er);ht.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 u=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")]),f={numRequiredSignatures:ht.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:ht.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:ht.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:ht.Buffer.from(e),keys:this.accountKeys.map(k=>wt(k.toBytes())),recentBlockhash:ge.decode(this.recentBlockhash)};let g=ht.Buffer.alloc(2048);const w=u.encode(f,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 u=[];for(let M=0;M<o;M++){const R=Ae(e,0,Fe);u.push(new it(ht.Buffer.from(R)))}const f=Ae(e,0,Fe),g=Ee(e);let w=[];for(let M=0;M<g;M++){const R=ze(e),C=Ee(e),_=Ae(e,0,C),T=Ee(e),O=Ae(e,0,T),$=ge.encode(ht.Buffer.from(O));w.push({programIdIndex:R,accounts:_,data:$})}const k={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:ge.encode(ht.Buffer.from(f)),accountKeys:u,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,u)=>o+u.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,u]=e.getMessageComponents(),g=new Gr(u,s).compileInstructions(t.instructions);return new pr({header:o,staticAccountKeys:u,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")]),u=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},u);return u.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)},u=[],f=Ee(e);for(let C=0;C<f;C++)u.push(new it(Ae(e,0,Fe)));const g=ge.encode(Ae(e,0,Fe)),w=Ee(e),k=[];for(let C=0;C<w;C++){const _=ze(e),T=Ee(e),O=Ae(e,0,T),$=Ee(e),q=new Uint8Array(Ae(e,0,$));k.push({programIdIndex:_,accountKeyIndexes:O,data:q})}const M=Ee(e),R=[];for(let C=0;C<M;C++){const _=new it(Ae(e,0,Fe)),T=Ee(e),O=Ae(e,0,T),$=Ee(e),q=Ae(e,0,$);R.push({accountKey:_,writableIndexes:O,readonlyIndexes:q})}return new pr({header:o,staticAccountKeys:u,recentBlockhash:g,compiledInstructions:k,addressTableLookups:R})}}const Ii={deserializeMessageVersion(n){const t=n[0],e=t&vn;return e===t?"legacy":e},deserialize:n=>{const t=Ii.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 dl=ht.Buffer.alloc(jr).fill(0);class Pt{constructor(t){this.keys=void 0,this.programId=void 0,this.data=ht.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 _=0;_<e.length;_++)if(e[_].programId===void 0)throw new Error(`Transaction instruction index ${_} has undefined program id`);const s=[],i=[];e.forEach(_=>{_.keys.forEach(O=>{i.push({...O})});const T=_.programId.toString();s.includes(T)||s.push(T)}),s.forEach(_=>{i.push({pubkey:new it(_),isSigner:!1,isWritable:!1})});const o=[];i.forEach(_=>{const T=_.pubkey.toString(),O=o.findIndex($=>$.pubkey.toString()===T);O>-1?(o[O].isWritable=o[O].isWritable||_.isWritable,o[O].isSigner=o[O].isSigner||_.isSigner):o.push(_)}),o.sort(function(_,T){if(_.isSigner!==T.isSigner)return _.isSigner?-1:1;if(_.isWritable!==T.isWritable)return _.isWritable?-1:1;const O={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return _.pubkey.toBase58().localeCompare(T.pubkey.toBase58(),"en",O)});const u=o.findIndex(_=>_.pubkey.equals(r));if(u>-1){const[_]=o.splice(u,1);_.isSigner=!0,_.isWritable=!0,o.unshift(_)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const _ of this.signatures){const T=o.findIndex(O=>O.pubkey.equals(_.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: ${_.publicKey.toString()}`)}let f=0,g=0,w=0;const k=[],M=[];o.forEach(({pubkey:_,isSigner:T,isWritable:O})=>{T?(k.push(_.toString()),f+=1,O||(g+=1)):(M.push(_.toString()),O||(w+=1))});const R=k.concat(M),C=e.map(_=>{const{data:T,programId:O}=_;return{programIdIndex:R.indexOf(O.toString()),accounts:_.keys.map($=>R.indexOf($.pubkey.toString())),data:ge.encode(T)}});return C.forEach(_=>{Et(_.programIdIndex>=0),_.accounts.forEach(T=>Et(T>=0))}),new Ce({header:{numRequiredSignatures:f,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=ki(r,s.secretKey);this._addSignature(s.publicKey,wt(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=ht.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):nl(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 xs;function zn(){return xs||(xs=1,function(n){const t=Fa(),e=za(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=u,n.SlowBuffer=W,n.INSPECT_MAX_BYTES=50;const s=2147483647;n.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=i(),!u.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 m=new Uint8Array(1),h={foo:function(){return 42}};return Object.setPrototypeOf(h,Uint8Array.prototype),Object.setPrototypeOf(m,h),m.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function o(m){if(m>s)throw new RangeError('The value "'+m+'" is invalid for option "size"');const h=new Uint8Array(m);return Object.setPrototypeOf(h,u.prototype),h}function u(m,h,d){if(typeof m=="number"){if(typeof h=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return k(m)}return f(m,h,d)}u.poolSize=8192;function f(m,h,d){if(typeof m=="string")return M(m,h);if(ArrayBuffer.isView(m))return C(m);if(m==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m);if(xe(m,ArrayBuffer)||m&&xe(m.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(xe(m,SharedArrayBuffer)||m&&xe(m.buffer,SharedArrayBuffer)))return B(m,h,d);if(typeof m=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const A=m.valueOf&&m.valueOf();if(A!=null&&A!==m)return u.from(A,h,d);const N=T(m);if(N)return N;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof m[Symbol.toPrimitive]=="function")return u.from(m[Symbol.toPrimitive]("string"),h,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m)}u.from=function(m,h,d){return f(m,h,d)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function g(m){if(typeof m!="number")throw new TypeError('"size" argument must be of type number');if(m<0)throw new RangeError('The value "'+m+'" is invalid for option "size"')}function w(m,h,d){return g(m),m<=0?o(m):h!==void 0?typeof d=="string"?o(m).fill(h,d):o(m).fill(h):o(m)}u.alloc=function(m,h,d){return w(m,h,d)};function k(m){return g(m),o(m<0?0:U(m)|0)}u.allocUnsafe=function(m){return k(m)},u.allocUnsafeSlow=function(m){return k(m)};function M(m,h){if((typeof h!="string"||h==="")&&(h="utf8"),!u.isEncoding(h))throw new TypeError("Unknown encoding: "+h);const d=D(m,h)|0;let A=o(d);const N=A.write(m,h);return N!==d&&(A=A.slice(0,N)),A}function R(m){const h=m.length<0?0:U(m.length)|0,d=o(h);for(let A=0;A<h;A+=1)d[A]=m[A]&255;return d}function C(m){if(xe(m,Uint8Array)){const h=new Uint8Array(m);return B(h.buffer,h.byteOffset,h.byteLength)}return R(m)}function B(m,h,d){if(h<0||m.byteLength<h)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<h+(d||0))throw new RangeError('"length" is outside of buffer bounds');let A;return h===void 0&&d===void 0?A=new Uint8Array(m):d===void 0?A=new Uint8Array(m,h):A=new Uint8Array(m,h,d),Object.setPrototypeOf(A,u.prototype),A}function T(m){if(u.isBuffer(m)){const h=U(m.length)|0,d=o(h);return d.length===0||m.copy(d,0,0,h),d}if(m.length!==void 0)return typeof m.length!="number"||Ot(m.length)?o(0):R(m);if(m.type==="Buffer"&&Array.isArray(m.data))return R(m.data)}function U(m){if(m>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return m|0}function W(m){return+m!=m&&(m=0),u.alloc(+m)}u.isBuffer=function(h){return h!=null&&h._isBuffer===!0&&h!==u.prototype},u.compare=function(h,d){if(xe(h,Uint8Array)&&(h=u.from(h,h.offset,h.byteLength)),xe(d,Uint8Array)&&(d=u.from(d,d.offset,d.byteLength)),!u.isBuffer(h)||!u.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(h===d)return 0;let A=h.length,N=d.length;for(let z=0,G=Math.min(A,N);z<G;++z)if(h[z]!==d[z]){A=h[z],N=d[z];break}return A<N?-1:N<A?1:0},u.isEncoding=function(h){switch(String(h).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}},u.concat=function(h,d){if(!Array.isArray(h))throw new TypeError('"list" argument must be an Array of Buffers');if(h.length===0)return u.alloc(0);let A;if(d===void 0)for(d=0,A=0;A<h.length;++A)d+=h[A].length;const N=u.allocUnsafe(d);let z=0;for(A=0;A<h.length;++A){let G=h[A];if(xe(G,Uint8Array))z+G.length>N.length?(u.isBuffer(G)||(G=u.from(G)),G.copy(N,z)):Uint8Array.prototype.set.call(N,G,z);else if(u.isBuffer(G))G.copy(N,z);else throw new TypeError('"list" argument must be an Array of Buffers');z+=G.length}return N};function D(m,h){if(u.isBuffer(m))return m.length;if(ArrayBuffer.isView(m)||xe(m,ArrayBuffer))return m.byteLength;if(typeof m!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof m);const d=m.length,A=arguments.length>2&&arguments[2]===!0;if(!A&&d===0)return 0;let N=!1;for(;;)switch(h){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return Lt(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return zt(m).length;default:if(N)return A?-1:Lt(m).length;h=(""+h).toLowerCase(),N=!0}}u.byteLength=D;function J(m,h,d){let A=!1;if((h===void 0||h<0)&&(h=0),h>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,h>>>=0,d<=h))return"";for(m||(m="utf8");;)switch(m){case"hex":return I(this,h,d);case"utf8":case"utf-8":return a(this,h,d);case"ascii":return E(this,h,d);case"latin1":case"binary":return S(this,h,d);case"base64":return x(this,h,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,h,d);default:if(A)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),A=!0}}u.prototype._isBuffer=!0;function $(m,h,d){const A=m[h];m[h]=m[d],m[d]=A}u.prototype.swap16=function(){const h=this.length;if(h%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;d<h;d+=2)$(this,d,d+1);return this},u.prototype.swap32=function(){const h=this.length;if(h%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let d=0;d<h;d+=4)$(this,d,d+3),$(this,d+1,d+2);return this},u.prototype.swap64=function(){const h=this.length;if(h%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let d=0;d<h;d+=8)$(this,d,d+7),$(this,d+1,d+6),$(this,d+2,d+5),$(this,d+3,d+4);return this},u.prototype.toString=function(){const h=this.length;return h===0?"":arguments.length===0?a(this,0,h):J.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(h){if(!u.isBuffer(h))throw new TypeError("Argument must be a Buffer");return this===h?!0:u.compare(this,h)===0},u.prototype.inspect=function(){let h="";const d=n.INSPECT_MAX_BYTES;return h=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(h+=" ... "),"<Buffer "+h+">"},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(h,d,A,N,z){if(xe(h,Uint8Array)&&(h=u.from(h,h.offset,h.byteLength)),!u.isBuffer(h))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof h);if(d===void 0&&(d=0),A===void 0&&(A=h?h.length:0),N===void 0&&(N=0),z===void 0&&(z=this.length),d<0||A>h.length||N<0||z>this.length)throw new RangeError("out of range index");if(N>=z&&d>=A)return 0;if(N>=z)return-1;if(d>=A)return 1;if(d>>>=0,A>>>=0,N>>>=0,z>>>=0,this===h)return 0;let G=z-N,kt=A-d;const yt=Math.min(G,kt),dt=this.slice(N,z),qt=h.slice(d,A);for(let ft=0;ft<yt;++ft)if(dt[ft]!==qt[ft]){G=dt[ft],kt=qt[ft];break}return G<kt?-1:kt<G?1:0};function F(m,h,d,A,N){if(m.length===0)return-1;if(typeof d=="string"?(A=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,Ot(d)&&(d=N?0:m.length-1),d<0&&(d=m.length+d),d>=m.length){if(N)return-1;d=m.length-1}else if(d<0)if(N)d=0;else return-1;if(typeof h=="string"&&(h=u.from(h,A)),u.isBuffer(h))return h.length===0?-1:Y(m,h,d,A,N);if(typeof h=="number")return h=h&255,typeof Uint8Array.prototype.indexOf=="function"?N?Uint8Array.prototype.indexOf.call(m,h,d):Uint8Array.prototype.lastIndexOf.call(m,h,d):Y(m,[h],d,A,N);throw new TypeError("val must be string, number or Buffer")}function Y(m,h,d,A,N){let z=1,G=m.length,kt=h.length;if(A!==void 0&&(A=String(A).toLowerCase(),A==="ucs2"||A==="ucs-2"||A==="utf16le"||A==="utf-16le")){if(m.length<2||h.length<2)return-1;z=2,G/=2,kt/=2,d/=2}function yt(qt,ft){return z===1?qt[ft]:qt.readUInt16BE(ft*z)}let dt;if(N){let qt=-1;for(dt=d;dt<G;dt++)if(yt(m,dt)===yt(h,qt===-1?0:dt-qt)){if(qt===-1&&(qt=dt),dt-qt+1===kt)return qt*z}else qt!==-1&&(dt-=dt-qt),qt=-1}else for(d+kt>G&&(d=G-kt),dt=d;dt>=0;dt--){let qt=!0;for(let ft=0;ft<kt;ft++)if(yt(m,dt+ft)!==yt(h,ft)){qt=!1;break}if(qt)return dt}return-1}u.prototype.includes=function(h,d,A){return this.indexOf(h,d,A)!==-1},u.prototype.indexOf=function(h,d,A){return F(this,h,d,A,!0)},u.prototype.lastIndexOf=function(h,d,A){return F(this,h,d,A,!1)};function Z(m,h,d,A){d=Number(d)||0;const N=m.length-d;A?(A=Number(A),A>N&&(A=N)):A=N;const z=h.length;A>z/2&&(A=z/2);let G;for(G=0;G<A;++G){const kt=parseInt(h.substr(G*2,2),16);if(Ot(kt))return G;m[d+G]=kt}return G}function X(m,h,d,A){return Ct(Lt(h,m.length-d),m,d,A)}function q(m,h,d,A){return Ct(Wt(h),m,d,A)}function V(m,h,d,A){return Ct(zt(h),m,d,A)}function Q(m,h,d,A){return Ct(Ur(h,m.length-d),m,d,A)}u.prototype.write=function(h,d,A,N){if(d===void 0)N="utf8",A=this.length,d=0;else if(A===void 0&&typeof d=="string")N=d,A=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(A)?(A=A>>>0,N===void 0&&(N="utf8")):(N=A,A=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const z=this.length-d;if((A===void 0||A>z)&&(A=z),h.length>0&&(A<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,h,d,A);case"utf8":case"utf-8":return X(this,h,d,A);case"ascii":case"latin1":case"binary":return q(this,h,d,A);case"base64":return V(this,h,d,A);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,h,d,A);default:if(G)throw new TypeError("Unknown encoding: "+N);N=(""+N).toLowerCase(),G=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(m,h,d){return h===0&&d===m.length?t.fromByteArray(m):t.fromByteArray(m.slice(h,d))}function a(m,h,d){d=Math.min(m.length,d);const A=[];let N=h;for(;N<d;){const z=m[N];let G=null,kt=z>239?4:z>223?3:z>191?2:1;if(N+kt<=d){let yt,dt,qt,ft;switch(kt){case 1:z<128&&(G=z);break;case 2:yt=m[N+1],(yt&192)===128&&(ft=(z&31)<<6|yt&63,ft>127&&(G=ft));break;case 3:yt=m[N+1],dt=m[N+2],(yt&192)===128&&(dt&192)===128&&(ft=(z&15)<<12|(yt&63)<<6|dt&63,ft>2047&&(ft<55296||ft>57343)&&(G=ft));break;case 4:yt=m[N+1],dt=m[N+2],qt=m[N+3],(yt&192)===128&&(dt&192)===128&&(qt&192)===128&&(ft=(z&15)<<18|(yt&63)<<12|(dt&63)<<6|qt&63,ft>65535&&ft<1114112&&(G=ft))}}G===null?(G=65533,kt=1):G>65535&&(G-=65536,A.push(G>>>10&1023|55296),G=56320|G&1023),A.push(G),N+=kt}return y(A)}const p=4096;function y(m){const h=m.length;if(h<=p)return String.fromCharCode.apply(String,m);let d="",A=0;for(;A<h;)d+=String.fromCharCode.apply(String,m.slice(A,A+=p));return d}function E(m,h,d){let A="";d=Math.min(m.length,d);for(let N=h;N<d;++N)A+=String.fromCharCode(m[N]&127);return A}function S(m,h,d){let A="";d=Math.min(m.length,d);for(let N=h;N<d;++N)A+=String.fromCharCode(m[N]);return A}function I(m,h,d){const A=m.length;(!h||h<0)&&(h=0),(!d||d<0||d>A)&&(d=A);let N="";for(let z=h;z<d;++z)N+=Ft[m[z]];return N}function O(m,h,d){const A=m.slice(h,d);let N="";for(let z=0;z<A.length-1;z+=2)N+=String.fromCharCode(A[z]+A[z+1]*256);return N}u.prototype.slice=function(h,d){const A=this.length;h=~~h,d=d===void 0?A:~~d,h<0?(h+=A,h<0&&(h=0)):h>A&&(h=A),d<0?(d+=A,d<0&&(d=0)):d>A&&(d=A),d<h&&(d=h);const N=this.subarray(h,d);return Object.setPrototypeOf(N,u.prototype),N};function v(m,h,d){if(m%1!==0||m<0)throw new RangeError("offset is not uint");if(m+h>d)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(h,d,A){h=h>>>0,d=d>>>0,A||v(h,d,this.length);let N=this[h],z=1,G=0;for(;++G<d&&(z*=256);)N+=this[h+G]*z;return N},u.prototype.readUintBE=u.prototype.readUIntBE=function(h,d,A){h=h>>>0,d=d>>>0,A||v(h,d,this.length);let N=this[h+--d],z=1;for(;d>0&&(z*=256);)N+=this[h+--d]*z;return N},u.prototype.readUint8=u.prototype.readUInt8=function(h,d){return h=h>>>0,d||v(h,1,this.length),this[h]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(h,d){return h=h>>>0,d||v(h,2,this.length),this[h]|this[h+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(h,d){return h=h>>>0,d||v(h,2,this.length),this[h]<<8|this[h+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(h,d){return h=h>>>0,d||v(h,4,this.length),(this[h]|this[h+1]<<8|this[h+2]<<16)+this[h+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(h,d){return h=h>>>0,d||v(h,4,this.length),this[h]*16777216+(this[h+1]<<16|this[h+2]<<8|this[h+3])},u.prototype.readBigUInt64LE=Be(function(h){h=h>>>0,_t(h,"offset");const d=this[h],A=this[h+7];(d===void 0||A===void 0)&&St(h,this.length-8);const N=d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24,z=this[++h]+this[++h]*2**8+this[++h]*2**16+A*2**24;return BigInt(N)+(BigInt(z)<<BigInt(32))}),u.prototype.readBigUInt64BE=Be(function(h){h=h>>>0,_t(h,"offset");const d=this[h],A=this[h+7];(d===void 0||A===void 0)&&St(h,this.length-8);const N=d*2**24+this[++h]*2**16+this[++h]*2**8+this[++h],z=this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+A;return(BigInt(N)<<BigInt(32))+BigInt(z)}),u.prototype.readIntLE=function(h,d,A){h=h>>>0,d=d>>>0,A||v(h,d,this.length);let N=this[h],z=1,G=0;for(;++G<d&&(z*=256);)N+=this[h+G]*z;return z*=128,N>=z&&(N-=Math.pow(2,8*d)),N},u.prototype.readIntBE=function(h,d,A){h=h>>>0,d=d>>>0,A||v(h,d,this.length);let N=d,z=1,G=this[h+--N];for(;N>0&&(z*=256);)G+=this[h+--N]*z;return z*=128,G>=z&&(G-=Math.pow(2,8*d)),G},u.prototype.readInt8=function(h,d){return h=h>>>0,d||v(h,1,this.length),this[h]&128?(255-this[h]+1)*-1:this[h]},u.prototype.readInt16LE=function(h,d){h=h>>>0,d||v(h,2,this.length);const A=this[h]|this[h+1]<<8;return A&32768?A|4294901760:A},u.prototype.readInt16BE=function(h,d){h=h>>>0,d||v(h,2,this.length);const A=this[h+1]|this[h]<<8;return A&32768?A|4294901760:A},u.prototype.readInt32LE=function(h,d){return h=h>>>0,d||v(h,4,this.length),this[h]|this[h+1]<<8|this[h+2]<<16|this[h+3]<<24},u.prototype.readInt32BE=function(h,d){return h=h>>>0,d||v(h,4,this.length),this[h]<<24|this[h+1]<<16|this[h+2]<<8|this[h+3]},u.prototype.readBigInt64LE=Be(function(h){h=h>>>0,_t(h,"offset");const d=this[h],A=this[h+7];(d===void 0||A===void 0)&&St(h,this.length-8);const N=this[h+4]+this[h+5]*2**8+this[h+6]*2**16+(A<<24);return(BigInt(N)<<BigInt(32))+BigInt(d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24)}),u.prototype.readBigInt64BE=Be(function(h){h=h>>>0,_t(h,"offset");const d=this[h],A=this[h+7];(d===void 0||A===void 0)&&St(h,this.length-8);const N=(d<<24)+this[++h]*2**16+this[++h]*2**8+this[++h];return(BigInt(N)<<BigInt(32))+BigInt(this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+A)}),u.prototype.readFloatLE=function(h,d){return h=h>>>0,d||v(h,4,this.length),e.read(this,h,!0,23,4)},u.prototype.readFloatBE=function(h,d){return h=h>>>0,d||v(h,4,this.length),e.read(this,h,!1,23,4)},u.prototype.readDoubleLE=function(h,d){return h=h>>>0,d||v(h,8,this.length),e.read(this,h,!0,52,8)},u.prototype.readDoubleBE=function(h,d){return h=h>>>0,d||v(h,8,this.length),e.read(this,h,!1,52,8)};function c(m,h,d,A,N,z){if(!u.isBuffer(m))throw new TypeError('"buffer" argument must be a Buffer instance');if(h>N||h<z)throw new RangeError('"value" argument is out of bounds');if(d+A>m.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(h,d,A,N){if(h=+h,d=d>>>0,A=A>>>0,!N){const kt=Math.pow(2,8*A)-1;c(this,h,d,A,kt,0)}let z=1,G=0;for(this[d]=h&255;++G<A&&(z*=256);)this[d+G]=h/z&255;return d+A},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(h,d,A,N){if(h=+h,d=d>>>0,A=A>>>0,!N){const kt=Math.pow(2,8*A)-1;c(this,h,d,A,kt,0)}let z=A-1,G=1;for(this[d+z]=h&255;--z>=0&&(G*=256);)this[d+z]=h/G&255;return d+A},u.prototype.writeUint8=u.prototype.writeUInt8=function(h,d,A){return h=+h,d=d>>>0,A||c(this,h,d,1,255,0),this[d]=h&255,d+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(h,d,A){return h=+h,d=d>>>0,A||c(this,h,d,2,65535,0),this[d]=h&255,this[d+1]=h>>>8,d+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(h,d,A){return h=+h,d=d>>>0,A||c(this,h,d,2,65535,0),this[d]=h>>>8,this[d+1]=h&255,d+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(h,d,A){return h=+h,d=d>>>0,A||c(this,h,d,4,4294967295,0),this[d+3]=h>>>24,this[d+2]=h>>>16,this[d+1]=h>>>8,this[d]=h&255,d+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(h,d,A){return h=+h,d=d>>>0,A||c(this,h,d,4,4294967295,0),this[d]=h>>>24,this[d+1]=h>>>16,this[d+2]=h>>>8,this[d+3]=h&255,d+4};function l(m,h,d,A,N){vt(h,A,N,m,d,7);let z=Number(h&BigInt(4294967295));m[d++]=z,z=z>>8,m[d++]=z,z=z>>8,m[d++]=z,z=z>>8,m[d++]=z;let G=Number(h>>BigInt(32)&BigInt(4294967295));return m[d++]=G,G=G>>8,m[d++]=G,G=G>>8,m[d++]=G,G=G>>8,m[d++]=G,d}function b(m,h,d,A,N){vt(h,A,N,m,d,7);let z=Number(h&BigInt(4294967295));m[d+7]=z,z=z>>8,m[d+6]=z,z=z>>8,m[d+5]=z,z=z>>8,m[d+4]=z;let G=Number(h>>BigInt(32)&BigInt(4294967295));return m[d+3]=G,G=G>>8,m[d+2]=G,G=G>>8,m[d+1]=G,G=G>>8,m[d]=G,d+8}u.prototype.writeBigUInt64LE=Be(function(h,d=0){return l(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Be(function(h,d=0){return b(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(h,d,A,N){if(h=+h,d=d>>>0,!N){const yt=Math.pow(2,8*A-1);c(this,h,d,A,yt-1,-yt)}let z=0,G=1,kt=0;for(this[d]=h&255;++z<A&&(G*=256);)h<0&&kt===0&&this[d+z-1]!==0&&(kt=1),this[d+z]=(h/G>>0)-kt&255;return d+A},u.prototype.writeIntBE=function(h,d,A,N){if(h=+h,d=d>>>0,!N){const yt=Math.pow(2,8*A-1);c(this,h,d,A,yt-1,-yt)}let z=A-1,G=1,kt=0;for(this[d+z]=h&255;--z>=0&&(G*=256);)h<0&&kt===0&&this[d+z+1]!==0&&(kt=1),this[d+z]=(h/G>>0)-kt&255;return d+A},u.prototype.writeInt8=function(h,d,A){return h=+h,d=d>>>0,A||c(this,h,d,1,127,-128),h<0&&(h=255+h+1),this[d]=h&255,d+1},u.prototype.writeInt16LE=function(h,d,A){return h=+h,d=d>>>0,A||c(this,h,d,2,32767,-32768),this[d]=h&255,this[d+1]=h>>>8,d+2},u.prototype.writeInt16BE=function(h,d,A){return h=+h,d=d>>>0,A||c(this,h,d,2,32767,-32768),this[d]=h>>>8,this[d+1]=h&255,d+2},u.prototype.writeInt32LE=function(h,d,A){return h=+h,d=d>>>0,A||c(this,h,d,4,2147483647,-2147483648),this[d]=h&255,this[d+1]=h>>>8,this[d+2]=h>>>16,this[d+3]=h>>>24,d+4},u.prototype.writeInt32BE=function(h,d,A){return h=+h,d=d>>>0,A||c(this,h,d,4,2147483647,-2147483648),h<0&&(h=4294967295+h+1),this[d]=h>>>24,this[d+1]=h>>>16,this[d+2]=h>>>8,this[d+3]=h&255,d+4},u.prototype.writeBigInt64LE=Be(function(h,d=0){return l(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Be(function(h,d=0){return b(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function _(m,h,d,A,N,z){if(d+A>m.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function L(m,h,d,A,N){return h=+h,d=d>>>0,N||_(m,h,d,4),e.write(m,h,d,A,23,4),d+4}u.prototype.writeFloatLE=function(h,d,A){return L(this,h,d,!0,A)},u.prototype.writeFloatBE=function(h,d,A){return L(this,h,d,!1,A)};function j(m,h,d,A,N){return h=+h,d=d>>>0,N||_(m,h,d,8),e.write(m,h,d,A,52,8),d+8}u.prototype.writeDoubleLE=function(h,d,A){return j(this,h,d,!0,A)},u.prototype.writeDoubleBE=function(h,d,A){return j(this,h,d,!1,A)},u.prototype.copy=function(h,d,A,N){if(!u.isBuffer(h))throw new TypeError("argument should be a Buffer");if(A||(A=0),!N&&N!==0&&(N=this.length),d>=h.length&&(d=h.length),d||(d=0),N>0&&N<A&&(N=A),N===A||h.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(A<0||A>=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),h.length-d<N-A&&(N=h.length-d+A);const z=N-A;return this===h&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,A,N):Uint8Array.prototype.set.call(h,this.subarray(A,N),d),z},u.prototype.fill=function(h,d,A,N){if(typeof h=="string"){if(typeof d=="string"?(N=d,d=0,A=this.length):typeof A=="string"&&(N=A,A=this.length),N!==void 0&&typeof N!="string")throw new TypeError("encoding must be a string");if(typeof N=="string"&&!u.isEncoding(N))throw new TypeError("Unknown encoding: "+N);if(h.length===1){const G=h.charCodeAt(0);(N==="utf8"&&G<128||N==="latin1")&&(h=G)}}else typeof h=="number"?h=h&255:typeof h=="boolean"&&(h=Number(h));if(d<0||this.length<d||this.length<A)throw new RangeError("Out of range index");if(A<=d)return this;d=d>>>0,A=A===void 0?this.length:A>>>0,h||(h=0);let z;if(typeof h=="number")for(z=d;z<A;++z)this[z]=h;else{const G=u.isBuffer(h)?h:u.from(h,N),kt=G.length;if(kt===0)throw new TypeError('The value "'+h+'" is invalid for argument "value"');for(z=0;z<A-d;++z)this[z+d]=G[z%kt]}return this};const rt={};function ct(m,h,d){rt[m]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:h.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${m}]`,this.stack,delete this.name}get code(){return m}set code(N){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:N,writable:!0})}toString(){return`${this.name} [${m}]: ${this.message}`}}}ct("ERR_BUFFER_OUT_OF_BOUNDS",function(m){return m?`${m} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ct("ERR_INVALID_ARG_TYPE",function(m,h){return`The "${m}" argument must be of type number. Received type ${typeof h}`},TypeError),ct("ERR_OUT_OF_RANGE",function(m,h,d){let A=`The value of "${m}" is out of range.`,N=d;return Number.isInteger(d)&&Math.abs(d)>2**32?N=At(String(d)):typeof d=="bigint"&&(N=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(N=At(N)),N+="n"),A+=` It must be ${h}. Received ${N}`,A},RangeError);function At(m){let h="",d=m.length;const A=m[0]==="-"?1:0;for(;d>=A+4;d-=3)h=`_${m.slice(d-3,d)}${h}`;return`${m.slice(0,d)}${h}`}function gt(m,h,d){_t(h,"offset"),(m[h]===void 0||m[h+d]===void 0)&&St(h,m.length-(d+1))}function vt(m,h,d,A,N,z){if(m>d||m<h){const G=typeof h=="bigint"?"n":"";let kt;throw h===0||h===BigInt(0)?kt=`>= 0${G} and < 2${G} ** ${(z+1)*8}${G}`:kt=`>= -(2${G} ** ${(z+1)*8-1}${G}) and < 2 ** ${(z+1)*8-1}${G}`,new rt.ERR_OUT_OF_RANGE("value",kt,m)}gt(A,N,z)}function _t(m,h){if(typeof m!="number")throw new rt.ERR_INVALID_ARG_TYPE(h,"number",m)}function St(m,h,d){throw Math.floor(m)!==m?(_t(m,d),new rt.ERR_OUT_OF_RANGE("offset","an integer",m)):h<0?new rt.ERR_BUFFER_OUT_OF_BOUNDS:new rt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${h}`,m)}const Tt=/[^+/0-9A-Za-z-_]/g;function $e(m){if(m=m.split("=")[0],m=m.trim().replace(Tt,""),m.length<2)return"";for(;m.length%4!==0;)m=m+"=";return m}function Lt(m,h){h=h||1/0;let d;const A=m.length;let N=null;const z=[];for(let G=0;G<A;++G){if(d=m.charCodeAt(G),d>55295&&d<57344){if(!N){if(d>56319){(h-=3)>-1&&z.push(239,191,189);continue}else if(G+1===A){(h-=3)>-1&&z.push(239,191,189);continue}N=d;continue}if(d<56320){(h-=3)>-1&&z.push(239,191,189),N=d;continue}d=(N-55296<<10|d-56320)+65536}else N&&(h-=3)>-1&&z.push(239,191,189);if(N=null,d<128){if((h-=1)<0)break;z.push(d)}else if(d<2048){if((h-=2)<0)break;z.push(d>>6|192,d&63|128)}else if(d<65536){if((h-=3)<0)break;z.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((h-=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 Wt(m){const h=[];for(let d=0;d<m.length;++d)h.push(m.charCodeAt(d)&255);return h}function Ur(m,h){let d,A,N;const z=[];for(let G=0;G<m.length&&!((h-=2)<0);++G)d=m.charCodeAt(G),A=d>>8,N=d%256,z.push(N),z.push(A);return z}function zt(m){return t.toByteArray($e(m))}function Ct(m,h,d,A){let N;for(N=0;N<A&&!(N+d>=h.length||N>=m.length);++N)h[N+d]=m[N];return N}function xe(m,h){return m instanceof h||m!=null&&m.constructor!=null&&m.constructor.name!=null&&m.constructor.name===h.name}function Ot(m){return m!==m}const Ft=function(){const m="0123456789abcdef",h=new Array(256);for(let d=0;d<16;++d){const A=d*16;for(let N=0;N<16;++N)h[A+N]=m[d]+m[N]}return h}();function Be(m){return typeof BigInt>"u"?Dt:m}function Dt(){throw new Error("BigInt not supported")}}(Fn)),Fn}var ht=zn();function en(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`positive integer expected, not ${n}`)}function Da(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function zr(n,...t){if(!Da(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 qa(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 Is(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 Dn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ka=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),qn=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Oe=(n,t)=>n<<32-t|n>>>t,Es=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Wa=n=>n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255;function As(n){for(let t=0;t<n.length;t++)n[t]=Wa(n[t])}function $a(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=$a(n)),zr(n),n}function Ha(...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 Kn{clone(){return this._cloneInto()}}function Wn(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 Bs(n=32){if(Dn&&typeof Dn.getRandomValues=="function")return Dn.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}function Va(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),u=Number(e&i),f=r?4:0,g=r?0:4;n.setUint32(t+f,o,r),n.setUint32(t+g,u,r)}const ja=(n,t,e)=>n&t^~n&e,Ga=(n,t,e)=>n&t^n&e^t&e;class _s extends Kn{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=qn(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 u=Math.min(s-this.pos,i-o);if(u===s){const f=qn(t);for(;s<=i-o;o+=s)this.process(f,o);continue}r.set(t.subarray(o,o+u),this.pos),this.pos+=u,o+=u,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){kr(this),Is(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;Va(r,s-8,BigInt(this.length*8),i),this.process(r,0);const u=qn(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=f/4,w=this.get();if(g>w.length)throw new Error("_sha2: outputLen bigger than state");for(let k=0;k<g;k++)u.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:u}=this;return t.length=s,t.pos=u,t.finished=i,t.destroyed=o,s%e&&t.buffer.set(r),t}}const nn=BigInt(2**32-1),$n=BigInt(32);function Rs(n,t=!1){return t?{h:Number(n&nn),l:Number(n>>$n&nn)}:{h:Number(n>>$n&nn)|0,l:Number(n&nn)|0}}function Ts(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}=Rs(n[s],t);[e[s],r[s]]=[i,o]}return[e,r]}const Za=(n,t)=>BigInt(n>>>0)<<$n|BigInt(t>>>0),Ya=(n,t,e)=>n>>>e,Ja=(n,t,e)=>n<<32-e|t>>>e,Xa=(n,t,e)=>n>>>e|t<<32-e,Qa=(n,t,e)=>n<<32-e|t>>>e,tc=(n,t,e)=>n<<64-e|t>>>e-32,ec=(n,t,e)=>n>>>e-32|t<<64-e,rc=(n,t)=>t,nc=(n,t)=>n,Ms=(n,t,e)=>n<<e|t>>>32-e,Ps=(n,t,e)=>t<<e|n>>>32-e,Ls=(n,t,e)=>t<<e-32|n>>>64-e,Cs=(n,t,e)=>n<<e-32|t>>>64-e;function ic(n,t,e,r){const s=(t>>>0)+(r>>>0);return{h:n+e+(s/2**32|0)|0,l:s|0}}const mt={fromBig:Rs,split:Ts,toBig:Za,shrSH:Ya,shrSL:Ja,rotrSH:Xa,rotrSL:Qa,rotrBH:tc,rotrBL:ec,rotr32H:rc,rotr32L:nc,rotlSH:Ms,rotlSL:Ps,rotlBH:Ls,rotlBL:Cs,add:ic,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)},[sc,oc]=mt.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 ac 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:u,Dl:f,Eh:g,El:w,Fh:k,Fl:M,Gh:R,Gl:C,Hh:B,Hl:T}=this;return[t,e,r,s,i,o,u,f,g,w,k,M,R,C,B,T]}set(t,e,r,s,i,o,u,f,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=u|0,this.Dl=f|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 D=0;D<16;D++,e+=4)Ye[D]=t.getUint32(e),Je[D]=t.getUint32(e+=4);for(let D=16;D<80;D++){const J=Ye[D-15]|0,$=Je[D-15]|0,F=mt.rotrSH(J,$,1)^mt.rotrSH(J,$,8)^mt.shrSH(J,$,7),Y=mt.rotrSL(J,$,1)^mt.rotrSL(J,$,8)^mt.shrSL(J,$,7),Z=Ye[D-2]|0,X=Je[D-2]|0,q=mt.rotrSH(Z,X,19)^mt.rotrBH(Z,X,61)^mt.shrSH(Z,X,6),V=mt.rotrSL(Z,X,19)^mt.rotrBL(Z,X,61)^mt.shrSL(Z,X,6),Q=mt.add4L(Y,V,Je[D-7],Je[D-16]),x=mt.add4H(Q,F,q,Ye[D-7],Ye[D-16]);Ye[D]=x|0,Je[D]=Q|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:u,Cl:f,Dh:g,Dl:w,Eh:k,El:M,Fh:R,Fl:C,Gh:B,Gl:T,Hh:U,Hl:W}=this;for(let D=0;D<80;D++){const J=mt.rotrSH(k,M,14)^mt.rotrSH(k,M,18)^mt.rotrBH(k,M,41),$=mt.rotrSL(k,M,14)^mt.rotrSL(k,M,18)^mt.rotrBL(k,M,41),F=k&R^~k&B,Y=M&C^~M&T,Z=mt.add5L(W,$,Y,oc[D],Je[D]),X=mt.add5H(Z,U,J,F,sc[D],Ye[D]),q=Z|0,V=mt.rotrSH(r,s,28)^mt.rotrBH(r,s,34)^mt.rotrBH(r,s,39),Q=mt.rotrSL(r,s,28)^mt.rotrBL(r,s,34)^mt.rotrBL(r,s,39),x=r&i^r&u^i&u,a=s&o^s&f^o&f;U=B|0,W=T|0,B=R|0,T=C|0,R=k|0,C=M|0,{h:k,l:M}=mt.add(g|0,w|0,X|0,q|0),g=u|0,w=f|0,u=i|0,f=o|0,i=r|0,o=s|0;const p=mt.add3L(q,Q,a);r=mt.add3H(p,X,V,x),s=p|0}({h:r,l:s}=mt.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=mt.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:u,l:f}=mt.add(this.Ch|0,this.Cl|0,u|0,f|0),{h:g,l:w}=mt.add(this.Dh|0,this.Dl|0,g|0,w|0),{h:k,l:M}=mt.add(this.Eh|0,this.El|0,k|0,M|0),{h:R,l:C}=mt.add(this.Fh|0,this.Fl|0,R|0,C|0),{h:B,l:T}=mt.add(this.Gh|0,this.Gl|0,B|0,T|0),{h:U,l:W}=mt.add(this.Hh|0,this.Hl|0,U|0,W|0),this.set(r,s,i,o,u,f,g,w,k,M,R,C,B,T,U,W)}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 cc=Wn(()=>new ac);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Os=BigInt(0),sn=BigInt(1),uc=BigInt(2);function sr(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function Dr(n){if(!sr(n))throw new Error("Uint8Array expected")}const lc=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function or(n){Dr(n);let t="";for(let e=0;e<n.length;e++)t+=lc[n[e]];return t}function Us(n){const t=n.toString(16);return t.length&1?`0${t}`:t}function Hn(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 Ns(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=Ns(n.charCodeAt(i)),u=Ns(n.charCodeAt(i+1));if(o===void 0||u===void 0){const f=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[s]=o*16+u}return r}function ar(n){return Hn(or(n))}function Sr(n){return Dr(n),Hn(or(Uint8Array.from(n).reverse()))}function xr(n,t){return vr(n.toString(16).padStart(t*2,"0"))}function qr(n,t){return xr(n,t).reverse()}function hc(n){return vr(Us(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];Dr(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 fc(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 dc(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function pc(n){let t;for(t=0;n>Os;n>>=sn,t+=1);return t}function gc(n,t){return n>>BigInt(t)&sn}function yc(n,t,e){return n|(e?sn:Os)<<BigInt(t)}const Vn=n=>(uc<<BigInt(n-1))-sn,jn=n=>new Uint8Array(n),Fs=n=>Uint8Array.from(n);function zs(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=jn(n),s=jn(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},u=(...k)=>e(s,r,...k),f=(k=jn())=>{s=u(Fs([0]),k),r=u(),k.length!==0&&(s=u(Fs([1]),k),r=u())},g=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let k=0;const M=[];for(;k<t;){r=u();const R=r.slice();M.push(R),k+=r.length}return cr(...M)};return(k,M)=>{o(),f(k);let R;for(;!(R=M(g()));)f();return o(),R}}const mc={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 u=mc[i];if(typeof u!="function")throw new Error(`Invalid validator "${i}", expected function`);const f=n[s];if(!(o&&f===void 0)&&!u(f,n))throw new Error(`Invalid param ${String(s)}=${f} (${typeof f}), 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 wc=Object.freeze(Object.defineProperty({__proto__:null,abytes:Dr,bitGet:gc,bitLen:pc,bitMask:Vn,bitSet:yc,bytesToHex:or,bytesToNumberBE:ar,bytesToNumberLE:Sr,concatBytes:cr,createHmacDrbg:zs,ensureBytes:de,equalBytes:fc,hexToBytes:vr,hexToNumber:Hn,isBytes:sr,numberToBytesBE:xr,numberToBytesLE:qr,numberToHexUnpadded:Us,numberToVarBytesBE:hc,utf8ToBytes:dc,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),bc=BigInt(3),Gn=BigInt(4),Ds=BigInt(5),qs=BigInt(8);BigInt(9),BigInt(16);function Kt(n,t){const e=n%t;return e>=pe?e:t+e}function kc(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 Zn(n,t){if(n===pe||t<=pe)throw new Error(`invert: expected positive integers, got n=${n} mod=${t}`);let e=Kt(n,t),r=t,s=pe,i=$t;for(;e!==pe;){const u=r/e,f=r%e,g=s-i*u;r=e,e=f,s=i,i=g}if(r!==$t)throw new Error("invert: does not exist");return Kt(s,t)}function vc(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&&kc(s,t,n)!==n-$t;s++);if(r===1){const o=(n+$t)/Gn;return function(f,g){const w=f.pow(g,o);if(!f.eql(f.sqr(w),g))throw new Error("Cannot find square root");return w}}const i=(e+$t)/ur;return function(u,f){if(u.pow(f,t)===u.neg(u.ONE))throw new Error("Cannot find square root");let g=r,w=u.pow(u.mul(u.ONE,s),e),k=u.pow(f,i),M=u.pow(f,e);for(;!u.eql(M,u.ONE);){if(u.eql(M,u.ZERO))return u.ZERO;let R=1;for(let B=u.sqr(M);R<g&&!u.eql(B,u.ONE);R++)B=u.sqr(B);const C=u.pow(w,$t<<BigInt(g-R-1));w=u.sqr(C),k=u.mul(k,C),M=u.mul(M,w),g=R}return k}}function Sc(n){if(n%Gn===bc){const t=(n+$t)/Gn;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%qs===Ds){const t=(n-Ds)/qs;return function(r,s){const i=r.mul(s,ur),o=r.pow(i,t),u=r.mul(s,o),f=r.mul(r.mul(u,ur),o),g=r.mul(u,r.sub(f,r.ONE));if(!r.eql(r.sqr(g),s))throw new Error("Cannot find square root");return g}}return vc(n)}const xc=(n,t)=>(Kt(n,t)&$t)===$t,Ic=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ec(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Ic.reduce((r,s)=>(r[s]="function",r),t);return Ir(n,e)}function Ac(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 Bc(n,t){const e=new Array(t.length),r=t.reduce((i,o,u)=>n.is0(o)?i:(e[u]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return t.reduceRight((i,o,u)=>n.is0(o)?i:(e[u]=n.mul(i,e[u]),n.mul(i,o)),s),e}function Ks(n,t){const e=t!==void 0?t:n.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function Ws(n,t,e=!1,r={}){if(n<=pe)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=Ks(n,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=Sc(n),u=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:Vn(s),ZERO:pe,ONE:$t,create:f=>Kt(f,n),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return pe<=f&&f<n},is0:f=>f===pe,isOdd:f=>(f&$t)===$t,neg:f=>Kt(-f,n),eql:(f,g)=>f===g,sqr:f=>Kt(f*f,n),add:(f,g)=>Kt(f+g,n),sub:(f,g)=>Kt(f-g,n),mul:(f,g)=>Kt(f*g,n),pow:(f,g)=>Ac(u,f,g),div:(f,g)=>Kt(f*Zn(g,n),n),sqrN:f=>f*f,addN:(f,g)=>f+g,subN:(f,g)=>f-g,mulN:(f,g)=>f*g,inv:f=>Zn(f,n),sqrt:r.sqrt||(f=>o(u,f)),invertBatch:f=>Bc(u,f),cmov:(f,g,w)=>w?g:f,toBytes:f=>e?qr(f,i):xr(f,i),fromBytes:f=>{if(f.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${f.length}`);return e?Sr(f):ar(f)}});return Object.freeze(u)}function $s(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 Hs(n){const t=$s(n);return t+Math.ceil(t/2)}function _c(n,t,e=!1){const r=n.length,s=$s(t),i=Hs(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),u=Kt(o,t-$t)+$t;return e?qr(u,s):xr(u,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Rc=BigInt(0),Yn=BigInt(1);function Vs(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,u=s;for(;i>Rc;)i&Yn&&(o=o.add(u)),u=u.double(),i>>=Yn;return o},precomputeWindow(s,i){const{windows:o,windowSize:u}=r(i),f=[];let g=s,w=g;for(let k=0;k<o;k++){w=g,f.push(w);for(let M=1;M<u;M++)w=w.add(g),f.push(w);g=w.double()}return f},wNAF(s,i,o){const{windows:u,windowSize:f}=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<u;C++){const B=C*f;let T=Number(o&k);o>>=R,T>f&&(T-=M,o+=Yn);const U=B,W=B+Math.abs(T)-1,D=C%2!==0,J=T<0;T===0?w=w.add(e(D,i[U])):g=g.add(e(J,i[W]))}return{p:g,f:w}},wNAFCached(s,i,o,u){const f=s._WINDOW_SIZE||1;let g=i.get(s);return g||(g=this.precomputeWindow(s,f),f!==1&&i.set(s,u(g))),this.wNAF(f,g,o)}}}function Jn(n){return Ec(n.Fp),Ir(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ks(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Me=BigInt(0),_e=BigInt(1),on=BigInt(2),Tc=BigInt(8),Mc={zip215:!0};function Pc(n){const t=Jn(n);return Ir(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Lc(n){const t=Pc(n),{Fp:e,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:u,h:f}=t,g=on<<BigInt(u*8)-_e,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,O)=>{if(I.length||O)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 U(S,I){if(B(S,I))return S;throw new Error(`Expected valid scalar < ${I}, got ${typeof S} ${S}`)}function W(S){return S===Me?S:U(S,r)}const D=new Map;function J(S){if(!(S instanceof $))throw new Error("ExtendedPoint expected")}class ${constructor(I,O,v,c){if(this.ex=I,this.ey=O,this.ez=v,this.et=c,!T(I))throw new Error("x required");if(!T(O))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 $)throw new Error("extended point not allowed");const{x:O,y:v}=I||{};if(!T(O)||!T(v))throw new Error("invalid affine point");return new $(O,v,_e,w(O*v))}static normalizeZ(I){const O=e.invertBatch(I.map(v=>v.ez));return I.map((v,c)=>v.toAffine(O[c])).map($.fromAffine)}_setWindowSize(I){this._WINDOW_SIZE=I,D.delete(this)}assertValidity(){const{a:I,d:O}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:v,ey:c,ez:l,et:b}=this,_=w(v*v),L=w(c*c),j=w(l*l),rt=w(j*j),ct=w(_*I),At=w(j*w(ct+L)),gt=w(rt+w(O*w(_*L)));if(At!==gt)throw new Error("bad point: equation left != right (1)");const vt=w(v*c),_t=w(l*b);if(vt!==_t)throw new Error("bad point: equation left != right (2)")}equals(I){J(I);const{ex:O,ey:v,ez:c}=this,{ex:l,ey:b,ez:_}=I,L=w(O*_),j=w(l*c),rt=w(v*_),ct=w(b*c);return L===j&&rt===ct}is0(){return this.equals($.ZERO)}negate(){return new $(w(-this.ex),this.ey,this.ez,w(-this.et))}double(){const{a:I}=t,{ex:O,ey:v,ez:c}=this,l=w(O*O),b=w(v*v),_=w(on*w(c*c)),L=w(I*l),j=O+v,rt=w(w(j*j)-l-b),ct=L+b,At=ct-_,gt=L-b,vt=w(rt*At),_t=w(ct*gt),St=w(rt*gt),Tt=w(At*ct);return new $(vt,_t,Tt,St)}add(I){J(I);const{a:O,d:v}=t,{ex:c,ey:l,ez:b,et:_}=this,{ex:L,ey:j,ez:rt,et:ct}=I;if(O===BigInt(-1)){const xe=w((l-c)*(j+L)),Ot=w((l+c)*(j-L)),Ft=w(Ot-xe);if(Ft===Me)return this.double();const Be=w(b*on*ct),Dt=w(_*on*rt),m=Dt+Be,h=Ot+xe,d=Dt-Be,A=w(m*Ft),N=w(h*d),z=w(m*d),G=w(Ft*h);return new $(A,N,G,z)}const At=w(c*L),gt=w(l*j),vt=w(_*v*ct),_t=w(b*rt),St=w((c+l)*(L+j)-At-gt),Tt=_t-vt,$e=_t+vt,Lt=w(gt-O*At),Wt=w(St*Tt),Ur=w($e*Lt),zt=w(St*Lt),Ct=w(Tt*$e);return new $(Wt,Ur,Ct,zt)}subtract(I){return this.add(I.negate())}wNAF(I){return Z.wNAFCached(this,D,I,$.normalizeZ)}multiply(I){const{p:O,f:v}=this.wNAF(U(I,r));return $.normalizeZ([O,v])[0]}multiplyUnsafe(I){let O=W(I);return O===Me?Y:this.equals(Y)||O===_e?this:this.equals(F)?this.wNAF(O).p:Z.unsafeLadder(this,O)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return Z.unsafeLadder(this,r).is0()}toAffine(I){const{ex:O,ey:v,ez:c}=this,l=this.is0();I==null&&(I=l?Tc:e.inv(c));const b=w(O*I),_=w(v*I),L=w(c*I);if(l)return{x:Me,y:_e};if(L!==_e)throw new Error("invZ was invalid");return{x:b,y:_}}clearCofactor(){const{h:I}=t;return I===_e?this:this.multiplyUnsafe(I)}static fromHex(I,O=!1){const{d:v,a:c}=t,l=e.BYTES;I=de("pointHex",I,l);const b=I.slice(),_=I[l-1];b[l-1]=_&-129;const L=Sr(b);L===Me||(O?U(L,g):U(L,e.ORDER));const j=w(L*L),rt=w(j-_e),ct=w(v*j-c);let{isValid:At,value:gt}=k(rt,ct);if(!At)throw new Error("Point.fromHex: invalid y coordinate");const vt=(gt&_e)===_e,_t=(_&128)!==0;if(!O&>===Me&&_t)throw new Error("Point.fromHex: x=0 and x_0=1");return _t!==vt&&(gt=w(-gt)),$.fromAffine({x:gt,y:L})}static fromPrivateKey(I){return V(I).point}toRawBytes(){const{x:I,y:O}=this.toAffine(),v=qr(O,e.BYTES);return v[v.length-1]|=I&_e?128:0,v}toHex(){return or(this.toRawBytes())}}$.BASE=new $(t.Gx,t.Gy,_e,w(t.Gx*t.Gy)),$.ZERO=new $(Me,_e,_e,Me);const{BASE:F,ZERO:Y}=$,Z=Vs($,u*8);function X(S){return Kt(S,r)}function q(S){return X(Sr(S))}function V(S){const I=u;S=de("private key",S,I);const O=de("hashed private key",i(S),2*I),v=M(O.slice(0,I)),c=O.slice(I,2*I),l=q(v),b=F.multiply(l),_=b.toRawBytes();return{head:v,prefix:c,scalar:l,point:b,pointBytes:_}}function Q(S){return V(S).pointBytes}function x(S=new Uint8Array,...I){const O=cr(...I);return q(i(R(O,de("context",S),!!s)))}function a(S,I,O={}){S=de("message",S),s&&(S=s(S));const{prefix:v,scalar:c,pointBytes:l}=V(I),b=x(O.context,v,S),_=F.multiply(b).toRawBytes(),L=x(O.context,_,l,S),j=X(b+L*c);W(j);const rt=cr(_,qr(j,e.BYTES));return de("result",rt,u*2)}const p=Mc;function y(S,I,O,v=p){const{context:c,zip215:l}=v,b=e.BYTES;S=de("signature",S,2*b),I=de("message",I),s&&(I=s(I));const _=Sr(S.slice(b,2*b));let L,j,rt;try{L=$.fromHex(O,l),j=$.fromHex(S.slice(0,b),l),rt=F.multiplyUnsafe(_)}catch{return!1}if(!l&&L.isSmallOrder())return!1;const ct=x(c,j.toRawBytes(),L.toRawBytes(),I);return j.add(L.multiplyUnsafe(ct)).subtract(rt).clearCofactor().equals($.ZERO)}return F._setWindowSize(8),{CURVE:t,getPublicKey:Q,sign:a,verify:y,ExtendedPoint:$,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>o(e.BYTES),precompute(S=8,I=$.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Xn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),js=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Cc=BigInt(1),Gs=BigInt(2);BigInt(3);const Oc=BigInt(5),Uc=BigInt(8);function Nc(n){const t=BigInt(10),e=BigInt(20),r=BigInt(40),s=BigInt(80),i=Xn,u=n*n%i*n%i,f=jt(u,Gs,i)*u%i,g=jt(f,Cc,i)*n%i,w=jt(g,Oc,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,Gs,i)*n%i,b2:u}}function Fc(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function zc(n,t){const e=Xn,r=Kt(t*t*t,e),s=Kt(r*r*t,e),i=Nc(n*s).pow_p_5_8;let o=Kt(n*r*i,e);const u=Kt(t*o*o,e),f=o,g=Kt(o*js,e),w=u===n,k=u===Kt(-n,e),M=u===Kt(-n*js,e);return w&&(o=f),(k||M)&&(o=g),xc(o,e)&&(o=Kt(-o,e)),{isValid:w||k,value:o}}const Dc=Ws(Xn,void 0,!0),qc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Dc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Uc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:cc,randomBytes:Bs,adjustScalarBytes:Fc,uvRatio:zc},Er=Lc(qc);var an={exports:{}};const Kc=Nn(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Wc=an.exports,Zs;function Ys(){return Zs||(Zs=1,function(n){(function(t,e){function r(x,a){if(!x)throw new Error(a||"Assertion failed")}function s(x,a){x.super_=a;var p=function(){};p.prototype=a.prototype,x.prototype=new p,x.prototype.constructor=x}function i(x,a,p){if(i.isBN(x))return x;this.negative=0,this.words=null,this.length=0,this.red=null,x!==null&&((a==="le"||a==="be")&&(p=a,a=10),this._init(x||0,a||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=Kc.Buffer}catch{}i.isBN=function(a){return a instanceof i?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===i.wordSize&&Array.isArray(a.words)},i.max=function(a,p){return a.cmp(p)>0?a:p},i.min=function(a,p){return a.cmp(p)<0?a:p},i.prototype._init=function(a,p,y){if(typeof a=="number")return this._initNumber(a,p,y);if(typeof a=="object")return this._initArray(a,p,y);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),a=a.toString().replace(/\s+/g,"");var E=0;a[0]==="-"&&(E++,this.negative=1),E<a.length&&(p===16?this._parseHex(a,E,y):(this._parseBase(a,p,E),y==="le"&&this._initArray(this.toArray(),p,y)))},i.prototype._initNumber=function(a,p,y){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(r(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),p,y)},i.prototype._initArray=function(a,p,y){if(r(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var S,I,O=0;if(y==="be")for(E=a.length-1,S=0;E>=0;E-=3)I=a[E]|a[E-1]<<8|a[E-2]<<16,this.words[S]|=I<<O&67108863,this.words[S+1]=I>>>26-O&67108863,O+=24,O>=26&&(O-=26,S++);else if(y==="le")for(E=0,S=0;E<a.length;E+=3)I=a[E]|a[E+1]<<8|a[E+2]<<16,this.words[S]|=I<<O&67108863,this.words[S+1]=I>>>26-O&67108863,O+=24,O>=26&&(O-=26,S++);return this._strip()};function u(x,a){var p=x.charCodeAt(a);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 f(x,a,p){var y=u(x,p);return p-1>=a&&(y|=u(x,p-1)<<4),y}i.prototype._parseHex=function(a,p,y){this.length=Math.ceil((a.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,O;if(y==="be")for(E=a.length-1;E>=p;E-=2)O=f(a,p,E)<<S,this.words[I]|=O&67108863,S>=18?(S-=18,I+=1,this.words[I]|=O>>>26):S+=8;else{var v=a.length-p;for(E=v%2===0?p+1:p;E<a.length;E+=2)O=f(a,p,E)<<S,this.words[I]|=O&67108863,S>=18?(S-=18,I+=1,this.words[I]|=O>>>26):S+=8}this._strip()};function g(x,a,p,y){for(var E=0,S=0,I=Math.min(x.length,p),O=a;O<I;O++){var v=x.charCodeAt(O)-48;E*=y,v>=49?S=v-49+10:v>=17?S=v-17+10:S=v,r(v>=0&&S<y,"Invalid character"),E+=S}return E}i.prototype._parseBase=function(a,p,y){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=a.length-y,O=I%E,v=Math.min(I,I-O)+y,c=0,l=y;l<v;l+=E)c=g(a,l,l+E,p),this.imuln(S),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(O!==0){var b=1;for(c=g(a,l,a.length,p),l=0;l<O;l++)b*=p;this.imuln(b),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(a){a.words=new Array(this.length);for(var p=0;p<this.length;p++)a.words[p]=this.words[p];a.length=this.length,a.negative=this.negative,a.red=this.red};function w(x,a){x.words=a.words,x.length=a.length,x.negative=a.negative,x.red=a.red}if(i.prototype._move=function(a){w(a,this)},i.prototype.clone=function(){var a=new i(null);return this.copy(a),a},i.prototype._expand=function(a){for(;this.length<a;)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(a,p){a=a||10,p=p|0||1;var y;if(a===16||a==="hex"){y="";for(var E=0,S=0,I=0;I<this.length;I++){var O=this.words[I],v=((O<<E|S)&16777215).toString(16);S=O>>>24-E&16777215,E+=2,E>=26&&(E-=26,I--),S!==0||I!==this.length-1?y=M[6-v.length]+v+y:y=v+y}for(S!==0&&(y=S.toString(16)+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(a===(a|0)&&a>=2&&a<=36){var c=R[a],l=C[a];y="";var b=this.clone();for(b.negative=0;!b.isZero();){var _=b.modrn(l).toString(a);b=b.idivn(l),b.isZero()?y=_+y:y=M[c-_.length]+_+y}for(this.isZero()&&(y="0"+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(a,p){return this.toArrayLike(o,a,p)}),i.prototype.toArray=function(a,p){return this.toArrayLike(Array,a,p)};var B=function(a,p){return a.allocUnsafe?a.allocUnsafe(p):new a(p)};i.prototype.toArrayLike=function(a,p,y){this._strip();var E=this.byteLength(),S=y||Math.max(1,E);r(E<=S,"byte array longer than desired length"),r(S>0,"Requested array length <= 0");var I=B(a,S),O=p==="le"?"LE":"BE";return this["_toArrayLike"+O](I,E),I},i.prototype._toArrayLikeLE=function(a,p){for(var y=0,E=0,S=0,I=0;S<this.length;S++){var O=this.words[S]<<I|E;a[y++]=O&255,y<a.length&&(a[y++]=O>>8&255),y<a.length&&(a[y++]=O>>16&255),I===6?(y<a.length&&(a[y++]=O>>24&255),E=0,I=0):(E=O>>>24,I+=2)}if(y<a.length)for(a[y++]=E;y<a.length;)a[y++]=0},i.prototype._toArrayLikeBE=function(a,p){for(var y=a.length-1,E=0,S=0,I=0;S<this.length;S++){var O=this.words[S]<<I|E;a[y--]=O&255,y>=0&&(a[y--]=O>>8&255),y>=0&&(a[y--]=O>>16&255),I===6?(y>=0&&(a[y--]=O>>24&255),E=0,I=0):(E=O>>>24,I+=2)}if(y>=0)for(a[y--]=E;y>=0;)a[y--]=0},Math.clz32?i.prototype._countBits=function(a){return 32-Math.clz32(a)}:i.prototype._countBits=function(a){var p=a,y=0;return p>=4096&&(y+=13,p>>>=13),p>=64&&(y+=7,p>>>=7),p>=8&&(y+=4,p>>>=4),p>=2&&(y+=2,p>>>=2),y+p},i.prototype._zeroBits=function(a){if(a===0)return 26;var p=a,y=0;return(p&8191)===0&&(y+=13,p>>>=13),(p&127)===0&&(y+=7,p>>>=7),(p&15)===0&&(y+=4,p>>>=4),(p&3)===0&&(y+=2,p>>>=2),(p&1)===0&&y++,y},i.prototype.bitLength=function(){var a=this.words[this.length-1],p=this._countBits(a);return(this.length-1)*26+p};function T(x){for(var a=new Array(x.bitLength()),p=0;p<a.length;p++){var y=p/26|0,E=p%26;a[p]=x.words[y]>>>E&1}return a}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,p=0;p<this.length;p++){var y=this._zeroBits(this.words[p]);if(a+=y,y!==26)break}return a},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},i.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).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(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var p=0;p<a.length;p++)this.words[p]=this.words[p]|a.words[p];return this._strip()},i.prototype.ior=function(a){return r((this.negative|a.negative)===0),this.iuor(a)},i.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},i.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},i.prototype.iuand=function(a){var p;this.length>a.length?p=a:p=this;for(var y=0;y<p.length;y++)this.words[y]=this.words[y]&a.words[y];return this.length=p.length,this._strip()},i.prototype.iand=function(a){return r((this.negative|a.negative)===0),this.iuand(a)},i.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},i.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},i.prototype.iuxor=function(a){var p,y;this.length>a.length?(p=this,y=a):(p=a,y=this);for(var E=0;E<y.length;E++)this.words[E]=p.words[E]^y.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(a){return r((this.negative|a.negative)===0),this.iuxor(a)},i.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},i.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},i.prototype.inotn=function(a){r(typeof a=="number"&&a>=0);var p=Math.ceil(a/26)|0,y=a%26;this._expand(p),y>0&&p--;for(var E=0;E<p;E++)this.words[E]=~this.words[E]&67108863;return y>0&&(this.words[E]=~this.words[E]&67108863>>26-y),this._strip()},i.prototype.notn=function(a){return this.clone().inotn(a)},i.prototype.setn=function(a,p){r(typeof a=="number"&&a>=0);var y=a/26|0,E=a%26;return this._expand(y+1),p?this.words[y]=this.words[y]|1<<E:this.words[y]=this.words[y]&~(1<<E),this._strip()},i.prototype.iadd=function(a){var p;if(this.negative!==0&&a.negative===0)return this.negative=0,p=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,p=this.isub(a),a.negative=1,p._normSign();var y,E;this.length>a.length?(y=this,E=a):(y=a,E=this);for(var S=0,I=0;I<E.length;I++)p=(y.words[I]|0)+(E.words[I]|0)+S,this.words[I]=p&67108863,S=p>>>26;for(;S!==0&&I<y.length;I++)p=(y.words[I]|0)+S,this.words[I]=p&67108863,S=p>>>26;if(this.length=y.length,S!==0)this.words[this.length]=S,this.length++;else if(y!==this)for(;I<y.length;I++)this.words[I]=y.words[I];return this},i.prototype.add=function(a){var p;return a.negative!==0&&this.negative===0?(a.negative=0,p=this.sub(a),a.negative^=1,p):a.negative===0&&this.negative!==0?(this.negative=0,p=a.sub(this),this.negative=1,p):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},i.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var p=this.iadd(a);return a.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var y=this.cmp(a);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var E,S;y>0?(E=this,S=a):(E=a,S=this);for(var I=0,O=0;O<S.length;O++)p=(E.words[O]|0)-(S.words[O]|0)+I,I=p>>26,this.words[O]=p&67108863;for(;I!==0&&O<E.length;O++)p=(E.words[O]|0)+I,I=p>>26,this.words[O]=p&67108863;if(I===0&&O<E.length&&E!==this)for(;O<E.length;O++)this.words[O]=E.words[O];return this.length=Math.max(this.length,O),E!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(a){return this.clone().isub(a)};function U(x,a,p){p.negative=a.negative^x.negative;var y=x.length+a.length|0;p.length=y,y=y-1|0;var E=x.words[0]|0,S=a.words[0]|0,I=E*S,O=I&67108863,v=I/67108864|0;p.words[0]=O;for(var c=1;c<y;c++){for(var l=v>>>26,b=v&67108863,_=Math.min(c,a.length-1),L=Math.max(0,c-x.length+1);L<=_;L++){var j=c-L|0;E=x.words[j]|0,S=a.words[L]|0,I=E*S+b,l+=I/67108864|0,b=I&67108863}p.words[c]=b|0,v=l|0}return v!==0?p.words[c]=v|0:p.length--,p._strip()}var W=function(a,p,y){var E=a.words,S=p.words,I=y.words,O=0,v,c,l,b=E[0]|0,_=b&8191,L=b>>>13,j=E[1]|0,rt=j&8191,ct=j>>>13,At=E[2]|0,gt=At&8191,vt=At>>>13,_t=E[3]|0,St=_t&8191,Tt=_t>>>13,$e=E[4]|0,Lt=$e&8191,Wt=$e>>>13,Ur=E[5]|0,zt=Ur&8191,Ct=Ur>>>13,xe=E[6]|0,Ot=xe&8191,Ft=xe>>>13,Be=E[7]|0,Dt=Be&8191,m=Be>>>13,h=E[8]|0,d=h&8191,A=h>>>13,N=E[9]|0,z=N&8191,G=N>>>13,kt=S[0]|0,yt=kt&8191,dt=kt>>>13,qt=S[1]|0,ft=qt&8191,Zt=qt>>>13,Ta=S[2]|0,Yt=Ta&8191,Jt=Ta>>>13,Ma=S[3]|0,Xt=Ma&8191,Qt=Ma>>>13,Pa=S[4]|0,te=Pa&8191,ee=Pa>>>13,La=S[5]|0,re=La&8191,ne=La>>>13,Ca=S[6]|0,ie=Ca&8191,se=Ca>>>13,Oa=S[7]|0,oe=Oa&8191,ae=Oa>>>13,Ua=S[8]|0,ce=Ua&8191,ue=Ua>>>13,Na=S[9]|0,le=Na&8191,he=Na>>>13;y.negative=a.negative^p.negative,y.length=19,v=Math.imul(_,yt),c=Math.imul(_,dt),c=c+Math.imul(L,yt)|0,l=Math.imul(L,dt);var Qi=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,v=Math.imul(rt,yt),c=Math.imul(rt,dt),c=c+Math.imul(ct,yt)|0,l=Math.imul(ct,dt),v=v+Math.imul(_,ft)|0,c=c+Math.imul(_,Zt)|0,c=c+Math.imul(L,ft)|0,l=l+Math.imul(L,Zt)|0;var ts=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(ts>>>26)|0,ts&=67108863,v=Math.imul(gt,yt),c=Math.imul(gt,dt),c=c+Math.imul(vt,yt)|0,l=Math.imul(vt,dt),v=v+Math.imul(rt,ft)|0,c=c+Math.imul(rt,Zt)|0,c=c+Math.imul(ct,ft)|0,l=l+Math.imul(ct,Zt)|0,v=v+Math.imul(_,Yt)|0,c=c+Math.imul(_,Jt)|0,c=c+Math.imul(L,Yt)|0,l=l+Math.imul(L,Jt)|0;var es=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(es>>>26)|0,es&=67108863,v=Math.imul(St,yt),c=Math.imul(St,dt),c=c+Math.imul(Tt,yt)|0,l=Math.imul(Tt,dt),v=v+Math.imul(gt,ft)|0,c=c+Math.imul(gt,Zt)|0,c=c+Math.imul(vt,ft)|0,l=l+Math.imul(vt,Zt)|0,v=v+Math.imul(rt,Yt)|0,c=c+Math.imul(rt,Jt)|0,c=c+Math.imul(ct,Yt)|0,l=l+Math.imul(ct,Jt)|0,v=v+Math.imul(_,Xt)|0,c=c+Math.imul(_,Qt)|0,c=c+Math.imul(L,Xt)|0,l=l+Math.imul(L,Qt)|0;var rs=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(rs>>>26)|0,rs&=67108863,v=Math.imul(Lt,yt),c=Math.imul(Lt,dt),c=c+Math.imul(Wt,yt)|0,l=Math.imul(Wt,dt),v=v+Math.imul(St,ft)|0,c=c+Math.imul(St,Zt)|0,c=c+Math.imul(Tt,ft)|0,l=l+Math.imul(Tt,Zt)|0,v=v+Math.imul(gt,Yt)|0,c=c+Math.imul(gt,Jt)|0,c=c+Math.imul(vt,Yt)|0,l=l+Math.imul(vt,Jt)|0,v=v+Math.imul(rt,Xt)|0,c=c+Math.imul(rt,Qt)|0,c=c+Math.imul(ct,Xt)|0,l=l+Math.imul(ct,Qt)|0,v=v+Math.imul(_,te)|0,c=c+Math.imul(_,ee)|0,c=c+Math.imul(L,te)|0,l=l+Math.imul(L,ee)|0;var ns=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(ns>>>26)|0,ns&=67108863,v=Math.imul(zt,yt),c=Math.imul(zt,dt),c=c+Math.imul(Ct,yt)|0,l=Math.imul(Ct,dt),v=v+Math.imul(Lt,ft)|0,c=c+Math.imul(Lt,Zt)|0,c=c+Math.imul(Wt,ft)|0,l=l+Math.imul(Wt,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(gt,Xt)|0,c=c+Math.imul(gt,Qt)|0,c=c+Math.imul(vt,Xt)|0,l=l+Math.imul(vt,Qt)|0,v=v+Math.imul(rt,te)|0,c=c+Math.imul(rt,ee)|0,c=c+Math.imul(ct,te)|0,l=l+Math.imul(ct,ee)|0,v=v+Math.imul(_,re)|0,c=c+Math.imul(_,ne)|0,c=c+Math.imul(L,re)|0,l=l+Math.imul(L,ne)|0;var is=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(is>>>26)|0,is&=67108863,v=Math.imul(Ot,yt),c=Math.imul(Ot,dt),c=c+Math.imul(Ft,yt)|0,l=Math.imul(Ft,dt),v=v+Math.imul(zt,ft)|0,c=c+Math.imul(zt,Zt)|0,c=c+Math.imul(Ct,ft)|0,l=l+Math.imul(Ct,Zt)|0,v=v+Math.imul(Lt,Yt)|0,c=c+Math.imul(Lt,Jt)|0,c=c+Math.imul(Wt,Yt)|0,l=l+Math.imul(Wt,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(gt,te)|0,c=c+Math.imul(gt,ee)|0,c=c+Math.imul(vt,te)|0,l=l+Math.imul(vt,ee)|0,v=v+Math.imul(rt,re)|0,c=c+Math.imul(rt,ne)|0,c=c+Math.imul(ct,re)|0,l=l+Math.imul(ct,ne)|0,v=v+Math.imul(_,ie)|0,c=c+Math.imul(_,se)|0,c=c+Math.imul(L,ie)|0,l=l+Math.imul(L,se)|0;var ss=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(ss>>>26)|0,ss&=67108863,v=Math.imul(Dt,yt),c=Math.imul(Dt,dt),c=c+Math.imul(m,yt)|0,l=Math.imul(m,dt),v=v+Math.imul(Ot,ft)|0,c=c+Math.imul(Ot,Zt)|0,c=c+Math.imul(Ft,ft)|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(Ct,Yt)|0,l=l+Math.imul(Ct,Jt)|0,v=v+Math.imul(Lt,Xt)|0,c=c+Math.imul(Lt,Qt)|0,c=c+Math.imul(Wt,Xt)|0,l=l+Math.imul(Wt,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(gt,re)|0,c=c+Math.imul(gt,ne)|0,c=c+Math.imul(vt,re)|0,l=l+Math.imul(vt,ne)|0,v=v+Math.imul(rt,ie)|0,c=c+Math.imul(rt,se)|0,c=c+Math.imul(ct,ie)|0,l=l+Math.imul(ct,se)|0,v=v+Math.imul(_,oe)|0,c=c+Math.imul(_,ae)|0,c=c+Math.imul(L,oe)|0,l=l+Math.imul(L,ae)|0;var os=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(os>>>26)|0,os&=67108863,v=Math.imul(d,yt),c=Math.imul(d,dt),c=c+Math.imul(A,yt)|0,l=Math.imul(A,dt),v=v+Math.imul(Dt,ft)|0,c=c+Math.imul(Dt,Zt)|0,c=c+Math.imul(m,ft)|0,l=l+Math.imul(m,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(Ct,Xt)|0,l=l+Math.imul(Ct,Qt)|0,v=v+Math.imul(Lt,te)|0,c=c+Math.imul(Lt,ee)|0,c=c+Math.imul(Wt,te)|0,l=l+Math.imul(Wt,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(gt,ie)|0,c=c+Math.imul(gt,se)|0,c=c+Math.imul(vt,ie)|0,l=l+Math.imul(vt,se)|0,v=v+Math.imul(rt,oe)|0,c=c+Math.imul(rt,ae)|0,c=c+Math.imul(ct,oe)|0,l=l+Math.imul(ct,ae)|0,v=v+Math.imul(_,ce)|0,c=c+Math.imul(_,ue)|0,c=c+Math.imul(L,ce)|0,l=l+Math.imul(L,ue)|0;var as=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(as>>>26)|0,as&=67108863,v=Math.imul(z,yt),c=Math.imul(z,dt),c=c+Math.imul(G,yt)|0,l=Math.imul(G,dt),v=v+Math.imul(d,ft)|0,c=c+Math.imul(d,Zt)|0,c=c+Math.imul(A,ft)|0,l=l+Math.imul(A,Zt)|0,v=v+Math.imul(Dt,Yt)|0,c=c+Math.imul(Dt,Jt)|0,c=c+Math.imul(m,Yt)|0,l=l+Math.imul(m,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(Ct,te)|0,l=l+Math.imul(Ct,ee)|0,v=v+Math.imul(Lt,re)|0,c=c+Math.imul(Lt,ne)|0,c=c+Math.imul(Wt,re)|0,l=l+Math.imul(Wt,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(gt,oe)|0,c=c+Math.imul(gt,ae)|0,c=c+Math.imul(vt,oe)|0,l=l+Math.imul(vt,ae)|0,v=v+Math.imul(rt,ce)|0,c=c+Math.imul(rt,ue)|0,c=c+Math.imul(ct,ce)|0,l=l+Math.imul(ct,ue)|0,v=v+Math.imul(_,le)|0,c=c+Math.imul(_,he)|0,c=c+Math.imul(L,le)|0,l=l+Math.imul(L,he)|0;var cs=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(cs>>>26)|0,cs&=67108863,v=Math.imul(z,ft),c=Math.imul(z,Zt),c=c+Math.imul(G,ft)|0,l=Math.imul(G,Zt),v=v+Math.imul(d,Yt)|0,c=c+Math.imul(d,Jt)|0,c=c+Math.imul(A,Yt)|0,l=l+Math.imul(A,Jt)|0,v=v+Math.imul(Dt,Xt)|0,c=c+Math.imul(Dt,Qt)|0,c=c+Math.imul(m,Xt)|0,l=l+Math.imul(m,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(Ct,re)|0,l=l+Math.imul(Ct,ne)|0,v=v+Math.imul(Lt,ie)|0,c=c+Math.imul(Lt,se)|0,c=c+Math.imul(Wt,ie)|0,l=l+Math.imul(Wt,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(gt,ce)|0,c=c+Math.imul(gt,ue)|0,c=c+Math.imul(vt,ce)|0,l=l+Math.imul(vt,ue)|0,v=v+Math.imul(rt,le)|0,c=c+Math.imul(rt,he)|0,c=c+Math.imul(ct,le)|0,l=l+Math.imul(ct,he)|0;var us=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(us>>>26)|0,us&=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(A,Xt)|0,l=l+Math.imul(A,Qt)|0,v=v+Math.imul(Dt,te)|0,c=c+Math.imul(Dt,ee)|0,c=c+Math.imul(m,te)|0,l=l+Math.imul(m,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(Ct,ie)|0,l=l+Math.imul(Ct,se)|0,v=v+Math.imul(Lt,oe)|0,c=c+Math.imul(Lt,ae)|0,c=c+Math.imul(Wt,oe)|0,l=l+Math.imul(Wt,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(gt,le)|0,c=c+Math.imul(gt,he)|0,c=c+Math.imul(vt,le)|0,l=l+Math.imul(vt,he)|0;var ls=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(ls>>>26)|0,ls&=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(A,te)|0,l=l+Math.imul(A,ee)|0,v=v+Math.imul(Dt,re)|0,c=c+Math.imul(Dt,ne)|0,c=c+Math.imul(m,re)|0,l=l+Math.imul(m,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(Ct,oe)|0,l=l+Math.imul(Ct,ae)|0,v=v+Math.imul(Lt,ce)|0,c=c+Math.imul(Lt,ue)|0,c=c+Math.imul(Wt,ce)|0,l=l+Math.imul(Wt,ue)|0,v=v+Math.imul(St,le)|0,c=c+Math.imul(St,he)|0,c=c+Math.imul(Tt,le)|0,l=l+Math.imul(Tt,he)|0;var hs=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(hs>>>26)|0,hs&=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(A,re)|0,l=l+Math.imul(A,ne)|0,v=v+Math.imul(Dt,ie)|0,c=c+Math.imul(Dt,se)|0,c=c+Math.imul(m,ie)|0,l=l+Math.imul(m,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(Ct,ce)|0,l=l+Math.imul(Ct,ue)|0,v=v+Math.imul(Lt,le)|0,c=c+Math.imul(Lt,he)|0,c=c+Math.imul(Wt,le)|0,l=l+Math.imul(Wt,he)|0;var fs=(O+v|0)+((c&8191)<<13)|0;O=(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(A,ie)|0,l=l+Math.imul(A,se)|0,v=v+Math.imul(Dt,oe)|0,c=c+Math.imul(Dt,ae)|0,c=c+Math.imul(m,oe)|0,l=l+Math.imul(m,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,he)|0,c=c+Math.imul(Ct,le)|0,l=l+Math.imul(Ct,he)|0;var ds=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(ds>>>26)|0,ds&=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(A,oe)|0,l=l+Math.imul(A,ae)|0,v=v+Math.imul(Dt,ce)|0,c=c+Math.imul(Dt,ue)|0,c=c+Math.imul(m,ce)|0,l=l+Math.imul(m,ue)|0,v=v+Math.imul(Ot,le)|0,c=c+Math.imul(Ot,he)|0,c=c+Math.imul(Ft,le)|0,l=l+Math.imul(Ft,he)|0;var ps=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(ps>>>26)|0,ps&=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(A,ce)|0,l=l+Math.imul(A,ue)|0,v=v+Math.imul(Dt,le)|0,c=c+Math.imul(Dt,he)|0,c=c+Math.imul(m,le)|0,l=l+Math.imul(m,he)|0;var gs=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(gs>>>26)|0,gs&=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,he)|0,c=c+Math.imul(A,le)|0,l=l+Math.imul(A,he)|0;var ys=(O+v|0)+((c&8191)<<13)|0;O=(l+(c>>>13)|0)+(ys>>>26)|0,ys&=67108863,v=Math.imul(z,le),c=Math.imul(z,he),c=c+Math.imul(G,le)|0,l=Math.imul(G,he);var ms=(O+v|0)+((c&8191)<<13)|0;return O=(l+(c>>>13)|0)+(ms>>>26)|0,ms&=67108863,I[0]=Qi,I[1]=ts,I[2]=es,I[3]=rs,I[4]=ns,I[5]=is,I[6]=ss,I[7]=os,I[8]=as,I[9]=cs,I[10]=us,I[11]=ls,I[12]=hs,I[13]=fs,I[14]=ds,I[15]=ps,I[16]=gs,I[17]=ys,I[18]=ms,O!==0&&(I[19]=O,y.length++),y};Math.imul||(W=U);function D(x,a,p){p.negative=a.negative^x.negative,p.length=x.length+a.length;for(var y=0,E=0,S=0;S<p.length-1;S++){var I=E;E=0;for(var O=y&67108863,v=Math.min(S,a.length-1),c=Math.max(0,S-x.length+1);c<=v;c++){var l=S-c,b=x.words[l]|0,_=a.words[c]|0,L=b*_,j=L&67108863;I=I+(L/67108864|0)|0,j=j+O|0,O=j&67108863,I=I+(j>>>26)|0,E+=I>>>26,I&=67108863}p.words[S]=O,y=I,I=E}return y!==0?p.words[S]=y:p.length--,p._strip()}function J(x,a,p){return D(x,a,p)}i.prototype.mulTo=function(a,p){var y,E=this.length+a.length;return this.length===10&&a.length===10?y=W(this,a,p):E<63?y=U(this,a,p):E<1024?y=D(this,a,p):y=J(this,a,p),y},i.prototype.mul=function(a){var p=new i(null);return p.words=new Array(this.length+a.length),this.mulTo(a,p)},i.prototype.mulf=function(a){var p=new i(null);return p.words=new Array(this.length+a.length),J(this,a,p)},i.prototype.imul=function(a){return this.clone().mulTo(a,this)},i.prototype.imuln=function(a){var p=a<0;p&&(a=-a),r(typeof a=="number"),r(a<67108864);for(var y=0,E=0;E<this.length;E++){var S=(this.words[E]|0)*a,I=(S&67108863)+(y&67108863);y>>=26,y+=S/67108864|0,y+=I>>>26,this.words[E]=I&67108863}return y!==0&&(this.words[E]=y,this.length++),p?this.ineg():this},i.prototype.muln=function(a){return this.clone().imuln(a)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(a){var p=T(a);if(p.length===0)return new i(1);for(var y=this,E=0;E<p.length&&p[E]===0;E++,y=y.sqr());if(++E<p.length)for(var S=y.sqr();E<p.length;E++,S=S.sqr())p[E]!==0&&(y=y.mul(S));return y},i.prototype.iushln=function(a){r(typeof a=="number"&&a>=0);var p=a%26,y=(a-p)/26,E=67108863>>>26-p<<26-p,S;if(p!==0){var I=0;for(S=0;S<this.length;S++){var O=this.words[S]&E,v=(this.words[S]|0)-O<<p;this.words[S]=v|I,I=O>>>26-p}I&&(this.words[S]=I,this.length++)}if(y!==0){for(S=this.length-1;S>=0;S--)this.words[S+y]=this.words[S];for(S=0;S<y;S++)this.words[S]=0;this.length+=y}return this._strip()},i.prototype.ishln=function(a){return r(this.negative===0),this.iushln(a)},i.prototype.iushrn=function(a,p,y){r(typeof a=="number"&&a>=0);var E;p?E=(p-p%26)/26:E=0;var S=a%26,I=Math.min((a-S)/26,this.length),O=67108863^67108863>>>S<<S,v=y;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 b=this.words[c]|0;this.words[c]=l<<26-S|b>>>S,l=b&O}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(a,p,y){return r(this.negative===0),this.iushrn(a,p,y)},i.prototype.shln=function(a){return this.clone().ishln(a)},i.prototype.ushln=function(a){return this.clone().iushln(a)},i.prototype.shrn=function(a){return this.clone().ishrn(a)},i.prototype.ushrn=function(a){return this.clone().iushrn(a)},i.prototype.testn=function(a){r(typeof a=="number"&&a>=0);var p=a%26,y=(a-p)/26,E=1<<p;if(this.length<=y)return!1;var S=this.words[y];return!!(S&E)},i.prototype.imaskn=function(a){r(typeof a=="number"&&a>=0);var p=a%26,y=(a-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(p!==0&&y++,this.length=Math.min(y,this.length),p!==0){var E=67108863^67108863>>>p<<p;this.words[this.length-1]&=E}return this._strip()},i.prototype.maskn=function(a){return this.clone().imaskn(a)},i.prototype.iaddn=function(a){return r(typeof a=="number"),r(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},i.prototype._iaddn=function(a){this.words[0]+=a;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(a){if(r(typeof a=="number"),r(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,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(a){return this.clone().iaddn(a)},i.prototype.subn=function(a){return this.clone().isubn(a)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(a,p,y){var E=a.length+y,S;this._expand(E);var I,O=0;for(S=0;S<a.length;S++){I=(this.words[S+y]|0)+O;var v=(a.words[S]|0)*p;I-=v&67108863,O=(I>>26)-(v/67108864|0),this.words[S+y]=I&67108863}for(;S<this.length-y;S++)I=(this.words[S+y]|0)+O,O=I>>26,this.words[S+y]=I&67108863;if(O===0)return this._strip();for(r(O===-1),O=0,S=0;S<this.length;S++)I=-(this.words[S]|0)+O,O=I>>26,this.words[S]=I&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(a,p){var y=this.length-a.length,E=this.clone(),S=a,I=S.words[S.length-1]|0,O=this._countBits(I);y=26-O,y!==0&&(S=S.ushln(y),E.iushln(y),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 b=E.clone()._ishlnsubmul(S,1,v);b.negative===0&&(E=b,c&&(c.words[v]=1));for(var _=v-1;_>=0;_--){var L=(E.words[S.length+_]|0)*67108864+(E.words[S.length+_-1]|0);for(L=Math.min(L/I|0,67108863),E._ishlnsubmul(S,L,_);E.negative!==0;)L--,E.negative=0,E._ishlnsubmul(S,1,_),E.isZero()||(E.negative^=1);c&&(c.words[_]=L)}return c&&c._strip(),E._strip(),p!=="div"&&y!==0&&E.iushrn(y),{div:c||null,mod:E}},i.prototype.divmod=function(a,p,y){if(r(!a.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var E,S,I;return this.negative!==0&&a.negative===0?(I=this.neg().divmod(a,p),p!=="mod"&&(E=I.div.neg()),p!=="div"&&(S=I.mod.neg(),y&&S.negative!==0&&S.iadd(a)),{div:E,mod:S}):this.negative===0&&a.negative!==0?(I=this.divmod(a.neg(),p),p!=="mod"&&(E=I.div.neg()),{div:E,mod:I.mod}):(this.negative&a.negative)!==0?(I=this.neg().divmod(a.neg(),p),p!=="div"&&(S=I.mod.neg(),y&&S.negative!==0&&S.isub(a)),{div:I.div,mod:S}):a.length>this.length||this.cmp(a)<0?{div:new i(0),mod:this}:a.length===1?p==="div"?{div:this.divn(a.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new i(this.modrn(a.words[0]))}:this._wordDiv(a,p)},i.prototype.div=function(a){return this.divmod(a,"div",!1).div},i.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},i.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},i.prototype.divRound=function(a){var p=this.divmod(a);if(p.mod.isZero())return p.div;var y=p.div.negative!==0?p.mod.isub(a):p.mod,E=a.ushrn(1),S=a.andln(1),I=y.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(a){var p=a<0;p&&(a=-a),r(a<=67108863);for(var y=(1<<26)%a,E=0,S=this.length-1;S>=0;S--)E=(y*E+(this.words[S]|0))%a;return p?-E:E},i.prototype.modn=function(a){return this.modrn(a)},i.prototype.idivn=function(a){var p=a<0;p&&(a=-a),r(a<=67108863);for(var y=0,E=this.length-1;E>=0;E--){var S=(this.words[E]|0)+y*67108864;this.words[E]=S/a|0,y=S%a}return this._strip(),p?this.ineg():this},i.prototype.divn=function(a){return this.clone().idivn(a)},i.prototype.egcd=function(a){r(a.negative===0),r(!a.isZero());var p=this,y=a.clone();p.negative!==0?p=p.umod(a):p=p.clone();for(var E=new i(1),S=new i(0),I=new i(0),O=new i(1),v=0;p.isEven()&&y.isEven();)p.iushrn(1),y.iushrn(1),++v;for(var c=y.clone(),l=p.clone();!p.isZero();){for(var b=0,_=1;(p.words[0]&_)===0&&b<26;++b,_<<=1);if(b>0)for(p.iushrn(b);b-- >0;)(E.isOdd()||S.isOdd())&&(E.iadd(c),S.isub(l)),E.iushrn(1),S.iushrn(1);for(var L=0,j=1;(y.words[0]&j)===0&&L<26;++L,j<<=1);if(L>0)for(y.iushrn(L);L-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(c),O.isub(l)),I.iushrn(1),O.iushrn(1);p.cmp(y)>=0?(p.isub(y),E.isub(I),S.isub(O)):(y.isub(p),I.isub(E),O.isub(S))}return{a:I,b:O,gcd:y.iushln(v)}},i.prototype._invmp=function(a){r(a.negative===0),r(!a.isZero());var p=this,y=a.clone();p.negative!==0?p=p.umod(a):p=p.clone();for(var E=new i(1),S=new i(0),I=y.clone();p.cmpn(1)>0&&y.cmpn(1)>0;){for(var O=0,v=1;(p.words[0]&v)===0&&O<26;++O,v<<=1);if(O>0)for(p.iushrn(O);O-- >0;)E.isOdd()&&E.iadd(I),E.iushrn(1);for(var c=0,l=1;(y.words[0]&l)===0&&c<26;++c,l<<=1);if(c>0)for(y.iushrn(c);c-- >0;)S.isOdd()&&S.iadd(I),S.iushrn(1);p.cmp(y)>=0?(p.isub(y),E.isub(S)):(y.isub(p),S.isub(E))}var b;return p.cmpn(1)===0?b=E:b=S,b.cmpn(0)<0&&b.iadd(a),b},i.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var p=this.clone(),y=a.clone();p.negative=0,y.negative=0;for(var E=0;p.isEven()&&y.isEven();E++)p.iushrn(1),y.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;y.isEven();)y.iushrn(1);var S=p.cmp(y);if(S<0){var I=p;p=y,y=I}else if(S===0||y.cmpn(1)===0)break;p.isub(y)}while(!0);return y.iushln(E)},i.prototype.invm=function(a){return this.egcd(a).a.umod(a)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(a){return this.words[0]&a},i.prototype.bincn=function(a){r(typeof a=="number");var p=a%26,y=(a-p)/26,E=1<<p;if(this.length<=y)return this._expand(y+1),this.words[y]|=E,this;for(var S=E,I=y;S!==0&&I<this.length;I++){var O=this.words[I]|0;O+=S,S=O>>>26,O&=67108863,this.words[I]=O}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(a){var p=a<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var y;if(this.length>1)y=1;else{p&&(a=-a),r(a<=67108863,"Number is too big");var E=this.words[0]|0;y=E===a?0:E<a?-1:1}return this.negative!==0?-y|0:y},i.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var p=this.ucmp(a);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var p=0,y=this.length-1;y>=0;y--){var E=this.words[y]|0,S=a.words[y]|0;if(E!==S){E<S?p=-1:E>S&&(p=1);break}}return p},i.prototype.gtn=function(a){return this.cmpn(a)===1},i.prototype.gt=function(a){return this.cmp(a)===1},i.prototype.gten=function(a){return this.cmpn(a)>=0},i.prototype.gte=function(a){return this.cmp(a)>=0},i.prototype.ltn=function(a){return this.cmpn(a)===-1},i.prototype.lt=function(a){return this.cmp(a)===-1},i.prototype.lten=function(a){return this.cmpn(a)<=0},i.prototype.lte=function(a){return this.cmp(a)<=0},i.prototype.eqn=function(a){return this.cmpn(a)===0},i.prototype.eq=function(a){return this.cmp(a)===0},i.red=function(a){return new V(a)},i.prototype.toRed=function(a){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(a){return this.red=a,this},i.prototype.forceRed=function(a){return r(!this.red,"Already a number in reduction context"),this._forceRed(a)},i.prototype.redAdd=function(a){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},i.prototype.redIAdd=function(a){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},i.prototype.redSub=function(a){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},i.prototype.redISub=function(a){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},i.prototype.redShl=function(a){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},i.prototype.redMul=function(a){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},i.prototype.redIMul=function(a){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},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(a){return r(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var $={k256:null,p224:null,p192:null,p25519:null};function F(x,a){this.name=x,this.p=new i(a,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 a=new i(null);return a.words=new Array(Math.ceil(this.n/13)),a},F.prototype.ireduce=function(a){var p=a,y;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),y=p.bitLength();while(y>this.n);var E=y<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(a,p){a.iushrn(this.n,0,p)},F.prototype.imulK=function(a){return a.imul(this.k)};function Y(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(Y,F),Y.prototype.split=function(a,p){for(var y=4194303,E=Math.min(a.length,9),S=0;S<E;S++)p.words[S]=a.words[S];if(p.length=E,a.length<=9){a.words[0]=0,a.length=1;return}var I=a.words[9];for(p.words[p.length++]=I&y,S=10;S<a.length;S++){var O=a.words[S]|0;a.words[S-10]=(O&y)<<4|I>>>22,I=O}I>>>=22,a.words[S-10]=I,I===0&&a.length>10?a.length-=10:a.length-=9},Y.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var p=0,y=0;y<a.length;y++){var E=a.words[y]|0;p+=E*977,a.words[y]=p&67108863,p=E*64+(p/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function Z(){F.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(Z,F);function X(){F.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(X,F);function q(){F.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(q,F),q.prototype.imulK=function(a){for(var p=0,y=0;y<a.length;y++){var E=(a.words[y]|0)*19+p,S=E&67108863;E>>>=26,a.words[y]=S,p=E}return p!==0&&(a.words[a.length++]=p),a},i._prime=function(a){if($[a])return $[a];var p;if(a==="k256")p=new Y;else if(a==="p224")p=new Z;else if(a==="p192")p=new X;else if(a==="p25519")p=new q;else throw new Error("Unknown prime "+a);return $[a]=p,p};function V(x){if(typeof x=="string"){var a=i._prime(x);this.m=a.p,this.prime=a}else r(x.gtn(1),"modulus must be greater than 1"),this.m=x,this.prime=null}V.prototype._verify1=function(a){r(a.negative===0,"red works only with positives"),r(a.red,"red works only with red numbers")},V.prototype._verify2=function(a,p){r((a.negative|p.negative)===0,"red works only with positives"),r(a.red&&a.red===p.red,"red works only with red numbers")},V.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(w(a,a.umod(this.m)._forceRed(this)),a)},V.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},V.prototype.add=function(a,p){this._verify2(a,p);var y=a.add(p);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},V.prototype.iadd=function(a,p){this._verify2(a,p);var y=a.iadd(p);return y.cmp(this.m)>=0&&y.isub(this.m),y},V.prototype.sub=function(a,p){this._verify2(a,p);var y=a.sub(p);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},V.prototype.isub=function(a,p){this._verify2(a,p);var y=a.isub(p);return y.cmpn(0)<0&&y.iadd(this.m),y},V.prototype.shl=function(a,p){return this._verify1(a),this.imod(a.ushln(p))},V.prototype.imul=function(a,p){return this._verify2(a,p),this.imod(a.imul(p))},V.prototype.mul=function(a,p){return this._verify2(a,p),this.imod(a.mul(p))},V.prototype.isqr=function(a){return this.imul(a,a.clone())},V.prototype.sqr=function(a){return this.mul(a,a)},V.prototype.sqrt=function(a){if(a.isZero())return a.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var y=this.m.add(new i(1)).iushrn(2);return this.pow(a,y)}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),O=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(O)!==0;)c.redIAdd(O);for(var l=this.pow(c,E),b=this.pow(a,E.addn(1).iushrn(1)),_=this.pow(a,E),L=S;_.cmp(I)!==0;){for(var j=_,rt=0;j.cmp(I)!==0;rt++)j=j.redSqr();r(rt<L);var ct=this.pow(l,new i(1).iushln(L-rt-1));b=b.redMul(ct),l=ct.redSqr(),_=_.redMul(l),L=rt}return b},V.prototype.invm=function(a){var p=a._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},V.prototype.pow=function(a,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return a.clone();var y=4,E=new Array(1<<y);E[0]=new i(1).toRed(this),E[1]=a;for(var S=2;S<E.length;S++)E[S]=this.mul(E[S-1],a);var I=E[0],O=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],b=c-1;b>=0;b--){var _=l>>b&1;if(I!==E[0]&&(I=this.sqr(I)),_===0&&O===0){v=0;continue}O<<=1,O|=_,v++,!(v!==y&&(S!==0||b!==0))&&(I=this.mul(I,E[O]),v=0,O=0)}c=26}return I},V.prototype.convertTo=function(a){var p=a.umod(this.m);return p===a?p.clone():p},V.prototype.convertFrom=function(a){var p=a.clone();return p.red=null,p},i.mont=function(a){return new Q(a)};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(a){return this.imod(a.ushln(this.shift))},Q.prototype.convertFrom=function(a){var p=this.imod(a.mul(this.rinv));return p.red=null,p},Q.prototype.imul=function(a,p){if(a.isZero()||p.isZero())return a.words[0]=0,a.length=1,a;var y=a.imul(p),E=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=y.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(a,p){if(a.isZero()||p.isZero())return new i(0)._forceRed(this);var y=a.mul(p),E=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=y.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(a){var p=this.imod(a._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(n,Wc)}(an)),an.exports}var $c=Ys();const Js=Nr($c);var cn={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Xs;function Hc(){return Xs||(Xs=1,function(n,t){var e=zn(),r=e.Buffer;function s(o,u){for(var f in o)u[f]=o[f]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(s(e,t),t.Buffer=i);function i(o,u,f){return r(o,u,f)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,u,f){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,u,f)},i.alloc=function(o,u,f){if(typeof o!="number")throw new TypeError("Argument must be a number");var g=r(o);return u!==void 0?typeof f=="string"?g.fill(u,f):g.fill(u):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 Qn,Qs;function Vc(){if(Qs)return Qn;Qs=1;var n=Hc().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),u=o.charCodeAt(0);if(r[u]!==255)throw new TypeError(o+" is ambiguous");r[u]=i}var f=e.length,g=e.charAt(0),w=Math.log(f)/Math.log(256),k=Math.log(256)/Math.log(f);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,U=0,W=0,D=B.length;W!==D&&B[W]===0;)W++,T++;for(var J=(D-W)*k+1>>>0,$=new Uint8Array(J);W!==D;){for(var F=B[W],Y=0,Z=J-1;(F!==0||Y<U)&&Z!==-1;Z--,Y++)F+=256*$[Z]>>>0,$[Z]=F%f>>>0,F=F/f>>>0;if(F!==0)throw new Error("Non-zero carry");U=Y,W++}for(var X=J-U;X!==J&&$[X]===0;)X++;for(var q=g.repeat(T);X<J;++X)q+=e.charAt($[X]);return q}function R(B){if(typeof B!="string")throw new TypeError("Expected String");if(B.length===0)return n.alloc(0);for(var T=0,U=0,W=0;B[T]===g;)U++,T++;for(var D=(B.length-T)*w+1>>>0,J=new Uint8Array(D);B[T];){var $=r[B.charCodeAt(T)];if($===255)return;for(var F=0,Y=D-1;($!==0||F<W)&&Y!==-1;Y--,F++)$+=f*J[Y]>>>0,J[Y]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");W=F,T++}for(var Z=D-W;Z!==D&&J[Z]===0;)Z++;var X=n.allocUnsafe(U+(D-Z));X.fill(0,0,U);for(var q=U;Z!==D;)X[q++]=J[Z++];return X}function C(B){var T=R(B);if(T)return T;throw new Error("Non-base"+f+" character")}return{encode:M,decodeUnsafe:R,decode:C}}return Qn=t,Qn}var ti,to;function eo(){if(to)return ti;to=1;var n=Vc(),t="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return ti=n(t),ti}var jc=eo();const ge=Nr(jc),Gc=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 Zc 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:u,H:f}=this;return[t,e,r,s,i,o,u,f]}set(t,e,r,s,i,o,u,f){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=u|0,this.H=f|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:u,F:f,G:g,H:w}=this;for(let k=0;k<64;k++){const M=Oe(u,6)^Oe(u,11)^Oe(u,25),R=w+M+ja(u,f,g)+Gc[k]+Qe[k]|0,B=(Oe(r,2)^Oe(r,13)^Oe(r,22))+Ga(r,s,i)|0;w=g,g=f,f=u,u=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,u=u+this.E|0,f=f+this.F|0,g=g+this.G|0,w=w+this.H|0,this.set(r,s,i,o,u,f,g,w)}roundClean(){Qe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ei=Wn(()=>new Zc);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 Yc(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 u=i&1023,f=o&1023;s.push(65536+(u<<10)+f),r+=1}else s.push(65533)}r+=1}return s}function Jc(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 ri(n){this.tokens=[].slice.call(n)}ri.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 Ar=-1;function ni(n,t){if(n)throw TypeError("Decoder error");return t||65533}var hn="utf-8";function fn(n,t){if(!(this instanceof fn))return new fn(n,t);if(n=n!==void 0?String(n).toLowerCase():hn,n!==hn)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})}fn.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 Xc({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var s=new ri(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Ar);)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===Ar)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),Jc(i)}};function dn(n,t){if(!(this instanceof dn))return new dn(n,t);if(n=n!==void 0?String(n).toLowerCase():hn,n!==hn)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 Qc(this._options)),this._streaming=!!e.stream;for(var r=[],s=new ri(Yc(t)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Ar);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Ar;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function Xc(n){var t=n.fatal,e=0,r=0,s=0,i=128,o=191;this.handler=function(u,f){if(f===ln&&s!==0)return s=0,ni(t);if(f===ln)return Ar;if(s===0){if(Ve(f,0,127))return f;if(Ve(f,194,223))s=1,e=f-192;else if(Ve(f,224,239))f===224&&(i=160),f===237&&(o=159),s=2,e=f-224;else if(Ve(f,240,244))f===240&&(i=144),f===244&&(o=143),s=3,e=f-240;else return ni(t);return e=e<<6*s,null}if(!Ve(f,i,o))return e=s=r=0,i=128,o=191,u.prepend(f),ni(t);if(i=128,o=191,r+=1,e+=f-128<<6*(s-r),r!==s)return null;var g=e;return e=s=r=0,g}}function Qc(n){n.fatal,this.handler=function(t,e){if(e===ln)return Ar;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 tu=Nn(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:fn,TextEncoder:dn},Symbol.toStringTag,{value:"Module"})));var ro;function eu(){if(ro)return Mt;ro=1;var n=Mt&&Mt.__createBinding||(Object.create?function(X,q,V,Q){Q===void 0&&(Q=V),Object.defineProperty(X,Q,{enumerable:!0,get:function(){return q[V]}})}:function(X,q,V,Q){Q===void 0&&(Q=V),X[Q]=q[V]}),t=Mt&&Mt.__setModuleDefault||(Object.create?function(X,q){Object.defineProperty(X,"default",{enumerable:!0,value:q})}:function(X,q){X.default=q}),e=Mt&&Mt.__decorate||function(X,q,V,Q){var x=arguments.length,a=x<3?q:Q===null?Q=Object.getOwnPropertyDescriptor(q,V):Q,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(X,q,V,Q);else for(var y=X.length-1;y>=0;y--)(p=X[y])&&(a=(x<3?p(a):x>3?p(q,V,a):p(q,V))||a);return x>3&&a&&Object.defineProperty(q,V,a),a},r=Mt&&Mt.__importStar||function(X){if(X&&X.__esModule)return X;var q={};if(X!=null)for(var V in X)V!=="default"&&Object.hasOwnProperty.call(X,V)&&n(q,X,V);return t(q,X),q},s=Mt&&Mt.__importDefault||function(X){return X&&X.__esModule?X:{default:X}};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(Ys()),o=s(eo()),u=r(tu),f=typeof TextDecoder!="function"?u.TextDecoder:TextDecoder,g=new f("utf-8",{fatal:!0});function w(X){return typeof X=="string"&&(X=Buffer.from(X,"utf8")),o.default.encode(Buffer.from(X))}Mt.baseEncode=w;function k(X){return Buffer.from(o.default.decode(X))}Mt.baseDecode=k;const M=1024;class R extends Error{constructor(q){super(q),this.fieldPath=[],this.originalMessage=q}addToFieldPath(q){this.fieldPath.splice(0,0,q),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(q){this.maybeResize(),this.buf.writeUInt8(q,this.length),this.length+=1}writeU16(q){this.maybeResize(),this.buf.writeUInt16LE(q,this.length),this.length+=2}writeU32(q){this.maybeResize(),this.buf.writeUInt32LE(q,this.length),this.length+=4}writeU64(q){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(q).toArray("le",8)))}writeU128(q){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(q).toArray("le",16)))}writeU256(q){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(q).toArray("le",32)))}writeU512(q){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(q).toArray("le",64)))}writeBuffer(q){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),q,Buffer.alloc(M)]),this.length+=q.length}writeString(q){this.maybeResize();const V=Buffer.from(q,"utf8");this.writeU32(V.length),this.writeBuffer(V)}writeFixedArray(q){this.writeBuffer(Buffer.from(q))}writeArray(q,V){this.maybeResize(),this.writeU32(q.length);for(const Q of q)this.maybeResize(),V(Q)}toArray(){return this.buf.subarray(0,this.length)}}Mt.BinaryWriter=C;function B(X,q,V){const Q=V.value;V.value=function(...x){try{return Q.apply(this,x)}catch(a){if(a instanceof RangeError){const p=a.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 a}}}class T{constructor(q){this.buf=q,this.offset=0}readU8(){const q=this.buf.readUInt8(this.offset);return this.offset+=1,q}readU16(){const q=this.buf.readUInt16LE(this.offset);return this.offset+=2,q}readU32(){const q=this.buf.readUInt32LE(this.offset);return this.offset+=4,q}readU64(){const q=this.readBuffer(8);return new i.default(q,"le")}readU128(){const q=this.readBuffer(16);return new i.default(q,"le")}readU256(){const q=this.readBuffer(32);return new i.default(q,"le")}readU512(){const q=this.readBuffer(64);return new i.default(q,"le")}readBuffer(q){if(this.offset+q>this.buf.length)throw new R(`Expected buffer length ${q} isn't within bounds`);const V=this.buf.slice(this.offset,this.offset+q);return this.offset+=q,V}readString(){const q=this.readU32(),V=this.readBuffer(q);try{return g.decode(V)}catch(Q){throw new R(`Error decoding UTF-8 string: ${Q}`)}}readFixedArray(q){return new Uint8Array(this.readBuffer(q))}readArray(q){const V=this.readU32(),Q=Array();for(let x=0;x<V;++x)Q.push(q());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 U(X){return X.charAt(0).toUpperCase()+X.slice(1)}function W(X,q,V,Q,x){try{if(typeof Q=="string")x[`write${U(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 a=0;a<Q[1];a++)W(X,null,V[a],Q[0],x)}else x.writeArray(V,a=>{W(X,q,a,Q[0],x)});else if(Q.kind!==void 0)switch(Q.kind){case"option":{V==null?x.writeU8(0):(x.writeU8(1),W(X,q,V,Q.type,x));break}case"map":{x.writeU32(V.size),V.forEach((a,p)=>{W(X,q,p,Q.key,x),W(X,q,a,Q.value,x)});break}default:throw new R(`FieldType ${Q} unrecognized`)}else D(X,V,x)}catch(a){throw a instanceof R&&a.addToFieldPath(q),a}}function D(X,q,V){if(typeof q.borshSerialize=="function"){q.borshSerialize(V);return}const Q=X.get(q.constructor);if(!Q)throw new R(`Class ${q.constructor.name} is missing in schema`);if(Q.kind==="struct")Q.fields.map(([x,a])=>{W(X,x,q[x],a,V)});else if(Q.kind==="enum"){const x=q[Q.field];for(let a=0;a<Q.values.length;++a){const[p,y]=Q.values[a];if(p===x){V.writeU8(a),W(X,p,q[p],y,V);break}}}else throw new R(`Unexpected schema kind: ${Q.kind} for ${q.constructor.name}`)}function J(X,q,V=C){const Q=new V;return D(X,q,Q),Q.toArray()}Mt.serialize=J;function $(X,q,V,Q){try{if(typeof V=="string")return Q[`read${U(V)}`]();if(V instanceof Array){if(typeof V[0]=="number")return Q.readFixedArray(V[0]);if(typeof V[1]=="number"){const x=[];for(let a=0;a<V[1];a++)x.push($(X,null,V[0],Q));return x}else return Q.readArray(()=>$(X,q,V[0],Q))}if(V.kind==="option")return Q.readU8()?$(X,q,V.type,Q):void 0;if(V.kind==="map"){let x=new Map;const a=Q.readU32();for(let p=0;p<a;p++){const y=$(X,q,V.key,Q),E=$(X,q,V.value,Q);x.set(y,E)}return x}return F(X,V,Q)}catch(x){throw x instanceof R&&x.addToFieldPath(q),x}}function F(X,q,V){if(typeof q.borshDeserialize=="function")return q.borshDeserialize(V);const Q=X.get(q);if(!Q)throw new R(`Class ${q.name} is missing in schema`);if(Q.kind==="struct"){const x={};for(const[a,p]of X.get(q).fields)x[a]=$(X,a,p,V);return new q(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[a,p]=Q.values[x],y=$(X,a,p,V);return new q({[a]:y})}throw new R(`Unexpected schema kind: ${Q.kind} for ${q.constructor.name}`)}function Y(X,q,V,Q=T){const x=new Q(V),a=F(X,q,x);if(x.offset<V.length)throw new R(`Unexpected ${V.length-x.offset} bytes after deserialized data`);return a}Mt.deserialize=Y;function Z(X,q,V,Q=T){const x=new Q(V);return F(X,q,x)}return Mt.deserializeUnchecked=Z,Mt}var ii=eu(),H={},no;function ru(){if(no)return H;no=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=zn();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,b){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=b}makeDestinationObject(){return{}}getSpan(l,b){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const b=Object.create(this.constructor.prototype);return Object.assign(b,this),b.property=l,b}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(b,_){return l.encode(this,b,_)},writable:!0}),Object.defineProperty(c,"decode",{value(b,_){return l.decode(b,_)},writable:!0})}H.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}H.ExternalLayout=o;class u extends o{constructor(l=1,b){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,b),this.elementSpan=l}isCount(){return!0}decode(l,b=0){t(l);const _=l.length-b;return Math.floor(_/this.elementSpan)}encode(l,b,_){return 0}}H.GreedyCount=u;class f extends o{constructor(l,b=0,_){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(b))throw new TypeError("offset must be integer or undefined");super(l.span,_||l.property),this.layout=l,this.offset=b}isCount(){return this.layout instanceof g||this.layout instanceof w}decode(l,b=0){return this.layout.decode(l,b+this.offset)}encode(l,b,_=0){return this.layout.encode(l,b,_+this.offset)}}H.OffsetLayout=f;class g extends r{constructor(l,b){if(super(l,b),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,b=0){return e(l).readUIntLE(b,this.span)}encode(l,b,_=0){return e(b).writeUIntLE(l,_,this.span),this.span}}H.UInt=g;class w extends r{constructor(l,b){if(super(l,b),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,b=0){return e(l).readUIntBE(b,this.span)}encode(l,b,_=0){return e(b).writeUIntBE(l,_,this.span),this.span}}H.UIntBE=w;class k extends r{constructor(l,b){if(super(l,b),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,b=0){return e(l).readIntLE(b,this.span)}encode(l,b,_=0){return e(b).writeIntLE(l,_,this.span),this.span}}H.Int=k;class M extends r{constructor(l,b){if(super(l,b),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,b=0){return e(l).readIntBE(b,this.span)}encode(l,b,_=0){return e(b).writeIntBE(l,_,this.span),this.span}}H.IntBE=M;const R=Math.pow(2,32);function C(c){const l=Math.floor(c/R),b=c-l*R;return{hi32:l,lo32:b}}function B(c,l){return c*R+l}class T extends r{constructor(l){super(8,l)}decode(l,b=0){const _=e(l),L=_.readUInt32LE(b),j=_.readUInt32LE(b+4);return B(j,L)}encode(l,b,_=0){const L=C(l),j=e(b);return j.writeUInt32LE(L.lo32,_),j.writeUInt32LE(L.hi32,_+4),8}}H.NearUInt64=T;class U extends r{constructor(l){super(8,l)}decode(l,b=0){const _=e(l),L=_.readUInt32BE(b),j=_.readUInt32BE(b+4);return B(L,j)}encode(l,b,_=0){const L=C(l),j=e(b);return j.writeUInt32BE(L.hi32,_),j.writeUInt32BE(L.lo32,_+4),8}}H.NearUInt64BE=U;class W extends r{constructor(l){super(8,l)}decode(l,b=0){const _=e(l),L=_.readUInt32LE(b),j=_.readInt32LE(b+4);return B(j,L)}encode(l,b,_=0){const L=C(l),j=e(b);return j.writeUInt32LE(L.lo32,_),j.writeInt32LE(L.hi32,_+4),8}}H.NearInt64=W;class D extends r{constructor(l){super(8,l)}decode(l,b=0){const _=e(l),L=_.readInt32BE(b),j=_.readUInt32BE(b+4);return B(L,j)}encode(l,b,_=0){const L=C(l),j=e(b);return j.writeInt32BE(L.hi32,_),j.writeUInt32BE(L.lo32,_+4),8}}H.NearInt64BE=D;class J extends r{constructor(l){super(4,l)}decode(l,b=0){return e(l).readFloatLE(b)}encode(l,b,_=0){return e(b).writeFloatLE(l,_),4}}H.Float=J;class $ extends r{constructor(l){super(4,l)}decode(l,b=0){return e(l).readFloatBE(b)}encode(l,b,_=0){return e(b).writeFloatBE(l,_),4}}H.FloatBE=$;class F extends r{constructor(l){super(8,l)}decode(l,b=0){return e(l).readDoubleLE(b)}encode(l,b,_=0){return e(b).writeDoubleLE(l,_),8}}H.Double=F;class Y extends r{constructor(l){super(8,l)}decode(l,b=0){return e(l).readDoubleBE(b)}encode(l,b,_=0){return e(b).writeDoubleBE(l,_),8}}H.DoubleBE=Y;class Z extends r{constructor(l,b,_){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(b instanceof o&&b.isCount()||Number.isInteger(b)&&0<=b))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let L=-1;!(b instanceof o)&&0<l.span&&(L=b*l.span),super(L,_),this.elementLayout=l,this.count=b}getSpan(l,b=0){if(0<=this.span)return this.span;let _=0,L=this.count;if(L instanceof o&&(L=L.decode(l,b)),0<this.elementLayout.span)_=L*this.elementLayout.span;else{let j=0;for(;j<L;)_+=this.elementLayout.getSpan(l,b+_),++j}return _}decode(l,b=0){const _=[];let L=0,j=this.count;for(j instanceof o&&(j=j.decode(l,b));L<j;)_.push(this.elementLayout.decode(l,b)),b+=this.elementLayout.getSpan(l,b),L+=1;return _}encode(l,b,_=0){const L=this.elementLayout,j=l.reduce((rt,ct)=>rt+L.encode(ct,b,_+rt),0);return this.count instanceof o&&this.count.encode(l.length,b,_),j}}H.Sequence=Z;class X extends r{constructor(l,b,_){if(!(Array.isArray(l)&&l.reduce((j,rt)=>j&&rt instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof b=="boolean"&&_===void 0&&(_=b,b=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 L=-1;try{L=l.reduce((j,rt)=>j+rt.getSpan(),0)}catch{}super(L,b),this.fields=l,this.decodePrefixes=!!_}getSpan(l,b=0){if(0<=this.span)return this.span;let _=0;try{_=this.fields.reduce((L,j)=>{const rt=j.getSpan(l,b);return b+=rt,L+rt},0)}catch{throw new RangeError("indeterminate span")}return _}decode(l,b=0){t(l);const _=this.makeDestinationObject();for(const L of this.fields)if(L.property!==void 0&&(_[L.property]=L.decode(l,b)),b+=L.getSpan(l,b),this.decodePrefixes&&l.length===b)break;return _}encode(l,b,_=0){const L=_;let j=0,rt=0;for(const ct of this.fields){let At=ct.span;if(rt=0<At?At:0,ct.property!==void 0){const gt=l[ct.property];gt!==void 0&&(rt=ct.encode(gt,b,_),0>At&&(At=ct.getSpan(b,_)))}j=_,_+=At}return j+rt-L}fromArray(l){const b=this.makeDestinationObject();for(const _ of this.fields)_.property!==void 0&&0<l.length&&(b[_.property]=l.shift());return b}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const b of this.fields)if(b.property===l)return b}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let b=0;for(const _ of this.fields){if(_.property===l)return b;0>_.span?b=-1:0<=b&&(b+=_.span)}}}H.Structure=X;class q{constructor(l){this.property=l}decode(l,b){throw new Error("UnionDiscriminator is abstract")}encode(l,b,_){throw new Error("UnionDiscriminator is abstract")}}H.UnionDiscriminator=q;class V extends q{constructor(l,b){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(b||l.property||"variant"),this.layout=l}decode(l,b){return this.layout.decode(l,b)}encode(l,b,_){return this.layout.encode(l,b,_)}}H.UnionLayoutDiscriminator=V;class Q extends r{constructor(l,b,_){let L;if(l instanceof g||l instanceof w)L=new V(new f(l));else if(l instanceof o&&l.isCount())L=new V(l);else if(l instanceof q)L=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(b===void 0&&(b=null),!(b===null||b instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(b!==null){if(0>b.span)throw new Error("defaultLayout must have constant span");b.property===void 0&&(b=b.replicate("content"))}let j=-1;b&&(j=b.span,0<=j&&(l instanceof g||l instanceof w)&&(j+=L.layout.span)),super(j,_),this.discriminator=L,this.usesPrefixDiscriminator=l instanceof g||l instanceof w,this.defaultLayout=b,this.registry={};let rt=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(ct){return rt(ct)},this.configGetSourceVariant=function(ct){rt=ct.bind(this)}}getSpan(l,b=0){if(0<=this.span)return this.span;const _=this.getVariant(l,b);if(!_)throw new Error("unable to determine span for unrecognized variant");return _.getSpan(l,b)}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 b=this.registry[l[this.discriminator.property]];if(b&&(!b.layout||b.property&&Object.prototype.hasOwnProperty.call(l,b.property)))return b}else for(const b in this.registry){const _=this.registry[b];if(_.property&&Object.prototype.hasOwnProperty.call(l,_.property))return _}throw new Error("unable to infer src variant")}decode(l,b=0){let _;const L=this.discriminator,j=L.decode(l,b),rt=this.registry[j];if(rt===void 0){const ct=this.defaultLayout;let At=0;this.usesPrefixDiscriminator&&(At=L.layout.span),_=this.makeDestinationObject(),_[L.property]=j,_[ct.property]=ct.decode(l,b+At)}else _=rt.decode(l,b);return _}encode(l,b,_=0){const L=this.getSourceVariant(l);if(L===void 0){const j=this.discriminator,rt=this.defaultLayout;let ct=0;return this.usesPrefixDiscriminator&&(ct=j.layout.span),j.encode(l[j.property],b,_),ct+rt.encode(l[rt.property],b,_+ct)}return L.encode(l,b,_)}addVariant(l,b,_){const L=new x(this,l,b,_);return this.registry[l]=L,L}getVariant(l,b=0){let _;return l instanceof Uint8Array?_=this.discriminator.decode(l,b):_=l,this.registry[_]}}H.Union=Q;class x extends r{constructor(l,b,_,L){if(!(l instanceof Q))throw new TypeError("union must be a Union");if(!Number.isInteger(b)||0>b)throw new TypeError("variant must be a (non-negative) integer");if(typeof _=="string"&&L===void 0&&(L=_,_=null),_){if(!(_ instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=_.span&&_.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof L!="string")throw new TypeError("variant must have a String property")}let j=l.span;0>l.span&&(j=_?_.span:0,0<=j&&l.usesPrefixDiscriminator&&(j+=l.discriminator.layout.span)),super(j,L),this.union=l,this.variant=b,this.layout=_||null}getSpan(l,b=0){if(0<=this.span)return this.span;let _=0;this.union.usesPrefixDiscriminator&&(_=this.union.discriminator.layout.span);let L=0;return this.layout&&(L=this.layout.getSpan(l,b+_)),_+L}decode(l,b=0){const _=this.makeDestinationObject();if(this!==this.union.getVariant(l,b))throw new Error("variant mismatch");let L=0;return this.union.usesPrefixDiscriminator&&(L=this.union.discriminator.layout.span),this.layout?_[this.property]=this.layout.decode(l,b+L):this.property?_[this.property]=!0:this.union.usesPrefixDiscriminator&&(_[this.union.discriminator.property]=this.variant),_}encode(l,b,_=0){let L=0;if(this.union.usesPrefixDiscriminator&&(L=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,b,_);let j=L;if(this.layout&&(this.layout.encode(l[this.property],b,_+L),j+=this.layout.getSpan(b,_+L),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 a(c){return 0>c&&(c+=4294967296),c}class p extends r{constructor(l,b,_){if(!(l instanceof g||l instanceof w))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof b=="string"&&_===void 0&&(_=b,b=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,_),this.word=l,this.msb=!!b,this.fields=[];let L=0;this._packedSetValue=function(j){return L=a(j),this},this._packedGetValue=function(){return L}}decode(l,b=0){const _=this.makeDestinationObject(),L=this.word.decode(l,b);this._packedSetValue(L);for(const j of this.fields)j.property!==void 0&&(_[j.property]=j.decode(l));return _}encode(l,b,_=0){const L=this.word.decode(b,_);this._packedSetValue(L);for(const j of this.fields)if(j.property!==void 0){const rt=l[j.property];rt!==void 0&&j.encode(rt)}return this.word.encode(this._packedGetValue(),b,_)}addField(l,b){const _=new y(this,l,b);return this.fields.push(_),_}addBoolean(l){const b=new E(this,l);return this.fields.push(b),b}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const b of this.fields)if(b.property===l)return b}}H.BitStructure=p;class y{constructor(l,b,_){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(b)||0>=b)throw new TypeError("bits must be positive integer");const L=8*l.span,j=l.fields.reduce((rt,ct)=>rt+ct.bits,0);if(b+j>L)throw new Error("bits too long for span remainder ("+(L-j)+" of "+L+" remain)");this.container=l,this.bits=b,this.valueMask=(1<<b)-1,b===32&&(this.valueMask=4294967295),this.start=j,this.container.msb&&(this.start=L-j-b),this.wordMask=a(this.valueMask<<this.start),this.property=_}decode(l,b){const _=this.container._packedGetValue();return a(_&this.wordMask)>>>this.start}encode(l){if(typeof l!="number"||!Number.isInteger(l)||l!==a(l&this.valueMask))throw new TypeError(s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const b=this.container._packedGetValue(),_=a(l<<this.start);this.container._packedSetValue(a(b&~this.wordMask)|_)}}H.BitField=y;class E extends y{constructor(l,b){super(l,1,b)}decode(l,b){return!!super.decode(l,b)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}H.Boolean=E;class S extends r{constructor(l,b){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 _=-1;l instanceof o||(_=l),super(_,b),this.length=l}getSpan(l,b){let _=this.span;return 0>_&&(_=this.length.decode(l,b)),_}decode(l,b=0){let _=this.span;return 0>_&&(_=this.length.decode(l,b)),e(l).slice(b,b+_)}encode(l,b,_){let L=this.length;if(this.length instanceof o&&(L=l.length),!(l instanceof Uint8Array&&L===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+L+") Uint8Array as src");if(_+L>b.length)throw new RangeError("encoding overruns Uint8Array");const j=e(l);return e(b).write(j.toString("hex"),_,L,"hex"),this.length instanceof o&&this.length.encode(L,b,_),L}}H.Blob=S;class I extends r{constructor(l){super(-1,l)}getSpan(l,b=0){t(l);let _=b;for(;_<l.length&&l[_]!==0;)_+=1;return 1+_-b}decode(l,b=0){const _=this.getSpan(l,b);return e(l).slice(b,b+_-1).toString("utf-8")}encode(l,b,_=0){typeof l!="string"&&(l=String(l));const L=n.Buffer.from(l,"utf8"),j=L.length;if(_+j>b.length)throw new RangeError("encoding overruns Buffer");const rt=e(b);return L.copy(rt,_),rt[_+j]=0,j+1}}H.CString=I;class O extends r{constructor(l,b){if(typeof l=="string"&&b===void 0&&(b=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,b),this.maxSpan=l}getSpan(l,b=0){return t(l),l.length-b}decode(l,b=0){const _=this.getSpan(l,b);if(0<=this.maxSpan&&this.maxSpan<_)throw new RangeError("text length exceeds maxSpan");return e(l).slice(b,b+_).toString("utf-8")}encode(l,b,_=0){typeof l!="string"&&(l=String(l));const L=n.Buffer.from(l,"utf8"),j=L.length;if(0<=this.maxSpan&&this.maxSpan<j)throw new RangeError("text length exceeds maxSpan");if(_+j>b.length)throw new RangeError("encoding overruns Buffer");return L.copy(e(b),_),j}}H.UTF8=O;class v extends r{constructor(l,b){super(0,b),this.value=l}decode(l,b){return this.value}encode(l,b,_){return 0}}return H.Constant=v,H.greedy=(c,l)=>new u(c,l),H.offset=(c,l,b)=>new f(c,l,b),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 U(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 W(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 D(c),H.f32=c=>new J(c),H.f32be=c=>new $(c),H.f64=c=>new F(c),H.f64be=c=>new Y(c),H.struct=(c,l,b)=>new X(c,l,b),H.bits=(c,l,b)=>new p(c,l,b),H.seq=(c,l,b)=>new Z(c,l,b),H.union=(c,l,b)=>new Q(c,l,b),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 O(c,l),H.constant=(c,l)=>new v(c,l),H}var P=ru(),lr={},io;function nu(){if(io)return lr;io=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),u=Buffer.from(o.padStart(i*2,"0").slice(0,i*2),"hex");return u.reverse(),u}}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 si=nu();class iu extends TypeError{constructor(t,e){let r;const{message:s,explanation:i,...o}=t,{path:u}=t,f=u.length===0?s:`At path: ${u.join(".")} -- ${s}`;super(i??f),i!=null&&(this.cause=f),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}}function su(n){return Kr(n)&&typeof n[Symbol.iterator]=="function"}function Kr(n){return typeof n=="object"&&n!=null}function pn(n){return Kr(n)&&!Array.isArray(n)}function Pe(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function ou(n){const{done:t,value:e}=n.next();return t?void 0:e}function au(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:u,message:f=`Expected a value of type \`${o}\`${u?` with refinement \`${u}\``:""}, but received: \`${Pe(r)}\``}=n;return{value:r,type:o,refinement:u,key:s[s.length-1],path:s,branch:i,...n,message:f}}function*so(n,t,e,r){su(n)||(n=[n]);for(const s of n){const i=au(s,t,e,r);i&&(yield i)}}function*oi(n,t,e={}){const{path:r=[],branch:s=[n],coerce:i=!1,mask:o=!1}=e,u={path:r,branch:s,mask:o};i&&(n=t.coercer(n,u));let f="valid";for(const g of t.validator(n,u))g.explanation=e.message,f="not_valid",yield[g,void 0];for(let[g,w,k]of t.entries(n,u)){const M=oi(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]?(f=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):Kr(n)&&(w!==void 0||g in n)&&(n[g]=w))}if(f!=="not_valid")for(const g of t.refiner(n,u))g.explanation=e.message,f="not_refined",yield[g,void 0];f==="valid"&&(yield[void 0,n])}let Ue=class{constructor(t){const{type:e,schema:r,validator:s,refiner:i,coercer:o=f=>f,entries:u=function*(){}}=t;this.type=e,this.schema=r,this.entries=u,this.coercer=o,s?this.validator=(f,g)=>{const w=s(f,g);return so(w,g,this,f)}:this.validator=()=>[],i?this.refiner=(f,g)=>{const w=i(f,g);return so(w,g,this,f)}:this.refiner=()=>[]}assert(t,e){return oo(t,this,e)}create(t,e){return st(t,this,e)}is(t){return ao(t,this)}mask(t,e){return cu(t,this,e)}validate(t,e={}){return Wr(t,this,e)}};function oo(n,t,e){const r=Wr(n,t,{message:e});if(r[0])throw r[0]}function st(n,t,e){const r=Wr(n,t,{coerce:!0,message:e});if(r[0])throw r[0];return r[1]}function cu(n,t,e){const r=Wr(n,t,{coerce:!0,mask:!0,message:e});if(r[0])throw r[0];return r[1]}function ao(n,t){return!Wr(n,t)[0]}function Wr(n,t,e={}){const r=oi(n,t,e),s=ou(r);return s[0]?[new iu(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function hr(n,t){return new Ue({type:n,schema:null,validator:t})}function uu(){return hr("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 hr("boolean",n=>typeof n=="boolean")}function ai(n){return hr("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 lu(){return hr("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 K(){return hr("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${Pe(n)}`)}function lt(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 co(n,t){return new Ue({type:"record",schema:null,*entries(e){if(Kr(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 nt(){return hr("string",n=>typeof n=="string"||`Expected a string, but received: ${Pe(n)}`)}function ci(n){const t=lu();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(Kr(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]=oi(e,i,r),[u]=o;if(u[0])for(const[f]of o)f&&s.push(f);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Pe(e)}`,...s]}})}function Br(){return hr("unknown",()=>!0)}function $r(n,t,e){return new Ue({...n,coercer:(r,s)=>ao(r,t)?n.coercer(e(r,s),s):n.coercer(r,s)})}var gn,hu=new Uint8Array(16);function uo(){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(hu)}const fu=/^(?:[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"&&fu.test(n)}for(var we=[],ui=0;ui<256;++ui)we.push((ui+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 lo,li,hi=0,fi=0;function du(n,t,e){var r=t&&e||0,s=t||new Array(16);n=n||{};var i=n.node||lo,o=n.clockseq!==void 0?n.clockseq:li;if(i==null||o==null){var u=n.random||(n.rng||uo)();i==null&&(i=lo=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),o==null&&(o=li=(u[6]<<8|u[7])&16383)}var f=n.msecs!==void 0?n.msecs:Date.now(),g=n.nsecs!==void 0?n.nsecs:fi+1,w=f-hi+(g-fi)/1e4;if(w<0&&n.clockseq===void 0&&(o=o+1&16383),(w<0||f>hi)&&n.nsecs===void 0&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");hi=f,fi=g,li=o,f+=122192928e5;var k=((f&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=f/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 ho(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 pu(n){n=unescape(encodeURIComponent(n));for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}var gu="6ba7b810-9dad-11d1-80b4-00c04fd430c8",yu="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function fo(n,t,e){function r(s,i,o,u){if(typeof s=="string"&&(s=pu(s)),typeof i=="string"&&(i=ho(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var f=new Uint8Array(16+s.length);if(f.set(i),f.set(s,i.length),f=e(f),f[6]=f[6]&15|t,f[8]=f[8]&63|128,o){u=u||0;for(var g=0;g<16;++g)o[u+g]=f[g];return o}return mn(f)}try{r.name=n}catch{}return r.DNS=gu,r.URL=yu,r}function mu(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 wu(bu(ku(n),n.length*8))}function wu(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 po(n){return(n+64>>>9<<4)+14+1}function bu(n,t){n[t>>5]|=128<<t%32,n[po(t)-1]=t;for(var e=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<n.length;o+=16){var u=e,f=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,u),r=tr(r,f),s=tr(s,g),i=tr(i,w)}return[e,r,s,i]}function ku(n){if(n.length===0)return[];for(var t=n.length*8,e=new Uint32Array(po(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 vu(n,t){return n<<t|n>>>32-t}function wn(n,t,e,r,s,i){return tr(vu(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 Su=fo("v3",48,mu);function xu(n,t,e){n=n||{};var r=n.random||(n.rng||uo)();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 Iu(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 di(n,t){return n<<t|n>>>32-t}function Eu(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),u=new Array(o),f=0;f<o;++f){for(var g=new Uint32Array(16),w=0;w<16;++w)g[w]=n[f*64+w*4]<<24|n[f*64+w*4+1]<<16|n[f*64+w*4+2]<<8|n[f*64+w*4+3];u[f]=g}u[o-1][14]=(n.length-1)*8/Math.pow(2,32),u[o-1][14]=Math.floor(u[o-1][14]),u[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]=u[k][R];for(var C=16;C<80;++C)M[C]=di(M[C-3]^M[C-8]^M[C-14]^M[C-16],1);for(var B=e[0],T=e[1],U=e[2],W=e[3],D=e[4],J=0;J<80;++J){var $=Math.floor(J/20),F=di(B,5)+Iu($,T,U,W)+D+t[$]+M[J]>>>0;D=W,W=U,U=di(T,30)>>>0,T=B,B=F}e[0]=e[0]+B>>>0,e[1]=e[1]+T>>>0,e[2]=e[2]+U>>>0,e[3]=e[3]+W>>>0,e[4]=e[4]+D>>>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 Au=fo("v5",80,Eu);const Bu="00000000-0000-0000-0000-000000000000";function _u(n){if(!yn(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const go=Nn(Object.freeze(Object.defineProperty({__proto__:null,NIL:Bu,parse:ho,stringify:mn,v1:du,v3:Su,v4:xu,v5:Au,validate:yn,version:_u},Symbol.toStringTag,{value:"Module"})));var pi,yo;function Ru(){if(yo)return pi;yo=1;const n=go.v4;return pi=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 u={method:e};if(o===2&&(u.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");u.params=r}if(typeof s>"u"){const f=typeof i.generator=="function"?i.generator:function(){return n()};u.id=f(u,i)}else o===2&&s===null?i.notificationIdNull&&(u.id=null):u.id=s;return u},pi}var gi,mo;function Tu(){if(mo)return gi;mo=1;const n=go.v4,t=Ru(),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 gi=e,e.prototype.request=function(r,s,i,o){const u=this;let f=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,f=r;else{typeof i=="function"&&(o=i,i=void 0);const M=typeof o=="function";try{f=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 f}let k;try{k=JSON.stringify(f,this.options.replacer)}catch(M){return o(M)}return this.callServer(k,function(M,R){u._parseResponse(M,R,o)}),f},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(u){return i(u)}if(i.length===3)if(Array.isArray(o)){const u=function(g){return typeof g.error<"u"},f=function(g){return!u(g)};return i(null,o.filter(u),o.filter(f))}else return i(null,o.error,o.result);i(null,o)},gi}var Mu=Tu();const Pu=Nr(Mu);var yi={exports:{}},wo;function Lu(){return wo||(wo=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(f,g,w){this.fn=f,this.context=g,this.once=w||!1}function i(f,g,w,k,M){if(typeof w!="function")throw new TypeError("The listener must be a function");var R=new s(w,k||f,M),C=e?e+g:g;return f._events[C]?f._events[C].fn?f._events[C]=[f._events[C],R]:f._events[C].push(R):(f._events[C]=R,f._eventsCount++),f}function o(f,g){--f._eventsCount===0?f._events=new r:delete f._events[g]}function u(){this._events=new r,this._eventsCount=0}u.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},u.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},u.prototype.listenerCount=function(g){var w=e?e+g:g,k=this._events[w];return k?k.fn?1:k.length:0},u.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],U=arguments.length,W,D;if(T.fn){switch(T.once&&this.removeListener(g,T.fn,void 0,!0),U){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(D=1,W=new Array(U-1);D<U;D++)W[D-1]=arguments[D];T.fn.apply(T.context,W)}else{var J=T.length,$;for(D=0;D<J;D++)switch(T[D].once&&this.removeListener(g,T[D].fn,void 0,!0),U){case 1:T[D].fn.call(T[D].context);break;case 2:T[D].fn.call(T[D].context,w);break;case 3:T[D].fn.call(T[D].context,w,k);break;case 4:T[D].fn.call(T[D].context,w,k,M);break;default:if(!W)for($=1,W=new Array(U-1);$<U;$++)W[$-1]=arguments[$];T[D].fn.apply(T[D].context,W)}}return!0},u.prototype.on=function(g,w,k){return i(this,g,w,k,!1)},u.prototype.once=function(g,w,k){return i(this,g,w,k,!0)},u.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=[],U=C.length;B<U;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},u.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},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,n.exports=u}(yi)),yi.exports}var Cu=Lu();const bo=Nr(Cu);var Ou=class extends bo{constructor(t,e,r){super();fe(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 Uu(n,t){return new Ou(n,t)}var Nu=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},Fu=class extends bo{constructor(t,e="ws://localhost:8080",{autoconnect:r=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...u}={},f,g){super();fe(this,"address");fe(this,"rpc_id");fe(this,"queue");fe(this,"options");fe(this,"autoconnect");fe(this,"ready");fe(this,"reconnect");fe(this,"reconnect_timer_id");fe(this,"reconnect_interval");fe(this,"max_reconnects");fe(this,"rest_options");fe(this,"current_reconnects");fe(this,"generate_request_id");fe(this,"socket");fe(this,"webSocketFactory");fe(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=u,this.current_reconnects=0,this.generate_request_id=f||(()=>++this.rpc_id),g?this.dataPack=g:this.dataPack=new Nu,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 u=this.generate_request_id(t,e),f={jsonrpc:"2.0",method:t,params:e||void 0,id:u};this.socket.send(this.dataPack.encode(f),s,g=>{if(g)return o(g);this.queue[u]={promise:[i,o]},r&&(this.queue[u].timeout=setTimeout(()=>{delete this.queue[u],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=ht.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 ko=[],vo=[],So=[],zu=BigInt(0),Hr=BigInt(1),Du=BigInt(2),qu=BigInt(7),Ku=BigInt(256),Wu=BigInt(113);for(let n=0,t=Hr,e=1,r=0;n<24;n++){[e,r]=[r,(2*e+3*r)%5],ko.push(2*(5*r+e)),vo.push((n+1)*(n+2)/2%64);let s=zu;for(let i=0;i<7;i++)t=(t<<Hr^(t>>qu)*Wu)%Ku,t&Du&&(s^=Hr<<(Hr<<BigInt(i))-Hr);So.push(s)}const[$u,Hu]=Ts(So,!0),xo=(n,t,e)=>e>32?Ls(n,t,e):Ms(n,t,e),Io=(n,t,e)=>e>32?Cs(n,t,e):Ps(n,t,e);function Vu(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 u=(o+8)%10,f=(o+2)%10,g=e[f],w=e[f+1],k=xo(g,w,1)^e[u],M=Io(g,w,1)^e[u+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 u=vo[o],f=xo(s,i,u),g=Io(s,i,u),w=ko[o];s=n[w],i=n[w+1],n[w]=f,n[w+1]=g}for(let o=0;o<50;o+=10){for(let u=0;u<10;u++)e[u]=n[o+u];for(let u=0;u<10;u++)n[o+u]^=~e[(u+2)%10]&e[(u+4)%10]}n[0]^=$u[r],n[1]^=Hu[r]}e.fill(0)}class mi extends Kn{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=Ka(this.state)}keccak(){Es||As(this.state32),Vu(this.state32,this.rounds),Es||As(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 u=0;u<o;u++)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)!==0&&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(Is(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 mi(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 Eo=((n,t,e)=>Wn(()=>new mi(t,n,e)))(1,136,256/8);class Ao extends Kn{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,qa(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:u}=this;return t=t,t.finished=s,t.destroyed=i,t.blockLen=o,t.outputLen=u,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Bo=(n,t,e)=>new Ao(n,t).update(e).digest();Bo.create=(n,t)=>new Ao(n,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ju(n){const t=Jn(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:Gu,hexToBytes:Zu}=wc,fr={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(n){const{Err:t}=fr;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:Gu(r),l:n.subarray(e+2)}},toSig(n){const{Err:t}=fr,e=typeof n=="string"?Zu(n):n;Dr(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}=fr._parseInt(e.subarray(2)),{d:o,l:u}=fr._parseInt(i);if(u.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,u=e(i),f=e(o);return`30${e(o+i+4)}02${f}${s}02${u}${r}`}},je=BigInt(0),Te=BigInt(1);BigInt(2);const _o=BigInt(3);BigInt(4);function Yu(n){const t=ju(n),{Fp:e}=t,r=t.toBytes||((C,B,T)=>{const U=B.toAffine();return cr(Uint8Array.from([4]),e.toBytes(U.x),e.toBytes(U.y))}),s=t.fromBytes||(C=>{const B=C.subarray(1),T=e.fromBytes(B.subarray(0,e.BYTES)),U=e.fromBytes(B.subarray(e.BYTES,2*e.BYTES));return{x:T,y:U}});function i(C){const{a:B,b:T}=t,U=e.sqr(C),W=e.mul(U,C);return e.add(e.add(W,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 u(C){if(!o(C))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function f(C){const{allowedPrivateKeyLengths:B,nByteLength:T,wrapPrivateKey:U,n:W}=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 D;try{D=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 U&&(D=Kt(D,W)),u(D),D}const g=new Map;function w(C){if(!(C instanceof k))throw new Error("ProjectivePoint expected")}class k{constructor(B,T,U){if(this.px=B,this.py=T,this.pz=U,B==null||!e.isValid(B))throw new Error("x required");if(T==null||!e.isValid(T))throw new Error("y required");if(U==null||!e.isValid(U))throw new Error("z required")}static fromAffine(B){const{x:T,y:U}=B||{};if(!B||!e.isValid(T)||!e.isValid(U))throw new Error("invalid affine point");if(B instanceof k)throw new Error("projective point not allowed");const W=D=>e.eql(D,e.ZERO);return W(T)&&W(U)?k.ZERO:new k(T,U,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(B){const T=e.invertBatch(B.map(U=>U.pz));return B.map((U,W)=>U.toAffine(T[W])).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(f(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 U=e.sqr(T),W=i(B);if(!e.eql(U,W))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:U,pz:W}=this,{px:D,py:J,pz:$}=B,F=e.eql(e.mul(T,$),e.mul(D,W)),Y=e.eql(e.mul(U,$),e.mul(J,W));return F&&Y}negate(){return new k(this.px,e.neg(this.py),this.pz)}double(){const{a:B,b:T}=t,U=e.mul(T,_o),{px:W,py:D,pz:J}=this;let $=e.ZERO,F=e.ZERO,Y=e.ZERO,Z=e.mul(W,W),X=e.mul(D,D),q=e.mul(J,J),V=e.mul(W,D);return V=e.add(V,V),Y=e.mul(W,J),Y=e.add(Y,Y),$=e.mul(B,Y),F=e.mul(U,q),F=e.add($,F),$=e.sub(X,F),F=e.add(X,F),F=e.mul($,F),$=e.mul(V,$),Y=e.mul(U,Y),q=e.mul(B,q),V=e.sub(Z,q),V=e.mul(B,V),V=e.add(V,Y),Y=e.add(Z,Z),Z=e.add(Y,Z),Z=e.add(Z,q),Z=e.mul(Z,V),F=e.add(F,Z),q=e.mul(D,J),q=e.add(q,q),Z=e.mul(q,V),$=e.sub($,Z),Y=e.mul(q,X),Y=e.add(Y,Y),Y=e.add(Y,Y),new k($,F,Y)}add(B){w(B);const{px:T,py:U,pz:W}=this,{px:D,py:J,pz:$}=B;let F=e.ZERO,Y=e.ZERO,Z=e.ZERO;const X=t.a,q=e.mul(t.b,_o);let V=e.mul(T,D),Q=e.mul(U,J),x=e.mul(W,$),a=e.add(T,U),p=e.add(D,J);a=e.mul(a,p),p=e.add(V,Q),a=e.sub(a,p),p=e.add(T,W);let y=e.add(D,$);return p=e.mul(p,y),y=e.add(V,x),p=e.sub(p,y),y=e.add(U,W),F=e.add(J,$),y=e.mul(y,F),F=e.add(Q,x),y=e.sub(y,F),Z=e.mul(X,p),F=e.mul(q,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(X,x),p=e.mul(q,p),Q=e.add(Q,x),x=e.sub(V,x),x=e.mul(X,x),p=e.add(p,x),V=e.mul(Q,p),Y=e.add(Y,V),V=e.mul(y,p),F=e.mul(a,F),F=e.sub(F,V),V=e.mul(a,Q),Z=e.mul(y,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 U=e.invertBatch(T.map(W=>W.pz));return T.map((W,D)=>W.toAffine(U[D])).map(k.fromAffine)})}multiplyUnsafe(B){const T=k.ZERO;if(B===je)return T;if(u(B),B===Te)return this;const{endo:U}=t;if(!U)return R.unsafeLadder(this,B);let{k1neg:W,k1:D,k2neg:J,k2:$}=U.splitScalar(B),F=T,Y=T,Z=this;for(;D>je||$>je;)D&Te&&(F=F.add(Z)),$&Te&&(Y=Y.add(Z)),Z=Z.double(),D>>=Te,$>>=Te;return W&&(F=F.negate()),J&&(Y=Y.negate()),Y=new k(e.mul(Y.px,U.beta),Y.py,Y.pz),F.add(Y)}multiply(B){u(B);let T=B,U,W;const{endo:D}=t;if(D){const{k1neg:J,k1:$,k2neg:F,k2:Y}=D.splitScalar(T);let{p:Z,f:X}=this.wNAF($),{p:q,f:V}=this.wNAF(Y);Z=R.constTimeNegate(J,Z),q=R.constTimeNegate(F,q),q=new k(e.mul(q.px,D.beta),q.py,q.pz),U=Z.add(q),W=X.add(V)}else{const{p:J,f:$}=this.wNAF(T);U=J,W=$}return k.normalizeZ([U,W])[0]}multiplyAndAddUnsafe(B,T,U){const W=k.BASE,D=($,F)=>F===je||F===Te||!$.equals(W)?$.multiplyUnsafe(F):$.multiply(F),J=D(this,T).add(D(B,U));return J.is0()?void 0:J}toAffine(B){const{px:T,py:U,pz:W}=this,D=this.is0();B==null&&(B=D?e.ONE:e.inv(W));const J=e.mul(T,B),$=e.mul(U,B),F=e.mul(W,B);if(D)return{x:e.ZERO,y:e.ZERO};if(!e.eql(F,e.ONE))throw new Error("invZ was invalid");return{x:J,y:$}}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=Vs(k,t.endo?Math.ceil(M/2):M);return{CURVE:t,ProjectivePoint:k,normPrivateKeyToScalar:f,weierstrassEquation:i,isWithinCurveOrder:o}}function Ju(n){const t=Jn(n);return Ir(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Xu(n){const t=Ju(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 u(p){return Kt(p,r)}function f(p){return Zn(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:w,weierstrassEquation:k,isWithinCurveOrder:M}=Yu({...t,toBytes(p,y,E){const S=y.toAffine(),I=e.toBytes(S.x),O=cr;return E?O(Uint8Array.from([y.hasEvenY()?2:3]),I):O(Uint8Array.from([4]),I,e.toBytes(S.y))},fromBytes(p){const y=p.length,E=p[0],S=p.subarray(1);if(y===s&&(E===2||E===3)){const I=ar(S);if(!o(I))throw new Error("Point is not on curve");const O=k(I);let v;try{v=e.sqrt(O)}catch(b){const _=b instanceof Error?": "+b.message:"";throw new Error("Point is not on curve"+_)}const c=(v&Te)===Te;return(E&1)===1!==c&&(v=e.neg(v)),{x:I,y:v}}else if(y===i&&E===4){const I=e.fromBytes(S.subarray(0,e.BYTES)),O=e.fromBytes(S.subarray(e.BYTES,2*e.BYTES));return{x:I,y:O}}else throw new Error(`Point of length ${y} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),R=p=>or(xr(p,t.nByteLength));function C(p){const y=r>>Te;return p>y}function B(p){return C(p)?u(-p):p}const T=(p,y,E)=>ar(p.slice(y,E));class U{constructor(y,E,S){this.r=y,this.s=E,this.recovery=S,this.assertValidity()}static fromCompact(y){const E=t.nByteLength;return y=de("compactSignature",y,E*2),new U(T(y,0,E),T(y,E,2*E))}static fromDER(y){const{r:E,s:S}=fr.toSig(de("DER",y));return new U(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(y){return new U(this.r,this.s,y)}recoverPublicKey(y){const{r:E,s:S,recovery:I}=this,O=Y(de("msgHash",y));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)===0?"02":"03",l=g.fromHex(c+R(v)),b=f(v),_=u(-O*b),L=u(S*b),j=g.BASE.multiplyAndAddUnsafe(l,_,L);if(!j)throw new Error("point at infinify");return j.assertValidity(),j}hasHighS(){return C(this.s)}normalizeS(){return this.hasHighS()?new U(this.r,u(-this.s),this.recovery):this}toDERRawBytes(){return vr(this.toDERHex())}toDERHex(){return fr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return vr(this.toCompactHex())}toCompactHex(){return R(this.r)+R(this.s)}}const W={isValidPrivateKey(p){try{return w(p),!0}catch{return!1}},normPrivateKeyToScalar:w,randomPrivateKey:()=>{const p=Hs(t.n);return _c(t.randomBytes(p),t.n)},precompute(p=8,y=g.BASE){return y._setWindowSize(p),y.multiply(BigInt(3)),y}};function D(p,y=!0){return g.fromPrivateKey(p).toRawBytes(y)}function J(p){const y=sr(p),E=typeof p=="string",S=(y||E)&&p.length;return y?S===s||S===i:E?S===2*s||S===2*i:p instanceof g}function $(p,y,E=!0){if(J(p))throw new Error("first arg must be private key");if(!J(y))throw new Error("second arg must be public key");return g.fromHex(y).multiply(w(p)).toRawBytes(E)}const F=t.bits2int||function(p){const y=ar(p),E=p.length*8-t.nBitLength;return E>0?y>>BigInt(E):y},Y=t.bits2int_modN||function(p){return u(F(p))},Z=Vn(t.nBitLength);function X(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 q(p,y,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:O,prehash:v,extraEntropy:c}=E;O==null&&(O=!0),p=de("msgHash",p),v&&(p=de("prehashed msgHash",S(p)));const l=Y(p),b=w(y),_=[X(b),X(l)];if(c!=null&&c!==!1){const ct=c===!0?I(e.BYTES):c;_.push(de("extraEntropy",ct))}const L=cr(..._),j=l;function rt(ct){const At=F(ct);if(!M(At))return;const gt=f(At),vt=g.BASE.multiply(At).toAffine(),_t=u(vt.x);if(_t===je)return;const St=u(gt*u(j+_t*b));if(St===je)return;let Tt=(vt.x===_t?0:2)|Number(vt.y&Te),$e=St;return O&&C(St)&&($e=B(St),Tt^=1),new U(_t,$e,Tt)}return{seed:L,k2sig:rt}}const V={lowS:t.lowS,prehash:!1},Q={lowS:t.lowS,prehash:!1};function x(p,y,E=V){const{seed:S,k2sig:I}=q(p,y,E),O=t;return zs(O.hash.outputLen,O.nByteLength,O.hmac)(S,I)}g.BASE._setWindowSize(8);function a(p,y,E,S=Q){var vt;const I=p;if(y=de("msgHash",y),E=de("publicKey",E),"strict"in S)throw new Error("options.strict was renamed to lowS");const{lowS:O,prehash:v}=S;let c,l;try{if(typeof I=="string"||sr(I))try{c=U.fromDER(I)}catch(_t){if(!(_t instanceof fr.Err))throw _t;c=U.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:_t,s:St}=I;c=new U(_t,St)}else throw new Error("PARSE");l=g.fromHex(E)}catch(_t){if(_t.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(O&&c.hasHighS())return!1;v&&(y=t.hash(y));const{r:b,s:_}=c,L=Y(y),j=f(_),rt=u(L*j),ct=u(b*j),At=(vt=g.BASE.multiplyAndAddUnsafe(l,rt,ct))==null?void 0:vt.toAffine();return At?u(At.x)===b:!1}return{CURVE:t,getPublicKey:D,getSharedSecret:$,sign:x,verify:a,ProjectivePoint:g,Signature:U,utils:W}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Qu(n){return{hash:n,hmac:(t,...e)=>Bo(n,t,Ha(...e)),randomBytes:Bs}}function tl(n,t){const e=r=>Xu({...n,...Qu(r)});return Object.freeze({...e(t),create:e})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ro=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),To=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),el=BigInt(1),wi=BigInt(2),Mo=(n,t)=>(n+t/wi)/t;function rl(n){const t=Ro,e=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),u=BigInt(44),f=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,wi,t)*g%t,C=jt(R,s,t)*R%t,B=jt(C,i,t)*C%t,T=jt(B,u,t)*B%t,U=jt(T,f,t)*T%t,W=jt(U,u,t)*B%t,D=jt(W,e,t)*w%t,J=jt(D,o,t)*C%t,$=jt(J,r,t)*g%t,F=jt($,wi,t);if(!bi.eql(bi.sqr(F),n))throw new Error("Cannot find square root");return F}const bi=Ws(Ro,void 0,void 0,{sqrt:rl}),bn=tl({a:BigInt(0),b:BigInt(7),Fp:bi,n:To,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const t=To,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-el*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,o=BigInt("0x100000000000000000000000000000000"),u=Mo(i*n,t),f=Mo(-r*n,t);let g=Kt(n-u*e-f*s,t),w=Kt(-u*r-f*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}}}},ei);BigInt(0),bn.ProjectivePoint;const nl=Er.utils.randomPrivateKey,Po=()=>{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 Lo(n){try{return Er.ExtendedPoint.fromHex(n),!0}catch{return!1}}const ki=(n,t)=>Er.sign(n,t.slice(0,32)),il=Er.verify,wt=n=>ht.Buffer.isBuffer(n)?n:n instanceof Uint8Array?ht.Buffer.from(n.buffer,n.byteOffset,n.byteLength):ht.Buffer.from(n);class vi{constructor(t){Object.assign(this,t)}encode(){return ht.Buffer.from(ii.serialize(Vr,this))}static decode(t){return ii.deserialize(Vr,this,t)}static decodeUnchecked(t){return ii.deserializeUnchecked(Vr,this,t)}}class sl extends vi{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 Co;const Oo=32,Fe=32;function ol(n){return n._bn!==void 0}let Uo=1;class it extends vi{constructor(t){if(super({}),this._bn=void 0,ol(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 Js(e)}else this._bn=new Js(t);if(this._bn.byteLength()>Fe)throw new Error("Invalid public key input")}}static unique(){const t=new it(Uo);return Uo+=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(ht.Buffer);if(t.length===Fe)return t;const e=ht.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=ht.Buffer.concat([t.toBuffer(),ht.Buffer.from(e),r.toBuffer()]),i=ei(s);return new it(i)}static createProgramAddressSync(t,e){let r=ht.Buffer.alloc(0);t.forEach(function(i){if(i.length>Oo)throw new TypeError("Max seed length exceeded");r=ht.Buffer.concat([r,wt(i)])}),r=ht.Buffer.concat([r,e.toBuffer(),ht.Buffer.from("ProgramDerivedAddress")]);const s=ei(r);if(Lo(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(ht.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 Lo(e.toBytes())}}Co=it,it.default=new Co("11111111111111111111111111111111"),Vr.set(it,{kind:"struct",fields:[["_bn","u256"]]});class al{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=wt(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=wt(nl()),this._publicKey=wt(kn(this._secretKey))}get publicKey(){return new it(this._publicKey)}get secretKey(){return ht.Buffer.concat([this._secretKey,this._publicKey],64)}}const cl=new it("BPFLoader1111111111111111111111111111111111"),er=1232,vn=127,jr=64;class Si extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Si.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class xi 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(xi.prototype,"name",{value:"TransactionExpiredTimeoutError"});class _r extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(_r.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),ul=(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,u)=>{const f={chars:ht.Buffer.from(i,"utf8")};return r(f,o,u)},s.alloc=i=>P.u32().span+P.u32().span+ht.Buffer.from(i,"utf8").length,s},ll=(n="authorized")=>P.struct([xt("staker"),xt("withdrawer")],n),hl=(n="lockup")=>P.struct([P.ns64("unixTimestamp"),P.ns64("epoch"),xt("custodian")],n),fl=(n="voteInit")=>P.struct([xt("nodePubkey"),xt("authorizedVoter"),xt("authorizedWithdrawer"),P.u8("commission")],n),dl=(n="voteAuthorizeWithSeedArgs")=>P.struct([P.u32("voteAuthorizationType"),xt("currentAuthorityDerivedKeyOwnerPubkey"),dr("currentAuthorityDerivedKeySeed"),xt("newAuthorized")],n);function No(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 No({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)===0)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 u=o.toBase58();let f=r.get(u);return f===void 0&&(f={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(u,f)),f},i=s(e);i.isSigner=!0,i.isWritable=!0;for(const o of t){s(o.programId).isInvoked=!0;for(const u of o.keys){const f=s(u.pubkey);f.isSigner||(f.isSigner=u.isSigner),f.isWritable||(f.isWritable=u.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(([,f])=>f.isSigner&&f.isWritable),r=t.filter(([,f])=>f.isSigner&&!f.isWritable),s=t.filter(([,f])=>!f.isSigner&&f.isWritable),i=t.filter(([,f])=>!f.isSigner&&!f.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[f]=e[0];Et(f===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const u=[...e.map(([f])=>new it(f)),...r.map(([f])=>new it(f)),...s.map(([f])=>new it(f)),...i.map(([f])=>new it(f))];return[o,u]}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 u=new it(i),f=t.findIndex(g=>g.equals(u));f>=0&&(Et(f<256,"Max lookup table index exceeded"),r.push(f),s.push(u),this.keyMetaMap.delete(i))}return[r,s]}}const Fo="Reached end of buffer unexpectedly";function ze(n){if(n.length===0)throw new Error(Fo);return n.shift()}function Ae(n,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>n.length:e>=n.length)throw new Error(Fo);return n.splice(...t)}class Le{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(u=>({programIdIndex:u.programIdIndex,accounts:u.accountKeyIndexes,data:ge.encode(u.data)}));return new Le({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:ht.Buffer.from(B),keyIndices:M,dataLength:ht.Buffer.from(T),data:C}});let s=[];Re(s,r.length);let i=ht.Buffer.alloc(er);ht.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 u=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")]),f={numRequiredSignatures:ht.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:ht.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:ht.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:ht.Buffer.from(e),keys:this.accountKeys.map(k=>wt(k.toBytes())),recentBlockhash:ge.decode(this.recentBlockhash)};let g=ht.Buffer.alloc(2048);const w=u.encode(f,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 u=[];for(let M=0;M<o;M++){const R=Ae(e,0,Fe);u.push(new it(ht.Buffer.from(R)))}const f=Ae(e,0,Fe),g=Ee(e);let w=[];for(let M=0;M<g;M++){const R=ze(e),C=Ee(e),B=Ae(e,0,C),T=Ee(e),U=Ae(e,0,T),W=ge.encode(ht.Buffer.from(U));w.push({programIdIndex:R,accounts:B,data:W})}const k={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:ge.encode(ht.Buffer.from(f)),accountKeys:u,instructions:w};return new Le(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,u)=>o+u.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,u]=e.getMessageComponents(),g=new Gr(u,s).compileInstructions(t.instructions);return new pr({header:o,staticAccountKeys:u,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")]),u=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},u);return u.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)},u=[],f=Ee(e);for(let C=0;C<f;C++)u.push(new it(Ae(e,0,Fe)));const g=ge.encode(Ae(e,0,Fe)),w=Ee(e),k=[];for(let C=0;C<w;C++){const B=ze(e),T=Ee(e),U=Ae(e,0,T),W=Ee(e),D=new Uint8Array(Ae(e,0,W));k.push({programIdIndex:B,accountKeyIndexes:U,data:D})}const M=Ee(e),R=[];for(let C=0;C<M;C++){const B=new it(Ae(e,0,Fe)),T=Ee(e),U=Ae(e,0,T),W=Ee(e),D=Ae(e,0,W);R.push({accountKey:B,writableIndexes:U,readonlyIndexes:D})}return new pr({header:o,staticAccountKeys:u,recentBlockhash:g,compiledInstructions:k,addressTableLookups:R})}}const Ii={deserializeMessageVersion(n){const t=n[0],e=t&vn;return e===t?"legacy":e},deserialize:n=>{const t=Ii.deserializeMessageVersion(n);if(t==="legacy")return Le.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 pl=ht.Buffer.alloc(jr).fill(0);class Pt{constructor(t){this.keys=void 0,this.programId=void 0,this.data=ht.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(U=>{i.push({...U})});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(),U=o.findIndex(W=>W.pubkey.toString()===T);U>-1?(o[U].isWritable=o[U].isWritable||B.isWritable,o[U].isSigner=o[U].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 U={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return B.pubkey.toBase58().localeCompare(T.pubkey.toBase58(),"en",U)});const u=o.findIndex(B=>B.pubkey.equals(r));if(u>-1){const[B]=o.splice(u,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(U=>U.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 f=0,g=0,w=0;const k=[],M=[];o.forEach(({pubkey:B,isSigner:T,isWritable:U})=>{T?(k.push(B.toString()),f+=1,U||(g+=1)):(M.push(B.toString()),U||(w+=1))});const R=k.concat(M),C=e.map(B=>{const{data:T,programId:U}=B;return{programIdIndex:R.indexOf(U.toString()),accounts:B.keys.map(W=>R.indexOf(W.pubkey.toString())),data:ge.encode(T)}});return C.forEach(B=>{Et(B.programIdIndex>=0),B.accounts.forEach(T=>Et(T>=0))}),new Le({header:{numRequiredSignatures:f,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=ki(r,s.secretKey);this._addSignature(s.publicKey,wt(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=ht.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):il(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(u=>u.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
|
|
8
|
-
Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(u=>u.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=ht.Buffer.alloc(s);return Et(e.length<256),ht.Buffer.from(r).copy(i,0),e.forEach(({signature:o},u)=>{o!==null&&(Et(o.length===64,"signature has invalid length"),ht.Buffer.from(o).copy(i,r.length+u*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=Ae(e,0,jr);s.push(ge.encode(ht.Buffer.from(o)))}return Bt.populate(
|
|
8
|
+
Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(u=>u.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=ht.Buffer.alloc(s);return Et(e.length<256),ht.Buffer.from(r).copy(i,0),e.forEach(({signature:o},u)=>{o!==null&&(Et(o.length===64,"signature has invalid length"),ht.Buffer.from(o).copy(i,r.length+u*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=Ae(e,0,jr);s.push(ge.encode(ht.Buffer.from(o)))}return Bt.populate(Le.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(pl)?null:ge.decode(s),publicKey:t.accountKeys[i]};r.signatures.push(o)}),t.instructions.forEach(s=>{const i=s.accounts.map(o=>{const u=t.accountKeys[o];return{pubkey:u,isSigner:r.signatures.some(f=>f.publicKey.toString()===u.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 Ei{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:u,numReadonlyUnsignedAccounts:f}=r,g=o-u;Et(g>0,"Message header is invalid");const w=t.staticAccountKeys.length-o-f;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 U of C.accountKeyIndexes){const W=k.get(U);if(W===void 0)throw new Error(`Failed to find key for account key index ${U}`);const D=U<o;let J;D?J=U<g:U<k.staticAccountKeys.length?J=U-o<w:J=U-k.staticAccountKeys.length<k.accountKeysFromLookups.writable.length,B.push({pubkey:W,isSigner:U<r.numRequiredSignatures,isWritable:J})}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:wt(C.data),keys:B}))}return new Ei({payerKey:M,instructions:R,recentBlockhash:i})}compileToLegacyMessage(){return Le.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 Ai{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(ul(),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(Ae(e,0,jr)));const i=Ii.deserialize(new Uint8Array(e));return new Ai(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]=ki(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 zo=1e3/(160/64),De=new it("SysvarC1ock11111111111111111111111111111111"),gl=new it("SysvarEpochSchedu1e111111111111111111111111"),yl=new it("Sysvar1nstructions1111111111111111111111111"),xn=new it("SysvarRecentB1ockHashes11111111111111111111"),Rr=new it("SysvarRent111111111111111111111111111111111"),ml=new it("SysvarRewards111111111111111111111111111111"),wl=new it("SysvarS1otHashes111111111111111111111111111"),bl=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 u;switch(t){case"send":u=`Transaction ${e} resulted in an error.
|
|
10
10
|
${r}. `+i+o;break;case"simulate":u=`Simulation failed.
|
|
11
11
|
Message: ${r}.
|
|
12
|
-
`+i+o;break;default:u=`Unknown action '${(f=>f)(t)}'`}super(u),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 bl={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 Bi(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:u}=t.nonceInfo,f=u.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:f,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:Uo(n,t),r=ht.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 zo=P.nu64("lamportsPerSignature"),qo=P.struct([P.u32("version"),P.u32("state"),xt("authorizedPubkey"),xt("nonce"),P.struct([zo],"feeCalculator")]),_i=qo.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=qo.decode(wt(t),0);return new En({authorizedPubkey:new it(e.authorizedPubkey),nonce:new it(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const kl=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}=kl(e),i=e;return i.decode=(o,u)=>{const f=s(o,u);return si.toBigIntLE(ht.Buffer.from(f))},i.encode=(o,u,f)=>{const g=si.toBufferLE(o,n);return r(g,u,f)},i})(8);class vl{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:wt(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:wt(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:wt(t.basePubkey.toBuffer()),seed:t.seed,programId:wt(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:wt(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:wt(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:wt(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:_i,programId:this.programId})):e.add(ye.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:_i,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:wt(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:wt(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:wt(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:wt(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 Sl=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 Bi(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")]),u=yr.chunkSize;let f=0,g=i,w=[];for(;g.length>0;){const k=g.slice(0,u),M=ht.Buffer.alloc(u+16);o.encode({instruction:0,offset:f,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(Bi(t,R,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await gr(1e3/4),f+=u,g=g.slice(u)}await Promise.all(w);{const k=P.struct([P.u32("instruction")]),M=ht.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",_=await t.sendTransaction(R,[e,r],{preflightCommitment:C}),{context:T,value:O}=await t.confirmTransaction({signature:_,lastValidBlockHeight:R.lastValidBlockHeight,blockhash:R.recentBlockhash},C);if(O.err)throw new Error(`Transaction ${_} failed (${JSON.stringify(O)})`);for(;;){try{if(await t.getSlot({commitment:C})>T.slot)break}catch{}await new Promise($=>setTimeout($,Math.round(Fo/2)))}}return!0}}yr.chunkSize=Sl;const xl=new it("BPFLoader2111111111111111111111111111111111");class Il{static getMinNumSignatures(t){return yr.getMinNumSignatures(t)}static load(t,e,r,s,i){return yr.load(t,e,r,i,s)}}function El(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ri,Do;function Al(){if(Do)return Ri;Do=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,u,f,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(u="[",o=r.length-1,i=0;i<o;i++)u+=e(r[i],!0)+",";return o>-1&&(u+=e(r[i],!0)),u+"]"}else if(k==="[object Object]"){for(f=t(r).sort(),o=f.length,u="",i=0;i<o;)g=f[i],w=e(r[g],!1),w!==void 0&&(u&&(u+=","),u+=JSON.stringify(g)+":"+w),i++;return"{"+u+"}"}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 Ri=function(r){var s=e(r,!1);if(s!==void 0)return""+s},Ri}var Bl=Al(),Ko=El(Bl);const Yr=32;function Ti(n){let t=0;for(;n>1;)n/=2,t++;return t}function _l(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=Ti(_l(t+Yr+1))-Ti(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+Ti(Yr)):this.slotsPerEpoch}}var Rl=globalThis.fetch;class Tl extends Nu{constructor(t,e,r){const s=i=>{const o=Ou(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 Ml(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 $o=56;class Mi{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=Ml(Pl,t),r=t.length-$o;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($o));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 Pl={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")])},Cl=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function Ll(n){const t=n.match(Cl);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[e,r,s,i]=t,o=n.startsWith("https:")?"wss:":"ws:",u=s==null?null:parseInt(s.slice(1),10),f=u==null?"":`:${u+1}`;return`${o}//${r}${f}${i}`}const Vt=$r(ai(it),rt(),n=>new it(n)),Ho=ci([rt(),Ht("base64")]),Pi=$r(ai(ht.Buffer),Ho,n=>ht.Buffer.from(n[0],"base64")),Vo=30*1e3;function Ol(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 jo(n){return n.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function Go(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:lt(cu())})})])}const Ul=Go(Br());function bt(n){return $r(Go(n),Ul,t=>"error"in t?t:{...t,result:st(t.result,n)})}function Gt(n){return bt(tt({context:tt({slot:K()}),value:n}))}function An(n){return tt({context:tt({slot:K()}),value:n})}function Ci(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 Nl=tt({foundation:K(),foundationTerm:K(),initial:K(),taper:K(),terminal:K()}),Fl=bt(ot(at(tt({epoch:K(),effectiveSlot:K(),amount:K(),postBalance:K(),commission:lt(at(K()))})))),zl=ot(tt({slot:K(),prioritizationFee:K()})),ql=tt({total:K(),validator:K(),foundation:K(),epoch:K()}),Dl=tt({epoch:K(),slotIndex:K(),slotsInEpoch:K(),absoluteSlot:K(),blockHeight:lt(K()),transactionCount:lt(K())}),Kl=tt({slotsPerEpoch:K(),leaderScheduleSlotOffset:K(),warmup:Ne(),firstNormalEpoch:K(),firstNormalSlot:K()}),Wl=ao(rt(),ot(K())),mr=at(Ie([tt({}),rt()])),$l=tt({err:mr}),Hl=Ht("receivedSignature"),Vl=tt({"solana-core":rt(),"feature-set":lt(K())}),jl=tt({program:rt(),programId:Vt,parsed:Br()}),Gl=tt({programId:Vt,accounts:ot(Vt),data:rt()}),Zo=Gt(tt({err:at(Ie([tt({}),rt()])),logs:at(ot(rt())),accounts:lt(at(ot(at(tt({executable:Ne(),owner:rt(),lamports:K(),data:ot(rt()),rentEpoch:lt(K())}))))),unitsConsumed:lt(K()),returnData:lt(at(tt({programId:rt(),data:ci([rt(),Ht("base64")])}))),innerInstructions:lt(at(ot(tt({index:K(),instructions:ot(Ie([jl,Gl]))}))))})),Zl=Gt(tt({byIdentity:ao(rt(),ot(K())),range:tt({firstSlot:K(),lastSlot:K()})}));function Yl(n,t,e,r,s,i){const o=e||Rl;let u;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 f;return r&&(f=async(w,k)=>{const M=await new Promise((R,C)=>{try{r(w,k,(_,T)=>R([_,T]))}catch(_){C(_)}});return await o(...M)}),new Mu(async(w,k)=>{const M={method:"POST",body:w,agent:u,headers:Object.assign({"Content-Type":"application/json"},t||{},Yh)};try{let R=5,C,_=500;for(;f?C=await f(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 ${_}ms delay...`),await gr(_),_*=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 Jl(n){return(t,e)=>new Promise((r,s)=>{n.request(t,e,(i,o)=>{if(i){s(i);return}r(o)})})}function Xl(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 Ql=bt(Nl),th=bt(ql),eh=bt(zl),rh=bt(Dl),nh=bt(Kl),ih=bt(Wl),sh=bt(K()),oh=Gt(tt({total:K(),circulating:K(),nonCirculating:K(),nonCirculatingAccounts:ot(Vt)})),Li=tt({amount:rt(),uiAmount:at(K()),decimals:K(),uiAmountString:lt(rt())}),ah=Gt(ot(tt({address:Vt,amount:rt(),uiAmount:at(K()),decimals:K(),uiAmountString:lt(rt())}))),ch=Gt(ot(tt({pubkey:Vt,account:tt({executable:Ne(),owner:Vt,lamports:K(),data:Pi,rentEpoch:K()})}))),Oi=tt({program:rt(),parsed:Br(),space:K()}),uh=Gt(ot(tt({pubkey:Vt,account:tt({executable:Ne(),owner:Vt,lamports:K(),data:Oi,rentEpoch:K()})}))),lh=Gt(ot(tt({lamports:K(),address:Vt}))),Jr=tt({executable:Ne(),owner:Vt,lamports:K(),data:Pi,rentEpoch:K()}),hh=tt({pubkey:Vt,account:Jr}),fh=$r(Ie([ai(ht.Buffer),Oi]),Ie([Ho,Oi]),n=>Array.isArray(n)?st(n,Pi):n),Ui=tt({executable:Ne(),owner:Vt,lamports:K(),data:fh,rentEpoch:K()}),dh=tt({pubkey:Vt,account:Ui}),ph=tt({state:Ie([Ht("active"),Ht("inactive"),Ht("activating"),Ht("deactivating")]),active:K(),inactive:K()}),gh=bt(ot(tt({signature:rt(),slot:K(),err:mr,memo:at(rt()),blockTime:lt(at(K()))}))),yh=bt(ot(tt({signature:rt(),slot:K(),err:mr,memo:at(rt()),blockTime:lt(at(K()))}))),mh=tt({subscription:K(),result:An(Jr)}),wh=tt({pubkey:Vt,account:Jr}),bh=tt({subscription:K(),result:An(wh)}),kh=tt({parent:K(),slot:K(),root:K()}),vh=tt({subscription:K(),result:kh}),Sh=Ie([tt({type:Ie([Ht("firstShredReceived"),Ht("completed"),Ht("optimisticConfirmation"),Ht("root")]),slot:K(),timestamp:K()}),tt({type:Ht("createdBank"),parent:K(),slot:K(),timestamp:K()}),tt({type:Ht("frozen"),slot:K(),timestamp:K(),stats:tt({numTransactionEntries:K(),numSuccessfulTransactions:K(),numFailedTransactions:K(),maxTransactionsPerEntry:K()})}),tt({type:Ht("dead"),slot:K(),timestamp:K(),err:rt()})]),xh=tt({subscription:K(),result:Sh}),Ih=tt({subscription:K(),result:An(Ie([$l,Hl]))}),Eh=tt({subscription:K(),result:K()}),Ah=tt({pubkey:rt(),gossip:at(rt()),tpu:at(rt()),rpc:at(rt()),version:at(rt())}),Yo=tt({votePubkey:rt(),nodePubkey:rt(),activatedStake:K(),epochVoteAccount:Ne(),epochCredits:ot(ci([K(),K(),K()])),commission:K(),lastVote:K(),rootSlot:at(K())}),Bh=bt(tt({current:ot(Yo),delinquent:ot(Yo)})),_h=Ie([Ht("processed"),Ht("confirmed"),Ht("finalized")]),Rh=tt({slot:K(),confirmations:at(K()),err:mr,confirmationStatus:lt(_h)}),Th=Gt(ot(at(Rh))),Mh=bt(K()),Jo=tt({accountKey:Vt,writableIndexes:ot(K()),readonlyIndexes:ot(K())}),Ni=tt({signatures:ot(rt()),message:tt({accountKeys:ot(rt()),header:tt({numRequiredSignatures:K(),numReadonlySignedAccounts:K(),numReadonlyUnsignedAccounts:K()}),instructions:ot(tt({accounts:ot(K()),data:rt(),programIdIndex:K()})),recentBlockhash:rt(),addressTableLookups:lt(ot(Jo))})}),Xo=tt({pubkey:Vt,signer:Ne(),writable:Ne(),source:lt(Ie([Ht("transaction"),Ht("lookupTable")]))}),Qo=tt({accountKeys:ot(Xo),signatures:ot(rt())}),ta=tt({parsed:Br(),program:rt(),programId:Vt}),ea=tt({accounts:ot(Vt),data:rt(),programId:Vt}),Ph=Ie([ea,ta]),Ch=Ie([tt({parsed:Br(),program:rt(),programId:rt()}),tt({accounts:ot(rt()),data:rt(),programId:rt()})]),ra=$r(Ph,Ch,n=>"accounts"in n?st(n,ea):st(n,ta)),na=tt({signatures:ot(rt()),message:tt({accountKeys:ot(Xo),instructions:ot(ra),recentBlockhash:rt(),addressTableLookups:lt(at(ot(Jo)))})}),Bn=tt({accountIndex:K(),mint:rt(),owner:lt(rt()),programId:lt(rt()),uiTokenAmount:Li}),ia=tt({writable:ot(Vt),readonly:ot(Vt)}),_n=tt({err:mr,fee:K(),innerInstructions:lt(at(ot(tt({index:K(),instructions:ot(tt({accounts:ot(K()),data:rt(),programIdIndex:K()}))})))),preBalances:ot(K()),postBalances:ot(K()),logMessages:lt(at(ot(rt()))),preTokenBalances:lt(at(ot(Bn))),postTokenBalances:lt(at(ot(Bn))),loadedAddresses:lt(ia),computeUnitsConsumed:lt(K())}),Fi=tt({err:mr,fee:K(),innerInstructions:lt(at(ot(tt({index:K(),instructions:ot(ra)})))),preBalances:ot(K()),postBalances:ot(K()),logMessages:lt(at(ot(rt()))),preTokenBalances:lt(at(ot(Bn))),postTokenBalances:lt(at(ot(Bn))),loadedAddresses:lt(ia),computeUnitsConsumed:lt(K())}),Mr=Ie([Ht(0),Ht("legacy")]),wr=tt({pubkey:rt(),lamports:K(),postBalance:at(K()),rewardType:at(rt()),commission:lt(at(K()))}),Lh=bt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:K(),transactions:ot(tt({transaction:Ni,meta:at(_n),version:lt(Mr)})),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),Oh=bt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:K(),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),Uh=bt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:K(),transactions:ot(tt({transaction:Qo,meta:at(_n),version:lt(Mr)})),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),Nh=bt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:K(),transactions:ot(tt({transaction:na,meta:at(Fi),version:lt(Mr)})),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),Fh=bt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:K(),transactions:ot(tt({transaction:Qo,meta:at(Fi),version:lt(Mr)})),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),zh=bt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:K(),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),qh=bt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:K(),transactions:ot(tt({transaction:Ni,meta:at(_n)})),rewards:lt(ot(wr)),blockTime:at(K())}))),sa=bt(at(tt({blockhash:rt(),previousBlockhash:rt(),parentSlot:K(),signatures:ot(rt()),blockTime:at(K())}))),zi=bt(at(tt({slot:K(),meta:at(_n),blockTime:lt(at(K())),transaction:Ni,version:lt(Mr)}))),Rn=bt(at(tt({slot:K(),transaction:na,meta:at(Fi),blockTime:lt(at(K())),version:lt(Mr)}))),Dh=Gt(tt({blockhash:rt(),lastValidBlockHeight:K()})),Kh=Gt(Ne()),Wh=tt({slot:K(),numTransactions:K(),numSlots:K(),samplePeriodSecs:K()}),$h=bt(ot(Wh)),Hh=Gt(at(tt({feeCalculator:tt({lamportsPerSignature:K()})}))),Vh=bt(rt()),jh=bt(rt()),Gh=tt({err:mr,logs:ot(rt()),signature:rt()}),Zh=tt({result:An(Gh),subscription:K()}),Yh={"solana-client":"js/1.0.0-maintenance"};class Jh{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 _=await this._rpcRequest("getBlockHeight",R),T=st(_,bt(K()));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,u,f;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,u=e.disableRetryOnRateLimit,f=e.httpAgent),this._rpcEndpoint=Ol(t),this._rpcWsEndpoint=r||Ll(t),this._rpcClient=Yl(t,s,i,o,u,f),this._rpcRequest=Jl(this._rpcClient),this._rpcBatchRequest=Xl(this._rpcClient),this._rpcWebSocket=new Tl(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),u=st(o,Gt(K()));if("error"in u)throw new ut(u.error,`failed to get balance for ${t.toBase58()}`);return u.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,bt(at(K())));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,bt(K()));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,sh);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,oh);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(Li));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(Li));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 u=this._buildArgs(o,s,"base64",i),f=await this._rpcRequest("getTokenAccountsByOwner",u),g=st(f,ch);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),u=st(o,uh);if("error"in u)throw new ut(u.error,`failed to get token accounts owned by account ${t.toBase58()}`);return u.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,lh);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,ah);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),u=st(o,Gt(at(Jr)));if("error"in u)throw new ut(u.error,`failed to get info about account ${t.toBase58()}`);return u.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),u=st(o,Gt(at(Ui)));if("error"in u)throw new ut(u.error,`failed to get info about account ${t.toBase58()}`);return u.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),u=await this._rpcRequest("getMultipleAccounts",o),f=st(u,Gt(ot(at(Ui))));if("error"in f)throw new ut(f.error,`failed to get info for accounts ${i}`);return f.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),u=await this._rpcRequest("getMultipleAccounts",o),f=st(u,Gt(ot(at(Jr))));if("error"in f)throw new ut(f.error,`failed to get info for accounts ${i}`);return f.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)}),u=await this._rpcRequest("getStakeActivation",o),f=st(u,bt(ph));if("error"in f)throw new ut(f.error,`failed to get Stake Activation ${t.toBase58()}`);return f.result}async getProgramAccounts(t,e){const{commitment:r,config:s}=Nt(e),{encoding:i,...o}=s||{},u=this._buildArgs([t.toBase58()],r,i||"base64",{...o,...o.filters?{filters:jo(o.filters)}:null}),f=await this._rpcRequest("getProgramAccounts",u),g=ot(hh),w=o.withContext===!0?st(f,Gt(g)):st(f,bt(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),u=st(o,bt(ot(dh)));if("error"in u)throw new ut(u.error,`failed to get accounts owned by program ${t.toBase58()}`);return u.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((f,g)=>{try{r=this.onSignature(e,(k,M)=>{r=void 0;const R={context:M,value:k};f({__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,f({__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:u,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),g=this.getCancellationPromise(e);let w;try{const k=await Promise.race([g,f,o]);if(k.__type===Ge.PROCESSED)w=k.response;else throw new Si(s)}finally{i=!0,u()}return w}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let u=!1;const f=new Promise(R=>{let C=i,_=null;const T=async()=>{try{const{context:O,value:$}=await this.getNonceAndContext(s,{commitment:t,minContextSlot:r});return _=O.slot,$==null?void 0:$.nonce}catch{return C}};(async()=>{if(C=await T(),!u)for(;;){if(i!==C){R({__type:Ge.NONCE_INVALID,slotInWhichNonceDidAdvance:_});return}if(await gr(2e3),u||(C=await T(),u))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,f]);if(R.__type===Ge.PROCESSED)M=R.response;else{let C;for(;;){const _=await this.getSignatureStatus(o);if(_==null)break;if(_.context.slot<(R.slotInWhichNonceDidAdvance??r)){await gr(400);continue}C=_;break}if(C!=null&&C.value){const _=t||"finalized",{confirmationStatus:T}=C.value;switch(_){case"processed":case"recent":if(T!=="processed"&&T!=="confirmed"&&T!=="finalized")throw new _r(o);break;case"confirmed":case"single":case"singleGossip":if(T!=="confirmed"&&T!=="finalized")throw new _r(o);break;case"finalized":case"max":case"root":if(T!=="finalized")throw new _r(o);break;default:}M={context:C.context,value:{err:C.value.err}}}else throw new _r(o)}}finally{u=!0,g()}return M}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const s=new Promise(f=>{let g=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{g=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>f({__type:Ge.TIMED_OUT,timeoutMs:g}),g)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let u;try{const f=await Promise.race([o,s]);if(f.__type===Ge.PROCESSED)u=f.response;else throw new xi(e,f.timeoutMs/1e3)}finally{clearTimeout(r),i()}return u}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=st(t,bt(ot(Ah)));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,Bh);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,bt(K()));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,bt(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,bt(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,Th);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,bt(K()));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,Ql);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)}),u=await this._rpcRequest("getInflationReward",o),f=st(u,Fl);if("error"in f)throw new ut(f.error,"failed to get inflation reward");return f.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=st(t,th);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,rh);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,nh);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,ih);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,Mh);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(t){const{context:e,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),r=st(e,$h);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,Hh);if("error"in i)throw new ut(i.error,"failed to get fee calculator");const{context:o,value:u}=i.result;return{context:o,value:u!==null?u.feeCalculator:null}}async getFeeForMessage(t,e){const r=wt(t.serialize()).toString("base64"),s=this._buildArgs([r],e),i=await this._rpcRequest("getFeeForMessage",s),o=st(i,Gt(at(K())));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(u=>u.toBase58()),r=e!=null&&e.length?[e]:[],s=await this._rpcRequest("getRecentPrioritizationFees",r),i=st(s,eh);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,Dh);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),u=st(o,Kh);if("error"in u)throw new ut(u.error,"failed to determine if the blockhash `"+t+"`is valid");return u.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=st(t,bt(Vl));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,bt(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 u=st(o,Uh);if("error"in u)throw u.error;return u.result}case"none":{const u=st(o,Oh);if("error"in u)throw u.error;return u.result}default:{const u=st(o,Lh);if("error"in u)throw u.error;const{result:f}=u;return f?{...f,transactions:f.transactions.map(({transaction:g,meta:w,version:k})=>({meta:w,transaction:{...g,message:Ci(k,g.message)},version:k}))}:null}}}catch(u){throw new ut(u,"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 u=st(o,Fh);if("error"in u)throw u.error;return u.result}case"none":{const u=st(o,zh);if("error"in u)throw u.error;return u.result}default:{const u=st(o,Nh);if("error"in u)throw u.error;return u.result}}}catch(u){throw new ut(u,"failed to get block")}}async getBlockProduction(t){let e,r;if(typeof t=="string")r=t;else if(t){const{commitment:u,...f}=t;r=u,e=f}const s=this._buildArgs([],r,"base64",e),i=await this._rpcRequest("getBlockProduction",s),o=st(i,Zl);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),u=st(o,zi);if("error"in u)throw new ut(u.error,"failed to get transaction");const f=u.result;return f&&{...f,transaction:{...f.transaction,message:Ci(f.version,f.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),u=st(o,Rn);if("error"in u)throw new ut(u.error,"failed to get transaction");return u.result}async getParsedTransactions(t,e){const{commitment:r,config:s}=Nt(e),i=t.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=st(f,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(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,void 0,s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=st(f,zi);if("error"in g)throw new ut(g.error,"failed to get transactions");const w=g.result;return w&&{...w,transaction:{...w.transaction,message:Ci(w.version,w.transaction.message)}}})}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),s=await this._rpcRequest("getBlock",r),i=st(s,qh);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 u={...o,transactions:o.transactions.map(({transaction:f,meta:g})=>{const w=new Ce(f.message);return{meta:g,transaction:{...f,message:w}}})};return{...u,transactions:u.transactions.map(({transaction:f,meta:g})=>({meta:g,transaction:Bt.populate(f.message,f.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,bt(ot(K())));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,sa);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("getBlock",r),i=st(s,sa);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("getTransaction",r),i=st(s,zi);if("error"in i)throw new ut(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const u=new Ce(o.transaction.message),f=o.transaction.signatures;return{...o,transaction:Bt.populate(u,f)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=await this._rpcRequest("getTransaction",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:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const u=st(o,Rn);if("error"in u)throw new ut(u.error,"failed to get confirmed transactions");return u.result})}async getConfirmedSignaturesForAddress(t,e,r){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<i));)try{const f=await this.getConfirmedBlockSignatures(e,"finalized");f.signatures.length>0&&(s.until=f.signatures[f.signatures.length-1].toString())}catch(f){if(f instanceof Error&&f.message.includes("skipped"))continue;throw f}let o=await this.getSlot("finalized");for(;!("before"in s)&&(r++,!(r>o));)try{const f=await this.getConfirmedBlockSignatures(r);f.signatures.length>0&&(s.before=f.signatures[f.signatures.length-1].toString())}catch(f){if(f instanceof Error&&f.message.includes("skipped"))continue;throw f}return(await this.getConfirmedSignaturesForAddress2(t,s)).map(f=>f.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,gh);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,yh);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 Mi({key:t,state:Mi.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,Vh);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>=Vo;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(Fo/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(K()));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 _=t.serialize(),T=ht.Buffer.from(_).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,Zo);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 _=await this._blockhashWithExpiryBlockHeight(C);if(s.lastValidBlockHeight=_.lastValidBlockHeight,s.recentBlockhash=_.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(),u=o.serialize(),g=s._serialize(u).toString("base64"),w={encoding:"base64",commitment:this.commitment};if(r){const C=(Array.isArray(r)?r:o.nonProgramIds()).map(_=>_.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,Zo);if("error"in R){let C;if("data"in R.error&&(C=R.error.data.logs,C&&Array.isArray(C))){const _=`
|
|
13
|
-
`,T=_+C.join(_);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 u=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=u.lastValidBlockHeight,t.recentBlockhash=u.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const f=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(f))o=!0;else{this._blockhashInfo.transactionSignatures.push(f);break}}}const i=t.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(t,e){const r=wt(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],u=await this._rpcRequest("sendTransaction",o),f=st(u,jh);if("error"in f){let g;throw"data"in f.error&&(g=f.error.data.logs),new Zr({action:s?"send":"simulate",signature:"",transactionMessage:f.error.message,logs:g})}return f.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 u=await this._rpcWebSocket.call(o,i);this._setSubscription(r,{...s,serverSubscriptionId:u,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[u]=s.callbacks,await this._updateSubscriptions()}catch(u){if(console.error(`Received ${u instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:u}),!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(u){if(u instanceof Error&&console.error(`${o} error:`,u.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,mh);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,bh);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),u=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:jo(s)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},u)}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,Zh);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=st(t,vh);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,xh);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,Ih);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,u)=>{if(o.type==="status"){e(o.result,u);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),u=this._makeSubscription({callback:(f,g)=>{e(f,g);try{this.removeSignatureListener(u)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return u}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:r}=st(t,Eh);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??Mo()}static generate(){return new Pr(Mo())}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 Xh{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(qi.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 qi{constructor(){}static createLookupTable(t){const[e,r]=it.findProgramAddressSync([t.authority.toBuffer(),si.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})}}qi.programId=new it("AddressLookupTab1e1111111111111111111111111");class Qh{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(De))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(De.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Rt(De.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Rt(De.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Rt(De.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(Di.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const De=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 Di{constructor(){}static requestUnits(t){const e=De.RequestUnits,r=It(e,t);return new Pt({keys:[],programId:this.programId,data:r})}static requestHeapFrame(t){const e=De.RequestHeapFrame,r=It(e,t);return new Pt({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(t){const e=De.SetComputeUnitLimit,r=It(e,t);return new Pt({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(t){const e=De.SetComputeUnitPrice,r=It(e,{microLamports:BigInt(t.microLamports)});return new Pt({keys:[],programId:this.programId,data:r})}}Di.programId=new it("ComputeBudget111111111111111111111111111111");const oa=64,aa=32,ca=64,ua=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===aa,`Public Key must be ${aa} bytes but received ${e.length} bytes`),Et(s.length===ca,`Signature must be ${ca} bytes but received ${s.length} bytes`);const o=ua.span,u=o+e.length,f=u+s.length,g=1,w=ht.Buffer.alloc(f+r.length),k=i??65535;return ua.encode({numSignatures:g,padding:0,signatureOffset:u,signatureInstructionIndex:k,publicKeyOffset:o,publicKeyInstructionIndex:k,messageDataOffset:f,messageDataSize:r.length,messageInstructionIndex:k},w),w.fill(e,o),w.fill(s,u),w.fill(r,f),new Pt({keys:[],programId:Tn.programId,data:w})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;Et(e.length===oa,`Private key must be ${oa} bytes but received ${e.length} bytes`);try{const i=Pr.fromSecretKey(e),o=i.publicKey.toBytes(),u=ki(r,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:u,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Tn.programId=new it("Ed25519SigVerify111111111111111111111111111");const tf=(n,t)=>{const e=bn.sign(n,t);return[e.toCompactRawBytes(),e.recovery]};bn.utils.isValidPrivateKey;const ef=bn.getPublicKey,la=32,Ki=20,ha=64,rf=11,Wi=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===ha,`Public key must be ${ha} bytes but received ${t.length} bytes`);try{return ht.Buffer.from(Io(wt(t))).slice(-Ki)}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 u;typeof e=="string"?e.startsWith("0x")?u=ht.Buffer.from(e.substr(2),"hex"):u=ht.Buffer.from(e,"hex"):u=e,Et(u.length===Ki,`Address must be ${Ki} bytes but received ${u.length} bytes`);const f=1+rf,g=f,w=f+u.length,k=w+s.length+1,M=1,R=ht.Buffer.alloc(Wi.span+r.length);return Wi.encode({numSignatures:M,signatureOffset:w,signatureInstructionIndex:o,ethAddressOffset:g,ethAddressInstructionIndex:o,messageDataOffset:k,messageDataSize:r.length,messageInstructionIndex:o,signature:wt(s),ethAddress:wt(u),recoveryId:i},R),R.fill(wt(r),Wi.span),new Pt({keys:[],programId:Cr.programId,data:R})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;Et(e.length===la,`Private key must be ${la} bytes but received ${e.length} bytes`);try{const i=wt(e),o=ef(i,!1).slice(1),u=ht.Buffer.from(Io(wt(r))),[f,g]=tf(u,i);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:f,recoveryId:g,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Cr.programId=new it("KeccakSecp256k11111111111111111111111111111");var fa;const da=new it("StakeConfig11111111111111111111111111111111");class pa{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 nf{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 pa(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"),ul(),ll()])},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")])}}),sf=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,u=It(o,{authorized:{staker:wt(r.staker.toBuffer()),withdrawer:wt(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:wt(i.custodian.toBuffer())}}),f={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Rr,isSigner:!1,isWritable:!1}],programId:this.programId,data:u};return new Pt(f)}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:da,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,u=me.Authorize,f=It(u,{newAuthorized:wt(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:f})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:u,custodianPubkey:f}=t,g=me.AuthorizeWithSeed,w=It(g,{newAuthorized:wt(o.toBuffer()),stakeAuthorizationType:u.index,authoritySeed:s,authorityOwner:wt(i.toBuffer())}),k=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:qe,isSigner:!1,isWritable:!1}];return f&&k.push({pubkey:f,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,u=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:u})}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:u,lamports:f}=t,g=new Bt;return g.add(ye.allocate({accountPubkey:i,basePubkey:o,seed:u,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:f}))}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,u=me.Withdraw,f=It(u,{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:f})}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 ga{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 of{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(Ke))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(Ke.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new ga(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(Ke.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(Ke.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(Ke.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 Ke=Object.freeze({InitializeAccount:{index:0,layout:P.struct([P.u32("instruction"),hl()])},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()])}}),af=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Lr{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:s}=t,i=Ke.InitializeAccount,o=It(i,{voteInit:{nodePubkey:wt(s.nodePubkey.toBuffer()),authorizedVoter:wt(s.authorizedVoter.toBuffer()),authorizedWithdrawer:wt(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),u={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(u)}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=Ke.Authorize,u=It(o,{newAuthorized:wt(s.toBuffer()),voteAuthorizationType:i.index}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:qe,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Bt().add({keys:f,programId:this.programId,data:u})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:u}=t,f=Ke.AuthorizeWithSeed,g=It(f,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:wt(r.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:wt(i.toBuffer()),voteAuthorizationType:o.index}}),w=[{pubkey:u,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=Ke.Withdraw,u=It(o,{lamports:s}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Bt().add({keys:f,programId:this.programId,data:u})}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=Ke.UpdateValidatorIdentity,o=It(i),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Bt().add({keys:u,programId:this.programId,data:o})}}Lr.programId=new it("Vote111111111111111111111111111111111111111"),Lr.space=3762;const ya=new it("Va1idator1nfo111111111111111111111111111111"),cf=tt({name:rt(),website:lt(rt()),details:lt(rt()),iconUrl:lt(rt()),keybaseUsername:lt(rt())});class $i{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(Ae(e,0,Fe)),u=ze(e)===1;s.push({publicKey:o,isSigner:u})}if(s[0].publicKey.equals(ya)&&s[1].isSigner){const i=dr().decode(ht.Buffer.from(e)),o=JSON.parse(i);return so(o,cf),new $i(s[1].publicKey,o)}return null}}const uf=new it("Vote111111111111111111111111111111111111111"),lf=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 Hi{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=lf.decode(wt(t),4);let s=r.rootSlot;return r.rootSlotValid||(s=null),new Hi({nodePubkey:new it(r.nodePubkey),authorizedWithdrawer:new it(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:s,authorizedVoters:r.authorizedVoters.map(hf),priorVoters:ff(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function hf({authorizedVoter:n,epoch:t}){return{epoch:t,authorizedVoter:new it(n)}}function ma({authorizedPubkey:n,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new it(n),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function ff({buf:n,idx:t,isEmpty:e}){return e?[]:[...n.slice(t+1).map(ma),...n.slice(0,t).map(ma)]}const wa={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 df(n,t){const e=t===!1?"http":"https";if(!n)return wa[e].devnet;const r=wa[e][n];if(!r)throw new Error(`Unknown ${e} cluster: ${n}`);return r}async function pf(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},u=await n.sendRawTransaction(t,o),f=i&&i.commitment,w=(await(s?n.confirmTransaction(s,f):n.confirmTransaction(u,f))).value;if(w.err)throw u!=null?new Zr({action:o!=null&&o.skipPreflight?"send":"simulate",signature:u,transactionMessage:`Status: (${JSON.stringify(w)})`}):new Error(`Raw transaction ${u} failed (${JSON.stringify(w)})`);return u}const Pn=Object.freeze(Object.defineProperty({__proto__:null,Account:ol,AddressLookupTableAccount:Mi,AddressLookupTableInstruction:Xh,AddressLookupTableProgram:qi,Authorized:pa,BLOCKHASH_CACHE_TIMEOUT_MS:Vo,BPF_LOADER_DEPRECATED_PROGRAM_ID:al,BPF_LOADER_PROGRAM_ID:xl,BpfLoader:Il,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:De,ComputeBudgetInstruction:Qh,ComputeBudgetProgram:Di,Connection:Jh,Ed25519Program:Tn,Enum:il,EpochSchedule:Wo,FeeCalculatorLayout:zo,Keypair:Pr,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Ze,Loader:yr,Lockup:Xr,MAX_SEED_LENGTH:Lo,Message:Ce,MessageAccountKeys:Gr,MessageV0:pr,NONCE_ACCOUNT_LENGTH:_i,NonceAccount:En,PACKET_DATA_SIZE:er,PUBLIC_KEY_LENGTH:Fe,PublicKey:it,SIGNATURE_LENGTH_IN_BYTES:jr,SOLANA_SCHEMA:Vr,STAKE_CONFIG_ID:da,STAKE_INSTRUCTION_LAYOUTS:me,SYSTEM_INSTRUCTION_LAYOUTS:Ut,SYSVAR_CLOCK_PUBKEY:qe,SYSVAR_EPOCH_SCHEDULE_PUBKEY:pl,SYSVAR_INSTRUCTIONS_PUBKEY:gl,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:xn,SYSVAR_RENT_PUBKEY:Rr,SYSVAR_REWARDS_PUBKEY:yl,SYSVAR_SLOT_HASHES_PUBKEY:ml,SYSVAR_SLOT_HISTORY_PUBKEY:wl,SYSVAR_STAKE_HISTORY_PUBKEY:In,Secp256k1Program:Cr,SendTransactionError:Zr,SolanaJSONRPCError:ut,SolanaJSONRPCErrorCode:bl,StakeAuthorizationLayout:sf,StakeInstruction:nf,StakeProgram:Mn,Struct:vi,SystemInstruction:vl,SystemProgram:ye,Transaction:Bt,TransactionExpiredBlockheightExceededError:Si,TransactionExpiredNonceInvalidError:_r,TransactionExpiredTimeoutError:xi,TransactionInstruction:Pt,TransactionMessage:Ei,TransactionStatus:Ge,VALIDATOR_INFO_KEY:ya,VERSION_PREFIX_MASK:vn,VOTE_PROGRAM_ID:uf,ValidatorInfo:$i,VersionedMessage:Ii,VersionedTransaction:Ai,VoteAccount:Hi,VoteAuthorizationLayout:af,VoteInit:ga,VoteInstruction:of,VoteProgram:Lr,clusterApiUrl:df,sendAndConfirmRawTransaction:pf,sendAndConfirmTransaction:Bi},Symbol.toStringTag,{value:"Module"})),rr=ge;var Vi={exports:{}},ba;function gf(){return ba||(ba=1,function(n){var t=function(){var e=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(f,g){if(!i[f]){i[f]={};for(var w=0;w<f.length;w++)i[f][f.charAt(w)]=w}return i[f][g]}var u={compressToBase64:function(f){if(f==null)return"";var g=u._compress(f,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(f){return f==null?"":f==""?null:u._decompress(f.length,32,function(g){return o(r,f.charAt(g))})},compressToUTF16:function(f){return f==null?"":u._compress(f,15,function(g){return e(g+32)})+" "},decompressFromUTF16:function(f){return f==null?"":f==""?null:u._decompress(f.length,16384,function(g){return f.charCodeAt(g)-32})},compressToUint8Array:function(f){for(var g=u.compress(f),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(f){if(f==null)return u.decompress(f);for(var g=new Array(f.length/2),w=0,k=g.length;w<k;w++)g[w]=f[w*2]*256+f[w*2+1];var M=[];return g.forEach(function(R){M.push(e(R))}),u.decompress(M.join(""))},compressToEncodedURIComponent:function(f){return f==null?"":u._compress(f,6,function(g){return s.charAt(g)})},decompressFromEncodedURIComponent:function(f){return f==null?"":f==""?null:(f=f.replace(/ /g,"+"),u._decompress(f.length,32,function(g){return o(s,f.charAt(g))}))},compress:function(f){return u._compress(f,16,function(g){return e(g)})},_compress:function(f,g,w){if(f==null)return"";var k,M,R={},C={},_="",T="",O="",$=2,q=3,X=2,W=[],F=0,Y=0,Z;for(Z=0;Z<f.length;Z+=1)if(_=f.charAt(Z),Object.prototype.hasOwnProperty.call(R,_)||(R[_]=q++,C[_]=!0),T=O+_,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,W.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,W.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,W.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,W.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,W.push(w(F)),F=0):Y++,M=M>>1;$--,$==0&&($=Math.pow(2,X),X++),R[T]=q++,O=String(_)}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,W.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,W.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,W.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,W.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,W.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,W.push(w(F)),F=0):Y++,M=M>>1;for(;;)if(F=F<<1,Y==g-1){W.push(w(F));break}else Y++;return W.join("")},decompress:function(f){return f==null?"":f==""?null:u._decompress(f.length,32768,function(g){return f.charCodeAt(g)})},_decompress:function(f,g,w){var k=[],M=4,R=4,C=3,_="",T=[],O,$,q,X,W,F,Y,Z={val:w(0),position:g,index:1};for(O=0;O<3;O+=1)k[O]=O;for(q=0,W=Math.pow(2,2),F=1;F!=W;)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,W=Math.pow(2,8),F=1;F!=W;)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,W=Math.pow(2,16),F=1;F!=W;)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>f)return"";for(q=0,W=Math.pow(2,C),F=1;F!=W;)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,W=Math.pow(2,8),F=1;F!=W;)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,W=Math.pow(2,16),F=1;F!=W;)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])_=k[Y];else if(Y===R)_=$+$.charAt(0);else return null;T.push(_),k[R++]=$+_.charAt(0),M--,$=_,M==0&&(M=Math.pow(2,C),C++)}}};return u}();n!=null?n.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(Vi)),Vi.exports}var yf=gf();const Le=Nr(yf);var ji=(n=>(n.USD="USD",n.EUR="EUR",n.GBP="GBP",n.BRL="BRL",n))(ji||{});class We{constructor(t){fe(this,"env");fe(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==="ngrok"?"https://coinflow.ngrok.app":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:u,blockchain:f="solana",webhookInfo:g,email:w,loaderBackground:k,handleHeightChangeId:M,bankAccountLinkRedirect:R,additionalWallets:C,nearDeposit:_,chargebackProtectionData:T,merchantCss:O,color:$,rent:q,lockDefaultToken:X,tokens:W,planCode:F,disableApplePay:Y,disableGooglePay:Z,customerInfo:J,settlementType:D,lockAmount:V,nativeSolToConvert:Q,theme:I,usePermit:c,transactionSigner:p,authOnly:y,deviceId:A,jwtToken:x,origins:E,threeDsChallengePreference:L,supportEmail:v,destinationAuthKey:a,allowedPaymentMethods:l}){var U;const b=s?`/${s}/${f}`:`/${f}`,S=new URL(b+r,We.getCoinflowBaseUrl(i));if(t&&S.searchParams.append("pubkey",t),e&&S.searchParams.append("sessionKey",e),u&&S.searchParams.append("transaction",u),o&&("cents"in o?(S.searchParams.append("cents",o.cents.toString()),"currency"in o?S.searchParams.append("currency",o.currency.toString()):S.searchParams.append("currency",ji.USD)):(S.searchParams.append("token",o.address.toString()),S.searchParams.append("amount",o.amount.toString()))),g&&S.searchParams.append("webhookInfo",Le.compressToEncodedURIComponent(JSON.stringify(g))),I&&S.searchParams.append("theme",Le.compressToEncodedURIComponent(JSON.stringify(I))),J&&S.searchParams.append("customerInfo",Le.compressToEncodedURIComponent(JSON.stringify(J))),w&&S.searchParams.append("email",w),v&&S.searchParams.append("supportEmail",v),W&&S.searchParams.append("tokens",W.toString()),k&&S.searchParams.append("loaderBackground",k),M&&S.searchParams.append("useHeightChange",M.toString()),R&&S.searchParams.append("bankAccountLinkRedirect",R),C&&S.searchParams.append("additionalWallets",Le.compressToEncodedURIComponent(JSON.stringify(C))),_&&S.searchParams.append("nearDeposit",_),T&&S.searchParams.append("chargebackProtectionData",Le.compressToEncodedURIComponent(JSON.stringify(T))),A)S.searchParams.append("deviceId",A);else if(typeof window<"u"){const j=(U=window==null?void 0:window.nSureSDK)==null?void 0:U.getDeviceId();j&&S.searchParams.append("deviceId",j)}return O&&S.searchParams.append("merchantCss",O),$&&S.searchParams.append("color",$),q&&S.searchParams.append("rent",q.lamports.toString()),Q&&S.searchParams.append("nativeSolToConvert",Q.lamports.toString()),X&&S.searchParams.append("lockDefaultToken","true"),F&&S.searchParams.append("planCode",F),Y&&S.searchParams.append("disableApplePay","true"),Z&&S.searchParams.append("disableGooglePay","true"),D&&S.searchParams.append("settlementType",D),V&&S.searchParams.append("lockAmount","true"),c===!1&&S.searchParams.append("usePermit","false"),p&&S.searchParams.append("transactionSigner",p),y===!0&&S.searchParams.append("authOnly","true"),x&&S.searchParams.append("jwtToken",x),E&&S.searchParams.append("origins",Le.compressToEncodedURIComponent(JSON.stringify(E))),l&&S.searchParams.append("allowedPaymentMethods",l.join(",")),L&&S.searchParams.append("threeDsChallengePreference",L),a&&S.searchParams.append("destinationAuthKey",a),S.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!")}}}function mf(n){if(!n)return;let t,e;if("name"in n&&n.name&&(t=n.name.split(" ")[0],e=n.name.split(" ").slice(1).join(" ")),"firstName"in n&&n.firstName&&(t=n.firstName),"lastName"in n&&n.lastName&&(e=n.lastName),t&&e)return{firstName:t,lastName:e}}var ka=(n=>(n.SignMessage="signMessage",n.SignTransaction="signTransaction",n.SendTransaction="sendTransaction",n.HeightChange="heightChange",n.Success="success",n.AuthDeclined="authDeclined",n.Loaded="loaded",n))(ka||{});function Cn(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 va(n,t,e){let r;try{if(r=JSON.parse(n),!("method"in r)||!("data"in r))return}catch(o){console.error("handleIFrameMessage JSON parse",o);return}const{data:s,method:i}=r;switch(i){case"signMessage":return t.handleSignMessage?t.handleSignMessage(s):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(s):void 0;case"sendTransaction":return t.handleSendTransaction(s);case"heightChange:"+e:return t.handleHeightChange?t.handleHeightChange(s):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(r.info);return;case"authDeclined":if(!t.onAuthDeclined)return;t.onAuthDeclined(r.info);return;case"loaded":return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${i} is not one of ${Object.values(ka)}`)}function Ln(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?We.byBlockchain(t,{solana:()=>wf({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),near:()=>bf({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),eth:()=>On({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),polygon:()=>On({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),base:()=>On({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),arbitrum:()=>On({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),user:()=>kf(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,onAuthDeclined:n.onAuthDeclined}}function wf({wallet:n,onSuccess:t,onAuthDeclined:e}){return{handleSendTransaction:async r=>{const s=Sa(r);return await n.sendTransaction(s)},handleSignMessage:async r=>{const s=n.signMessage;if(!s)throw new Error("signMessage is not supported by this wallet");const i=await s(new TextEncoder().encode(r));if(!rr)throw new Error("bs58 dependency is required");return rr.encode(i)},handleSignTransaction:async r=>{const s=n.signTransaction;if(!s)throw new Error("signTransaction is not supported by this wallet");const i=Sa(r),o=await s(i);if(!rr)throw new Error("bs58 dependency is required");return rr.encode(o.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t,onAuthDeclined:e}}function Sa(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 bf({wallet:n,onSuccess:t,onAuthDeclined:e}){return{handleSendTransaction:async r=>{const s=JSON.parse(Buffer.from(r,"base64").toString()),i=await n.signAndSendTransaction(s);if(!i)throw new Error("Transaction did not send");const{transaction:o}=i;return o.hash},onSuccess:t,onAuthDeclined:e}}function On({wallet:n,onSuccess:t,onAuthDeclined:e}){return{handleSendTransaction:async r=>{const s=JSON.parse(Buffer.from(r,"base64").toString()),{hash:i}=await n.sendTransaction(s);return i},handleSignMessage:async r=>n.signMessage(r),onSuccess:t,onAuthDeclined:e}}function kf({onSuccess:n,onAuthDeclined:t}){return{handleSendTransaction:async()=>Promise.resolve(""),onSuccess:n,onAuthDeclined:t}}const Qr="tokenExCardNumber",Or="tokenExCardCvv",xa={[br.VISA]:"visa",[br.MASTERCARD]:"masterCard",[br.AMEX]:"americanExpress",[br.DISCOVER]:"discover"};async function Ia(n){const{token:t,origins:e,env:r}=n;return new Promise((s,i)=>{fetch(new We(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 vf({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 Ea(n){const{token:t,cardType:e}=n;return await Zi(Or,n,{cvvOnly:!0,cvv:!0,cvvContainerID:Or,placeholder:"CVV",token:t,cardType:xa[e]})}async function Aa(n){return await Zi(Qr,n,{cvv:!0,cvvContainerID:Or,cvvPlaceholder:"CVV"})}async function Ba(n){return await Zi(Qr,n,{cvv:!1})}async function Zi(n,t,e){const{tokenExScriptLoaded:r,css:s,debug:i,font:o,setCachedToken:u,setLoaded:f}=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 Ia({...t,token:e.token}),{styles:w}=Sf(s),k={...g,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:w,font:o,debug:i??!1,...e},M=TokenEx.Iframe(n,k);return vf({iframe:M,setCachedToken:u,setLoaded:f})}function Sf(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 xf=et.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return We.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(We.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:n,origin:t});const e=va(n,this.args,this.args.handleHeightChangeId);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(We.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},If=["src","scrolling"];function Ef(n,t,e,r,s,i){return et.openBlock(),et.createElementBlock("iframe",{credentialless:"",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,If)}const Un=Yi(xf,[["render",Ef]]),Af=et.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:Un},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Cn(this.args);return{...this.args,walletPubkey:n,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...Ln(this.args),handleHeightChange:this.args.handleHeightChange}}}});function Bf(n,t,e,r,s,i){const o=et.resolveComponent("coinflow-i-frame");return et.openBlock(),et.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const _f=Yi(Af,[["render",Bf]]),Rf=et.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:Un},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Cn(this.args);return{...this.args,walletPubkey:n,route:`/purchase-v2/${this.args.merchantId}`,transaction:We.getTransaction(this.args)}},messageHandlers(){return{...Ln(this.args),handleHeightChange:this.args.handleHeightChange}}}});function Tf(n,t,e,r,s,i){const o=et.resolveComponent("coinflow-i-frame");return et.openBlock(),et.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const Mf=Yi(Rf,[["render",Tf]]),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,u=k=>r.value=k,f=async k=>{const M=await Ea({...n,...k,tokenExScriptLoaded:e.value,setCachedToken:i,setLoaded:o});return u(M),M},g=async k=>{const M=await Aa({...n,...k,tokenExScriptLoaded:e.value,setCachedToken:i,setLoaded:o});return u(M),M},w=async k=>{const M=await Ba({...n,...k,tokenExScriptLoaded:e.value,setCachedToken:i,setLoaded:o});return u(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:f,initializeTokenExCardOnlyIframe:w,loaded:t,cachedToken:s,setTokenExScriptTag:Gi,tokenExScriptLoaded:e}},Pf=["id"],Cf=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,u)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Qr)},null,8,Pf))}}),Lf=["id"],Of=et.defineComponent({__name:"CoinflowCvvInput",setup(n){return(t,e)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Or)},null,8,Lf))}}),Uf=["id"],Nf=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,u)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Or)},null,8,Uf))}}),Ff=et.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(n){const t=et.ref(void 0);et.onMounted(()=>new We(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) {
|
|
12
|
+
`+i+o;break;default:u=`Unknown action '${(f=>f)(t)}'`}super(u),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 kl={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 Bi(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:u}=t.nonceInfo,f=u.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:f,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:No(n,t),r=ht.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 Do=P.nu64("lamportsPerSignature"),qo=P.struct([P.u32("version"),P.u32("state"),xt("authorizedPubkey"),xt("nonce"),P.struct([Do],"feeCalculator")]),_i=qo.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=qo.decode(wt(t),0);return new En({authorizedPubkey:new it(e.authorizedPubkey),nonce:new it(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const vl=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}=vl(e),i=e;return i.decode=(o,u)=>{const f=s(o,u);return si.toBigIntLE(ht.Buffer.from(f))},i.encode=(o,u,f)=>{const g=si.toBufferLE(o,n);return r(g,u,f)},i})(8);class Sl{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:wt(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:wt(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:wt(t.basePubkey.toBuffer()),seed:t.seed,programId:wt(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:wt(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:wt(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:wt(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:_i,programId:this.programId})):e.add(ye.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:_i,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:wt(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:wt(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:wt(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:wt(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 xl=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 Bi(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")]),u=yr.chunkSize;let f=0,g=i,w=[];for(;g.length>0;){const k=g.slice(0,u),M=ht.Buffer.alloc(u+16);o.encode({instruction:0,offset:f,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(Bi(t,R,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")&&await gr(1e3/4),f+=u,g=g.slice(u)}await Promise.all(w);{const k=P.struct([P.u32("instruction")]),M=ht.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:U}=await t.confirmTransaction({signature:B,lastValidBlockHeight:R.lastValidBlockHeight,blockhash:R.recentBlockhash},C);if(U.err)throw new Error(`Transaction ${B} failed (${JSON.stringify(U)})`);for(;;){try{if(await t.getSlot({commitment:C})>T.slot)break}catch{}await new Promise(W=>setTimeout(W,Math.round(zo/2)))}}return!0}}yr.chunkSize=xl;const Il=new it("BPFLoader2111111111111111111111111111111111");class El{static getMinNumSignatures(t){return yr.getMinNumSignatures(t)}static load(t,e,r,s,i){return yr.load(t,e,r,i,s)}}function Al(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ri,Ko;function Bl(){if(Ko)return Ri;Ko=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,u,f,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(u="[",o=r.length-1,i=0;i<o;i++)u+=e(r[i],!0)+",";return o>-1&&(u+=e(r[i],!0)),u+"]"}else if(k==="[object Object]"){for(f=t(r).sort(),o=f.length,u="",i=0;i<o;)g=f[i],w=e(r[g],!1),w!==void 0&&(u&&(u+=","),u+=JSON.stringify(g)+":"+w),i++;return"{"+u+"}"}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 Ri=function(r){var s=e(r,!1);if(s!==void 0)return""+s},Ri}var _l=Bl(),Wo=Al(_l);const Yr=32;function Ti(n){let t=0;for(;n>1;)n/=2,t++;return t}function Rl(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 $o{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=Ti(Rl(t+Yr+1))-Ti(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+Ti(Yr)):this.slotsPerEpoch}}var Tl=globalThis.fetch;class Ml extends Fu{constructor(t,e,r){const s=i=>{const o=Uu(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 Pl(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 Ho=56;class Mi{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=Pl(Ll,t),r=t.length-Ho;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(Ho));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 Ll={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")])},Cl=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function Ol(n){const t=n.match(Cl);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[e,r,s,i]=t,o=n.startsWith("https:")?"wss:":"ws:",u=s==null?null:parseInt(s.slice(1),10),f=u==null?"":`:${u+1}`;return`${o}//${r}${f}${i}`}const Vt=$r(ai(it),nt(),n=>new it(n)),Vo=ci([nt(),Ht("base64")]),Pi=$r(ai(ht.Buffer),Vo,n=>ht.Buffer.from(n[0],"base64")),jo=30*1e3;function Ul(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 Go(n){return n.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function Zo(n){return Ie([tt({jsonrpc:Ht("2.0"),id:nt(),result:n}),tt({jsonrpc:Ht("2.0"),id:nt(),error:tt({code:Br(),message:nt(),data:lt(uu())})})])}const Nl=Zo(Br());function bt(n){return $r(Zo(n),Nl,t=>"error"in t?t:{...t,result:st(t.result,n)})}function Gt(n){return bt(tt({context:tt({slot:K()}),value:n}))}function An(n){return tt({context:tt({slot:K()}),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 Le(t)}const Fl=tt({foundation:K(),foundationTerm:K(),initial:K(),taper:K(),terminal:K()}),zl=bt(ot(at(tt({epoch:K(),effectiveSlot:K(),amount:K(),postBalance:K(),commission:lt(at(K()))})))),Dl=ot(tt({slot:K(),prioritizationFee:K()})),ql=tt({total:K(),validator:K(),foundation:K(),epoch:K()}),Kl=tt({epoch:K(),slotIndex:K(),slotsInEpoch:K(),absoluteSlot:K(),blockHeight:lt(K()),transactionCount:lt(K())}),Wl=tt({slotsPerEpoch:K(),leaderScheduleSlotOffset:K(),warmup:Ne(),firstNormalEpoch:K(),firstNormalSlot:K()}),$l=co(nt(),ot(K())),mr=at(Ie([tt({}),nt()])),Hl=tt({err:mr}),Vl=Ht("receivedSignature"),jl=tt({"solana-core":nt(),"feature-set":lt(K())}),Gl=tt({program:nt(),programId:Vt,parsed:Br()}),Zl=tt({programId:Vt,accounts:ot(Vt),data:nt()}),Yo=Gt(tt({err:at(Ie([tt({}),nt()])),logs:at(ot(nt())),accounts:lt(at(ot(at(tt({executable:Ne(),owner:nt(),lamports:K(),data:ot(nt()),rentEpoch:lt(K())}))))),unitsConsumed:lt(K()),returnData:lt(at(tt({programId:nt(),data:ci([nt(),Ht("base64")])}))),innerInstructions:lt(at(ot(tt({index:K(),instructions:ot(Ie([Gl,Zl]))}))))})),Yl=Gt(tt({byIdentity:co(nt(),ot(K())),range:tt({firstSlot:K(),lastSlot:K()})}));function Jl(n,t,e,r,s,i){const o=e||Tl;let u;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 f;return r&&(f=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 Pu(async(w,k)=>{const M={method:"POST",body:w,agent:u,headers:Object.assign({"Content-Type":"application/json"},t||{},Jh)};try{let R=5,C,B=500;for(;f?C=await f(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 Xl(n){return(t,e)=>new Promise((r,s)=>{n.request(t,e,(i,o)=>{if(i){s(i);return}r(o)})})}function Ql(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 th=bt(Fl),eh=bt(ql),rh=bt(Dl),nh=bt(Kl),ih=bt(Wl),sh=bt($l),oh=bt(K()),ah=Gt(tt({total:K(),circulating:K(),nonCirculating:K(),nonCirculatingAccounts:ot(Vt)})),Ci=tt({amount:nt(),uiAmount:at(K()),decimals:K(),uiAmountString:lt(nt())}),ch=Gt(ot(tt({address:Vt,amount:nt(),uiAmount:at(K()),decimals:K(),uiAmountString:lt(nt())}))),uh=Gt(ot(tt({pubkey:Vt,account:tt({executable:Ne(),owner:Vt,lamports:K(),data:Pi,rentEpoch:K()})}))),Oi=tt({program:nt(),parsed:Br(),space:K()}),lh=Gt(ot(tt({pubkey:Vt,account:tt({executable:Ne(),owner:Vt,lamports:K(),data:Oi,rentEpoch:K()})}))),hh=Gt(ot(tt({lamports:K(),address:Vt}))),Jr=tt({executable:Ne(),owner:Vt,lamports:K(),data:Pi,rentEpoch:K()}),fh=tt({pubkey:Vt,account:Jr}),dh=$r(Ie([ai(ht.Buffer),Oi]),Ie([Vo,Oi]),n=>Array.isArray(n)?st(n,Pi):n),Ui=tt({executable:Ne(),owner:Vt,lamports:K(),data:dh,rentEpoch:K()}),ph=tt({pubkey:Vt,account:Ui}),gh=tt({state:Ie([Ht("active"),Ht("inactive"),Ht("activating"),Ht("deactivating")]),active:K(),inactive:K()}),yh=bt(ot(tt({signature:nt(),slot:K(),err:mr,memo:at(nt()),blockTime:lt(at(K()))}))),mh=bt(ot(tt({signature:nt(),slot:K(),err:mr,memo:at(nt()),blockTime:lt(at(K()))}))),wh=tt({subscription:K(),result:An(Jr)}),bh=tt({pubkey:Vt,account:Jr}),kh=tt({subscription:K(),result:An(bh)}),vh=tt({parent:K(),slot:K(),root:K()}),Sh=tt({subscription:K(),result:vh}),xh=Ie([tt({type:Ie([Ht("firstShredReceived"),Ht("completed"),Ht("optimisticConfirmation"),Ht("root")]),slot:K(),timestamp:K()}),tt({type:Ht("createdBank"),parent:K(),slot:K(),timestamp:K()}),tt({type:Ht("frozen"),slot:K(),timestamp:K(),stats:tt({numTransactionEntries:K(),numSuccessfulTransactions:K(),numFailedTransactions:K(),maxTransactionsPerEntry:K()})}),tt({type:Ht("dead"),slot:K(),timestamp:K(),err:nt()})]),Ih=tt({subscription:K(),result:xh}),Eh=tt({subscription:K(),result:An(Ie([Hl,Vl]))}),Ah=tt({subscription:K(),result:K()}),Bh=tt({pubkey:nt(),gossip:at(nt()),tpu:at(nt()),rpc:at(nt()),version:at(nt())}),Jo=tt({votePubkey:nt(),nodePubkey:nt(),activatedStake:K(),epochVoteAccount:Ne(),epochCredits:ot(ci([K(),K(),K()])),commission:K(),lastVote:K(),rootSlot:at(K())}),_h=bt(tt({current:ot(Jo),delinquent:ot(Jo)})),Rh=Ie([Ht("processed"),Ht("confirmed"),Ht("finalized")]),Th=tt({slot:K(),confirmations:at(K()),err:mr,confirmationStatus:lt(Rh)}),Mh=Gt(ot(at(Th))),Ph=bt(K()),Xo=tt({accountKey:Vt,writableIndexes:ot(K()),readonlyIndexes:ot(K())}),Ni=tt({signatures:ot(nt()),message:tt({accountKeys:ot(nt()),header:tt({numRequiredSignatures:K(),numReadonlySignedAccounts:K(),numReadonlyUnsignedAccounts:K()}),instructions:ot(tt({accounts:ot(K()),data:nt(),programIdIndex:K()})),recentBlockhash:nt(),addressTableLookups:lt(ot(Xo))})}),Qo=tt({pubkey:Vt,signer:Ne(),writable:Ne(),source:lt(Ie([Ht("transaction"),Ht("lookupTable")]))}),ta=tt({accountKeys:ot(Qo),signatures:ot(nt())}),ea=tt({parsed:Br(),program:nt(),programId:Vt}),ra=tt({accounts:ot(Vt),data:nt(),programId:Vt}),Lh=Ie([ra,ea]),Ch=Ie([tt({parsed:Br(),program:nt(),programId:nt()}),tt({accounts:ot(nt()),data:nt(),programId:nt()})]),na=$r(Lh,Ch,n=>"accounts"in n?st(n,ra):st(n,ea)),ia=tt({signatures:ot(nt()),message:tt({accountKeys:ot(Qo),instructions:ot(na),recentBlockhash:nt(),addressTableLookups:lt(at(ot(Xo)))})}),Bn=tt({accountIndex:K(),mint:nt(),owner:lt(nt()),programId:lt(nt()),uiTokenAmount:Ci}),sa=tt({writable:ot(Vt),readonly:ot(Vt)}),_n=tt({err:mr,fee:K(),innerInstructions:lt(at(ot(tt({index:K(),instructions:ot(tt({accounts:ot(K()),data:nt(),programIdIndex:K()}))})))),preBalances:ot(K()),postBalances:ot(K()),logMessages:lt(at(ot(nt()))),preTokenBalances:lt(at(ot(Bn))),postTokenBalances:lt(at(ot(Bn))),loadedAddresses:lt(sa),computeUnitsConsumed:lt(K())}),Fi=tt({err:mr,fee:K(),innerInstructions:lt(at(ot(tt({index:K(),instructions:ot(na)})))),preBalances:ot(K()),postBalances:ot(K()),logMessages:lt(at(ot(nt()))),preTokenBalances:lt(at(ot(Bn))),postTokenBalances:lt(at(ot(Bn))),loadedAddresses:lt(sa),computeUnitsConsumed:lt(K())}),Mr=Ie([Ht(0),Ht("legacy")]),wr=tt({pubkey:nt(),lamports:K(),postBalance:at(K()),rewardType:at(nt()),commission:lt(at(K()))}),Oh=bt(at(tt({blockhash:nt(),previousBlockhash:nt(),parentSlot:K(),transactions:ot(tt({transaction:Ni,meta:at(_n),version:lt(Mr)})),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),Uh=bt(at(tt({blockhash:nt(),previousBlockhash:nt(),parentSlot:K(),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),Nh=bt(at(tt({blockhash:nt(),previousBlockhash:nt(),parentSlot:K(),transactions:ot(tt({transaction:ta,meta:at(_n),version:lt(Mr)})),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),Fh=bt(at(tt({blockhash:nt(),previousBlockhash:nt(),parentSlot:K(),transactions:ot(tt({transaction:ia,meta:at(Fi),version:lt(Mr)})),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),zh=bt(at(tt({blockhash:nt(),previousBlockhash:nt(),parentSlot:K(),transactions:ot(tt({transaction:ta,meta:at(Fi),version:lt(Mr)})),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),Dh=bt(at(tt({blockhash:nt(),previousBlockhash:nt(),parentSlot:K(),rewards:lt(ot(wr)),blockTime:at(K()),blockHeight:at(K())}))),qh=bt(at(tt({blockhash:nt(),previousBlockhash:nt(),parentSlot:K(),transactions:ot(tt({transaction:Ni,meta:at(_n)})),rewards:lt(ot(wr)),blockTime:at(K())}))),oa=bt(at(tt({blockhash:nt(),previousBlockhash:nt(),parentSlot:K(),signatures:ot(nt()),blockTime:at(K())}))),zi=bt(at(tt({slot:K(),meta:at(_n),blockTime:lt(at(K())),transaction:Ni,version:lt(Mr)}))),Rn=bt(at(tt({slot:K(),transaction:ia,meta:at(Fi),blockTime:lt(at(K())),version:lt(Mr)}))),Kh=Gt(tt({blockhash:nt(),lastValidBlockHeight:K()})),Wh=Gt(Ne()),$h=tt({slot:K(),numTransactions:K(),numSlots:K(),samplePeriodSecs:K()}),Hh=bt(ot($h)),Vh=Gt(at(tt({feeCalculator:tt({lamportsPerSignature:K()})}))),jh=bt(nt()),Gh=bt(nt()),Zh=tt({err:mr,logs:ot(nt()),signature:nt()}),Yh=tt({result:An(Zh),subscription:K()}),Jh={"solana-client":"js/1.0.0-maintenance"};class Xh{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=Wo(R);return g[C]=g[C]??(async()=>{try{const B=await this._rpcRequest("getBlockHeight",R),T=st(B,bt(K()));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,u,f;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,u=e.disableRetryOnRateLimit,f=e.httpAgent),this._rpcEndpoint=Ul(t),this._rpcWsEndpoint=r||Ol(t),this._rpcClient=Jl(t,s,i,o,u,f),this._rpcRequest=Xl(this._rpcClient),this._rpcBatchRequest=Ql(this._rpcClient),this._rpcWebSocket=new Ml(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),u=st(o,Gt(K()));if("error"in u)throw new ut(u.error,`failed to get balance for ${t.toBase58()}`);return u.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,bt(at(K())));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,bt(K()));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,oh);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,ah);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(Ci));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(Ci));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 u=this._buildArgs(o,s,"base64",i),f=await this._rpcRequest("getTokenAccountsByOwner",u),g=st(f,uh);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),u=st(o,lh);if("error"in u)throw new ut(u.error,`failed to get token accounts owned by account ${t.toBase58()}`);return u.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,hh);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,ch);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),u=st(o,Gt(at(Jr)));if("error"in u)throw new ut(u.error,`failed to get info about account ${t.toBase58()}`);return u.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),u=st(o,Gt(at(Ui)));if("error"in u)throw new ut(u.error,`failed to get info about account ${t.toBase58()}`);return u.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),u=await this._rpcRequest("getMultipleAccounts",o),f=st(u,Gt(ot(at(Ui))));if("error"in f)throw new ut(f.error,`failed to get info for accounts ${i}`);return f.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),u=await this._rpcRequest("getMultipleAccounts",o),f=st(u,Gt(ot(at(Jr))));if("error"in f)throw new ut(f.error,`failed to get info for accounts ${i}`);return f.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)}),u=await this._rpcRequest("getStakeActivation",o),f=st(u,bt(gh));if("error"in f)throw new ut(f.error,`failed to get Stake Activation ${t.toBase58()}`);return f.result}async getProgramAccounts(t,e){const{commitment:r,config:s}=Nt(e),{encoding:i,...o}=s||{},u=this._buildArgs([t.toBase58()],r,i||"base64",{...o,...o.filters?{filters:Go(o.filters)}:null}),f=await this._rpcRequest("getProgramAccounts",u),g=ot(fh),w=o.withContext===!0?st(f,Gt(g)):st(f,bt(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),u=st(o,bt(ot(ph)));if("error"in u)throw new ut(u.error,`failed to get accounts owned by program ${t.toBase58()}`);return u.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((f,g)=>{try{r=this.onSignature(e,(k,M)=>{r=void 0;const R={context:M,value:k};f({__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,f({__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:u,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),g=this.getCancellationPromise(e);let w;try{const k=await Promise.race([g,f,o]);if(k.__type===Ge.PROCESSED)w=k.response;else throw new Si(s)}finally{i=!0,u()}return w}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let u=!1;const f=new Promise(R=>{let C=i,B=null;const T=async()=>{try{const{context:U,value:W}=await this.getNonceAndContext(s,{commitment:t,minContextSlot:r});return B=U.slot,W==null?void 0:W.nonce}catch{return C}};(async()=>{if(C=await T(),!u)for(;;){if(i!==C){R({__type:Ge.NONCE_INVALID,slotInWhichNonceDidAdvance:B});return}if(await gr(2e3),u||(C=await T(),u))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,f]);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 _r(o);break;case"confirmed":case"single":case"singleGossip":if(T!=="confirmed"&&T!=="finalized")throw new _r(o);break;case"finalized":case"max":case"root":if(T!=="finalized")throw new _r(o);break;default:}M={context:C.context,value:{err:C.value.err}}}else throw new _r(o)}}finally{u=!0,g()}return M}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const s=new Promise(f=>{let g=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{g=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>f({__type:Ge.TIMED_OUT,timeoutMs:g}),g)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let u;try{const f=await Promise.race([o,s]);if(f.__type===Ge.PROCESSED)u=f.response;else throw new xi(e,f.timeoutMs/1e3)}finally{clearTimeout(r),i()}return u}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=st(t,bt(ot(Bh)));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,_h);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,bt(K()));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,bt(nt()));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,bt(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,Mh);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,bt(K()));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,th);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)}),u=await this._rpcRequest("getInflationReward",o),f=st(u,zl);if("error"in f)throw new ut(f.error,"failed to get inflation reward");return f.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=st(t,eh);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,nh);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,ih);if("error"in e)throw new ut(e.error,"failed to get epoch schedule");const r=e.result;return new $o(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=st(t,sh);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,Ph);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(t){const{context:e,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),r=st(e,Hh);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,Vh);if("error"in i)throw new ut(i.error,"failed to get fee calculator");const{context:o,value:u}=i.result;return{context:o,value:u!==null?u.feeCalculator:null}}async getFeeForMessage(t,e){const r=wt(t.serialize()).toString("base64"),s=this._buildArgs([r],e),i=await this._rpcRequest("getFeeForMessage",s),o=st(i,Gt(at(K())));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(u=>u.toBase58()),r=e!=null&&e.length?[e]:[],s=await this._rpcRequest("getRecentPrioritizationFees",r),i=st(s,rh);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,Kh);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),u=st(o,Wh);if("error"in u)throw new ut(u.error,"failed to determine if the blockhash `"+t+"`is valid");return u.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=st(t,bt(jl));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,bt(nt()));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 u=st(o,Nh);if("error"in u)throw u.error;return u.result}case"none":{const u=st(o,Uh);if("error"in u)throw u.error;return u.result}default:{const u=st(o,Oh);if("error"in u)throw u.error;const{result:f}=u;return f?{...f,transactions:f.transactions.map(({transaction:g,meta:w,version:k})=>({meta:w,transaction:{...g,message:Li(k,g.message)},version:k}))}:null}}}catch(u){throw new ut(u,"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 u=st(o,zh);if("error"in u)throw u.error;return u.result}case"none":{const u=st(o,Dh);if("error"in u)throw u.error;return u.result}default:{const u=st(o,Fh);if("error"in u)throw u.error;return u.result}}}catch(u){throw new ut(u,"failed to get block")}}async getBlockProduction(t){let e,r;if(typeof t=="string")r=t;else if(t){const{commitment:u,...f}=t;r=u,e=f}const s=this._buildArgs([],r,"base64",e),i=await this._rpcRequest("getBlockProduction",s),o=st(i,Yl);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),u=st(o,zi);if("error"in u)throw new ut(u.error,"failed to get transaction");const f=u.result;return f&&{...f,transaction:{...f.transaction,message:Li(f.version,f.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),u=st(o,Rn);if("error"in u)throw new ut(u.error,"failed to get transaction");return u.result}async getParsedTransactions(t,e){const{commitment:r,config:s}=Nt(e),i=t.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=st(f,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(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,void 0,s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=st(f,zi);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("getBlock",r),i=st(s,qh);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 u={...o,transactions:o.transactions.map(({transaction:f,meta:g})=>{const w=new Le(f.message);return{meta:g,transaction:{...f,message:w}}})};return{...u,transactions:u.transactions.map(({transaction:f,meta:g})=>({meta:g,transaction:Bt.populate(f.message,f.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,bt(ot(K())));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,oa);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("getBlock",r),i=st(s,oa);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("getTransaction",r),i=st(s,zi);if("error"in i)throw new ut(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const u=new Le(o.transaction.message),f=o.transaction.signatures;return{...o,transaction:Bt.populate(u,f)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=await this._rpcRequest("getTransaction",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:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const u=st(o,Rn);if("error"in u)throw new ut(u.error,"failed to get confirmed transactions");return u.result})}async getConfirmedSignaturesForAddress(t,e,r){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<i));)try{const f=await this.getConfirmedBlockSignatures(e,"finalized");f.signatures.length>0&&(s.until=f.signatures[f.signatures.length-1].toString())}catch(f){if(f instanceof Error&&f.message.includes("skipped"))continue;throw f}let o=await this.getSlot("finalized");for(;!("before"in s)&&(r++,!(r>o));)try{const f=await this.getConfirmedBlockSignatures(r);f.signatures.length>0&&(s.before=f.signatures[f.signatures.length-1].toString())}catch(f){if(f instanceof Error&&f.message.includes("skipped"))continue;throw f}return(await this.getConfirmedSignaturesForAddress2(t,s)).map(f=>f.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,yh);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,mh);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 Mi({key:t,state:Mi.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,jh);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>=jo;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(zo/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(K()));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=ht.Buffer.from(B).toString("base64");if(Array.isArray(e)||r!==void 0)throw new Error("Invalid arguments");const U=e||{};U.encoding="base64","commitment"in U||(U.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(U.innerInstructions=e.innerInstructions);const W=[T,U],D=await this._rpcRequest("simulateTransaction",W),J=st(D,Yo);if("error"in J)throw new Error("failed to simulate transaction: "+J.error.message);return J.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(),u=o.serialize(),g=s._serialize(u).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,Yo);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 u=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=u.lastValidBlockHeight,t.recentBlockhash=u.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const f=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(f))o=!0;else{this._blockhashInfo.transactionSignatures.push(f);break}}}const i=t.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(t,e){const r=wt(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],u=await this._rpcRequest("sendTransaction",o),f=st(u,Gh);if("error"in f){let g;throw"data"in f.error&&(g=f.error.data.logs),new Zr({action:s?"send":"simulate",signature:"",transactionMessage:f.error.message,logs:g})}return f.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 u=await this._rpcWebSocket.call(o,i);this._setSubscription(r,{...s,serverSubscriptionId:u,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[u]=s.callbacks,await this._updateSubscriptions()}catch(u){if(console.error(`Received ${u instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:u}),!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(u){if(u instanceof Error&&console.error(`${o} error:`,u.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,wh);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,s=Wo([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,kh);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),u=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:Go(s)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},u)}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,Yh);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=st(t,Sh);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,Ih);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,Eh);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,u)=>{if(o.type==="status"){e(o.result,u);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),u=this._makeSubscription({callback:(f,g)=>{e(f,g);try{this.removeSignatureListener(u)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return u}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:r}=st(t,Ah);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??Po()}static generate(){return new Pr(Po())}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 Qh{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(Di.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 Di{constructor(){}static createLookupTable(t){const[e,r]=it.findProgramAddressSync([t.authority.toBuffer(),si.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})}}Di.programId=new it("AddressLookupTab1e1111111111111111111111111");class tf{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(qe))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(qe.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Rt(qe.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Rt(qe.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Rt(qe.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(qi.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const qe=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 qi{constructor(){}static requestUnits(t){const e=qe.RequestUnits,r=It(e,t);return new Pt({keys:[],programId:this.programId,data:r})}static requestHeapFrame(t){const e=qe.RequestHeapFrame,r=It(e,t);return new Pt({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(t){const e=qe.SetComputeUnitLimit,r=It(e,t);return new Pt({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(t){const e=qe.SetComputeUnitPrice,r=It(e,{microLamports:BigInt(t.microLamports)});return new Pt({keys:[],programId:this.programId,data:r})}}qi.programId=new it("ComputeBudget111111111111111111111111111111");const aa=64,ca=32,ua=64,la=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===ca,`Public Key must be ${ca} bytes but received ${e.length} bytes`),Et(s.length===ua,`Signature must be ${ua} bytes but received ${s.length} bytes`);const o=la.span,u=o+e.length,f=u+s.length,g=1,w=ht.Buffer.alloc(f+r.length),k=i??65535;return la.encode({numSignatures:g,padding:0,signatureOffset:u,signatureInstructionIndex:k,publicKeyOffset:o,publicKeyInstructionIndex:k,messageDataOffset:f,messageDataSize:r.length,messageInstructionIndex:k},w),w.fill(e,o),w.fill(s,u),w.fill(r,f),new Pt({keys:[],programId:Tn.programId,data:w})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;Et(e.length===aa,`Private key must be ${aa} bytes but received ${e.length} bytes`);try{const i=Pr.fromSecretKey(e),o=i.publicKey.toBytes(),u=ki(r,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:u,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Tn.programId=new it("Ed25519SigVerify111111111111111111111111111");const ef=(n,t)=>{const e=bn.sign(n,t);return[e.toCompactRawBytes(),e.recovery]};bn.utils.isValidPrivateKey;const rf=bn.getPublicKey,ha=32,Ki=20,fa=64,nf=11,Wi=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 Lr{constructor(){}static publicKeyToEthAddress(t){Et(t.length===fa,`Public key must be ${fa} bytes but received ${t.length} bytes`);try{return ht.Buffer.from(Eo(wt(t))).slice(-Ki)}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 Lr.createInstructionWithEthAddress({ethAddress:Lr.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 u;typeof e=="string"?e.startsWith("0x")?u=ht.Buffer.from(e.substr(2),"hex"):u=ht.Buffer.from(e,"hex"):u=e,Et(u.length===Ki,`Address must be ${Ki} bytes but received ${u.length} bytes`);const f=1+nf,g=f,w=f+u.length,k=w+s.length+1,M=1,R=ht.Buffer.alloc(Wi.span+r.length);return Wi.encode({numSignatures:M,signatureOffset:w,signatureInstructionIndex:o,ethAddressOffset:g,ethAddressInstructionIndex:o,messageDataOffset:k,messageDataSize:r.length,messageInstructionIndex:o,signature:wt(s),ethAddress:wt(u),recoveryId:i},R),R.fill(wt(r),Wi.span),new Pt({keys:[],programId:Lr.programId,data:R})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:s}=t;Et(e.length===ha,`Private key must be ${ha} bytes but received ${e.length} bytes`);try{const i=wt(e),o=rf(i,!1).slice(1),u=ht.Buffer.from(Eo(wt(r))),[f,g]=ef(u,i);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:f,recoveryId:g,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Lr.programId=new it("KeccakSecp256k11111111111111111111111111111");var da;const pa=new it("StakeConfig11111111111111111111111111111111");class ga{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}}da=Xr,Xr.default=new da(0,0,it.default);class sf{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 ga(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"),ll(),hl()])},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")])}}),of=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,u=It(o,{authorized:{staker:wt(r.staker.toBuffer()),withdrawer:wt(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:wt(i.custodian.toBuffer())}}),f={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Rr,isSigner:!1,isWritable:!1}],programId:this.programId,data:u};return new Pt(f)}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:De,isSigner:!1,isWritable:!1},{pubkey:In,isSigner:!1,isWritable:!1},{pubkey:pa,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,u=me.Authorize,f=It(u,{newAuthorized:wt(s.toBuffer()),stakeAuthorizationType:i.index}),g=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:De,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:f})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:u,custodianPubkey:f}=t,g=me.AuthorizeWithSeed,w=It(g,{newAuthorized:wt(o.toBuffer()),stakeAuthorizationType:u.index,authoritySeed:s,authorityOwner:wt(i.toBuffer())}),k=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:De,isSigner:!1,isWritable:!1}];return f&&k.push({pubkey:f,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,u=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:u})}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:u,lamports:f}=t,g=new Bt;return g.add(ye.allocate({accountPubkey:i,basePubkey:o,seed:u,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:f}))}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:De,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,u=me.Withdraw,f=It(u,{lamports:i}),g=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:De,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:f})}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:De,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}Mn.programId=new it("Stake11111111111111111111111111111111111111"),Mn.space=200;class ya{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 af{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(Ke))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(Ke.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new ya(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(Ke.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(Ke.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(Ke.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(Cr.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 Ke=Object.freeze({InitializeAccount:{index:0,layout:P.struct([P.u32("instruction"),fl()])},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"),dl()])}}),cf=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Cr{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:s}=t,i=Ke.InitializeAccount,o=It(i,{voteInit:{nodePubkey:wt(s.nodePubkey.toBuffer()),authorizedVoter:wt(s.authorizedVoter.toBuffer()),authorizedWithdrawer:wt(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),u={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Rr,isSigner:!1,isWritable:!1},{pubkey:De,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Pt(u)}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=Ke.Authorize,u=It(o,{newAuthorized:wt(s.toBuffer()),voteAuthorizationType:i.index}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:De,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Bt().add({keys:f,programId:this.programId,data:u})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:u}=t,f=Ke.AuthorizeWithSeed,g=It(f,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:wt(r.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:wt(i.toBuffer()),voteAuthorizationType:o.index}}),w=[{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:De,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=Ke.Withdraw,u=It(o,{lamports:s}),f=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Bt().add({keys:f,programId:this.programId,data:u})}static safeWithdraw(t,e,r){if(t.lamports>e-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return Cr.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,nodePubkey:s}=t,i=Ke.UpdateValidatorIdentity,o=It(i),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Bt().add({keys:u,programId:this.programId,data:o})}}Cr.programId=new it("Vote111111111111111111111111111111111111111"),Cr.space=3762;const ma=new it("Va1idator1nfo111111111111111111111111111111"),uf=tt({name:nt(),website:lt(nt()),details:lt(nt()),iconUrl:lt(nt()),keybaseUsername:lt(nt())});class $i{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(Ae(e,0,Fe)),u=ze(e)===1;s.push({publicKey:o,isSigner:u})}if(s[0].publicKey.equals(ma)&&s[1].isSigner){const i=dr().decode(ht.Buffer.from(e)),o=JSON.parse(i);return oo(o,uf),new $i(s[1].publicKey,o)}return null}}const lf=new it("Vote111111111111111111111111111111111111111"),hf=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 Hi{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=hf.decode(wt(t),4);let s=r.rootSlot;return r.rootSlotValid||(s=null),new Hi({nodePubkey:new it(r.nodePubkey),authorizedWithdrawer:new it(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:s,authorizedVoters:r.authorizedVoters.map(ff),priorVoters:df(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function ff({authorizedVoter:n,epoch:t}){return{epoch:t,authorizedVoter:new it(n)}}function wa({authorizedPubkey:n,epochOfLastAuthorizedSwitch:t,targetEpoch:e}){return{authorizedPubkey:new it(n),epochOfLastAuthorizedSwitch:t,targetEpoch:e}}function df({buf:n,idx:t,isEmpty:e}){return e?[]:[...n.slice(t+1).map(wa),...n.slice(0,t).map(wa)]}const ba={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 pf(n,t){const e=t===!1?"http":"https";if(!n)return ba[e].devnet;const r=ba[e][n];if(!r)throw new Error(`Unknown ${e} cluster: ${n}`);return r}async function gf(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},u=await n.sendRawTransaction(t,o),f=i&&i.commitment,w=(await(s?n.confirmTransaction(s,f):n.confirmTransaction(u,f))).value;if(w.err)throw u!=null?new Zr({action:o!=null&&o.skipPreflight?"send":"simulate",signature:u,transactionMessage:`Status: (${JSON.stringify(w)})`}):new Error(`Raw transaction ${u} failed (${JSON.stringify(w)})`);return u}const Pn=Object.freeze(Object.defineProperty({__proto__:null,Account:al,AddressLookupTableAccount:Mi,AddressLookupTableInstruction:Qh,AddressLookupTableProgram:Di,Authorized:ga,BLOCKHASH_CACHE_TIMEOUT_MS:jo,BPF_LOADER_DEPRECATED_PROGRAM_ID:cl,BPF_LOADER_PROGRAM_ID:Il,BpfLoader:El,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:qe,ComputeBudgetInstruction:tf,ComputeBudgetProgram:qi,Connection:Xh,Ed25519Program:Tn,Enum:sl,EpochSchedule:$o,FeeCalculatorLayout:Do,Keypair:Pr,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Ze,Loader:yr,Lockup:Xr,MAX_SEED_LENGTH:Oo,Message:Le,MessageAccountKeys:Gr,MessageV0:pr,NONCE_ACCOUNT_LENGTH:_i,NonceAccount:En,PACKET_DATA_SIZE:er,PUBLIC_KEY_LENGTH:Fe,PublicKey:it,SIGNATURE_LENGTH_IN_BYTES:jr,SOLANA_SCHEMA:Vr,STAKE_CONFIG_ID:pa,STAKE_INSTRUCTION_LAYOUTS:me,SYSTEM_INSTRUCTION_LAYOUTS:Ut,SYSVAR_CLOCK_PUBKEY:De,SYSVAR_EPOCH_SCHEDULE_PUBKEY:gl,SYSVAR_INSTRUCTIONS_PUBKEY:yl,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:xn,SYSVAR_RENT_PUBKEY:Rr,SYSVAR_REWARDS_PUBKEY:ml,SYSVAR_SLOT_HASHES_PUBKEY:wl,SYSVAR_SLOT_HISTORY_PUBKEY:bl,SYSVAR_STAKE_HISTORY_PUBKEY:In,Secp256k1Program:Lr,SendTransactionError:Zr,SolanaJSONRPCError:ut,SolanaJSONRPCErrorCode:kl,StakeAuthorizationLayout:of,StakeInstruction:sf,StakeProgram:Mn,Struct:vi,SystemInstruction:Sl,SystemProgram:ye,Transaction:Bt,TransactionExpiredBlockheightExceededError:Si,TransactionExpiredNonceInvalidError:_r,TransactionExpiredTimeoutError:xi,TransactionInstruction:Pt,TransactionMessage:Ei,TransactionStatus:Ge,VALIDATOR_INFO_KEY:ma,VERSION_PREFIX_MASK:vn,VOTE_PROGRAM_ID:lf,ValidatorInfo:$i,VersionedMessage:Ii,VersionedTransaction:Ai,VoteAccount:Hi,VoteAuthorizationLayout:cf,VoteInit:ya,VoteInstruction:af,VoteProgram:Cr,clusterApiUrl:pf,sendAndConfirmRawTransaction:gf,sendAndConfirmTransaction:Bi},Symbol.toStringTag,{value:"Module"})),rr=ge;var Vi={exports:{}},ka;function yf(){return ka||(ka=1,function(n){var t=function(){var e=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(f,g){if(!i[f]){i[f]={};for(var w=0;w<f.length;w++)i[f][f.charAt(w)]=w}return i[f][g]}var u={compressToBase64:function(f){if(f==null)return"";var g=u._compress(f,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(f){return f==null?"":f==""?null:u._decompress(f.length,32,function(g){return o(r,f.charAt(g))})},compressToUTF16:function(f){return f==null?"":u._compress(f,15,function(g){return e(g+32)})+" "},decompressFromUTF16:function(f){return f==null?"":f==""?null:u._decompress(f.length,16384,function(g){return f.charCodeAt(g)-32})},compressToUint8Array:function(f){for(var g=u.compress(f),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(f){if(f==null)return u.decompress(f);for(var g=new Array(f.length/2),w=0,k=g.length;w<k;w++)g[w]=f[w*2]*256+f[w*2+1];var M=[];return g.forEach(function(R){M.push(e(R))}),u.decompress(M.join(""))},compressToEncodedURIComponent:function(f){return f==null?"":u._compress(f,6,function(g){return s.charAt(g)})},decompressFromEncodedURIComponent:function(f){return f==null?"":f==""?null:(f=f.replace(/ /g,"+"),u._decompress(f.length,32,function(g){return o(s,f.charAt(g))}))},compress:function(f){return u._compress(f,16,function(g){return e(g)})},_compress:function(f,g,w){if(f==null)return"";var k,M,R={},C={},B="",T="",U="",W=2,D=3,J=2,$=[],F=0,Y=0,Z;for(Z=0;Z<f.length;Z+=1)if(B=f.charAt(Z),Object.prototype.hasOwnProperty.call(R,B)||(R[B]=D++,C[B]=!0),T=U+B,Object.prototype.hasOwnProperty.call(R,T))U=T;else{if(Object.prototype.hasOwnProperty.call(C,U)){if(U.charCodeAt(0)<256){for(k=0;k<J;k++)F=F<<1,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++;for(M=U.charCodeAt(0),k=0;k<8;k++)F=F<<1|M&1,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++,M=M>>1}else{for(M=1,k=0;k<J;k++)F=F<<1|M,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++,M=0;for(M=U.charCodeAt(0),k=0;k<16;k++)F=F<<1|M&1,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++,M=M>>1}W--,W==0&&(W=Math.pow(2,J),J++),delete C[U]}else for(M=R[U],k=0;k<J;k++)F=F<<1|M&1,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++,M=M>>1;W--,W==0&&(W=Math.pow(2,J),J++),R[T]=D++,U=String(B)}if(U!==""){if(Object.prototype.hasOwnProperty.call(C,U)){if(U.charCodeAt(0)<256){for(k=0;k<J;k++)F=F<<1,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++;for(M=U.charCodeAt(0),k=0;k<8;k++)F=F<<1|M&1,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++,M=M>>1}else{for(M=1,k=0;k<J;k++)F=F<<1|M,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++,M=0;for(M=U.charCodeAt(0),k=0;k<16;k++)F=F<<1|M&1,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++,M=M>>1}W--,W==0&&(W=Math.pow(2,J),J++),delete C[U]}else for(M=R[U],k=0;k<J;k++)F=F<<1|M&1,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++,M=M>>1;W--,W==0&&(W=Math.pow(2,J),J++)}for(M=2,k=0;k<J;k++)F=F<<1|M&1,Y==g-1?(Y=0,$.push(w(F)),F=0):Y++,M=M>>1;for(;;)if(F=F<<1,Y==g-1){$.push(w(F));break}else Y++;return $.join("")},decompress:function(f){return f==null?"":f==""?null:u._decompress(f.length,32768,function(g){return f.charCodeAt(g)})},_decompress:function(f,g,w){var k=[],M=4,R=4,C=3,B="",T=[],U,W,D,J,$,F,Y,Z={val:w(0),position:g,index:1};for(U=0;U<3;U+=1)k[U]=U;for(D=0,$=Math.pow(2,2),F=1;F!=$;)J=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),D|=(J>0?1:0)*F,F<<=1;switch(D){case 0:for(D=0,$=Math.pow(2,8),F=1;F!=$;)J=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),D|=(J>0?1:0)*F,F<<=1;Y=e(D);break;case 1:for(D=0,$=Math.pow(2,16),F=1;F!=$;)J=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),D|=(J>0?1:0)*F,F<<=1;Y=e(D);break;case 2:return""}for(k[3]=Y,W=Y,T.push(Y);;){if(Z.index>f)return"";for(D=0,$=Math.pow(2,C),F=1;F!=$;)J=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),D|=(J>0?1:0)*F,F<<=1;switch(Y=D){case 0:for(D=0,$=Math.pow(2,8),F=1;F!=$;)J=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),D|=(J>0?1:0)*F,F<<=1;k[R++]=e(D),Y=R-1,M--;break;case 1:for(D=0,$=Math.pow(2,16),F=1;F!=$;)J=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),D|=(J>0?1:0)*F,F<<=1;k[R++]=e(D),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=W+W.charAt(0);else return null;T.push(B),k[R++]=W+B.charAt(0),M--,W=B,M==0&&(M=Math.pow(2,C),C++)}}};return u}();n!=null?n.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})}(Vi)),Vi.exports}var mf=yf();const Ce=Nr(mf);var ji=(n=>(n.USD="USD",n.EUR="EUR",n.GBP="GBP",n.BRL="BRL",n.ARS="ARS",n.BHD="BHD",n.BWP="BWP",n.BND="BND",n.BGN="BGN",n.CLP="CLP",n.HRK="HRK",n.DJF="DJF",n.DOP="DOP",n.EGP="EGP",n.GEL="GEL",n.HUF="HUF",n.ISK="ISK",n.INR="INR",n.ILS="ILS",n.JMD="JMD",n.JOD="JOD",n.KZT="KZT",n.KWD="KWD",n.KGS="KGS",n.LVL="LVL",n.LTL="LTL",n.MWK="MWK",n.MYR="MYR",n.MUR="MUR",n.MXN="MXN",n.MAD="MAD",n.NAD="NAD",n.NZD="NZD",n.PEN="PEN",n.PHP="PHP",n.PLN="PLN",n.RON="RON",n.SAR="SAR",n.SGD="SGD",n.LKR="LKR",n.TWD="TWD",n.TZS="TZS",n.THB="THB",n.TRY="TRY",n.UAH="UAH",n))(ji||{});const va={USD:"USD",EUR:"EUR",GBP:"GBP",BRL:"BRL"};function wf(n){return n in va}class We{constructor(t){fe(this,"env");fe(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==="ngrok"?"https://coinflow.ngrok.app":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,presentment:u,transaction:f,blockchain:g="solana",webhookInfo:w,email:k,loaderBackground:M,handleHeightChangeId:R,bankAccountLinkRedirect:C,additionalWallets:B,nearDeposit:T,chargebackProtectionData:U,merchantCss:W,color:D,rent:J,lockDefaultToken:$,tokens:F,planCode:Y,disableApplePay:Z,disableGooglePay:X,customerInfo:q,settlementType:V,lockAmount:Q,nativeSolToConvert:x,theme:a,usePermit:p,transactionSigner:y,authOnly:E,deviceId:S,jwtToken:I,origins:O,threeDsChallengePreference:v,supportEmail:c,destinationAuthKey:l,allowedPaymentMethods:b}){var j;const _=s?`/${s}/${g}`:`/${g}`,L=new URL(_+r,We.getCoinflowBaseUrl(i));if(t&&L.searchParams.append("pubkey",t),e&&L.searchParams.append("sessionKey",e),f&&L.searchParams.append("transaction",f),o&&("cents"in o?(L.searchParams.append("cents",o.cents.toString()),"currency"in o?L.searchParams.append("currency",o.currency.toString()):L.searchParams.append("currency",ji.USD)):(L.searchParams.append("token",o.address.toString()),L.searchParams.append("amount",o.amount.toString()))),u&&L.searchParams.append("presentment",u),w&&L.searchParams.append("webhookInfo",Ce.compressToEncodedURIComponent(JSON.stringify(w))),a&&L.searchParams.append("theme",Ce.compressToEncodedURIComponent(JSON.stringify(a))),q&&L.searchParams.append("customerInfo",Ce.compressToEncodedURIComponent(JSON.stringify(q))),k&&L.searchParams.append("email",k),c&&L.searchParams.append("supportEmail",c),F&&L.searchParams.append("tokens",F.toString()),M&&L.searchParams.append("loaderBackground",M),R&&L.searchParams.append("useHeightChange",R.toString()),C&&L.searchParams.append("bankAccountLinkRedirect",C),B&&L.searchParams.append("additionalWallets",Ce.compressToEncodedURIComponent(JSON.stringify(B))),T&&L.searchParams.append("nearDeposit",T),U&&L.searchParams.append("chargebackProtectionData",Ce.compressToEncodedURIComponent(JSON.stringify(U))),S)L.searchParams.append("deviceId",S);else if(typeof window<"u"){const rt=(j=window==null?void 0:window.nSureSDK)==null?void 0:j.getDeviceId();rt&&L.searchParams.append("deviceId",rt)}return W&&L.searchParams.append("merchantCss",W),D&&L.searchParams.append("color",D),J&&L.searchParams.append("rent",J.lamports.toString()),x&&L.searchParams.append("nativeSolToConvert",x.lamports.toString()),$&&L.searchParams.append("lockDefaultToken","true"),Y&&L.searchParams.append("planCode",Y),Z&&L.searchParams.append("disableApplePay","true"),X&&L.searchParams.append("disableGooglePay","true"),V&&L.searchParams.append("settlementType",V),Q&&L.searchParams.append("lockAmount","true"),p===!1&&L.searchParams.append("usePermit","false"),y&&L.searchParams.append("transactionSigner",y),E===!0&&L.searchParams.append("authOnly","true"),I&&L.searchParams.append("jwtToken",I),O&&L.searchParams.append("origins",Ce.compressToEncodedURIComponent(JSON.stringify(O))),b&&L.searchParams.append("allowedPaymentMethods",b.join(",")),v&&L.searchParams.append("threeDsChallengePreference",v),l&&L.searchParams.append("destinationAuthKey",l),L.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 Ce.compressToEncodedURIComponent(JSON.stringify(e))},eth:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Ce.compressToEncodedURIComponent(JSON.stringify(e))},base:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Ce.compressToEncodedURIComponent(JSON.stringify(e))},arbitrum:()=>{if(!("transaction"in t))return;const{transaction:e}=t;return Ce.compressToEncodedURIComponent(JSON.stringify(e))},near:()=>{if(!("action"in t))return;const{action:e}=t;return Ce.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!")}}}function bf(n){if(!n)return;let t,e;if("name"in n&&n.name&&(t=n.name.split(" ")[0],e=n.name.split(" ").slice(1).join(" ")),"firstName"in n&&n.firstName&&(t=n.firstName),"lastName"in n&&n.lastName&&(e=n.lastName),t&&e)return{firstName:t,lastName:e}}var Gi=(n=>(n.SignMessage="signMessage",n.SignTransaction="signTransaction",n.SendTransaction="sendTransaction",n.HeightChange="heightChange",n.Success="success",n.AuthDeclined="authDeclined",n.Loaded="loaded",n.AccountLinked="accountLinked",n))(Gi||{});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 Sa(n,t,e){let r;try{if(r=JSON.parse(n),!("method"in r)||!("data"in r))return}catch(o){console.error("handleIFrameMessage JSON parse",o);return}const{data:s,method:i}=r;switch(i){case"signMessage":return t.handleSignMessage?t.handleSignMessage(s):void 0;case"signTransaction":return t.handleSignTransaction?t.handleSignTransaction(s):void 0;case"sendTransaction":return t.handleSendTransaction(s);case"heightChange:"+e:return t.handleHeightChange?t.handleHeightChange(s):void 0;case"success":if(!t.onSuccess)return;t.onSuccess(r.info);return;case"authDeclined":if(!t.onAuthDeclined)return;t.onAuthDeclined(r.info);return;case"loaded":return;case"accountLinked":return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${i} is not one of ${Object.values(Gi)}`)}function Cn(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?We.byBlockchain(t,{solana:()=>kf({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),near:()=>vf({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),eth:()=>On({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),polygon:()=>On({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),base:()=>On({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),arbitrum:()=>On({wallet:e,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),user:()=>Sf(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,onAuthDeclined:n.onAuthDeclined}}function kf({wallet:n,onSuccess:t,onAuthDeclined:e}){return{handleSendTransaction:async r=>{const s=xa(r);return await n.sendTransaction(s)},handleSignMessage:async r=>{const s=n.signMessage;if(!s)throw new Error("signMessage is not supported by this wallet");const i=await s(new TextEncoder().encode(r));if(!rr)throw new Error("bs58 dependency is required");return rr.encode(i)},handleSignTransaction:async r=>{const s=n.signTransaction;if(!s)throw new Error("signTransaction is not supported by this wallet");const i=xa(r),o=await s(i);if(!rr)throw new Error("bs58 dependency is required");return rr.encode(o.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:t,onAuthDeclined:e}}function xa(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 vf({wallet:n,onSuccess:t,onAuthDeclined:e}){return{handleSendTransaction:async r=>{const s=JSON.parse(Buffer.from(r,"base64").toString()),i=await n.signAndSendTransaction(s);if(!i)throw new Error("Transaction did not send");const{transaction:o}=i;return o.hash},onSuccess:t,onAuthDeclined:e}}function On({wallet:n,onSuccess:t,onAuthDeclined:e}){return{handleSendTransaction:async r=>{const s=JSON.parse(Buffer.from(r,"base64").toString()),{hash:i}=await n.sendTransaction(s);return i},handleSignMessage:async r=>n.signMessage(r),onSuccess:t,onAuthDeclined:e}}function Sf({onSuccess:n,onAuthDeclined:t}){return{handleSendTransaction:async()=>Promise.resolve(""),onSuccess:n,onAuthDeclined:t}}const Qr="tokenExCardNumber",Or="tokenExCardCvv",Ia={[br.VISA]:"visa",[br.MASTERCARD]:"masterCard",[br.AMEX]:"americanExpress",[br.DISCOVER]:"discover"};async function Ea(n){const{token:t,origins:e,env:r}=n;return new Promise((s,i)=>{fetch(new We(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 Zi({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 xf({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 Aa(n){const{token:t,cardType:e}=n;return await Yi(Or,n,{cvvOnly:!0,cvv:!0,cvvContainerID:Or,placeholder:"CVV",token:t,cardType:Ia[e]})}async function Ba(n){return await Yi(Qr,n,{cvv:!0,cvvContainerID:Or,cvvPlaceholder:"CVV"})}async function _a(n){return await Yi(Qr,n,{cvv:!1})}async function Yi(n,t,e){const{tokenExScriptLoaded:r,css:s,debug:i,font:o,setCachedToken:u,setLoaded:f}=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 Ea({...t,token:e.token}),{styles:w}=If(s),k={...g,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:w,font:o,debug:i??!1,...e},M=TokenEx.Iframe(n,k);return xf({iframe:M,setCachedToken:u,setLoaded:f})}function If(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 Ef=et.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return We.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(We.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:n,origin:t});const e=Sa(n,this.args,this.args.handleHeightChangeId);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(We.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)}}}),Ji=(n,t)=>{const e=n.__vccOpts||n;for(const[r,s]of t)e[r]=s;return e},Af=["src","scrolling"];function Bf(n,t,e,r,s,i){return et.openBlock(),et.createElementBlock("iframe",{credentialless:"",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,Af)}const Un=Ji(Ef,[["render",Bf]]),_f=et.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:Un},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Ln(this.args);return{...this.args,walletPubkey:n,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...Cn(this.args),handleHeightChange:this.args.handleHeightChange}}}});function Rf(n,t,e,r,s,i){const o=et.resolveComponent("coinflow-i-frame");return et.openBlock(),et.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const Tf=Ji(_f,[["render",Rf]]),Mf=et.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:Un},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Ln(this.args);return{...this.args,walletPubkey:n,route:`/purchase-v2/${this.args.merchantId}`,transaction:We.getTransaction(this.args)}},messageHandlers(){return{...Cn(this.args),handleHeightChange:this.args.handleHeightChange}}}});function Pf(n,t,e,r,s,i){const o=et.resolveComponent("coinflow-i-frame");return et.openBlock(),et.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const Lf=Ji(Mf,[["render",Pf]]),Xi=n=>{const t=et.ref(!1),e=et.ref(!1),r=et.ref(void 0),s=et.ref(void 0);et.onMounted(()=>{Zi({env:n.env,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),e.value=!0}})});const i=k=>s.value=k,o=()=>t.value=!0,u=k=>r.value=k,f=async k=>{const M=await Aa({...n,...k,tokenExScriptLoaded:e.value,setCachedToken:i,setLoaded:o});return u(M),M},g=async k=>{const M=await Ba({...n,...k,tokenExScriptLoaded:e.value,setCachedToken:i,setLoaded:o});return u(M),M},w=async k=>{const M=await _a({...n,...k,tokenExScriptLoaded:e.value,setCachedToken:i,setLoaded:o});return u(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:f,initializeTokenExCardOnlyIframe:w,loaded:t,cachedToken:s,setTokenExScriptTag:Zi,tokenExScriptLoaded:e}},Cf=["id"],Of=et.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{initializeTokenExIframe:e,tokenExIframe:r}=Xi(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,u)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Qr)},null,8,Cf))}}),Uf=["id"],Nf=et.defineComponent({__name:"CoinflowCvvInput",setup(n){return(t,e)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Or)},null,8,Uf))}}),Ff=["id"],zf=et.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{initializeCvvOnlyTokenExIframe:e,tokenExIframe:r}=Xi(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,u)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Or)},null,8,Ff))}}),Df=et.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(n){const t=et.ref(void 0);et.onMounted(()=>new We(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
|
-
};`,u=document.createElement("script");u.innerHTML=o,document.head.appendChild(u),s(()=>{document.head.removeChild(i),document.head.removeChild(u)})}),(s,i)=>null}}),zf=["id"],qf=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,u)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Qr)},null,8,zf))}}),Df={style:{position:"relative",height:"100%"}},Kf={style:{position:"relative",zIndex:10,height:"100%"}},_a=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 f=Cn(n.args);return{...n.args,walletPubkey:f,transaction:void 0,routePrefix:"form",route:`/${n.route}/${n.args.merchantId}`}}function r(){return{...Ln(n.args),handleHeightChange:n.args.handleHeightChange}}const s=et.ref(.8),i=et.ref("flex"),o=Math.random().toString(16).substring(2);function u({data:f}){var g,w;try{const k=JSON.parse(f);if("method"in k&&k.method==="loaded"&&(s.value=1,setTimeout(()=>{i.value="none"},2e3)),"method"in k&&k.data.startsWith("ERROR"))return(w=(g=n.args)==null?void 0:g.onError)==null||w.call(g,k.info),!1;if(!("method"in k)||k.method!=="getToken")return}catch{return}t==null||t(f)}return(f,g)=>(et.openBlock(),et.createElementBlock("div",Df,[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(f.$slots,"default")],4),et.createElementVNode("div",Kf,[et.createVNode(Un,{onOnMessage:u,args:{...e(),...r(),handleHeightChangeId:et.unref(o)}},null,8,["args"])])]))}}),Wf={id:"svg-logo",viewBox:"0 0 35 15"},$f={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"},Hf={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},Vf=["fill"],jf=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",Wf,[(et.openBlock(),et.createElementBlock("svg",$f,[r[1]||(r[1]=et.createElementVNode("title",null,"Apple Logo",-1)),et.createElementVNode("g",Hf,[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,Vf)])]))]))}}),Gf=et.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(et.openBlock(),et.createBlock(_a,{route:"apple-pay",args:n.args},{default:et.withCtx(()=>[et.createVNode(jf,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}}),Zf={key:0,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Yf={key:1,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Jf=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",Zf,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",Yf,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))}}),Xf=et.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(et.openBlock(),et.createBlock(_a,{route:"google-pay",args:n.args,overlayDisplayOverride:"flex",alignItems:"center"},{default:et.withCtx(()=>[et.createVNode(Jf,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}});yt.CARD_TYPE_MAPPING=xa,yt.CardType=br,yt.CoinflowApplePayButton=Gf,yt.CoinflowCardNumberInput=Cf,yt.CoinflowCardNumberOnlyInput=qf,yt.CoinflowCvvInput=Of,yt.CoinflowCvvOnlyInput=Nf,yt.CoinflowGooglePayButton=Xf,yt.CoinflowIframe=Un,yt.CoinflowPurchase=Mf,yt.CoinflowPurchaseProtection=Ff,yt.CoinflowUtils=We,yt.CoinflowWithdraw=_f,yt.Currency=ji,yt.MerchantStyle=ms,yt.PaymentMethods=bs,yt.SettlementType=ir,yt.ThreeDsChallengePreference=ws,yt.TokenExCardNumberIframeId=Qr,yt.TokenExCvvContainerID=Or,yt.doInitializeCvvOnlyTokenExIframe=Ea,yt.doInitializeTokenExCardOnlyIframe=Ba,yt.doInitializeTokenExIframe=Aa,yt.getCustomerName=mf,yt.getHandlers=Ln,yt.getIframeConfig=Ia,yt.getWalletPubkey=Cn,yt.handleIFrameMessage=va,yt.setTokenExScriptTag=Gi,Object.defineProperty(yt,Symbol.toStringTag,{value:"Module"})});
|
|
18
|
+
};`,u=document.createElement("script");u.innerHTML=o,document.head.appendChild(u),s(()=>{document.head.removeChild(i),document.head.removeChild(u)})}),(s,i)=>null}}),qf=["id"],Kf=et.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:t}){const{tokenExIframe:e,initializeTokenExCardOnlyIframe:r}=Xi(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,u)=>(et.openBlock(),et.createElementBlock("div",{id:et.unref(Qr)},null,8,qf))}}),Wf={style:{position:"relative",height:"100%"}},$f={style:{position:"relative",zIndex:10,height:"100%"}},Ra=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 f=Ln(n.args);return{...n.args,walletPubkey:f,transaction:void 0,routePrefix:"form",route:`/${n.route}/${n.args.merchantId}`}}function r(){return{...Cn(n.args),handleHeightChange:n.args.handleHeightChange}}const s=et.ref(.8),i=et.ref("flex"),o=Math.random().toString(16).substring(2);function u({data:f}){var g,w;try{const k=JSON.parse(f);if("method"in k&&k.method==="loaded"&&(s.value=1,setTimeout(()=>{i.value="none"},2e3)),"method"in k&&k.data.startsWith("ERROR"))return(w=(g=n.args)==null?void 0:g.onError)==null||w.call(g,k.info),!1;if(!("method"in k)||k.method!=="getToken")return}catch{return}t==null||t(f)}return(f,g)=>(et.openBlock(),et.createElementBlock("div",Wf,[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(f.$slots,"default")],4),et.createElementVNode("div",$f,[et.createVNode(Un,{onOnMessage:u,args:{...e(),...r(),handleHeightChangeId:et.unref(o)}},null,8,["args"])])]))}}),Hf={id:"svg-logo",viewBox:"0 0 35 15"},Vf={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"},jf={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},Gf=["fill"],Zf=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",Hf,[(et.openBlock(),et.createElementBlock("svg",Vf,[r[1]||(r[1]=et.createElementVNode("title",null,"Apple Logo",-1)),et.createElementVNode("g",jf,[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,Gf)])]))]))}}),Yf=et.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(et.openBlock(),et.createBlock(Ra,{route:"apple-pay",args:n.args},{default:et.withCtx(()=>[et.createVNode(Zf,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}}),Jf={key:0,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Xf={key:1,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Qf=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",Jf,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",Xf,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))}}),td=et.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(n){return(t,e)=>(et.openBlock(),et.createBlock(Ra,{route:"google-pay",args:n.args,overlayDisplayOverride:"flex",alignItems:"center"},{default:et.withCtx(()=>[et.createVNode(Qf,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}});pt.CARD_TYPE_MAPPING=Ia,pt.CardType=br,pt.CoinflowApplePayButton=Yf,pt.CoinflowCardNumberInput=Of,pt.CoinflowCardNumberOnlyInput=Kf,pt.CoinflowCvvInput=Nf,pt.CoinflowCvvOnlyInput=zf,pt.CoinflowGooglePayButton=td,pt.CoinflowIframe=Un,pt.CoinflowPurchase=Lf,pt.CoinflowPurchaseProtection=Df,pt.CoinflowUtils=We,pt.CoinflowWithdraw=Tf,pt.Currency=ji,pt.IFrameMessageMethods=Gi,pt.MerchantStyle=ws,pt.PaymentMethods=ks,pt.SettlementType=ir,pt.ThreeDsChallengePreference=bs,pt.TokenExCardNumberIframeId=Qr,pt.TokenExCvvContainerID=Or,pt.WithdrawCurrencies=va,pt.doInitializeCvvOnlyTokenExIframe=Aa,pt.doInitializeTokenExCardOnlyIframe=_a,pt.doInitializeTokenExIframe=Ba,pt.getCustomerName=bf,pt.getHandlers=Cn,pt.getIframeConfig=Ea,pt.getWalletPubkey=Ln,pt.handleIFrameMessage=Sa,pt.isWithdrawCurrency=wf,pt.setTokenExScriptTag=Zi,Object.defineProperty(pt,Symbol.toStringTag,{value:"Module"})});
|